Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

PostgreSQL - Get started

How to provision PostgreSQL?

1

Open your Global Service

In ITCare, search your target Global Service in the top search bar and click on it to display its information page.

2

Select PostgreSQL

Click the Create a resource button, go to Managed databases and select PostgreSQL. Pick the required version.

3

Fill in the form

Fill in the form then click Next. Select your customizations and click Next.

4

Submit the request

Review the synthesis before submitting the form.

Provisioning can take up to 2 hours based on the current load on automation.

Once the deployment is ready, you will be notified by email.

How to manage your PostgreSQL?

On the resource page of your PostgreSQL, you can take any action available by using the Manage button in the upper right corner. This includes, starting, stopping, deleting, rebooting, resizing and much more.

How to access your PostgreSQL deployment?

When your deployment is created with cegedim.cloud ITCare, you obtained a SQL role named "admin" with credentials.

With these credentials, you may connect to the deployment with its name on tcp port 5432. You may use the postgres database to connect to.

If your deployment is named "mycluster", here is an example on how to connect using Python:

import psycopg2

# Connect to the postgres database
conn = psycopg2.connect(database='postgres', user='myuser', password='mystrongpwd', host='mycluster.pg.cegedim.cloud')
# Open a cursor to perform database operations
cursor = conn.cursor()
# Execute a query
cursor.execute("SELECT datname from pg_database")
# Retrieve query results
records = cursor.fetchall()
# Print all results
for record in records:
  print(record)

If you choose to activate TLS, you have received the root certificate you should trust and give to the library you use to connect, for example psycopg2.

import psycopg2

# Connect to the postgres database
conn = psycopg2.connect(database='postgres', user='myuser', password='mystrongpwd', host='mycluster.pg.cegedim.cloud', sslmode='verify-full', sslrootcert='cegedimcloud.pg.crt')
# Open a cursor to perform database operations
cursor = conn.cursor()
# Execute a query
cursor.execute("SELECT datname from pg_database")
# Retrieve query results
records = cursor.fetchall()
# Print all results
for record in records:
  print(record)

How to create a role?

It is safer not to use the admin role for applications.

Once connected, you may create a regular role as the following (replace <a_role> and <very_strong_password> with your own credentials)

How to create a database?

If you want to create a database owned by the role you have just created, use the following SQL statements:

How to create a database with another encoding and/or collation?

You may use the following SQL requests with template0 database as template database:

How to restore in self-service?

The PostgreSQL PaaS has a functionality allowing to restore a PostgreSQL PaaS (source) to another PostgreSQL PaaS (destination) at a given time (using Point-In-Time Recovery) under the following constraints:

  • the user must have access to the cloud of the source deployment and the destination deployment

  • the source must be backed up (option chosen during creation)

  • both source and destination must be active

  • the source and destination must be different

  • the source and destination must be in the same version of PostgreSQL

  • the source and destination must be in version 12 or higher

  • the target time must not be in the future (bounded on the right by the current time).

  • the target time must not be more than 7 days (for non-production services) or 14 days (for production services) in the past (bounded on the left by the retention of backups)

You can choose to include or exclude the time target in the restoration process.

How to install the oracle_fdw extension?

You can install the oracle_fdw extension on your databases. This extension allows you to connect to a PostgreSQL deployment and read/write tables that are actually located on an Oracle server. To do this, using ITCare, go to the Manage menu, then Manage Extensions, select your database, then oracle_fdw, and click the Submit button. Remember that according to best practices, you have created a role and a dedicated database:

Once the extension is installed, you must create several objects in the database. You must have the following items to perform this operation:

  • the username and password for the account (admin) that was provided to you when you created your PostgreSQL deployment.

  • the role that will connect to the PostgreSQL database and access the Oracle database

  • The SID of the Oracle database

  • The username and password for the role that has the right to connect to the Oracle database and read/write the tables in question.

  • The name and definition of the Oracle tables

Example: the Oracle table used below

For the rest of this example, we will assume that a table has been created in Oracle as follows:

Using your admin account on the customer database, you must create a mapping between your Oracle server, the Oracle database, and the Oracle role (the role that created the person table, for example)

Finally, with the myrole role, connected to the customer database (in PostgreSQL):

Fix an incorrect server or user mapping

If an error occurs when declaring the correspondences between the server and the Oracle role, the admin role can make the following changes:

The documentation for the oracle_fdw extension is available here.

How to install the postgres_fdw extension?

You can install the postgres_fdw extension on your databases. This extension allows you to read/write tables located in another PostgreSQL deployment. To do this, using ITCare, go to the Manage menu, then Manage Extensions on your pg16 deployment, select your database, then postgres_fdw, and click the Submit button. Remember that according to best practices, you have created a role and a dedicated database on each of the PostgreSQL deployments:

Example: create the test data on pg15

On the pg15 server in version 15, for example (pg15.pg.cegedim.cloud)

On the pg16 server (pg16.pg.cegedim.cloud):

With the admin role on the customer database of the pg16 deployment, create the mappings with the pg15 server and the rolea role:

With the roleb role on the pg16 deployment, customer database, import the definition of the mytable table:

Last updated