---
title: "oracle 序列"
author: "simple_hui"
date: "2010-03-10T14:24:17Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2012-09-09T17:55:22Z"
id: 612027
url: "https://simple-hui.iteye.com/blog/612027"
---

创建序列  
create sequence seq\_a minvalue 1000 maxvalue 99999999 start with 1000 increment by 1 nocache;

查询序列  
select seq\_a.nextval from dual;

为每张表生成对应的序列

--创建存储过程  
create or replace procedure p\_createseq(tablename in varchar2)  
is  
strsql varchar2(500);  
begin  
strsql:='create sequence seq\_'||tablename||' minvalue 1000 maxvalue 99999999 start with 1000 increment by 1 nocache';  
execute immediate strsql;  
end p\_createseq;