Sql order of data

88 Views Asked by At

I have the following problem. On my server I have to maintain data in particular order (to by specific order of insertion). And it has to be stored in a file. I'm currently using SQLite to do this, but is it safe to assume that SQL db will keep the order of insertion, or should I use something else (in this case please give me a hint what to do).

1

There are 1 best solutions below

0
On BEST ANSWER

Rows in a table are not stored in any particular order. You can only guarantee order with an order by clause.

To order rows by insertion, you'd typically use an autoincrement column. That assigns a higher values to rows that are inserted later. You can then order by autoinc_col to retrieve rows in the order in which they were inserted.