I'm trying to create a database in PostgreSQL using this command:
createdb -E UTF8 aws-inventories
There are no errors from that command. But when I go to list the dbs the new database isn't there:
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------------+----------+----------+----------------------------+----------------------------+-----------------------
analysis | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
animals | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
postgis_31_sample | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
postgres | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
template0 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres +
| | | | | postgres=CTc/postgres
(6 rows)
And if I try to change to that new database it tells me that it isn't there:
postgres-# \c aws-inventories
FATAL: database "aws-inventories" does not exist
Previous connection kept
I also tried this with the CREATE DATABASE
command. And I get the same result:
postgres=# CREATE DATABASE aws-inventories
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------------+----------+----------+----------------------------+----------------------------+-----------------------
analysis | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
animals | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
postgis_31_sample | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
postgres | postgres | UTF8 | English_United States.1252 | English_United States.1252 |
template0 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres +
| | | | | postgres=CTc/postgres
(6 rows)
postgres-# \c aws-inventories
FATAL: database "aws-inventories" does not exist
Previous connection kept
Doing the same commands in PGAdmin4 I do get an error:
createdb aws-inventories
ERROR: syntax error at or near "createdb"
LINE 1: createdb aws-inventories
^
SQL state: 42601
Character: 1**strong text**
CREATE DATABASE aws-inventories
ERROR: syntax error at or near "-"
LINE 1: CREATE DATABASE aws-inventories
^
SQL state: 42601
Character: 20
I'm on PostgreSQL 13. Why is Postgres refusing to create this database?