您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PostgreSQL 9.2中的json存储表示和检索

2024/3/3 18:16:54发布23次查看
postgresql 9.2中的json存储表示和检索 其解决方案就是使用hstore类型,使用它,先得创建对应的扩展。 www.2cto.com 下面只列出简单的使用示例: iihero=# create extension hstore; create extension iihero=# iihero=# select a=1,b=2::hstore; hstore ---
postgresql 9.2中的json存储表示和检索
其解决方案就是使用hstore类型,使用它,先得创建对应的扩展。
  www.2cto.com  
下面只列出简单的使用示例:
iihero=# create extension hstore;
create extension
iihero=#
iihero=# select 'a=>1,b=>2'::hstore;
  hstore
--------------------
 a=>1, b=>2
(1 row)
iihero=# insert into tjson values(1, 'a=>1, b=>2, c=>3'::hstore);
insert 0 1
iihero=# insert into tjson values(2, 'a=>2, b=>3, c=>4'::hstore);
insert 0 1
iihero=# select * from tjson where col2 @>'a=>1';
 id | col2
----+------------------------------
  1 | a=>1, b=>2, c=>3
(1 row)
iihero=# select * from tjson where col2 @>'a=>1' and col2 @>'b=>2';
 id | col2
----+------------------------------
  1 | a=>1, b=>2, c=>3
(1 row)
所不同的,只是语法表现形式的不同。还可以充分利用索引。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product