Learn to define and manage database structure with CREATE, ALTER, DROP.
Data Definition Language (DDL) is the subset of SQL commands used to create, modify, and delete the structure of database objects like tables, indexes, and users. These commands don't deal with the data itself, but rather with the 'blueprint' or schema that holds the data. The three primary DDL commands are `CREATE`, `ALTER`, and `DROP`. The `CREATE` command is used to build new objects. The most common use is `CREATE TABLE`, which defines a new table, its columns, the data type of each column (e.g., INT, VARCHAR, DATE), and any constraints like PRIMARY KEY, FOREIGN KEY, or NOT NULL. You can also use `CREATE DATABASE` to make a new database or `CREATE INDEX` to build an index for faster data retrieval. The `ALTER` command is used to modify the structure of an existing object. With `ALTER TABLE`, you can add a new column, delete an existing column, or change the data type of a column. This command is powerful but must be used with caution, especially on large tables, as it can be a slow and resource-intensive operation. The `DROP` command is used to permanently delete an existing database object. `DROP TABLE employees` will remove the 'employees' table and all the data within it. This action is irreversible, so it must be used with extreme care. Mastering DDL is the first step in building a database from scratch.