重建outln用户脚本(不知道以前在什么地方看到的,现贴出共享)

-- createoutln.sql的详细脚本

[@more@]set serveroutput on
declare
user_exists exception;
outln_user number;
outln_tables number;
extra_outln_tables number;
ddl_cursor integer;
begin
select count(*) into outln_user from user$ where name = 'OUTLN';
select count(*)
into outln_tables
from obj$
where name in ('OL$', 'OL$HINTS') and
owner# = (select user# from user$ where name = 'OUTLN');
select count(*)
into extra_outln_tables
from obj$
where name not in ('OL$', 'OL$HINTS') and type# = 2 and
owner# = (select user# from user$ where name = 'OUTLN');
ddl_cursor := dbms_sql.open_cursor;
if outln_user = 0
then
dbms_sql.parse(ddl_cursor,
'create user outln identified by outln',
dbms_sql.native);
dbms_sql.parse(ddl_cursor,
'grant connect, resource, execute any procedure to outln',
dbms_sql.native);
dbms_sql.parse(ddl_cursor,
'create table outln.ol$ ( ' ||
'ol_name varchar2(30), ' || 'sql_text long, ' ||
'textlen number, ' || 'signature raw(16), ' ||
'hash_value number, ' || 'category varchar2(30), ' ||
'version varchar2(64), ' || 'creator varchar2(30), ' ||
'timestamp date, ' || 'flags number, ' ||
'hintcount number)',
dbms_sql.native);
dbms_sql.parse(ddl_cursor,
'create table outln.ol$hints ( ' ||
'ol_name varchar2(30), ' || 'hint# number, ' ||
'category varchar2(30), ' || 'hint_type number, ' ||
'hint_text varchar2(512), ' || 'stage# number, ' ||
'node# number, ' || 'table_name varchar2(30), ' ||
'table_tin number, ' || 'table_pos number)',
dbms_sql.native);
dbms_sql.parse(ddl_cursor,
'create unique index outln.ol$name ' ||
'on outln.ol$(ol_name)',
dbms_sql.native);
dbms_sql.parse(ddl_cursor,
'create unique index outln.ol$signature ' ||
' on outln.ol$(signature,category)',
dbms_sql.native);
dbms_sql.parse(ddl_cursor,
'create unique index outln.ol$hnt_num ' ||
' on outln.ol$hints(ol_name, hint#)',
dbms_sql.native);
dbms_output.put_line('OUTLN CREATION SUCCESSFUL');
else
if outln_tables != 2 or extra_outln_tables != 0
then
dbms_output.put_line('ERROR - OUTLN USER ALREADY EXISTS');
raise user_exists;
else
dbms_output.put_line('OUTLN CREATION SUCCESSFUL');
end if;
end if;
exception
when user_exists then
raise;
end;
/

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/802415/viewspace-823070/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/802415/viewspace-823070/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值