OracleʱÇø
ÉÌÒµºÍÊý¾Ý¿âºÜ¶àʱºò±ØÐë¿çʱÇø¹¤×÷£¬´Ó9i¿ªÊ¼£¬oracle»·¾³¿ªÊ¼ÓÐÁËʱÇøÒâʶ£¬Í¨¹ýÖ¸¶¨Êý¾Ý¿âµÄʱÇøºÍʹÓÃTIMESTAMP WITH TIME ZONEºÍTIMESTAMP WITH LOCAL TIME ZONEÊý¾ÝÀàÐÍÀ´ÊµÏָù¦ÄÜ¡£
TIMESTAMP WITH TIME ZONE²»»á´æ´¢Êý¾Ý¿âʱÇø£¬µ«ÊÇÓÐÒ»¸öָʾÓÃÀ´ËµÃ÷¸Ãʱ¼äËùʹÓõÄʱÇø¡£TIMESTAMP WITH LOCAL TIME ZONE»áͬʱ´æ´¢Êý¾Ý¿âʱÇø£¬²¢ÇÒ»á¸ù¾Ý²éѯ¿Í»§¶ËµÄʱÇø½øÐÐÏàÓ¦µÄת»»¡£
Êý¾Ý¿âʱÇø¿ÉÒÔÔÚ´´½¨Ê±ÔÚcreate databaseÃüÁîÖÐÉèÖã¬Ò²¿ÉÒÔʹÓÃalter database set TIME_ZONE=...À´Ð޸ġ£Èç¹ûûÓÐÌرðµÄÖ¸¶¨£¬Ä¬Èϵģ¬Êý¾Ý¿â½«×ñ´ÓÖ÷»ú²Ù×÷ϵͳʱÇøÉèÖ㬻òÕßÈ¡×Ô»·¾³±äÁ¿ORA_STDZ¡£ËùÓÐÖ§³ÖµÄʱÇø¼Ç¼ÔÚV$TIMEZONE_NAMES¶¯Ì¬ÐÔÄܱíÖС£Ê±ÇøÓÐÈýÖÖ±íʾ·½·¨£¬È«Ãû¡¢ËõдºÍÏà¶ÔÓÚ±ê׼ʱ¼ä£¨¸ñÁÖÍþÖÎʱ¼ä£©µÄ¹Ì¶¨Æ«ÒÆ,±ÈÈç±ê׼ʱ¼äÏàÓ¦µÄÈýÖÖ±íʾ·½·¨·Ö±ðΪ£ºEtc/Greenwich¡¢GMTºÍ+00:00¡£
Oracle 9i ¿ªÊ¼¶àÁË 3 ¸ö¹ØÓÚʱ¼äµÄÊý¾ÝÀàÐÍ£ºTIMESTAMP [(precision)] TIMESTAMP [(precision)] WITH TIME ZONE TIMESTAMP [(precision)] WITH LOCAL TIME ZONE£¬ÆäÖÐ TIMESTAMP [(precision)] WITH TIME ZONE ±£´æÁËʱÇøÐÅÏ¢¡£
1. Oracle µÄʱÇøÉèÖÃ
Oracle µÄʱÇø¿ÉÒÔ·ÖΪÁ½ÖÖ£¬Ò»ÖÖÊÇÊý¾Ý¿âµÄʱÇø£¬Ò»ÖÖÊÇ session ʱÇø£¬Ò²¾ÍÊÇ¿Í»§¶ËÁ¬½ÓʱµÄʱÇø£¨¾¹ýʵÑ飬Á¬½ÓÒÔºóÔÙÐ޸Ŀͻ§¶ËµÄʱÇø£¬session µÄʱÇø²»»á¸ü¸Ä£©¡£
Êý¾Ý¿âµÄʱÇøÔÚ´´½¨Êý¾Ý¿âʱ¿ÉÒÔͨ¹ýÔÚ create database Óï¾äÖмÓÉÏ SET TIME_ZONE = ' { { + | - } hh : mi | time_zone_region } ' À´Ö¸¶¨£¬Èç¹û£¬²»Ö¸¶¨£¬Ä¬ÈÏÊÇ°´ÕÕÊý¾Ý¿âËùÔڵIJÙ×÷ϵͳʱÇøÀ´É趨µÄ¡£´´½¨Ö®ºó£¬¿ÉÒÔͨ¹ý alter database À´Ð޸ġ£ÆäÖÐ time_zone_region ²ÎÊý¿ÉÒÔͨ¹ý²éѯ V$TIMEZONE_NAMES ¶¯Ì¬ÊÓͼÀ´»ñµÃËùÓÐÖ§³ÖµÄÖµ¡£ÐÞ¸ÄÖ®ºó£¬ÐèÒªÖØÆôÊý¾Ý¿â²ÅÄÜÉúЧ¡£¾³£ÓÐÈË»áÅöµ½ÎÞ·¨Ð޸ĵÄÇé¿ö£º
SQL> alter database set time_zone='+06:00';
alter database set time_zone='+06:00'
*
ERROR at line 1:
ORA-02231: missing or invalid option to ALTER DATABASE
TOM ¶Ô´ËÎÊÌâÓйý½âÊÍ£¬TIME_ZONE µÄÉ趨Ö÷ÒªÊÇΪÁË WITH LOCAL TIME ZONE£¬µ± session µÄʱÇøºÍÊý¾Ý¿âµÄʱÇø²»Í¬Ê±£¬oracle ¸ù¾ÝʱÇøµÄ²î¾àת»»µ½Êý¾Ý¿âµÄʱ¼ä£¬ÔÙ±£´æµ½Êý¾Ý¿âµÄ WITH LOCAL TIME ZONE ÀàÐÍÖУ¬ËûÊDz»±£´æʱÇøµÄ£¬ËùÒÔÐèÒª TIME_ZONE À´½øÐи÷ÖÖʱÇøÖ®¼äʱ¼äµÄת»»£¨WITH TIME ZONE ÀàÐͱ£´æÁËÔʼµÄʱÇø£¬ËùÒÔ²»ÐèÒª TI
Ïà¹ØÎĵµ£º
oracleÆô¶¯ÎÊÌâ
Ò»£ºÊý¾Ý¿âûÓÐÆô¶¯
#sqlplus /nolog
sql>connect /as sysdba
sql>startup
¶þ£º¼àÌý³öÎÊÌâ
µÇ¼DB·þÎñÆ÷
ʹÓÃlsnrctl start/stop¿ªÆô/¹Ø±Õ¼àÌý
ʹÓÃlsnrctl status²é¿´×´Ì¬
ÀíӦΪ£º
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ERPAP)(PORT=1521)))
STATUS of the ......
¾¹ý³¤Ê±¼äѧϰOracle£¬Äã¿ÉÄÜ»áÓöµ½Oracle tnsÅäÖÃÎÊÌ⣬ÕâÀォ½éÉÜOracle tnsÅäÖÃÎÊÌâµÄ½â¾ö·½·¨¡£×î½üæ×Å°²×°OracleÊý¾Ý¿â£¬±¾À´Í¦¼òµ¥µÄ£¬¿ÉÀÏÊdzöÏÖÎÊÌ⣬×îºó×Ô¼ºÔÚÍøÉÏÕûÀíÁËһЩtns´íÎó½â¾ö·½·¨£¬Ï£Íû¶Ô³õѧÕßÓÐÒæ¡£
³£¼ûÎÊÌâ:
1¡¢ORA-12541:tns:ûÓмàÌýÆ÷£º
ÏÔ¶øÒ×¼û£¬·þÎñÆ÷¶ËµÄ¼àÌýÆ÷ûÓÐÆô¶¯£¬ÁíÍâ¼ì²é¿Í» ......
ͨ¹ý select * from table whereid=16701 for update ËøסһÕűí
ͨ¹ýÒÔÏÂÓï¾ä¿É²éѯ³ö±»ËøסµÄ¶ÔÏó
SELECT OBJECT_ID,
SESSION_ID,
SERIAL#,
ORACLE_USERNAME,
&nb ......
Á¬½ÓOracleÊý¾Ý¿âµÄHibernateÅäÖÃÎļþ
Á¬½ÓOracleµÄHibernateÅäÖÃÎļþÓÐÁ½ÖÖ¸ñʽ£¬Ò»ÖÖÊÇxml¸ñʽµÄ£¬ÁíÒ»ÖÖÊÇJavaÊôÐÔÎļþ¸ñʽµÄ¡£ÏÂÃæ·Ö±ð¸ø³öÕâÁ½ÖÖ¸ñʽÅäÖÃÎļþµÄ´úÂë¡£
1£®xml¸ñʽµÄÅäÖÃÎļþ
ÏÂÃ潫¸ø³öÁ¬½Ó±¾µØOracle·þÎñÆ÷ÉϵÄdb_database02Êý¾Ý¿âʱHibernateÅäÖÃÎļþhibernate.cfg.xmlµÄ´úÂë¡£
Àý³Ì2-5£º¹âÅÌ\mr ......
select * from TTable1 for update Ëø¶¨±íµÄËùÓÐÐУ¬Ö»ÄܶÁ²»ÄÜд
2 select * from TTable1 where pkid = 1 for update Ö»Ëø¶¨pkid=1µÄÐÐ
3 select * from Table1 a join Table2 b on a.pkid=b.pkid for update Ëø¶¨Á½¸ö±íµÄËùÓмǼ
4 select * from Table1 a join Table2 b on a.pki ......