首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

Orace序列怎的恢复从1开始

2013-01-07 
Orace序列怎样恢复从1开始SQL create table test (2id number(8) primary key,3name varchar2(20) not nu

Orace序列怎样恢复从1开始
SQL> create table test (
  2  id number(8) primary key,
  3  name varchar2(20) not null);

表已创建。

SQL> create sequence test_seq
  2  start with 1
  3  increment by 1
  4  nocache;

序列已创建。

SQL> insert into test (id,name) values (test_seq.nextval,'aaa');

已创建 1 行。

SQL> select * from test;

        ID NAME
---------- --------------------
         2 aaa

各位大虾,为什么我的序列老是从2开始?
[解决办法]
你是11gr2吧?据说是个bug!
10g上面就是好好的,从1开始的。
[解决办法]

引用:
因为你从1开始起步。所以,你创建序列的的当前值为1,但是你使用了nextval取下一个值就是2了,你可以把起步值为0试试

顶,
create sequence test_seq
  2 start with 0
  3 increment by 1
  4 nocache;

热点排行