qfedu-linux-advanced-level/day9/homework/h6.sql

22 lines
501 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
尝试删除某一个登录人员记录并要求图片集关联的数据置NULL
*/
-- 进入 bookdb 数据库
USE bookdb;
-- 更新关联个人信息表数据为NULL
UPDATE profile_info SET login_id = NULL WHERE login_id = 1002;
-- 更新关联图片集表数据为NULL
UPDATE images SET user_id = NULL WHERE user_id = 1002;
-- 删除 login_id 为 1002 的用户
DELETE
FROM login
WHERE login_id = 1002;
-- 显示效果
SELECT * FROM login;
SELECT * FROM profile_info;
SELECT * FROM images;