Database Reference
In-Depth Information
Step 2: Installing into a database (version 9.1 and later)
The new extension support makes installation much simpler and more consistent. Use
the CREATE EXTENSION command to install extensions into each database. The three big
benefits are that you don't have to figure out where the extension files are kept ( share/
extension ), you can uninstall them just as easily with DROP EXTENSION , and you have a
readily available listing of what is installed and what is available. PostgreSQL installation
packages include the most popular extensions, so you really don't need to do more than
run the command. To retrieve extensions not packaged with PostgreSQL, visit the
PostgreSQL Extension Network .
Here is how we would install the fuzzystrmatch extension using a query:
CREATE EXTENSION fuzzystrmatch ;
You can still install an extension noninteractively using psql. Make sure you're connec‐
ted to the database where you need the extension, then run a command such as:
psql -p 5432 -d mydb -c "CREATE EXTENSION fuzzystrmatch;"
C-based extensions must be installed by a superuser. Most exten‐
sions fall into this genre.
We suggest you create one or more schemas to house extensions to keep them separate
from production data. After you create the schema, install extensions into it through a
command like:
CREATE EXTENSION fuzzystrmatch SCHEMA my_extensions ;
Upgrading to the new extension model
If you've been using a version of PostgreSQL older than 9.1 and restored your old da‐
tabase into version 9.1 or later during a version upgrade, all extensions should continue
to function without intervention. For maintainability, you should upgrade your old
extensions in the contrib folder to use the new approach to extensions. You can upgrade
extensions, especially the ones that come packaged with PostgreSQL, from the old con‐
trib model to the new one. Remember that we're referring only to the upgrade in the
installation model, not to the extension itself.
For example, suppose you had installed the tablefunc extension (for cross-tab queries)
to your PostgreSQL 9.0 in a schema called contrib , and you've just restored your da‐
tabase to a 9.1 server. Run the following command to upgrade:
CREATE EXTENSION tablefunc SCHEMA contrib FROM unpackaged ;
Search WWH ::




Custom Search