0
我有一個包含1000條記錄的數據表。我想執行從C#到PGSQL的批量插入操作。我知道一種將文本文件複製到pgtable
的方法。將C#批量複製到PostgreSql
的例子語法如下:
using (NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;User Id=postgres;Password=postgres;Database=postgres;"))
{
onn.Open();
NpgsqlCommand command = new NpgsqlCommand("copy \"schema\".\"tablename\" (\"col1\",\"col2\") from 'C:\\datafile.txt'", conn);
command.ExecuteNonQuery();
conn.Close();
}
有沒有我可以使用到數據表,而不是寫數據傳遞到一個文本文件中的任何其他功能?我正在使用Npgsql.dll
。