±±´óÇàÄñoracleѧϰ±Ê¼Ç17
Êý¾ÝÀàÐÍʹÓÃ
1.ÉùÃ÷£º
a.¸ñʽ£ºVariable_name [constant] databyte [not null] [:=default expression]
b.±äÁ¿Óë³£Á¿ÉùÃ÷»ù±¾Ò»Ö£¬Ê¹ÓÃconstantÉùÃ÷µÄΪ³£Á¿£¬²»Ê¹ÓÃΪ±äÁ¿£¬²¢ÇÒ¸³ÖµÖ»ÄÜÔÚDECLAREÇøÓò¸³Öµ£»
c.ʹÓÃ%TYPEºÍ%ROWTYPEÉùÃ÷¿ÉÒÔʹ±äÁ¿µÄÀàÐÍÓë±íÖÐ×Ö¶ÎÀàÐÍ»òÕû¸ö¼Ç¼ÀàÐͱ£³ÖÒ»Ö£»
2.¸³Öµ£º
a.ʹÓÓ:=”¸³Öµ£»
b.ʹÓÓselect into” »ò “fetch into”¸³Öµ£»
c.ʹÓÓ&str”´Ó¼üÅÌÊäÈ븳ֵ£»
DECLARE
eno VARCHAR(10):='0';
ename VARCHAR(20);
isValid BOOLEAN := TRUE;
empName CONSTANT VARCHAR(10):='pf';
BEGIN
eno:='1';
ename:='name1';
dbms_output.put_line('eno:'||eno);
dbms_output.put_line('ename:'||ename);
-- dbms_output.put_line('isValid:'||to_char(isValid));
dbms_output.put_line('empName:'||empName);
select stu_id, stu_name into eno,ename from student where stu_id = '1';
dbms_output.put_line('eno:'||eno);
dbms_output.put_line('ename:'||ename);
END;
ÄäÃûpl/sql³ÌÐò¿é
ÎÞ·¨ÔÙoracleÖд洢£¬Ã¿´ÎÖ´Ðж¼Ðè±àÒë
ÊôÐÔ
Ϊpl/sql±äÁ¿ºÍ³£Á¿ÒýÓÃÊý¾Ý¿âÖеÄÊý¾ÝÀàÐͺͶÔÏó
±äÁ¿Ãû ±íÃû.×Ö¶ÎÃû%type ÒýÓÃÊý¾Ý¿âÁÐ
±äÁ¿Ãû ±íÃû%rowtype ´ú±í±íÖеÄÐÐ ·ÃÎÊʱ²ÉÓà ±äÁ¿Ãû.±íÖÐÁÐÃû
declare
stuid student.stu_id%type;
stuname student.stu_name%type;
sturow student%rowtype;
begin
select stu_id,stu_name into stuid,stuname from student where stu_id = '1';
select * into sturow from student where stu_id = '2';
dbms_output.put_line('stuid:'||stuid);
dbms_output.put_line('stuname:'||stuname);
dbms_output.put_line('sturow stu_id:'||sturow.stu_id);
dbms_output.put_line('sturow stu_name:'||sturow.stu_name);
end;
Âß¼±È½Ï
ÊýÖµ±È½Ï
ÔËËã·û
º¬Òå
ʾÀý
=
µÈÓÚ
a = 123
!=
²»µÈÓÚ
c != 123
<
СÓÚ
a < 1
>
´óÓÚ
b > 4
<=
СÓÚµÈÓÚ
a <= b
>=
´óÓÚµÈÓÚ
a >= c
×Ö·û±È½Ï
ÔËËã·û
º¬Òå
ʾÀý
=
µÈÓÚ
name = 'pf'
!=
²»µÈÓÚ
name != 'pf'
<
×Öĸ˳ÐòÅÅÔÚÆäÇ°
n
Ïà¹ØÎĵµ£º
±íÀàÐÍ£º
1¶Ñ×éÖ¯±í£¨heap organized table£©£ºÕâЩ¾ÍÊÇ“ÆÕͨ”µÄ±ê×¼Êý¾Ý¿â±í¡£Êý¾ÝÒԶѵķ½Ê½¹ÜÀí¡£¶Ñ£¨heap£©ÊÇÒ»×é¿Õ¼ä£¬ÒÔÒ»ÖÖÓÐЩËæ»úµÄ·½Ê½Ê¹Óá£
2Ë÷Òý×éÖ¯±í£¨index organized table£©£ºÕâЩ±í°´Ë÷Òý½á¹¹´æ´¢¡£Õâ¾ÍÇ¿ÖÆÒªÇóÐб¾ÉíÓÐijÖÖÎïÀí˳Ðò¡£Ë÷Òý×éÖ¯±íIOTÖУ¬Êý¾ÝÒª¸ù¾ÝÖ÷¼üÓÐÐòµØ´æ´¢¡£
3Ë÷Ò ......
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 ......
°´±í·½Ê½µÄµ¼³ö£¬µ¼Èë
exp SYSTEM/SYSTEM@SBJSDB00 TABLES=KOKAN90.MASTER_SEND_LIMIT LOG=C:\A.LOG
IMP SYSTEM/SYSTEM@SBJSDB00 IGNORE=Y FULL=Y LOG=C:\B.LOG
֮ǰÓùýºÜ¶àÓï¾ä¶¼±¨´í£¬µÃµ½µÄ½ÌѵÊÇ ÏÈÖ´ÐÐexp SYSTEM/SYSTEM@SBJSDB00£¬°´Ìáʾһ²½²½ÊäÈë³É¹¦¹ýºó£¬ÔÙ°ÑÌáʾ·Òë³É²ÎÊýºÍ²ÎÊýÖµ
¹ØÓÚ²ÎÊý˵Ã÷Óà exp hel ......
¹Ø¼ü×Ö: oracle cast() º¯ÊýÎÊÌâ
SQL> create table t1(a varchar(10));
Table created.
SQL> insert into t1 values ('12.3456');
1 row created.
SQL> select round(a) from t1;
ROUND(A)
----------
12
SQL> select round(a,3) from t1;
ROUN ......