Why does psql not recognise my single quotes?

后端 未结 2 1510
陌清茗
陌清茗 2021-01-25 02:29
$ psql -E --host=xxx --port=yyy --username=chi --dbname=C_DB -c \'DELETE FROM \"Stock_Profile\" WHERE \"Symbol\" = \'MSFT\'; \'

ERROR: column \"msft\"

2条回答
  •  太阳男子
    2021-01-25 02:51

    It's because the single quote before MSFT terminates the string as far as psql is concerned.

    As @imsop points out case sensitivity is not preserved when removing double quotes from table names and column names so you can escape the double quotes with backward slash (\) when this is required.

    psql -E --host=xxx --port=yyy --username=chi --dbname=C_DB -c "DELETE FROM \"Stock_Profile\" WHERE \"Symbol\" = 'MSFT';"
    

提交回复
热议问题