Trafodion 查看表的创建时间与修改时间

Trafodion中每个对象(如表、索引等)创建后,会在元数据表中增加相应的记录,主要元数据表为"_MD_".objects。
以下是"_MD_".objects的表结构,

SQL>showddl "_MD_".objects;

 
CREATE TABLE TRAFODION."_MD_".OBJECTS
  ( 
    CATALOG_NAME                     VARCHAR(256 BYTES) CHARACTER SET UTF8
      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE NOT SERIALIZED
  , SCHEMA_NAME                      VARCHAR(256 BYTES) CHARACTER SET UTF8
      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE NOT SERIALIZED
  , OBJECT_NAME                      VARCHAR(256 BYTES) CHARACTER SET UTF8
      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE NOT SERIALIZED
  , OBJECT_TYPE                      CHAR(2) CHARACTER SET ISO88591 COLLATE
      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE NOT SERIALIZED
  , OBJECT_UID                       LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
      NOT SERIALIZED
  , CREATE_TIME                      LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
      NOT SERIALIZED
  , REDEF_TIME                       LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
      NOT SERIALIZED
  , VALID_DEF                        CHAR(2) CHARACTER SET ISO88591 COLLATE
      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE NOT SERIALIZED
  , DROPPABLE                        CHAR(2) CHARACTER SET ISO88591 COLLATE
      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE NOT SERIALIZED
  , OBJECT_OWNER                     INT NO DEFAULT NOT NULL NOT DROPPABLE NOT
      SERIALIZED
  , SCHEMA_OWNER                     INT NO DEFAULT NOT NULL NOT DROPPABLE NOT
      SERIALIZED
  , FLAGS                            LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
      NOT SERIALIZED
 , CONSTRAINT TRAFODION."_MD_".OBJECTS_PK PRIMARY KEY (CATALOG_NAME ASC,
    SCHEMA_NAME ASC, OBJECT_NAME ASC, OBJECT_TYPE ASC)
  )
 ATTRIBUTES NAMESPACE 'TRAF_RSRVD_1' 
;

CREATE UNIQUE INDEX OBJECTS_UNIQ_IDX ON TRAFODION."_MD_".OBJECTS
  ( 
    OBJECT_UID ASC
  )
;

“_MD_”.objects中有两个字段CREATE_TIME及REDEF_TIME,分别表示创建时间和更新时间,它们的类型为largeint,需要使用CONVERTTIMESTAMP转换为时间戳,另外,转换后的时间戳为UETC时间,需要+8小时转换为CST时间。

因此,想查看一个表的创建时间和修改时间的方法如下,

SELECT  converttimestamp(create_time)+interval '8' HOUR AS create_time , 
        converttimestamp(redef_time)+interval '8' HOUR AS redef_time
FROM "_MD_".objects AS a WHERE a.object_name=;

如,

SQL>SELECT  converttimestamp(create_time)+interval '8' HOUR AS create_time , 
+>        converttimestamp(redef_time)+interval '8' HOUR AS redef_time
+>FROM "_MD_".objects AS a WHERE a.object_name='T_BUET_BUSINESSEVENT';

CREATE_TIME                REDEF_TIME                
-------------------------- --------------------------
2019-07-17 18:31:54.752077 2019-08-21 11:51:17.935288

--- 1 row(s) selected.

你可能感兴趣的:(大数据)