SQL CREATE TABLE is a command to create a new table in the RDBMS database, such as MySQL, SQL Server, Oracle, and others.

The syntax for creating a new table using SQL is:


CREATE TABLE table_name
column1 datatype constraint,
column2 datatype constraint,
column_n datatype constraint

When this statement is executed, a new table with the specified name is created. The new table will have the columns and data types defined in the statement. It is also possible to add constraints such as NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, and default value.

For example, in MySQL, the following SQL statement creates a new table named "tbl_employee" in the database:


CREATE TABLE `tbl_employee` (
  `last_name` VARCHAR (100) NOT NULL,
  `first_name` VARCHAR (100) NOT NULL,
  `address` VARCHAR (255),
  PRIMARY KEY (`employee_id`)
) ENGINE = INNODB CHARSET = utf8 COLLATE = utf8_unicode_ci;

Found This Useful? Share This Page!