Create a New Table
suggest changeA basic Employees table, containing an ID, and the employee’s first and last name along with their phone number can be created using
CREATE TABLE Employees(
Id int identity(1,1) primary key not null,
FName varchar(20) not null,
LName varchar(20) not null,
PhoneNumber varchar(10) not null
);
This example is specific to Transact-SQL
CREATE TABLE creates a new table in the database, followed by the table name, Employees
This is then followed by the list of column names and their properties, such as the ID
Id int identity(1,1) not null
| Value | Meaning |
|---|---|
Id |
The column’s name. |
int |
The data type. |
identity(1,1) |
SQL Server: values are generated starting at 1 and incrementing by 1 for each new row. |
primary key |
Values in this column must be unique and not NULL. |
not null |
This column cannot contain NULL. |
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents