Skip to main content

CREATE in SQL

CREATE statement.                        
    • CREATE statement is used to create new table
    • It add column to table
    • It set data type to column.
    • it belongs to Data Definition language (DDL). 
CREATE  TABLE table_name(Column_name1 DataType, Column_name2 DataType, Column_name3 DataType, Column_name4 DataType, ........ Column_nameN DataType);
The table_name is name of table to create. Column_Name define name of column and DataType defines any datatypes. DataType may be numeric , date, character, unicode or binary.

CREATE TABLE Employee(id int NOT NULL, emp_name nvarchar(20) NOT NULL, dob date DATE, salary int DEFAULT 10,000);
-----------------------------------------------------------
DESC Employee
Desc statement describe the table. 
 Field Data Type Null key Default
 id INT NO  
 emp_name NVARCHAR(20) NO  
dob DATE YES  
 salary int YES  10,000

This statement create named employeee with column id,emp_name, dob, salary. Default used to set default value. The NOT NULL will not all null value.
Some datatype may change according to database engine oracle, MSSQL Server, MYSQL, ACCESS etc.

CREATE TABLE Dept(id int, dept_name nvachar(20) NOT NULL)
It create department table with id and department name.

Thank You. Like, Share and Subscribe 👍 Followlect.com
                               
                                      

Comments