課程
/數(shù)據(jù)庫
/Oracle
/Oracle數(shù)據(jù)庫開發(fā)必備利器之SQL基礎(chǔ)
oracle數(shù)據(jù)庫id怎么實現(xiàn)自增長
2017-03-01
源自:Oracle數(shù)據(jù)庫開發(fā)必備利器之SQL基礎(chǔ) 3-4
正在回答
create table Test_Table ( ID number(11) primary key, Name varchar(50) not null)
create sequence AutoID start with 1 //根據(jù)需要自己可修改該數(shù)值 increment by 1 //步長值 minvalue 1 nomaxvalue
create trigger AutoID_Trigger before insert on Test_Table for each row begin select AutoID.nextval into :new.ID from dual; end AutoID_Trigger;
舉報
為你帶來Oracle開發(fā)必備的sql基礎(chǔ),為后續(xù)課程學(xué)習(xí)打下好的基礎(chǔ)
2 回答col 字段名 heading xxx格式化字段名如何確定是哪個表的字段?
2 回答關(guān)于字段類型
1 回答可以一條語句修改多個字段的字段類型嗎?
3 回答沒有更改字段名
2 回答不能修改字段為user?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-03-01
create table Test_Table
(
ID number(11) primary key,
Name varchar(50) not null
)
create sequence AutoID
start with 1 //根據(jù)需要自己可修改該數(shù)值
increment by 1 //步長值
minvalue 1
nomaxvalue
create trigger AutoID_Trigger
before insert on Test_Table for each row
begin
select AutoID.nextval into :new.ID from dual;
end AutoID_Trigger;