You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
shandan/dbsql/bianmu-clean.sql

44 lines
2.0 KiB

-- 数据库清理脚本
-- 指定数据库模式名
set SCHEMA BIANMU;
--清理数据源表
delete from B_DATA_SOURCE;
--清理目录表
delete from B_DIRECTORY T1 where T1.ID not in('-');
--清理元数据表
delete from B_METADATA_BASIC;
delete from B_METADATA_DETAILS;
--清理目录与元数据关系表
delete from B_DIRECTORY_METADATA;
--清理审核记录表
delete from B_REVIEW_RECORD;
-- 清理用户表
delete from SYS_USER where SYS_USER.USER_ID not in('sa','admin','zhangsan','artisan');
-- 清理机构表
delete from SYS_ORG where SYS_ORG.ID <> 'ROOT';
-- 清理角色表
delete from SYS_ROLE where SYS_ROLE.ROLE_ID not in('3fb1c570496d4c09ab99b8d31b06ccc','3fb1c570496d4c09ab99b8d31b06xxx','3fb1c570496d4c09ab99b8d31b06zzz');
-- 清理权限表
delete from SYS_PERMISSIONS where PERMIS_ID not in('PERMIS_ONLY_ORG','PERMIS_ONLY_SELF','PERMIS_ORG_LEADER','PERMIS_ROOT');
--清理操作日志表
delete from SYS_OPERATE_LOG;
--清理通知表
delete from SYS_NOTIFICATION;
delete from SYS_NOTIFICATION_UNREAD;
--清理文件表
delete from SYS_FILE;
delete from SYS_FILE_CHUNK;
-- 清理用户角色关系表
delete from SYS_USER_ROLE T1 where T1.ROLE_ID not in(select ROLE_ID from SYS_ROLE);
delete from SYS_USER_ROLE T1 where T1.USER_ID not in(select USER_ID from SYS_USER);
-- 清理角色权限表
delete from SYS_ROLE_PERMISSIONS T1 where T1.ROLE_ID not in(select ROLE_ID from SYS_ROLE);
delete from SYS_ROLE_PERMISSIONS T1 where T1.PERMIS_ID not in(select PERMIS_ID from SYS_PERMISSIONS);
-- 清理权限机构表
delete from SYS_PERMIS_ORG T1 where T1.PERMIS_ID not in(select PERMIS_ID from SYS_PERMISSIONS);
delete from SYS_PERMIS_ORG T1 where T1.ORG_ID not in(select ID from SYS_ORG);
-- 清理用户客户端关系表
delete from SYS_USER_CLIENT T1 where T1.USER_ID not in(select USER_ID from SYS_USER);
delete from SYS_USER_CLIENT T1 where T1.CLIENT_ID not in(select CLIENT_ID from OAUTH_CLIENT_DETAILS);
--清理角色菜单表
delete from SYS_ROLE_MENU T1 where T1.ROLE_ID not in(select ROLE_ID from SYS_ROLE);