Shows how to provision, connect to, and query a PostgreSQL database instance hosted on Oracle Cloud Infrastructure (OCI).
Use Oracle Cloud’s "PostgreSQL Database" service. It deploys a managed instance in minutes, handles backups, patching, and high-availability.
1. Log in to OCI.
2. Navigate to Databases ▶ PostgreSQL.
3. Click Create Cluster, choose region, shape, version, and admin password.
4.Click Create; note the public endpoint once provisioning finishes.
Open port 5432 in the VCN security list, install the PostgreSQL client locally, then run:psql "host=<public-ip> user=admin dbname=postgres password=<password> sslmode=require"
Create common ecommerce tables so you can test quickly.The syntax section below shows full DDL.
After loading sample data, run analytical queries such as total sales by customer or low-stock products.
• Enable automated backups and point-in-time recovery.
• Place the DB in a private subnet and access through a bastion host.
• Turn on automatic minor-version patching.
• Scale read replicas instead of vertical scaling when possible.
See the mistakes section—most issues stem from security lists and misconfigured SSL.
.
Yes. OCI Free Tier includes an always-free PostgreSQL instance (up to 1 OCPU and 20 GB storage). Good for testing and small workloads.
Use pg_dump
on the source server and pg_restore
or psql
to load the dump file into the OCI instance. For large datasets, upload the dump to Object Storage and restore from there.
Create read replicas from the console. Applications can route read-only traffic to replicas, leaving the primary for writes.