SQL中的索引用于快速访问表或者视图中的数据。
索引是在表或者视图上创建的。
数据库具有数千个表和视图的大量数据。
当我们尝试访问此数据时,需要更多时间。
UNIQUE 索引确保列值或者多于一列的组合值不能在表中出现多次。
在SQL Server 2008创建唯一索引示例
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Student1Details]') AND type in (N'U')) DROP TABLE [dbo].Student1Details GO create table Student1Details( [ID] int NOT NULL, [Name] [varchar](50) NULL, [Branch] [varchar](10) NULL, [Location] [varchar](10) NULL constraint [PK_Student1] primary key clustered ( [ID] asc )) on [PRIMARY] insert into Student1Details select 1, 'Nitin', 'CS','IND' union all select 2, 'Ravi', 'EI','ENG' union all select 3, 'Tim', 'ME','US' union all select 4, 'Rick', 'ME','IND' union all select 5, 'Rakesh', 'CS','ABD' union all select 6, 'Tarun', 'ME','IND' union all select 7,'Raushan','IT','IND' select * from Student1Details CREATE UNIQUE INDEX index_student_normal ON Student1Details(Id)
日期:2020-06-02 22:17:43 来源:oir作者:oir