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 a free installation-package. You can use it on Linux after you download and decompress the installation 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
PolarPlus provides a CLI for PolarDB. PolarPlus supports SQL statements, Stored Procedure Language (SPL) anonymous blocks, and PolarPlus commands.
We recommend that you use PolarPlus to manage PolarDB for PostgreSQL (Compatible with Oracle) clusters. PolarPlus is adapted to PolarDB for PostgreSQL (Compatible with Oracle). Unknown exceptions may occur when you use the tools such as psql in PostgreSQL Community.
PolarPlus allows you to perform the following operations:
Query specified database objects.
Run stored procedures.
Format the outputs of SQL statements.
Run batch processing scripts.
Run OS commands.
Record outputs.
To download and configure PolarPlus, perform the following steps:
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 package from the link specified in Download the PolarPlus client. Decompress the PolarPlus 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 Logon parameters.
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.
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 username that is used to connect to a database.
password
The password 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 none of connectstring,
variable
, and NOLOG are 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. Only
polarplus
in the directory and command is replaced withpolarplus2
.