ITPub博客

首页 > 应用开发 > IT综合 > 重建outln用户脚本(不知道以前在什么地方看到的,现贴出共享)

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

原创 IT综合 作者:chance2000 时间:2006-03-26 00:38:50 0 删除 编辑

-- 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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    78
  • 访问量
    835306