SQL Create Table

SQL Create Table command is used to create tables. Tables are the basic building blocks of a database.

Tables are divided into rows and columns. To create a table we need to know:

  • The name of the table/entity
  • The fields/columns
  • Type of each field/column
  • State if Null value is permitted for each field,

The syntax to create a table:

CREATE TABLE table_name
   field1 data_type [primary key],
   field2 data_type [NOT NULL],
   field3 data_type [NULL],
   . . . .

The primary key is used to indicate the unique identifier of a table. If we set a field as a primary key, it will automatically set into not null too.

Valid data types in Transact-SQL are as follow:


For example let's create authors table.

Sql command:

          au_id INT PRIMARY KEY,
          au_fname NVARCHAR(25),
          au_lname NVARCHAR(25),
          phone NVARCHAR(12),
          address NVARCHAR(40),
          city NVARCHAR(40),
          state NVARCHAR(10),
          zip NVARCHAR(10)

Quick link. From here, you can learn the following:

Sql Create Database
Use this to create a database.

Sql Alter Table
Used less often, but it is very handy to know this command. With this you can basically edit a table structure.

Sql Drop Table
Used to delete a table, not just the content. This command is also used very often during the tutorial. So, you need to master this too.

Data Retrieval
All you need to know about Sql Select can be found here.

Couldn't find what you're looking for? Use this search feature to quickly find it!

Positive Resources

All of us have at least two or three things that excite us. We could talk about these subjects for hours. Good news!. Did you know that Site Built It! can turn this type of deep interest and enthusiasm into a revenue-generating business?

Review some of the Site Build It! case studies and you'll absolutely discover something that ignites more positive ideas into your mind.

SBI! Video Tour

Invest the most
important 30 minutes
you will spend online.

Click, sit back, and
understand why SBI!
makes you succeed.