ORACLE WITH AS Ó÷¨
ÔÎÄ´«ËÍÃÅ£ºhttp://blog.csdn.net/wh62592855/archive/2009/11/06/4776631.aspx
¼ÇµÃÒÔǰÔÚÂÛ̳Àï¿´µ½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 re
Ïà¹ØÎĵµ£º
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
-- -
ÕÔ A
......
Ò».×ÊÔ´ÐèÒª£º
ÖÁÉÙ1024 MBÎïÀíÄÚ´æ
1024£2048 Ðè1.5±¶µÄ½»»¥¿Õ¼ä
2048£8192 Ðè1±¶µÄ½»»¥¿Õ¼ä
8192£ Ðè0.75±¶µÄ½»»¥¿Õ¼ä
ÖÁÉÙ400 MB /tmp ÁÙʱĿ¼¿Õ¼ä
oracleÈí¼þÐèÒª1.5 GB µ½ 3.5 GB ´ÅÅ̿ռä
ĬÈÏÊý¾Ý¿âÐèÒª1.2 GB
¶þ.²é¿´ÏµÍ³×ÊÔ´Ïà¹ØÓï ......
PL/SQLµ¥Ðк¯ÊýºÍ×麯ÊýÏê½â
º¯ÊýÊÇÒ»ÖÖÓÐÁã¸ö»ò¶à¸ö²ÎÊý²¢ÇÒÓÐÒ»¸ö·µ»ØÖµµÄ³ÌÐò¡£ÔÚSQLÖÐOracleÄÚ½¨ÁËһϵÁк¯Êý£¬
ÕâЩº¯Êý¶¼¿É±»³ÆÎªSQL»òPL/SQLÓï¾ä£¬º¯ÊýÖ÷Òª·ÖΪÁ½´óÀࣺ
µ¥Ðк¯Êý
×麯Êý
±¾ÎĽ«ÌÖÂÛÈçºÎÀûÓõ¥Ðк¯ÊýÒÔ¼°Ê¹ÓùæÔò¡£
SQLÖеĵ¥Ðк¯Êý
SQLºÍPL/SQLÖÐ×Ô´øºÜ¶àÀàÐ͵ĺ¯Êý£¬ÓÐ×Ö·û¡¢Êý×Ö¡¢ÈÕÆÚ¡¢×ª ......
´ÓÔÚLinuxÉϰ²×°Oracleµ½Í¶ÈëʹÓòż¸Ì죬Åöµ½µÄÎÊÌâ¾Í³É°ÙÉÏǧµÄ¡£ÔÚʹÓÿͻ§¶ËÁ¬½ÓÔ¶³ÌOracleÊý¾Ý¿â·þÎñÆ÷ʱ£¬³öÏÖÁËlistener refused the connection with the following error ora-12519 Listener refused the connection with the following error:ORA-12519, TNS:no appropriate service handler foundThe Connection ......
ORACLE RAC¹¤×÷ÔÀí
ORACLE RAC¹¤×÷ÔÀí
¡¡¡¡ÔÚÒ»¸öÓ¦Óû·¾³µ±ÖУ¬ËùÓеķþÎñÆ÷ʹÓú͹ÜÀíͬһ¸öÊý¾Ý¿â£¬Ä¿µÄÊÇΪÁË·Öɢÿһ̨·þÎñÆ÷µÄ¹¤×÷Á¿£¬Ó²¼þÉÏÖÁÉÙÐèÒªÁ½Ì¨ÒÔÉϵķþÎñÆ÷£¬¶øÇÒ»¹ÐèÒªÒ»¸ö¹²Ïí´æ´¢É豸¡£Í¬Ê±»¹ÐèÒªÁ½ÀàÈí¼þ£¬Ò»¸öÊǼ¯ÈºÈí¼þ£¬ÁíÍâÒ»¸ö¾ÍÊÇOracleÊý¾Ý¿âÖеÄRAC×é¼þ¡£Í¬Ê±ËùÓзþÎñÆ÷ÉϵÄOS¶¼Ó¦¸ÃÊÇÍ ......