确定,从第一,
“我们如何才能在数据应用键在数据库中的机器人,就像我们给在Oracle数据库?是否有可能?如果没有,请告诉我为什么。“
Ans - 我们可以应用所有适用于任何其他数据库的规则,如oracle,mysql等......因此,您可以在Android的SQLite数据库中同时使用主键和外键的概念。
2.当我删除数据库中的第一行(其ID为'1')时,下面的行id不会进入序列号,即第二行(现在第一行)的id为'2'为什么不是'1'?
Ans:根据数据库规则,每当你从行中删除任何记录时,它的关键字保持不变,它没有改变,并且该记录之后的任何数据也具有相同的关键字或ID,所以无论何时你想访问该数据该ID或密钥保持不变。
编辑:如果你想修改该密钥或ID,你可以使用UPDATE查询。
EDIT: update(String table, ContentValues values, String whereClause, String[] whereArgs)
Updating Values
To execute an update statement, we have two ways:
1. To execute db.execSQL
2. To execute db.update method:
public int UpdateEmp(Employee emp)
{
SQLiteDatabase db=this.getWritableDatabase();
ContentValues cv=new ContentValues();
cv.put(colName, emp.getName());
cv.put(colAge, emp.getAge());
cv.put(colDept, emp.getDept());
return db.update(employeeTable, cv, colID+"=?",
new String []{String.valueOf(emp.getID())});
}
The update method has the following parameters:
1. String Table: The table to update a value in
2. ContentValues cv: The content values object that has the new values
3. String where clause: The WHERE clause to specify which record to update
4. String[] args: The arguments of the WHERE clause
Convenience method for updating rows in the database.
希望你能理解它。
谢谢,