Hologres is compatible with the PostgreSQL ecosystem. Most development and BI tools that support PostgreSQL can connect directly to Hologres. Use your preferred tools to quickly build an enterprise-grade real-time data warehouse. This topic describes how to connect to Hologres using the PSQL client and develop data with standard PostgreSQL statements.
Install the PSQL client
Before using the PSQL client, download and install it from the official website. If the PSQL client is already installed, you can skip this section. The installation steps are as follows.
-
Download the PSQL client
Go to the Postgres official website. Download the client installation package for PostgreSQL 11 or later that matches your operating system. Then, follow the prompts to install it.
-
Set environment variables
-
Windows system.
-
On the page, click Environment Variables.
-
Add the path to the PostgreSQL bin directory to the Path variable.
-
Click OK.
-
-
For macOS, you typically do not need to set environment variables. For more information, see Set Environment Variables.
-
Connect to Hologres and develop
After you download and install the PSQL client, connect to a Hologres instance to develop data.
-
Connect to Hologres
Open the PSQL client command-line interface and enter the connection information. The syntax is the same as connecting to a PostgreSQL database.
-
The statement for Linux is as follows.
psql -h <Endpoint> -p <Port> -U <AccessKey ID> -d <Database>After you execute the statement, enter the AccessKey secret.

-
The statement for macOS is as follows.
PGUSER=<AccessKey ID> PGPASSWORD=<AccessKey Secret> psql -p <Port> -h <Endpoint> -d <Database>
-
The statement for Windows is as follows.
Server [localhost]: Endpoint Database [postgres]: Database Port [5432]: Port Username [postgres]: <AccessKey ID> Password for user <AccessKey ID>: <AccessKey Secret>
Parameter
Description
AccessKey ID
-
Alibaba Cloud account: The AccessKey ID of your Alibaba Cloud account. Click AccessKey Management to get the AccessKey ID.
-
Custom account: The username of the custom account, such as BASIC$abc.
AccessKey Secret
-
Alibaba Cloud account: The AccessKey secret of your Alibaba Cloud account.
-
Custom account: The password of the custom account.
Port
The public network or VPC port of the Hologres instance.
Example value:
80.NoteFor more information about the public network, see Instance Details.
Endpoint
The public network or VPC address of the Hologres instance.
Example value:
xxx-cn-hangzhou.hologres.aliyuncs.com.NoteFor more information about the public network, see Instance Details.
Database
The name of the Hologres database.
After a Hologres instance is enabled, the system automatically creates the postgres database.
Use the postgres database to connect to Hologres. However, this database is allocated few resources. For business development, create a new database. For more information, see Create a database.
Example value:
mydb.Usage examples
-
Log on with an Alibaba Cloud account. The statement is as follows:
PGUSER="xxx" PGPASSWORD="xxx" psql -h hgpostcn-cn-xxx-cn-hangzhou.hologres.aliyuncs.com -p 80 -d demo
-
Log on with a custom account
-
If the username of the custom account is abc, as shown in the following figure.

-
The logon statement is as follows:
PGUSER="BASIC\$abc" PGPASSWORD="xxx" psql -h hgpostcn-cn-xxx-cn-hangzhou.hologres.aliyuncs.com -p 80 -d demo
-
NoteYou can also use other development tools to connect to Hologres, such as DataWorks or HoloWeb. For more information, see DataWorks Quick Start or Connect to HoloWeb and execute a query.
-
-
(Optional) Create a database
After a Hologres instance is enabled, the system automatically creates the postgres database. This database has limited resources and is intended only for operations management. For business development, create a new database.
NoteIf you have already created a business database, skip this step.
-
Command syntax.
CREATE Database <DatabaseName>;DatabaseName is the name of the database to be created.
-
Example.
-- Create a database named test. CREATE Database test;
-
-
Develop data
Use standard PostgreSQL statements in the PSQL client for data development.
The following example shows how to create a table and write data to it. The SQL statements are as follows.
BEGIN; CREATE TABLE nation ( n_nationkey bigint NOT NULL, n_name text NOT NULL, n_regionkey bigint NOT NULL, n_comment text NOT NULL, PRIMARY KEY (n_nationkey) ); CALL SET_TABLE_PROPERTY('nation', 'bitmap_columns', 'n_nationkey,n_name,n_regionkey'); CALL SET_TABLE_PROPERTY('nation', 'dictionary_encoding_columns', 'n_name,n_comment'); CALL SET_TABLE_PROPERTY('nation', 'time_to_live_in_seconds', '31536000'); COMMIT; INSERT INTO nation VALUES (11,'zRAQ', 4,'nic deposits boost atop the quickly final requests? quickly regula'), (22,'RUSSIA', 3 ,'requests against the platelets use never according to the quickly regular pint'), (2,'BRAZIL', 1 ,'y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special '), (5,'ETHIOPIA', 0 ,'ven packages wake quickly. regu'), (9,'INDONESIA', 2 ,'slyly express asymptotes. regular deposits haggle slyly. carefully ironic hockey players sleep blithely. carefull'), (14,'KENYA', 0 ,'pending excuses haggle furiously deposits. pending, express pinto beans wake fluffily past t'), (3,'CANADA', 1 ,'eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold'), (4,'EGYPT', 4 ,'y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d'), (7,'GERMANY', 3 ,'l platelets. regular accounts x-ray: unusual, regular acco'), (20 ,'SAUDI ARABIA', 4 ,'ts. silent requests haggle. closely express packages sleep across the blithely'); SELECT * FROM nation;Develop jobs based on your business scenarios. The following are examples.
-
Accelerate reading data from MaxCompute. For more information, see Accelerate MaxCompute data queries using foreign tables.
-
Write data to Hologres in real time using Flink. For more information, see Hologres sink table.
-