删除无效用户脚本
发布网友
发布时间:2022-05-29 03:07
我来回答
共1个回答
热心网友
时间:2024-11-14 11:43
可通过在数据库中执行一下脚本来删除无效用户,因用户会跟系统中其他很多业务表关联,所以需要先删除其关联表中的数据记录,以下语句基本能删除所有关联表中的用户信息,操作前请先备份数据库;
delete docex_fileOpinion where docexfiledetail_id in (select id from docex_filedetail where reaser_id in (select id from system_users where status=0))
delete docex_filedetail where reaser_id in (select id from system_users where status=0)
delete checkwork_history where login_users in (select id from system_users where status=0)
delete checkwork_report where login_user in (select id from system_users where status=0)
delete system_positionmember where user_id in (select id from system_users where status=0)
delete system_user_role where user_id in (select id from system_users where status=0)
delete bulletins_user where user_id in (select id from system_users where status=0)
delete messages where user_id in (select id from system_users where status=0)
delete worklog where user_id in (select id from system_users where status=0)
delete worklog_mx where worklog_id in (select id from worklog where user_id in (select id from system_users where status=0))
delete knowledge_read where user_id in (select id from system_users where status=0)
delete knowledges where modifyuser_id in (select id from system_users where status=0)
delete docex_file where user_id in (select id from system_users where status=0)
delete dbo.docex_fileattach where file_id in (select id from dbo.docex_file where user_id in (select id from system_users where status=0))
delete messages where fromuser_id in (select id from system_users where status=0)
delete dbo.task where user_id in (select id from system_users where status=0)
delete dbo.task_user where task_id in(select id from dbo.task where user_id in (select id from system_users where status=0))
delete system_users where status=0