Adding an extension in PostgreSQL

From EN Ikoula wiki
Revision as of 09:57, 8 July 2021 by Ikbot (talk | contribs)
⧼vector-jumptonavigation⧽ ⧼vector-jumptosearch⧽

es:Añadir una extensión en PostgreSQL fr:Ajouter une extension en PostgreSQL
This article has been created by an automatic translation software. You can view the article source here.

Introduction

This page deals with adding an extension to a PostgreSQL database.

Connecting to PostgreSQL

We switch to the postgres user and then connect to the PostgreSQL database test:

# su - postgres
postgres@vm-postgres:~$ psql -d test
psql (9.1.24lts2)
Saisissez « help » pour l aide.

test=#

We check the extensions currently present:

test=# \dx
                          Liste des extensions installées
    Nom    | Version |   Schéma   |                   Description
-----------+---------+------------+-------------------------------------------------
 plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
(1 ligne)

Adding an extension

We will, for example, add the extension unaccent (a function that allows, among other things, to remove accents):

test=# CREATE EXTENSION IF NOT EXISTS "unaccent";
CREATE EXTENSION

We check that it is in place:

test=# \dx
                          Liste des extensions installées
    Nom    | Version |   Schéma   |                   Description
-----------+---------+------------+-------------------------------------------------
 plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
 unaccent  | 1.0     | public     | text search dictionary that removes accents
(2 lignes)

We can also check that it is functional, for example:

test=# SELECT unaccent('Hôtel');
 unaccent
----------
 Hotel
(1 ligne)

The word Hotel is returned without a circumflex accent.




Cet article vous a semblé utile ?

0



You are not allowed to post comments.