SQL Create Table

The SQL Create Table is used to create new table in the database.

Create Table Syntax :

The syntax of the Create Table is −
In creating a basic table involves, define the naming of the table (table-name) and its columns (column 1, column 2 ..... column) and the datatype of each column (column 1 datatype ...... column 2 data Type).

CREATE TABLE table-name (
column1 datatype,
column2 datatype,
column3 datatype,
.
.
.
columnN datatype
); 



Create Table Example :

The following code block is an example, which creates a table name Customer that contains the following column names (CustomerID, CustomerName, Age, Address, Customer List), where CustomerID is a primary key and not NULL.

CREATE TABLE Customer(
CustomerID   INT              NOT NULL,
CustomerName VARCHAR (20)     NOT NULL,
Age  INT              NOT NULL,
Address  CHAR (25) ,
CustomerSalary   DECIMAL (18, 2),       
PRIMARY KEY (ID)
);



The empty "Customer" table will now look like this:

CustomerID CustomerName Age Address CustomerSalary





Visit :


Discussion



* You must be logged in to add comment.