Oracleѧϰ±Ê¼Ç4 ÉÔ¸´ÔӵIJéѯºÍ·ÖÒ³
ÈÔȻʹÓÃSCOTTÓû§À´²Ù×÷£º
1¡¢ ÏÔʾ¹¤×ʱȲ¿ÃÅ30µÄËùÓÐÔ±¹¤µÄ¹¤×ʶ¼¸ßµÄÔ±¹¤µÄÐÅÏ¢£º
Select * from emp where sal>all(select sal from emp where deptno=30);
2¡¢ ÏÔʾ¹¤×ʱȲ¿ÃÅ30µÄÈÎÒâÒ»¸öÔ±¹¤µÄ¹¤×ʸ߾ͿÉÒÔµÄÔ±¹¤µÄÐÅÏ¢£º
Select * from emp where sal>any(select sal from emp where deptno=30);
Æäʵ£¬»»ÖÖ·½·¨Ò²ÊÇ¿ÉÒԵģº
Select * from emp where sal>(select min(sal) from emp where deptno=30);
3¡¢ ÕÒ³öºÍSMITHµÄ²¿Ãźš¢¹¤×÷¶¼ÏàͬµÄÔ±¹¤µÄÐÅÏ¢£º
Select * from emp where (deptno,job)=(Select deptno,job from emp where ename=’SMITH’);
4¡¢ ÈçºÎÏÔʾ¸ßÓÚ×Ô¼º²¿ÃÅƽ¾ù¹¤×ʵÄÔ±¹¤µÄÐÅÏ¢
½â¾öÕâ¸ö¸´ÔÓÒ»µãµÄ²éѯ£¬ÎÒÃÇ¿ÉÒÔÕâÑù¿¼ÂÇ£º
ÏÈÕÒ³öÿ¸ö²¿ÃŵÄƽ¾ù¹¤×Ê£º
Select deptno,avg(sal) avg_sal from emp group by deptno;½á¹ûÈçÏ£º
SQL> select deptno,avg(sal) avg_sal from emp group by deptno;
DEPTNO AVG_SAL
------ ----------
30 1566.66666
20 2175
10 2916.66666
È»ºóÎÒÃǾͿÉÒÔ°ÑÕâÕÅ±íµ±³ÉÒ»ÕÅ×Ó±íʹÓãº
select a2.ename,a2.sal,a2.deptno,a1.avg_sal from emp a2,(select deptno,avg(sal) avg_sal from emp group by deptno) a1 where a2.deptno=a1.deptno and a2.sal>a1.avg_sal;
½á¹ûΪ£º
ENAME SAL DEPTNO AVG_SAL
---------- --------- ------ ----------
ALLEN 1600.00 30 1566.66666
JONES 2975.00 20 2175
BLAKE 2850.00 30 1566.66666
SCOTT 3000.00 20 2175
K
Ïà¹ØÎĵµ£º
Ä¿Ç°Ö÷Á÷Êý¾Ý¿â£º
΢Èí£ºsql serverºÍaccess
ÈðµäMySql£ºAB¹«Ë¾mysql
IBM¹«Ë¾£ºDB2¡¢
ÃÀ¹úSybase¹«Ë¾£ºSybase
IBM¹«Ë¾ ......
1£®OracleΪ¿Í»§¶Ë¿ªÆô»á»°ÓÐÁ½ÖÖ·½Ê½£º¹²Ïí·þÎñºÍרÓ÷þÎñ¡£ÔÚרÓ÷þÎñÇé¿öÏ£¬¼àÌýÆ÷ΪÁ¬½ÓÇëÇó´´½¨Ð½ø³Ì£¨Unix»·¾³ÏÂÊÇProcess£¬WindowsÏÂÎÒÏëÓ¦¸ÃÊÇThread°É£©£»¹²Ïí·þÎñÇé¿öÏ£¬¼àÌýÆ÷½«¿Í»§ÇëÇ󽻸øDispatcher£¬ÓÉDispatcher°²ÅŶà¿Í»§µÄ×÷Òµ¡£SQL ServerÔÚĬÈÏÇé¿öÏÂ×Ô¶¯Îª¿Í»§¶ËÁ¬½Ó´´½¨Ị̈߳¬µ±Óзdz£¶àµÄ¿Í ......
Oracle±íµÄ¹ÜÀí
±íÃûºÍÁÐÃûµÄÃüÃû¹æÔò£º
1±ØÐëÒÔ×Öĸ¿ªÍ·
2³¤¶È²»Äܳ¬¹ý30¸ö×Ö·û
3²»ÄÜʹÓÃOracleµÄ±£Áô×Ö
4Ö»ÄÜʹÓÃÈçÏÂ×Ö·û£ºA-Z,a-z,0-9,$,#µÈ
OracleÖ§³ÖµÄÊý¾ÝÀàÐÍ£º
1char ¶¨³¤£¬×î´ó2000×Ö·û
Àý×Ó£ºchar(10) ‘Ïþ»Ô’ Ç°Ëĸö×Ö·û·Å’Ïþ»Ô’£¬ºóÌíÁù¸ö¿Õ¸ñ²¹È«
2varchar2(20) ±ä³¤£¬×î´ ......
Ò».OracleÊý¾Ý¿âÖг£ÓõÄÊý¾ÝÀàÐÍ
varchar2(³¤¶È)¿É±ä³¤×Ö·û´®
char(³¤¶È) ¶¨³¤
number()±íʾÕûÊý»òÕ߸¡µãÊýnumber(8) number(8,2)
clog ×Ö·ûµÄ´ó¶ÔÏó
blog ¶þ½øÖƵĴó¶ÔÏó
¶þ.Êý¾Ý¿â²éѯ
1£©SELECTÓï¾ä
´Ó±íÖÐÌáÈ¡²éѯÊý¾Ý.Ó﷨ΪSELECT [DISTINCT] {column1,column2,…} from tablename WHERE {con ......