SQLite Forum

SELECT * Column Sequence / Order (not ORDER BY)
> how to have SQLite tell me the ordinal position of the columns as part of the table definition

Assuming you have a table named "t1", this will do:


SELECT name, cid FROM pragma_table_info('t1');

--- or ---

SELECT name FROM pragma_table_info('t1') ORDER BY cid ASC;


This will work with the pre-compiled binaries from the site, but I think only after 3.27 or so - not 100% sure, but if you use older versions in production, note that there was a time, not long ago, when this did not work yet.