-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