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

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

问题描述

我需要使用 CTAS (Create Table As Select) 创建一个名为 Au_Books_ZL 的表,其中包含 au_id, fname, lname, title_id, title, Pub_id、价格和收入(即价格*销售额).

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?

推荐答案

创建表的语法类似于

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天全站免登陆