Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL CREATE TABLEµÄÓ÷¨

±í¸ñÊÇÊý¾Ý¿âÖд¢´æ×ÊÁϵĻù±¾¼Ü¹¹¡£ÔÚ¾ø´ó²¿·ÝµÄÇé¿öÏ£¬Êý¾Ý¿â³§É̲»¿ÉÄÜÖªµÀÄúÐèÒªÈçºÎ´¢´æÄúµÄ×ÊÁÏ£¬ËùÒÔͨ³£Äú»áÐèÒª×Ô¼ºÔÚÊý¾Ý¿âÖн¨Á¢±í¸ñ¡£ËäÈ»Ðí¶àÊý¾Ý¿â¹¤¾ß¿ÉÒÔÈÃÄúÔÚ²»ÐèÓõ½ SQL µÄÇé¿öϽ¨Á¢±í¸ñ£¬²»¹ýÓÉÓÚ±í¸ñÊÇÒ»¸ö×î»ù±¾µÄ¼Ü¹¹£¬ÎÒÃǾö¶¨°üÀ¨ CREATE TABLE µÄÓï·¨ÔÚÕâ¸öÍøÕ¾ÖС£
ÔÚÎÒÃÇÌøÈë CREATE TABLE µÄÓ﷨֮ǰ£¬ÎÒÃÇ×îºÃÏȶԱí¸ñÕâ¸ö¶«Î÷ÓÐЩ¶àÒ»µãµÄÁ˽⡣±í¸ñ±»·ÖΪÀ¸Î» (column) ¼°ÁÐλ (row)¡£Ã¿Ò»Áдú±íÒ»±Ê×ÊÁÏ£¬¶øÿһÀ¸´ú±íÒ»±Ê×ÊÁϵÄÒ»²¿·Ý¡£¾ÙÀýÀ´Ëµ£¬Èç¹ûÎÒÃÇÓÐÒ»¸ö¼ÇÔع˿Í×ÊÁϵıí¸ñ£¬ÄÇÀ¸Î»¾ÍÓпÉÄÜ°üÀ¨ÐÕ¡¢Ãû¡¢µØÖ·¡¢³ÇÊС¢¹ú¼Ò¡¢ÉúÈÕ£®£®£®µÈµÈ¡£µ±ÎÒÃǶԱí¸ñ϶¨Òåʱ£¬ÎÒÃÇÐèҪעÃ÷À¸Î»µÄ±êÌ⣬ÒÔ¼°ÄǸöÀ¸Î»µÄ×ÊÁÏÖÖÀà¡£
ÄÇ£¬×ÊÁÏÖÖÀàÊÇʲôÄØ£¿×ÊÁÏ¿ÉÄÜÊÇÒÔÐí¶à²»Í¬µÄÐÎʽ´æÔڵġ£Ëü¿ÉÄÜÊÇÒ»¸öÕûÊý (ÀýÈç 1)£¬¡¢Ò»¸öʵÊý(ÀýÈç 0.55)¡¢Ò»¸ö×Ö´® (ÀýÈç 'sql')¡¢Ò»¸öÈÕÆÚ/ʱ¼ä (ÀýÈç '2000-JAN-25 03:22:22')¡¢»òÉõÖÁÊÇ ÒÔ¶þ½ø·¨ (binary) µÄ״̬´æÔÚ¡£µ±ÎÒÃÇÔÚ¶ÔÒ»¸ö±í¸ñ϶¨Òåʱ£¬ÎÒÃÇÐèÒª¶Ôÿһ¸öÀ¸Î»µÄ×ÊÁÏÖÖÀà϶¨Òå¡£(ÀýÈç 'ÐÕ' Õâ¸öÀ¸Î»µÄ×ÊÁÏÖÖÀàÊÇ char(50)©¥©¥´ú±íÕâÊÇÒ»¸ö 50 ¸ö×Ö·ûµÄ×Ö´®)¡£ÎÒÃÇÐèҪעÒâµÄÒ»µãÊDz»Í¬µÄÊý¾Ý¿âÓв»Í¬µÄ×ÊÁÏÖÖÀ࣬ËùÒÔÔÚ¶Ô±í¸ñ×ö³ö¶¨Òå֮ǰ×îºÃÏȲο¼Ò»ÏÂÊý¾Ý¿â±¾ÉíµÄ˵Ã÷¡£
CREATE TABLE µÄÓï·¨ÊÇ£º
CREATE TABLE "±í¸ñÃû"
("À¸Î» 1" "À¸Î» 1 ×ÊÁÏÖÖÀà",
"À¸Î» 2" "À¸Î» 2 ×ÊÁÏÖÖÀà",
... )
ÈôÎÒÃÇÒª½¨Á¢ÎÒÃÇÉÏÃæÌá¹ýµÄ¹Ë¿Í±í¸ñ£¬ÎÒÃǾʹòÈëÒÔÏ嵀 SQL£º
CREATE TABLE customer
(First_Name char(50),
Last_Name char(50),
Address char(50),
City char(50),
Country char(25),
Birth_Date date)


Ïà¹ØÎĵµ£º

SQL SELECTµÄÓ÷¨

ÊÇÓÃÀ´×öʲôµÄÄØ£¿Ò»¸ö×î³£Óõķ½Ê½Êǽ«×ÊÁÏ´ÓÊý¾Ý¿âÖеıí¸ñÄÚÑ¡³ö¡£´ÓÕâÒ»¾ä»Ø´ðÖУ¬ÎÒÃÇÂíÉÏ¿ÉÒÔ¿´µ½Á½¸ö¹Ø¼ü×Ö£º ´Ó (from) Êý¾Ý¿âÖеıí¸ñÄÚÑ¡³ö (SELECT)¡£(±í¸ñÊÇÒ»¸öÊý¾Ý¿âÄڵĽṹ£¬ËüµÄÄ¿µÄÊÇ´¢´æ×ÊÁÏ¡£ÔÚ±í¸ñ´¦ÀíÕâÒ»²¿·ÖÖУ¬ÎÒÃÇ»áÌáµ½ÈçºÎʹÓà SQL À´É趨±í¸ñ¡£) ÎÒÃÇÓÉÕâÀï¿ÉÒÔ¿´µ½×î»ù±¾µÄ SQL ¼Ü¹¹£º
SE ......

SQL DISTINCTµÄÓ÷¨

SELECT Ö¸ÁîÈÃÎÒÃÇÄܹ»¶ÁÈ¡±í¸ñÖÐÒ»¸ö»òÊý¸öÀ¸Î»µÄËùÓÐ×ÊÁÏ¡£ Õ⽫°ÑËùÓеÄ×ÊÁ϶¼×¥³ö£¬ÎÞÂÛ×ÊÁÏÖµÓÐÎÞÖظ´¡£ÔÚ×ÊÁÏ´¦ÀíÖУ¬ÎÒÃǻᾭ³£Åöµ½ÐèÒªÕÒ³ö±í¸ñÄڵIJ»Í¬ ×ÊÁÏÖµµÄÇé¿ö¡£»»¾ä»°Ëµ£¬ÎÒÃÇÐèÒªÖªµÀÕâ¸ö±í¸ñ/À¸Î»ÄÚÓÐÄÄЩ²»Í¬µÄÖµ£¬¶øÿ¸öÖµ³öÏֵĴÎÊý²¢²»ÖØÒª¡£ÕâÒªÈçºÎ´ï³ÉÄØ£¿ÔÚ SQL ÖУ¬ÕâÊǺÜÈÝÒ××öµ½µÄ¡£ÎÒÃÇÖ»ÒªÔ ......

SQL ORDER BYµÄÓ÷¨

µ½Ä¿Ç°ÎªÖ¹£¬ÎÒÃÇÒÑѧµ½ÈçºÎ½åÓÉ SELECT ¼° WHEREÕâÁ½¸öÖ¸Á×ÊÁÏÓɱí¸ñÖÐ×¥³ö¡£²»¹ýÎÒÃÇÉÐδÌáµ½ÕâЩ×ÊÁÏÒªÈçºÎÅÅÁС£ÕâÆäʵÊÇÒ»¸öºÜÖØÒªµÄÎÊÌâ¡£ÊÂʵÉÏ£¬ÎÒÃǾ­³£ÐèÒªÄܹ»½«×¥³öµÄ×ÊÁÏ×öÒ»¸öÓÐϵͳµÄÏÔʾ¡£Õâ¿ÉÄÜÊÇÓÉСÍù´ó (ascending) »òÊÇÓÉ´óÍùС(descending)¡£ÔÚÕâÖÖÇé¿öÏ£¬ÎÒÃǾͿÉÒÔÔËÓà ORDER BYÕâ¸öÖ¸ÁîÀ´´ïµ½ ......

SQL COUNTµÄÓ÷¨

ÔÚÉÏÒ»Ò³ÓÐÌáµ½£¬COUNT ÊǺ¯ÊýÖ®Ò»¡£ÓÉÓÚËüµÄʹÓù㷺£¬ÎÒÃÇÔÚÕâÀïÌرðÌá³öÀ´ÌÖÂÛ¡£»ù±¾ÉÏ£¬COUNT ÈÃÎÒÃÇÄܹ»Êý³öÔÚ±í¸ñÖÐÓжàÉÙ±Ê×ÊÁϱ»Ñ¡³öÀ´¡£ËüµÄÓï·¨ÊÇ£º
SELECT COUNT("À¸Î»Ãû")
from "±í¸ñÃû"
¾ÙÀýÀ´Ëµ£¬ÈôÎÒÃÇÒªÕÒ³öÎÒÃǵÄʾ·¶±í¸ñÖÐÓм¸±Ê store_name À¸²»ÊÇ¿Õ°×µÄ×ÊÁÏʱ£¬
Store_Information ±í¸ñ
store ......

SQL SUBSTRINGµÄÓ÷¨

SQL ÖÐµÄ substring º¯ÊýÊÇÓÃÀ´×¥³öÒ»¸öÀ¸Î»×ÊÁÏÖеÄÆäÖÐÒ»²¿·Ö¡£Õâ¸öº¯ÊýµÄÃû³ÆÔÚ²»Í¬µÄ×ÊÁÏ¿âÖв»ÍêÈ«Ò»Ñù£º
MySQL: SUBSTR(), SUBSTRING()
Oracle: SUBSTR()
SQL Server: SUBSTRING()
×î³£Óõ½µÄ·½Ê½ÈçÏ (ÔÚÕâÀïÎÒÃÇÓÃSUBSTR()ΪÀý)£º
SUBSTR(str,pos): ÓÉ<str>ÖУ¬Ñ¡³öËùÓдӵÚ<pos>λÖÿªÊ¼µÄ× ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ