oracle视图、存储过程、定时任务、用户授权、备份表

视图

sql 复制代码
create or replace view user_view as
select user_id,dept_id,phonenumber,name,user_name from sys_user where del_flag='0' and status='0' and sfyzh='Y';

存储过程

sql 复制代码
create or replace procedure sg_zzjg
as
       cursor region_list is

     select ID_,CODE_,CREATE_TIME,CREATE_USER_ID,DATA_AREA_CODE,DEL_FLAG,
     ORDER_NUMBER,REMARK_,UPDATE_TIME,UPDATE_USER_ID,ADDRESS_,AREA_SITUATION,
     GOVERNANCE_SITUATION,KEY_WORD,LAYER_LABEL_ID,ORDER_,PARENT_ID,REGION_CODE,
     REGION_NAME,REGION_TYPE,LEVEL_,CENTERID,MAPLEVEL,PROVICECODE,TREE_TYPE,LONGITUDE,
     LATITUDE,EXTEND_ATT,LXDH from REGION@Zhzx11_35_Operention;


     cursor user_list is
     select user_id,dept_id,phonenumber,name,user_name
     from SYS_USER@Zhzx11_35_Operention
     where del_flag='0' and status='0' and sfyzh='Y';

     cursor jgbm_list is
     select ID,BMMC,BMBM,BMJC,BGSDH,YB,DZ,SSQUY,SJBM,SSQIY,LXR,
     LXDH,BMMS,SFJDYBM,SFYGDZTQYQX,SFQY,SORT,CREATE_BY,CREATE_TIME,
     UPDATE_BY,UPDATE_TIME,DEL_FLAG,JLSJ,SFZYBM,ANCESTORS,ISBSC,SFQZ,
     BMLB,SFDBBM,SFBSC,ZSKBMBM,U_ID
     from YW_JGBMXXB@Zhzx11_35_Operention
    where del_flag=0  and sfqy=0;


     begin

         delete from sg_region;
         delete from sg_users;
         delete from sg_jgbm;


      for x in region_list
         loop
           insert into sg_region(ID_, CODE_, CREATE_TIME, CREATE_USER_ID, DATA_AREA_CODE, DEL_FLAG, ORDER_NUMBER, REMARK_, UPDATE_TIME, UPDATE_USER_ID,
                                     ADDRESS_, AREA_SITUATION, EXTEND_ATT, GOVERNANCE_SITUATION, KEY_WORD, LAYER_LABEL_ID, ORDER_, PARENT_ID, REGION_CODE, REGION_NAME,
                                     REGION_TYPE, LEVEL_, CENTERID, MAPLEVEL, PROVICECODE, TREE_TYPE)
           values(x.ID_, x.CODE_, x.CREATE_TIME, x.CREATE_USER_ID, x.DATA_AREA_CODE, x.DEL_FLAG, x.ORDER_NUMBER, x.REMARK_, x.UPDATE_TIME, x.UPDATE_USER_ID,
                                     x.ADDRESS_, x.AREA_SITUATION, x.EXTEND_ATT, x.GOVERNANCE_SITUATION, x.KEY_WORD, x.LAYER_LABEL_ID, x.ORDER_, x.PARENT_ID, x.REGION_CODE, x.REGION_NAME,
                                     x.REGION_TYPE, x.LEVEL_, x.CENTERID, x.MAPLEVEL, x.PROVICECODE, x.TREE_TYPE);
         end loop;

     for x in user_list
         loop
           insert into sg_users(user_id,dept_id,phonenumber,name,user_name)
           values(x.user_id,x.dept_id,x.phonenumber,x.name,x.user_name);
         end loop;

     for x in jgbm_list
         loop
           insert into sg_jgbm( ID,BMMC,BMBM,BMJC,BGSDH,YB,DZ,SSQUY,SJBM,SSQIY,LXR,
                LXDH,BMMS,SFJDYBM,SFYGDZTQYQX,SFQY,SORT,CREATE_BY,CREATE_TIME,
                UPDATE_BY,UPDATE_TIME,DEL_FLAG,JLSJ,SFZYBM,ANCESTORS,ISBSC,SFQZ,
                BMLB,SFDBBM,SFBSC,ZSKBMBM,U_ID)
           values(x.ID,x.BMMC,x.BMBM,x.BMJC,x.BGSDH,x.YB,x.DZ,x.SSQUY,x.SJBM,x.SSQIY,x.LXR,
                x.LXDH,x.BMMS,x.SFJDYBM,x.SFYGDZTQYQX,x.SFQY,x.SORT,x.CREATE_BY,x.CREATE_TIME,
                x.UPDATE_BY,x.UPDATE_TIME,x.DEL_FLAG,x.JLSJ,x.SFZYBM,x.ANCESTORS,x.ISBSC,x.SFQZ,
                x.BMLB,x.SFDBBM,x.SFBSC,x.ZSKBMBM,x.U_ID);
         end loop;

      commit;

end sg_zzjg;

定时任务

sql 复制代码
var sg_zzjg number;
 begin
 dbms_job.submit(:sg_zzjg,'sg_zzjg;',Trunc(sysdate)+1/24 ,'Trunc(sysdate+1)+1/24');
 end;
/

sg_zzjg 存储过程的名字。每天凌晨一点执行。
一定要在cmd窗口执行

用户授权

sql 复制代码
create user SG  identified by SG_20240119_;#创建用户和密码
GRANT CREATE SESSION TO username;#授权连接权限
GRANT RESOURCE TO username;#授权资源权限
grant select on JGBM_VIEW to SG;
grant select on REGION_VIEW to SG;
grant select on USER_VIEW to SG;
grant select on JGBM_VIEW to SG;#授权视图查询权限
grant select on REGION_VIEW to SG;
grant select on USER_VIEW to SG;

备份表

sql 复制代码
CREATE TABLE new_table_name AS SELECT * FROM table_name;
相关推荐
远歌已逝2 小时前
维护在线重做日志(二)
数据库·oracle
qq_433099403 小时前
Ubuntu20.04从零安装IsaacSim/IsaacLab
数据库
Dlwyz3 小时前
redis-击穿、穿透、雪崩
数据库·redis·缓存
工业甲酰苯胺5 小时前
Redis性能优化的18招
数据库·redis·性能优化
没书读了6 小时前
ssm框架-spring-spring声明式事务
java·数据库·spring
i道i7 小时前
MySQL win安装 和 pymysql使用示例
数据库·mysql
小怪兽ysl7 小时前
【PostgreSQL使用pg_filedump工具解析数据文件以恢复数据】
数据库·postgresql
wqq_9922502777 小时前
springboot基于微信小程序的食堂预约点餐系统
数据库·微信小程序·小程序
爱上口袋的天空7 小时前
09 - Clickhouse的SQL操作
数据库·sql·clickhouse
聂 可 以9 小时前
Windows环境安装MongoDB
数据库·mongodb