hstore> Functions
|
akeys(hstore)
text[]
- get hstore>'s keys as array
+ get hstore>'s keys as an array
akeys('a=>1,b=>2')
{a,b}
|
skeys(hstore)
setof text
- get hstore>'s keys as set
+ get hstore>'s keys as a set
skeys('a=>1,b=>2')
a
b
|
avals(hstore)
text[]
- get hstore>'s values as array
+ get hstore>'s values as an array
avals('a=>1,b=>2')
{1,2}
|
svals(hstore)
setof text
- get hstore>'s values as set
+ get hstore>'s values as a set
svals('a=>1,b=>2')
|
each(hstore)
- setof (key text, value text)
- get hstore>'s keys and values as set
+ setof(key text, value text)
+ get hstore>'s keys and values as a set
select * from each('a=>1,b=>2')
|
defined(hstore,text)
boolean
- does hstore> contain non-null value for key?
+ does hstore> contain non-NULL> value for key?
defined('a=>NULL','a')
f
|
delete(hstore,text)
hstore
- delete any item matching key
+ delete pair with matching key
delete('a=>1,b=>2','b')
"a"=>"1"
|
delete(hstore,text[])
hstore
- delete any item matching any of the keys
+ delete pairs with matching keys
delete('a=>1,b=>2,c=>3',ARRAY['a','b'])
"c"=>"3"
|
delete(hstore,hstore)
hstore
- delete any key/value pair with an exact match in the second argument
+ delete pairs matching those in the second argument
delete('a=>1,b=>2','a=>4,b=>2'::hstore)
"a"=>"1"
|
populate_record(record,hstore)
record
- replace fields in record with matching values from hstore
+ replace fields in record> with matching values from hstore>
see Examples section
The function populate_record is actually declared
- with anyelement>, not record>, as its first argument;
+ with anyelement>, not record>, as its first argument,
but it will reject non-record types with a runtime error.
Indexes
- hstore> has index support for @>>, ?>,
- ?&> and ?|> operators. You can use either
- GiST or GIN index types. For example:
+ hstore> has GiST and GIN index support for the @>>,
+ ?>, ?&> and ?|> operators. For example:
CREATE INDEX hidx ON testhstore USING GIST (h);
- Additionally, hstore> has index support for the =>
- operator using the btree> or hash> index types. This
- allows hstore> columns to be declared UNIQUE, or used with
- GROUP BY, ORDER BY or DISTINCT. The sort ordering for hstore>
- values is not intended to be particularly useful; it merely brings
- exactly equal values together.
- If an index is needed to support => comparisons it can be
- created as follows:
+ hstore> also supports btree> or hash> indexes for
+ the => operator. This allows hstore> columns to be
+ declared UNIQUE>, or to be used in GROUP BY>,
+ ORDER BY> or DISTINCT> expressions. The sort ordering
+ for hstore> values is not particularly useful, but these indexes
+ may be useful for equivalence lookups. Create indexes for =>
+ comparisons as follows:
CREATE INDEX hidx ON testhstore USING BTREE (h);
Add a key, or update an existing key with a new value:
-UPDATE tab SET h = h || ('c' => '3');
+UPDATE tab SET h = h || ('c' => '3');
- Convert a record to an hstore:
+ Convert a record> to an hstore>:
CREATE TABLE test (col1 integer, col2 text, col3 text);
SELECT hstore(t) FROM test AS t;
hstore
---------------------------------------------
- "col1"=>"123", "col2"=>"foo", "col3"=>"bar"
+ "col1"=>"123", "col2"=>"foo", "col3"=>"bar"
(1 row)
- Convert an hstore to a predefined record type:
+ Convert an hstore> to a predefined record> type:
CREATE TABLE test (col1 integer, col2 text, col3 text);
SELECT * FROM populate_record(null::test,
- '"col1"=>"456", "col2"=>"zzz"');
+ '"col1"=>"456", "col2"=>"zzz"');
col1 | col2 | col3
------+------+------
456 | zzz |
- Modify an existing record using the values from an hstore:
+ Modify an existing record using the values from an hstore>:
CREATE TABLE test (col1 integer, col2 text, col3 text);
INSERT INTO test VALUES (123, 'foo', 'bar');
-SELECT (r).* FROM (SELECT t #= '"col3"=>"baz"' AS r FROM test t) s;
+SELECT (r).* FROM (SELECT t #= '"col3"=>"baz"' AS r FROM test t) s;
col1 | col2 | col3
------+------+------
123 | foo | baz
The hstore> type, because of its intrinsic liberality, could
contain a lot of different keys. Checking for valid keys is the task of the
- application. Examples below demonstrate several techniques for checking
- keys and obtaining statistics.
+ application. The following examples demonstrate several techniques for
+ checking keys and obtaining statistics.
Simple example:
-SELECT * FROM each('aaa=>bq, b=>NULL, ""=>1');
+SELECT * FROM each('aaa=>bq, b=>NULL, ""=>1');
When upgrading from older versions, always load the new
- version of this module into the database before restoring an old
- dump. Otherwise, many new features will be unavailable.
+ version of this module into the database before restoring a dump.
+ Otherwise, many new features will be unavailable.
- In the event of doing a binary upgrade, upward
- compatibility is maintained by having the new code recognize
- old-format data. This will entail a slight performance penalty when
- processing data that has not yet been modified by the new code. It is
- possible to force an upgrade of all values in a table column
- by doing an UPDATE statement as follows:
+ In the event of a binary upgrade, upward compatibility is maintained by
+ having the new code recognize old-format data. This will entail a slight
+ performance penalty when processing data that has not yet been modified by
+ the new code. It is possible to force an upgrade of all values in a table
+ column by doing an UPDATE> statement as follows:
UPDATE tablename SET hstorecol = hstorecol || '';
+ United Kingdom