views:

58

answers:

1

How can i run multiple sql files from one main sql files in postgres.

For example in oracle Inside Main.sql i can specify n number of @Child.sql , and then i can run Main.sql to run all child.sql 's .

How can i do this in the postgres.

Thanks! Pratik

+2  A: 

\i is the psql equivalent of the Oracle SQL*Plus @ command.

If you're using psql to run the Main.sql script, you can put:

\i path/to/child.sql

... in Main.sql. The difference between this and the EXECUTE SCRIPT command pointed out by Tzury is that there the path in FILENAME would refer to a path on the server's file system, while the \i command refers to a path on the machine running psql.

wilberforce