I have the following code from my command line...
psql (9.1.10)
Type "help" for help.
postgres=# CREATE DATABASE exampledb
postgres-#
After I entered the CREATE DB command the prompt changed from ending with "=#" to "-#". I would like to know what this change means and what the implications are for receiving and processing commands.
psql is a terminal-based front-end to PostgreSQL. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results. Alternatively, input can be from a file or from command line arguments.
postgres=# means you could start a new command. postgres-# means this is the continuation of the active command.
Getting a PostgreSQL command prompt You can get a command shell in Windows by running cmd.exe. The CSEP544 shell launcher script will also open a shell for you. Type psql -U postgres at the prompt, and hit Enter. Here, postgres represents the username of the database superuser.
I now realize that the "postgres=#" prompt is a fresh prompt waiting for the start of a new command, while the "postgres-#" is the result of hitting enter after typing a command that does not end with a semicolon.
The semicolon denotes the end of a command, so pressing enter without a terminating ";" suggests to postgres that you would like to continue writing your command on a new line.
Inserting a semicolon at any point and pressing enter will return you to the original prompt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With