PL/SQLÀý×Ó
ÒÔÏÂÊǾ²âÑéÄÜÕýÈ·ÔËÐеÄ:
create table t_emp_log212
(
who varchar2(10) not null,
action varchar2(10) not null,
actime date
);
create or replace trigger tri_emp_insert
before insert
on t_emp
begin
insert into t_emp_log(who,action,actime)values(user,'insert',sysdate);
end;
-------------------------------------------------------------------------------------------
set serveroutput on
declare
v_empno emp.empno%type:=&empno;
v_ename emp.ename%type;
begin
select empno, ename into v_empno,v_ename from emp where empno=v_empno;
dbms_output.put_line(v_ename);
exception
when others then
dbms_output.put_line(' your empno is null,ename is null');
end;
-------------------------------------------------------------------------------------------
SET SERVEROUTPUT ON
declare
type tabletype1 is table of varchar2(10) index by binary_integer;
type tabletype2 is table of varchar2(10) index by binary_integer;
table1 tabletype1;
table2 tabletype2;
begin
table1(1):='´óѧ';
table1(2):='´óר';
table2(1):=88;
table2(2):=55;
dbms_output.put_line(table1(1)||table2(1));
dbms_output.put_line(table1(2)||table2(2));
end;
-------------------------------------------------------------------------------------------
set serveroutput on;
declare
v_grade char(10):=upper('&p_grade');/*upper½«×Ö·û´®È«±ä´óд ±ØÐë¼ÓÒýºÅ ÒòΪ¸³ÖµÒÔºóÏÔʾΪupper£¨'A'£©¶øupper£¨A£©A×÷Ϊ³£Á¿ÁË*/
v_result varchar2(20);
begin
v_result:=
case v_grade
when 'A' then '90 ·ÖÒÔÉÏ'
when 'B' then '80·Öµ½90·ÖÖ®¼ä'
when 'C' then '60·Öµ½80·ÖÖ®¼ä'
else '²»¼°¸ñ'
end;
dbms_output.put_line('grade'||v_grade||'result'||v_result);
end;
-------------------------------------------------------------------------------------------
set serverout on
declare
v_item number(3):=1;
begin
loop
dbms_output.put_line(v_item);
Ïà¹ØÎĵµ£º
ACCESS SQLÓï·¨²Î¿¼
=================
Ò». »ù´¡¸ÅÄî
¿ÉÒÔʹÓõÄÊý¾ÝÀàÐÍÈçÏ£º
1. TEXT£ºÎı¾ÐÍ£¨Ö¸¶¨³¤¶Èʱ£©£¬±¸×¢ÐÍ£¨²»Ö¸¶¨³¤¶Èʱ£©£»
2.
CHAR£¬NCHAR£¬VARCHAR£¬NVARCHAR£ºÎı¾ÐÍ£¬¿ÉÒÔÖ¸¶¨³¤¶È£¬·ñÔòĬÈÏֵΪ255£¡
3. ......
¸ÄÉÆSQLÓï¾ä
¡¡¡¡ºÜ¶àÈ˲»ÖªµÀSQLÓï¾äÔÚSQL SERVERÖÐÊÇÈçºÎÖ´Ðеģ¬ËûÃǵ£ÐÄ×Ô¼ºËùдµÄSQLÓï¾ä»á±»SQL SERVERÎó½â¡£±ÈÈ磺
select * from table1 where name=''zhangsan'' and tID > 10000
ºÍÖ´ÐÐ:
select * from table1 where tID > 10000 and name=''zhangsan''
¡¡¡¡Ò»Ð©È˲»ÖªµÀÒÔÉÏÁ½ÌõÓï¾äµÄÖ´ÐÐЧÂÊÊÇ·ñÒ» ......
ÎÒÏÈÅ×שÒýÓñ:
1. ¿ª·¢ÐÔ: SQLSERVER²»ÄÜ,ORACLEÄÜ×°ÔÚUNIXÉÏ
2. ·ÖÇø±í: SQLSERVER²»Ä ......
sqlÊǹØÏµÊý¾Ý¿â²éѯÓïÑÔ,Ãæ¶ÔµÄÊý¾Ý¿â;
¶øhqlÊÇHibernateÕâÑùµÄÊý¾Ý¿â³Ö¾Ã»¯¿ò¼ÜÌṩµÄÄÚÖòéѯÓïÑÔ,ËäÈ»ËûÃǵÄÄ¿µÄ¶¼ÊÇΪÁË´ÓÊý¾Ý¿â²éѯÐèÒªµÄÊý¾Ý,µ«sql²Ù×÷µÄÊÇÊý¾Ý¿â±íºÍ×Ö¶Î,
¶ø×÷ÎªÃæÏò¶ÔÏóµÄhql²Ù×÷µÄÔòÊdz־û¯À༰ÆäÊôÐÔ¡£
¾ÙÒ»¸ö¼òµ¥µÄÀý×Ó
sqlÓï¾ä
select * from tb_goods where id in (select goodsid f ......