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
)


SQL Server 2014 Standard w/ 10CAL Edition, Media & License | 32 bit & 64 bit

Price: $299.99
Buy It Now
Brand New - Microsoft SQL Server 2012 Standard Edition SP3 and 10 CAL License

Price: $400
Buy It Now
SQL Server 2014 Standard Edition, 16 Core Processor License | unlimited USER CAL

Price: $599.99
Buy It Now
MSFT SQL Server 2008 R2 Standard Edition 32/x64 | 25CAL, Media, License

Price: $299.99
Buy It Now
MSFT SQL Server 2012 Standard Edition, 32bit & 64bit, Media & License w/10CAL

Price: $399.99
Buy It Now
Lenovo Microsoft SQL Server 2016 CAL (1 User)

Price: $199.99
Buy It Now







Copyright 2017 - TSQLTutorials.com