navigation

CREATE TABLE

The SQL CREATE TABLE statement is used to create a new table.

Syntax:

Basic syntax of CREATE TABLE statement is as follows:
CREATE TABLE table_name(
   column1 datatype,
   column2 datatype,
   column3 datatype,
   .....
   columnN datatype,
   PRIMARY KEY( one or more columns )
);

The table_name specify the name of the table which you wat to create.
The column_name parameters specify the names of the columns of the table.
The data_type parameter specifies what type of data the column can hold (e.g. varchar, integer, decimal, date, etc.).
The size parameter specifies the maximum length of the column of the table.

CREATE TABLE is the keyword telling the database system what you want to do. In this case, you want to create a new table. The unique name or identifier for the table follows the CREATE TABLE statement.

Example:

Following is an example, which creates a ‘EMPLOYEE1’ table:
CREATE TABLE DSOCIQA.EMPLOYEE1
(ID NUMBER(10), NAME VARCHAR(10),
START_DATE DATE, END_DATE DATE,
SALARY NUMBER(10));
                        
You can verify if your table has been created successfully by looking at the message displayed by the ORACLE, otherwise you can use DESC command as follows:

DESC EMPLOYEE1;






Now, you have EMPLOYEE1 table available in your database which you can use to store required information related to customers.



No comments:

Post a Comment