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

pl/sql³£Óú¯Êý

1¡£Sysdate µ±Ç°ÈÕÆÚºÍʱ¼ä
SQL> Select sysdate from dual;
SYSDATE
----------
21-6ÔÂ -05
2¡£Last_day ±¾ÔÂ×îºóÒ»Ìì
SQL> Select last_day(sysdate) from dual;
LAST_DAY(S
----------
30-6ÔÂ -05
3¡£Add_months(d,n) µ±Ç°ÈÕÆÚdºóÍÆn¸öÔÂ
ÓÃÓÚ´ÓÒ»¸öÈÕÆÚÖµÔö¼Ó»ò¼õÉÙһЩÔ·Ý
date_value:=add_months(date_value,number_of_months)
SQL> Select add_months(sysdate,2) from dual;
ADD_MONTHS
----------
21-8ÔÂ -05
4¡£Months_between(f,s) ÈÕÆÚfºÍs¼äÏà²îÔÂÊý
SQL> select months_between(sysdate,to_date('2005-11-12','yyyy-mm-dd'))from dual;
MONTHS_BETWEEN(SYSDATE,TO_DATE('2005-11-12','YYYY-MM-DD'))
----------------------------------------------------------
-4.6966741
5¡£NEXT_DAY(d, day_of_week)
·µ»ØÓÉ"day_of_week"ÃüÃûµÄ£¬ÔÚ±äÁ¿"d"Ö¸¶¨µÄÈÕÆÚÖ®ºóµÄµÚÒ»¸ö¹¤×÷ÈÕµÄÈÕÆÚ¡£²ÎÊý"day_of_week"±ØÐëΪ¸ÃÐÇÆÚÖеÄijһÌì¡£
SQL> SELECT next_day(to_date('20050620','YYYYMMDD'),1) from dual;
NEXT_DAY(T
----------
26-6ÔÂ -05
6¡£current_date()·µ»Øµ±Ç°»á»°Ê±ÇøÖеĵ±Ç°ÈÕÆÚ
date_value:=current_date
SQL> column sessiontimezone for a15
SQL> select sessiontimezone,current_date from dual;
SESSIONTIMEZONE CURRENT_DA
--------------- ----------
+08:00 13-11ÔÂ-03
SQL> alter session set time_zone='-11:00' 2 /
»á»°ÒѸü¸Ä¡£
SQL> select sessiontimezone,current_timestamp from dual;
SESSIONTIMEZONE CURRENT_TIMESTAMP
--------------- ------------------------------------
-11:00 12-11ÔÂ-03 04.59.13.668000 ÏÂÎç -11:00
7¡£current_timestamp()ÒÔtimestamp with time zoneÊý¾ÝÀàÐÍ·µ»Øµ±Ç°»á»°Ê±ÇøÖеĵ±Ç°ÈÕÆÚ
SQL> select current_timestamp from dual;
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
21-6ÔÂ -05 10.13.08.220589 ÉÏÎç +08:00
8¡£dbtimezone()·µ»ØʱÇø
SQL> select dbtimezone from dual;
DBTIME
------
-08:00
9¡£extract()ÕÒ³öÈÕÆÚ»ò¼ä¸ôÖµµÄ×Ö¶ÎÖµ
date_value:=extract(date_field from [datetime_value|interval_value])
SQL> select extract(month from sysdate) "This Month" from dual;
This Month
--------


Ïà¹ØÎĵµ£º

SQL 2005 tips

USE tempdb
GO
CREATE TABLE AuctionItems
(
  itemid       INT          NOT NULL PRIMARY KEY NONCLUSTERED,
  itemtype     NVARCHAR(30) NOT NULL,
  whenmade     INT&nb ......

Sql Server µÈ´ý״̬˵Ã÷

µÈ´ýÀàÐÍ  ˵Ã÷  
ASYNC_DISKPOOL_LOCK 
µ±³¢ÊÔͬ²½²¢ÐеÄỊ̈߳¨Ö´Ðд´½¨»ò³õʼ»¯ÎļþµÈÈÎÎñ£©Ê±³öÏÖ¡£ 
ASYNC_IO_COMPLETION 
µ±Ä³ÈÎÎñÕýÔڵȴý I/O Íê³Éʱ³öÏÖ¡£ 
ASYNC_NETWORK_IO 
µ±ÈÎÎñ±»×èÖ¹ÔÚÍøÂçÖ®ºóʱ³öÏÖÔÚÍøÂçдÈëÖС£ 
BACKUP 
µ±ÈÎÎñ×÷Ϊ±¸·Ý´¦Àí ......

Ìá¸ßSQLÖ´ÐÐЧÂʵļ¸µã½¨Òé:

¡¡¡¡
¡¡¡¡¡ô¾¡Á¿²»ÒªÔÚwhereÖаüº¬×Ó²éѯ;
¡¡¡¡¹ØÓÚʱ¼äµÄ²éѯ£¬¾¡Á¿²»ÒªÐ´³É£ºwhere to_char(dif_date,'yyyy-mm-dd')=to_char('2007-07-01','yyyy-mm-dd');
¡¡¡¡¡ôÔÚ¹ýÂËÌõ¼þÖУ¬¿ÉÒÔ¹ýÂ˵ô×î´óÊýÁ¿¼Ç¼µÄÌõ¼þ±ØÐë·ÅÔÚwhere×Ó¾äµÄĩβ;
¡¡¡¡from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í£¬driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖа ......

ÈçºÎ²é¿´SQL Server²¹¶¡°æ±¾

ÈçºÎ²é¿´SQL Server²¹¶¡°æ±¾  [http://www.cnblogs.com/yitian/articles/1285021.html]
1¡¢ÓÃIsql»òÕßSQL²éѯ·ÖÎöÆ÷µÇ¼µ½SQL Server£¬Èç¹ûÊÇÓÃIsql£¬ÇëÔÚcmd´°¿ÚÊäÈëisql -U sa,È»ºóÊäÈëÃÜÂ룬½øÈ룻Èç¹ûÊÇÓÃSQL²éѯ·ÖÎöÆ÷£¬Çë´Ó³ÌÐòÖÐÆô¶¯£¬ÊäÈësaºÍÃÜÂ루Ҳ¿ÉÒÔÓÃwindowsÑéÖ¤£©¡£
2¡¢ÔÚISQLÖÐÊäÈ ......

¼à¿ØÊý¾Ý¿âÐÔÄܵÄSQL»ã×Ü

¼à¿ØÊý¾Ý¿âÐÔÄܵÄSQL»ã×Ü ¡¾http://hi.baidu.com/g%5Fliying/blog/item/89711cfc27b82ff4fc037f80.html¡¿
1. ¼à¿ØÊÂÀýµÄµÈ´ý
select event,sum(decode(wait_Time,0,0,1)) "Prev",
sum(decode(wait_Time,0,1,0)) "Curr",count(*) "Tot"
from v$session_Wait
group by event order by 4;
2. »Ø¹ö¶ÎµÄÕùÓÃÇé¿ö
se ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ