参考文档:http://wenku.baidu.com/view/aed397d528ea81c758f57852.html
对应DB:SQL Server 2005
1.建立.bat文件
sqlcmd -U sa -P Password01! -S ws-keirin-01 -i D:/temp/databasescript/a.sql -o D:/temp/databasescript/log.txt
sqlcmd -U sa -P Password01! -S ws-keirin-01 -i D:/temp/databasescript/b.sql -o D:/temp/databasescript/log.txt
其中-U为用户名,-P为密码,-S为服务器,如果不指定,则默认为本机,-i为入力sql文件,-o为出力log文件
2.建立a.sql和b.sql文件
为方便起见,最好在其中使用use dbname语句显示指定DB名称。
3.执行.bat文件
便可以完成脚本操作DB了。
具体语法参照上述链接。
参考文档:http://hi.baidu.com/naivebaby/blog/item/35ca8113b47dcb0c5baf5379.html
对应DB:POSTGRESQL
1.建立.bat文件
psql -U postgres terasoluna -f D:/temp/databasescript/postgres/p1.sql
psql -U postgres terasoluna -f D:/temp/databasescript/postgres/p2.sql
其中-U为用户名,terasoluna 为DB,-f为为执行脚本。
2.建立p1.sql和p2.sql文件
3.执行.bat文件
便可以完成脚本操作DB了。
具体语法参照上述链接。