Create a new table in the database.
The CREATE TABLE statement defines a new table in the database with a specified name and column definitions. Each column definition includes a name, data type, and optional constraints such as PRIMARY KEY, NOT NULL, UNIQUE, DEFAULT, and FOREIGN KEY. You can also define table-level constraints. CREATE TABLE is a data definition language (DDL) statement. Using IF NOT EXISTS prevents an error if the table already exists.
| Name | Description | Optional |
|---|---|---|
table_name |
The name for the new table. | No |
column_definitions |
One or more column definitions including name, data type, and optional constraints. | No |
CREATE TABLE users (
id INT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
age INT
);