如何在 Postgres 9.3 上安装/启用 uuid-ossp 扩展?

Dav*_*ave 8 postgresql postgresql-9.3 uuid postgresql-extensions

我在 Ubuntu Linux 14.04 上使用 Postgres 9.3。如何安装/启用 uuid-ossp 扩展?我首先验证了 contrib 包是否已安装……

root@prodbox:/home/rails/myproject# apt-get install postgresql-contrib
Reading package lists... Done
Building dependency tree       
Reading state information... Done
postgresql-contrib is already the newest version.
Run Code Online (Sandbox Code Playgroud)

然后我登录并尝试创建扩展...

root@prodbox:/home/rails/myproject# su - postgres
postgres@prodbox:~$ psql
psql (9.6.0, server 9.3.11)
Type "help" for help.

postgres=# CREATE EXTENSION "uuid-ossp";
ERROR:  could not open extension control file "/usr/share/postgresql/9.3/extension/uuid-ossp.control": No such file or directory
Run Code Online (Sandbox Code Playgroud)

我都没有想法了。我错过了什么?

dez*_*zso 5

您似乎安装了两个版本(9.6 和 9.3)(因为psql版本是 9.6)。因为该postgresql-contrib包自动默认为当前支持的 PostgreSQL 数据库 contrib 包(如您执行 apt-cache show postgresql-contrib 时所述),所以您必须安装 9.3 的 contrib 包:

apt-get install postgresql-contrib-9.3
Run Code Online (Sandbox Code Playgroud)