Running the Greenplum Client Tools

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

Parent topic: Greenplum Database Client Tools for Windows

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.

Connection ParameterDescriptionEnvironment Variable
Database nameThe 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 nameThe host name of the Greenplum Database master. The default host is the local host.$PGHOST
PortThe port number that the Greenplum Database master instance is running on. The default is 5432.$PGPORT
User nameThe 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:

  1. $ psql.exe -d gpdatabase -h master_host -p 5432 -U gpadmin
  2. $ psql.exe gpdatabase
  3. $ 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:

  1. $ 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:

  1. 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:

  1. => 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.