oracleËÀËøÔÒò·ÖÎö
ËÀËøµÄÔÒò
1¡£Ä£ÄâËÀËø
1¡£1¡£Ö÷±í
-- Create table
create table WDZ1
(
WDZ1ID NUMBER not null,
MEMO VARCHAR2(20)
)
;
alter table WDZ1
add constraint XXXXXX primary key (WDZ1ID);
1¡£2¡£´Ó±í£¨Ã»ÓÐÍ⽡µÄË÷Òý£©
-- Create table
create table WDZ2
(
WDZ2ID NUMBER not null,
WDZ1ID NUMBER,
MEMO VARCHAR2(20)
)
;
-- Create/Recreate primary, unique and foreign key constraints
alter table WDZ2
add constraint XXXXX primary key (WDZ2ID)
;
alter table WDZ2
add constraint XXX foreign key (WDZ1ID)
references WDZ1 (WDZ1ID);
1¡£3¡£²åÈëÊý¾Ý±íµ½×¡±í
begin
insert into wdz1 values (1,'aa');
insert into wdz1 values(2,'aa2');
insert into wdz1 values (3,'aa3');
insert into wdz2 values(10,3,'wdz3--1');
commit;
end;
1¡£4¡£ÔÚÒ»¸öÊý¾Ý¿âseeesionÀïÃæ²åÈëÊýµ½´Ó±í£¬µ«ÊDz»Ìá½»ÊÂÎñ
begin
update wdz2 set memo='update wdz2 momo'
where wdz2id=10;
insert into wdz2 values(20,2,'wdz2--1');
end;
¶Ô´Ó±í½øÐвåÈë/Ð޸ļǼ£¬Ê©¼ÓµÄËøÒ²¾ÍÊÇÐм¶Ëø
1¡£5¡£ÔÚÁíÍâÒ»¸öÊý¾Ý¿âseeesionÀïÃæɾ³ý Ö÷±íÊý¾Ý
delete from wdz1 where wdz1id=1
Õâʱºò ³ÌÐò»áËÀËø£¬³ý·Ç ÉÏÃæµÄ ¶Ô´Ó±íµÄ Êý¾Ý²Ù×÷Ìá½»ÊÂÎñ»òÕ߻عöÊÂÎñ¡£
2¡£¾ßÌåÔÒò·ÖÎö
Ò»¸öÊý¾Ý±íµÄÍâ¼üÖ÷ÒªÓÐ3ÖÖ·½Ê½À´Î¬»¤Ëü×Ô¼ººÍÖ÷±íÊý¾ÝµÄÒ»ÖÂÐÔ¡£
(1)delete cascade
Àý×ÓÈçÏ£º
alter table WDZ2
add constraint XXX foreign key (WDZ1ID)
references WDZ1 (WDZ1ID) on delete cascade;
(2)Set null
Àý×ÓÈçÏ£º
alter table WDZ2
add constraint XXX foreign key (WDZ1ID)
references WDZ1 (WDZ1ID) on delete set null;
(3)No action
×¢Ò⣬ÕâÊÇoracleÍâ¼üʹÓÃʱºòµÄĬÈÏÑ¡Ïî¡£
Àý×ÓÈçÏ£º
alter table WDZ2
add constraint XXX foreign key (WDZ1ID)
references WDZ1 (WDZ1ID);
ÒÔÇ°³öÏÖËÀËøÖ÷ÒªÊÇÎÒÃÇÈÏΪ£¬ÔÚ 1¡£4¡£»á¶ÔÊý¾Ý±íwdz2½øÐÐÊ©¼ÓÐм¶Ëø£¬µ«ÊÇ´Ó±í(wdz2)µÄÍ⽡ÊÇNo action£¬É¾³ýÖ÷±í(wdz1)²»»áÈ¥·ÃÎÊ´Ó±í£¬¸ü²»»áÈ¥Ëø¶¨ wdz2±íµÄ¼Ç¼»òÕ߶ÔÕû¸öÊý¾Ý´Ó±í(wdz2)Ê©¼Ó±í¼¶Ëø¡£ÊÂʵÉÏ oralceµÄNo action Ñ¡ÏîµÄ×ÖÃæÒâ˼ÆÛÆÁËÎÒÃÇ£¬oracleÔÚɾ³ýÖ÷±íµÄʱºò
»áȥѰÕÒËùÓÐÒÔÖ÷±íµÄÖ÷¼ü×÷ΪÍâ¼üµÄÊý¾Ý±í£¬È»ºó¿´È¥¿´´Ó±í
ÊÇ·ñÓиÃÍâ¼üµÄË÷Òý£¬Èç¹ûûÓÐÔò»á¶ÔÕû¸ö´Ó±íÊ©¼Ó±í¼¶Ëø£¬È»ºó
¶Ô´Ó±í½
Ïà¹ØÎĵµ£º
1. ASCII: ·µ»ØÓëÖ¸¶¨µÄ×Ö·û¶ÔÓ¦µÄÊ®½øÖÆÊý;
SQL> select ascii('A') A,ascii('a') a,ascii(0) zero,ascii('') space from dual;
A A ZERO SPACE
--------- --------- --------- ---------
65 97 48
2. CHR:¸ø³öÕûÊý,·µ»Ø¶ÔÓ¦µÄ×Ö·û;
SQ ......
³õ³õѧϰoracle 10g,×î»ù±¾µÄÎÊÌâ¾ÍÊÇ°²×°Êý¾Ý¿â,³õ³õ°²×°Êý¾Ý¿âʱ,°²×°Óë±ðÈ˵Ķ¼²î²»¶à,¾ÍÊÇÔÚ×îºóʱ,²»ÄÜ×ÔÐÐÅä×°Êý¾Ý¿â,Òª×Ô¼ºÅäÖÃÊý¾Ý¿â,×îºó¾¹ý×Ô¼ºµÄÅŲé:ÔÚ°²×°ÏµÍ³Ê±,ϵͳµÄ¼ÆËã»úÃû³Æ(×¢²á¼ÆËã»úʱÓõÄ)ΪӢÎÄ,Óû§Ãû³ÆΪÖÐÎÄ,Òò´Ë²»ÄÜ×ÔÐÐÅäÖÃÊý¾Ý¿â,
¾¹ý±¾È˵Ķà´ÎʵÑé,ÔÚ¼ÆËã»úÃû³Æ¡¢Óû§ÃûΪӢÎĵÄ×´Ì¬Ï ......
http://blog.sina.com.cn/s/blog_3fed8ad60100bydo.html
1¡¢Ê×ÏÈÀûÓÃsystemÕÊ»§´´½¨ÐµķÖÇø£º
my_space1, my_space2(ÀûÓÃÍøÒ³¿ØÖÆ̨´´½¨±í¿Õ¼äÒÔ¼°ÓôúÂë´´½¨)¡£
ÔÚʵ¼Ê¹¤×÷ÖУ¬²»Í¬µÄÇø¿ÉÒÔλÓÚ²»Í¬µÄÎïÀí´ÅÅÌÖУ¬²ÅÓÐÕæÕý·ÖÇøµÄЧ¹û¡£
È»ºó£ºÓÃscottÕÊ»§´´½¨·¶Î§·ÖÇø±í£º
create table t1(
id number(5) pri ......
1.oracle×Ö·û¼¯ÎÊÌ⣺
Êý¾Ý¿â×Ö·û¼¯ÎªZHS16BGK£¬ºº×ÖÔÚÊý¾Ý¿â´æ·ÅµÄʱºòÕ¼ÓÃÁ½¸ö×Ö½Ú
Êý¾Ý¿â×Ö·û¼¯ÎªUTF8£¬ºº×ÖÔÚÊý¾Ý¿âÀï´æ·ÅµÄʱºòÕ¼ÓÃÈý¸ö×Ö½Ú
ÓÉÓÚ×Ö·û¼¯²»Í¬£¬µ¼ÖÂÏÖÔÚÊý¾Ý¿âIMPµÄʱºòÓÐЩ±íµÄ×ֶγ¤¶È²»¹»£¬³öÏÖORA-12899: value too large for columnµÄ´íÎó¡£
ͨ¹ýÐÞ¸Ä×Ö·û¼¯¿ÉÒÔ½â¾öÕâÖÖÎÊÌâ¡£
2.utf-8ºÍunico ......
Oracle´æ´¢¹ý³Ì¹¦ÄÜÇ¿´ó£¬ËûÖ÷ÒªµÄ×÷ÓÃÓÐÒÔϼ¸µã:
1.¿ÉÒÔÅúÁ¿Ö´ÐÐsqlÓï¾ä£¬ÌṩÄÚÖõÄÊÂÎñÖ§³Ö£¬Í¬Ê±Äܹ»Ìá¸ßÊý¾Ý¿â²Ù×÷µÄЧÂÊ¡£
2.¿Í»§¶Ë³ÌÐòÒÀ¾Ý´æ´¢¹ý³ÌÃûÀ´µ÷Óã¬Ìṩ³ÌÐòµÄ¿ÉÒÆÖ²ÐÔ¡£
3.Ìṩ¸´ÔÓµÄSQLÓï¾äÂß¼Ö§³Ö¡£
Óï·¨½á¹¹°üÀ¨¹ý³ÌÉùÃ÷£¬Ö´Ðйý³Ì²¿·Ö£¬´æ´¢¹ý³ÌÒì³£
1£©²»´ø²ÎÊý£º
Create or replace ......