ALTER TABLE RENAME ステートメントと RENAME TABLE ステートメントの違いは何ですか。
つまり、
Alter table old_table_name rename to new_table_name
と
rename table old_table_name to new_table_name.
ALTER TABLE RENAME ステートメントと RENAME TABLE ステートメントの違いは何ですか。
つまり、
Alter table old_table_name rename to new_table_name
と
rename table old_table_name to new_table_name.
テーブルの名前を old_table_name から new_table_name に変更します。
その構文は間違っています。table
キーワードは必要ありません。正しい構文は -
rename old_table_name to new_table_name;
alter
それでは、ステートメントと単純なステートメントの違いを見てみましょうrename
。
私は 2 つのスキーマを持っていSCOTT
ますLALIT
。
SQL> SHOW USER
USER is "SCOTT"
SQL>
SQL> create table t(id number);
Table created.
SQL> rename t to t_new;
Table renamed.
SQL> alter table t_new rename to t_newer;
Table altered.
したがって、両方のステートメントは同じ で機能しschema
ます。
他のスキーマに接続しましょう -
SQL> SHOW USER
USER is "LALIT"
SQL>
SQL> create table t(id number);
Table created.
SQL> rename scott.t_newer to t_newest;
rename scott.t_newer to t_newest
*
ERROR at line 1:
ORA-01765: specifying owner's name of the table is not allowed
SQL> alter table scott.t_newer rename to t_newest;
Table altered.
したがって、エラーが表示されますORA-01765: specifying owner's name of the table is not allowed
。これは、単純なrename
ステートメントが他のスキーマ オブジェクトで失敗する場所です。ALTER
ステートメントのみが機能します。