CREATE TABLE is a Data Definition Language (DDL) command that registers a new, permanently stored table in the current database schema. It specifies the table name, one or more column definitions (each with a data type and optional column-level constraints), and optional table-level constraints such as PRIMARY KEY, FOREIGN KEY, UNIQUE, and CHECK. The statement fails if a table with the same name already exists unless the IF NOT EXISTS clause (or dialect-specific equivalent) is supplied. Some systems allow additional options like storage engine, tablespace, partitioning rules, and comment strings. Because CREATE TABLE changes the database catalog, it is auto-committed in most systems and cannot be rolled back in databases that implicitly commit DDL. Temporary or global temporary tables can be created with dialect-specific keywords (e.g., TEMP, TEMPORARY, GLOBAL TEMPORARY).
table_name
(identifier) - Name of the table to be createdcolumn_name
(identifier) - Name of each columndata_type
(type) - Data type for the column (e.g., INT, VARCHAR, DATE)column_constraints
(keyword list) - NOT NULL, UNIQUE, PRIMARY KEY, DEFAULT, CHECK, REFERENCEStable_constraints
(keyword list) - PRIMARY KEY, UNIQUE, FOREIGN KEY, CHECK applied to multiple columnsIF NOT EXISTS
(clause) - Skips creation if the table already existsTABLE_OPTIONS
(dialect specific) - Storage engine, tablespace, partitioning, comments, etc.ALTER TABLE, DROP TABLE, CREATE TABLE AS, CREATE TEMPORARY TABLE, PRIMARY KEY, FOREIGN KEY, CHECK, UNIQUE, DEFAULT
SQL-86 (ANSI X3.135-1986)
Most databases raise an error. Add IF NOT EXISTS to skip creation safely.
Only databases with transactional DDL (like PostgreSQL) allow it. Others auto-commit as soon as the statement runs.
Include a FOREIGN KEY clause that points to the parent table and column inside the CREATE TABLE definition.
CREATE TABLE builds an empty structure. CREATE TABLE AS SELECT both creates the table and fills it with data from a query.