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
。
我有两个模式,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
语句有效。