CREATE, DROP, and INSERT Table
In this lesson, we will take a look at three commands regarding relations/tables.
We'll cover the following...
CREATE TABLE
Creating a basic table involves naming the table and defining its columns and the data type for each column.
The SQL CREATE TABLE statement is used to create a new table.
Syntax
The basic syntax of the CREATE TABLE
statement is as follows:
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY(one or more columns)
);
CREATE TABLE
is the keyword telling the database system what you want to do. The unique name or identifier for the table follows the CREATE TABLE
statement.
Then, in brackets, comes the list defining each column in the table and what data type it is.
Example
The following code block is an example which creates a CUSTOMERS table ...