The CREATE DATABASE Statement
The CREATE DATABASE statement is used to create a database.
SQL CREATE DATABASE Syntax
CREATE DATABASE database_name
The CREATE DATABASE statement is used to create a database.
SQL CREATE DATABASE Syntax
CREATE DATABASE database_name
CREATE DATABASE Example
Now we want to create a database called "Employee".
We use the following CREATE DATABASE statement:
Now we want to create a database called "Employee".
We use the following CREATE DATABASE statement:
CREATE DATABASE Employee
Database tables can be added with the CREATE TABLE statement.
The CREATE TABLE Statement
The CREATE TABLE statement is used to create a table in a database.
SQL CREATE TABLE Syntax
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
)
The data type specifies what type of data the column can hold. For a complete reference of all the data types available in MS Access, MySQL, and SQL Server, go to our complete Data Types reference.
CREATE TABLE Example
Now we want to create a table called " EmpDetails " that contains five columns: EmpId, FirstName, LastName, Address.
We use the following CREATE TABLE statement:
CREATE TABLE
(
EmpId int,
FirstName varchar(200),
LastName varchar(200),
Address varchar(500)
)
The EmpId column is of type int and will hold a number. The LastName, FirstName, Address columns are of type varchar with a maximum length of 200,200,500 resp. characters.