91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

oracle中create table with as和insert into with as語句

發布時間:2020-07-07 22:26:28 來源:網絡 閱讀:2932 作者:天黑順路 欄目:關系型數據庫

oracle支持使用with as 子句來創建表
語法:
create table table_name as
with clause_name as
(select query )
[, clause_name1 as
(select query ) ...]
select column1,...columnn from clause_name;

語法:
insert into table_name
with clause_name as
(select query )
[, clause_name1 as
(select query ) ...]
select column1,...columnn from clause_name;

例子:
--create with 語句

CREATE TABLE w_test_20 AS 

WITH  data_info_19 AS 
  (SELECT 
         NVL(ename,'unknow employee') AS ename, 
         DECODE(deptno,10,'ACCOUNTING',20,'RESEARCH',30,'SALES',40,'OPERATIONS','no this department') AS dname,
         NVL(job,'unkown job') AS job ,
         substr(to_char(hiredate,'yyyy-mm-dd'),1,7) AS hiredate,
         CASE WHEN sal <= 1000 THEN 'D' 
              WHEN sal > 1000 AND sal <= 2000 THEN 'C'
              WHEN sal > 2000 AND sal <= 3000 THEN 'B'
              WHEN sal > 3000  THEN 'A'
              ELSE 'unkown grade' 
         END AS grade,
         ROUND(sal,2) AS sal,
         FLOOR(nvl(comm,0)) AS comm,
         NVL(sal,0)+NVL(comm,0) AS total_sal
     FROM emp WHERE deptno IN 
     (SELECT DISTINCT deptno FROM dept))

 SELECT * FROM data_info_19;
CREATE TABLE w_test_18 AS 
WITH dept_info AS 
(SELECT deptno AS deptno_1,dname FROM dept)
,
emp_info AS
(SELECT empno AS empno_1,ename,job,deptno FROM emp)
,
other_info AS
(SELECT empno,hiredate,NVL(sal,0)+NVL(comm,0) AS total_sal FROM emp )

SELECT * FROM dept_info d LEFT JOIN emp_info e ON d.deptno_1=e.deptno RIGHT JOIN other_info o ON e.empno_1=o.empno ;
INSERT INTO w_test_19
WITH  data_info_19 AS 
  (SELECT 
         NVL(ename,'unknow employee') AS ename, 
         DECODE(deptno,10,'ACCOUNTING',20,'RESEARCH',30,'SALES',40,'OPERATIONS','no this department') AS dname,
         NVL(job,'unkown job') AS job ,
         substr(to_char(hiredate,'yyyy-mm-dd'),1,7) AS hiredate,
         CASE WHEN sal <= 1000 THEN 'D' 
              WHEN sal > 1000 AND sal <= 2000 THEN 'C'
              WHEN sal > 2000 AND sal <= 3000 THEN 'B'
              WHEN sal > 3000  THEN 'A'
              ELSE 'unkown grade' 
         END AS grade,
         ROUND(sal,2) AS sal,
         FLOOR(nvl(comm,0)) AS comm,
         NVL(sal,0)+NVL(comm,0) AS total_sal
     FROM emp WHERE deptno IN 
     (SELECT DISTINCT deptno FROM dept))

 SELECT * FROM data_info_19;
INSERT INTO  w_test_18 
WITH dept_info AS 
(SELECT deptno AS deptno_1,dname FROM dept)
,
emp_info AS
(SELECT empno AS empno_1,ename,job,deptno FROM emp)
,
other_info AS
(SELECT empno,hiredate,NVL(sal,0)+NVL(comm,0) AS total_sal FROM emp )

SELECT * FROM dept_info d LEFT JOIN emp_info e ON d.deptno_1=e.deptno RIGHT JOIN other_info o ON e.empno_1=o.empno ;
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

巨野县| 扶余县| 宜川县| 曲水县| 美姑县| 咸宁市| 木兰县| 阳山县| 扎鲁特旗| 永清县| 东兰县| 敖汉旗| 永兴县| 富蕴县| 新野县| 株洲县| 天柱县| 津南区| 永泰县| 舒城县| 乐陵市| 吉水县| 吉林市| 阜平县| 武清区| 武山县| 湘阴县| 辽宁省| 河东区| 光山县| 阿尔山市| 延安市| 洪湖市| 祁门县| 施甸县| 蓬莱市| 和田市| 卢湾区| 攀枝花市| 赞皇县| 饶阳县|