|
在dbms_stat语句前加begin 后加end;
SQL> dbms_stats.gather_table_stats(ownname => 'HR',tabname => 'REGIONS',estimate_percent => 20,cascade => TRUE,force =>TRUE);
SP2-0734: 未知的命令开头 "dbms_stats..." - 忽略了剩余的行。
SQL> begin dbms_stats.gather_table_stats(ownname => 'HR',tabname => 'REGIONS',estimate_percent => 20,cascade => TRUE,force =>TRUE) e
nd;
2 /
begin dbms_stats.gather_table_stats(ownname => 'HR',tabname => 'REGIONS',estimate_percent => 20,cascade => TRUE,force =>TRUE) end;
*
第 1 行出现错误:
ORA-06550: 第 1 行, 第 127 列:
PLS-00103: 出现符号 "END"在需要下列之一时:
:= . ( % ;
符号 ";" 被替换为 "END" 后继续。
已用时间: 00: 00: 00.07
SQL> begin dbms_stats.gather_table_stats(ownname => 'HR',tabname => 'REGIONS',estimate_percent => 20,cascade => TRUE,force =>TRUE);
end;
2 /
PL/SQL 过程已成功完成。
已用时间: 00: 00: 00.62
SQL> create or replace procedure benben
2 as
3 vSqlStatement varchar2(10000);
4
5 cursor cur_gather_tab_statistics is
6 select 'begin dbms_stats.gather_table_stats(ownname => ''' || owner ||
7 ''',tabname => ''' || segment_name ||
8 ''',estimate_percent => 20,cascade => TRUE,force => TRUE); end;'
9 from dba_segments
10 where segment_type = 'TABLE'
11 and owner in ('HR');
12
13 begin
14
15 open cur_gather_tab_statistics;
16 fetch cur_gather_tab_statistics into vSqlStatement;
17 while cur_gather_tab_statistics%found loop
18 dbms_output.put_line(vSqlStatement);
19 execute immediate vSqlStatement;
20 fetch cur_gather_tab_statistics into vSqlStatement;
21 end loop;
22 close cur_gather_tab_statistics;
23
24 end;
25 /
过程已创建。
已用时间: 00: 00: 00.03
SQL> exec benben |
|