1语法:
create table 表名 as select ..........
2用处:
是复制表结构和表数据
3例子:
(1*)
SQL> create table tt 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 tt;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL>
(2*)
SQL> create table ss as select * from dept where deptno=1;
Table created.
SQL> select * from ss;
no rows selected
SQL> select deptno from ss;
no rows selected
SQL> desc ss;
Name Null? Type
----------------------------------------- -------- ----------------------------
DEPTNO NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
SQL> desc tt;
Name Null? Type
----------------------------------------- -------- ----------------------------
DEPTNO NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
SQL>
4总结:
能复制数据结构和数据 但where条件不成立的时候,只生产表结构。