【发布时间】:2018-03-02 17:35:42
【问题描述】:
我有一个名为 test.sh 的 shell 文件,它正在调用其他 sql 文件“table.sql”。 'table.sql' 文件将创建一些表,但我想在特定模式 'bird' 中创建表。
sql 文件的内容。
create schema bird; --bird should not be hard coded it should be in variable
set search_path to 'bird';
create table bird.sparrow(id int, name varchar2(20));
shell 文件的内容。
dbname=$1
cnport=$2
schemaname=$3
filename=$4
gsql -d ${dbname} -p ${cnport} -f ${filenam} #[how to give schema name here so that it can be used in table.sql without hardcoding]
我会像这样执行我的 shell 文件
sh test.sh db1 9999 bird table.sql
【问题讨论】:
标签: sql linux postgresql shell