PostgreSQL中的键值对 [英] Key value pair in PostgreSQL

查看:436
本文介绍了PostgreSQL中的键值对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将键值对保存在PostgreSQL数据库中,该数据库将具有有关记录的一些基本信息。

I need to save key value pairs in PostgreSQL database which will have some basic info regarding the record.

在对该主题进行了一些搜索之后,我发现 hstore 是其中一种选择。但是即使阅读了文档之后,我仍然无法弄清楚如何在具有 hstore 列的表中添加记录,以及如何在结果中返回它们以及如何可以解析它。

After some googling on the topic I found out hstore is one of the options. But even after going through the documentation I am not able to figure out how to add records in a table with a hstore column and also how they are returned in the result and how I can parse it.

我对PostgreSQL完全陌生,所以任何代码参考都很棒。

I am totally new to PostgreSQL so any code reference will be great.

推荐答案

您需要安装其他模块 hstore ,然后才能使用它。每个数据库一次:

You need to install the additional module hstore before you can use it. Once per database:

CREATE EXTENSION hstore;

创建扩展 已在Postgres 9.1中引入。较旧的版本还有其他方法。

CREATE EXTENSION has been introduced with Postgres 9.1. Older versions have other methods.

详细了解 EAV (实体属性值)存储在其中的优缺点(很多)此相关问题od dba.SE 下的RDBMS。

Read more about the pros and (many) cons of EAV (Entity-Attribute-Value) storage in an RDBMS under this related question od dba.SE.

这篇关于PostgreSQL中的键值对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆