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

oracle¼¶ÁªÉ¾³ý

oracleÖÐʹÓÃon delete cascadeºÍon delete set nullÀ´½¨Á¢Íâ¼ü
ÆäÃæÎÒÃǽéÉÜÁË´´½¨Íâ¼üÔ¼ÊøʱÈç¹ûʹÓÃoracleĬÈϵĴ´½¨·½Ê½£¬ÔÚɾ³ý±»²ÎÕÕµÄÊý¾Ýʱ£¬½«ÎÞ·¨±»É¾³ý£¬ÕâÒ»µãÔÚoracle9iÖиøÁËÎÒÃǸü¶àÁé»îµÄÑ¡Ôñ£¬ÎÒÃÇ¿ÉÊÇʹÓÃon delete cascadeºÍ on delete set null¹Ø¼ü×ÖÀ´¾ö¶¨É¾³ý±»²ÎÕÕÊý¾ÝʱÊÇ·ñÒª½«²ÎÕÕÕâ¸öÊý¾ÝµÄÄÇЩÊý¾ÝÒ»²¢É¾³ý£¬»¹Êǽ«ÄÇЩ²ÎÕÕÕâÌõÊý¾ÝµÄÊý¾ÝµÄ¶ÔÓ¦Öµ¸³¿Õ¡£
ÀýÈçÏÂÃæÕâÁ½¸ö±íÖзֱð´æµÄʱԱ¹¤µÄ»ù±¾ÐÅÏ¢ºÍ¹«Ë¾µÄ²¿ÃÅÐÅÏ¢¡£ÎÒÃÇΪ
create table dept
(deptno number(10) not null,
deptname varchar2(30) not null,
constraint pk_dept primary key(deptno));
ºÍ
create table emp
( empno number(10) not null,
fname varchar2(20) ,
lname varchar2(20) ,
dept number(10) ,
constraint pk_emp primary key(empno));
È»ºóÎÒÃÇÏÖÔÚ·Ö±ðʹÓÃÕâÁ½¸ö¹Ø¼ü×ÖÀ´Ôö¼ÓÍâ¼üÊÔһϣ¬Ê×ÏÈÎÒÃÇÀ´ÊÔÒ»ÏÂon delete cascade
alter table emp
add constraint fk_emp_dept foreign key(dept) references dept(deptno) on delete cascade;
ÏÈÔö¼ÓÍâ¼ü¡£È»ºó²åÈëÊý¾Ý¡£
insert into dept values(1,’ÏúÊÛ²¿’);
insert into dept values(2,’²ÆÎñ²¿’);
insert into emp values (2,’Mary’,'Song’,1);
insert into emp values (3,’Linda’,'Liu’,2);
insert into emp values (4,’Linlin’,'Zhang’,1);
È»ºóÏÖÔÚÎÒҪɾ³ýÏúÊÛ²¿£¬»áÓÐʲôºó¹ûÄØ£¿
delete from dept where deptno = 1;
ÎÒÃÇ·¢ÏÖ³ýÁËdeptÖеÄÒ»ÌõÊý¾Ý±»É¾³ýÁË£¬empÖÐÁ½ÌõÊý¾ÝÒ²±»É¾³ýÁË£¬ÆäÖÐempÖеÄÁ½ÌõÊý¾ÝÊDzÎÕÕÁËÏúÊÛ²¿µÄÕâÌõÊý¾ÝµÄ£¬Õâ¾ÍºÜÈÝÒ×Àí½âon delete cascadeÁË¡£
½ÓÏÂÀ´ÎÒÃÇÔÙÀ´¿´on delete set null,¹ËÃû˼ÒåÁË£¬ÕâÖÖ·½Ê½½¨Á¢µÄÍâ¼üÔ¼Êø£¬µ±±»²ÎÕÕµÄÊý¾Ý±»É¾³ýÊÇ£¬²ÎÕÕ¸ÃÊý¾ÝµÄÄÇЩÊý¾ÝµÄ¶ÔÓ¦Öµ½«»á±äΪ¿ÕÖµ£¬ÏÂÃæÎÒÃÇ»¹ÊÇͨ¹ýÊÔÑéÀ´Ö¤Ã÷on delete set null×÷Óãº
Ê×ÏȻָ´¸Õ²ÅµÄÄǼ¸ÌõÊý¾Ý£¬È»ºó¸ü¸ÄÔ¼Êø£º
alter table emp
add constraint fk_emp_dept foreign key(dept) references dept(deptno) on delete set null;
È»ºóÎÒÃÇÔÚÖ´ÐÐɾ³ý²Ù×÷£º
delete from dept where deptno = 1;
ÄãÒ²»á·¢ÏÖ³ýÁËdeptÖеÄÏúÊÛ²¿±»É¾³ýÒÔÍ⣬empÖвÎÕÕÕâÌõÊý¾ÝµÄÁ½ÌõÊý¾ÝµÄdeptµÄÖµ±»×Ô¶¯¸³¿ÕÁË£¬Õâ¾ÍÊÇon delete set nullµÄ×÷ÓÃÁË¡£
ʹÓÃon delete set nullÓÐÒ»µãÐèÒ


Ïà¹ØÎĵµ£º

oracle insertÓï·¨£¨ÈÕÆÚ¸ñʽ£©

insert into dts_auction_comments (id,auction_id,user_id,user_nick,comments,gmt_create,gmt_modified,status,comm_type)
                            values(409,127380, ......

Ò»¸ö¼òµ¥µÄhibernateÁ¬½ÓoracleÊý¾Ý¿âÀý×Ó£¡

Ò»¡¢ Hibernate½éÉÜ
    HibernateÊÇ»ùÓÚ¶ÔÏó/¹ØϵӳÉ䣨ORM£¬Object/Relational Mapping£©µÄÒ»¸ö½â¾ö·½°¸¡£ORM·½°¸µÄ˼ÏëÊǽ«¶ÔÏóÄ£ÐͱíʾµÄ¶ÔÏóÓ³Éäµ½¹ØϵÐÍÊý¾Ý¿âÖУ¬»òÕß·´Ö®¡£HibernateÄ¿Ç°ÊÇORM˼ÏëÔÚJavaÖÐ×î³É¹¦¡¢×îÇ¿´óµÄʵÏÖ¡£ËüÓÚ2001ÄêµÄÄêÄ©·¢²¼µÚÒ»¸ö°æ±¾£¬Á¢¼´ÒýÆðÁ˹㷺µÄ×¢Òâ¡£2003Äê6Ô£ ......

oracle·Ö×é rollup,Cube

CUBE ºÍ ROLLUP Ö®¼äµÄÇø±ðÔÚÓÚ£º
CUBE Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄËùÓÐ×éºÏµÄ¾ÛºÏ¡£
ROLLUP Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄijһ²ã´Î½á¹¹µÄ¾ÛºÏ¡£
     OracleµÄGROUP BYÓï¾ä³ýÁË×î»ù±¾µÄÓï·¨Í⣬»¹Ö§³ÖROLLUPºÍCUBEÓï¾ä¡£Èç¹ûÊÇROLLUP(A, B, C)µÄ»°£¬Ê×ÏÈ·Ö³ÉÁ½´ó²½£º£¨1£©¶ÔÓÚ·ûºÏÌõ¼þµÄÿ ......

Oracle trunc º¯ÊýµÄʹÓÃ

OracleµÄtrunc º¯ÊýÒ»°ãÓÃÀ´ ¶ÔÈÕÆÚºÍʱ¼ä½øÐнØÈ¡¡£
 
1¡¢Êý×Ö´¦Àí ¡£½ØÈ¡
 
 select trunc(5.75),trunc(5.75,1),trunc(5.75,-1),trunc(556.234,-2) from dual;
 
 
Êä³ö:
TRUNC(5.75) TRUNC(5.75,1) TRUNC(5.75,-1) TRUNC(556.234,-2)
----------- ------------- -------------- ----- ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ