我的 PostgreSQL 11 資料庫中有一個表,每個日期的線串幾何形狀相同,但屬性(每小時資料)不同。我正在嘗試將每個日期的屬性匯出到單獨的 shapefile 中。我在 Windows 10 (x64) PC 上并嘗試使用該pgsql2shp實用程式。
以下代碼行有效(假設我想要前 50 個日期1..50),但它輸出整個表(1..50.shp)而不是每個日期的單獨表:
for %i in (1..50) ; do pgsql2shp -f %i.shp -h localhost -p my_port -u postgres -P my_code postgres public.my_table '"select * from my_table where date = $i"'; done
如何修復上述行以匯出每個日期的 shapefile?
uj5u.com熱心網友回復:
for /L %i in (1,1,50) do pgsql2shp -f %i.shp -h localhost -p my_port -u postgres -P my_code postgres public.my_table '"select * from my_table where date = %i"'
備注:
for /LStephan 提到的語法。
分號被視為分隔符,與Space
SQL 陳述句中的$i應該是%i替換%i的值。
我; done不知道 - 它可能是必需的。
如果這是作為批處理檔案中的一行執行的,則每個都%i需要%%i. 這可能會節省大量容易出錯的重新輸入。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/494642.html
標籤:视窗 PostgreSQL 批处理文件 命令 地理信息系统
