The CREATE TABLE statement in SQL is used to define a new table in a database. It specifies the table name and the columns it will contain, along with the data types for each column. The basic syntax is:
CREATE TABLE table_name (
column1 datatype [constraints],
column2 datatype [constraints],
…
);
table_name: The name of the table to be created.
column1, column2, …: The names of the columns in the table.
datatype: The data type for each column (e.g., INT, VARCHAR, DATE).
constraints: Optional rules like PRIMARY KEY, NOT NULL, UNIQUE, etc., that enforce integrity.
Example:
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
Name VARCHAR(100),
HireDate DATE
);
This creates an “Employees” table with three columns: EmployeeID, Name, and HireDate.