Name
CREATE TABLE
Synopsis
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table
{[(definition)][options]|[[AS] SELECT...]|[LIKE table]}Use this statement to create a new table within a database. This
statement has many clauses and options; however, when creating a basic
table, you can omit most of them. The TEMPORARY
keyword is used to create a temporary table that can be accessed only
by the current connection thread and is not accessible by other users.
The IF NOT EXISTS flag is used to suppress error
messages caused by attempting to create a table by the same name as an
existing one. After the table name is given, either the table
definition is given (i.e., a list of columns and their data types)
along with table options or properties, or a table can be created
based on another table. The subsections that follow describe how
to:
Set column properties regarding NULL and default values (see the CREATE TABLE: Column flags” subsection)
Create an index for a table based on one or more columns (see the CREATE TABLE: Index and key definitions” subsection)
Reference a foreign key constraint (see the CREATE TABLE: Foreign key references” subsection)
Specify various table options (see the CREATE TABLE: Table options” subsection)
Create a table exactly like another table (see the CREATE TABLE: Based on an existing table” subsection)
Create a table with filesystem partitions (see the three subsections on partitioning: CREATE TABLE: Partitioning,” CREATE TABLE: Partition definitions,” and CREATE TABLE: ...