Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Can we create a clustered index on composite primary key.

Answers were Sorted based on User's Feedback



Can we create a clustered index on composite primary key...

Answer / monal

You can also do this.

create table Test
(officeid integer not null,
empid integer not null,
age integer ,
sex varchar(5),
name varchar(20),
PRIMARY KEY (OFFICEID, EMPID))


this will also create composite primary key and cluster
index on composite primary key.

Is This Answer Correct ?    18 Yes 2 No

Can we create a clustered index on composite primary key...

Answer / anil kumar

Here's the procedure:

Create a table with no primary key defined.
Create clustered index on the primary key columns.
Alter the table to define the primary key.

Table creation:

create table CDSWEB.Anil (officeid integer not null,
empid integer not null,
age integer ,sex varchar(5),
name varchar(20));

Index creation:
create index CDSWEB.AN001 on CDSWEB.Anil(officeid,empid)
CLUSTER;

Primary key defined:

alter table CDSWEB.ANIL
add primary key (officeid,empid);

Is This Answer Correct ?    2 Yes 0 No

Can we create a clustered index on composite primary key...

Answer / shatrunjay shukla

Yes
If you are creating a composite Primary Key, or a composite Clustered Index that is NOT a Primary Key, you are creating a single index that uses both column values as the clustering key.

CREATE TABLE T(id INT, cat INT, uName SYSNAME);

CREATE UNIQUE CLUSTERED INDEX ix_T_id_cat ON T (id,cat);



SELECT * FROM SYS.INDEXES WHERE object_id = OBJECT_ID('T');

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Explain the rules for designing files and file groups in sql server?

0 Answers  


What is SQL Profiler what is the use of it?

2 Answers   247Customer, Steria,


What is Outter Join?

1 Answers  


What are the benefits of filtered indexes?

0 Answers  


What does it mean to normalize a database and why would you do it?

0 Answers  


How can u get the number of pupils connecting the database?

1 Answers   Cap Gemini,


Difference b/w Clustered & non-clustered index? Not the bookish definition, but how they internally works in SQL Server?

1 Answers   United Healthcare,


Difference between Function and Procedure-in general?

6 Answers  


Is port 1433 secure?

0 Answers  


how to copy only distinct data into another table which is not already exist in database?

2 Answers   Spectra,


How to give a user the option of importing Excel and a delimited text file into a SQL Server Database without manually using SQL DTS?

1 Answers   GE,


1.How to check the backup file details if we do not have access to that folder 2.how to check the backup file size without connecting to the folder

3 Answers   CarrizalSoft Technologies, IBM,


Categories