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

    参照完整性

    references tb_name(index_col_name,...)

    [on delete reference option]

    [on update reference option]

    限制策略级联策略置空策略不采取实施策略

    restrict | cascade | set null | no action \默认策略是restrict

    定义与实现完整性约束

    use mysql_test;

    create table orders

    (

      order_id int not null auto_increment,

      order_product char(50) not null,

      order_product_type char(50) not null,  

      cust_id int not null,

      order_date datetime not null,

      order_price double not null,

      order_amount int not null.

      primary key(order_id),

      foreign key(cust_id)

      references cust(cust_id)

      on delete restrict

      on update restrict

    )

    用户定义的完整性: 非空约束,check约束

    命名完整性约束: constraint[symbol]  \只能给基于表的完整性约束指定名字,无法给基于列的完整性约束指定名字

    更新完整性约束: 使用alter table语句更新与列或表有关的各种约束

    1)完整性约束不能直接被修改(先删除,再增加).

    2)使用alter table语句,可以独立的删除完整性约束,而不会删除表本身(drop table语句删除一个表,则表中所有的完整性约束都会被自动删除).

  • 相关阅读:
    13 | 效率为王:脚本与数据的解耦 + Page Object模型
    关于编程与生活
    我的python学习笔记
    Tarjan学习笔记
    web----https请求过程
    JVM----堆内存设置原理
    算法----快速排序
    SpringCloud----spring security Oauth2认证解决方案
    Mysql----insert/update/delete
    课外知识----单点登录
  • 原文地址:https://www.cnblogs.com/lsxsx/p/13393922.html
Copyright © 2011-2022 走看看