Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views

SQL Cheatsheet

Structured Query Language (SQL) is used to manage and organize data in relational databases. There are three main categories of SQL commands: Data Definition Language (DDL) defines database structure, Data Manipulation Language (DML) manipulates data, and Data Control Language (DCL) controls privileges. Some key DDL commands are CREATE, ALTER, and DROP while common DML commands include SELECT, INSERT, UPDATE, and DELETE. SQL allows users to retrieve, insert, update, and delete data from database tables.

Uploaded by

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

SQL Cheatsheet

Structured Query Language (SQL) is used to manage and organize data in relational databases. There are three main categories of SQL commands: Data Definition Language (DDL) defines database structure, Data Manipulation Language (DML) manipulates data, and Data Control Language (DCL) controls privileges. Some key DDL commands are CREATE, ALTER, and DROP while common DML commands include SELECT, INSERT, UPDATE, and DELETE. SQL allows users to retrieve, insert, update, and delete data from database tables.

Uploaded by

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

Our Internship Programs

SQL Data Sci ence


Arti fi ci al Intel l i gence

CHEATSHEET
Contact Us
+916381057440
www.digyquant.com

Structured Query Language, is a standard language for interacting with relational databases. It is used to manage and organize data in all kinds of systems in
which various data relationships need to be managed. There are several types of SQL commands, and they can be divided into different categories based on
their functions. Three of these categories are Data Definition Language (DDL), Data Manipulation Language (DML), and Control Language (CL).

These are commands that define the database structure or schema. It allows you to These are commands used to control
DDL CREATE, ALTER, and DROP the database objects like table, index, sequence, views, etc. DCL the privileges on the database objects.
DCL is used to manage the rights or
CREATE: Creates a new table or database. ALTER: Modifies an existing database object.
Command permissions that are provided to a
DROP: Deletes an entire table or database. TRUNCATE: Deletes all records from a table.
database user.
These are commands used for manipulating the data present in the database. DML allows
DML you to work with the data that is present in the database like inserting data, updating Command GRANT: Gives user's access privileges
to the database.
data, retrieving data, and deleting data from the database.
REVOKE: Takes back access privileges
SELECT: Retrieves data from the database. INSERT: Inserts data into a table.
Command given to the user.
UPDATE: Modifies data in a table. DELETE: Deletes data from a table.

Action ( DDL ) Description Action ( DML ) Description


---------------------------- ------------------------------------------------------------
--------------------------------------- --------------------------------------------------
INSERT INTO Insert new records into a table.
CREATE DATABASE Create a new database
UPDATE Update existing records in a table.
DELETE Delete existing records from a table. USE Switch to a database

SELECT (All Columns) Select all columns from a table. CREATE TABLE Create a new table
SELECT (Specific Columns) Select specific columns from a table.
ALTER TABLE (Add Column) Add a new column to a table
SELECT DISTINCT Select distinct (different) values of a column.
ALTER TABLE (Modify Column) Modify an existing column in a table
WHERE Filter records that fulfill a specified condition.
ALTER TABLE (Rename Column) Rename an existing column in a table
AND, OR, NOT Combine conditions.
ORDER BY (Ascending) Sort the results in ascending order. ALTER TABLE (Drop Column) Remove a column in a table

ORDER BY (Descending) Sort the results in descending order. ALTER TABLE (Add Primary Key) Add a primary key to a table
COUNT Count the number of rows that match a specified condition.
ALTER TABLE (Drop Primary Key) Remove a primary key from a table
GROUP BY Group rows that have the same values in specified columns into aggregated data.
ALTER TABLE (Add Foreign Key) Add a foreign key to a table
HAVING Filter the results of a GROUP BY.
INNER JOIN Combine rows from different tables if they meet a certain condition. ALTER TABLE (Drop Foreign Key) Remove a foreign key from a table

LEFT JOIN Return all records from the left table, and the matched records from the right table. CHECK Constraint Ensure that all values in a column satisfy a condition
RIGHT JOIN Return all records from the right table, and the matched records from the left table.
UNIQUE Constraint Ensure that all values in a column are unique
FULL OUTER JOIN Return all records when there is a match in either the left or the right table.
ALTER TABLE (Delete Constraint) Delete a constraint
UNION Combine the result set of two or more SELECT statements (only distinct values).
UNION ALL Combine the result set of two or more SELECT statements (allows duplicate values). DROP TABLE Remove a table

NULL VALUES Select rows where column value is NULL. RENAME TABLE Rename a table
NOT NULL VALUES Select rows where column value is not NULL.
TRIM Remove leading and trailing spaces from a string.
LIKE Search for a specified pattern in a column.
SUBSTRING Extract a part of a string.
IN Specify multiple possible values for a column.
BETWEEN Select values within a given range. COALESCE Return the first non-null value in a list.

ALIASES Give a table or a column a temporary name. DATE Functions Work with dates.
UPDATE with JOIN Update a table using data from another table.
TRUNCATE TABLE Delete all records from a table, without deleting the table
INSERT INTO SELECT Copy data from one table and insert it into another table.
CASE
EXISTS
Implement IF-THEN-ELSE logic.
Test for the existence of any record in a subquery.
Digyquant Benefits
ANY and ALL Compare a value to each value in a list or returned by a query. 1:1 Mentorship from In-Depth Q&A and
SELECT INTO Create a new table and fill it with data from a selected table. Industry experts Clarification
INSERT Multiple Rows Insert multiple rows into a table.
LIMIT Restrict the number of rows returned by a query. 24x7 Live 1:1 Video based Hands-On Learning with
FETCH Retrieve a single row or multiple rows. doubt support Projects and Exercises
OFFSET Skip a specified number of rows before returning the result set.
Mentors with 12+ years of experience
ISNULL() Function Replace NULL values with another value.

You might also like