我想通過向其添加SYSDATE
來更改表名稱。例如,我想將表EXAMPLE_TABLE
更改爲EXAMPLE_TABLE_05_01_2015
,但我想從SYSDATE
獲取日期。使用sysdate更改表名稱
我準備以下,但它不工作:
ALTER TABLE "MYDB"."EXAMPLE_TABLE" rename to (SELECT 'EXAMPLE_TABLE' || TO_CHAR(SYSDATE, '_dd_MM_yyyy') FROM DUAL);
我怎樣才能使它發揮作用?
以下是錯誤:
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;
回報你什麼錯誤? – rtome
你可以在'SQL * Plus'中使用'變量替換'。看到我的答案。 –