Join us Now |  Forgot Password? | Forgot UserName?


Learn step by step

SQL - Create Table

In SQL statement CREATE TABLE is the SQL command that adds new table to an SQL database. Tables are the basic unit of organization and storage of data in SQL. Each table represents an entity such as a product, customer, code or event. Table is similar to a file in a non-database system.
Tables are organized into rows and columns. Example, a table of customer would likely have a separate row for each customer. And columns are attributes that describe the row. Example, a row in customer table would have columns like customer_nbr, customer_name, account_balance_amt, etc.

The basic syntax of CREATE TABLE statement:

CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
columnN datatype,
PRIMARY KEY( one or more columns )

CREATE TABLE product ( product_nbr int NOT NULL,
product_name varchar(40) NOT NULL,
product_status_code char(10) NOT NULL,
start_date date NULL,
end_date date NULL,
raw_material_cost decimal(12,2) NULL,
primary key (product_nbr)


product_nbr product_name product_status_code start_date end_date raw_material_cost

Related Videos