select into 与 insert into select

来源:互联网 发布:excel保存后数据丢失 编辑:程序博客网 时间:2024/06/05 16:56

一. 区别:

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;

1 0
原创粉丝点击