Skip to content
Advertisement

Postgres Issue: prompt has changed

test=# SELECT COUNT(id) FROM person’

test’#

enter image description here

Advertisement

Answer

psql is smart enough to guide us. Look at this simple session:

postgres=# select
postgres-# (          -- statement was not finished by semicolon
postgres(# select     -- parenthesis was opened, needs to be closed
postgres(# '
postgres'# abc        -- quote was opened, needs to be closed
postgres'# '          -- quote is still opened
postgres(# as x       -- quote was closed, parenthesis still opened
postgres(# )
postgres-# ;          -- parenthesis was closed, statement needs semicolon to completion
┌─────┐
│  x  │
├─────┤
│    ↵│
│ abc↵│
│     │
└─────┘

The whole statement looks like

select (select 'abc' as x);

without n‘s

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement