Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of different command line prompts in PostgreSQL?

Tags:

postgresql

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.

like image 213
HMLDude Avatar asked Oct 29 '13 20:10

HMLDude


People also ask

What is PostgreSQL command line tools?

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.

What does '# mean in psql?

postgres=# means you could start a new command. postgres-# means this is the continuation of the active command.

How do I get postgres prompt?

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.


1 Answers

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.

like image 60
HMLDude Avatar answered Sep 16 '22 14:09

HMLDude