Oracle queries one table for inserting data into another table

Source: Internet
Author: User
Tags one table

1. Add a table that passes the structure and data of another table

CREATE TABLE XTHAME.TAB1 as SELECT * from Dsknow.combdversion

2. If the table exists:

INSERT INTO TAB1 select * from TAB2;

3. In the same table, assign the reference to the A field to the B field:

UPDATE table_name Set B = A;

4. Inserting field data from one table into the field data of another table

Insert into XTHAME.TAB1 (pk_bdversion,vbdcode) select Pk_bdversion,vbdcode from Dsknow.combdversion;

* If alert: ORA-00928: Missing SELECT keyword error

The reason is: here Tab1 (Field1,field2,....) Cannot add single quotation marks

5.4th extends multiple fields of multiple tables, inserting multiple fields of the same table.

INSERT into Xthame. BUTTON (button_id, Button_name, Button_code) Select A.pk_examquest, B.pk_bdversion,a.vquestname from Dsknow. Combdversion B, Dsknow. Rqt_examquest a where a.pk_examquest= ' 1001sx1000000000jobv ' and b.pk_bdversion= ' 1000bdv1000010101001 ';

Refer to the original link : https://www.2cto.com/database/201511/450244.html

Blog is to remember that they are easy to forget things, but also a summary of their work, the article can be reproduced, without copyright. Hope to do their own efforts to do better, we work together to improve!

If there is any problem, welcome to discuss together, code if there is a problem, you are welcome to the great God!

Oracle queries one table for inserting data into another table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.