T-SQL Tutorials - TSQLTutorials.com

CREATE TABLE


Introduction

The CREATE TABLE statement is how new tables are created in SQL. Tables are the structures that hold data, in a relational database. The syntax for using the CREATE TABLE command is as follows:

  • CREATE TABLE [table name]
    (
      column name 1 datatype for column,
      column name 2 datatype for column
    )

Beginning Example

In this example we will create a simple 'Employees' table with a 'Name' column, 'Position' column and a 'Salary' column: CREATE TABLE Employees
(
  Name varchar(20),
  Position varchar(25),
  Salary int
)




Second Example

In this next example we will create the same 'Employees' table, but this time we will create an auto-incrementing primary key. CREATE TABLE Employees
(
  EmployeeKey int IDENTITY(1,1) PRIMARY KEY,
  Name varchar(20),
  Position varchar(25),
  Salary int
)


Microsoft SQL Server 2005 - Standard Edition 5 CAL's

Price: $1785
Buy It Now
SQL Server 2005 Enterprise Edition 1 CAL
Current Price: $4599.99
Current Bids: 0
228-00683 MS SQL Server 2000 Standard 5 CAL

Price: $375
Buy It Now
Microsoft SQL Server 2008 R2 Enterprise w/25 Device Cal
Price: $13049
Buy It Now
Microsoft SQL Server 2000 Standard 10 CAL 228-00684 NEW

Price: $939
Buy It Now
Microsoft SQL Server 2000 Standard Edition -Five CAL -

Price: $399
Buy It Now







Copyright 2010 - TSQLTutorials.com