2011-10-19 45 views
0

當我們使用CTAS這樣的:甲骨文刪除和重建同義詞

create table big2 as select * from big1; 
drop table big1; 
rename big2 to big1; 

如果有同義詞現有的BIG1,我們需要對刪除並重新創建它們之前BIG1下降代名詞?或者這不是必要的?

+1

就叫'創建synonym',看看它失敗。測試它會比在這裏寫下你的問題更快。 :) – GolezTrol

回答

1

不需要。別名同義詞是您爲對象提供的另一個名稱(無論是否在您的架構中)。請參閱下面的代碼。

(順便說一句,你不應該重命名錶T2直接點t1 ??請問你CTAS有其他有條件的地方,你在這裏沒有顯示?)

SQL> create table t1 as 
    2 select * from scott.emp; 

Table created. 

SQL> select count(*) from t1; 

    COUNT(*) 
---------- 
     14 

SQL> select count(*) from t2; 
select count(*) from t2 
        * 
ERROR at line 1: 
ORA-00942: table or view does not exist 


SQL> create synonym s1 for t1; 

Synonym created. 

SQL> create table t2 as 
    2 select * from t1; 

Table created. 

SQL> drop table t1; 

Table dropped. 

SQL> alter table t2 rename to t1; 

Table altered. 

SQL> select count(*) from t1; 

    COUNT(*) 
---------- 
     14 

SQL> select count(*) from s1; 

    COUNT(*) 
---------- 
     14