json应用 本文介绍天翼云TeleDB数据库json应用。 创建json 类型字段表 plaintext teledb create table tjson(id int,fjson json); CREATE TABLE 插入数据 plaintext teledb insert into tjson values(1,'{"col1":1,"col2":"teledb"}'); INSERT 0 1 teledb insert into tjson values(2,'{"col1":1,"col2":"teledb","col3":"pgxz"}'); INSERT 0 1 teledb select from tjson; id fjson + 1 {"col1":1,"col2":"teledb"} 2 {"col1":1,"col2":"teledb","col3":"pgxz"} (2 rows) 通过键获得json对象域 plaintext teledb select fjson >'col2' as col2 ,fjson > 'col3' as col3 from tjson; col2 col3 + "teledb" "teledb" "pgxz" (2 rows) 以文本形式获取对象值 plaintext teledb select fjson >>'col2' as col2 ,fjson >> 'col3' as col3 from tjson; col2 col3 + teledb teledb pgxz (2 rows) teledb select fjson >>'col2' as col2 ,fjson >> 'col3' as col3 from tjson where fjson >> 'col3' is not null; col2 col3 + teledb pgxz (1 row)