0% found this document useful (0 votes)
13 views

Total Content Map SQL

SQL is a programming language used to manage and manipulate relational databases. A database is a structured collection of data organized to allow efficient retrieval, updating, and management. SQL serves as a standard language for communicating with databases, allowing users to perform operations like querying, inserting, updating, and deleting data. More advanced SQL topics include constraints, conditional logic, regular expressions, subqueries, stored procedures, views, and relational versus non-relational databases.

Uploaded by

Gaurav Salunkhe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Total Content Map SQL

SQL is a programming language used to manage and manipulate relational databases. A database is a structured collection of data organized to allow efficient retrieval, updating, and management. SQL serves as a standard language for communicating with databases, allowing users to perform operations like querying, inserting, updating, and deleting data. More advanced SQL topics include constraints, conditional logic, regular expressions, subqueries, stored procedures, views, and relational versus non-relational databases.

Uploaded by

Gaurav Salunkhe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SQL

Introduction Basics Advance

What is SQL? Databases Importance


of SQL

SQL (Structured Query Language) is a A database is a structured collection of It serves as a standard language for com-
domain-specific programming lan- data organized and stored in a way that municating with databases, allowing users

Constraints Conditional Logic


guage used for managing and manip- allows efficient retrieval, updating, and to perform various operations such as
ulating relational databases management of data. It serves as a querying data, inserting, updating, and Regular Expressions Subqueries Stored Procedures Views
centralized repository for information, deleting records, creating and modifying
making it easier to store, access, and database structures, and more.
manipulate data for various purposes.

Relational Non-Relational Case Expressions


Databases Databases
A stored procedure is a prepared
SQL code that can be saved,
reused, and shared.

MongoDB, Cassandra,
MySQL, PostgreSQL, Oracle
Couchbase, Redis, Amazon Performs conditional logic in SQL queries.
Database, Microsoft SQL • Views are virtual tables created by a query that can
DynamoDB, Firestore,
Server, SQLite, IBM Db2, Mari- Example: SELECT name, CASE WHEN score
Apache HBase be queried like actual tables.
aDB, Microsoft Access >= 90 THEN 'A' WHEN score >= 80 THEN 'B' • Create Views: Views are created using the CREATE
ELSE 'C' END AS grade FROM students; VIEW statement.
• Drop Views: Views can be deleted using the DROP
Primary Keys Foreign Keys Indexes VIEW statement to free up resources or change the
data model.
• Updatable Views: Some views are updatable, allow-
ing data modifications through the view.

A primary key is a unique identifier for A foreign key is a column or a set Indexes are data structures used to im-
each row in a table. It ensures that of columns in a table that refers prove the retrieval speed of data from a
each record is uniquely identifiable to the primary key of another database table. They act like a quick refer-
within the table. table. It establishes a relationship ence or pointer to the actual data. Indexes
between two tables, representing are created on one or more columns of a
a "parent-child" relationship. table, allowing the database to perform Non-correlated Correlated
faster searches and lookups.

A subquery that can be executed inde- A subquery that can be executed independently
pendently of the outer query. of the outer query.
Example: SELECT name FROM products WHERE Example: SELECT name FROM products WHERE
price > (SELECT AVG(price) FROM products). price > (SELECT AVG(price) FROM products).

^ (Start of Line) $ (End of Line) [abc] [a-z] [A-Z] [0-9] [^abc] . (Any Character) * (Zero or More) REGEXP REGEXP_REPLACE

Matches any character inside Matches any character not inside the Matches zero or more occurrences of A function used for replacing text in a string
the brackets. Matches any uppercase letter. the preceding element. based on a pattern.
Matches the start of a line. brackets.
Example: [A-Z]ello matches "Hello". Example: SELECT REGEXP_REPLACE('apple,
Example: ^Hello matches Example: [aeiou] matches any Example: [^0-9] matches any Example: ab*c matches "ac", "abc",
vowel. orange,banana', ',', '|')
"Hello, world!" non-digit. "abbc", and so on. returns "apple|orange|banana".

Matches the end of a line. Matches any digit.


Matches any lowercase letter. A function used for pattern matching in
Example: world!$ matches Example: [0-9][0-9] matches Matches any single character.
Example: [a-z]at matches "cat" and "hat". string data.
"Hello, world!" two-digit numbers. Example: c.t matches "cat" and "cot".
Example: SELECT * FROM products WHERE
name REGEXP 'shoe|sneaker'.

Data Types Operators Functions SQL Statements

Numeric Character String Date and Time Boolean Binary Miscellaneous


Datatypes Datatypes Datatypes Datatypes Datatypes Datatypes SELECT INSERT UPDATE DELETE

BOOLEAN or BOOL

BIGINT DECIMAL(p, s) The SELECT statement is used to The UPDATE statement is used to
INTEGER SMALLINT or NUMERIC(p, s) FLOAT(p)
ENUM SET retrieve data from a database modify existing records in a da-
Represents true or false values
Larger range of table. It allows you to specify the tabase table. You specify the
Whole numbers Approximate
The DELETE statement is
integers than INTEGER table, the columns to be updat-
(e.g., 1, 100, -42)
(e.g., -9,223,372,036,854,775,808
numeric values with A list of predefined values A set of predefined values columns you want to retrieve and
(e.g., 'red', 'green', 'blue')
floating-point precision (e.g., 'a', 'b', 'c') used to remove rows
to 9,223,372,036,854,775,807) the table(s) from which you want ed, and the new values for those
(records) from a data-
to retrieve the data. columns.
DATE TIME TIMESTAMP base table.
Smaller range of Exact numeric values The INSERT statement is
integers than INTEGER with specified precision 'p'
(e.g., -32,768 to 32,767) and scale 's' used to add new rows
Date and time
Date (e.g., '2023-08-01')
(e.g., '2023-08-01 12:30:45')
(records) into a data-
base table. You specify
the table and the values
Time (e.g., '12:30:45') you want to insert into
BINARY(n) VARBINARY(n) BLOB
each column.

Variable-length binary
Represents true or false values
data for large binary objects

CHAR(n) VARCHAR(n) TEXT Variable-length binary data


with a maximum length of 'n'

Aggregation Functions String Functions Date and Time Conditional Joins and Related
Numeric Functions Grouping Functions Subquery Functions
Functions Functions Functions
Fixed-length character Variable-length character
string with a specified length 'n' string for large text data

min: Returns the minimum value in a set of values. NOW() IF/ELSE (CASE)
Variable-length
DATE() COALESCE()
character string with Example: SELECT MIN(price) FROM products.
NULLIF()
a maximum length of 'n' max: Returns the maximum value in a set of values. EXTRACT()
DECODE()
Example: SELECT MAX(salary) FROM employees. DATEPART() (in some database systems)
avg: Calculates the average value of a set of values. DATEADD()
Example: SELECT AVG(age) FROM students. ROUND()
sum: Adds up all the values in a set. CONCAT() ABS()
IN
Example: SELECT SUM(quantity) FROM orders.
SUBSTRING() CEIL()
INNER JOIN EXISTS
count: Counts the number of values in a set.
LENGTH() FLOOR() ANY/SOME
LEFT JOIN (or LEFT OUTER JOIN)
Example: SELECT COUNT(*) FROM customers. POWER() RIGHT JOIN (or RIGHT OUTER JOIN) ALL
UPPER()
FULL JOIN (or FULL OUTER JOIN) NOT IN
LOWER()
UNION NOT EXISTS
UNION ALL

Arithmetic Operators Comparison Logical Pattern Matching NULL Comparison IN Operators BETWEEN Operators EXISTS Operators
Operators Operators Operators Operators

AND: Logical AND IS NULL: Checks if a value is NULL BETWEEN: Checks if a


+: Addition
OR: Logical OR (absence of value) value is within a specified range
-: Subtraction
*: Multiplication NOT: Logical NOT (negation)
/: Division
%: Modulo
(remainder after division) =: Equal to IN: Checks if a value
<> or !=: Not equal to is within a list of values EXISTS: Checks if a
<: Less than %: Matches any sequence of characters (wildcard) subquery returns any rows
>: Greater than _: Matches any single character (wildcard)
<=: Less than or equal to
>=: Greater than or equal to

You might also like