一、創(chuàng)建序列:
create sequence <序列名稱>
start with <起始數(shù)>
increment by <增長(zhǎng)量>
[maxvalue 值]
[minvalue 值]
[cycle 當(dāng)?shù)竭_(dá)最大值的時(shí)候,將繼續(xù)從頭開始]
[Nocycle -- 一直累加,不循環(huán)]
[Cache ]
二、Oracal的lpad函數(shù)
lpad( string1, padded_length, [ pad_string ] )
其中string1是需要粘貼字符的字符串
padded_length是返回的字符串的數(shù)量,如果這個(gè)數(shù)量比原字符串的長(zhǎng)度要短,lpad函數(shù)將會(huì)把字符串截取成padded_length;
pad_string是個(gè)可選參數(shù),這個(gè)字符串是要粘貼到string1的左邊,如果這個(gè)參數(shù)未寫,lpad函數(shù)將會(huì)在string1的左邊粘貼空格。
例如:
lpad('tech', 7); |
將返回' tech' |
lpad('tech', 2); |
將返回'te' |
lpad('tech', 8, '0'); |
將返回'0000tech' |
lpad('tech on the net', 15, 'z'); |
將返回 'tech on the net' |
lpad('tech on the net', 16, 'z'); |
將返回 'ztech on the net' |
三、Oracal的to_char函數(shù)
The following are date examples for the to_char function.
to_char(sysdate, 'yyyy/mm/dd'); |
would return '2003/07/09' |
to_char(sysdate, 'Month DD, YYYY'); |
would return 'July 09, 2003' |
to_char(sysdate, 'FMMonth DD, YYYY'); |
would return 'July 9, 2003' |
to_char(sysdate, 'MON DDth, YYYY'); |
would return 'JUL 09TH, 2003' |
to_char(sysdate, 'FMMON DDth, YYYY'); |
would return 'JUL 9TH, 2003' |
to_char(sysdate, 'FMMon ddth, YYYY'); |
would return 'Jul 9th, 2003' |
You will notice that in some examples, the format_mask parameter begins with "FM". This means that zeros and blanks are suppressed.
This can be seen in the examples below.
to_char(sysdate, 'FMMonth DD, YYYY'); |
would return 'July 9, 2003' |
to_char(sysdate, 'FMMON DDth, YYYY'); |
would return 'JUL 9TH, 2003' |
to_char(sysdate, 'FMMon ddth, YYYY'); |
would return 'Jul 9th, 2003' |
The zeros have been suppressed so that the day component shows as "9" as opposed to "09".
四、例:
DROP SEQUENCE test_mySeq;
DROP TABLE test;
CREATE SEQUENCE test_mySeq
START WITH 1001
INCREMENT BY 1
MAXVALUE 9999999999
MINVALUE 1
CYCLE
NOCACHE;
CREATE TABLE test
(
ID VARCHAR2(10) not null,
orderid VARCHAR2(20) not NULL
);
INSERT INTO test(ID,orderid)VALUES(to_char(SYSDATE,'yyyymmdd'),'HG-'||to_char(SYSDATE,'yyyymmdd')||lpad(test_mySeq.nextval, 8, '0'));
COMMIT;
SELECT * FROM test ORDER BY orderid ASC;
轉(zhuǎn)自:http://blog.csdn.net/jkant/archive/2009/04/24/4106687.aspx
減肥瘦身品總匯 值得信賴*脈脈美妝*正品現(xiàn)貨謝絕講價(jià) 〓深港商盟〓名品歐衣坊(美國(guó)休閑品牌AF系列) QQ三國(guó)游戲幣及道具專賣店 小臉紅紅的瘦身旗艦店減肥瘦身品總匯 值得信賴*脈脈美妝*正品現(xiàn)貨謝絕講價(jià) 〓深港商盟〓名品歐衣坊(美國(guó)休閑品牌AF系列) QQ三國(guó)游戲幣及道具專賣店 小臉紅紅的瘦身旗艦店減肥瘦身品總匯 值得信賴*脈脈美妝*正品現(xiàn)貨謝絕講價(jià) 〓深港商盟〓名品歐衣坊(美國(guó)休閑品牌AF系列) QQ三國(guó)游戲幣及道具專賣店 小臉紅紅的瘦身旗艦店
減肥瘦身品總匯
值得信賴*脈脈美妝*正品現(xiàn)貨謝絕講價(jià)
〓深港商盟〓名品歐衣坊(美國(guó)休閑品牌AF系列)
QQ三國(guó)游戲幣及道具專賣店
小臉紅紅的瘦身旗艦店
posted on 2009-05-20 18:08
龍華城 閱讀(1844)
評(píng)論(0) 編輯 收藏