全部產品
Search
文件中心

ApsaraDB RDS:ST_AsTableFormat

更新時間:Feb 28, 2024

擷取一條軌跡的定義,用於在ST_AsTable函數中指定列類型。

文法

text ST_AsTableFormat(trajectory traj);

參數

參數名稱

描述

traj

原始軌跡。

描述

此函數用於擷取一條軌跡的定義,並以文本的形式輸出Record type,在ST_AsTable函數將一條軌跡轉化成表時被使用。

例如:如果需要將一個軌跡轉化成表,則先通過此函數獲得其定義為(t timestamp, x double precision, y double precision, sog real, cog integer, hdg integer, rot integer, status integer, is_satelite smallint, statictime integer),再通過下列語句,將軌跡轉化為擁有特定列的表格。

SELECT f.* FROM table_name, ST_AsTable(traj) AS f(t timestamp, x double precision, y double precision, sog real, cog integer, hdg integer, rot integer, status integer, is_satelite smallint, statictime integer);

樣本

SELECT ST_AsTableFormat('{"trajectory":{"version":1,"type":"STPOINT","leafcount":1,"start_time":"2010-01-01 11:30:00","end_time":"2010-01-01 11:30:00","spatial":"SRID=4326;POINT(1 1)","timeline":["2010-01-01 11:30:00"],"attributes":{"leafcount":1,"i1":{"type":"integer","length":1,"nullable":true,"value":[1]},"i2":{"type":"integer","length":2,"nullable":true,"value":[1]},"i4":{"type":"integer","length":4,"nullable":true,"value":[1]},"i8":{"type":"integer","length":8,"nullable":true,"value":[1]}, "f4":{"type":"float","length":4,"nullable":true,"value":[1]},"f8":{"type":"float","length":8,"nullable":true,"value":[1]},"string":{"type":"string","length":10,"nullable":true,"value":["fat"]},"timestamp":{"type":"timestamp","length":8,"nullable":true,"value":["2010-01-01 11:30:00"]},"bool":{"type":"bool","length":1,"nullable":true,"value":["true"]}}}}'::trajectory);
-----
(t timestamp, x double precision, y double precision, i1 integer, i2 smallint, i4 integer, i8 bigint, f4 real, f8 double precision, string text, timestamp timestamp, bool boolean)