从一个表中选择,插入到另一个表中的oracle sql查询
问题描述:
我正在尝试从一个表中选择数据
并将数据插入到另一个表中
I am trying to select data from one table
and insert the data into another table
SELECT ticker FROM tickerdb;
我正在尝试使用OracleSql
从tickerdb表中获取股票代码"GOOG",
并将t.ticker插入stockdb表.
Using OracleSql I am trying to
get the ticker symbol "GOOG" from the tickerdb table,
and insert the t.ticker into the stockdb table.
从tickerdb表中选择->插入quotedb表中
select from tickerdb table --> insert into quotedb table
INSERT INTO quotedb
(t.ticker, q.prevclose, q.opn, q.rnge,
q.volume, q.marketcap, q.dividend, q.scrapedate)
VALUES (?,?,?,?,?,?,?,?,SYSDATE)
tickerdb t inner JOIN quotedb q
ON t.ticker = q.ticker
答
从oracle文档中,以下查询对其进行了更好的解释
From the oracle documentation, the below query explains it better
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
您可以阅读链接
您的查询如下
//just the concept
INSERT INTO quotedb
(COLUMN_NAMES) //seperated by comma
SELECT COLUMN_NAMES FROM tickerdb,quotedb WHERE quotedb.ticker = tickerdb.ticker
注意:确保插入和选择中的列根据您的要求位于正确的位置
Note: Make sure the columns in insert and select are in right position as per your requirement
希望这会有所帮助!