[20190531]Timestamp Oddity.txt --//链接:https://jonathanlewis.wordpress.com/2019/05/29/timestamp-oddity/ --//重复测试: 1.环境: SCOTT@test01p> @ ver1 PORT_STRING VERSION BANNER CON_ID ------------------------------ -------------- -------------------------------------------------------------------------------- ---------- IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0 2.测试: SCOTT@test01p> create table t1 ( ts_tz timestamp(9) with time zone, ts_ltz timestamp(9) with local time zone); Table created. SCOTT@test01p> insert into t1 values(systimestamp, systimestamp); 1 row created. SCOTT@test01p> commit ; Commit complete. SCOTT@test01p> select * from t1; TS_TZ TS_LTZ ----------------------------- ----------------------------- 2019-05-30 20:18:47.954000000 2019-05-30 20:18:47.954000000 --//显示一样,估计和我的环境配置有关,不探究了. SCOTT@test01p> alter table t1 add constraint ts_ltz_uk unique (ts_ltz); Table altered. SCOTT@test01p> alter table t1 add constraint ts_tz_uk unique (ts_tz); alter table t1 add constraint ts_tz_uk unique (ts_tz) * ERROR at line 1: ORA-02329: column of datatype TIME/TIMESTAMP WITH TIME ZONE cannot be unique or a primary key --//不能建立约束在local time zone的timestamp类型上. SCOTT@test01p> create unique index ts_tz_uk on t1(ts_tz); Index created. --//这样建立OK,但实际上建立函数索引. SCOTT@test01p> select index_name, column_name from user_ind_columns where table_name = 'T1'; INDEX_NAME COLUMN_NAME -------------------- -------------------- TS_LTZ_UK TS_LTZ TS_TZ_UK SYS_NC00003$ SCOTT@test01p> column COLUMN_EXPRESSION format a30 SCOTT@test01p> select * from user_ind_expressions where table_name = 'T1'; INDEX_NAME TABLE_NAME COLUMN_EXPRESSION COLUMN_POSITION -------------------- -------------------- ------------------------------ --------------- TS_TZ_UK T1 SYS_EXTRACT_UTC("TS_TZ") 1 --//很奇怪的字段类型,建立唯一索引,也就是保存的值可能存在重复吗? --//链接:https://jonathanlewis.wordpress.com/2019/05/29/timestamp-oddity/ Oracle has silently invoked the sys_extract_utc() function on our (free-floating) timestamp column to normalize it to UTC. This is really not very friendly but it does make sense, of course – it would be rather expensive to enforce uniqueness if there were (at least) 24 different ways of storing the same absolute value – and 24 is a conservative estimate. --//甲骨文已经默默地调用sys_extract_utc()函数在我们(自由浮动)时间戳列规范化UTC。这是真的不是很友好但它确实有意义,当然,这 --//将是相当昂贵的执行独特性如果有(至少)24种不同的方式存储相同的绝对值,24是保守的估计。 --//上班在11.2.0.4上重复测试: SCOTT@book> @ ver1 PORT_STRING VERSION BANNER ------------------------------ -------------- -------------------------------------------------------------------------------- x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production create table t1 ( ts_tz timestamp(9) with time zone, ts_ltz timestamp(9) with local time zone); insert into t1 values(systimestamp, systimestamp); commit ; select * from t1; SCOTT@book> select * from t1; TS_TZ TS_LTZ ------------------------------------ ----------------------------- 2019-05-31 08:40:14.003461000 +08:00 2019-05-31 08:40:14.003461000 SCOTT@book> select dump(ts_tz,16) c50 ,dump(TS_LTZ,16) c50 from t1; C50 C50 -------------------------------------------------- -------------------------------------------------- Typ=181 Len=13: 78,77,5,1f,1,29,f,0,34,cf,88,1c,3c Typ=231 Len=11: 78,77,5,1f,1,29,f,0,34,cf,88 SCOTT@book> alter table t1 add constraint ts_ltz_uk unique (ts_ltz); Table altered. SCOTT@book> alter table t1 add constraint ts_tz_uk unique (ts_tz); alter table t1 add constraint ts_tz_uk unique (ts_tz) * ERROR at line 1: ORA-02329: column of datatype TIME/TIMESTAMP WITH TIME ZONE cannot be unique or a primary key --//不能建立约束在local time zone的timestamp类型上. SCOTT@book> create unique index ts_tz_uk on t1(ts_tz); Index created. SCOTT@book> select index_name, column_name from user_ind_columns where table_name = 'T1'; INDEX_NAME COLUMN_NAME ------------------------------ -------------------- TS_LTZ_UK TS_LTZ TS_TZ_UK SYS_NC00003$ SCOTT@book> column COLUMN_EXPRESSION format a30 SCOTT@book> select * from user_ind_expressions where table_name = 'T1'; INDEX_NAME TABLE_NAME COLUMN_EXPRESSION COLUMN_POSITION ------------------------------ ---------- ------------------------------ --------------- TS_TZ_UK T1 SYS_EXTRACT_UTC("TS_TZ") 1 --//同样!!
[20190531]Timestamp Oddity.txt
来源:这里教程网
时间:2026-03-03 13:47:42
作者:
编辑推荐:
- [20190531]Timestamp Oddity.txt03-03
- [20190531]建立job与commit.txt03-03
- sqlplus / as sysdba报错ORA-01017: invalid username/password; logon denied03-03
- 【SQL】根据两列信息,整合两张表数据03-03
- [20190531]ORA-600 kokasgi1故障模拟与恢复.txt03-03
- DB BUFFER LRU 列表的latch等待03-03
- [20190531]ORA-600 kokasgi1故障模拟与恢复(后续).txt03-03
- linux下恢复误删除oracle的数据文件03-03
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 5-dw_星型模型和雪花模型
5-dw_星型模型和雪花模型
26-03-03 - Oracle RAC+DG环境搭建(CentOS 7+Oracle 12C)(三) 网络规划及相关配置
- Oracle RAC+DG环境搭建(CentOS 7+Oracle 12C) (六) 安装Grid Infrastructure
- 安装Oracle 11G RAC 遇到的2个问题——Failed to run "oifcfg" 和 找不到集群节点
- OGG Director报错 Connection FAILED
OGG Director报错 Connection FAILED
26-03-03 - Debian rsyslog服务配置与管理(新手入门完整教程)
Debian rsyslog服务配置与管理(新手入门完整教程)
26-03-03 - NOT IN之后的子查询不能包含NULL值
NOT IN之后的子查询不能包含NULL值
26-03-03 - 6-dw_元数据管理
6-dw_元数据管理
26-03-03 - 外键没有索引哪些DML操作会被阻塞
外键没有索引哪些DML操作会被阻塞
26-03-03 - Oracle/云MySQL/MsSQL“大迁移”真相及最优方案
Oracle/云MySQL/MsSQL“大迁移”真相及最优方案
26-03-03
