CREATE TABLE 表名 AS SELECT 語句


 
SQL
> select * from dept; DEPTNO DNAME LOC ------ -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL> create table dept2 as select * from dept; Table created SQL> select * from dept; DEPTNO DNAME LOC ------ -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL> select * from dept2; DEPTNO DNAME LOC ------ -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL> create table dept3 as select * from dept where 1 = 2; Table created SQL> select * from dept3; DEPTNO DNAME LOC ------ -------------- ------------- SQL> select OWNER from user_constraints where table_name = 'DEPT'; OWNER -------------------------------------------------------------------------------- SCOTT SQL> select OWNER from user_constraints where table_name = 'DEPT2'; OWNER --------------------------------------------------------------------------------

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as scott

由上面的使用 CREATE TABLE 表名 AS SELECT 語句可以看出:

    1:只會復制表數據和表結構,不會有任何約束。

    2:當 where 條件不成立時,只復制表結構,沒有任務數據。

轉自:http://ears.iteye.com/blog/1470605

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM