Can you reorder SQLite table columns via a query?
I would prefer a query method, but if that is not possible is there any other way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you control the order of columns by the order you name them in the query. Both these queries return the same rows, but the columns are in a different order.
If you want it to appear that the columns in the base table have been permanently changed, you can use a view.
If you wanted to make that change transparent to application programs, you’d first rename the table, then create the view, giving it the old name of the table. Finally, you’d jump through whatever hoops your dbms requires in order to make that view updatable. In SQLite, I think that means writing code to implement some
INSTEAD OFtriggers.