hstore数据类型
来源:互联网 发布:券商工资知乎 编辑:程序博客网 时间:2024/06/06 11:00
hstore数据类型作为扩展模块,用来存储具有多个属性值的数据,一种Postgres内置的键值对结构的数据类型
1,开启hstore:
Create extension hstore;
2,创建一个hstore字段:在创建表是只要指定这个字段的数据类型为hstore就可以了:
CREATE TABLE products (
id serial PRIMARY KEY,
name varchar,
attributes hstore
);
3,插入数据:把字段的值用单引号包含一来, 不同的就是要知道创建字典的一些额外的结构:
INSERT INTO products (name, attributes) VALUES (
'Geek Love: A Novel',
'author => "Katherine Dunn",
pages => 368,
category => fiction'
);
4,读取数据:
SELECT name, attributes->'pages' as pages
FROM products
WHERE attributes->'pages'= '368'
结果:
几种方法获取hstore的值:
方式1>:
SELECT 字段名->'xxxx' FROM tablename;
方式2>:
SELECT 字段名 FROM tablename;
如下操作可以将hstore类型转php数组:
$xxx = json_decode('{'.str_replace('=>',':',$xxx['字段名']).'}',true);
方式3>:
explode() 也可以将hstore类型转变成php数组
- hstore数据类型
- PostgreSQL: hstore 数据类型使用介绍
- postgresql hstore用法
- PostgreSQL,Hibernate,hstore
- HBase source code. HStore
- PostgreSQL安装hstore
- PostgreSQL的hstore初步学习
- PostgreSQL的hstore初步学习
- PostgreSQL hstore 列性能提升一例
- permission denied to create extension "hstore"解决方案
- 【ubuntu】Ubuntu 安装postgreSQL以及图形界面pgadmin3,hstore
- 【PostgreSQL】PostgreSQL hstore类型数据增删改查
- HBase的Hmaster、HRegionserver、Region、Hstore、memstore、HFile的关系
- 数据类型
- 数据类型
- 数据类型
- 数据类型
- 数据类型
- 第五章 虚拟存储器介绍
- weka: 生成并保存ARFF格式数据
- JavaBeans vs Spring beans vs POJOs
- memcached—认识Memcache
- Sql Server数据库 002—sql server 2008 r2 连接字符串
- hstore数据类型
- 第十六周 项目二 (1) 字符串连接
- TIM配置
- VS编译器
- Go语言
- 扑克牌
- 第十五周OJ项目2:指针当形参
- Android导入其他工程时报错的解决方法探索
- Free PPTP VPN