SQL Server 2005ÖеķÖÇø±í£¨Î壩£ºÌí¼ÓÒ»¸ö·ÖÇø
ËùνÌìÏ´óÊ£¬·Ö¾Ã±ØºÏ£¬ºÏ¾Ã±Ø·Ö£¬¶ÔÓÚ·ÖÇø±í¶øÑÔÒ²Ò»Ñù¡£Ç°ÃæÎÒÃǽéÉܹýÈçºÎɾ³ý£¨ºÏ²¢£©·ÖÇø±íÖеÄÒ»¸ö·ÖÇø£¬ÏÂÃæÎÒÃǽéÉÜÒ»ÏÂÈçºÎΪ·ÖÇø±íÌí¼ÓÒ»¸ö·ÖÇø¡£
Ϊ·ÖÇø±íÌí¼ÓÒ»¸ö·ÖÇø£¬ÕâÖÖÇé¿öÊÇʱ³£»á
·¢ÉúµÄ¡£±ÈÈ磬×î³õÔÚÊý¾Ý¿âÉè¼Æʱ£¬Ö»Ô¤¼ÆÁË´æ·Å3ÄêµÄÊý¾Ý£¬¿ÉÊǵ½Á˵Ú4ÌìÔõô°ì£¿ÕâÑùµÄ»°£¬ÎÒÃǾͿÉÒÔΪ·ÖÇø±íÌí¼ÓÒ»¸ö·ÖÇø£¬ÈÃËü°ÑеÄÊý¾Ý·ÅÔÚеķÖÇøÀï¡£ÔÙ±ÈÈ磬×î³õÉè¼Æʱ£¬Ò»¸ö·ÖÇøÓÃÓÚ´æ·ÅÒ»ÄêµÄÊý¾Ý£¬½á¹ûÔÚʹÓõÄʱºò²Å·¢ÏÖ£¬Ò»ÄêµÄÊý¾ÝÌ«¶à£¬Ï뽫һ¸ö·ÖÇøÖеÄÊý¾Ý·ÖΪÁ½¸ö·ÖÇøÀ´´æ·Å¡£
Óöµ½ÕâÖÖÇé¿ö£¬¾Í±ØÐëҪΪ·ÖÇø±íÌí¼ÓÒ»¸ö·ÖÇøÁË¡£
µ±È»£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃÐ޸ķÖÇøº¯ÊýµÄ·½Ê½À´Ìí¼ÓÒ»¸ö·ÖÇø£¬µ«ÊÇÔÚÐ޸ķÖÇøº¯Êýʱ£¬ÎÒÃDZØÐëҪעÒâÁíÒ»¸öÎÊÌâ——·ÖÇø·½°¸¡£ÎªÊ²Ã´»¹Òª×¢Òâ·ÖÇø·½°¸ÄØ£¿ÎÒÃǻعýÍ·À´¿´Ò»ÏÂÇ°ÃæÊÇÔõô¶¨Òå·ÖÇøº¯ÊýºÍ·ÖÇø·½°¸µÄ£¬ÈçÒÔÏ´úÂëËùʾ£º
--Ìí¼Ó·ÖÇøº¯Êý
CREATE PARTITION FUNCTION partfunSale (datetime)
AS RANGE RIGHT FOR VALUES ('20100101','20110101','20120101','20130101')
--Ìí¼Ó·ÖÇø·½°¸
CREATE PARTITION SCHEME partschSale
AS PARTITION partfunSale
TO ( Sale2009, Sale2010, Sale2011, Sale2012, Sale2013)
´ÓÒÔÉÏ´úÂëÖпÉÒÔ¿´³ö£¬·ÖÇøº¯Êý¶¨ÒåÁËÓÃÓÚ·ÖÇøµÄÊý¾Ý±ß½ç£¬¶ø·ÖÇøº¯ÊýÖ¸¶¨ÁË·ûºÏ·ÖÇø±ß½çµÄÊý¾Ý´æ·ÅÔÚÎļþ×é¡£Òò´Ë£¬·ÖÇø·½°¸ÖÐÖ¸¶¨µÄÎļþ×é¸öÊýÓ¦¸ÃÊDZȷÖÇøº¯ÊýÖÐÖ¸¶¨µÄ±ß½çÊý´ó1µÄ¡£ÈçÉÏÀýÖУ¬·ÖÇøº¯ÊýÖÐÖ¸¶¨µÄ±ß½çÊýΪ4£¬ÄÇôÔÚ·ÖÇø·½°¸ÖÐÖ¸¶¨µÄÎļþ×éÊý¾ÍΪ5¡£
Èç¹û£¬ÎÒÃǽ«·ÖÇøº¯ÊýÖеı߽çÊýÔö¼ÓÒ»¸ö£¬ÄÇô·ÖÇø·½°¸ÖеÄÎļþ×éÊýÒ²¾ÍÒªÏàÓ¦µØÔö¼ÓÒ»¸ö¡£Òò´Ë£¬ÎÒÃDz»Äܼò¼òµ¥µ¥µØͨ¹ýÐ޸ķÖÇøº¯ÊýµÄ·½Ê½À´Îª·ÖÇø±íÌí¼ÓÒ»¸ö·ÖÇø¡£
ÄÇô£¬ÎÒÃÇÓ¦¸ÃÔõô×öÄØ£¿ÊDz»ÊÇÒªÏÈΪ·ÖÇø·½°¸Ìí¼ÓÒ»¸öÎļþ×飿
ÕâÖÖÏë·¨ÊÇûÓдíµÄ£¬ÏëҪΪ·ÖÇø±íÌí¼ÓÒ»¸ö·ÖÇø£¬¿ÉÒÔͨ¹ýÒÔÏÂÁ½¸ö²½ÖèÀ´ÊµÏÖ£º
1¡¢Îª·ÖÇø·½°¸Ö¸¶¨Ò»¸ö¿ÉÒÔʹÓõÄÎļþ×é¡£
2¡¢Ð޸ķÖÇøº¯Êý¡£
ÔÚΪ·ÖÇø·½°¸Ö¸¶¨Ò»¸ö¿ÉÓõÄÎļþ×éʱ£¬¸Ã·ÖÇø·½°¸²¢Ã»ÓÐÁ¢¿ÌʹÓÃÕâ¸öÎļþ×飬ֻÊǽ«Îļþ×éÏȱ¸ÓÃ×Å£¬µÈÐÞ¸ÄÁË·ÖÇøº¯ÊýÖ®ºó·ÖÇø·½°¸²Å»áʹÓÃÕâ¸öÎļþ×飨²»ÒªÍü¼ÇÁ
Ïà¹ØÎĵµ£º
Êý¾Ý¿âÀàÐÍΪDateTimeÀàÐÍ£¬½«Æä×öÄ£ºý²éѯʱ£¬ÔÚHibernateÖУ¬¿ÉÒÔÓÃÆ´SQLµÄÎÊÌ⽫Æä½â¾ö£¬¼´ÔÚSQL²éѯ·ÖÎöÆ÷дSQLÒ»Ñù£¬µ«ÊÇÀûÓòÎÊýÅäÖã¬Ôò·½·¨ÈçÏ£º
1¡¢Æ´ÉÏSQL,È磺
String beginPara= &q ......
´íÎóÈçÏ£º
Database character set (AL32UTF8) and Client character set (ZHS16GBK) are different.
Character set conversion may cause unexpected results.
Note: you can set the client character set through the NLS_LANG environment variable or the NLS_LANG registry key in
HKEY_LOCAL_MACHINE\SOFTWARE\ ......
CREATE PROCEDURE fenye
@tblName varchar(255)='wdf1', -- ±íÃû
@strGetFields varchar(1000) = '*', -- ÐèÒª·µ»ØµÄÁÐ
@fldName varchar(255)='userid', -- ÅÅÐòµÄ×Ö¶ÎÃû
@PageSize int = 10, -- Ò³³ß´ç
@PageIndex int = 1, -- Ò³Âë
@doCount bit = 0, -- ·µ»Ø¼Ç¼×ÜÊý, ·Ç 0 ÖµÔò·µ»Ø
@OrderType bit = 0, -- Éè ......