sqlwrite does not preserve row order

7 次查看(过去 30 天)
I am writing a script to manipulate a .mat file containing a structure into a table and then write to a Microsoft SQL Server database. When I use the sqlwrite command, it does not seem to preserve the row order of the original table. The columns are all there and rows are written correctly, but the starting point is different every time I delete and rewrite the table. This is annoying as the data should be ordered by increasing time. Is there a way to preserve order when writing?
Thanks in advance for any help!

采纳的回答

the cyclist
the cyclist 2023-3-9
Even if you store the data in a particular order (which you should not try to do), there is no guarantee that any given SELECT statement will retrieve the data in that order. I know for a fact that this is true in PostgreSQL, and I am confident that this is true in the major databases systems.
Users who need records in a particular order must use the ORDER BY clause (or equivalent).

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by