我在我的表中插入幾行,我不知道爲什麼插入的行不會在插入 -SQL INSERT不是爲了
這裏的順序是Java代碼 -
for (Entry<Integer, String> entry : treeMap.entrySet()) {
System.out.println("Key: " + entry.getKey() + ". Value: " + entry.getValue());
insert(entry.getKey(), entry.getValue()); //method to insert a single record
}
插入查詢:
insert into heightList(heightId,height) values(?,?)
的sysout
日誌:(打印爲了所有鍵)
Key: 1. Value: some text
Key: 2. Value: some text
Key: 3. Value: some text
Key: 4. Value: some text
Key: 5. Value: some text
Key: 6. Value: some text
Key: 7. Value: some text
Key: 8. Value: some text
Key: 9. Value: some text
Key: 10. Value: some text
Key: 11. Value: some text
Key: 12. Value: some text
Key: 13. Value: some text
Key: 14. Value: some text
Key: 15. Value: some text
Key: 16. Value: some text
Key: 17. Value: some text
Key: 18. Value: some text
Key: 19. Value: some text
Key: 20. Value: some text
Key: 21. Value: some text
Key: 22. Value: some text
Key: 23. Value: some text
Key: 24. Value: some text
Key: 25. Value: some text
Key: 26. Value: some text
Key: 27. Value: some text
Key: 28. Value: some text
Key: 29. Value: some text
Key: 30. Value: some text
Key: 31. Value: some text
Key: 32. Value: some text
Key: 33. Value: some text
Key: 34. Value: some text
Key: 35. Value: some text
Key: 36. Value: some text
Key: 37. Value: some text
,但是這是我的表看起來像插入後 -
heightId height
1 some text
10 some text
11 some text
12 some text
13 some text
14 some text
15 some text
16 some text
17 some text
18 some text
19 some text
2 some text
20 some text
21 some text
22 some text
23 some text
24 some text
25 some text
26 some text
27 some text
28 some text
29 some text
3 some text
30 some text
31 some text
32 some text
33 some text
34 some text
35 some text
36 some text
37 some text
4 some text
5 some text
6 some text
7 some text
8 some text
9 some text
爲什麼行不是爲了,我怎麼可以將它們按順序?
是的字段是'varchar' ... – JAVAGeek
因此將其轉換爲int,然後'按ID順序「將正常工作。就目前而言,它已被正確排序,但僅僅是因爲你在數據庫中說明了現場的情況。嘗試和GUESS在現場做什麼不是數據庫的工作。你已經告訴它它是文本,所以它應用了基於文本的規則。 –
我只是將字段更改爲int,並且數據現在是按順序排列的,我真的不知道這件事 - 謝謝! – JAVAGeek