3.1. Data Definition Language (DDL)

Data Definition Language consists of those SQL statements used to define and manage all the objects or components in an SQL database. DDL is the subset of SQL statements used for modeling the structure (rather than the data contents) of a database. DDL consists of three primary statements for each type of database object.

  • CREATE creates a new database system object in the current database.

Example: Create a new table with two columns.

CREATE TABLE table1 ( col1   INT, col2 INT);
  • ALTER modifies an existing object definition or structure.

Example: Add a column to table1.

ALTER TABLE table1 ADD  col3   INT;
  • DROP removes the definition of the metadata AND any underlying data.

Example: Remove table1 and all of ...

Get Transact-SQL Desk Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.