Question

I am trying to run basic postgresql commands which start with a backslash within Squirrel SQL sql client. For example, I'd like to be able to type

\dt 

to mean "SHOW TABLES" instead of

"SELECT * FROM information_schema.tables WHERE table_schema = 'public';"  

This works from the psql command line. However, when I try to run "\dt" within Squirrel I get a syntax error message:

Error: ERROR: syntax error at or near "\"
Position: 1
SQLState:  42601
ErrorCode: 0

I assume there's some kind of SQL syntax checking going on here on the part of Squirrel? Does any one know a way to make PostgreSQL commands which start with a backslash work in Squirrel SQL? I have the Postgres plugin installed...

Thanks,

Was it helpful?

Solution

The backslash commands are part of the psql client, not the PostgreSQL backend server. psql translates them into batches of SQL, which you can see by running psql with the -E flag, and uses the results to produce the displayed output.

This means you can't use these commands from other clients.

Alongside the inability to use pg_dump from within a PostgreSQL protocol session, or get equivalent functionality from the backend server, this is a bit of an FAQ.

At this point the only real option is to use a client that understands the information_schema or PostgreSQL's catalogs (pg_catalog) and can produce the display you want its self. A popular choice is PgAdmin-III, though I stick with psql myself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top