Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

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 ......

Oracle SQL Óï¾ä¶Ôʱ¼ä²Ù×÷µÄ×ܽá

ÔÚSQLÓï¾äÖУ¬³£³£Óûá¶Ôʱ¼ä£¨»òÈÕÆÚ£©½øÐÐһЩ´¦Àí£¬ÏÂÃæÊDZȽÏͨÓõÄһЩÓï¾ä£º
ÑÓ³Ù£º
sysdate+(5/24/60/60)          ÔÚϵͳʱ¼ä»ù´¡ÉÏÑÓ³Ù5Ãë
sysdate+5/24/60               ÔÚϵͳʱ¼ä»ù´ ......

Ö´ÐÐSQLÎÄ£¬Éú³ÉEXCEL

''' <summary>
''' SQLÎÄ執ÐÐ結¹û¤ÎEXCEL³öÁ¦
''' </summary>
''' <param name="connString">OLEDB½Ó続ÎÄ×ÖÁÐ</param>
''' <param name="sqlString">SQLÎÄ</param>
''' <param name="savePath">³öÁ¦¥Õ¥¡¥¤¥ë¥Ñ¥¹</param> ......

sqlË÷ÒýÀàÐÍ

Ë÷ÒýÀàÐÍ
ΨһË÷Òý£ºÎ¨Ò»Ë÷Òý²»ÔÊÐíÁ½ÐоßÓÐÏàͬµÄË÷ÒýÖµ
Ö÷¼üË÷Òý£ºÎª±í¶¨ÒåÒ»¸öÖ÷¼ü½«×Ô¶¯´´½¨Ö÷¼üË÷Òý£¬Ö÷¼üË÷ÒýÊÇΨһË÷ÒýµÄÌØÊâÀàÐÍ¡£Ö÷¼üË÷ÒýÒªÇóÖ÷¼üÖеÄÿ¸öÖµÊÇΨһµÄ£¬²¢ÇÒ²»ÄÜΪ¿Õ
¾Û¼¯Ë÷Òý(Clustered)£º±íÖи÷ÐеÄÎïÀí˳ÐòÓë¼üÖµµÄÂß¼­£¨Ë÷Òý£©Ë³ÐòÏàͬ£¬Ã¿¸ö±íÖ»ÄÜÓÐÒ»¸ö
·Ç¾Û¼¯Ë÷Òý(Non-clustered)£º·Ç¾Û ......

SQL select

--desc ±íÃû ÃèÊö±íµÄÄÚÈÝ  
desc emp;
--¼ÓÉÏÊýѧ±í´ïʽºÍÁÐÃû  ""±£³Ö¸ñʽ
select ename "name space", sal*12 year_sal from emp;   
select 2*3 from dual;
select sysdate from dual;
--¿ÕÖµµÄÊýѧ±í´ïʽ ½á¹û¶¼ÊÇ¿ÕÖµ
select ename, sal*12 + comm from emp;  
- ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ