SQL Server 6インデックスとデータ整合性の実験

10096 ワード

SQL Server 6インデックスとデータ整合性の実験
これはシリーズで、いくつかのドキュメントを一緒に見る必要があります.
--  6.1  
--1、    
Create INDEX depart_ind
	on Employees(departmentID)
Create INDEX ad_ind
	on Employees(Name,Address)
Create UNIQUE INDEX dep_ind
	on Departments(departmentName)
--2、    
Alter INDEX ALL
	on Employees REBULD
--3、    
Drop INDEX depart_ind on Employees
--  6.2   
--(1)
Create Table Employees5
(
EmployeeID char(6) not null,
Name char(10) not null primary key,
Sex tinyint,
Education char(4),
constraint uk_id Unique(EmployeeID))
--(2)
Alter table Employees5
	Drop constraint uk_id
--    
Create Table Employees6
(
EmployeeID char(3) not null,
Name char(10) not null,
Sex tinyint,
Education char(4),
constraint eid6 primary key(EmployeeID,Name))
--    Address
Alter Table Employees6
	Add Address char(20)
		constraint a_id Unique(Address)
--(3)      ,          ,        
Create Table student
(
   char(10) not null,
   char(2) not null 
check (   in (' ', ' ')))
--       ,          
Insert student values('1021','  ')
--(4)  salary2, salary2 outcome  income
Create Table salary2
(
EployeeID char(10) not null,
income float not null,
outcome float not null,
Check (income>=outcome)
)
--(5)
Alter Table Employees
	Add constraint depart check(DepartmentID>=1 and DepartmentID<=5)
--(6)        
Create RULE list_rule
	As @list in('   ', '   ', '     ', '   ')
--(7)
Create Table salary3
(
EmpoyeeID char(6) not null primary key,
Income float not null,
Outcome float not null,
foreign key(EmployeeID)
	references salary(EmployeeID)
		on update cascade
		on delete cascade
)