๐ผDDL Commands
What are DDL Commands?
DDL or Data Definition Language commands are used to define and manage the structure of database objects like tables, indexes, views etc.
๐ Rules for DDL Commands ๐
SQL DDL commands are used to define and modify database schema objects like tables, indexes etc.
๐๏ธ Rules for CREATE Command ๐๏ธ
The CREATE command is used to create a new database object.
Specify object type (TABLE, INDEX etc.) after CREATE
Object name must follow standard naming conventions
Columns, data types, constraints etc. defined within parentheses
This creates a new table called users
with two columns.
โ๏ธ Rules for ALTER Command โ๏ธ
The ALTER command modifies an existing database object.
Specify object name after ALTER
Add, remove, or modify columns, constraints etc.
Can rename objects using RENAME TO
This adds a new column to the existing users
table.
โ Rules for DROP Command โ
The DROP command is used to delete objects from the database.
Specify object type and name after DROP
Removed object and all associated data are deleted
Cannot be undone, use with caution
This permanently deletes the users
table from the database.
So those are some key rules for the main SQL DDL commands like CREATE, ALTER and DROP. Following SQL standards allows portable DDL across database systems.
Last updated