Learn SQL - Manipulation Cheatsheet - Codecademy
Learn SQL - Manipulation Cheatsheet - Codecademy
Manipulation
Column Constraints
Column constraints are the rules applied to the
values of individual columns: CREATE TABLE student (
id INTEGER PRIMARY KEY,
● PRIMARY KEY constraint can be used to
name TEXT UNIQUE,
uniquely identify the row.
grade INTEGER NOT NULL,
● UNIQUE columns have a di erent value age INTEGER DEFAULT 10
for every row.
);
● NOT NULL columns must have a value.
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
VALUES (value1, value2);
● Insert into columns in order.
DELETE Statement
The DELETE statement is used to delete
records (rows) in a table. The WHERE clause DELETE FROM table_name
speci es which record or records that should WHERE some_column = some_value;
be deleted. If the WHERE clause is omitted, all
records will be deleted.
UPDATE Statement
The UPDATE statement is used to edit records
(rows) in a table. It includes a SET clause that UPDATE table_name
indicates the column to edit and a WHERE SET column1 = value1, column2
clause for specifying the record(s). = value2
WHERE some_column = some_value;