简体   繁体   中英

What is wrong with this postgresql query to set datestyle?

alter database CST_SCRI1 set datestyle  to "ISO, DMY"

ERROR: database cst_scri1 does not exist;

And this was the list of databases i have

"postgres"
"testdb"
"satish_caliber"
"satish_ajax"
"CST_Billing"
"caliber_ehcrms"
"satish_hcrms"
"Caliber_eCALIBRA"
"cst_scri"
"school"
"CST_SCRI1"

Try it in this way:

alter database "CST_SCRI1" set datestyle to "ISO, DMY"

And restart postgres:

sudo service postgresql restart

PostgreSQL "folds" identifiers (names of tables, columns, databases, etc) to lower-case by default. So although you typed CST_SCRI1 , this gets folded to cst_scri1 . Since your database was actually created with the name in uppercase, there is no database with that lowercase name, as the error says.

The solution is to put the identifier in "double quotes" , which suppresses the case folding.

It's generally sensible to avoid uppercase letters in identifiers when you're creating databases, tables, etc, so that you don't have to worry about this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM