使用sysdate更改表名

gun*_*yim 5 sql oracle

我想通过附加更改表名SYSDATE.例如,我想将表更改EXAMPLE_TABLEEXAMPLE_TABLE_05_01_2015,但我想从中获取日期SYSDATE.

我准备了以下但是它不起作用:

ALTER TABLE "MYDB"."EXAMPLE_TABLE" rename to (SELECT 'EXAMPLE_TABLE' || TO_CHAR(SYSDATE, '_dd_MM_yyyy') FROM DUAL);
Run Code Online (Sandbox Code Playgroud)

我怎样才能使它工作?

这是错误:

SQL Error: ORA-14047: ALTER TABLE|INDEX RENAME may not be combined with other operations
14047. 00000 -  "ALTER TABLE|INDEX RENAME may not be combined with other operations"
*Cause:    ALTER TABLE or ALTER INDEX statement attempted to combine
           a RENAME operation with some other operation which is illegal
*Action:   Ensure that RENAME operation is the sole operation specified in
           ALTER TABLE or ALTER INDEX statement;
Run Code Online (Sandbox Code Playgroud)

Ren*_*ger 6

使用execute immediate.

begin
   execute immediate 
   'alter table mydb.example_table rename to ' ||
   'example_table_' || to_char(sysdate, 'dd_mm_yyyy');
end;
/
Run Code Online (Sandbox Code Playgroud)

也就是说,我有预感你最好使用分区表.