SQL CREATE Table
SQL Tutorial » CREATE Table
How do you create a new table in SQL Server?
CREATE TABLE statement is used to create in database server a new table.
1. Syntax:
column_1 datatype,
column_2 datatype,
column_3 datatype,
....
column_N datatype,
);
column_1, column_2 ... column_N parameters specify the names of the columns of the table.
Datatype specifies the type of data of the column and it may vary from one database to another database ( text,varchar, integer, date, etc.). For example, INT is supported in MySQL, NUMBER is supported in Oracle database.
SQL CREATE TABLE Example
The next example creates a table named "Users" that contains six columns as: ID, Last_Name, First_Name, Address, City and Email:
ID int(11),
Last_Name varchar(120),
Firs_tName varchar(120),
Address varchar(120),
City varchar(60),
Email varchar(60)
);
The ID column is of type int and will hold an integer with 11 digits.
The Last_Name, First_Name, Address columns are varchar and will hold characters, the maximum length for these fields is 120 characters.
City and Email columns are varchar and will hold characters, the maximum length for these fields is 60 characters.
Related subjects:
SQL DROP DataBase
SQL update DataBase
PHP select / view data
Conect to MySQLi
SQL insert into table
Tags: SQL CREATE Table: primary key, example, if not exists, foreign key, create table and insert data sql, as, from select, with auto increment id, from another table, with index
Can you create a table in SQL?
How do you create a new table in SQL Server?
What is Create Table command in SQL?
How do you create a table in schema?
SQL CREATE Table with primary key
The next example creates a table named "Users" that contains six columns with ID as primary key and NOT NULL(these fields cannot be NULL while creating records in the table), Last_Name, First_Name, Address, City and Email:
ID int NOT NULL,
Last_Name varchar(120) NOT NULL,
Firs_tName varchar(120) NOT NULL,
Address varchar(120) NOT NULL,
City varchar(60),
Email varchar(60) NOT NULL,
PRIMARY KEY (ID)
);
Create Table Using Another Table
A copy of an existing table can be created using CREATE TABLE.
The new table gets the same column definitions. All columns or specific columns can be selected.
If you create a new table using an old table, the new table will be filled with the existing values from the old table.
SELECT column_1, column_2,..., column_N
FROM existing-table-name
WHERE ....;
SQL CREATE Table: primary key, example, if not exists, foreign key, create table and insert data sql, as, from select, with auto increment id, from another table, with index
Can you create a table in SQL?
How do you create a new table in SQL Server?
What is Create Table command in SQL?
How do you create a table in schema?
SQL CREATE Table - sql tutorial
This tool makes it easy to create, adjust, and experiment with custom colors for the web.

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.

Find here examples of creative and unique website layouts.

Find here examples of creative and unique website CSS HTML menu.