我希望在shell中从DB2迁移到Postgres。如何将连接sql从db2改为Postgres?
#!/bin/bash
DBUSRSTR="user ${DBUSER} using ${DBPSW}"
VAR=`db2 CONNECT TO ${DBNAME} ${DBUSRSTR}`
if [ ! $? -eq 0 ]; then
logErr ${MSG002E}
logErr ${VAR}
exit 2
fi
db2 set current schema TEST
if [ ! $? -eq 0 ]; then
logErr ${MSG002E}
exit 2
fi
logInfo "Set Current Schema:" $?
db2 truncate table TEST.table1 immediate我只想删除db2命令,改为Postgres命令。
发布于 2019-07-17 10:33:08
您可以运行psql命令行并执行查询。
psql -d ${DBNAME} -U ${DBUSER} -h ${DBHOST} -c "select 1" 发布于 2019-07-17 12:16:55
您不能跨多个客户端调用维护一个打开的PostgreSQL连接,但您可以使用“此处文档”:
psql -U user <<EOF
SET ...
TRUNCATE ...
...
EOF对于密码,您将使用password file。
https://stackoverflow.com/questions/57067404
复制相似问题