postgresql 如何使用 psql 执行 *.sql 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23991871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to execute *.sql file using psql
提问by Vivek S.
I have created an index.sql
file which contains index creating script for 95 table
我创建了一个index.sql
包含索引创建脚本的文件95 table
for example
例如
DROP INDEX IF EXISTS gtab03_vrctrlid_idx cascade;
CREATE UNIQUE INDEX gtab03_vrctrlid_idx ON gtab03 USING btree (vrctrlid);
I have consolidated all table's index creating script
to a file called index.sql
I need to run the entire script at a time, is it possible to execute the index.sql
file using psql
我已将所有表合并index creating script
到一个名为index.sql
我需要一次运行整个脚本的index.sql
文件中,是否可以使用psql
回答by Sney
Is that what u mean?
这就是你的意思吗?
\i e:/myFolder/index.sql;
回答by Vivek S.
Following script worked for me,
以下脚本对我有用,
psql -U postgres -d mydb -a -f "D:\index.sql" -- Absolute path to .sql file