zoukankan      html  css  js  c++  java
  • 同义词使用案例

    --创建表(PUB_SYSLOG)
    create table PUB_SYSLOG
    (
    logid VARCHAR2(36) not null,
    requestuser VARCHAR2(20),
    requesttime DATE not null,
    requestip VARCHAR2(20) not null,
    requesturl VARCHAR2(500),
    requestmethod VARCHAR2(100),
    requestparam VARCHAR2(4000),
    requestresult VARCHAR2(4000),
    logtype VARCHAR2(110),
    requestmethodnote VARCHAR2(4000)
    );
    --创建表(PUB_SYSLOG_BACKUP)
    create table PUB_SYSLOG_BACKUP
    (
    logid VARCHAR2(36) not null,
    requestuser VARCHAR2(20),
    requesttime DATE not null,
    requestip VARCHAR2(20) not null,
    requesturl VARCHAR2(500),
    requestmethod VARCHAR2(100),
    requestparam VARCHAR2(4000),
    requestresult VARCHAR2(4000),
    logtype VARCHAR2(110),
    requestmethodnote VARCHAR2(4000)
    );
    -- Add comments to the table
    comment on table PUB_SYSLOG_BACKUP
    is '日志备份';
    -- Create/Recreate primary, unique and foreign key constraints
    alter table PUB_SYSLOG_BACKUP
    add constraint PK_LOGBACK primary key (LOGID);
    --创建视图(关联日志表和日志备份表)
    create or replace view pub_syslogview as
    select "LOGID","REQUESTUSER","REQUESTTIME","REQUESTIP","REQUESTURL","REQUESTMETHOD","REQUESTPARAM","REQUESTRESULT","LOGTYPE","REQUESTMETHODNOTE" from pub_syslog
    union ALL
    select "LOGID","REQUESTUSER","REQUESTTIME","REQUESTIP","REQUESTURL","REQUESTMETHOD","REQUESTPARAM","REQUESTRESULT","LOGTYPE","REQUESTMETHODNOTE" from pub_syslog_backup;
    --创建同义词(基于视图的同义词)
    create or replace synonym PUB_SYSLOG_BACK
    for PUB_SYSLOGVIEW;
    --备份系统日志(存储过程,定时调用)
    create or replace procedure backup_pub_syslog is
    begin
    insert into pub_syslog_backup
    (logid,
    requestuser,
    requesttime,
    requestip,
    requesturl,
    requestmethod,
    requestparam,
    requestresult,
    logtype,
    requestmethodnote)
    select slog.logid,
    slog.requestuser,
    slog.requesttime,
    slog.requestip,
    slog.requesturl,
    slog.requestmethod,
    slog.requestparam,
    slog.requestresult,
    slog.logtype,
    slog.requestmethodnote
    from pub_syslog slog;
     
    delete pub_syslog;
     
    end backup_pub_syslog;
    --调用备份日志存储过程
    call backup_pub_syslog();
    commit;
    --查询操作日志
    select * from PUB_SYSLOG_BACK;
  • 相关阅读:
    android apk瘦身之 图片压缩 tinypng
    java 1.7 新io 实践 NIO2
    Still unable to dial persistent://blog.csdn.net:80 after 3 attempts
    dex2oat 加载多次
    android stadio open recent 在同一窗口打开
    &运算符的应用
    MethodTrace 生成的trace文件为空
    MethodTrace 生成的trace文件为空
    error: unknown host service 的详细解决办法
    error: unknown host service 的详细解决办法
  • 原文地址:https://www.cnblogs.com/wushuang0608/p/8405265.html
Copyright © 2011-2022 走看看