Matias
Matias

Reputation: 589

single quotes when using psql from command line

I'm trying to run this simple psql command from command line and getting column ns doesn't exists. I'm sure is something pretty silly that I'm missing.

psql -U myuser -p 6432 -h myhost -d mydb-c 'update schema.table set column ='NS' where id <> 123;'

ERROR: column "ns" does not exist

I tried escape E'NS' to 'NS' but didn't work..

Thanks

Upvotes: 1

Views: 594

Answers (1)

Pierre D
Pierre D

Reputation: 26201

This is really a shell question, and is answered for example here.

Adapted for your question:

psql -U myuser -p 6432 -h myhost -d mydb-c 'update schema.table set column ='"'"'NS'"'"' where id <> 123;'

Note: sometimes, when you have several levels of passing args to nested shell invocations, it can also be beneficial to use the octal form of single-quote:

echo "\047"
# '

Upvotes: 1

Related Questions