Tuesday, March 27, 2012

Indexes and Constraints in SYBASE T-SQL

Indexes and Constraints

Indexes: 
2 types of indexes - clustered and nonclustered. Both are B-tree.
 
Clustered - only one clustered index per table can exist (data is maintained in clustered index order).
 
Nonclustered indexes - you can have 249 of them per table. They maintain pointers to rows (not data pages).
 
An index can contain up to 16 columns, but toal index width <= 255.

Creating indexes: 
create unique clustered index name_index  on authors (au_lname, au_fname) 
create index fname_index on authors (au_fname, au_lname) 
***********************-
 
Constraints:
 
Primary Key and Unique Constraints
 
Check Constraints
 
Referential-integrity Constraints
 
Primary-Key Constraints
 
Foreign-Key Constraints
 
Modifying Constraints
 
Adding Constraints
 
Removing Constraints
 
Information on Constraints:
 
sp_helpconstraint 
***********************-
 
Comparing Data-integrity Methods:
 
Rules, Defaults, Indexes, Constraints, Keys (Primary Key, Foreign Key (primary key from another table), Common key)
 

 

No comments:

Post a Comment