Cheatsheet
To create a table
Warning
Add primary
key after the colum_name
if that column is primary.
To select from a table
All columns
Specific column
To insert into table
Warning
Note: char
and varchar
must be enclosed with single quotes('
)
Creating keys
Primary key
Add the primary key
keyword after the column_name.
Tip
primary key
declaration on an attribute ensures that the attribute is not null
Composite primary key
Add the primary key (column_name_1, column_name_2, ....)
at the end before the closing parentheses )
while creating the table.
Foreign key
Add the foreign key (column_name) references parent_table(parent_column)
at the end before the closing parentheses )
while creating the table.
Deleting rows
Alter
Adding an attribute
Deleting an attribute
Important Points to Note
delete
: Delete row(s) from the table. But schema is not lostdrop
: Entire table is deleted along with schema.truncate
: Deletes the table along with schema, but the schema is regenerated.