Dynamic Columns

来源:互联网 发布:php 返回上个页面 编辑:程序博客网 时间:2024/06/04 16:32

Dynamic Columns

specifying columns dynamically is now supported by allowing column definitions to included in parenthesis after the table in theFROM clause on a SELECT statement

通过允许列定义在SELECT语句的FROM子句后的括号中包含在括号中,可以动态地指定列

For example:

SELECT eventTime, lastGCTime, usedMemory, maxMemory

FROM EventLog(lastGCTime TIME, usedMemory BIGINT, maxMemory BIGINT)

WHERE eventType = 'OOM' AND lastGCTime < eventTime - 1


Where you may have defined only a subset of your event columns at create time, since each event type may have different properties:

CREATE TABLE EventLog (

    eventId BIGINT NOT NULL,

    eventTime TIME NOT NULL,

    eventType CHAR(3) 

    CONSTRAINT pk PRIMARY KEY (eventId, eventTime))

To upsert a row with dynamic columns:

UPSERT INTO EventLog (eventId, eventTime, eventType, lastGCTime TIME, usedMemory BIGINT, maxMemory BIGINT) VALUES(1, CURRENT_TIME(), ‘abc’, CURRENT_TIME(), 512, 1024);

原创粉丝点击