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

sqlÓï¾ä»ù´¡

--------------------------------------------------------
--sql structured query language
--DML--Data Manipulation Language--Êý¾Ý²Ù×÷ÓïÑÔ
query information (SELECT),
add new rows (INSERT),
modify existing rows (UPDATE),
delete existing rows (DELETE),
perform a conditional update or insert operation (MERGE),
see an execution plan of SQL (EXPLAIN PLAN),
and lock a table to restrict access (LOCK TABLE).
--DDL--Data Definition Language--Êý¾Ý¶¨ÒåÓïÑÔ
create, modify,drop, or rename objects (CREATE,ALTER,DROP,RENAME),
remove all rows from a database object without dropping the structure (TRUNCATE),
manage access privileges (GRANT,REVOKE),
audit database use (AUDIT,NOAUDIT)
and add a description about an object to the dictionary (COMMENT).
--Transaction ControlÊÂÎñ¿ØÖÆÓï¾ä
save the changes(COMMIT)
or discard the changes (ROLLBACK) made by DML statements.
Also included in the transaction-control statements are statements to set a point or marker in the transaction for possible rollback (SAVEPOINT)
and to define the properties for the transaction (SET TRANSACTION).
Used to manage the properties of the database.
There isonly one statement in this category (ALTER SYSTEM).
--DCL--Data Control Language--Ó뿪·¢¹ØÏµ²»ÊǺÜÃÜÇÐ,ÓÃÓÚȨÏ޵ķÖÅäÓë»ØÊÕ
grant,revoke,data control
--Session Control
control the session properties (ALTER SESSION)
and to enable/disable roles (SET ROLE).
--System Control
--------------------------------------------------------
selectµÄÓ÷¨
--ÿ¸öÔ±¹¤µÄËùÓÐÐÅÏ¢
select * from emp
--ÿ¸öÈ˵IJ¿ÃűàºÅ£¬ÐÕÃû£¬Ð½Ë®
select deptno,ename,sal from emp;
--ÿ¸öÈ˵ÄÄêн
select ename,sal*12 from emp;
--¼ÆËã2*3µÄÖµ
select 2*3 from emp;
--¼ÆËã2*3µÄÖµ(dual)
select 2*3 from dual;
select * from dual;
--µÃµ½µ±Ç°Ê±¼ä
select sysdate from dual
--¿ÉÒÔ¸øÁÐÆð±ðÃû,±ÈÈçÇóÿ¸öÈ˵ÄÄêн
select ename,sal*12  salperyear from emp;
--Èç¹û±ðÃûÖÐÓпոñ£¬ÐèÒªÓÃË«ÒýºÅ
select ename,sal*12  "sal per y


Ïà¹ØÎĵµ£º

SQLSERVER SQLÐÔÄÜÓÅ»¯

1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á ......

sql join on Ó÷¨

A left join B µÄÁ¬½ÓµÄ¼Ç¼ÊýÓëA±íµÄ¼Ç¼Êýͬ
A right join B µÄÁ¬½ÓµÄ¼Ç¼ÊýÓëB±íµÄ¼Ç¼Êýͬ
A left join B µÈ¼ÛB right join A
table A:Field_K, Field_A1     a3     b4     ctable B:Field_K, Field_B1     x2  &nbs ......

ʵÑéÎå SQL²éѯ£¨ÅÅÐò¡¢¼¯º¯ÊýºÍ·Ö×é×Ó¾äµÄÓ¦Óã©

ÊÔÑéÄ¿µÄ:
Ò»¡¢Ñ§Ï°²éѯ½á¹ûµÄÅÅÐò
¶þ¡¢Ñ§Ï°Ê¹Óü¯º¯ÊýµÄ·½·¨£¬Íê³Éͳ¼Æ
µÈ²éѯ¡£
Èý¡¢Ñ§Ï°Ê¹Ó÷Ö×é×Ó¾ä
Ò»¡¢Ñ§Ï°²éѯ½á¹ûµÄÅÅÐò
1¡¢²éѯȫÌåѧÉúÐÅÏ¢£¬½á¹û°´ÕÕÄêÁä½µ
ÐòÅÅÐò
select *
from student
order by sage desc
2¡¢²éѯѧÉúÑ¡ÐÞÇé¿ö£¬½á¹ûÏȰ´ÕտγÌ
ºÅÉýÐòÅÅÐò£¬ÔÙ°´³É¼¨½µÐòÅÅÐò
select *
from ......

Sql ServerʵÓòÙ×÷С¼¼ÇÉ×ܽá(ת)

°üÀ¨°²×°Ê±ÌáʾÓÐ¹ÒÆðµÄ²Ù×÷¡¢ÊÕËõÊý¾Ý¿â¡¢Ñ¹ËõÊý¾Ý¿â¡¢×ªÒÆÊý¾Ý¿â¸øÐÂÓû§ÒÔÒÑ´æÔÚÓû§È¨ÏÞ¡¢¼ì²é±¸·Ý¼¯¡¢ÐÞ¸´Êý¾Ý¿âµÈ¡£
¡¡¡¡(Ò»)¹ÒÆð²Ù×÷
¡¡¡¡ÔÚ°²×°Sql»òsp²¹¶¡µÄʱºòϵͳÌáʾ֮ǰÓÐ¹ÒÆðµÄ°²×°²Ù×÷£¬ÒªÇóÖØÆô£¬ÕâÀïÍùÍùÖØÆôÎÞÓ㬽â¾ö°ì·¨£º
¡¡¡¡µ½HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Man ......

SQL Server Ë÷Òý»ù´¡ÖªÊ¶(2)

£¨http://www.builder.com.cn/2008/0211/733054.shtml£© »ù´¡ÖªÊ¶£¨4£©
²»ÂÛÊÇ ¾Û¼¯Ë÷Òý£¬»¹ÊǷǾۼ¯Ë÷Òý£¬¶¼ÊÇÓÃB+Ê÷À´ÊµÏֵġ£ÎÒÃÇÔÚÁ˽âÕâÁ½ÖÖË÷Òý֮ǰ£¬ÐèÒªÏÈÁ˽âB+ͨ¹ý×ܽᣬÎÒ·¢ÏÖ×Ô¼ºÒÔǰºÜ¶àºÜÄ£ºýµÄ¸ÅÄî¶¼ÇåÎúÁ˺ܶࡣ
²»ÂÛÊÇ ¾Û¼¯Ë÷Òý£¬»¹ÊǷǾۼ¯Ë÷Òý£¬¶¼ÊÇÓÃB+Ê÷À´ÊµÏֵġ£ÎÒÃÇÔÚÁ˽âÕâÁ½ÖÖË÷Òý֮ǰ£¬ÐèÒªÏÈ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ