SQL DDL
DDL (Data Definition Language) in SQL refers to the subset of SQL commands used to define and modify database structures. DDL deals with creating, altering, and dropping databases and tables, as well as defining relationships between the data.
Key DDL Commands:
1. CREATE: Creates a new database object (table, view, etc.)
2. ALTER: Modifies an existing database object (table, column, etc.)
3. DROP: Deletes a database object (table, database, etc.)
4. TRUNCATE: Removes all rows from a table (no rollback)
5. RENAME: Renames a database object (table, column, etc.)
Characteristics of DDL:
  • Permanent Changes: Once executed, the changes made by DDL commands (like DROP or CREATE) are permanent and cannot be undone unless you have backups.
  • Implicit Commit: DDL commands automatically commit the changes made to the database. You don't need to use COMMIT after a DDL command.
  • Structure Focused: DDL commands focus on the structure of the database rather than the data itself.