c# - varchar column sorted by itself -


enter image description here

i have table columns, columns varchar. have noticed rows in table sorted automatically. i, instead, want rows in same order inserted table. clues? please note haven't applied order by clause , dates same columns.

as evident although added testing book 3 first, automatically came below testing book 2 not desired.

is because pk composite?

you did not specify rdbms using, can following regards microsoft sql server:

  1. you cannot guarantee predictable / repeatable ordering without order clause

  2. if want rows ordered when inserted, need to: add new column either identity (could int or bigint) or datetime / datetime2 datatype default constraint of getdate() or getutcdate() and order new field

  3. the new field has nothing pk. in reference suggestion else made. pk relationships, not sorting, , while identity typically used pk, there plenty of situations have pk of 1 or more non-auto-incrementing fields , still have auto-incrementing field.

  4. if need detail on millisecond / nanosecond records inserted guaranteed / repeatable sort, both datetime / datetime2 , identity fields.

  5. adding one, or both, of these fields not imply specific index structure. existence merely allows create 1 or more indexes include them enforce desired ordering.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -