ʹÓÃSQLÓï¾ä
ʹÓÃSQLÓï¾ä
SQLÓïÑÔ°üÀ¨Êý¾Ý²éѯÓïÑÔ(SELECT)¡¢Êý¾Ý²Ù×ÝÓïÑÔ(INSERT¡¢UPDATE¡¢DELETE)¡¢ÊÂÎñ¿ØÖÆÓïÑÔ(COMMIT¡¢ROLLBACK¡¢SAVEPOINT)¡¢Êý¾Ý¶¨ÒåÓïÑÔ(CREATE TABLE¡¢ALTER TABLE¡¢DROP)¡¢Êý¾Ý¿ØÖÆÓïÑÔ(GRANT¡¢REVOKE)µÈÎå¸ö²¿·Ö¡£
µ±±àдPL/SQLÓ¦ÓóÌÐòʱ£¬Ö»ÄÜÖ±½ÓǶÈëSELECT...INTO...Óï¾ä¡¢DMLÓï¾äºÍÊÂÎñ¿ØÖÆÓï¾ä¡£
(Ò»)ʹÓûù±¾²éѯ
¢Ù¼òµ¥²éѯÓï¾ä
(1) Óï·¨£ºSELECT <*,column [±ðÃû],...> from TABLE|VIEW;
ÆäÖУº*±íʾ¼ìË÷ËùÓÐÁУ¬columnÓÃÓÚÖ¸¶¨Òª¼ìË÷µÄÁлò±í´ïʽ*£¨¶àÁлò¶à±í´ïʽ֮¼äÓöººÅ·Ö¸ô£©£¬±ðÃûÓÃÓÚÖ¸¶¨Áлò±í´ïʽµÄ±ðÃû£¬fromÓÃÓÚÖ¸¶¨Òª¼ìË÷µÄ±í»òÊÓͼ¡£
×¢£º*ºÍcolumn²»ÄÜ»ìºÏʹÓÃ
(2)DESC(describe) ±íÃû³Æ --ÓÃÓÚÈ·¶¨±í½á¹¹
(3)¼ìË÷ÈÕÆÚÁÐʱ£¬ÈÕÆÚĬÈÏÏÔʾ¸ñʽΪ'dd-mon-yy',Èç¹ûÒªÏëʹÓÃ'yyyy-mon-dd'¸ñʽ£¬Ôò±ØÐëʹÓÃTO_CHARº¯Êý½øÐÐת»»¡£
Àý£º
SQL> select ename,job,hiredate from emp where deptno=10; --ĬÈÏ
ENAME JOB HIREDATE
---------- --------- --------------
CLARK MANAGER 09-6ÔÂ -81
KING PRESIDENT 17-11ÔÂ-81
MILLER CLERK 23-1ÔÂ -82
SQL> select ename,job,to_char(hiredate,'yyyy-mon-dd') from emp where deptno=10; --ʹÓÃto_charº¯Êý
ENAME JOB TO_CHAR(HIREDATE
---------- --------- ----------------
CLARK MANAGER 1981-6ÔÂ -09
KING PRESIDENT 1981-11ÔÂ-17
MILLER CLERK &n
Ïà¹ØÎĵµ£º
¾ßÌåҪעÒâµÄ£º
1.Ó¦¾¡Á¿±ÜÃâÔÚ where ×Ó¾äÖжÔ×ֶνøÐÐ null ÖµÅжϣ¬·ñÔò½«µ¼ÖÂÒýÇæ·ÅÆúʹÓÃË÷Òý¶ø½øÐÐÈ«±íɨÃ裬È磺
select id from t where num is null
¿ÉÒÔÔÚnumÉÏÉèÖÃĬÈÏÖµ0£¬È·±£±íÖÐnumÁÐûÓÐnullÖµ£¬È»ºóÕâÑù²éѯ£º
select id from t where num=0 &n ......
SQL Server Êý¾Ý¿â¹ÊÕÏÐÞ¸´¶¥¼¶¼¼ÇÉÖ®Ò»
2010-04-26 10:37:52 À´Ô´:TechTargetÖйú ÎÒÒªÊÕ²Ø
SQL Server 2005 ºÍ 2008 Óм¸¸ö¹ØÓڸ߿ÉÓÃÐÔµÄÑ¡ÏÈçÈÕÖ¾´«Êä¡¢¸±±¾ºÍÊý¾Ý¿â¾µÏñ¡£ËùÓÐÕâЩ¼¼Êõ¶¼Äܹ»×÷Ϊά»¤Ò»¸ö±¸Ó÷þÎñÆ÷µÄÊֶΣ¬Í¬Ê±Õâ¸öÊý¾Ý¿â¿ÉÒÔÔÚÄãÔÏȵÄÖ÷Êý¾Ý¿â³öÎÊÌâʱÉÏÏß²¢×÷ΪеÄÖ÷·þÎñÆ÷¡£È»¶ø£¬Äã± ......
--ͨ¹ýsqlÆóÒµ¹ÜÀíÆ÷Ð޸ĺÍɾ³ýa±íÖÐÊý¾Ýʱ»á³öÏÖ´íÎó
--sqlÆóÒµ¹ÜÀíBug£¬Í¨¹ý³ÌÐò»òÖ´ÐÐsqlÓï¾ä¸üÐÂa±íÊý¾ÝûÓÐÎÊÌâ
--Ìí¼Ó
Insert a (FName, FCode, FOther) Values('11','2222','33')
--ÐÞ¸Ä
Update a Set FName='22_Edit' Where FCode='22'
--ɾ³ý
Delete a Where FCode='22'
--²é¿´a/b±íÊý¾Ý
Select * from a ......
¼Ü¹¹£¨Schema£©¡£Î¢ÈíµÄ¹Ù·½ËµÃ÷£¨MSDN£©£º
"Êý¾Ý¿â¼Ü¹¹ÊÇÒ»¸ö¶ÀÁ¢ÓÚÊý¾Ý¿âÓû§µÄ·ÇÖظ´ÃüÃû¿Õ¼ä£¬Äú¿ÉÒÔ½«¼Ü¹¹ÊÓΪ¶ÔÏóµÄÈÝÆ÷"£¬Ïêϸ²Î¿¼
http://technet.microsoft.com/zh-cn/library/ms190387.aspx.ÎÒÃÇÖªµÀ£¬ÔÚJAVAÖУ¬ÃüÃû¿Õ
¼äÃûÆäʵ¾ÍÊÇÎļþ¼ÐÃû¡£Òò´ËÎÒÃǷdz£Ã÷È·Ò»µã£ºÒ»¸ö¶ÔÏóÖ»ÄÜÊôÓÚÒ»¸ö¼Ü¹¹£¬¾ÍÏ ......