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;
  • 相关阅读:
    Bw树:新硬件平台的B树(内存数据库中的b树索引)
    SQL Server 列存储索引强化
    SQL Server Column Store Indeses
    我了解的数据库事务复制
    [MySQL Reference Manual] 10 全球化
    [20141208]数据库复制并不会复制索引创建删除
    10个超赞的jQuery图片滑块动画
    推荐20款JavaScript框架给前端开发者
    7个华丽的基于Canvas的HTML5动画
    10个非常炫酷的jQuery相册动画赏析
  • 原文地址:https://www.cnblogs.com/wushuang0608/p/8405265.html
Copyright © 2011-2022 走看看