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

SQLµÄÓÅ»¯

´ó¼Ò¶¼ÔÚÌÖÂÛ¹ØÓÚÊý¾Ý¿âÓÅ»¯·½ÃæµÄ¶«¶«£¬¸ÕºÃ²ÎÓ뿪·¢ÁËÒ»¸öÊý¾Ý²Ö¿â·½ÃæµÄÏîÄ¿£¬ÒÔϵÄÒ»µã¶«Î÷ËãÊÇÊý¾Ý¿âÓÅ»¯·½ÃæµÄѧϰ+ʵսµÄһЩÐĵÃÌå»áÁË£¬ÄóöÀ´´ó¼Ò¹²Ïí¡£»¶Ó­ÅúÆÀÖ¸Õý°¢£¡
SQLÓï¾ä£º
ÊǶÔÊý¾Ý¿â(Êý¾Ý)½øÐвÙ×÷µÄΩһ;¾¶£»
ÏûºÄÁË70%~90%µÄÊý¾Ý¿â×ÊÔ´£»¶ÀÁ¢ÓÚ³ÌÐòÉè¼ÆÂß¼­£¬Ïà¶ÔÓÚ¶Ô³ÌÐòÔ´´úÂëµÄÓÅ»¯£¬¶ÔSQLÓï¾äµÄÓÅ»¯ÔÚʱ¼ä³É±¾ºÍ·çÏÕÉϵĴú¼Û¶¼ºÜµÍ£»
¿ÉÒÔÓв»Í¬µÄд·¨£»Ò×ѧ£¬ÄѾ«Í¨¡£
SQLÓÅ»¯£º
¹Ì¶¨µÄSQLÊéдϰ¹ß£¬ÏàͬµÄ²éѯ¾¡Á¿±£³ÖÏàͬ£¬´æ´¢¹ý³ÌµÄЧÂʽϸߡ£
Ó¦¸Ã±àдÓëÆä¸ñʽһÖµÄÓï¾ä£¬°üÀ¨×ÖĸµÄ´óСд¡¢±êµã·ûºÅ¡¢»»ÐеÄλÖõȶ¼ÒªÒ»ÖÂ
ORACLEÓÅ»¯Æ÷£º
ÔÚÈκοÉÄܵÄʱºò¶¼»á¶Ô±í´ïʽ½øÐÐÆÀ¹À£¬²¢ÇÒ°ÑÌض¨µÄÓï·¨½á¹¹×ª»»³ÉµÈ¼ÛµÄ½á¹¹£¬Õâô×öµÄÔ­ÒòÊÇ
Ҫô½á¹û±í´ïʽÄܹ»±ÈÔ´±í´ïʽ¾ßÓиü¿ìµÄËÙ¶È
ҪôԴ±í´ïʽֻÊǽá¹û±í´ïʽµÄÒ»¸öµÈ¼ÛÓïÒå½á¹¹
²»Í¬µÄSQL½á¹¹ÓÐʱ¾ßÓÐͬÑùµÄ²Ù×÷£¨ÀýÈ磺= ANY (subquery) and IN (subquery)£©£¬ORACLE»á°ÑËûÃÇÓ³Éäµ½Ò»¸öµ¥Ò»µÄÓïÒå½á¹¹¡£
1 ³£Á¿ÓÅ»¯£º
³£Á¿µÄ¼ÆËãÊÇÔÚÓï¾ä±»ÓÅ»¯Ê±Ò»´ÎÐÔÍê³É£¬¶ø²»ÊÇÔÚÿ´ÎÖ´ÐÐʱ¡£ÏÂÃæÊǼìË÷ÔÂн´óÓÚ2000µÄµÄ±í´ïʽ£º
sal > 24000/12
sal > 2000
sal*12 > 24000
Èç¹ûSQLÓï¾ä°üÀ¨µÚÒ»ÖÖÇé¿ö£¬ÓÅ»¯Æ÷»á¼òµ¥µØ°ÑËüת±ä³ÉµÚ¶þÖÖ¡£
ÓÅ»¯Æ÷²»»á¼ò»¯¿çÔ½±È½Ï·ûµÄ±í´ïʽ£¬ÀýÈçµÚÈýÌõÓï¾ä£¬¼øÓÚ´Ë£¬Ó¦¾¡Á¿Ð´Óó£Á¿¸ú×ֶαȽϼìË÷µÄ±í´ïʽ£¬¶ø²»Òª½«×Ö¶ÎÖÃÓÚ±í´ïʽµ±ÖС£·ñÔòûÓа취ÓÅ»¯£¬±ÈÈçÈç¹ûsalÉÏÓÐË÷Òý£¬µÚÒ»ºÍµÚ¶þ¾Í¿ÉÒÔʹÓ㬵ÚÈý¾ÍÄÑÒÔʹÓá£
2 ²Ù×÷·ûÓÅ»¯£º
ÓÅ»¯Æ÷°ÑʹÓÃLIKE²Ù×÷·ûºÍÒ»¸öûÓÐͨÅä·ûµÄ±í´ïʽ×é³ÉµÄ¼ìË÷±í´ïʽת»»ÎªÒ»¸ö“=”²Ù×÷·û±í´ïʽ¡£
ÀýÈ磺ÓÅ»¯Æ÷»á°Ñ±í´ïʽename LIKE 'SMITH'ת»»Îªename = 'SMITH'
ÓÅ»¯Æ÷Ö»ÄÜת»»Éæ¼°µ½¿É±ä³¤Êý¾ÝÀàÐ͵ıí´ïʽ£¬Ç°Ò»¸öÀý×ÓÖУ¬Èç¹ûENAME×ֶεÄÀàÐÍÊÇCHAR(10)£¬ ÄÇôÓÅ»¯Æ÷½«²»×öÈκÎת»»¡£
Ò»°ãÀ´½²LIKE±È½ÏÄÑÒÔÓÅ»¯¡£
ÆäÖУº
~~ IN ²Ù×÷·ûÓÅ»¯£º
    ÓÅ»¯Æ÷°ÑʹÓÃIN±È½Ï·ûµÄ¼ìË÷±í´ïʽÌ滻ΪµÈ¼ÛµÄʹÓÓ=”ºÍ“OR”²Ù×÷·ûµÄ¼ìË÷±í´ïʽ¡£
    ÀýÈ磬ÓÅ»¯Æ÷»á°Ñ±í´ïʽename IN ('SMITH','KING','JONES')Ì滻Ϊ
ename = 'SMITH' OR ename = 'KING' OR ename = 'JONES‘
~~ ANYºÍSOME ²Ù×÷·ûÓÅ»¯:
    ÓÅ»¯Æ÷½«¸úËæÖµÁбíµÄANYºÍSOME¼ìË


Ïà¹ØÎĵµ£º

db2 V8µÄÓйØSQL limits

The following tables describe certain SQL
limits. Adhering to the most restrictive case can help the programmer
design application programs that are easily portable.
Table 7. Identifier Length Limits
Description
Limit in Bytes
Longest authorization
name (can only be single-byte characters) ......

SQL¡¢PL/SQLѧϰ±Ê¼Ç


 
1£®SQL²¢Ðвéѯ
alter session enable parallel dml execute immediate 'alter session enable parallel dml'; --Ð޸ĻỰ²¢ÐÐDML      select /*+parallel(a,4)*/ * from table_name a       select /*+parallel(a,8)*/ * from table_name a &nbs ......

ms sql´æ儲過³Ì參數·µ»ØÖµ

create table tabReProc
 (    
 name varchar(30),    
 age integer,    
 primary key(name,age)    
 ) 
 insert into tabReProc values('x7700',20) 
 insert into tabR ......

ÇÉÓÃSQLµÄÈ«¾ÖÁÙʱ±í·ÀÖ¹Óû§Öظ´µÇ¼

ÇÉÓÃSQLµÄÈ«¾ÖÁÙʱ±í·ÀÖ¹Óû§Öظ´µÇ¼
ÎÄÕÂÀ´×Ô£ºhttp://www.cnblogs.com/lindayyh/archive/2010/04/05/1704763.html
ÔÚÎÒÃÇ¿ª·¢ÉÌÎñÈí¼þµÄʱºò£¬³£³£»áÓöµ½ÕâÑùµÄÒ»¸öÎÊÌ⣺ÔõÑù·ÀÖ¹Óû§Öظ´µÇ¼ÎÒÃǵÄϵͳ£¿ÌرðÊǶÔÓÚÒøÐлòÊDzÆÎñ²¿ÃÅ£¬¸üÊÇÒªÏÞÖÆÓû§ÒÔÆ乤ºÅÉí·Ý¶à´ÎµÇÈë¡£
¿ÉÄÜ»áÓÐÈË˵ÔÚÓû§ÐÅÏ¢±íÖмÓÒ»×Ö¶ÎÅÐ ......

SQL Server SQL for xml auto Ìí¼Ó¸ù½Úµã


½ñÌì´ÓÊý¾Ý¿âÖвéѯ³öxml£¬Í¬Ê±Ìí¼ÓÒ»¸ö¸ù½Úµã
×öÁËÈçϲâÊÔ£º
create table TestXmlQuery(
ID int identity(1,1) not null,
Name varchar(10)
)
go
insert into [TestXmlQuery] (Name) values('²âÊÔ1')
insert into [TestXmlQuery] (Name) values('²âÊÔ2')
insert into [TestXmlQuery] (Name) values('²âÊÔ3') ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ