Having a database with case sensitive name like MyDb,
if I want to use psql to grant all privileges on this database to the user 'user' I can just write:
GRANT ALL PRIVILEGES ON DATABASE "MyDb" TO user;
it works.
But what if I want to use shell scripts?
Running the following command:
su - postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE \"MyDb\" TO user;\""
fails with the error like: ERROR: database "mydb" does not exist
su
at all? Why notsudo -u postgres psql -c 'GRANT ALL PRIVILEGES ON DATABASE "MyDb" TO user;'
?