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

SQL SERVER 2008 ±Ê¼ÇÖ®ÐÐѹËõºÍҳѹËõ

 
/*
    2008 ѹËõ
 
 
    ÐÐѹËõ
   
    SQL SERVER 2008 Òý½øÁËÐÐѹËõÕâ¸öÐÂÌØÐÔ,Ö»ÓÐÆóÒµ°æ¾ßÓиÃÐÂÌØÐÔ.ÐÐѹËõÖ»ÐèÒª×îµÍµÄ¿Õ¼ä¶ÔÐÐÊý¾Ý½øÐÐѹËõ.ÐÐѹËõ¿ÉÒÔÔÚCREATEÒ»¸ö±í,Ë÷Òý»òÕßALTERÒ»¸ö±í,Ë÷ÒýµÄʱºò½øÐд´½¨.ѹËõ¿ÉÒÔÔÚÐ춱ð,Ò²¿ÉÒÔÔÚÒ³¼¶±ð.ͬÑù±¸·ÝµÄʱºòÒ²¿ÉÒÔ½øÐÐѹËõ.ÒÔÏÂÏȾÙÀý˵Ã÷ÈçºÎ´´½¨Ò»¸ö±íÐÐѹËõºÍALTER±íµÄʱºòÌí¼ÓÐÐѹËõ.
 
    ½¨Á¢²âÊÔÊý¾Ý
*/
 
    CREATE DATABASE COMPRESSION_TEST
    GO
 
 
    USE COMPRESSION_TEST
    GO
 
/*  ½¨Á¢Ò»¸ö¾ßÓÐÐÐѹËõµÄ±í*/
 
 
    CREATE TABLE Compression_tb1
    (id int not null identity(1,1),
     departid int not null,
     JOBdesc CHAR(2000) not null --ΪÁËЧ¹ûÃ÷ÏÔÒ»µã,¿ÉÒÔÉèÖó¤µã
     )
     with( DATA_COMPRESSION=ROW)  --½¨Á¢µ½ÓÐÐÐѹËõÑ¡ÏîµÄ±í
 
/*  ¿ÉÒÔÓÃÈçÏÂÓï¾ä´ÓÐÂÅäÖÃѹËõÑ¡Ïî*/
 
    ALTER TABLE Compression_tb1 REBUILD
    WITH (DATA_COMPRESSION=NONE) --È¥³ýѹËõÑ¡Ïî
 
/*
    ÒÔÉϸöÓï¾ä¿ÉÒԵߵ¹¹ýÀ´Æ©ÈçÏȽ¨Á¢Ã»ÓÐѹËõÑ¡ÏîµÄ±í,È»ºóͨ¹ýALTER±íÅäÖûñµÃѹËõÑ¡Ïî
    ÆäÖÐDATA_COMPRESSIONÓиö²ÎÊýNONE,ROW,PAGE
 
    ÏÂÃæ¶Ô²âÊÔ±íÌî³äÀ¬»øÊý¾ÝÀ´ÑÝʾѹËõµÄЧ¹û
*/
    INSERT Compression_tb1(departid ,JOBdesc)
    VALUES(CAST(RAND()*20 as int)
    , REPLICATE('a',50))
    GO 100000
 
/*
    Êý¾ÝÌí¼ÓºÃ,ÎÒ¿ÉÒÔÓÃϵͳSP sp_estimate_data_compression_savings À´¹À¼ÆʹÓÃÐÐѹËõ»òÕßҳѹËõ¿ÉÒÔ½ÚÊ¡¶àÉÙ´ÅÅÌ¿Õ¼ä.sp_estimate_data_compression_savingsÓиö²ÎÊý:ÐèҪѹËõµÄ±íµÄ¼Ü¹¹Ãû³Æ¡¢   ¶ÔÏóÃû³Æ¡¢Ë÷ÒýID¡¢·ÖÇøºÅºÍѹËõ·½Ê½¡£ÈçϵÄʾÀýÏȼì²éÐÐѹËõ¿ÉÒÔ½ÚÊ¡¶àÉٿռ䡣
*/
 
    EXEC SYS.sp_estimate_data_c


Ïà¹ØÎĵµ£º

SQL SERVER ͼ±íÊý¾Ý¿â

ͼ±í
ͼ±í(ÓֳƹØϵͼ)ÊÇSQL ServerÖÐÒ»ÀàÌØÊâµÄÊý¾Ý¿â¶ÔÏó£¬ËüÌṩ¸øÓû§Ö±¹ÛµØ¹ÜÀíÊý¾Ý¿â±íµÄ·½·¨¡£Í¨¹ýͼ±í£¬Óû§¿ÉÒÔÖ±¹ÛµØ´´½¨¡¢±à¼­Êý¾Ý¿â±íÖ®¼äµÄ¹Øϵ£¬Ò²¿ÉÒԱ༭±í¼°ÆäÁеÄÊôÐÔ¡£ÀûÓÃÆóÒµ¹ÜÀíÆ÷´´½¨Í¼±íµÄ¾ßÌå²½ÖèÈçÏ£º
(1)ÔÚÆóÒµ¹ÜÀíÆ÷ÖУ¬Õ¹¿ªÖ¸¶¨µÄ·þÎñÆ÷ºÍÊý¾Ý¿â£¬´ò¿ªÒª½¨Á¢µÄͼ±íËùÔÚµÄÊý¾Ý¿â£¬ÓÒ»÷ͼ±íÍ ......

SQL ¶ÔDateTime (ʱ¼äºÍÈÕÆÚ£©Êý¾ÝÀàÐ͵Ļù±¾²Ù×÷

ÈÕÆÚºÍʱ¼äº¯Êý¶Ô½¨Á¢Ò»¸öÕ¾µãÊǷdz£ÓÐÓõġ£Õ¾µãµÄÖ÷ÈËÍùÍù¶ÔÒ»¸ö±íÖеÄÊý¾ÝºÎʱ±»
¸üиÐÐËȤ¡£Í¨¹ýÈÕÆÚºÍʱ¼äº¯Êý£¬Äã¿ÉÒÔÔÚºÁÃ뼶¸ú×ÙÒ»¸ö±íµÄ¸Ä±ä¡£
·µ»Øµ±Ç°ÈÕÆÚºÍʱ¼ä
ͨ¹ýº¯ÊýGETDATE£¨£©£¬Äã¿ÉÒÔ»ñµÃµ±Ç°µÄÈÕÆÚºÍʱ¼ä¡£ÀýÈ磬Óï¾äSELECT GETDATE()
·µ»ØÈçϵĽá¹û£º
…………&h ......

SQLÖÐNµÄ×÷ÓÃ?

SQLÖÐNµÄ×÷ÓÃ?
exec sp_executesql N'SELECT TOP 1 ISNULL(vDefine1,'''') AS vMonth, dtBegin, dtEnd from SM_ActMonth WHERE vActID=@P1 AND bCarryForward=@P2 ORDER BY iListID DESC
', N'@P1 varchar(3),@P2 bit', '001', 1
exec sp_executesql N'SELECT * from KEHU WHERE KHDM>=@P1 AND ZK=@P2',N'@P1 VARCHAR ......

ÓÃSQL´æ´¢¹ý³ÌʵÏÖÅúÁ¿²åÈëÊý¾Ý

ÐÞ¸ÄÄÚÈÝ£ºÉ¾³ýÔ­À´µÄTIMEά¶È£¬Ð½¨TIMEά¶È£¬ÐÞ¸ÄSALESÁ¢·½¡£
Êý¾Ý²åÈ룺
            1£¬ÊÂʵÊý¾Ý²åÈ룺ͨ¹ýDTS¼Óµ÷¶ÈʵÏÖ½«sales_fact_1997µÄÊý¾Ý½øÐи´ÖÆ¡£ÆµÂÊΪÿ·ÖÖÓ10000Ìõ¡£            &nb ......

×ÔÔö×ֶεÄSQLÓï¾ä½â¾ö·½°¸

create table [±íÃû]
(
[×Ô¶¯±àºÅ×Ö¶Î] int IDENTITY (1,1) PRIMARY KEY ,
[×Ö¶Î1] nVarChar(50) default 'ĬÈÏÖµ' null ,
[×Ö¶Î2] ntext null ,
[×Ö¶Î3] datetime,
[×Ö¶Î4] money null ,
[×Ö¶Î5] int default 0,
[×Ö¶Î6] Decimal (12,4) default 0,
[×Ö¶Î7] image null ,
)
ɾ³ý±í£º
Drop table [ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ