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

sqlÌâÖеÄÖÖÖÖ

ÔÚ×ösqlÌâʱ£¬ÎÒÃÇ×îÅÂÓöµ½Ìõ¼þ¸´ÔӵIJéѯÓï¾ä£¬ÒòΪ´ó¶àʱºòÐèÒªÁ½Èý¸ö×Ó²éѯÀ´ÊµÏÖ£¬
¶ø´ó¶àÊýͬѧ£¬¿ÉÒÔ˵¶¼±È½ÏÅÂ×Ó²éѯµÄ£¬ÒÔÇ°ÎÒÒ²±»ÕâЩÌâĿŪµÄÔÆÀïÎíÀïµÄ£¬
²»¹ý×ö¶àÁËÕâÀàµÄÌâÄ¿ºó·¢ÏÖ£¬ÆäʵҲÓÐÒ»¶¨¹æÂÉ£¬ÎÒÃÇ¿ÉÒÔ×ܽáÒ»Ì×ÊʺÏ×Ô¼ºµÄ·½·¨À´´¦Àí£¬
ÏÂÃæʱÎÒ¶Ô¸ÃÀàÌâÄ¿µÄ´¦Àí·½·¨£º
ÓйºÎï±íÈçÏ£º
ÌâÄ¿£º ²éѯ¹ºÎïÉÌÆ·ÀàÐͲ»Ö»Ò»ÖֵĹºÎïÕßµÄÐÅÏ¢¡£
 
ÎÒ½«ÌâÄ¿²ð·ÖÈçÏ£º
Ôò¿ÉµÃ³öÁ½Ìõ²éѯÓï¾ä£º
<1>select * from ¹ºÎïÐÅÏ¢±í where ¹ºÎïÕß in……
<2>select ¹ºÎïÕß from ¹ºÎïÐÅÏ¢±í group by ¹ºÎïÕß having count(*)>=2
 
½«Óï¾ä<2>¼Óµ½Óï¾ä<1>ºó¼´¿ÉµÃ³öÒ»ÖÖÕýÈ·´ð°¸¡£
 
½«Óï¾ä´ÓÍâÏòÀïÆÊÎö£¬Äóö¼òµ¥µÄ²éѯÓï¾ä£¬È»ºóÔÙ×éºÏ¡£
µ±È»ÎÒÕâÀïµÄÌâÄ¿£¬ÊÇÎÒÁÙʱÏëµÄ¿ÉÄÜ»¹±È½Ï¼òµ¥£¬ÎÒÓмû¹ýÕâÑùµÄÓï¾ä
²éѯ……µÄ……µÄ……µÄ……µÄ……¡£¿ÉÒÔ˵¿ÉÄÜÓÐÁ½Èý¸ö»ò¸ü¶àµÄ×Ó²éѯ£¬ÄǾÍÐèÒªÓÐÒ»¸öºÃµÄ·½·¨ÁË¡£


Ïà¹ØÎĵµ£º

pl/sqlÀûÓÃrownumÈ¡µÃÅÅÐòºóµÄ²¿·ÖÐÐÐòÁÐ

ÎÒÃÇʹÓÃoracleµÄÈ˶¼ÖªµÀ¿ÉÒÔͨ¹ýrownumαÁеõ½²éѯ½á¹ûÐòÁÐÇ°ÃæµÄÖ¸¶¨µÄÐУ¬ÎªÁËÏÂÃæ¸üºÃµÄ½øÐÐ˵Ã÷ÎÊÌ⣬ÎÒÃÇÏÈÀ´´´½¨Ò»¸öÊý¾Ý±ítable1£º
create table table1
(AAA integer primary key,
BBB varchar(30));
È»ºóÔÚtable1ÖвåÈë9ÌõÊý¾Ý£º
insert into table1 values (8, 'good');
insert into table1 values (7 ......

Oracle:pl/sql Òì³£´¦Àí[ת]


pl/sql ÌṩÁËÇ¿´ó¶øÁé»îµÄÊÖ¶ÎÀ´²¶×½ºÍ´¦Àí³ÌÐò²úÉúµÄÒì³££¬´Ó¶øʹ oracle µÄÓû§Ô¶ÀëһЩÁîÈË·³ÄÕµÄ bug ¡£
 
pl/sql Òì³£´¦ÀíµÄ¸ÅÄîºÍÊõÓï
 
ÔÚ oracle ÖÐËùÓеĴíÎ󶼱»ÈÏΪÊDz»Ó¦¸Ã·¢ÉúµÄÒì³£¡£Ò»¸öÒì³£¿ÉÄÜÊÇÒÔÏ 3 ÖÖÇé¿öµÄÒ»ÖÖ£º
u       ÓÉϵͳ²úÉúµÄ´íÎó£¨& ......

sql È¡·´

 update anketo1 set fb = substring('10',fb+1,1) WHERE id =5
ºóÀ´ÎÊÁËBM,BM˵ֱ½ÓÈ¡·´
update anketo1 set fb = ~ fb WHERE id =5
ÎÒ¸æËßÁËBMÓÃsubstringÒ²¿ÉÒÔ.
BM˵:"Õâ¼Ò»ïÀ÷º¦£¬ÕâÒ²ÄÜÏë³ö,ÕâÊôÓÚаÃÅÎ书."
×îºóÓÖÏëµ½ÓÃABSÈ¡¾ø¶ÔÖµÒ²¿ÉÒÔ
update anketo1 set fb = abs(fb-1)
ÎÒ¾õµÃ²»¹ÜÊÇʲôÎ书,ÄÜÖ ......

Ö´ÐÐSQLÈ¡PostgreSQLÊý¾Ý¿â»ò±í´óС

ÔÚPostgreSQL8.1.3ÉÏ¿ÉÒÔwork
1. È¡Êý¾Ý¿â´óС
SELECT pg_size_pretty(pg_database_size('somedatabase')) As fulldbsize
2. È¡±í´óС
SELECT pg_size_pretty(pg_total_relation_size('someschema.sometable')) As fulltblsize, pg_size_pretty(pg_relation_size('someschema.sometable')) As justthetblsize
Ô­Ìù£º
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ