Database Reference
In-Depth Information
HStore
The HStore extension stores data in key and value format. It is a data structure consisting
of a non-ordered set of items formed by a key-value pair, in which each key has an associ-
ated value. The HStore data type is useful because it allows their use in queries.
In the following example, you will create a new table called profiles and store a data key /
value in the configs column.
$ heroku pg:psql --app your-app-name
CREATE EXTENSION hstore;
CREATE TABLE profiles (configs hstore);
INSERT INTO profiles (configs) VALUES ('resolution =>
"1024x768", brightness => 45');
This data type has a limitation where all their data is stored in string format. You can see
that if you perform a SELECT query:
SELECT * FROM profiles;
configs
----------------------------------------------
"brightness"=>"45", "resolution"=>"1024x768"
Finally, you are able to find records using the configs key-value data:
SELECT * FROM profiles WHERE configs->'resolution' =
'1024x768';
configs
----------------------------------------------
"brightness"=>"45", "resolution"=>"1024x768"
There are numerous possibilities of using the HStore extension and you can find more in-
formation in the PostgreSQL documentation http://www.postgresql.org/docs/current/static/
hstore.html .
Search WWH ::




Custom Search