欢迎投稿

今日深度:

select into 与 insert into select,selectintoinsert

select into 与 insert into select,selectintoinsert


一. 区别:

insert into select: 用于将select出来的结果集复制到一个新表中, 它是标准的sql语句

select into: 将结果保存到一个变量中, 它是plsql的赋值语句


二. 例子:

insert into select:

insert into test select * from t_source where id = 1;  
commit;  
select into:
create or replace procedure my_test is
  aa varchar2(100);
  v_record t_source%rowtype;
begin
  select name into aa from t_source where id = 1;
  dbms_output.put_line('普通变量 name= ' || aa);

  select * into v_record from t_source where id = 1;
  dbms_output.put_line('记录变量 name= ' || v_record.name);

end;

www.htsjk.Com true http://www.htsjk.com/shujukunews/7703.html NewsArticle select into 与 insert into select,selectintoinsert 一. 区别: insert into select: 用于将select出来的结果集复制到一个新表中, 它是标准的sql语句 select into: 将结果保存到一个变量中, 它是plsql的赋语句...
评论暂时关闭