Wednesday, 23 July 2014

Create the clustered index and primary key in one table



                     Yes,In one table we can apply the clustered index and primary key, and also we can apply the both clustered index and primary key in single column or we can apply the two different columns.The primary key created for the eno column will create a Non clustered index for the eno column.Why Because in table can have only one clustered index on it.The clustered index created on sal column

create table exam(eno int not null,ename varchar(20),sal money)

create index clustered exam(sal)                  //(we will create the clustered index)

sp_helpindex exam                                    //(This command shows the which indexs are created in table)

alter table exam add constraint pk_r primary key(eno)      //(we will create the primary key)

No comments:

Post a Comment