Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 year" from emp;
--Èç¹ûûÓÐÄÚÈÝ£¬ÔòΪ¿Õ
select comm from


Ïà¹ØÎĵµ£º

SQL SERVER ÓëACCESS¡¢EXCELµÄÊý¾Ýת»»

ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØÊµÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£ ......

ʹÓÃSQLServerÄ£°åÀ´Ð´¹æ·¶µÄSQLÓï¾ä

Èç¹ûÄã¾­³£Óöµ½ÏÂÃæµÄÎÊÌ⣬Äã¾ÍÒª¿¼ÂÇʹÓÃSQL ServerµÄÄ£°åÀ´Ð´¹æ·¶µÄSQLÓï¾äÁË£º
SQL³õѧÕß¡£
¾­³£Íü¼Ç³£ÓõÄDML»òÊÇDDL SQL Óï¾ä¡£
ÔÚ¶àÈË¿ª·¢Î¬»¤µÄSQLÖУ¬Ã¿¸öÈ˶¼ÓÐ×Ô¼ºµÄSQLϰ¹ß£¬Ã»ÓÐÒ»Ì×ͳһµÄ¹æ·¶¡£
ÔÚSQL Server Management StudioÖУ¬ÒѾ­¸ø´ó¼ÒÌṩÁ˺ܶೣÓõÄÏÖ³ÉSQL¹æ·¶Ä£°å¡£
SQL Server Management ......

oracle sqlÓÅ»¯Ö®¶à±íÁ¬½ÓÓÅ»¯


Use equality first.
ʹÓõÈÁ¬½Ó
Use range operators only where equality does not apply.
Ö»ÓÐÔÚµÈÁ¬½Ó²»¿ÉÓõÄÇé¿öÏÂÊÂÓÉÇø¼äÁ¬½Ó
Avoid use of negatives in the form of !=
or NOT.
±ÜÃâʹÓà £¡= »òÕß not
Avoid LIKE pattern matching.
±ÜÃâʹÓà LIKEÆ¥Åä
Try to retrieve specific rows and in small n ......

Sql serverÖÐ DateAdd¡¢DateDiffÓ÷¨

 Õâ¸öº¯ÊýDateAdd(month,2,WriteTime)£º
ÈÕÆÚ²¿·ÖËõд Year yy, yyyy quarter qq, q Month mm, m dayofyear dy, y Day dd, d Week wk, ww Hour hh minute mi, n second ss, s millisecond ms
¡¡¡¡Õâ¸ö±í×㹻˵Ã÷ÎÊÌâÁ˰É,´Óyearµ½millisecond¶¼¿ÉÒÔ´¦Àí£¬¹»·½±ãÁ˰É.
DATEDIFF º¯Êý [ÈÕÆÚºÍʱ¼ä]
-------------- ......

SQL·ÖÒ³²éѯ

/*µÚ¼¸Ò³±ØÐë´óÓÚ1
select top ÿҳÊýÁ¿ * id
 from @t a
 where id not in
 (select top (µÚ¼¸Ò³-1)*ÿҳÊýÁ¿ id
  from @t b
 )
*/
declare @lcSqlCommand nvarchar(100)
declare @t table (id int IDENTITY,orderDate datetime)
insert into @t
 select orderDate
&nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ