The client program createdb
does not support all those options.
Create a file db_create.sql
:
CREATE DATABASE MydatAbseName
WITH OWNER myadmin
TEMPLATE template0
ENCODING SQL_ASCII
TABLESPACE pg_default
LC_COLLATE C
LC_CTYPE C
CONNECTION LIMIT -1;
呼吁:
psql -U postgres postgres -f C:/path/to/db_create.sql
The trick here is to connect to the default maintenance db "postgres" and create the new database from there. I do it with the default superuser named "postgres" in my example.
psql -f
executes the SQL commands in the given file.
您也只能执行一个带有<条码>-c条码>的单一指挥系统。 (无相关档案):
psql -U postgres postgres -c "CREATE DATABASE MydatAbseName WITH OWNER Myadmin
EMPLATE template ENCODING SQL_ASCII TABLESPACE pg_default LC_COLLATE C
LC_CTYPE C CONNECTION LIMIT -1"
More on creating a database in the fine manual here and here.
More on psql.
On Windows, it looks something like this:
"C:Program FilesPostgreSQLverson_numberinpsql.exe" -U user -f C:/path/to/db_create.sql postgres
The last "postgres" is the name of the default maintenance db.
If you want to use it in a batch file you have to answer a password prompt or connect with a user that is allowed access without providing a password. Basics in chapters The Password File and The pg_hba.conf File of the manual. More here: