Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
989 views
in Technique[技术] by (71.8m points)

postgresql - How do I import modules or install extensions in Postgres 8.4?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

  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
    
  6. Load the SQL files using: psql -U user_name -d database_name -f module_name.sql

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

PostgreSQL 9.1:

After step #1 above, do:

  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";

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...