±±´óÇàÄñoracleѧϰ±Ê¼Ç16
PL/SQL
¿é½á¹¹
DECLARE
ÉùÃ÷²¿·Ö
BEGIN
¿ÉÖ´Ðв¿·Ö
EXCEPTION
Òì³£´¦Àí²¿·Ö
END;
Àý£º
Ê×ÏÈÎÒÃÇ¿´Ò»¸ö¼òµ¥Ö®Àý×Ó,ÏÂÃæÕâ¸öÀý×ÓÊÇͳ¼Æ´Ó1ÖÁ100µÄ×ܺÍ.
declare
i number:=0; /*ÉùÃ÷±äÁ¿¾®¸ø³õÖµ*/
t number:=1;
error_message exception; /*ÉùÃ÷Ò»¸ö³ö´í´¦Àí*/
begin
for t in 1..100 loop
i:=i+t;
end loop;
if i>=5050 then
raise error_message; /*Òý·¢´íÎó´¦Àí*/
else
insert into c_nt(c_t) values(i);
end if;
exception
when error_message then
insert into c_nt(c_t) values(0);
end;
Ò»¡¢
±äÁ¿
1.
ÄÚÖÃÊý¾ÝÀàÐÍ
A.
±êÁ¿
a)
NUMBER
Datatype
Range
Subtypes
description
BINARY_INTEGER
[-214748364, 2147483647]
NATURAL
NATURAL
NPOSITIVE
POSITIVEN
SIGNTYPE
ÓÃÓÚ´æ´¢µ¥×Ö½ÚÕûÊý¡£
ÒªÇó´æ´¢³¤¶ÈµÍÓÚNUMBERÖµ¡£
ÓÃÓÚÏÞÖÆ·¶Î§µÄ×ÓÀàÐÍ(SUBTYPE):
NATURAL:ÓÃÓڷǸºÊý
POSITIVE:Ö»ÓÃÓÚÕýÊý
NATURALN:Ö»ÓÃÓڷǸºÊýºÍ·ÇNULLÖµ
POSITIVEN:Ö»ÓÃÓÚÕýÊý£¬²»ÄÜÓÃÓÚNULLÖµ
SIGNTYPE:Ö»ÓÐÖµ:-1¡¢0»ò1.
NUMBER
[1.0E-130,1.0E126)
DEC
DECIMAL
DOUBLE
PRECISION
FLOAT
INTEGERIC
INT
NUMERIC
REAL
SMALLINT
´æ´¢Êý×ÖÖµ£¬°üÀ¨ÕûÊýºÍ¸¡µãÊý¡£¿ÉÒÔÑ¡Ôñ¾«¶ÈºÍ¿Ì¶È·½Ê½£¬Óï·¨£º
number[ ( [,])]¡£
ȱʡµÄ¾«¶ÈÊÇ38,scaleÊÇ0.
PLS_INTEGER
[-214748364, 2147483647]
ÓëBINARY_INTEGER»ù±¾Ïàͬ£¬µ«²ÉÓûúÆ÷ÔËËãʱ£¬PLS_INTEGERÌṩ¸üºÃµÄÐÔÄÜ ¡£
b)
CHARACTER
datatype
rang
subtype
description
CHAR
×î´ó³¤¶È32767×Ö½Ú
CHARACTER
´æ´¢¶¨³¤×Ö·û´®£¬Èç¹û³¤¶ÈûÓÐÈ·¶¨£¬È±Ê¡ÊÇ1
LONG
×î´ó³¤¶È2147483647×Ö½Ú
´æ´¢¿É±ä³¤¶È×
Ïà¹ØÎĵµ£º
ORACLEÊý¾Ý¿â²åÈëÐÔÄܲâÊÔ
MKing
2010-3-8
²âÊÔ»·¾³»ù±¾ÐÅÏ¢£º
OS£ºWindows XP sp3
DB£ºOracle 9.2.0.1 δÆôÓù鵵
DBÖØ×öÈÕÖ¾Îļþ´óС£º100MB
Ó²ÅÌÐͺţºSAMSUNG HD161GJ£¨SATA-300,160G,7200rpm,8M cache£©
CPU£ºIntel Core2 E8400£¨3.0G£©
Äڴ棺2G
ͨ¹ýHD TuneµÃµ½µÄÓ²ÅÌ»ù±¾²âÊÔÐÅÏ ......
±¾ÎÄÖ÷Òª´Ó´óÐÍÊý¾Ý¿âORACLE»·¾³Ëĸö²»Í¬¼¶±ðµÄµ÷Õû·ÖÎöÈëÊÖ£¬·ÖÎöORACLEµÄϵͳ½á¹¹ºÍ¹¤×÷»úÀí£¬´Ó¾Å¸ö²»Í¬·½Ãæ½ÏÈ«ÃæµØ×ܽáÁËORACLEÊý¾Ý¿âµÄÓÅ»¯µ÷Õû·½°¸¡£
¹Ø¼ü´Ê ORACLEÊý¾Ý¿â»·¾³µ÷ÕûÓÅ»¯Éè¼Æ·½°¸
¶ÔÓÚORACLEÊý¾Ý¿âµÄÊý¾Ý´æÈ¡£¬Ö÷ÒªÓÐËĸö²»Í¬µÄµ÷Õû¼¶±ð£¬µÚÒ»¼¶µ÷ÕûÊDzÙ×÷ÏµÍ ......
1¡¢Ê²Ã´ÊÇ´æ´¢¹ý³Ì¡£´æ´¢¹ý³ÌÊÇÊý¾Ý¿â·þÎñÆ÷¶ËµÄÒ»¶Î³ÌÐò£¬ËüÓÐÁ½ÖÖÀàÐÍ¡£Ò»ÖÖÀàËÆÓÚSELECT²éѯ£¬ÓÃÓÚ¼ìË÷Êý¾Ý£¬¼ìË÷µ½µÄÊý¾ÝÄܹ»ÒÔÊý¾Ý¼¯µÄÐÎʽ·µ
»Ø¸ø¿Í»§¡£ÁíÒ»ÖÖÀàËÆÓÚINSERT»òDELETE²éѯ£¬Ëü²»·µ»ØÊý¾Ý£¬Ö»ÊÇÖ´ÐÐÒ»¸ö¶¯×÷¡£ÓеķþÎñÆ÷ÔÊÐíͬһ¸ö´æ´¢¹ý³Ì¼È¿ÉÒÔ·µ»ØÊý¾ÝÓÖ¿ÉÒÔÖ´Ðж¯×÷¡£
2¡¢Ê²Ã´Ê±ºòÐèÒªÓô洢¹ý³Ì
......
ORACLE 10 ѧϰ±Ê¼ÇÃüÁîµÚÒ»¿Î¡£
1.
sqlplus /nolog
connect /as sysdba
alter user scott account unlock;
alter user scott identified by manager;
2.
grant select on dept to nmerp;
revoke select on dept to nmerp;
select * from scott.dept
create table abc(a varchar2(10),b char(10));
alter& ......
ORACLE 10 ѧϰ±Ê¼Ç-µÚ2½Ú-ÃüÁî¡£
1. inner join / left join/ right join / full join
select a.dname, b.ename from dept a, emp b where a.deptno=b.deptno and a.deptno=10;
select a.dname, b.ename from dept a inner join emp b
on a.deptno=b.deptno and a.deptno=10;
select dname,ename from dept natural ......