I have tried to create a postgresql database from linux(CentOS) command line by executing the following,

psql -U admin -p55432 postgres -c "CREATE DATABASE TEST_DB"

Created database name appeared as "test_db". I need to create database in upper case.


In PostgreSQL unquoted names are case-insensitive. So I do not see special reason to need of Upper case database name. But you can try something like:

psql -U admin -p55432 postgres -c "CREATE DATABASE \"TEST_DB\""

You can use the createdb(1) command, installed with Postgres, to create a database with an uppercase name without having to use quoting:

createdb -U admin -p55432 TEST_DB

Unless you want the database to be owned by admin, you should probably also set an owner using the -O flag.

Note: There’s also an accompanying dropdb(1) command.

You can read more about the Postgres command-line tools in the official documentation.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.