Loading lesson path
Concept visual
Start at both ends
statement is used to create a new table in a database.
table_name ( column1 datatype constraint, column2 datatype constraint, column3 datatype constraint,....
);The table_name parameter specifies the name of the new table. The column1, column2, ... parameters specify the names of the columns within the table. The datatype parameter specifies the data type of each column (e.g. varchar, int, date, etc.). The constraint parameter is optional, and specifies rules for data integrity (e.g. primary key, not null, etc.).
SQL Constraints chapter.
For an overview of the available data types, go to our complete Data Types Reference.
The following example creates a table named "Persons" with five columns:
( PersonID int PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255),
);The empty "Persons" table can now be filled with data, with the INSERT INTOstatement.
Formula
statement can also be used to create a new table that copies some/all data from an existing table.
If you create a new table from an existing table, the new table will be filled with the values from the existing table.new_table