需要帮助将列中的日期值拆分为新列

时间:2017-12-03 18:56:52

标签: sql sql-server oracle

我在我的一张表中列出了以下列。

DB_Attribute
Attributes: ServerId=300000049436:DBCOP01; CountryCode=HK; Environment=LIVE; 
ServerName=BCOINST@HK000HSP2717; ServerStatus=ACTIVE; ViewPointName=DBA HTSA HASE; 
LifecycleStatus=Active; assetGroup=bcoinst; BusinessCriticality=TIER 2; GSDServiceCount=1; 
HSBCLocation=HK HHQ; DBCount=1; GSDServiceName=HASE-BCO; LastChange=2017/10/29  20:00:01; DBTimeStamp=2017/10/29

Attributes: ViewPointName=DBA HTSA - DB2; BusinessCriticality=TIER 2; 
ServerId=300000027610:VNPRD1HF; HSBCLocation=HK TKO; Environment=LIVE; LifecycleStatus=Active; 
assetGroup=ap4vnpu1; DBCount=1; GSDServiceCount=2; DBTimeStamp=2017/10/29; 
GSDServiceName=VNM AAPS4; ServerStatus=ACTIVE; LastChange=2017/10/29  20:00:01; ServerName=AP4VNPU1@HKP02LP2311; CountryCode=HK

Attributes: ServerId=300000028881:KWTAS; CountryCode=HK; DBTimeStamp=2017/10/29; 
LastChange=2017/10/29  20:00:01; LifecycleStatus=Active; DBCount=1; HSBCLocation=HK TKO; 
ViewPointName=DBA HTSA - DB2; Environment=LIVE; BusinessCriticality=TIER 2; GSDServiceName=GWIS KWT; 
ServerStatus=ACTIVE; ServerName=DB2IKWTA@HKPA2LS0024; GSDServiceCount=1

Attributes: DBTimeStamp=2017/07/12; LifecycleStatus=Active; DBCount=3; 
Environment=LIVE; LastChange=2017/07/13  20:00:02; ServerId=300000027589:VNVNP3JL; 
BusinessCriticality=TIER 1; GSDServiceCount=0; ServerStatus=ACTIVE; CountryCode=HK; HSBCLocation=HK TKO; 
GSDServiceName=VNM HFE2; ViewPointName=DBA HTSA - DB2; ServerName=HFEVNPU2@HKP02LP0620

Attributes: ServerStatus=ACTIVE; Environment=LIVE; GSDServiceName=JPM HFE2; 
LastChange=2017/10/29  20:00:01; ServerId=300000027592:JPJPP3HF; LifecycleStatus=Active; 
ServerName=HFEJPPU1@HKP02LP0720; BusinessCriticality=TIER 2; GSDServiceCount=1; HSBCLocation=HK TKO; 
CountryCode=HK; DBCount=3; ViewPointName=DBA HTSA - DB2; DBTimeStamp=2017/10/29

从上面的 DB_Attribute 列中,您可以看到有一个名为 DBTimeStamp 的值,现在我的要求是我正在寻找一个查询来放置 DBTimeStamp 进入新专栏。

此致

维卡斯

1 个答案:

答案 0 :(得分:0)

在oracle中尝试使用函数REGEXP_SUBSTR通过正则表达式获取 DBTimeStamp

示例:

SELECT REGEXP_SUBSTR ('Example text in database column', '(\S*)(\s)')
FROM dual;

结果是'示例'

Oracle doc:https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions131.htm