Running the Greenplum Client Tools

Running the Greenplum Client Tools

This section contains information for connecting to Greenplum Database using the psql.exe command-line client tool.

Connecting to Greenplum Database

Users and administrators always connect to Greenplum Database through the master host. In order to establish a connection to the Greenplum Database master, you will need to know the following connection information and configure your client program accordingly. See Configuring the Client Tools for more information.

Table 1. Connection Parameters
Connection Parameter Description Environment Variable
Database name The name of the database to which you want to connect. For a newly initialized system, use the postgres database to connect for the first time. $PGDATABASE
Host name The host name of the Greenplum Database master. The default host is the local host. $PGHOST
Port The port number that the Greenplum Database master instance is running on. The default is 5432. $PGPORT
User name The database user (role) name to connect as. This is not necessarily the same as your OS user name. Check with your Greenplum administrator if you are not sure what you database user name is. Note that every Greenplum Database system has one superuser account that is created automatically at initialization time. This account has the same name as the OS name of the user who initialized the Greenplum system (typically gpadmin). $PGUSER

Running psql.exe

The psql.exe program is invoked from a Windows command-line session. For complete command syntax and options for psql.exe, see psql.exe.

Depending on the default values used or the environment variables you have set, the following examples show how to access a database in Greenplum Database via psql:

$ psql.exe -d gpdatabase -h master_host -p 5432 -U gpadmin

$ psql.exe gpdatabase

$ psql.exe

If a user-defined database has not yet been created, you can access the system by connecting to the postgres database. For example:

$ psql.exe postgres

After connecting to a database, psql provides a prompt with the name of the database to which psql is currently connected, followed by the string => (or =# if you are the database superuser). For example:

gpdatabase=>

At the prompt, you may type in SQL commands. A SQL command must end with a ; (semicolon) in order to be sent to the server and executed. For example:

=> SELECT count(*) FROM mytable;

For more information on using the psql.exe client application, see psql.exe. For more information on SQL commands and syntax, see SQL Syntax Summary.