我的样本表:
表名
Code | Name | Location ---- (Table Column)
C001 | John | China
C002 | Joy | Taiwan
B001 | Carl | Turkey
结果:该列将作为具有其值的行。
Code | C001
Name | John
Location | China
我需要像在SQL中一样对postgreSQL进行示例查询 - > STUFF功能。
答案 0 :(得分:0)
尝试一下:
SELECT key, value
FROM (
SELECT row_to_json (t.*) AS line
FROM table_name t
) AS r
CROSS JOIN LATERAL json_each_text (r.line);
参考HERE