Difference between username-# and username=# in psql shell?

Viewed 351

The user comes up usually in the form username=# in the console once you enter psql into the terminal. But then I noticed it said username-# where the equal sign was replaced with a hyphen but it still seemed to perform the same way.

I know it's a simple question but I'd still like to know. Does this change in symbol mean anything in particular?

1 Answers

It's not username, it's the name of the database you're connected to. Usually each user has a private database, and psql connects to it by default.

The - means you're in the middle of writing an SQL query, or "ending semicolon missing":

test=# select 1+1
test-# ;
 ?column? 
----------
        2
(1 row)

Also, when you have unmatched delimiters, those are shown:

test=# select (1+1
test(# )
test-# ;
 ?column? 
----------
        2
(1 row)
Related