Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
Unit 7 To TSQL
Unit 7
Modern Business
Technology
Developed by
Michael Hotek
Integrity
177-32-1176
267-41-2394 267-41-2394...
409-56-7008 341-53-8472...
177-32-1176 402-31-7808...
756-30-7391
409-56-7008...
756-30-7391 532-86-9471...
899-46-2035 655-27-5281...
756-30-7391...
775-93-6481...
835-21-6639...
Indexes
• Keys:
• Logical
– Primary, foreign, and common
• Physical
– Single column or composite
– This is an index
• Indexes are not necessarily logical
keys
• Indexes can be applied to columns
that are not keys
• Can contain up to 16 columns
• Can have a maximum size of 256
bytes
Clustered Index
Data Pages
Page 1132
Key ptr Bennet
Page 1007 Chan
Bennet 1132 Dull
Greane 1133 Edwards
Hunter 1127
Key ptr
Page 1001
Bennet 1007 Page 1133
Karsen 1009 Greane
Smith 1062 Green
Greene
Key ptr
Page 1009
Karsen 1315 Page 11127
Hunter
Jenkins
Row
Key Page 1241
ptr 10 O'Leary
Page 1132 11 Ringer
Row Page Bennet 1421,1 12 White
Key Chan 1129,3 13 Jenkins
ptr ptr Dull 1409,1
Page 1007 Edwards 1018,5
Bennet 1421,1 1132
Greane 1242,4 1133
Hunter 1242,1 1127 Page 1242
14 Hunter
Row Page 15 Smith
Key ptr ptr 16 Ringer
Page 1001 Page 1133 17 Greane
Bennet 1421,1 1007 Greane 1242,4
Karsen 1876,1 1305 Green 1409,2
Smith 1242,1 1062 Greene 1421,2
Page 1305 Page 1421
Karsen 1876,1 1311 18 Bennet
19 Greene
20 Ringer
Page 1127
Hunter 1242,1
Jenkins 1241,4
Page 1409
21 Dull
22 Green
23 White
• Column Level
create table titles
(title_id tid not null,
title varchar(80) null,
pub_id char(4) null
constraint publishers_pub_id
references publishers(pub_id),
notes varchar(200) null)
• Restrictions
Referential Integrity
constraint salesdetail_FK2
foreign key (title_id)
references titles(title_id))
Referential Integrity
ALTER TABLE
[database.[owner].]table_name
[WITH NOCHECK]
[ADD
{col_name column_properties
[column_constraints]
| [[,] table_constraint]}
[, {next_col_name |
next_table_constraint}]...]
|
[DROP [CONSTRAINT]
constraint_name [,
constraint_name2]...]
Getting Help