The CREATE TABLE statement is used to create a new table in a database. The column specifies the name of the column of the table. The datatype parameter specifies the type of data the column can hold.
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
Constraints can be specified when the table is created with the CREATE TABLE statement, or after the table is created with the ALTER TABLE statement. Constraints are used to specify rules for the data in a table.
CREATE TABLE table_name (
column1 datatype constraint,
column2 datatype constraint,
column3 datatype constraint,
....
);
Constraints are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the table. If there is any violation between the constraint and the data action, the action is aborted.
The following constraints are used in SQL: