如何在Oracle中创建表为select(CTAS)? [英] How can I create table as select (CTAS) in oracle?

查看:124
本文介绍了如何在Oracle中创建表为select(CTAS)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用CTAS (Create Table As Select)创建一个名为Au_Books_ZL的表,其中包含au_id, fname, lname, title_id, title, Pub_id, price and revenue (which is price*sales).

I need to use CTAS (Create Table As Select) to create a table named Au_Books_ZL that contains au_id, fname, lname, title_id, title, Pub_id, price and revenue (which is price*sales).

我已经在线浏览了其他问题,但是它们没有显示如何在查询中包括所有属性(lname,fname,title_id等).我该如何编写CTAS来创建新表?

I have browsed other questions online, but they don't show how to include all the attributes (lname, fname, title_id ect.) in the query. How could I write up my CTAS to create the new table?

推荐答案

用于创建表的语法类似于

The syntax for creating a table would be something like

CREATE TABLE au_books_zl
AS
  SELECT au_id,
         fname,
         lname,
         title_id,
         title,
         pub_id,
         price,
         price * sales as revenue
    FROM <<whatever tables you need to select from>>
   WHERE <<whatever conditions you need to apply>>

这篇关于如何在Oracle中创建表为select(CTAS)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆