如何在Postgres 8.4中导入模块或安装扩展? [英] How do I import modules or install extensions in Postgres 8.4?

查看:243
本文介绍了如何在Postgres 8.4中导入模块或安装扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导入与8.4.1 postgres捆绑在一起的几个模块,并且所有这样做的命令(例如contrib.import等)都不起作用或找不到。请帮助我。

I'm trying to import several modules that come bundled with 8.4.1 postgres, and all the commands to do so (such as contrib.import etc) do not work or cannot be found. Please help me.

推荐答案

在Ubuntu上安装PostgreSQL contrib 模块或Kubuntu(或类似的Linux发行版):

To install PostgreSQL contrib modules on Ubuntu or Kubuntu (or similar Linux distributions):


  1. 安装contrib包:
    sudo apt-get install postgresql-contrib

  2. 重启数据库:
    sudo /etc/init.d/postgresql-8.4 restart

  3. 更改为数据库所有者帐户(例如, postgres )。

  4. 切换到contrib模块的目录:
    /usr/share/postgresql/8.4/contrib /

  5. 使用 ls 查看以下模块的列表:

  1. Install the contrib package: sudo apt-get install postgresql-contrib
  2. Restart the database: sudo /etc/init.d/postgresql-8.4 restart
  3. Change to the database owner account (e.g., postgres).
  4. Change to the contrib modules' directory: /usr/share/postgresql/8.4/contrib/
  5. Use ls to see a list of the following modules:


adminpack               autoinc
btree_gin               btree_gist
chkpass                 citext
cube                    dblink
dict_int                dict_xsyn
earthdistance           fuzzystrmatch
hstore                  insert_username
int_aggregate           isn
lo                      ltree
moddatetime             pageinspect
pg_buffercache          pgcrypto
pg_freespacemap         pgrowlocks
pg_stat_statements      pgstattuple
pg_trgm                 pgxml
refint                  seg
sslinfo                 tablefunc
test_parser             timetravel
tsearch2                uuid-ossp


  • 使用以下命令加载SQL文件:
    psql - U user_name -d database_name -f module_name.sql

    例如,如果您的管理用户名为 postgres ,您的数据库名为 storage ,您想要的模块是 cube ,你输入:

    For example, if your administrative user was named postgres and your database was named storage and the module you wanted was cube, you would type:

    psql -U postgres -d storage -f cube.sql
    



    PostgresSQL 9.1:



    在上面的步骤#1之后,执行:

    PostgresSQL 9.1:

    After step #1 above, do:


    1. sudo /etc/init.d/postgresql restart

    2. (与上面#3相同)

    3. cd /usr/share/postgresql/9.1/extension (有扩展名)

    4. 打开 psql

    5. CREATE EXTENSIONuuid-ossp;

    1. sudo /etc/init.d/postgresql restart
    2. (same as #3 above)
    3. cd /usr/share/postgresql/9.1/extension (has extensions)
    4. open psql
    5. CREATE EXTENSION "uuid-ossp";

    这篇关于如何在Postgres 8.4中导入模块或安装扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆