22 lines
501 B
SQL
22 lines
501 B
SQL
/*
|
||
尝试删除某一个登录人员记录,并要求图片集关联的数据置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; |