[英]How to run SQL files in a directory in order by file name in PSQL
有點像這樣的問題: 在目錄中運行所有SQL文件
我有以下文件: V1__some_migration.sql
, V2__some_other_one.sql
等
我想知道如何根據文件名循環瀏覽並將其導入到一些bash腳本中(如果您知道在UNIX [OS X]和Linux [Ubuntu]上都可以使用的方式,請加分)
依次通過:
YOUR_DIR="/path/to/your/directory"
for file in $YOUR_DIR/*; do
psql <insert your options here> "${file}"
done
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.