How to Create a SQL Table Example


Create SQL Table with Primary Key

CREATE TABLE Student (
  ID INT NOT NULL,
  First_Name VARCHAR(50) NOT NULL,
  Last_Name VARCHAR(50) NOT NULL,
  PRIMARY KEY(ID)
);

Details

  1. The T-SQL code above will create the database table Student.
  2. The Student table has 3 columns: ID, First_Name, and Last_Name
  3. The Student table has a PRIMARY KEY: ID

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s