Reputation: 59960
I search to create a database via CMD, i success to create it using this command:
C:\>"C:\Program Files\PostgreSQL\9.3\bin\psql.exe" -U postgres template1
So when i excute this command i can Create my database like this:
template1=# CREATE DATABASE d_base;
My objectif is to create this database with just one line:
like this:
C:\>"C:\Program Files\PostgreSQL\9.3\bin\psql.exe" -U postgres template1 "CREATE DATABASE T;"
But this not work with me, it gave me this error:
i can solve this problem with creating a .bat Script but my objectif is to use just one line,
Is there any solution for that.
Thank you.
Upvotes: 0
Views: 5175
Reputation: 246308
You get that error because template1
is not the last argument. You can use -d
to specify the database.
Use the database postgres
instead of template1
.
Try this:
"C:\Program Files\PostgreSQL\9.3\bin\psql.exe" -U postgres -d postgres -c "CREATE DATABASE t"
Upvotes: 2
Reputation: 3701
https://www.postgresql.org/docs/9.3/static/app-psql.html
see --command=command
section
Upvotes: 2