当前位置:网站首页>【数据库】期末必知必会-----第七章 数据库完整性
【数据库】期末必知必会-----第七章 数据库完整性
2022-07-17 03:22:00 【小羊不会飞】
第七章 数据库完整性
1、数据库完整性的概念
概念:数据库中数据在逻辑上的一致性、正确性、有效性和相容性
2、数据完整性包含哪三个方面(分别是什么含义;能举出例子)
实体完整性:对主键的约束
参照完整性:对外键的约束
用户自定义完整性:针对某一具体应用数据必须满足的语义要求
例子:
学生表中设置学号为主键,体现了实体完整性;学生表中的专业号为外码,参照专业表中的主码专业号,体现了参照完整性;学生表中性别字段设置为只能取男/女,体现了用户自定义完整性;
3、触发器的含义,什么时候激活
含义:用户定义在关系表上的一类由事件驱动的特殊过程
激活:INSERT、DELETE、UPDATE
4、会写触发器(代码)
//例1
CREATE TRIGGER test_trg
AFTER INSERT
ON stu
FOR EACH ROW
INSERT INTO test VALUES(SYSDATE());
INSERT INTO stu VALUES('1','Mary','F','2002-10-13');
SELECT * FROM test;
//例2
CREATE TRIGGER del_trig
AFTER DELETE
ON course
FOR EACH ROW
DELETE FROM sc WHERE 课号=OLD.课号;边栏推荐
- 【超能云终端创领先机】本地计算云端管理,英特尔助力教育数字化
- A Tutorial on Learned Multi-dimensional Indexes
- Micro, m3o micro service series (III)
- Automake Chinese Manual_ incomplete
- HCIP第七天笔记
- 可省近90%服务器,反欺诈效率却大增,PayPal打破「AI内存墙」的方案为何如此划算?
- [try to hack] NTLM authentication process
- Tutorial: Adaptive Replication and Partitioning in Data Systems
- 学术分享 | 基于OpenVINO的多染色病理图像信息评估系统设计与开发
- 【论文笔记】VOLO: Vision Outlooker for Visual Recognition
猜你喜欢

【Notebook系列第七期】OpenVINO预训练模型的的下载和使用方法

【黄啊码】MySQL入门—5、数据库小技巧:单个列group by就会,多个列呢?

Redis数据迁移:方法二AOF

Program analysis and Optimization - 11 multi branch analysis

Styleflow concise reading: use continuous flow to complete attribute editing

Leetcode 931: minimum sum of descent path

Hcip day 5 notes

可省近90%服务器,反欺诈效率却大增,PayPal打破「AI内存墙」的方案为何如此划算?

Hcip day 6 notes

HCIP第六天笔记
随机推荐
DataX dorisworter plug-in documentation
1255. Dynamic programming for state compression of the word set with the highest score
Laradock restart MySQL found
剑指 Offer 60. n个骰子的点数
2022 Yangtze River Delta mathematical modeling: Gearbox Fault Diagnosis
程序分析与优化 - 11 多分支分析
Swagger
Hcip day 6 notes
Tutorial: Adaptive Replication and Partitioning in Data Systems
Realize the dual opening of wechat on the computer (log in to two wechat)
Application of MATLAB in linear algebra
Styleflow concise reading: use continuous flow to complete attribute editing
Redis data migration: Method 1 RDB
hello world驱动
Doris learning notes query
Teaching reform and software platform of entrepreneurship practice simulation
Session和Cookie的工作原理
Why do more and more people choose to live a "low life"?
基于OpenVINO Model Server打造人像抠图服务器
Redis batch deletes keys with specific prefixes