I want to reorder the data of a table by a field.
The only way I know is creating a new table and passing all data (except the primary key id
) from the old table to the new one ordering by id_temp:
INSERT INTO db1.ticket id_temp, text, answer_timestamp, mileage , distance_unit,
troubles, error_codes, controls, answer_text, answer_pdf, answer_pdf_link,
estimated_duration, real_duration, delete_operator_id, request_type_id,
request_properties_id, category_id, operator_id, language_id, deleted_at,
created_at, updated_at
SELECT (id_temp, text, answer_timestamp, mileage, distance_unit, troubles,
error_codes, controls, answer_text, answer_pdf, answer_pdf_link,
estimated_duration, real_duration, delete_operator_id, request_type_id,
request_properties_id, category_id, operator_id, language_id, deleted_at,
created_at, updated_at)
FROM db1.ticket_temp order by id_temp;
However this method looks to me very heavy.
Is it another way to reorder the data in a table without creating a new one?