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语句删除一个表,则表中所有的完整性约束都会被自动删除).

  • 相关阅读:
    500 多个 Linux 命令文档搜索
    C++ 字符串基本操作
    串的模式匹配算法
    查看、启动、关闭防火墙
    天润融通面试
    LeetCode 169. 求众数
    【面试题】人人车一次面试总结
    一个完整的 JS 身份证校验代码
    oracle多表查询
    百度地图的Icon
  • 原文地址:https://www.cnblogs.com/lsxsx/p/13393922.html
Copyright © 2011-2022 走看看