0

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:

enter image description here

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.

2 Answers 2

2

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"
Sign up to request clarification or add additional context in comments.

Comments

2

https://www.postgresql.org/docs/9.3/static/app-psql.html

see --command=command section

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.