On Wed, 2012-09-12 at 17:20 +0300, Heikki Linnakangas wrote: > On 12.09.2012 17:10, Peter Eisentraut wrote: > > I was surprised to find that psql -f file.sql with a file such as this > > > > select 1; > > select 2 > > > > executes both commands even though the second one is not terminated. > > > > I realize that this is inconsistently handled throughout the system, for > > example libpq APIs don't care about the missing semicolon, but > > interactive psql does. > > Even interactive psql doesn't require a semicolon at the end; it's just > that without it, it doesn't know whether you're still adding to the > command or if it's finished. But you can also use \g: > > ostgres=# select 1 > postgres-# \g > ?column? > ---------- > 1 > (1 row)
A \g is equivalent to a semicolon, at least as far as saying, execute this command now. Note that postgres=# select 1 postgres-# <press Ctrl-D here> does not execute the command before quitting. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers