Bulk C# datatable to postgresql table

后端 未结 5 1914
说谎
说谎 2021-01-20 04:29

I have got a datatable with thousands of records. I have got a postgres table with the same fields of the datatable. I want everyday to truncate this table and fill again wi

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-20 05:15

    There is some option to bulk insert into PostgreSQL.

    By example, in my library, I'm using the SQL Copy

    COPY TableName (Column1, Column2, Column3) FROM STDIN BINARY
    

    Disclaimer: I'm the owner of the project Bulk-Operations.NET

    This library make it very easy to perform any kind of bulk operations:

    • BulkInsert
    • BulkUpdate
    • BulkDelete
    • BulkMerge

    In multiple database provider including PostgreSQL

    // Easy to use
    var bulk = new BulkOperation(connection);
    bulk.BulkInsert(dt);
    bulk.BulkUpdate(dt);
    bulk.BulkDelete(dt);
    bulk.BulkMerge(dt);
    

提交回复
热议问题