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

sql»ù´¡ÖªÊ¶

SQLÓïÑÔÓÉÃüÁî¡¢×Ӿ䡢ÔËËãºÍ¼¯ºÏº¯ÊýµÈ¹¹³É¡£ÔÚSQLÖУ¬Êý¾Ý¶¨ÒåÓïÑÔDDL£¨ÓÃÀ´½¨Á¢¼°¶¨ÒåÊý¾Ý±í¡¢×Ö¶ÎÒÔ¼°Ë÷ÒýµÈÊý¾Ý¿â½á¹¹£©°üº¬µÄÃüÁîÓÐCREATE¡¢DROP¡¢ALTER£»Êý¾Ý²Ù×ÝÓïÑÔDML£¨ÓÃÀ´ÌṩÊý¾ÝµÄ²éѯ¡¢ÅÅÐòÒÔ¼°É¸Ñ¡Êý¾ÝµÈ¹¦ÄÜ£©°üº¬µÄÃüÁîÓÐSELECT¡¢INSERT¡¢UPDATE¡¢DELETE¡£
Ò»¡¢SQLÓï¾ä
£¨1£©Select ²éѯÓï¾ä
Óï·¨£ºSELECT [ALL|DISTINCT] <Ä¿±êÁбí´ïʽ> [AS ÁÐÃû]
[,<Ä¿±êÁбí´ïʽ> [AS ÁÐÃû] ...] from <±íÃû> [£¬<±íÃû>…]
[WHERE <Ìõ¼þ±í´ïʽ> [AND|OR <Ìõ¼þ±í´ïʽ>...]
[GROUP BY ÁÐÃû [HAVING <Ìõ¼þ±í´ïʽ>>
[ORDER BY ÁÐÃû [ASC | DESC>
½âÊÍ£º[ALL|DISTINCT]   ALL£ºÈ«²¿£» DISTINCT£º²»°üÀ¨Öظ´ÐÐ
<Ä¿±êÁбí´ïʽ> ¶Ô×ֶοÉʹÓÃAVG¡¢COUNT¡¢SUM¡¢MIN¡¢MAX¡¢ÔËËã·ûµÈ
<Ìõ¼þ±í´ïʽ>
²éѯÌõ¼þ ν´Ê
±È½Ï =¡¢>,<,>=,<=,!=,<>,
È·¶¨·¶Î§ BETWEEN AND¡¢NOT BETWEEN AND
È·¶¨¼¯ºÏ IN¡¢NOT IN
×Ö·ûÆ¥Åä LIKE£¨“%”Æ¥ÅäÈκγ¤¶È£¬“_”Æ¥ÅäÒ»¸ö×Ö·û£©¡¢NOT LIKE
¿ÕÖµ IS NULL¡¢IS NOT NULL
×Ó²éѯ ANY¡¢ALL¡¢EXISTS
¼¯ºÏ²éѯ UNION£¨²¢£©¡¢INTERSECT£¨½»£©¡¢MINUS£¨²î£©
¶àÖØÌõ¼þ AND¡¢OR¡¢NOT
<GROUP BY ÁÐÃû> ¶Ô²éѯ½á¹û·Ö×é
[HAVING <Ìõ¼þ±í´ïʽ>] ·Ö×éɸѡÌõ¼þ
[ORDER BY ÁÐÃû [ASC | DESC> ¶Ô²éѯ½á¹ûÅÅÐò£»ASC£ºÉýÐò DESC£º½µÐò
Àý1£º select student.sno as ѧºÅ, student.name as ÐÕÃû, course as ¿Î³ÌÃû, score as ³É¼¨ from score,student where student.sid=score.sid and score.sid=:sid
Àý2£ºselect student.sno as ѧºÅ, student.name as ÐÕÃû,AVG(score) as ƽ¾ù·Ö from score,student where student.sid=score.sid and student.class=:class and (term=5 or term=6) group by student.sno, student.name having count(*)>0 order by ƽ¾ù·Ö DESC
Àý3£ºselect * from score where sid like '9634'
Àý4£ºselect * from student where class in (select class from student where name='³ÂСС')
£¨2£©INSERT²åÈëÓï¾ä
Óï·¨£ºINSERT INTO <±íÃû> [£¨<×Ö¶ÎÃû1> [,<×Ö¶ÎÃû2>, ...])] VALUES (<³£Á¿1> [,<³£Á¿2>, ...])
Óï·¨£ºINSERT INTO <±íÃû> [£¨<×Ö¶ÎÃû1> [,<×Ö¶ÎÃû2>, ...])] ×Ó²éѯ
Àý×Ó£ºINSERT INTO ½èÊé±í£¨


Ïà¹ØÎĵµ£º

SQL Server ÖÐASµÄÌØÊâÐÔ

 ÍâÁ¬½ÓÈ¡Êý¾ÝÈç¹ûΪ¿Õ£¬²»´æÔÚASʱ¿ÉÄÜÈ¡µ½Êý¾Ý£¬µ«¼ÓÁËAS¾Í»á±¨´í¡£±ÈÈçSelect Top 10 a.*,b.Class AS ClassId
,b.DeviceName from AuxBusInfo a Left Join  DeviceCandidate b On a.InitialDeviceRscId = b.DeviceRscId Order By AuxBusId£¬µ± ......

SQL SERVERÓï·¨

1.´´½¨±í
(1)ÓÃCreate Table ÃüÁî´´½¨±í
Óï·¨:
Create Table tabl_name
({
}column_name As computed_column_expression
}
}[£¬...n]
)
[On {fiegroup | Default}]
[Textimage_On {fiegroup | Default}]
Àý×Ó:
´ò¿ªcustÊý¾Ý¿â£¬´´½¨Ò»¸ö±í£¬¸Ã±í°üº¬ÁËѧÉúµÄÓйØÐÅÏ¢£¬¼´ÓÐѧºÅ¡¢ÐÕÃû¡¢ÐԱ𡢳öÉúÈ ......

ASP.NETÔ¶³Ì±¸·Ý»Ö¸´SQL ServerÊý¾Ý¿â

///<summary>
      ///±¸·ÝÊý¾Ý¿âµ½±¾µØ´ÅÅÌ
      ///</summary>
    public bool BackUp(string BackUpFile)
    {
        try
&nbs ......

¾«ÃîSQL語¾ä

      1. ˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ£¬Ô´±íÃû£ºa£¬Ð±íÃû£ºb)
SQL: select * into b from a where 1<>1;
        2. ˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý£¬Ô´±íÃû£ºa£¬Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d, e, f from b;
   &nb ......

SQLÓïÑÔ»ù±¾Óï¾ä½éÉÜ


±íµÄ½¨Á¢
¹ØϵÊý¾Ý¿âµÄÖ÷ÒªÌصãÖ®Ò»¾ÍÊÇÓñíµÄ·½Ê½×éÖ¯Êý¾Ý¡£±íÊÇSQLÓïÑÔ´æ·ÅÊý¾Ý¡¢²éÕÒÊý¾ÝÒÔ¼°¸üÐÂÊý¾ÝµÄ»ù±¾Êý¾Ý½á¹¹¡£ÔÚSQLÓïÑÔÖУ¬±íÓÐÑϸñµÄ¶¨Ò壬ËüÊÇÒ»ÖÖ¶þά±í£¬¶ÔÓÚÕâÖÖ±íÓÐÈçϹ涨£º
1)ÿһÕÅ±í¶¼ÓÐÒ»¸öÃû×Ö£¬Í¨³£³ÆΪ±íÃû»ò¹ØϵÃû¡£±íÃû±ØÐëÒÔ×Öĸ¿ªÍ·£¬×î´ó³¤¶ÈΪ30¸ö×Ö·û¡£
2)Ò»Õűí¿ÉÒÔÓÉÈô¸ÉÁÐ×é³É£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ