【发布时间】:2013-11-30 14:49:17
【问题描述】:
我在 PS 服务器中有 7 个表,其中包含过去 3 年的数据(数十亿条记录)。要求是将所有数据移动到备份表中,除了最后几个月的数据。所以我们接近:
- 1) 将现有表名更改为备份表
- 2) 然后新建表
- 3) 然后将 3 个月的数据移动到新表中。
这样数据处理会很快。
我尝试使用以下查询来更改表名,但它不起作用。任何人都可以帮忙。这是高优先级。
declare
sql_stmt varchar2(1000);
cursor c1 is select table_name from staging_clear;
type t1 is table of c1%rowtype;
curtype t1;
begin
open c1;
fetch c1 bulk collect into curtype;
for i in 1..curtype.count loop
sql_stmt:= 'begin
alter table '||curtype(i).table_name||' rename to '|| curtype(i).table_name||'_bkp';
dbms_output.put_line(sql_stmt);
execute immediate sql_stmt;
dbms_output.put_line(sql_stmt);
end loop;
end;
错误报告:
ORA-06550:第 2 行,第 11 列:PLS-00103:遇到符号 预期以下情况之一时的“ALTER”:开始案例声明退出 for goto if loop mod null pragma raise return select update while with
【问题讨论】:
-
在你的 sql_stmt 中松开开头
-
我也有高优先级...