SQL CREATE TABLE is a command that creates a new table in the RDBMS database, such as MySQL, SQL Server, Oracle, etc.



The syntax for creating a new table using SQL is:

Syntax:

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:

Example:

CREATE TABLE `tbl_employee` (
  `employee_id` INT NOT NULL AUTO_INCREMENT,
  `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 Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram