Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kiryuu Sakuya
Database-test
Commits
30aa10f8
Verified
Commit
30aa10f8
authored
Dec 17, 2019
by
Kiryuu Sakuya
🎵
Browse files
Finish No.2
parent
c0cfb3af
Changes
1
Hide whitespace changes
Inline
Side-by-side
02. 某电影资料数据库.md
View file @
30aa10f8
...
...
@@ -304,14 +304,22 @@ DELIMITER ;
### 8. 用 SQL 编写一个完整性规则,当插入上映信息时,如果公司名称为 `Warner Bros` 并且该公司的电影的制作年份大于 2012,则自动将票价提高 20%
```
mysql
DELIMITER //
CREATE TRIGGER oh_my_2012 AFTER INSERT ON I FOR EACH ROW
BEGIN
UPDATE I SET
Iprice = New.Iprice * 1.2
WHERE I.Mno IN (SELECT M.Mno FROM M WHERE M.Mname = 'Warner Bros' AND M.Myear = '2012');
END //
DELIMITER ;
```
不完整测试代码(懒得补充其它的了,电影是
[
疯狂原始人
](
https://movie.douban.com/subject/1907966/
)
):
```
mysql
INSERT INTO I (
Ino, Mno, Itime, Iprice
) VALUE (
40004, 30004, "2013-04-20", "9.99"
);
```
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment