2012-02-17 22 views
2

我需要使用CTAS (Create Table As Select)創建一個名爲Au_Books_ZL的表,其中包含au_id, fname, lname, title_id, title, Pub_id, price and revenue (which is price*sales)如何在oracle中創建表爲select(CTAS)?

我瀏覽過其他在線的問題,但沒有說明如何在查詢中包含所有屬性(lname,fname,title_id等)。我怎樣才能寫出我的CTAS來創建新表格?

+0

請只要求一兩件事。我從這篇文章中刪除了一些不相關的問題 - 隨意將這些問題作爲單獨的問題提出。 – 2012-02-17 19:14:57

+0

相關:http://stackoverflow.com/questions/2250196/select-into-using-oracle – Vadzim 2017-03-02 11:30:19

回答

2

創建表的語法會像在一個單一的StackOverflow問題

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

謝謝!我知道了! – GivenPie 2012-02-17 20:00:50