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

SQL¾ä·¨µÄÓ¦ÓÃ

ÔÚÕâÒ»Ò³ÖУ¬ÎÒÃÇÁгöËùÓÐÔÚÕâ¸öÍøÕ¾ÓÐÁгö SQL Ö¸ÁîµÄÓï·¨¡£ÈôÒª¸üÏ꾡µÄ˵Ã÷£¬ÇëµãÑ¡Ö¸ÁîÃû³Æ¡£
ÕâÒ»Ò³µÄÄ¿µÄÊÇÌṩһ¸ö¼ò½àµÄ SQL Óï·¨×öΪ¶ÁÕ߲ο¼Ö®Óá£ÎÒÃǽ¨ÒéÄúÏÖÔھͰ´ Control-D ½«±¾Ò³¼ÓÈëÄúµÄ¡ºÎÒµÄ×î°®¡»¡£
Select
SELECT "À¸Î»" from "±í¸ñÃû"
Distinct
SELECT DISTINCT "À¸Î»"
from "±í¸ñÃû"
Where
SELECT "À¸Î»"
from "±í¸ñÃû"
WHERE "condition"
And/Or
SELECT "À¸Î»"
from "±í¸ñÃû"
WHERE "¼òµ¥Ìõ¼þ"
{[AND|OR] "¼òµ¥Ìõ¼þ"}+
In
SELECT "À¸Î»"
from "±í¸ñÃû"
WHERE "À¸Î»" IN ('Öµ1', 'Öµ2', ...)
Between
SELECT "À¸Î»"
from "±í¸ñÃû"
WHERE "À¸Î»" BETWEEN 'Öµ1' AND 'Öµ2'
Like
SELECT "À¸Î»"
from "±í¸ñÃû"
WHERE "À¸Î»" LIKE {ģʽ}
Order By
SELECT "À¸Î»"
from "±í¸ñÃû"
[WHERE "Ìõ¼þ"]
ORDER BY "À¸Î»" [ASC, DESC]
Count
SELECT COUNT("À¸Î»")
from "±í¸ñÃû"
Group By
SELECT "À¸Î»1", SUM("À¸Î»2")
from "±í¸ñÃû"
GROUP BY "À¸Î»1"
Having
SELECT "À¸Î»1", SUM("À¸Î»2")
from "±í¸ñÃû"
GROUP BY "À¸Î»1"
HAVING (À¸Î»)
Create Table
CREATE TABLE "±í¸ñÃû"
("À¸Î» 1" "À¸Î» 1 ×ÊÁÏÖÖÀà",
"À¸Î» 2" "À¸Î» 2 ×ÊÁÏÖÖÀà",
... )
Drop Table
DROP TABLE "±í¸ñÃû"
Truncate Table
TRUNCATE TABLE "±í¸ñÃû"
Insert Into
INSERT INTO "±í¸ñÃû" ("À¸Î»1", "À¸Î»2", ...)
VALUES ("Öµ1", "Öµ2", ...)
Update
UPDATE "±í¸ñÃû"
SET "À¸Î»1" = [ÐÂÖµ]
WHERE {Ìõ¼þ}
Delete from
DELETE from "±í¸ñÃû"
WHERE {Ìõ¼þ}


Ïà¹ØÎĵµ£º

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

SQL ÍⲿÁ¬½ÓµÄÓ÷¨

֮ǰÎÒÃÇ¿´µ½µÄ×óÁ¬½Ó (left join)£¬ÓÖ³ÆÄÚ²¿Á¬½Ó (inner join)¡£ÔÚÕâ¸öÇé¿öÏ£¬ÒªÁ½¸ö±í¸ñÄÚ¶¼ÓÐͬÑùµÄÖµ£¬ÄÇÒ»±Ê×ÊÁϲŻᱻѡ³ö¡£ÄÇÈç¹ûÎÒÃÇÏëÒªÁгöÒ»¸ö±í¸ñÖÐÿһ±ÊµÄ×ÊÁÏ£¬ÎÞÂÛËüµÄÖµÔÚÁíÒ»¸ö±í¸ñÖÐÓÐûÓгöÏÖ£¬ÄǸÃÔõô°ìÄØ£¿ÔÚÕâ¸öʱºò£¬ÎÒÃǾÍÐèÒªÓõ½ SQL OUTER JOIN (ÍⲿÁ¬½Ó) µÄÖ¸Áî¡£
ÍⲿÁ¬½ÓµÄÓï·¨ÊÇÒÀÊý¾ ......

SQL SUBSTRINGµÄÓ÷¨

SQL ÖÐµÄ substring º¯ÊýÊÇÓÃÀ´×¥³öÒ»¸öÀ¸Î»×ÊÁÏÖеÄÆäÖÐÒ»²¿·Ö¡£Õâ¸öº¯ÊýµÄÃû³ÆÔÚ²»Í¬µÄ×ÊÁÏ¿âÖв»ÍêÈ«Ò»Ñù£º
MySQL: SUBSTR(), SUBSTRING()
Oracle: SUBSTR()
SQL Server: SUBSTRING()
×î³£Óõ½µÄ·½Ê½ÈçÏ (ÔÚÕâÀïÎÒÃÇÓÃSUBSTR()ΪÀý)£º
SUBSTR(str,pos): ÓÉ<str>ÖУ¬Ñ¡³öËùÓдӵÚ<pos>λÖÿªÊ¼µÄ× ......

SQL TRIMµÄÓ÷¨

SQL ÖÐµÄ TRIM º¯ÊýÊÇÓÃÀ´ÒƳýµôÒ»¸ö×Ö´®ÖеÄ×ÖÍ·»ò×Öβ¡£×î³£¼ûµÄÓÃ;ÊÇÒƳý×ÖÊ×»ò×ÖβµÄ¿Õ°×¡£Õâ¸öº¯ÊýÔÚ²»Í¬µÄ×ÊÁÏ¿âÖÐÓв»Í¬µÄÃû³Æ£º
MySQL: TRIM(), RTRIM(), LTRIM()
Oracle: RTRIM(), LTRIM()
SQL Server: RTRIM(), LTRIM()
¸÷ÖÖ trim º¯ÊýµÄÓï·¨ÈçÏ£º
TRIM([[λÖÃ] [ÒªÒƳýµÄ×Ö´®] from ] ×Ö´®): [λÖÃ] ......

SQL Ö÷¼üµÄÓ÷¨

Ö÷¼ü (Primary Key) ÖеÄÿһ±Ê×ÊÁ϶¼ÊDZí¸ñÖеÄΨһֵ¡£»»ÑÔÖ®£¬ËüÊÇÓÃÀ´¶ÀÒ»ÎÞ¶þµØÈ·ÈÏÒ»¸ö±í¸ñÖеÄÿһÐÐ×ÊÁÏ¡£Ö÷¼ü¿ÉÒÔÊÇÔ­±¾×ÊÁÏÄÚµÄÒ»¸öÀ¸Î»£¬»òÊÇÒ»¸öÈËÔìÀ¸Î» (ÓëÔ­±¾×ÊÁÏûÓйØϵµÄÀ¸Î»)¡£Ö÷¼ü¿ÉÒÔ°üº¬Ò»»ò¶à¸öÀ¸Î»¡£µ±Ö÷¼ü°üº¬¶à¸öÀ¸Î»Ê±£¬³ÆΪ×éºÏ¼ü (Composite Key)¡£
Ö÷¼ü¿ÉÒÔÔÚ½¨ÖÃбí¸ñʱÉ趨 (ÔËÓà CREA ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ