Arrao4u

…a blog by Rama Rao

Archive for the ‘Index & Foreign keys’ Category

Indexes & Foreign keys

Posted by arrao4u on February 9, 2010

ALTER

TABLE rolemenutran ADD

FOREIGN KEY (level_id) REFERENCES userlevel(level_id)

ALTER

TABLE rolemenutran ADD FOREIGN KEY (menuid) REFERENCES dms_menu(menuid)

ALTER  T

ABLE rolemenutran DROP constraint K__RoleMenuT__menuI__1EA48E88

COVERING INDEX:

CREATE NONCLUSTERED INDEX indx_dmsmaster_companyname
ON dbo.dmsmaster (company_name)
INCLUDE (source, source_type)
GO

Creating clustered and non clustered index:

create nonclustered index indx_dmsmaster_companyname
on dmsmaster(company_name)
include(user_id,source_type,source)
create nonclustered index indx_dmslocation_locationdetails
on dmslocation(master_id)
include(area_id,category,city,dateofentry_loc,lastupdatedby,locality,mobile,pincode,presale_assign,state,telephone1,telephone2,telephone3,tse_name,typeofcard,validated,validated_remarks,validateddate,validator_code)

dead lock:

Select * from dms.dbo.BlockingSpid [nolock]

Remove index:

drop

index dmslocation.Dmslocation_pincode

Get the all Indexes

select ‘table_name’=object_name(i.id)  ,i.indid

,’index_name’=i.name  ,i.groupid

,’filegroup’=f.name  ,’file_name’=d.physical_name

,’dataspace’=s.name from sys.sysindexes i

,sys.filegroups f  ,sys.database_files d

,sys.data_spaces s

where objectproperty(i.id,’IsUserTable’) = 1

and f.data_space_id = i.groupid

and f.data_space_id = d.data_space_id

and f.data_space_id = s.data_space_id

order by f.name,object_name(i.id),groupid

Posted in Index & Foreign keys | Leave a Comment »