oracle 批量插入-支持序列自增


1、创建表、序列

-- Create table
create table test_batch
(
  id      number not null,
  name    varchar2(20),
  account varchar2(20)
)

-- Create sequence 
create sequence seq_test_batch
minvalue 1
maxvalue 9999999999999999999
start with 1
increment by 1
cache 20;

 

2、批量插入SQL

insert into test_batch(id, name, account)
select seq_test_batch.nextval, name, account from(
  select 'frank' as name , 'frank001' as account from dual
  union
  select 'quanbs' as name , 'quanbs001' as account from dual
);
commit;

注意:每个值后面跟对应别名,别名对应数据库字段名。 

 

3、查看插入结果

select * from test_batch;

 

查看ibatis+oracle批量插入请进入另一个帖子:【oracle+ibatis 批量插入-支持序列自增


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM