Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¡¾oracleÐòÁÐרÌâ¡¿£¨×ªÔØ£©

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;
ÔÚoracleÖУ¬ÎªÁË·½±ãÎÒ³£³£Óô¥·¢Æ÷¼°ÐòÁнáºÏÆðÀ´ÊµÏÖ£¬ÏÂÃæ¾ÍÊÇÒ»¸öʾÀý¡£
ÏȽ¨±í¡¢ÔÙ½¨ÐòÁС¢È»ºóÊÇ´¥·¢Æ÷£¬×îºó²âÊÔ
=============================================
--ΪÖ÷¼üÖ¸¶¨ÐòÁбàºÅ
--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³ÂÊöʽµÄÒ»²¿·Ö£¬Òò´ËËüÐèÒªÒ»¸öµ½Êý¾Ý¿âµÄÍù·µ¹ý³Ì£¨·ñÔòËü¾Í²»Äܱ£Ö¤ÆäÖµÊÇΨһ
µÄ£©¡£
SYS_GUIDÔ´×Ô²»ÐèÒª¶ÔÊý¾Ý¿â½øÐзÃÎʵÄʱ¼ä´ÁºÍ»úÆ÷±êʶ·û£¬Õâ¾Í½ÚÊ¡Á˲éѯµÄÏûºÄ¡£
create table use_seq_table(id integer);
create sequence use_seq_sequence;
insert into use_seq_table values (use_seq_sequence_value.nextval);
REM - for some reason, the documentation uses raw(32)
create table use_guid_table(id raw(16));
insert into use_guid_table(sys_guid());
ºÜ¶àÓ¦ÓóÌÐò¶¼ÒÀ¿¿ÐòÁÐÉú³ÉÆ÷À´´´½¨


Ïà¹ØÎĵµ£º

¡¾×ªÌû¡¿SQL Oracleɾ³ýÖØ¸´¼Ç¼

1.Oracleɾ³ýÖØ¸´¼Ç¼.
ɾ³ý±íÖжàÓàµÄÖØ¸´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´Åжϣ¬Ö»ÁôÓÐrowid×îСµÄ¼Ç¼.
delete from people
where peopleId  in (select  peopleId  from people  group  by  peopleId   having  count(peopleId) > 1)
and rowid not i ......

ORACLE+SQLÐÔÄÜÓÅ»¯ÏµÁÐ

ORACLE SQLÐÔÄÜÓÅ»¯ÏµÁÐ
 
1. ·ÃÎÊTableµÄ·½Ê½
ORACLE ²ÉÓÃÁ½ÖÖ·ÃÎʱíÖмǼµÄ·½Ê½:
a. È«±íɨÃè
È«±íɨÃè¾ÍÊÇ˳ÐòµØ·ÃÎʱíÖÐÿÌõ¼Ç¼. ORACLE²ÉÓÃÒ»´Î¶ÁÈë¶à¸öÊý¾Ý¿é(database block)µÄ·½Ê½ÓÅ»¯È«±íɨÃè.
b. ͨ¹ýROWID·ÃÎʱí
Äã¿ÉÒÔ²ÉÓûùÓÚROWIDµÄ·ÃÎÊ·½Ê½Çé¿ö,Ìá¸ß·ÃÎʱíµÄЧÂÊ, , ROWID°üº¬Á˱íÖмǼµ ......

oracle LogMiner¼ò½é

Ô­ÎĵØÖ·£ºhttp://www.phontol.com/20090719_525808_1.html
1  LogMiner µÄÓÃ;
¡¡¡¡Oracle LogMiner ÊÇ Oracle¹«Ë¾´Ó²úÆ· 8iÒÔºóÌṩµÄÒ»¸öʵ¼Ê·Ç³£ÓÐÓõķÖÎö¹¤¾ß£¬Ê¹Óøù¤¾ß¿ÉÒÔÇáËÉ»ñµÃ OracleÖØ×÷ÈÕÖ¾Îļþ£¨¹éµµÈÕÖ¾Îļþ£©ÖеľßÌåÄÚÈÝ£¬ÌرðÊÇ£¬¸Ã ¹¤¾ß¿ÉÒÔ·ÖÎö³öËùÓжÔÓÚÊý¾Ý¿â²Ù×÷µÄ DML£¨insert¡¢update¡¢ ......

OracleÖÐrownumµÄʹÓÃ

ÔÚʹÓÃOracleÖÐʹÓÃRownum£¬»áÓÐЩÎó½â£¬ÏÖÕûÀíÏÂÍøÓÑÃǵÄÎÄÕ£¬Ï£ÍûÄÜÓÐËù°ïÖú£¬ºÇºÇ
¶ÔÓÚ Oracle µÄ rownum ÎÊÌ⣬ºÜ¶à×ÊÁ϶¼Ëµ²»Ö§³Ö>,>=,=,between...and£¬Ö»ÄÜÓÃÒÔÉÏ·ûºÅ(<¡¢<=¡¢!=)£¬²¢·Ç˵ÓÃ>,>=,=,between..and ʱ»áÌáʾSQLÓï·¨´íÎ󣬶øÊǾ­³£ÊDz鲻³öÒ»Ìõ¼Ç¼À´£¬»¹»á³öÏÖËÆºõÊÇĪÃûÆäÃîµÄ½á¹û ......

oracle±Ê¼Ç

--oralceÖдӱíÖÐËæ»úÈ¡³önÌõ¼Ç¼
select * from  (select t.*,dbms_random.random num from fms_branch_info t order by num)    
where rownum <= 5;
--ȡǰʮÐÐ
SELECT t.* from fms_branch_info t
WHERE ROWNUM != 10
--WHERE ROWNUM between 1 and 10
ORDER BY branch_code;
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ