最近在做論壇資料轉換程式。例如表src, 表dest都有乙個id自增長字段,(都是access資料庫,起始值1 ,步長1)
表src中id,char兩字段的值為
1、a
2、b
3、c
6、d
7、e
9、f
這樣在將src中的記錄插入表dest的時候會有麻煩,使得表dest中記錄如下所示
1、a
2、b
3、c
4、d
5、e
6、f
這樣造成dest和其它關聯表中的資料難以對應 。因此有必要在向表dest中插入記錄時 設定其id欄位的起始值,然後再進行插入操作
在 發現如下文字:
通過以下語句,你可以在建表的時候指定其起始值和步進值:
以下為引用的內容:
create table tblneworder2 (
orderid autoincrement (1000, 10),
itemid long, quantity long)
你也可以用下面的語句修改下乙個起始值和步進值:
以下為引用的內容:
alter table tblorder
alter column orderid counter (2000, 50)
要重新開始:
以下為引用的內容:
alter table tablename
alter column orderid counter (1, 1)
在 vbe 介面裡面用以下**:
以下為引用的內容:
docmd.runsql "alter table tablename alter column orderid counter (1, 1)"
這裡要注意的是自動編號往往被用作標識記錄的唯一性,但是 jet 在用 ddl 語句更改自動編號的同時不會保證修改後的自動編號仍然保持唯一性,因此會出現標識號重複的現象。要避免這一現象最好把自動編號設定為主鍵、或者不可重複。
oracle資料庫設定列自增長
在oracle資料庫中設定列自動增長的步驟如下 1.首先建立一張表,如下 create table users useridnumber primary key,usernamevarchar2 32 not null,passwordvarchar2 32 not null 2.建立乙個序列,如下...
Oracle資料庫中設定自增長列
oracle資料庫中不支援自增長列的,需要通過物件中的sequences 序列 來完成 1.在sequences新建 2.新建資料庫表 3.執行sql語句 sq mybatis.nextval來表示id自增長,sq mybatis是剛才建立的sequences insert into t users...
資料庫id自增長
1.建立序列 create sequence create sequence innerid minvalue 1 maxvalue 99999999999999 start with 1 increment by 1 cache 20 order 2.innerid.currval 指當前序列 i...