0

I want to create a database from shell script, I add this line to my script

psql -c 'CREATE DATABASE template1 WITH OWNER = postgres ENCODING = 'LATIN1' TABLESPACE = pg_default LC_COLLATE = "fr_FR iso88591" LC_CTYPE = "fr_FR iso88591" CONNECTION LIMIT = -1 TEMPLATE template0;'

but I get the error ERROR: invalid locale name: "fr_FR iso88591"

When I connect to postgresql then I run CREATE DATABASE template1 WITH OWNER = postgres ENCODING = 'LATIN1' TABLESPACE = pg_default LC_COLLATE = "fr_FR iso88591" LC_CTYPE = "fr_FR iso88591" CONNECTION LIMIT = -1 TEMPLATE template0; it works

What's the problem ? why I cannot create the database from shell script ?

3
  • You need to escape the embedded single quotes inside the single quotes. This is more a bash question (assuming you are using bash), not really a "DBA question" Aug 24, 2022 at 7:27
  • I think it should be fr_FR.iso88591 rather than fr_FR iso88591 (if this is glibc). Otherwise, it looks fine. Aug 24, 2022 at 7:57
  • the same problem Aug 25, 2022 at 11:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.