I have a data file .sql with a whole long list of commands like INSERT INTO XXX ("id","field1","field2")... But my database has field1 and field2 switched in positions. How can I change my SQL file so that ALL field1 and field2 are swapped? Is that possible? If not, how best can i import my sql file into my DB?? Tks alot!
It might be better to insert the field definitions instead. For example The typical insert string goes as such INSERT INTO TABE ('id', 'field1', 'field2', 'field3') VALUES (1, 'value for field 1', 'value for field 2' ... ) By inserting the bolded part you can define the order in which your values will be assigned. For reasons such as this is why its always best to export out to a complete insert instead of assuming the order will be the same as the data.
There is no need to swap the fieldnames since the INSERT will work fine regardless to actual field order used in table definition..
Incorrect. If he's using an Insert statement such as INSERT INTO TABLE ('field values'...); and not INSERT INTO TABLE ('field names', ...) VALUES ('field values', ...); And for some reason in his new database structure the fields are not in the same order, that WILL be a problem.