taoxingtianxia 发表于 2013-1-14 08:55:55

ORACLE语法中的INSERT INTO...SELECT...

 
把一表里的数据取出直接插进另外一表


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','then');


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 foo);
 
drop table foo;
 
页: [1]
查看完整版本: ORACLE语法中的INSERT INTO...SELECT...