这个不解释,只是自我整理。mysql
insert EMP_EAST (DEPTNO,DNAME,LOC) select DEPTNO,DNAME,LOC from DEPT where LOC in ('NEW YORK','BOSTON')
说白了就是复制表的结构,pass 平台用的挺多的,须要动态建立表。sql
select * into dept_2 from DEPT where 1=0
介绍一下mysql的:code
create table dept_2 as select * from dept where 1=0
好比说有一张表,你只容许它插入某些固定的行,其余行不让插入。table
不少人会以为这个需求很奇怪,不让插入那么要其余列干啥呢?其余列可能就是默认值了。class
实现这种需求也特别简单,采用视图的方式,原理就是更新视图那么对应的表也会更新。原理
create view new_emps as select empno,ename,job from EMP
而后插入视图,就能够了。select
insert into new_emps(empno,ename,job) values(1,'xxx','xxx')