zoukankan      html  css  js  c++  java
  • 数据完整性

    1、域完整性

      域完整性通过Check约束和Not Null约束实现,以限制输入值,保证数据的完整性。
       |`Check`约束|检查约束|
      | `Not Null`约束|非空约束|
      在创建表时实现域完整性:
            Create table goods(
                  id int not null check(id>=0)                 
            )
      在修改表时实现域完整性:
            Alter table goods  add constraint ck_id check(id>=0)
            Alter table goods  modify column id int not null
    

    2、实体完整性

      实体完整性通过Primary约束和Unique约束实现,不允许对应列中重复出现重复值。
       `Primary key`约束|主键约束
       `Unique key`约束|唯一约束
           在创建表时实现域完整性:
            Create table goods(
                  id int constraint pk_id primary key,
                  name char(6) constraint uq_name unique       
            )
            在修改表时实现域完整性:
            Alter table goods  add constraint pk_id primary key(id)
            Alter table goods  add constraint uq_name unique(name)
    

    3、参照完整性

       `Foreign Key`约束|外键约束
         在创建表时实现参照完整性:
            Create table goods(
                  id int not null references order(goods_id),
            )
          在修改表时实现参照完整性:
           Alter table goods  add constraint fk_id foreign key(id) references order(goods_id)
  • 相关阅读:
    高级选项更改MathType数学公式样式
    tp 批量转码
    create the web service by yourshelf
    云通讯 添加群组
    sql 更新字段
    op bug 修复计划
    php ut8声明
    PHP 包含文件
    php 判断查询结果是否为空
    合并列值
  • 原文地址:https://www.cnblogs.com/TheFaceOfAutumnWhenSummerEnd/p/13619061.html
Copyright © 2011-2022 走看看