Use SQL Cursor cursor
In the past two days to do data migration between the old and new systems, access to sql cursor, record summary.
Our demand is to require map multiple tables, and the results are updated to a target table, the old and new systems do A / B Testing, so when the old table there are any updates, such as add, delete, change, we must updates to the new table.
I had chosen solution is to use a batch Insert, but encountered a need to insert the table map relationships, where a field is another table id just insert the data, it can only be solved by recycling. Looked around SQL for loop, to implement a bit laborious. Of course, a useful while do
or temporary tables and other solutions are welcome to explore the e-mail, use the cursor here to share the experience.
As I understand it, the cursor can be thought of as a pointer to a pointer to use when we need to do:
- Statement Pointer
- A pointer to the address
- Get a pointer to content
- Moving the pointer to the new address
Thus it appreciated that the cursor is more convenient, the following example to illustrate a method using the cursor:
|
|
Summary: The cursor is a model for writing programs easier to understand and easy to read, but if used improperly, it is easy to stifle the performance, with caution.
Original: Large column SQL Cursor usage Cursor