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

SQL Ëæ»ú³éÑùµÄ×ܽá

¶ÔÓÚSQL Ëæ»ú³éÑùÎÒÃdz£Ïëµ½µÄ¾ÍÊÇnewid()£¬µ«Èç¹û¶ÔÓÚÒ»¸öÔÚ°ÙÍò¡¢Ç§ÍòÉõÖÁ¸ü´óº£Á¿Êý¾Ý±íÖгéÑùµÄ»°£¬¼òµ¥µÄnewid()£¬ÆäÐÔÄÜ£¬Ð§ÂʾͲ»ÊǺÜÀíÏëÁË¡£ËùÒÔÔÚÕâÀïÓбØÒªÌÖÂÛһϣ¬ÔñÓŶøÓá£
 
long_goodsÊÇÒ»¸ö°ÙÍòÊý¾ÝµÄ±í£¬Ctrl+LÖ´ÐÐÒÔÏÂÓï¾ä:
 
--id_indexÊÇÎÒΪÖ÷¼ü¼ÓµÄÒ»¸ö·Ç¾Û½¹Ë÷Òý
SELECT top 1  * from long_goods order by newid()
--²éѯ¿ªÏú 43%
SELECT top 1  * from long_goods with(index=id_index) order by newid()
--²éѯ¿ªÏú 54%
select top 1 * from long_goods where id=(select top 1 id from long_goods order by newid())
--²éѯ¿ªÏú 1%
select top 1 * from long_goods where id=(select top 1 id from long_goods with(index=id_index) order by newid())
--²éѯ¿ªÏú 1%
 
ËäÈ»µÚÈý¸öÓëµÚËĸöµÄ¿ªÏúÊÇÒ»Ñù£¬µ«Êµ¼ÊÓ¦¸ÃÊǵÚËÄÖÖÓÅÓÚµÚÈýÖÖ¡£
 
Èç¹ûMS SQL2005Éý¼¶µ½Ö§³Ö TABLESAMPLE µÄ»°£¬ÒÔÏÂÓï¾äµÄ³éÑùÖ´ÐÐЧÂÊ¿ÉΪ×îÓŵÄ
SELECT * from long_goods TABLESAMPLE SYSTEM (10 PERCENT)
 
ºÇºÇ..ϰàÁË£¬ÖÁÓÚÆäÖÐÔ­Òò£¬Ï´ÎÓпÕÔÙÐø.


Ïà¹ØÎĵµ£º

ÔÚpl/sql ÖиıäÁ㤶È

 
    
 
NO.1  
alter   table   pdt   modify("PDTNAME",varchar2(100))
NO.2  
×ֶβ»ÓÓ”  
  alter   table   pdt   modify(PDTNAME,varchar2(100)) &n ......

SqlÓï¾äѧϰ±Ê¼Ç(3) ²åÈëÊý¾Ý

ÕâÀïʹÓõÄÊý¾Ý¿âºÍÊý¾Ý±í·Ö±ðÀ´×ÔSqlÓï¾äѧϰ±Ê¼Ç£¨1£©——´´½¨Êý¾Ý¿âºÍSqlÓï¾äѧϰ±Ê¼Ç£¨2£©——´´½¨Êý¾Ý±í
use RetalDB
go
--²åÈëÊý¾Ýµ½±ítb_movie_type
insert tb_movie_type values(0,'ÆÕͨƬ','Regular')
insert tb_movie_type values(1,'ÐÂÆ¬','NewRelease')
insert tb_movie_type values ......

OracleµÄSQLÓï¾äÖÐÈçºÎ´¦Àí¡®&¡¯·ûºÅ

ÔÚOracleÖУ¬Èç¹ûÔÚsqlÖгöÏÖ'&'·ûºÅ£¬»á±»×Ô¶¯×ªÒ壻
¶ø±»ÒªÇóÊäÈëÔÚ&·ûºÅºó¸úËæµÄ×Ö·û´®µÄÖµ£¬ÀýÈ磺
update tablename set columnName='http://www.g.cn/cv2.jsp?spid=222&cid=333';
Ö´ÐÐÕâ¸ö²Ù×÷ʱ£¬Oracle»áÌáʾ
Enter value for cid:
Ô­ÒòÊÇÔÚOracleÖÐ & ·ûºÅÊÇ×÷ΪתÒå×Ö·ûʹÓõġ£
½â¾ö·½·¨ ......

ÌÖÂÛ ²¢·¢Ö´ÐÐSQLʱµÄ¸üжªÊ§£¬ÈçºÎ½â¾öÕâÖÖÎÊÌâ

    ×î½üÓöµ½Ò»¸öÎÊÌ⣬ÔÚ²Ù×÷SQL¸üÐÂÕË»§Óà¶îʱ£¬³£³£·¢ÏÖ¸üкóµÄÓà¶îÓëʵ¼ÊµÄ²»Ïà·û£¬ÂíÉÏÏëµ½ÁËÊDz»ÊÇ´æÔÚ²¢·¢¸üУ¬Ò»²é¹ûÈ»Èç´Ë¡£Ö®Ç°Ò²ÔøÓöµ½¹ýÕâÑùµÄÎÊÌ⣬µ±Ê±Ã»Ì«ÔÚÒ⣬ÏÖÔÚÊǽâ¾öµÄʱºòÁË¡£ÓÃMysqlÄ£ÄâÁËÒ»ÏÂÕâ¸ö¹ý³Ì£º´´½¨Á½ÕÅ±í£¬paralltableºÍparallalter£¬Ã¿´Î¸ù¾Ýparatable±í¸üÐÂparallalte ......

dz̸SQL½Ì³ÌÖ®Group byºÍHaving

ÔÚ½éÉÜGROUP BY ºÍ HAVING ×Ó¾äǰ£¬ÎÒÃDZØÐèÏȽ²½²sqlÓïÑÔÖÐÒ»ÖÖÌØÊâµÄº¯Êý£º¾ÛºÏº¯Êý£¬ÀýÈçSUM, COUNT, MAX, AVGµÈ¡£ÕâЩº¯ÊýºÍÆäËüº¯ÊýµÄ¸ù±¾Çø±ð¾ÍÊÇËüÃÇÒ»°ã×÷ÓÃÔÚ¶àÌõ¼Ç¼ÉÏ¡£
      SELECT SUM(population) from bbc
¡¡¡¡ÕâÀïµÄSUM×÷ÓÃÔÚËùÓзµ»Ø¼Ç¼µÄpopulation×Ö¶ÎÉÏ£¬½á¹û¾ÍÊǸòéÑ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ