CREATE command is a DDL command which is used to create a table or a database. The syntax for creating table and database with CREATE command is as follows −
The syntax for creating a database −
Create database database-name;
Example
mysql> Create database query; Query OK, 1 row affected (0.04 sec)
In the example above we have created a database named ‘query’.
The syntax for creating a table −
Create table table-name( column-name1 datatype1, column-name2 datatype2, column-name3 datatype3, column-name4 datatype4 ------------------------------);
Example
mysql> Create table Employee(Id INT, Name Varchar(20)); Query OK, 0 rows affected (0.19 sec)
In the example above, we have created a table named ‘Employee’ having two columns ‘Id’ and ‘Name’.