Insert Into in Oracle Grammar. . . SELECT. . .

xiaoxiao2021-03-06  37

Write the INSERT statement today and want to directly insert the data in a table directly into another table. The result is forgotten. Looking for a long time. It's really idiot, first record the grammar found. . . Set feedback OFF; set pagesize 0;

Create Table Foo (A Number, B Varchar (10), C Varchar (10));

INSERT INTO FOO VALUES (15, 'ABC', 'DEF'); Insert Into Foo Values ​​(998, 'Max', 'Min'); Insert Into Foo Values ​​(7, 'Bla', 'Bla'); Insert Into Foo Values ​​(632, 'Now', 'Ten');

INSERT INTO FOO (A, B, C) (SELECT AA, BB, CC FROM (SELECT MAX (A) 1 aa from foo), (Select 'New' BB, 'OLD' CC from Dual);

Select * from foo where a = (SELECT MAX (a) from fo);

Drop Table foo;

/// below is written by yourself. . . The RQ field is used to use Index, so use BetWeenInsert Into MHMIS.T_CXLC_INFO (Last_Trans_Date, RQ, CH, XC, DWDM) (Select Sysdate, A.RQ, A.CH, A.XC, A.dwdm from Tdb.t_CXLC_INFO A WHERE NOT EXISTS (SELECT RQ, CH, XC, DWDM from MHMIS.T_CXLC_INFO WHMIDM = a.dwdm and xc = a.xc and ch = a.ch and rq = a.rq) and (a.rq between to_date " 2003-09-22 ',' YYYY-MM-DD ') AND to_DATE (' 2004-09-23 ',' YYYY-MM-DD ')) and A.ch in (SELECT B.CH from DB_PS_TRAIN B)) );

转载请注明原文地址:https://www.9cbs.com/read-62312.html

New Post(0)