Sql serverÖÐʱ¼äº¯ÊýÓ÷¨Ïê½â
SQLÖеÄʱ¼äº¯Êý·Ç³£ÓÐÓã¬ÌرðÊÇÔÚÎÒÃǽøÐгõʼ¸³Öµ¡¢¸´ÔÓ²éѯµÄʱºò£¬¾ÍÏÔµÃÌر𷽱㡣
1¡¢»ñµÃϵͳµ±Ç°Ê±¼ä
select getdate()
2¡¢DateName ( datepart , date )·µ»Ø±íʾָ¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄ×Ö·û´®¡£
--½ñÌìÊÇ2009-2-24--ÐÇÆÚ¶þ
SELECT DATENAME(year, getdate()) AS 'Year Name' --------·µ»Ø£º2009
SELECT DATENAME(month, getdate()) AS 'Month Name' --------·µ»Ø£º02
SELECT DATENAME(weekday, getdate()) AS 'Weekday Name'------·µ»Ø£ºÐÇÆÚ¶þ
3¡¢DATEADD (datepart , number, date )£¬ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ¡£
select DateAdd(MM,2,'2008-8-8') --------------·µ»Ø£º2008-10-08 00:00:00.000
select DateAdd(dd,2,'2008-8-8') --------------·µ»Ø£º2008-08-10 00:00:00.000
select dateadd(hh,-1,getdate()) --------------·µ»Ø£º2009-02-23 12:46:46.450£¬·µ»ØÇ°Ò»¸öСʱµÄʱ¼ä
4¡¢DATEDIFF ( date-part, date-expression-1, date-expression-2 ) ·µ»ØÁ½¸öÈÕÆÚÖ®¼äµÄ¼ä¸ô¡£
¡¡¡¡´Ëº¯Êý¼ÆËãÁ½¸öÖ¸¶¨ÈÕÆÚÖ®¼äÈÕÆÚ²¿·ÖµÄÊýÄ¿¡£½á¹ûΪÈÕÆÚ²¿·ÖÖеÈÓÚ£¨date2 - date1£©µÄÓзûºÅµÄÕûÊýÖµ¡£
SELECT datediff( hour, '4:00AM', '5:50AM' )---------------------------·µ»Ø: 1
SELECT datediff( month, '1987/05/02', '1995/11/15' )------------------·µ»Ø: 102
SELECT datediff( day, '00:00', '23:59' )------------------------------·µ»Ø£º0
SELECT datediff( day, '1999/07/19 00:00', '1999/07/23 23:59' )------·µ»Ø£º4
SELECT datediff( month, '1999/07/19', '1999/07/23' )------------------·µ»Ø£º0
SELECT datediff( month, '1999/07/19', '1999/08/23' )------------------·µ»Ø£º1
ʵÀý£º²éѯµ±Ìì¸üеÄÊý¾Ý
select * from tableName where datediff(dd,F_EditTime,getdate())=0
5¡¢DATEPART ( datepart ,date )·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄÕûÊý¡£
--½ñÌìÊÇ2009-2-
Ïà¹ØÎĵµ£º
×°ÁËSQL2000ºó°²×°SQL2005,ËäȻʹÓñðÃû¼ÓÒÔÇø±ðÁË£¬µ«·¢ÏÖ2005ÖÐûÓпɹ©·ÃÎʵÄÀàËÆÆóÒµ¹ÜÀíÆ÷£¬Ò»Ê±³å¶¯£¬Ð¶ÁË2000£¬ÍêÕû°²×°ÁË2005£¬·¢ÏÖ»¹ÊÇûÓÐÆóÒµ¹ÜÀíÆ÷£¬ËÑË÷¹ýºó²Å·¢ÏÖÐèÒª°²×°SQLServer2005_SSMSEE.msi£¨¼´SQLServerManagerStudioExpressEdition£©£¬ËüÌṩÁËÀàËÆÆóÒµ¹ÜÀíÆ÷µÄͼÐλ¯²Ù×÷½çÃæ¡£
×°ºÃºó£¬SQL ......
½ñÌìÖÕÓÚ°ÑÕâ¸öÎÊÌâ¸ø½â¾öÁË£º
²Î¿¼ÎÄÕ£ºhttp://blog.csdn.net/long2006sky/archive/2007/04/23/1576583.aspx
ʵÀý˵Ã÷£º
»·¾³£ºwin2k+sqlserver 2K+²éѯ·ÖÎöÆ÷
SQLSERVER·þÎñʵÀý ......
sql±àÒëÓëÖرàÒë
1.sp_recompile
ʹ´æ´¢¹ý³ÌºÍ´¥·¢Æ÷ÔÚÏ´ÎÔËÐÐʱÖØбàÒë¡£
2.sp_refreshview
Èç¹ûÊÓͼËùÒÀÀµµÄ»ù´¡¶ÔÏó·¢Éú¸ü¸Ä(Èç:±íÔö¼ÓÁËÒ»¸ö×Ö¶Î)£¬ÔòÊÓͼ²»»á×Ô¶¯¸üУ¬ÕâʱÐèÒªµ÷Óøô洢¹ý³ÌÀ´¶ÔÊÓͼ½øÐÐˢС£ÓÐÈË˵£¬ÖØдò¿ªÒ»ÏÂÊÓͼ¾Í¿ÉÒÔ¸üÐÂÊÓͼ£¬µ«ÎÒÊÔÁËûÓгɹ¦¡£
Àý1£ºË¢ÐÂÖ¸¶¨Ãû³ÆµÄÊÓͼ
......
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)
ÎÒ¾õµÃ²»¹ÜÊÇʲôÎ书,ÄÜÖ ......
ÔÚ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
ÔÌù£º
......