PolarPlus is a tool that is used to connect clients to PolarDB databases. PolarPlus is compatible with Oracle syntax.
Download the PolarPlus client
PolarPlus provides an installation-free client package. You can use it on Linux after you download and decompress the package. The following code shows the structure of the decompressed PolarPlus directory. The polarplus
file is executable. If you add the path of the polarplus_release/
directory to the system variable PATH
, you can run the polarplus
command.
polarplus_release
├── polarplus -> ./polarplus.sh
├── polarplus.sh
├── polarplus.jar
├── login.sql
├── etc
│ └── sysconfig
├── help
└── lib
Use PolarPlus
Overview
PolarPlus provides a CLI for PolarDB. It supports SQL statements, PolarPlus commands, PL/SQL anonymous blocks, functions, and stored procedures. PolarPlus allows you to perform the following operations:
Query specific database objects.
Execute stored procedures.
Format the outputs of SQL statements.
Run batch processing scripts.
Run OS commands.
Record outputs.
Compatibility with Oracle
PolarPlus is adapted to PolarDB and supports common features of the SQL*Plus tool of Oracle.
We recommend that you use PolarDB-Tools to manage PolarDB clusters. This toolset is adapted to PolarDB for PostgreSQL (Compatible with Oracle). The psql tool in the toolset provides Oracle-compatible PL/SQL anonymous blocks, functions, and stored procedures.
Configure PolarPlus
The following dependencies are required for PolarPlus:
Java Development Kit (JDK) 1.8 for 64-bit OSs
OpenSSL 1.1 for 64-bit OSs
Run the
wget
command to download the PolarPlus client package from the link specified in the "Download the PolarPlus client" section of this topic. Decompress the client package.Go to the bin directory.
Open the
polarplus.sh
file.Modify the
export base="{pwd}/polarplus"
line: Replace{pwd}
with the absolute path of thepolarplus
file.On the server that you want to connect to a PolarDB database, run the following command to start PolarPlus:
polarplus [ -S[ILENT ] ] [ login | /NOLOG ] [ @scriptfile[.ext ] ]
Parameter
Description
-S[ILENT ]
If you configure this parameter, no logon banner or logon-related message appears when you use PolarPlus to connect to the database.
login
The logon information that is used to connect to the database server and the database.
The value of this parameter must be specified in the following format:
username[/password][@{connectstring | variable } ]
For more information, see the "Logon parameters" table in this topic.
The variable parameter is a variable that is defined in the login.sql file. The login.sql file contains the connection string of the database.
/NOLOG
If you specify
/NOLOG
, no connections to the database are created when you start PolarPlus. If you want to connect to the database to execute SQL statements or run PolarPlus commands, do not specify this option.NoteIf you specify this option when you start PolarPlus and you want to connect to the database, run the CONNECT command.
scriptfile[.ext ]
The scriptfile parameter specifies the name of the file that is stored in the current working directory. This file contains the SQL statements that are automatically executed and the PolarPlus commands that are automatically run after you start PolarPlus.
.ext specifies the file extension.
If the file extension of a script file is.sql
, you can omit the file extension when you specify the script file. When you create a script file, name the file in the <File name>.<File extension> format. Otherwise, PolarPlus cannot access the file.NoteFor files that do not contain a file extension suffix in the file name, PolarPlus processes the files as
.sql
files.Table 1. Logon parameters
Parameter
Description
username
The name of the database account that is used to connect to the database.
password
The password of the database account that is used to connect to the database.
connectstring
The connection string of the database. The connection string must be specified in the following format:
host[:port][/dbname][?ssl={true | false}]
The host parameter specifies the hostname or the IP address of the database server.
NoteIf the
connectstring
,variable
, or/NOLOG
parameter is not configured, the default host is the on-premises host.If you use an Internet Protocol version 6 (IPv6) address to connect to a database, you must place the IP address in brackets ([]).
The following example shows how to use an IPv6 address to connect to a database:
polarplus polardb/password@[fe80::20c:29ff:fe7c:78b2]:5444/polardb
The port parameter specifies the port that is used by the database server to receive connection requests.
NoteIf you leave this parameter empty, the default port 5444 is used.
The dbname parameter specifies the name of the database to which you want to connect.
NoteIf you leave this parameter empty, the default value polardb is used.
If you want to create SSL connections, you must specify
?ssl = true
andhost:port
in the connection string. Otherwise, SSL connections cannot be established.
The following example shows how to use PolarPlus to connect to a PolarDB database:
polarplus polardb/password@pc-bp1zxxxxxxxxxxx.o.polardb.rds.aliyuncs.com:1521/polardb
NotePolarPlus is used to connect to only PolarDB for PostgreSQL (Compatible with Oracle) 1.0 clusters. To connect to PolarDB for PostgreSQL (Compatible with Oracle) 2.0 clusters, you must download PolarPlus2. The directory structure and usage of PolarPlus2 are similar to those of PolarPlus. You need to only replace
polarplus
in the directories and commands withpolarplus2
.