标签:
CREATE TABLE [dbo].[Student]([ID] [INT] IDENTITY(1,1) NOT NULL,[Name] [NVARCHAR](50) NOT NULL,[Age] [INT] NOT NULL,[Height] [INT] NOT NULL,[Address] [NVARCHAR](100) NULL,[Class] [NVARCHAR](50) NOT NULL,[EntranceDateTime] [DATETIME] NOT NULL,CONSTRAINT [PK_Student] PRIMARY KEY CLUSTERED([ID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]GO
ALTER TABLE [dbo].[Student] ADD CONSTRAINT [DF_Student_EntranceDateTime] DEFAULT (GETDATE()) FOR [EntranceDateTime]GO
往表里插入 500万数据:
DECLARE @i INT;SET @i=1;WHILE(@i<5000001)BEGININSERT INTO dbo.Student(Name,Age,Height,[Address],Class,EntranceDateTime)VALUES(‘yang_‘+CONVERT(NVARCHAR(10),@i),RAND()*10+7,RAND()*100+50,‘厦门土豪小区1座‘+CONVERT(NVARCHAR(10),CONVERT(INT,RAND()*100+1))+‘号‘,CONVERT(NVARCHAR(10),CONVERT(INT,RAND()*6+1))+‘年级‘,GETDATE())SET @i=@i+1;END
CREATE NONCLUSTERED INDEX [IX_Student_Age_Name] ON [dbo].[Student]([Age] ASC)INCLUDE ( [Name]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]GO 、
Ø [Col1] = 3.14Ø [Col1] > 100Ø [Col1] BETWEEN 0 AND 99Ø [Col1] LIKE ‘abc%‘Ø [Col1] IN (2, 3, 5, 7)
Ø ABS([Col1]) = 1Ø [Col1] + 1 = 9Ø [Col1] LIKE ‘%abc‘
标签:
原文地址:http://www.cnblogs.com/SFLYQ/p/4381414.html