SQLServer 建表 SQL 基础
USE dbTestGO/*******************************************************DataServer: localhost*DataBase: dbTest*Name: Test_SQL_Table*Function: Test_SQL_Table *Input: *Output:*Creator: greatwqs 2012-02-23*Updated: ******************************************************/CREATE TABLE [dbo].[Test_SQL_Table]( -- IDENTITY(1,1) 从1自动增长1[id] [int] IDENTITY(1,1) NOT NULL,[websiteID] [int] NULL,[visitIP] [char](15) NOT NULL,[visitTime] [datetime] NOT NULL,[visitStatus] [int] NULL,[createTime] [datetime] NULL DEFAULT (getdate()),-- id为主键 CONSTRAINT [PK_Test_SQL_Table] PRIMARY KEY CLUSTERED ([id] ASC) ON [PRIMARY]) ON [PRIMARY]GO-- 外键创建索引CREATE NONCLUSTERED INDEX [IX_Test_SQL_Table_websiteID] ON [dbo].[Test_SQL_Table] ([websiteID] ASC) WITH (FILLFACTOR = 90) ON [PRIMARY]GO
?
建表SQL实例, 自动增长, 默认值, 主键, 外键 外键在这里创建索引里面的websiteID为外键.
?