-1
我是新手机器人。如何在表中创建外键?下面是我的代码,创建表是playerTable和attackTable。请帮忙!如何在sqlite android中创建外键?
public void onCreate(SQLiteDatabase db) {
// Create a database table
String createPlayerTable = "CREATE TABLE " + TABLE_NAME
+ " (_id INTEGER PRIMARY KEY autoincrement," + PlayerName + " TEXT not null, "
+ PlayerAge + " TEXT not null, "+PlayerBorn+" TEXT not null, "+PlayerWeight+" TEXT not null, "+PlayerHeight+" TEXT not null);";
db.execSQL(createPlayerTable);
String createAttackTable = "CREATE TABLE " + TABLE_ATTACK
+ " (_ID INTEGER PRIMARY KEY autoincrement," + playerAttack + " TEXT not null, "
+ playerPassing + " TEXT not null);";
db.execSQL(createAttackTable);
除此之外,可以自动增加从其他数字如1000开始?我的意思是自动增量从1,2,3,4开始,等等...我想从1000,10001,1002开始数字...是可能的吗?
谢谢,朋友!我的第二个问题有什么想法? – user3103876
要从某个值开始自动增量,可以插入第一行,主ID包含要从中开始递增的值,例如: insert into TABLE_NAME(_id,some_column)values(1000,some_value); – gile
对不起,我不明白你的意思。你能提供更多的例子吗? – user3103876