Mysql Cheetsheet
Mysql Cheetsheet
Manipulation
Column Constraints
Column constraints are the rules applied to the values CREATE TABLE student (
of individual columns:
id INTEGER PRIMARY KEY,
• PRIMARY KEY constraint can be used to
uniquely identify the row. name TEXT UNIQUE,
• UNIQUE columns have a di�erent value for grade INTEGER NOT NULL,
every row.
age INTEGER DEFAULT 10
• NOT NULL columns must have a value.
);
• DEFAULT assigns a default value for the
column when no value is speci�ed.
There can be only one PRIMARY KEY column per
table and multiple UNIQUE columns.
The CREATE TABLE statement creates a new table CREATE TABLE table_name (
in a database. It allows one to specify the name of the
column1 datatype,
table and the name of each column in the table.
column2 datatype,
column3 datatype
);
INSERT Statement
The INSERT INTO statement is used to add a new -- Insert into columns in order:
record (row) to a table.
INSERT INTO table_name
It has two forms as shown:
• Insert into columns in order. VALUES (value1, value2);
• Insert into columns by name.
1 of 2 18/01/25, 12:46
Firefox about:srcdoc
The ALTER TABLE statement is used to modify the ALTER TABLE table_name
columns of an existing table. When combined with the
ADD column_name datatype;
ADD COLUMN clause, it is used to add a new
column.
DELETE Statement
UPDATE Statement
Print Share
2 of 2 18/01/25, 12:46