Key value pair in PostgreSQL [closed]

◇◆丶佛笑我妖孽 提交于 2019-11-28 10:56:29

问题


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

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.

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


回答1:


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

CREATE EXTENSION hstore;

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

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



来源:https://stackoverflow.com/questions/15032540/key-value-pair-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!