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

±ê×¼³£ÓÃsqlÓï¾ä Ò»

 SQL ÊÇÒ»ÃÅ ANSI µÄ±ê×¼¼ÆËã»úÓïÑÔ£¬ÓÃÀ´·ÃÎʺͲÙ×÷Êý¾Ý¿âϵͳ¡£SQL Óï¾äÓÃÓÚÈ¡»ØºÍ¸üÐÂÊý¾Ý¿âÖеÄÊý¾Ý¡£SQL ¿ÉÓëÊý¾Ý¿â³ÌÐòЭͬ¹¤×÷£¬±ÈÈç MS Access¡¢DB2¡¢Informix¡¢MS SQL Server¡¢Oracle¡¢Sybase ÒÔ¼°ÆäËûÊý¾Ý¿âϵͳ¡£
²»ÐÒµØÊÇ£¬´æÔÚןܶ಻ͬ°æ±¾µÄ SQL ÓïÑÔ£¬µ«ÊÇΪÁËÓë ANSI ±ê×¼Ïà¼æÈÝ£¬ËüÃDZØÐëÒÔÏàËƵķ½Ê½¹²Í¬µØÀ´Ö§³ÖһЩÖ÷ÒªµÄ¹Ø¼ü´Ê£¨±ÈÈç SELECT¡¢UPDATE¡¢DELETE¡¢INSERT¡¢WHERE µÈµÈ£©¡£
×¢ÊÍ£º³ýÁË SQL ±ê×¼Ö®Í⣬´ó²¿·Ö SQL Êý¾Ý¿â³ÌÐò¶¼ÓµÓÐËüÃÇ×Ô¼ºµÄ˽ÓÐÀ©Õ¹£¡
³£ÓÃÓï¾ä
SELECT * from Persons WHERE LastName IN ('Adams','Carter')
SELECT * from Persons WHERE LastName BETWEEN 'Adams' AND 'Carter' £¨×Öĸ˳Ðò£©
SELECT * from Persons WHERE LastName NOT BETWEEN 'Adams' AND 'Carter'
ʹÓñðÃû£¨±íºÍ×ֶζ¼ÄܱðÃû£©
SELECT po.OrderID, p.LastName, p.FirstName
from Persons AS p, Product_Orders AS po
WHERE p.LastName='Adams'
WHERE p.FirstName='John'
SELECT LastName AS Family, FirstName AS Name
from Persons
¶à±í²éѯ
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
from Persons, Orders
WHERE Persons.Id_P = Orders.Id_P
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
from Persons
INNER JOIN Orders
ON Persons.Id_P = Orders.Id_P
ORDER BY Persons.LastName
SELECT column_name(s)
from table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
²»Í¬µÄ SQL JOIN
³ýÁËÎÒÃÇÔÚÉÏÃæµÄÀý×ÓÖÐʹÓÃµÄ INNER JOIN£¨ÄÚÁ¬½Ó£©£¬ÎÒÃÇ»¹¿ÉÒÔÆäËû¼¸ÖÖÁ¬½Ó¡£
ÏÂÃæÁгöÁËÄú¿ÉÒÔʹÓÃµÄ JOIN ÀàÐÍ£¬ÒÔ¼°ËüÃÇÖ®¼äµÄ²îÒì¡£
JOIN: Èç¹û±íÖÐÓÐÖÁÉÙÒ»¸öÆ¥Å䣬Ôò·µ»ØÐÐ
LEFT JOIN: ¼´Ê¹ÓÒ±íÖÐûÓÐÆ¥Å䣬Ҳ´Ó×ó±í·µ»ØËùÓеÄÐÐ
RIGHT JOIN: ¼´Ê¹×ó±íÖÐûÓÐÆ¥Å䣬Ҳ´ÓÓÒ±í·µ»ØËùÓеÄÐÐ
FULL JOIN: Ö»ÒªÆäÖÐÒ»¸ö±íÖдæÔÚÆ¥Å䣬¾Í·µ»ØÐÐ
SELECT column_name(s) from table_name1
UNION
SELECT column_name(s) from table_name2   //²»ÔÊÐíÖظ´
SELECT column_name(s) from table_name1
UNION ALL
SELECT column_name(s) from table_name2   //ÔÊÐíÖظ´
²åÈëÊվݵ½Ð±í
SELECT *
INTO Persons IN 'Backup.mdb'   //IN 'Backup.mdb' Öƶ¨Êý¾Ý¿âÖеÄÕâ¸ö±í
from Persons
SE


Ïà¹ØÎĵµ£º

SQL ͨÓô洢¹ý³Ì


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/ ......

java»ñÈ¡SQL²éѯ½á¹û¼¯ÖеÄÐÐÊýºÍÁÐÊý

http://cheneyph.javaeye.com/blog/477829
         ÔÚJavaÖУ¬»ñµÃResultSetµÄ×ÜÐÐÊýµÄ·½·¨ÓÐÒÔϼ¸ÖÖ¡£
µÚÒ»ÖÖ£ºÀûÓÃResultSetµÄgetRow·½·¨À´»ñµÃResultSetµÄ×ÜÐÐÊý
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABL ......

SQLÖظ´¼Ç¼²éѯ

SQLÖظ´¼Ç¼²éѯ
1¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select * from
people
where peopleId in (select   peopleId from   people group by   peopleId
having count
(peopleId) > 1)
2¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨p ......

sql 2000MMC ²»ÄÜ´ò¿ªÎļþ

 MMC ²»ÄÜ´ò¿ªÎļþ C:\Program Files\Microsoft SQL Server\80\Tools\BINN\SQL Server Enterprise Manager.MSC¡£¿ÉÒÔÔ­ÒòÊÇÎļþ²»´æÔÚ£¬²»ÊÇÒ»¸öMMC¿ØÖÆ̨£¬»òÕßÓúóÀ´MMC°æ±¾´´½¨£¬Ò²ÐíҲûÓзÃÎÊ´ËÎļþµÄ×㹻ȨÏÞ¡£
½â¾ö·½·¨£º
ÖØд´½¨´ËÎļþ£¬ÔËÐжԻ°¿òÖÐÊäÈë:mmc
1) ¿ØÖÆ̨-->Ìí¼Ó/ɾ³ý¹ÜÀíµ¥Ôª-->Ìí¼ ......

»ñÈ¡SQL ServerµÄһЩϵͳÐÅÏ¢

 --@@CPU_BUSY»ñÈ¡cpu¹¤×÷ʱ¼ä
select @@CPU_BUSY AS 'CPU ms',GETDATE() AS 'TIMES'
--»ñÈ¡´ÅÅ̶Áд´ÎÊý
SELECT @@TOTAL_READ AS 'Reads',@@TOTAL_WRITE AS 'Writes', GETDATE() AS 'As of'
--»ñÈ¡SQl·þÎñÆ÷Ãû
SELECT HOST_NAME()
--»ñµÃÊý¾Ý¿â±íʾºÅ
USE master
SELECT name,DB_ID(name) AS DB_ID from sysd ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ