I'm starting a new project. The task is to basically move data from a file to a database. Let's say there's one data-file per hour and a line of the file transforms into one row of the database.
Technical Details:
My problem is the updating process.
What I'd like to do is:
Solution 1:
original_table
copy_table
to original_table
Solution 2:
original_table
original_table
(shrink, reset index) Questions:
Solution 2 definitely sounds more efficient. Solution 1 sounds needlessly roundabout.
To accomplish steps 4 & 5 from solution 1 or step 3 from solution 2, just use EntityCommand.ExecuteNonQuery
with the appropriate T-SQL text - eg TRUNCATE TABLE original_table
.
How about
all wrapped in a transaction? That way if your copy fails the truncate is rolled back and you don't lose your original table. No data shuffling.
Solution 1: BAD. It has timing issues in which the table is not accessible which means that other programs must handle this.
Solution 2: Same.
What about:
3: Load the new data into a temporary table, then merge it into the original table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.