【问题标题】:Create Table with multiple "WITH" Common table expression (CTE)创建具有多个“WITH”公用表表达式 (CTE) 的表
【发布时间】:2018-07-23 16:04:06
【问题描述】:

以下是我的 oracle 查询 - 如何修改查询以在我的 oracle 数据库中创建表?我正在使用 SQL Developer,请告知-

我想创建一个名为“Team”的表,其中包含上次选择查询中的所有列(列名:g、h、a、b、d、e)

WITH 
    Nam1 as (Select a,b from aaa),
    Nam2 as (select d,e from bbb)

Select  dd.g
       ,pp.h
       ,qq.a
       ,qq.b
       ,gg.d
       ,gg.e
from nam3 dd
join nam4 pp on dd.id = pp.id
join nam1 qq on pp.id = qq.id
join nam2 gg on qq.id = gg.id

谢谢!

【问题讨论】:

    标签: sql oracle common-table-expression ddl create-table


    【解决方案1】:

    只需在您的查询前加上 CREATE TABLE 语句:

    CREATE TABLE Team AS
    WITH 
        Nam1 as (Select a,b from aaa),
        Nam2 as (Select d,e from bbb)
    
    Select  dd.g
           ,pp.h
           ,qq.a
           ,qq.b
           ,gg.d
           ,gg.e
      from nam3 dd
      join nam4 pp on dd.id = pp.id
      join nam1 qq on pp.id = qq.id
      join nam2 gg on qq.id = gg.id;
    

    【讨论】:

      猜你喜欢
      • 2019-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多