One Pager Cheat Sheet
- Data Definition Language (DDL) is a subset of SQL commands that we use to create, modify and manipulate the structure of database objects.
- The
CREATE
command is used to create objects such as a database, table, index, view, and stored procedure in a database. - The
CREATE TABLE
command is used to create a new table called artists in the database, defining its columns, data types, size, andPRIMARY KEY
. - The DDL command
ALTER
is used to modify existing databases by adding or modifying columns in atable
. - We can use the
ALTER
command with theADD
keyword to add a new column called nationality to the table artists. - Using the
DROP
command we can delete a database, table, column, constraint, or index. - The
DROP TABLE
command is used to deletetables
, such as artists, followed by asemicolon
. - The
TRUNCATE TABLE
command is used to delete data entries from a table while keeping its structure, indexes, and dependencies. - The
TRUNCATE TABLE
command deletes the data within a table but does not affect its structure, indexes or dependencies. - The DDL command
RENAME
can be used to change the name of tables and columns in our database. - We
RENAME
thecolumn
year_published to release_year in the albums table using theRENAME COLUMN
clause of theALTER TABLE
DLL
command.