49
最近I went into trouble试图与Django一起使用hstore。我这样安装hstore:如何创建一个已安装hstore扩展的新数据库?
$ sudo -u postgres psql
postgres=# CREATE EXTENSION hstore;
WARNING: => is deprecated as an operator name
DETAIL: This name may be disallowed altogether in future versions of PostgreSQL.
CREATE EXTENSION
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
---------+---------+------------+--------------------------------------------------
hstore | 1.0 | public | data type for storing sets of (key, value) pairs
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(2 rows)
而天真地认为我的新数据库将包括hstore。这是不是这样的:
$ createdb dbtest
$ psql -d dbtest -c '\dx'
List of installed extensions
Name | Version | Schema | Description
---------+---------+------------+------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(1 row)
有没有一种方法可以自动hstore在新创建的数据库?
+1是正确的,并将其全部置于有用的格式中。有人可能会考虑使用与“template1”不同的数据库。任何数据库都可以作为模板:'CREATE DATABASE foo TEMPLATE mytemplate'。或者,一旦你在'template1'中有了额外的东西,你可以使用(默认为空)'template0'。 – 2012-07-20 19:48:07