0

How can i create a Postgresql script to create multiple indexes?

I've a list of 'CREATE INDEX' statements and don't want to execute the one by one. So it would be nice to have a script for this job.

Postgresql 9.1

5
  • You can run them as bundle of commands... As one Query... Commented Aug 25, 2014 at 10:57
  • Can you explain me how. How to seperate the commands ? Is it possible to add them in a file (one command per line) and use psql -f <filename> ? Commented Aug 25, 2014 at 11:27
  • each command should be ";" separated. Commented Aug 25, 2014 at 11:28
  • Already tried to seperate them bij ';' but that doesn't work. Only the first one executes. Commented Aug 25, 2014 at 11:29
  • For others who also struggle with this. After some trail and error, this works for me: psql -d <db_name> -f <file_name> One command per line in file. Commented Aug 25, 2014 at 11:50

1 Answer 1

1

Try this command

  psql -f file_path db_name
Sign up to request clarification or add additional context in comments.

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.