私は1000個のレコードを持つデータテーブルを持っています。 C#からPGSQLへの一括挿入操作を実行したい。私はテキストファイルをpgtable
にコピーする方法を知っています。次のようにBulk 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
を使っています。