?
1、創建表? -利用已有表,創建表
這樣創建的缺點-- 主鍵會丟失
-- 創建表,表結構與數據與t_emptest 一致 CREATE TABLE t_emptest1 AS SELECT * FROM t_emptest ;
-- 創建空表,表結構與t_emptest 一致 CREATE TABLE t_emptest1 AS SELECT * FROM t_emptest WHERE 1 = 2;
?
2、插入數據
-- 插入數據,利用已有表的數據插入新表中 -- 將t_emptest表中lucy的雇員信息插入到t_emptest1 表中 INSERT INTO t_emptest1 SELECT * FROM t_emptest WHERE ENAME='lucy'
?
-- 將lucy所在部門的雇員信息插入到t_emptest1中 INSERT INTO t_emptest1 SELECT * FROM t_emptest WHERE DEPTNO=(SELECT DEPTNO FROM t_emptest WHERE ENAME='lucy' )
?