SQLite的:排序“insertOrderinDB” [英] SQLite: Order by 'insertOrderinDB'
问题描述
我需要知道如何在DB插入顺序的选择,而不由我自己作出任何索引字段。可能是这更多钞票?
和,在一个事务中的插入顺序是线性模式? (先插入句子 - >第一次插入)
DB CREATION
私有静态最后弦乐CREATE_TABLE_SONGS =CREATE TABLE IF NOT EXISTS SONGS(+
LIST_ID INT NOT NULL,+
PLAY_ID INT NOT NULL,+ //在列表中的歌曲ID
SONG_ID诠释NOT NULL,+ // ID歌曲
TITLE VARCHAR(200)NOT NULL,+
TIME INT NOT NULL,+
PROVIDER INT NOT NULL,+
PROVIDER_ID VARCHAR(200)NOT NULL,+
SONG_STATE INT NOT NULL,+
主键(LIST_ID,PLAY_ID));;
然后
db.execSQL(CREATE_TABLE_SONGS);
SQLite的表有一个秘密一栏名为 ROWID
其中的值会增加为您添加行。它可以作为输入到表顺序的代理。 ROWID
基本上是一个免费的自动递增的整数主键的表列。
请注意,根据定义SQL数据库没有排顺序的概念。虽然我会感到惊讶,如果行为 ROWID
SQLite中的每一个改变(因为它的存在和行为的记载),作为一项规则,如果你想在SQL数据库一个有序的方式检索行你是负责存储自己订购信息。
i need to know how to make a select with the insert order in DB without making any index field by my own . May be this posible?
And , the insertion order in a transaction is linear-mode? (first insert sentences -> first insert )
DB CREATION:
private static final String CREATE_TABLE_SONGS = "CREATE TABLE IF NOT EXISTS SONGS (" +
"LIST_ID int NOT NULL, " +
"PLAY_ID int NOT NULL, " + //ID of the song in the list
"SONG_ID int NOT NULL, " + //ID of the song
"TITLE varchar(200) NOT NULL," +
"TIME int NOT NULL, " +
"PROVIDER int NOT NULL, " +
"PROVIDER_ID varchar(200) NOT NULL, " +
"SONG_STATE int NOT NULL, " +
"PRIMARY KEY (LIST_ID,PLAY_ID));";
And then
db.execSQL(CREATE_TABLE_SONGS);
SQLite tables have a "secret" column called ROWID
the value of which increases as you add rows. It can serve as a proxy for "order entered into table". ROWID
is basically a "free" auto-incrementing integer primary key column for the table.
Note that by definition SQL databases have no notion of row ordering. While I would be surprised if the behavior of ROWID
every changed in SQLite (since it's existence and behavior is documented), as a rule if you want to retrieve rows in an ordered fashion in SQL databases you're responsible for storing the ordering information yourself.
这篇关于SQLite的:排序“insertOrderinDB”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!