Oracle SQLÓÅ»¯¼¼ÇÉ
ÎÒ¾õµÃÖ÷ÒªÓ¦¸Ã´Ó5¸ö·½Ãæ½øÐе÷Õû£º
1.È¥µô²»±ØÒªµÄ´óÐͱíµÄÈ«±íɨÃè
2.»º´æСÐͱíµÄÈ«±íɨÃè
3.¼ìÑéÓÅ»¯Ë÷ÒýµÄʹÓÃ
4.¼ìÑéÓÅ»¯µÄÁ¬½Ó¼¼Êõ
5.¾¡¿ÉÄܼõÉÙÖ´Ðмƻ®µÄCost
ÏÖÔÚ¼òµ¥µÄ¾Ù¼¸¸öÀý×Ó
Where×Ó¾äÖÐÓГ!=”½«²»Ê¹ÓÃË÷Òý
select account_name from test where amount != 0 (²»Ê¹ÓÃ)
select account_name from test where amount > 0 (ʹÓÃ)
WhereÌõ¼þÖжÔ×Ö¶ÎÔö¼Ó´¦Àíº¯Êý½«²»Ê¹ÓøÃÁеÄË÷Òý
select * from emp where to_char(hire_date,'yyyymmdd')='20080411' (²»Ê¹ÓÃ)
select * from emp where hire_date = to_char('20080411','yyyymmdd') (ʹÓÃ)
±ÜÃâÔÚË÷ÒýÁÐÉÏʹÓÃIS NULL
select * from emp where dept_code is null (²»Ê¹ÓÃ)
select * from emp where dept_code > 0 (ʹÓÃ)
IS NULL²»會Óõ½Ë÷Òý
¶øIS NOT NULLÓõ½Ë÷ÒýÈ«掃Ãè
ͨÅä·û% µÄʹÓÃ
select * from emp where name like '%A' (²»Ê¹ÓÃË÷Òý)
select * from emp where name like 'A%' (ʹÓÃË÷Òý)
¿ÉÒÔͨ¹ý½¨Á¢·´ÏòË÷Òý
ÈÃselect * from emp where name like '%A'
ҲʹÓÃË÷Òý
ÔÚº¬ÓÐ×Ó²éѯµÄSQLÓï¾äÖÐ,ÒªÌرð×¢Òâ¼õÉÙ¶Ô±íµÄ²éѯ.Àý×Ó£º
SELECT EMP_NO from EMP WHERE (GROUP,NAME) = ( SELECT
COLUMN1,COLUMN2 from TEST WHERE TEST_ID = 604)
×î¸ßЧµÄɾ³ýÖظ´¼Ç¼·½·¨ ( ÒòΪʹÓÃÁËROWID)Àý×Ó£º
DELETE from EMP E WHERE E.ROWID > (SELECT MIN(X.ROWID)
from EMP X WHERE X.EMP_NO = E.EMP_NO);
sqlÓï¾äÓôóдµÄ£»ÒòΪoracle×ÜÊÇÏȽâÎösqlÓï¾ä£¬°ÑСдµÄ×Öĸת»»³É´óдµÄÔÙÖ´ÐÐ
ÔÚjava´úÂëÖÐÓõ½preparedStatementµÄ時ºò¾¡Á¿ÉÙÓÃÁ¬½Ó·û“£«”Á¬½Ó×Ö·û´®£¡
Ïà¹ØÎĵµ£º
Êý¾Ý¿âѹÁ¦²âÊÔ
Ò»¡¢ÓÃorabm²âÊÔÊý¾Ý¿âCPU
Orabmͨ¹ýÔÚÓû§Ö¸¶¨µÄ²¢·¢ÏÂÔËÐÐÖ¸¶¨ÊýÁ¿µÄÊÂÎñÀ´²âÊÔϵͳÐÔÄÜ.ËüÖ÷Òª²âÊÔÊý¾Ý¿â·þÎñÆ÷µÄCPUÐÔÄܺÍÄÚ´æ¡£
orabmʵ¼ÊÉÏÊÇÒ»¶ÑsqlµÄ¼¯ºÏ¡£
orabm¿ÉÒÔÓÃÔÚlinux/windows/solarisÏÂʹÓá£
orabm²»Ò»¶¨ÐèÒªÔËÐÐÔÚÊý¾Ý¿âËùÔÚ·þÎñÆ÷ÉÏ£¬Ëü¿ÉÒÔÔËÐÐÔÚÈκΰ²×°ÁË9i¿Í»§¶ËµÄÖÕ¶ËÉÏ¡£Äã ......
ÔÚÏàͬ²Ù×÷ϵͳ»·¾³Ï£¬Ïàͬ°æ±¾OracleÊý¾Ý¿âµÄǨÒƱȽϼòµ¥¡£
´óÖ²½Ö裺
1¡¢È·¶¨Ô´»úµÄ²Ù×÷ϵͳÀàÐͺͰ汾£¬Ô´»úÖ÷»úÃû£»Oracle°æ±¾£¬°²×°Ä¿Â¼£¬SID¡£
±¾ÀýÖУ¬Ô´»úΪ£º Win2k Adv£¬ ywxt£¬Oracle v8.17, d:\oracle, orcl
Ä¿±ê»úΪ£ºWin2003£¬ywxt£¬Oracle v8.17, d:\oracle, orcl
......
OracleÖ´ÐÐÍⲿÎļþ£º
c:>sqlplus user/pwd@db
sql>@new.sql
Ö´Ðжà¸ösqlÎļþ:
1.°ÑËùÓеÄÎļþ¶¼·ÅÔÚͬһ¸öĿ¼Ï£¬È»ºóÔÚÃüÁîÐÐÀïÖ´ÐÐÃüÁ
c:>dir/b > d:\1.sql
»á°ÑËùÓеÄsqlÎļþÃû¶¼Êä³öµ½Ò»¸ösqlÎļþÖС£
2.ÓÃUltraEdit´ò¿ªÉú³ÉµÄ ......
¶ÔÓÚORACLEÊý¾Ý¿âµÄÊý¾Ý´æÈ¡£¬Ö÷ÒªÓÐËĸö²»Í¬µÄµ÷Õû¼¶±ð£¬µÚÒ»¼¶µ÷ÕûÊDzÙ×÷ϵͳ¼¶°üÀ¨Ó²¼þƽ̨,µÚ¶þ¼¶µ÷ÕûÊÇORACLE RDBMS¼¶µÄµ÷Õû,µÚÈý¼¶ÊÇÊý¾Ý¿âÉè¼Æ¼¶µÄµ÷Õû,×îºóÒ»¸öµ÷Õû¼¶ÊÇSQL¼¶¡£Í¨³£ÒÀ´ËËļ¶µ÷Õû¼¶±ð¶ÔÊý¾Ý¿â½øÐе÷Õû¡¢ÓÅ»¯£¬Êý¾Ý¿âµÄÕûÌåÐÔÄÜ»áµÃµ½ºÜ´óµÄ¸ÄÉÆ¡£ÏÂÃæ´Ó¼¸¸ö²»Í¬·½Ã ......
¡¡¡¡´ÓÓαêÌáÈ¡Êý¾Ý
¡¡¡¡´ÓÓαêµÃµ½Ò»ÐÐÊý¾ÝʹÓÃFETCHÃüÁÿһ´ÎÌáÈ¡Êý¾Ýºó£¬Óα궼ָÏò½á¹û¼¯µÄÏÂÒ»ÐС£Óï·¨ÈçÏ£º
FETCH cursor_name INTO variable[,variable,...]
¡¡¡¡¶ÔÓÚSELECT¶¨ÒåµÄÓαêµÄÿһÁУ¬FETCH±äÁ¿ÁÐ±í¶¼Ó¦¸ÃÓÐÒ»¸ö±äÁ¿ÓëÖ®Ïà¶ÔÓ¦£¬±äÁ¿µÄÀàÐÍÒ²ÒªÏàͬ¡£
¡¡¡¡Àý£º
SET SERVERIUTPUT ON
DECLARE
......