Oracle dbtimezone與os時區不一致的解決辦法
//檢視資料庫時區
SQL> select dbtimezone from dual;
DBTIMEZONE
----------
+00:00
//檢視當前時間和時區
SQL> select systimestamp from dual;
SYSTIMESTAMP
--------------------------------------------------------------------------------
12-4月 -11 02.39.49.421000 下午 +08:00
//修改資料時區
SQL> alter database set time_zone='+8:00';
ORA-30079: cannot alter database timezone when database has TIMESTAMP WITH LOCAL TIME ZONE columns
/從錯誤提示,可以看出資料庫中一些表的列的資料型別為:TIMESTAMP WITH LOCAL TIME ZONE
//需要將這些列刪除後,才能更改,下面我們來查詢這些列:
SQL>
select u.name || '.' || o.name || '.' || c.name TSLTZcolumn from sys.obj$ o, sys.col$ c, sys.user$ u where c.type# = 231 and o.obj# = c.obj# and u.user# = o.owner#;
TSLTZ_COLUMN
--------------------------------------------------------------------------------
OE.ORDERS.ORDER_DATE
//是oe使用者下orders表下的列order_date
SQL> desc oe.orders;
Name Type Nullable Default Comments
------------ --------------------------------- -------- ------- -----------------------------------------------------------
ORDER_ID NUMBER(12) PRIMARY KEY column.
ORDER_DATE TIMESTAMP(6) WITH LOCAL TIME ZONE TIMESTAMP WITH LOCAL TIME ZONE column, NOT NULL constraint.
ORDER_MODE VARCHAR2(8) Y CHECK constraint.
CUSTOMER_ID NUMBER(6)
ORDER_STATUS NUMBER(2) Y 0: Not fully entered, 1: Entered, 2: Canceled - bad credit,-
3: Canceled - by customer, 4: Shipped - whole order, -
5: Shipped - replacement items, 6: Shipped - backlog on items, -
7: Shipped - special delivery, 8: Shipped - billed, 9: Shipped - payment plan,-
10: Shipped - paid
ORDER_TOTAL NUMBER(8,2) Y CHECK constraint.
SALES_REP_ID NUMBER(6) Y References hr.employees.employee_id.
PROMOTION_ID NUMBER(6) Y Sales promotion ID. Used in SH schema
SQL> alter table oe.orders drop column order_date; --刪除列
Table altered
SQL> alter database set time_zone='+8:00'; --修改時區
Database altered
SQL> shutdown immediate; --關閉資料庫
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup; --重啟資料庫
ORACLE instance started.
Total System Global Area 171966464 bytes
Fixed Size 7877988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.
Database opened.
SQL> select dbtimezone from dual; --檢視更新後的時區
DBTIMEZONE
----------
+08:00
[@more@]
SQL> select dbtimezone from dual;
DBTIMEZONE
----------
+00:00
//檢視當前時間和時區
SQL> select systimestamp from dual;
SYSTIMESTAMP
--------------------------------------------------------------------------------
12-4月 -11 02.39.49.421000 下午 +08:00
//修改資料時區
SQL> alter database set time_zone='+8:00';
ORA-30079: cannot alter database timezone when database has TIMESTAMP WITH LOCAL TIME ZONE columns
/從錯誤提示,可以看出資料庫中一些表的列的資料型別為:TIMESTAMP WITH LOCAL TIME ZONE
//需要將這些列刪除後,才能更改,下面我們來查詢這些列:
SQL>
select u.name || '.' || o.name || '.' || c.name TSLTZcolumn from sys.obj$ o, sys.col$ c, sys.user$ u where c.type# = 231 and o.obj# = c.obj# and u.user# = o.owner#;
TSLTZ_COLUMN
--------------------------------------------------------------------------------
OE.ORDERS.ORDER_DATE
//是oe使用者下orders表下的列order_date
SQL> desc oe.orders;
Name Type Nullable Default Comments
------------ --------------------------------- -------- ------- -----------------------------------------------------------
ORDER_ID NUMBER(12) PRIMARY KEY column.
ORDER_DATE TIMESTAMP(6) WITH LOCAL TIME ZONE TIMESTAMP WITH LOCAL TIME ZONE column, NOT NULL constraint.
ORDER_MODE VARCHAR2(8) Y CHECK constraint.
CUSTOMER_ID NUMBER(6)
ORDER_STATUS NUMBER(2) Y 0: Not fully entered, 1: Entered, 2: Canceled - bad credit,-
3: Canceled - by customer, 4: Shipped - whole order, -
5: Shipped - replacement items, 6: Shipped - backlog on items, -
7: Shipped - special delivery, 8: Shipped - billed, 9: Shipped - payment plan,-
10: Shipped - paid
ORDER_TOTAL NUMBER(8,2) Y CHECK constraint.
SALES_REP_ID NUMBER(6) Y References hr.employees.employee_id.
PROMOTION_ID NUMBER(6) Y Sales promotion ID. Used in SH schema
SQL> alter table oe.orders drop column order_date; --刪除列
Table altered
SQL> alter database set time_zone='+8:00'; --修改時區
Database altered
SQL> shutdown immediate; --關閉資料庫
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup; --重啟資料庫
ORACLE instance started.
Total System Global Area 171966464 bytes
Fixed Size 7877988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.
Database opened.
SQL> select dbtimezone from dual; --檢視更新後的時區
DBTIMEZONE
----------
+08:00
[@more@]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23682146/viewspace-1055048/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【Oracle】 Oracle dbtimezone與OS時區不一致Oracle
- 時區錯誤導致oracle的EM不能啟動解決辦法Oracle
- laravel8 時區設定無效解決辦法Laravel
- 丟失Oracle中資料檔案Ora時的解決辦法Oracle
- oracle imp過慢的解決辦法Oracle
- oracle 11g awr不自動生成的臨時解決辦法Oracle
- 印表機無法列印的原因與解決辦法
- jive發貼時NullPointException解決辦法NullException
- Oracle opatch apply 時提示oci.dll has active的解決辦法OracleAPP
- 方差與偏差的解釋和解決辦法
- Hive常見的bug與解決辦法。Hive
- npm 使用安裝超時的解決辦法NPM
- 建庫時EM報錯的解決辦法
- Oracle statspack無法收集快照,及解決辦法Oracle
- 連線oracle錯誤解決辦法Oracle
- oracle 1455 錯誤解決辦法Oracle
- Oracle表碎片起因及解決辦法Oracle
- AIX重啟不進OS只進診斷模式的解決辦法AI模式
- Oracle死鎖的檢視以及解決辦法Oracle
- oracle rac asm 問題的官方解決辦法OracleASM
- Redhat區域網安裝的解決辦法(轉)Redhat
- emc powerpath 識別裝置名不一致解決辦法
- session丟失與解決辦法的資料Session
- MySql登入時閃退的快速解決辦法MySql
- 解決PythonWin執行時崩潰的辦法Python
- Oracle12154解決辦法Oracle
- Oracle ORA-00257故障解決辦法Oracle
- oracle壞塊問題及解決辦法Oracle
- oracle 10g emctl 報錯的解決辦法Oracle 10g
- jsonUnexpected token,字串編碼不一致等的終極解決辦法JSON字串編碼
- 【git】Git commit時提示錯誤時 解決辦法GitMIT
- JavaScript 跨域總結與解決辦法JavaScript跨域
- OpenStack 的NAT解決辦法
- 公寓噪音的解決辦法
- ubuntu域名解析暫時失效解決辦法Ubuntu
- emca刪除em時間過長的解決辦法
- unity player 顯示播放錯誤時的解決辦法Unity
- bilibili 看影片時 GPU 狂飆的解決辦法.GPU