一、創建序列:
create sequence <序列名稱>
start with <起始數>
increment by <增長量>
[maxvalue 值]
[minvalue 值]
[cycle 當到達最大值的時候,將繼續從頭開始]
[Nocycle -- 一直累加,不循環]
[Cache ]
二、Oracal的lpad函數
lpad( string1, padded_length, [ pad_string ] ) pad_string是個可選參數,這個字符串是要粘貼到string1的左邊,如果這個參數未寫,lpad函數將會在string1的左邊粘貼空格。
其中string1是需要粘貼字符的字符串
padded_length是返回的字符串的數量,如果這個數量比原字符串的長度要短,lpad函數將會把字符串截取成padded_length;
例如:
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函數
The following are date examples for the to_char function. You will notice that in some examples, the format_mask parameter begins with "FM". This means that zeros and blanks are suppressed. The zeros have been suppressed so that the day component shows as "9" as opposed to "09".
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'
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'
四、例:
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
);
SELECT * FROM test ORDER BY orderid ASC;
INSERT INTO test(ID,orderid)VALUES(to_char(SYSDATE,'yyyymmdd'),'HG-'||to_char(SYSDATE,'yyyymmdd')||lpad(test_mySeq.nextval, 8, '0'));
COMMIT;
轉自:http://blog.csdn.net/jkant/archive/2009/04/24/4106687.aspx
減肥瘦身品總匯 值得信賴*脈脈美妝*正品現貨謝絕講價 〓深港商盟〓名品歐衣坊(美國休閑品牌AF系列) QQ三國游戲幣及道具專賣店 小臉紅紅的瘦身旗艦店減肥瘦身品總匯 值得信賴*脈脈美妝*正品現貨謝絕講價 〓深港商盟〓名品歐衣坊(美國休閑品牌AF系列) QQ三國游戲幣及道具專賣店 小臉紅紅的瘦身旗艦店減肥瘦身品總匯 值得信賴*脈脈美妝*正品現貨謝絕講價 〓深港商盟〓名品歐衣坊(美國休閑品牌AF系列) QQ三國游戲幣及道具專賣店 小臉紅紅的瘦身旗艦店
減肥瘦身品總匯 值得信賴*脈脈美妝*正品現貨謝絕講價 〓深港商盟〓名品歐衣坊(美國休閑品牌AF系列) QQ三國游戲幣及道具專賣店 小臉紅紅的瘦身旗艦店