sqlwrite does not preserve row order

조회 수: 4 (최근 30일)
Kathryn
Kathryn 2023년 3월 9일
답변: the cyclist 2023년 3월 9일
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