How can I create table as select (CTAS) in oracle?

一笑奈何 提交于 2019-12-02 03:54:26

问题


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).

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?


回答1:


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>>


来源:https://stackoverflow.com/questions/9333897/how-can-i-create-table-as-select-ctas-in-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!