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µÄ時ºò¾¡Á¿ÉÙÓÃÁ¬½Ó·û“£«”Á¬½Ó×Ö·û´®£¡
Ïà¹ØÎĵµ£º
£££££¹ØÓÚ·Ö×éºó×Ö¶ÎÆ´½ÓµÄÎÊÌâ
À´×Ô:www.itpub.net
×î½üÔÚÂÛ̳ÉÏ£¬¾³£»á¿´µ½¹ØÓÚ·Ö×éºó×Ö¶ÎÆ´½ÓµÄÎÊÌ⣬
´ó¸ÅÊÇÀàËÆÏÂÁеÄÇéÐΣº
SQL> select no,q from test
2 /
NO Q
---------- ------------------------------
001 n1
001 n2
001 n3
001 n4
001 n5
002 m1
003 t1
003 t2
003 t3
003 ......
1£¬oracle tools£ºOUI¡¢DBCA¡¢OEM¡¢SQL*PLUS¡¢NETCA¡¢µÚÈý·½¹¤¾ß£¨toad¡¢PL\SQL developer£©
2£¬¿ÉʹÓÃresponsefile¿ìËÙȥͼÐΰ²×°oracle£¬ÔÚÔ´°²×°Îļþ/responseÀïÃæÓÐһЩģ°åÅäÖÃrpsÎļþ
3£¬Ô¤ÖÃÓû§ÊÇsysÓû§ÓësystemÓû§£ºsysÊÇoracleÊý¾Ý¿â
ÖÐȨÏÞ×î¸ßµÄÕʺţ¬¾ßÓÐcreate
databaseµÄȨÏÞ£¬¶øsystemûÓÐÕâ¸öȨÏÞ£ ......
¶ÔÓÚORACLEÊý¾Ý¿âµÄÊý¾Ý´æÈ¡£¬Ö÷ÒªÓÐËĸö²»Í¬µÄµ÷Õû¼¶±ð£¬µÚÒ»¼¶µ÷ÕûÊDzÙ×÷ϵͳ¼¶°üÀ¨Ó²¼þƽ̨,µÚ¶þ¼¶µ÷ÕûÊÇORACLE RDBMS¼¶µÄµ÷Õû,µÚÈý¼¶ÊÇÊý¾Ý¿âÉè¼Æ¼¶µÄµ÷Õû,×îºóÒ»¸öµ÷Õû¼¶ÊÇSQL¼¶¡£Í¨³£ÒÀ´ËËļ¶µ÷Õû¼¶±ð¶ÔÊý¾Ý¿â½øÐе÷Õû¡¢ÓÅ»¯£¬Êý¾Ý¿âµÄÕûÌåÐÔÄÜ»áµÃµ½ºÜ´óµÄ¸ÄÉÆ¡£ÏÂÃæ´Ó¼¸¸ö²»Í¬·½Ã ......
´ó¼Ò¶¼ÔÚÌÖÂÛ¹ØÓÚÊý¾Ý¿âÓÅ»¯·½ÃæµÄ¶«¶«£¬¸ÕºÃ²ÎÓ뿪·¢ÁËÒ»¸öÊý¾Ý²Ö¿â·½ÃæµÄÏîÄ¿£¬ÒÔϵÄÒ»µã¶«Î÷ËãÊÇÊý¾Ý¿âÓÅ»¯·½ÃæµÄѧϰ+ʵսµÄһЩÐĵÃÌå»áÁË£¬ÄóöÀ´´ó¼Ò¹²Ïí¡£»¶ÓÅúÆÀÖ¸Õý°¢£¡
SQLÓï¾ä£º
ÊǶÔÊý¾Ý¿â(Êý¾Ý)½øÐвÙ×÷µÄΩһ;¾¶£»
ÏûºÄÁË70%~90%µÄÊý¾Ý¿â×ÊÔ´£»¶ÀÁ¢ÓÚ³ÌÐòÉè¼ÆÂß¼£¬Ïà¶ÔÓÚ¶Ô³ÌÐòÔ´´úÂëµÄÓÅ»¯£¬¶ÔSQ ......