oracle ÐòÁÐ
ÐòÁУ¨SEQUENCE£©ÐòÁÐÊÇÒ»Êý¾Ý¿â¶ÔÏó£¬ÀûÓÃËü¿ÉÉú³ÉΨһµÄÕûÊý¡£Ò»¸öÐòÁеÄÖµÊÇÓÉÌØÊâµÄOracle³ÌÐò×Ô¶¯Éú³É£¬Òò´ËÐòÁбÜÃâÁËÔÚÓ¦Óà ²ãʵÏÖÐòÁжøÒýÆðµÄÐÔÄÜÆ¿¾±¡£¸ÃÐòÁÐΪÉÏÉýÐòÁУ¬ÓÉ1¿ªÊ¼£¬ÔöÁ¿Îª1£¬Ã»ÓÐÉÏÏÞ¡£ÔÚÉýÐòʱ£¬ÐòÁпɴӱÈ×îСֵ´óµÄÖµ¿ªÊ¼£¬È±Ê¡ÖµÎªÐòÁеÄ×îСֵ¡£¶ÔÓÚ½µ Ðò£¬ÐòÁпÉÓɱÈ×î´óֵСµÄÖµ¿ªÊ¼£¬È±Ê¡ÖµÎªÐòÁеÄ×î´óÖµ¡£ÐÞ¸ÄÐòÁпÉÒÔ£º? ÐÞ¸ÄδÀ´ÐòÁÐÖµµÄÔöÁ¿¡£
ORACLEûÓÐÏóSQL SERVERÖÐÒ»ÑùµÄ×ÔÔö¼Ó×ֶΣ¬ÒªÊµÏÖÖ»ÄÜͨ¹ýSEQUENCEÀ´ÊµÏÖ
1.´´½¨ÐòÁУº
create sequence your_seq
nocycle
maxvalue 9999999999
start with 1;
2.ʹÓô¥·¢Æ÷ʵÏÖ×ÔÔö£º
create or replace trigger your_seq_tri
before insert on your_table1 for each row
declare
next_id number;
begin
select your_seq.nextval into next_id from dual;
:new.id := next_id;
end;
ÔÚoraclekÖУ¬ÎªÁË·½±ãÎÒ³£³£Óô¥·¢Æ÷¼°ÐòÁнáºÏÆðÀ´ÊµÏÖ£¬ÏÂÃæ¾ÍÊÇÒ»¸öʾÀý¡£
ÏȽ¨±í¡¢ÔÙ½¨ÐòÁС¢È»ºóÊÇ´¥·¢Æ÷£¬×îºó²âÊÔ=============================================
--ΪÖ÷¼üÖ¸¶¨ÐòÁбàºÅ
--2003-10-8 15:53
=============================================
conn scott/tiger@powermis
drop table foo;
create table foo(
id number primary key,
data varchar2(100));
create sequence foo_seq;
create or replace trigger bifer_foo_id_pk
before insert
on foo
for each row
begin
select foo_seq.nextval into :new.id from dual;
end;
/
insert into foo(data)
values('Chirstopher');
insert into foo(id,data)
values(5,'Sean');
select * from foo;
Oracle8iÒýÈëÁËSYS_GUIDÕâ¸ö¸ÅÄËüͬOracle¹ÜÀíÔ±ËùʹÓõĴ«Í³µÄÐòÁУ¨sequence£©Ïà±È¾ßÓÐÖî¶àÓÅÊÆ¡£Ò»¸öÐòÁÐÉú³ÉÆ÷Ö»ÊǼòµ¥µØ´´½¨´Ó¸ø¶¨µÄÆðµã¿ªÊ¼µÄһϵÁÐÕûÊýÖµ£¬¶øÇÒËü±»ÓÃÔÚÑ¡Ôñ³ÂÊöʽµÄʱºò×Ô¶¯µØµÝÔö¸ÃϵÁС£
ÐòÁÐÉú³ÉÆ÷ËùÉú³ÉµÄÊý×ÖÖ»Äܱ£Ö¤ÔÚµ¥¸öʵÀýÀïÊÇΨһµÄ£¬Õâ¾Í²»ÊʺϽ«ËüÓÃ×÷²¢ÐлòÕßÔ¶³Ì»·¾³ÀïµÄÖ÷¹Ø¼ü
×Ö£¬ÒòΪ¸÷×Ô»·¾³ÀïµÄÐòÁпÉÄÜ»áÉú³ÉÏàͬµÄÊý×Ö£¬´Ó¶øµ¼Ö³åÍ»µÄ·¢Éú¡£SYS_GUID»á±£Ö¤Ëü´´½¨µÄ±êʶ·ûÔÚ
ÿ¸öÊý¾Ý¿âÀﶼÊÇΨһµÄ¡£
´ËÍ⣬ÐòÁбØÐëÊÇDML³ÂÊöʽµÄÒ»²¿·Ö£¬Òò´ËËüÐèÒªÒ»¸öµ½Êý¾Ý¿âµÄÍù·µ¹ý³Ì£¨·ñÔòËü¾Í
Ïà¹ØÎĵµ£º
oracle±í¿Õ¼ä²Ù×÷Ïê½â
1
2
3×÷Õߣº À´Ô´£º ¸üÐÂÈÕÆÚ£º2006-01-04
5
6
7½¨Á¢±í¿Õ¼ä
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
²»ÊÇORACLEµÄÎÊÌâ
2009-12-30 15:00
  ......
OracleÊý¾Ý¿âÓαêʹÓ÷½·¨
2009-12-30 15:27
SQLÊÇÓÃÓÚ·ÃÎÊOracleÊý¾Ý¿âµÄÓïÑÔ£¬PL/SQLÀ©Õ¹ºÍ¼ÓÇ¿ÁËSQLµÄ¹¦ÄÜ£¬ËüͬʱÒýÈëÁ˸üÇ¿µÄ³ÌÐòÂß¼, ÏÂÃæÔÚ±¾ÎÄÖн«¶ÔÓαêµÄʹÓýøÐÐһϽ²½â,Ï£Íû¿ÉÒԺʹó¼Ò¹²Í¬Ñ§Ï°½ø²½¡£
¡¡¡¡Óαê×ÖÃæÀí½â¾ÍÊÇÓζ¯µÄ¹â±ê¡£ÓαêÊÇSQLµÄÒ»¸öÄڴ湤×÷Çø£¬ÓÉϵͳ»òÓû§ÒÔ±äÁ¿µÄÐÎ ......
ÔÎĵØÖ·£ºhttp://www.cnblogs.com/yf520gn/archive/2009/01/12/1374359.html
EXISTSµÄÖ´ÐÐÁ÷³Ì
select * from t1 where exists ( select null from t2 where y = x )
¿ÉÒÔÀí½âΪ:
for x in ( select * from t1 )
loop
if ( exists ( select null from ......
lob×ֶβ»ÄÜ×ögroup by£¬¶øunionÖÐÐèҪʹÓÃgroup by¹ýÂ˵ôÖظ´¼Í¼£¬ËùÒÔ²»ÐÐ ¡£ ÓÃunion all¾Í¿ÉÒÔÁË¡£
Áí£ºunion ºÍ union allÇø±ð£º
UNIONÔÚ½øÐбíÁ´½Óºó»áɸѡµôÖظ´µÄ¼Ç¼£¬ËùÒÔÔÚ±íÁ´½Óºó»á¶ÔËù²úÉúµÄ½á¹û¼¯½øÐÐÅÅÐòÔËË㣬ɾ³ýÖظ´µÄ¼Ç¼ÔÙ·µ» ......