Skip to content
Discord Get Started

hstore — Key-Value

hstore in DB9 is a metadata-only shimCREATE EXTENSION hstore succeeds and registers extension metadata, but the hstore type itself does not exist. Any attempt to use hstore as a column type or cast to hstore will fail with ERROR: type "hstore" does not exist.

For new code, use JSONB instead. JSONB provides a superset of hstore functionality with full operator support, better performance, and broad ecosystem support.

SQL
CREATE EXTENSION hstore;
FeatureSupported
CREATE EXTENSION hstoreYes — registers extension metadata only
hstore column typeNo — type "hstore" does not exist
Cast from textNo — 'key=>value'::hstore fails with type error
Basic key access (->)No — type does not exist
Containment (@>)No — type does not exist
FeatureStatusJSONB Alternative
%, ?, ?&, `?` operatorsNot supported
`hstorehstore` concatenation
hs - key deletionNot supportedjsonb - key
akeys(), avals(), hstore_to_array()Not supportedjsonb_object_keys(), jsonb_each()
hstore_to_json(), hstore_to_jsonb()Not supportedCast directly with ::jsonb
populate_record(), hstore_to_record()Not supportedjsonb_populate_record()
slice(), skeys(), svals()Not supportedjsonb operators

If you have existing code using hstore, JSONB provides equivalent functionality with full operator support:

SQL
-- hstore: CREATE TABLE with hstore column
-- JSONB equivalent:
CREATE TABLE settings (
id SERIAL PRIMARY KEY,
data JSONB
);
-- hstore: INSERT 'key=>value' syntax
-- JSONB equivalent:
INSERT INTO settings (data) VALUES ('{"theme": "dark", "lang": "en"}');
-- hstore: data->'key' (returns TEXT)
-- JSONB equivalent:
SELECT data->>'theme' FROM settings;
-- Returns: 'dark'
-- hstore: data @> 'key=>value'
-- JSONB equivalent:
SELECT * FROM settings WHERE data @> '{"theme": "dark"}';
-- hstore: delete a key data - 'key'
-- JSONB equivalent:
UPDATE settings SET data = data - 'theme';
-- hstore: get all keys akeys(data)
-- JSONB equivalent:
SELECT jsonb_object_keys(data) FROM settings;
Featurehstore (DB9)JSONB
Key-value storageNot available (type missing)Full support
Nested valuesNoYes
Operator supportNoneFull
GIN indexingNoYes
Schema validationNoYes (check constraints)
Ecosystem supportLimitedUniversal
LimitValue
hstore typeDoes not exist — metadata shim only
Operators availableNone — type does not exist
Recommended alternativeJSONB — full operator support