Oracle´´½¨×ÔÔö×ֶη½·¨ ORACLE SEQUENCEµÄ¼òµ¥½éÉÜ
ÏȼÙÉèÓÐÕâôһ¸ö±í£º
create
table
S_Depart (
DepartId
INT
not
null
,
DepartName NVARCHAR2(
40
)
not
null
,
DepartOrder
INT
default
0
,
constraint
PK_S_DEPART
primary
key
(DepartId)
);
ÔÚoracleÖÐsequence¾ÍÊÇËùνµÄÐòÁкţ¬Ã¿´ÎÈ¡µÄʱºòËü»á×Ô¶¯Ôö¼Ó£¬Ò»°ãÓÃÔÚÐèÒª°´ÐòÁкÅÅÅÐòµÄµØ·½¡£
1¡¢Create Sequence
ÄãÊ×ÏÈÒªÓÐCREATE SEQUENCE»òÕßCREATE ANY SEQUENCEȨÏÞ£¬
CREATE SEQUENCE emp_sequence
INCREMENT BY 1 -- ÿ´Î¼Ó¼¸¸ö
START WITH 1 -- ´Ó1¿ªÊ¼¼ÆÊý
NOMAXvalue -- ²»ÉèÖÃ×î´óÖµ
NOCYCLE -- Ò»Ö±ÀÛ¼Ó£¬²»Ñ»·
CACHE 10; --ÉèÖûº´æcache¸öÐòÁУ¬Èç¹ûϵͳdownµôÁË»òÕßÆäËüÇé¿ö½«»áµ¼ÖÂÐòÁв»Á¬Ðø£¬Ò²¿ÉÒÔÉèÖÃΪ---------NOCACHE
Õë¶ÔS_Depart´´½¨µÄsequenceÈçÏ£º
create
sequence S_S_DEPART
minvalue
1
maxvalue
999999999999999999999999999
start
with
1
increment
by
1
nocache;
Ò»µ©¶¨ÒåÁËemp_sequence£¬Äã¾Í¿ÉÒÔÓÃCURRVAL£¬NEXTVAL
CURRVAL=·µ»Ø sequenceµÄµ±Ç°Öµ
NEXTVAL=Ôö¼ÓsequenceµÄÖµ£¬È»ºó·µ»Ø sequence Öµ
±ÈÈ磺
emp_sequence.CURRVAL
emp_sequence.NEXTVAL
¿ÉÒÔʹÓÃsequenceµÄµØ·½£º
- ²»°üº¬×Ó²éѯ¡¢snapshot¡¢VIEWµÄ SELECT Óï¾ä
- INSERTÓï¾äµÄ×Ó²éѯÖÐ
- NSERTÓï¾äµÄvalueSÖÐ
- UPDATE µÄ SETÖÐ
¿
Ïà¹ØÎĵµ£º
author£ºskate
time£º2010/03/04
oracleÊý¾Ý¿â¼¶±ðÓÅ»¯·ÖÎö¹¤¾ß½éÉÜ
µ±ÎÒÃǶÔÊý¾Ý¿âÓÅ»¯Õï¶Ïʱ£¬ÐèÒªÊÕ¼¯ÏàÓ¦µÄÐÅÏ¢ÒÔ¹©²Î¿¼£¬´Ó¸öÈ˵ÄʹÓþÑéÀ´Ëµ£¬ÕâÖÖͳ¼ÆÊý¾Ý·ÖΪÁ½´óÀà
Ò»ÀàÊÇÊý¾Ý¿â¼¶±ðµÄͳ¼ÆÐÅÏ¢
¶þÀàÊÇos¼¶±ðµÄͳ¼ÆÐÅÏ¢
ÏÂÃæ¾Í·Ö±ð½éÉÜÔÚ²»Í¬µÄ¼¶±ðÏ£¬³£ÓÃʲô¹¤¾ßÀ´ÊÕ¼¯ÐÅÏ¢°ïÖúÓÅ»¯Õï¶Ï
Ê×ÏÈÊÇoracleÊý¾ ......
Ò».˵Ã÷
oracle µÄexp/impÃüÁîÓÃÓÚʵÏÖ¶ÔÊý¾Ý¿âµÄµ¼³ö/µ¼Èë²Ù×÷;
expÃüÁîÓÃÓÚ°ÑÊý¾Ý´ÓÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷µ¼³öÖÁ±¾µØ,Éú³ÉdmpÎļþ;
impÃüÁîÓÃÓڰѱ¾µØµÄÊý¾Ý¿âdmpÎļþ´Ó±¾µØµ¼Èëµ½Ô¶³ÌµÄOracleÊý¾Ý¿âÖС£
¶þ.Óï·¨
¿ÉÒÔͨ¹ýÔÚÃüÁîÐÐÊäÈë imp help=y »ñÈ¡impµÄÓï·¨ÐÅÏ¢:
========= ......
delete ɾ³ýÒ»ÕÅ´ó±íʱ¿Õ¼ä²»ÊÍ·Å£¬·Ç³£ÂýÊÇÒòΪռÓôóÁ¿µÄϵͳ×ÊÔ´£¬Ö§³Ö»ØÍ˲Ù×÷£¬¿Õ¼ä»¹±»ÕâÕűíÕ¼ÓÃ×Å¡£
truncate table ±íÃû (ɾ³ý±íÖмǼʱÊͷűí¿Õ¼ä)
DML Óï¾ä£º
±í¼¶¹²ÏíËø£º ¶ÔÓÚ²Ù×÷Ò»ÕűíÖеIJ»Í¬¼Ç¼ʱ£¬»¥²»Ó°Ïì
Ðм¶ÅÅËüËø£º¶ÔÓÚÒ»ÐмǼ£¬oracle »áÖ»ÔÊÐíÖ»ÓÐÒ»¸öÓû§¶ÔËüÔÚͬһʱ¼ä½øÐÐÐ޸IJÙ×÷ ......
Õª Òª£º±¾ÎÄÌÖÂÛÁËOracleºÍSQL ServerµÄÔÚÊÂÎñ´¦ÀíÉϵÄÇø±ð£¬²¢·ÖÎöÁËÆäʵÏÖ»úÖƵIJîÒì¡£
¹Ø¼ü´Ê£ºOracle£»SQL Server£»ÊÂÎñ£»ÊÂÎñ¸ôÀ뼶±ð£»DDL¡£
ÊÂÎñ´¦ÀíÊÇËùÓдóÐÍÊý¾Ý¿â²úÆ·µÄÒ»¸ö¹Ø¼üÎÊÌ⣬¸÷Êý¾Ý¿â³§É̶¼ÔÚÕâ¸ö·½Ã滨·ÑÁ˺ܴó¾«Á¦£¬²»Í¬µÄÊÂÎñ´¦Àí·½Ê½»áµ¼ÖÂÊý¾Ý¿âÐÔÄܺ͹¦ÄÜÉϵľ޴ó²îÒì¡£
ÊÂÎñ´¦ÀíÒ²ÊÇÊý¾Ý¿â¹Ü ......
1¡¢ÓÃÀ´²åÈë´óÁ¿²âÊÔÊý¾ÝµÄ´æ´¢¹ý³Ì
CREATE OR REPLACE PROCEDURE INSERTAMOUNTTEST
(
ST_NUM IN NUMBER,
ED_NUM IN NUMBER
)
IS
BEGIN
declare
......