学习_Oracle_安全的数据库脚本

包含升级以及回滚
--update
declare
    icount number;
begin
    select count(*) into icount from user_tables where table_name = upper('CGW_T_KAFKAMQCONF');
    if icount = 0 then
        execute immediate '
        create table CGW_T_KAFKAMQCONF(
		   TopicName         		VARCHAR2(100)		not null,
		   BrokerUrl				VARCHAR2(300)		not null,
		   KafkaParam				VARCHAR2(300)		not null,
		   TopicParam			    VARCHAR2(300)		not null,
		   Partition				INTEGER default -1  not null,
		   GroupId                  INTEGER,
		   constraint PK_CGW_T_KAFKAMQCONF primary key (TopicName) using index tablespace TS_MDSP_IDX
		) tablespace TS_MDSP_DATA
        ';
    
        commit;
    end if;    
end;
/

declare
icount INTEGER;
begin
    select count(*) into icount from CGW_T_PLUGIN where PLUGINNAME = 'kafkamqproducer';
    if icount = 0
    then
insert into CGW_T_PLUGIN (PLUGINNAME, NODETYPE, NODEID, MAJORVERSION, MINORVERSION, STATUS, ISPLATPLUGIN, MODIFIEDTIME, PLUGINDESC, PLUGINPROVISION)
select 'kafkamqproducer', 10, 0, 1, 0, 1, 0, null, 'kafkamqproducer', 'Huawei Technologies Co., Ltd.' from dual
where not exists (select 1 from CGW_T_AUTH where INTERFACEID = '0x100008B8' and NEID = '6900000001');
    end if;
commit;
end;
/

declare
icount INTEGER;
begin
    select count(*) into icount from CGW_T_KAFKAMQCONF where TopicName = 'PayBind';
    if icount = 0
    then
insert into CGW_T_KAFKAMQCONF (TopicName, BrokerUrl, KafkaParam, TopicParam, Partition)
select 'PayBind', '10.136.95.6:9092', 'queue.buffering.max.messages=100000', 'message.timeout.ms=30000', -1 from dual
where not exists (select 1 from CGW_T_AUTH where INTERFACEID = '0x100008B8' and NEID = '6900000001');
    end if;
commit;
end;
/



--rollback

delete from CGW_T_PLUGIN where PLUGINNAME = 'kafkamqproducer'
/

delete from CGW_T_KAFKAMQCONF where TopicName = 'PayBind'
/

declare
    icount number;
begin
    select count(*) into icount from user_tables where table_name = upper('CGW_T_KAFKAMQCONF');
    if icount > 0 then
        execute immediate 'DROP table CGW_T_KAFKAMQCONF ';   
        commit;
    end if;    
end;
/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值