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