Loading Data Driven Insights
Preparing your learning content.
Preparing your learning content.
A beginner-friendly guide to the SQL CREATE TABLE statement, including table planning, column names, data types, and a SQL Server-friendly example.
On this page
Jump to a lesson section
The CREATE TABLE statement is used to create a new table in a database.
A table gives your data a clear structure before any rows are inserted. It defines the table name, the column names, the data type for each column, and any optional rules or constraints.
A CREATE TABLE statement starts with the table name, followed by a list of columns. Each column should have a name and a data type.
CREATE TABLE table_name (
column1 data_type,
column2 data_type,
column3 data_type
);
Here is a practical SQL Server-friendly example:
CREATE TABLE Employees (
employee_id INT,
employee_name VARCHAR(100),
department VARCHAR(50),
salary DECIMAL(10, 2)
);
Before writing CREATE TABLE, decide what data the table should store.
For an Employees table, we can plan the columns like this:
This command creates a table called Employees.
CREATE TABLE Employees (
employee_id INT,
employee_name VARCHAR(100),
department VARCHAR(50),
salary DECIMAL(10, 2)
);
employee_id as a whole numberemployee_name as textdepartment as textsalary as a decimal numberAfter running the CREATE TABLE statement, the table structure is defined like this:
SQL Roadmap Progress
Topic 12 of 111
11% complete
Next in SQL Roadmap
Continue with the next SQL topic in the recommended roadmap order.
Continue learning →