0% found this document useful (0 votes)
5 views3 pages

Cheatsheet SQL

The document provides an overview of SQL manipulation commands, including column constraints, the CREATE TABLE statement, and various data manipulation statements such as INSERT, ALTER, DELETE, and UPDATE. It explains the purpose and syntax of each command, highlighting key features like PRIMARY KEY, UNIQUE, NOT NULL, and DEFAULT constraints. This serves as a cheatsheet for learning SQL database management.

Uploaded by

gupta.anandkr15
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Cheatsheet SQL

The document provides an overview of SQL manipulation commands, including column constraints, the CREATE TABLE statement, and various data manipulation statements such as INSERT, ALTER, DELETE, and UPDATE. It explains the purpose and syntax of each command, highlighting key features like PRIMARY KEY, UNIQUE, NOT NULL, and DEFAULT constraints. This serves as a cheatsheet for learning SQL database management.

Uploaded by

gupta.anandkr15
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Firefox about:srcdoc

Cheatsheets / Learn SQL

Manipulation

Column Constraints

Column constraints are the rules applied to the values of individual columns: CREATE TABLE student (
• PRIMARY KEY constraint can be used to uniquely identify the row.
id INTEGER PRIMARY KEY,
• UNIQUE columns have a di�erent value for every row.
• NOT NULL columns must have a value.
name TEXT UNIQUE,
• DEFAULT assigns a default value for the column when no value is grade INTEGER NOT NULL,
speci�ed. age INTEGER DEFAULT 10
There can be only one PRIMARY KEY column per table and multiple
);
UNIQUE columns.

CREATE TABLE Statement

The CREATE TABLE statement creates a new table in a database. It allows CREATE TABLE table_name (
one to specify the name of the table and the name of each column in the table.
column1 datatype,
column2 datatype,
column3 datatype
);

1 of 3 2/7/2025, 6:40 PM
Firefox about:srcdoc

INSERT Statement

The INSERT INTO statement is used to add a new record (row) to a table. -- Insert into columns in order:
It has two forms as shown:
INSERT INTO table_name
• Insert into columns in order.
• Insert into columns by name. VALUES (value1, value2);

-- Insert into columns by name:


INSERT INTO table_name (column1, column2)
VALUES (value1, value2);

ALTER TABLE Statement

The ALTER TABLE statement is used to modify the columns of an existing ALTER TABLE table_name
table. When combined with the ADD COLUMN clause, it is used to add a
ADD column_name datatype;
new column.

DELETE Statement

The DELETE statement is used to delete records (rows) in a table. The DELETE FROM table_name
WHERE clause speci�es which record or records that should be deleted. If WHERE some_column = some_value;
the WHERE clause is omitted, all records will be deleted.

2 of 3 2/7/2025, 6:40 PM
Firefox about:srcdoc

UPDATE Statement

The UPDATE statement is used to edit records (rows) in a table. It includes a UPDATE table_name
SET clause that indicates the column to edit and a WHERE clause for SET column1 = value1, column2 = value2
specifying the record(s).
WHERE some_column = some_value;

Print Share

3 of 3 2/7/2025, 6:40 PM

You might also like