0

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

Matias
  • 487
  • 2
  • 22
  • Try double quotes `-c "update ... 'NS' where ..."` – a_horse_with_no_name Feb 03 '21 at 12:18
  • Thanks, it worked, now problem is that I'm executing this from a shell script so I'm not sure how to pass the "". Here's what I'm running:executeSQL $DB "update schema.table set column ='NS' where id <> 123;" – Matias Feb 03 '21 at 12:55

1 Answers1

0

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"
# '
Pierre D
  • 19,195
  • 6
  • 50
  • 84