广州私人做网站,在线设计平台的发展趋势,网站后台哪些功能需要前端配合,济南企业建站品牌目录
复制表
将部门 30 的所有员工信息保存在 emp30 表中
将复杂查询结果创建为表
只将 emp 表的结构复制为 empnull 表 从入门到总裁:https://blog.csdn.net/weixin_67859959/article/details/135209645
复制表
严格来说#xff0c;复制表不是复制操作复制表不是复制操作而是将一个子查询的返回结果变为了一张表的形式保存
create table 表名称 as 子查询
将部门 30 的所有员工信息保存在 emp30 表中
SQL create table emp30 as select * from emp where empno30;表已创建。 as后面的子查询中返回查询结果这个结果保存在新的数据表 emp30 中
如果现在是一个复杂查询那么也可以将这个最终结果保存在数据表中
将复杂查询结果创建为表
select d.deptno,d.dname,temp.count,temp.avg
from dept d,(select deptno dno,count(*) count,avg(sal) avgfrom empgroup BY deptno) temp
where d.deptnotemp.dno() ;把上面的复杂查询结果保存到数据表 deptstat 中
SQL create table deptstat2 AS3 select d.deptno,d.dname,temp.count,temp.avg4 from dept d,(5 select deptno dno,count(*) count,avg(sal) avg6 from emp7 group BY deptno) temp8 where d.deptnotemp.dno() ;表已创建。
此时的统计查询结果保存在 deptstat 表里面
除了可以将数据保存在数据表之中那么还可以将表结构进行复制即不复制表内容只复制表结构
只将 emp 表的结构复制为 empnull 表
SQL create table empnull2 as3 select * from emp where 12 ;表已创建。
只需要设置一个绝对不可能满足的条件即可例如上面这个例子中条件“12”是不能满足的所以不会有数据但是通过这种方法可以复制表的结构