ORACLE WITH AS Ó÷¨
¼ÇµÃÒÔÇ°ÔÚÂÛ̳Àï¿´µ½inthirtiesÓõ½¹ýWITH ASÕâ¸ö×ÖÑÛ£¬µ±Ê±Ã»ÌرðÔÚÒâ¡£½ñÌìÔÚÒ»¸öÌû×ÓÀïÓÖ¿´µ½ÓÐÈËÓÃÕâ¸ö£¬ËùÒÔ¾ÍÈ¥ÍøÉÏËÑÁËËÑÏà¹ØÄÚÈÝ£¬×Ô¼ºÐ¡ÊÔÁËÒ»°Ñ£¬Ð´ÏÂÀ´£¬·½±ãÒÔºóÍüÁ˵Ļ°Ñ§Ï°¡£
===================================================================================
ÏȾٸöÀý×Ó°É£º
ÓÐÁ½ÕÅ±í£¬·Ö±ðΪA¡¢B£¬ÇóµÃÒ»¸ö×ֶεÄÖµÏÈÔÚ±íAÖÐÑ°ÕÒ£¬Èç¹ûA±íÖдæÔÚÊý¾Ý£¬ÔòÊä³öA±íµÄÖµ£»Èç¹ûA±íÖв»´æÔÚ£¬ÔòÔÚB±íÖÐÑ°ÕÒ£¬ÈôB±íÖÐÓÐÏàÓ¦¼Ç¼£¬ÔòÊä³öB±íµÄÖµ£»Èç¹ûB±íÖÐÒ²²»´æÔÚ£¬ÔòÊä³ö"no records”×Ö·û´®¡£
with
sql1 as (select to_char(a) s_name from test_tempa),
sql2 as (select to_char(b) s_name from test_tempb where not exists (select s_name from sql1 where rownum=1))
select * from sql1
union all
select * from sql2
union all
select 'no records' from dual
where not exists (select s_name from sql1 where rownum=1)
and not exists (select s_name from sql2 where rownum=1);
Ôپٸö¼òµ¥µÄÀý×Ó
with a as (select * from test)
select * from a;
Æäʵ¾ÍÊÇ°ÑÒ»´ó¶ÑÖظ´Óõ½µÄSQLÓï¾ä·ÅÔÚwith as ÀïÃ棬ȡһ¸ö±ðÃû£¬ºóÃæµÄ²éѯ¾Í¿ÉÒÔÓÃËü
ÕâÑù¶ÔÓÚ´óÅúÁ¿µÄSQLÓï¾äÆðµ½Ò»¸öÓÅ»¯µÄ×÷Ó㬶øÇÒÇå³þÃ÷ÁË
ÏÂÃæÊÇËÑË÷µ½µÄÓ¢ÎÄÎĵµ×ÊÁÏ
About Oracle WITH clause
Starting in Oracle9i release 2 we see an incorporation of the SQL-99 “WITH clause”, a tool for materializing subqueries to save Oracle from having to re-compute them multiple times.
The SQL “WITH clause” is very similar to the use of Global temporary tables (GTT), a technique that is often used to improve query speed for complex subqueries. Here are some important notes about the Oracle “WITH clause”:
• The SQL “WITH clause” only works on Oracle 9i release 2 and beyond.
• Formally, the “WITH clause” is called subquery factoring
• The SQL “WITH clause” is used when a subquery is executed multiple times
• Also useful for recursive queries (SQL-99, but not Oracle SQL)
To keep it simple, the fo
Ïà¹ØÎĵµ£º
´æ´¢¹ý³Ì´´½¨Óï·¨£º
create or replace procedure ´æ´¢¹ý³ÌÃû£¨param1 in type£¬param2 out type£©
as
±äÁ¿1 ÀàÐÍ£¨Öµ·¶Î§£©;
±äÁ¿2 ÀàÐÍ£¨Öµ·¶Î§£©;
Begin
Select count(*) into ±äÁ¿1 from ±íA whereÁÐÃû=param1£»
If (ÅжÏÌõ¼þ) then
&n ......
1. ASCII
·µ»ØÓëÖ¸¶¨µÄ×Ö·û¶ÔÓ¦µÄÊ®½øÖÆÊý;
SQL> select ascii(A) A,ascii(a) a,ascii(0) zero,ascii( ) space from dual;
A A ZERO SPACE
--------- --------- --------- ---------
65 97 48 32
2. CHR
¸ø³öÕûÊý,·µ»Ø¶ÔÓ¦µÄ×Ö·û;
SQL> select chr(54740) zhao,chr(65) chr65 from dual;
ZH C
-- ......
ADFÊÇ£¨Application Development Framework£©µÄ¼ò³Æ£¬ËüµÄÇ°ÉíÊÇBC4J¡£ ¹âÌýÕâ¸öÃû×Ö¾ÍÖªµÀËüÊÇÒ»¸öend-to-endµÄ¿ò¼Ü¡£ºÍSpringÒ»ÑùËüÔÚÆóÒµÓ¦Óüܹ¹µÄÿһ¸ö²ã´Î¶¼ÌṩÁËËüµÄÖ§³Ö¡£ADFµÄ¼Ü¹¹ÈçÏÂͼËùʾ£º
ÔÚÿһ²ãADF¶¼ÓÐËüµÄһЩ×é¼þ¡£ÎÒÕâ´ÎÖ÷ÒªÏë½²½²ADFµÄdata binding£¬ÒòΪËü¸ôÀëÁËÒµÎñÂß¼²ãºÍweb²ã£¬Ê¹µÃÁ½¸ö²ã´Î ......
oracleµÄnvlº¯ÊýµÄÓ÷¨ ͨ¹ý²éѯ»ñµÃij¸ö×ֶεĺϼÆÖµ£¬Èç¹ûÕâ¸öֵλnull½«¸ø³öÒ»¸öÔ¤ÉèµÄĬÈÏÖµ
select nvl(sum(t.dwxhl),1) from tb_jhde t where zydm=-1ÕâÀï¹ØÐĵÄnvlµÄÓ÷¨£¬nvl£¨arg,value£©´ú±íÈç¹ûÇ°ÃæµÄargµÄֵΪnullÄÇô·µ»ØµÄֵΪºóÃæµÄvalue
Èç: NVL(a,b)¾ÍÊÇÅжÏaÊÇ·ñÊÇNULL,Èç¹û²»ÊÇ·µ»ØaµÄÖµ£¬Èç¹ ......