PSQL Basic Use Guide
After you have installed the software and the Greenplum database has been started, you can now access the database and start running queries as you please. There are several different ways to do this, however, so the below will be a very brief guide respectively.
The most basic way is to use the âPSQLâ command from the PowerShell command line. Running the below as gpadmin on the container/VM will connect you to the âdemoâ database:
psql -d demo
To exit out of the database run:
\q

You can, still using the âPSQLâ command, run queries directly against the database using either the â-câ orâ-fâ option, which allows you to submit a query from the command line or from a file respectively:
psql -d demo -c âselect âhello worldâ as example;â
psql -d demo -f example.sql

Important Note: You would need to manually create the SQL file above yourself.
Should you wish to do so, you may use the following command to create your own database to test in:
psql -d demo -c âcreate database sandbox;â
Finally, you can also connect to a Greenplum database running on the container via a compatible PSQL GUI Client of your choice.
Once you have started your client, navigate accordingly to add a new server, fill in any required details and head to the respective âConnectionâ tab. Simply add in the details below and then connect your session:
Hostname - localhost
Port number - 5432
Database - demo
Username - gpadmin

Once submitted, your client should connect to the desired database and queries can now be run from here.

You may additionally be able to connect from a remote host by using the IP address of the hosting system.
However, this will depend on how any firewalls are configured and is not guaranteed to work.
Last updated