SQLʱ¼äº¯Êý
Sqlʱ¼äº¯Êý
Ò»¡¢sql serverÈÕÆÚʱ¼äº¯Êý
Sql ServerÖеÄÈÕÆÚÓëʱ¼äº¯Êý
1. µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
select getdate()
2. dateadd ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
ÀýÈ磺ÏòÈÕÆÚ¼ÓÉÏ2Ìì
select dateadd(day,2,'2004-10-15') --·µ»Ø£º2004-10-17 00:00:00.000
3. datediff ·µ»Ø¿çÁ½¸öÖ¸¶¨ÈÕÆÚµÄÈÕÆÚºÍʱ¼ä±ß½çÊý¡£
select datediff(day,'2004-09-01','2004-09-18') --·µ»Ø£º17
4. datepart ·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄÕûÊý¡£
select DATEPART(month, '2004-10-15') --·µ»Ø 10
5. datename ·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄ×Ö·û´®
select datename(weekday, '2004-10-15') --·µ»Ø£ºÐÇÆÚÎå
6. day(), month(),year() --¿ÉÒÔÓëdatepart¶ÔÕÕÒ»ÏÂ
select µ±Ç°ÈÕÆÚ=convert(varchar(10),getdate(),120)
,µ±Ç°Ê±¼ä=convert(varchar(8),getdate(),114)
select datename(dw,'2004-10-15')
select ±¾ÄêµÚ¶àÉÙÖÜ=datename(week,'2004-10-15')
,½ñÌìÊÇÖܼ¸=datename(weekday,'2004-10-15')
¶þ¡¢ÈÕÆÚ¸ñʽת»»
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
20040912
select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12
ÆäËüÎÒ²»³£ÓõÄÈÕÆÚ¸ñʽת»»·½·¨:
select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004
selec
Ïà¹ØÎĵµ£º
SQL2005ÖÐrow_number( )¡¢rank( )¡¢dense_rank( )¡¢ntile( )º¯ÊýµÄÓ÷¨(2) ÊÕ²Ø
SQL server 2005ÐÂÔöµÄ¼¸¸öº¯Êý,·Ö±ðÊÇrow_number( )¡¢rank( )¡¢,DENSE_RANK( )¡¢ntile( )ÏÂÃæÒÔʵÀý·Ö±ð¼òµ¥½²½â¡£
1.row_number( )
ÏÈÀ´µãÊý¾Ý,ÏȽ¨¸ö±í
SET NOCOUNT ......
2.1 ±¾ÕÂÄ¿µÄ
ÔÚ±¾ÕÂÖоÍÔÚ HSQLDB Ö÷Ò³ÂÛ̳»òÓʼþÁбíÖжà´ÎÌá³öµÄÎÊÌâ½øÐнâ´ð£¬Èç¹ûÄã´òËãÔÚÓ¦
ÓóÌÐòÖÐʹÓÃHSQLDB µÄ»°£¬ÄãÓ¦¸ÃÔĶÁһϱ¾Õ¡£
2.2 ¶ÔSQL ±ê×¼µÄÖ§³Ö
1.8.0 °æ±¾µÄHSQLDB Ö§³ÖSQL92¡¢99 ºÍ2003 ±ê×¼¹æ¶¨µÄSQL ·½ÑÔ¡£ÕâÒâζ×ÅHSQLDB
ÖÐÖ§³ÖµÄ±ê×¼ÌØÐÔ£¨ÀýÈç×óÍâÁ¬½Ó£©µÄÓï·¨ÊÇÓɱê×¼Îı¾¹æ¶¨µÄ¡£Ðí¶ ......
ÔÚ SQL Server Management Studio ÖУ¬Á¬½Óµ½Êý¾Ý¿âÒýÇæ·þÎñÆ÷ÀàÐÍ£¬Õ¹¿ªÊý¾Ý¿â£¬ÓÒ¼üµ¥»÷Ò»¸öÊý¾Ý¿â£¬Ö¸Ïò“ÈÎÎñ”£¬ÔÙµ¥»÷“µ¼ÈëÊý¾Ý”»ò“µ¼³öÊý¾Ý”¡£
»òÕß
¿ªÊ¼²¢Ñ¡ÔñÔËÐв¢ÊäÈëCMD È»ºóÔÚÃüÁîÌáʾ·ûÀïÊäÈëDTSWIZARD¡£
»ò
ÔÚÃüÁîÌáʾ·û´°¿ÚÖÐÔËÐÐ DTSWizard.exe£¨Î»ÓÚ C:\Program ......
1£©PL/SQLÊý¾ÝÀàÐÍ
Ãû³Æ
ÀàÐÍ
˵Ã÷
NUMBER
Êý×ÖÐÍ
ÄÜ´æ·ÅÕûÊýÖµºÍʵÊýÖµ£¬²¢ÇÒ¿ÉÒÔ¶¨Ò徫¶ÈºÍÈ¡Öµ·¶Î§
BINARY_INTEGER
Êý×ÖÐÍ
¿É´æ´¢´ø·ûºÅÕûÊý£¬ÎªÕûÊý¼ÆËãÓÅ»¯ÐÔÄÜ
DEC
Êý×ÖÐÍ
NUMBERµÄ×ÓÀàÐÍ£¬Ð¡Êý
DOUBLE PRECISION
Êý×ÖÐÍ
NUMBERµÄ×ÓÀàÐÍ£¬¸ß¾«¶ÈʵÊý
INTEGER
Êý×ÖÐÍ
NUMBERµÄ×ÓÀàÐÍ£¬ÕûÊý
INT
Êý ......
---------Êýѧº¯Êý
1.¾ø¶ÔÖµ
S:select abs(-1) value
O:select abs(-1) value from dual
2.È¡Õû(´ó)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.È¡Õû£¨Ð¡£©
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.È¡Õû£¨½ØÈ¡£©
S:select cast(-1.002 as int) v ......