Kingbase hstore扩展插件使用

1. 插件hstore简介

hstore支持hstore类型及其相关的函数。

  • 插件名为hstore

  • 插件版本 V1.0

2. 插件hstore加载方式

使用时需要create extension hstore。

示例:

create extension hstore;

注意

创建扩展前,需要关闭禁用多态函数参数,执行'set ora_forbid_func_polymorphism to off;' 。

3. 插件hstore参数配置

无需配置任何参数。

4. 插件hstore使用方法

4.1. hstore类型

字符串的一种,可以将字符串与'=>'进行单元分割重组形成新的字符串。

示例

select ''::hstore;
 hstore
--------

(1 row)

select 'a=>b'::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select ' a=>b'::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select 'a =>b'::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select 'a=>b '::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select 'a=> b'::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select '"a"=>"b"'::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select ' "a"=>"b"'::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select '"a" =>"b"'::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select '"a"=>"b" '::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select '"a"=> "b"'::hstore;
  hstore
----------
 "a"=>"b"
(1 row)

select 'aa=>bb'::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select ' aa=>bb'::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select 'aa =>bb'::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select 'aa=>bb '::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select 'aa=> bb'::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select '"aa"=>"bb"'::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select ' "aa"=>"bb"'::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select '"aa" =>"bb"'::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select '"aa"=>"bb" '::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select '"aa"=> "bb"'::hstore;
   hstore
------------
 "aa"=>"bb"
(1 row)

select 'aa=>bb, cc=>dd'::hstore;
                 hstore
------------------------
 "aa"=>"bb", "cc"=>"dd"
(1 row)

select 'aa=>bb , cc=>dd'::hstore;
                 hstore
------------------------
 "aa"=>"bb", "cc"=>"dd"
(1 row)

select 'aa=>bb ,cc=>dd'::hstore;
                 hstore
------------------------
 "aa"=>"bb", "cc"=>"dd"
(1 row)

select 'aa=>bb, "cc"=>dd'::hstore;
                 hstore
------------------------
 "aa"=>"bb", "cc"=>"dd"
(1 row)

select 'aa=>bb , "cc"=>dd'::hstore;
                 hstore
------------------------
 "aa"=>"bb", "cc"=>"dd"
(1 row)

select 'aa=>bb ,"cc"=>dd'::hstore;
                 hstore
------------------------
 "aa"=>"bb", "cc"=>"dd"
(1 row)

select 'aa=>"bb", cc=>dd'::hstore;
                 hstore
------------------------
 "aa"=>"bb", "cc"=>"dd"
(1 row)

select 'aa=>"bb" , cc=>dd'::hstore;
                 hstore
------------------------
 "aa"=>"bb", "cc"=>"dd"
(1 row)

select 'aa=>"bb" ,cc=>dd'::hstore;
                 hstore
------------------------
 "aa"=>"bb", "cc"=>"dd"
(1 row)

select 'aa=>null'::hstore;
   hstore
------------
 "aa"=>NULL
(1 row)

select 'aa=>NuLl'::hstore;
   hstore
------------
 "aa"=>NULL
(1 row)

select 'aa=>"NuLl"'::hstore;
        hstore
--------------
 "aa"=>"NuLl"
(1 row)

select e'\\=a=>q=w'::hstore;
   hstore
-------------
 "=a"=>"q=w"
(1 row)

select e'"=a"=>q\\=w'::hstore;
   hstore
-------------
 "=a"=>"q=w"
(1 row)

select e'"\\"a"=>q>w'::hstore;
        hstore
--------------
 "\"a"=>"q>w"
(1 row)

4.2. hstore_to_jsonb

将hstore类型转换为jsonb类型。

语法

hstore_to_jsonb(hstore) returns jsonb。

示例

select hstore_to_jsonb('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
                                                                                 hstore_to_jsonb
-------------------------------------------------------------------------------------------------
 {"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
(1 row)

4.3. hstore_to_json

将hstore转换为json类型。

语法

hstore_to_json(hstore) returns json。

示例

select hstore_to_json('"a key" =>1, b => t, c => null, d=> 12345, e => 012345, f=> 1.234, g=> 2.345e+4');
                                                                                 hstore_to_json
-------------------------------------------------------------------------------------------------
 {"b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4", "a key": "1"}
(1 row)

5. 插件hstore卸载方法

不需要hstore插件只需要卸载插件即可。

示例:

drop extension hstore;

6. 插件hstore升级方法

hstore扩展插件通常随KingbaseES安装包一并升级。通常情况下用户无法单独升级插件。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值