您好,登錄后才能下訂單哦!
本篇內容主要講解“數據庫中怎么解決修改表名時遇到ORA-14047錯誤”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“數據庫中怎么解決修改表名時遇到ORA-14047錯誤”吧!
SQL> show user; USER is "TEST" SQL> create table rename_table ( id int); Table created. SQL> select table_name from user_tables; TABLE_NAME -------------------------------------------------------------------------------- RENAME_TABLE
SQL> show user; USER is "SYS" SQL> alter table test.RENAME_TABLE rename to test.RENAME_TABLE2; alter table test.RENAME_TABLE rename to test.RENAME_TABLE2 * ERROR at line 1: ORA-14047: ALTER TABLE|INDEX RENAME may not be combined with other operations
問題原因
Oracle是允許A用戶修改B用戶表名的,但是在新表名前是不能指定用戶名的,使用如下方法修改表名成功。
SQL> alter table test.RENAME_TABLE rename to RENAME_TABLE2; Table altere SQL> select OWNER,TABLE_NAME from dba_tables where owner='TEST'; OWNER TABLE_NAME -------------------- -------------------- TEST RENAME_TABLE2
++++++++++++++++++++++++++++++++分割線+++++++++++++++++++++++++++++++
還有一個修改表名的命令rename to ,但是這個命令只能修改自己用戶下表的表名
使用Sys用戶修改test用戶表的表名
SQL> show user; USER is "SYS" SQL> select OWNER,TABLE_NAME from dba_tables where owner='TEST'; OWNER TABLE_NAME -------------------- -------------------- TEST RENAME_TABLE2 SQL> rename test.RENAME_TABLE2 to RENAME_TABLE; rename test.RENAME_TABLE2 to RENAME_TABLE * ERROR at line 1: ORA-01765: specifying owner's name of the table is not allowed
切換為test用戶,修改表名成功
SQL> show user; USER is "TEST" SQL> select OWNER,TABLE_NAME from dba_tables where owner='TEST'; OWNER TABLE_NAME -------------------- -------------------- TEST RENAME_TABLE2 SQL> rename RENAME_TABLE2 to RENAME_TABLE; Table renamed. SQL> select OWNER,TABLE_NAME from dba_tables where owner='TEST'; OWNER TABLE_NAME -------------------- -------------------- TEST RENAME_TABLE
到此,相信大家對“數據庫中怎么解決修改表名時遇到ORA-14047錯誤”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。