Skip to content
Discord Get Started

hstore — Key-Value

PostgreSQL-compatible key-value store type.

SQL
CREATE EXTENSION hstore;

Note: The hstore extension in DB9 is primarily for client compatibility. It allows PostgreSQL clients and ORMs that expect hstore support to connect without errors.

For key-value storage, consider using JSONB which offers richer functionality:

SQL
-- Recommended: Use JSONB for key-value data
CREATE TABLE settings (
id SERIAL PRIMARY KEY,
data JSONB
);
INSERT INTO settings (data) VALUES ('{"theme": "dark", "lang": "en"}');
-- Query JSONB
SELECT data->>'theme' FROM settings;