从一个表中选择,插入另一个表 oracle sql 查询

select from one table, insert into another table oracle sql query(从一个表中选择,插入另一个表 oracle sql 查询)
本文介绍了从一个表中选择,插入另一个表 oracle sql 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am trying to select data from one table
and insert the data into another table

    SELECT ticker FROM tickerdb;

Using OracleSql I am trying to
get the ticker symbol "GOOG" from the tickerdb table,
and insert the t.ticker into the stockdb table.

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

解决方案

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;

You can read this link

Your query would be as follows

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

Hope this helps!

这篇关于从一个表中选择,插入另一个表 oracle sql 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)