PolarPlus is a command-line interface (CLI) for PolarDB for PostgreSQL (Compatible with Oracle). It lets you run SQL statements, PL/SQL anonymous blocks, functions, and stored procedures directly from the terminal without installing a database client.
With PolarPlus, you can:
Query database objects
Execute stored procedures
Format SQL output
Run batch processing scripts
Run OS commands
Record session output
To manage PolarDB clusters with a more fully integrated toolset, use PolarDB-Tools. Its psql tool supports Oracle-compatible PL/SQL anonymous blocks, functions, and stored procedures.
Prerequisites
Before you begin, make sure you have:
Java Development Kit (JDK) 1.8 for 64-bit operating systems
OpenSSL 1.1 for 64-bit operating systems
A Linux environment (PolarPlus runs on Linux only)
Download PolarPlus
PolarPlus ships as a no-install package. Download and decompress it — no installation step is needed.
wget https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20241204/eozaey/polarplus_release.tar.gz
tar -xzf polarplus_release.tar.gzAfter decompression, the directory looks like this:
polarplus_release
├── polarplus -> ./polarplus.sh
├── polarplus.sh
├── polarplus.jar
├── login.sql
├── etc
│ └── sysconfig
├── help
└── libThe polarplus file is the executable entry point. To run it from anywhere, add polarplus_release/ to your PATH:
export PATH="$PATH:/path/to/polarplus_release"Configure PolarPlus
Before starting PolarPlus, set the base path in the startup script:
Open
polarplus.sh.Find the line
export base="{pwd}/polarplus"and replace{pwd}with the absolute path to thepolarplusfile.
Connect to a database
Startup syntax
Start PolarPlus with the following command:
polarplus [-S[ILENT]] [<login> | /NOLOG] [@<scriptfile>[.<ext>]]The three components map to distinct modes of operation:
Options
| Option | Description |
|---|---|
-S[ILENT] | Suppresses the logon banner and connection messages. |
Logon
<username>[/<password>][@{<connectstring> | <variable>}]| Parameter | Description |
|---|---|
username | The database account name. |
password | The database account password. |
connectstring | The connection string. See Connection string format. |
variable | A variable defined in login.sql. This file stores your connection string and loads automatically on startup. |
Start (script file)
@<scriptfile>[.<ext>]PolarPlus runs the SQL statements and commands in this file automatically on startup.
| Parameter | Description |
|---|---|
scriptfile | A script file in the current working directory. If the file extension is .sql, you can omit it. Files without an extension are treated as .sql. Name your script files as <filename>.<extension> — PolarPlus cannot access files that have no extension in the filename. |
`/NOLOG`
Use /NOLOG to start PolarPlus without connecting to a database. This is useful when you want to edit scripts or run PolarPlus commands before establishing a connection. To connect after startup, run the CONNECT command.
Connection string format
<host>[:<port>][/<dbname>][?ssl={true|false}]| Parameter | Description |
|---|---|
host | The hostname or IP address of the database server. Defaults to the on-premises host if omitted. |
port | The port the database server listens on. Defaults to 5444 if omitted. |
dbname | The name of the database to connect to. Defaults to polardb if omitted. |
?ssl=true | Enables SSL. Must be used together with host:port. |
For IPv6 addresses, wrap the address in brackets:
polarplus polardb/password@[fe80::20c:29ff:fe7c:78b2]:5444/polardbConnect to a PolarDB database
polarplus polardb/password@pc-bp1zxxxxxxxxxxx.o.polardb.rds.aliyuncs.com:1521/polardbVersion compatibility
PolarPlus connects to PolarDB for PostgreSQL (Compatible with Oracle) 1.0 clusters only. Use PolarPlus2 for 2.0 clusters.
| Cluster version | Client | Download |
|---|---|---|
| PolarDB for PostgreSQL (Compatible with Oracle) 1.0 | PolarPlus | polarplus_release.tar.gz |
| PolarDB for PostgreSQL (Compatible with Oracle) 2.0 | PolarPlus2 | polarplus2_release.tar.gz |
PolarPlus2 has the same directory structure and usage as PolarPlus. Replace polarplus with polarplus2 in all paths and commands.