我寫一個SQL腳本多個.CSV文件複製到一個Postgres數據庫是這樣的:多個CSV文件複製到Postgres的
COPY product(title, department) from 'ys.csv' CSV HEADER;
我有多個文件,我想複製我不想:
COPY product(title, department) from 'ys1.csv' CSV HEADER;
COPY product(title, department) from 'ys2.csv' CSV HEADER;
COPY product(title, department) from 'ys3.csv' CSV HEADER;
COPY product(title, department) from 'ys4.csv' CSV HEADER;
COPY product(title, department) from 'ys5.csv' CSV HEADER;
我想用for循環來代替多個拷貝命令。這可能嗎?謝謝
使用'do'塊可能嗎? http://www.postgresql.org/docs/current/static/sql-do.html –