PolarPlus is a command-line interface (CLI) for PolarDB for PostgreSQL (Compatible with Oracle). If you're migrating from Oracle or managing PolarDB clusters in a terminal-driven workflow, PolarPlus provides the same SQL*Plus experience you're used to.
With PolarPlus, you can:
Run SQL queries and PL/SQL anonymous blocks
Execute stored procedures and functions
Format query output
Run batch scripts containing SQL and PolarPlus commands
Execute operating system commands
Log session output to a file
To manage your PolarDB cluster through a broader set of tools, see PolarDB-Tools. The psql tool included in PolarDB-Tools supports PL/SQL anonymous blocks, functions, and stored procedures using Oracle syntax.
Prerequisites
Before you begin, make sure your Linux system has the following installed:
Java Development Kit (JDK) 1.8 (64-bit)
OpenSSL 1.1 (64-bit)
Download PolarPlus
Download the package using wget:
wget https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/en-US/20240708/riozpy/polarplus2_release.tar.gz
tar -xzf polarplus2_release.tar.gzPolarPlus is a no-install tool. After extraction, the directory structure is:
polarplus2_release
├── polarplus2 -> ./polarplus2.sh
├── polarplus2.sh
├── polarplus.jar
├── login.sql
├── etc
│ └── sysconfig
├── help
└── libpolarplus2 is the executable file (a symlink to polarplus2.sh). To run it from anywhere, add the polarplus2_release/ directory to your PATH environment variable.
Configure PolarPlus
Open
polarplus2.shin a text editor.Set the
baseenvironment variable to the absolute path of thepolarplus2_releasedirectory:export base="/home/polarplus2_release"Replace
/home/polarplus2_releasewith the actual absolute path on your system.
Connect to a database
Syntax
polarplus2 [ -S[ILENT] ] [ login | /NOLOG ] [ @scriptfile[.ext] ]| Argument | Description |
|---|---|
-S[ILENT] | Starts in silent mode, which suppresses the welcome banner and command prompts. |
login | Login credentials in the format username[/password][@{connectstring | variable}]. |
/NOLOG | Starts PolarPlus without connecting to a database. Connect later using the CONNECT command. |
@scriptfile[.ext] | Path to a script file to run automatically at startup. The .sql extension can be omitted — PolarPlus uses .sql by default for files without a specified extension. |
The connection string format is:
host[:port][/dbname][?ssl={true | false}]| Parameter | Default | Description |
|---|---|---|
host | Local host | The hostname or IP address of the database server. |
port | 5444 | The port that accepts connections on the database server. |
dbname | polardb | The name of the database to connect to. |
ssl | false | Set to true to enable SSL. Must include host:port in the connection string when using SSL. |
To connect using an IPv6 address, enclose the address in square brackets:
polarplus2 <username>/<password>@[fe80::20c:29ff:fe7c:78b2]:<port>/<database>A variable defined in login.sql can also serve as the connection string.
Connect to your cluster
Run the following command to connect:
./polarplus2 <username>/<password>@<host>:<port>/<dbname>Next steps
To manage your cluster with additional tools, see PolarDB-Tools.