zoukankan      html  css  js  c++  java
  • 7.索引和数据完整性

    use YGGL
    
    --建立索引
    create index index_dep
    on Employees(DepID)
    
    --建立复合索引
    create index index_com
    on Employees(EmpName,EmpSex)
    
    --建立唯一聚集索引
    create unique clustered index index_uc
    on Employees(EmpID)
    
    --重建索引
    alter index all
      on Employees rebuild
    
    --删除索引
    drop index index_com
     on Employees
    
    --创建表是创建主键约束或唯一约束
     create table Employees5
     (
     EmployeeID int not null unique,
     EmpName varchar(6) not null primary key,--constraint pk_en primay key
     EmpSex bit not null,
     EmpEdu char(3) not null
     )
    
     --修改表时创建主键约束或唯一约束
     alter table Employees5
     add
     constraint uk_es unique(EmpSex)
    
     --删除主键约束或唯一约束
     alter table Employees5
     drop constraint uk_es
    
     --创建表是添加check约束
     create table student
     (
     sName varchar(6) not null,
     sAge int not null
     check(sAge<100 and sAge>0)
     )
    
      create table student1
     (
     sName varchar(6) not null,
     sSex char(2) not null
     check(sSex in('男','女'))
     )
    
     --修改表是添加check约束
     alter table student1
     add 
     constraint ck_age check(sage<100) 
    
     --删除check约束
     alter table student1
     drop constraint ck_age
    
    --外键 foreign key

  • 相关阅读:
    OpenSLAM
    CAD&CG GDC 2018大会论文录用名单
    hdu4328(经典dp用悬线法求最大子矩形)
    hdu3729(二分图)
    hdu 4055(经典问题)
    Codeforces Round #207 (Div. 1) B (gcd的巧妙运用)
    hdu1066(经典题)
    zoj3662(dp)
    zoj3659(经典并查集)
    hdu4565(矩阵快速幂+经典的数学处理)
  • 原文地址:https://www.cnblogs.com/wangxueliang/p/9346508.html
Copyright © 2011-2022 走看看