SQLite在Android中创建具有多个主键的表

时间:2016-07-31 14:06:24

标签: android sqlite

请指导我。如何以这种方式将两列定义为主键。

 $scope.$on("modalClosing",function(event,value){
    console.log(value); //value should be $scope.editMade
  });

由于

2 个答案:

答案 0 :(得分:2)

你可以试试这个 -

CREATE TABLE tablename (
  column1, 
  column2,
  PRIMARY KEY (column1, column2)
);

答案 1 :(得分:1)

应分别声明多个主键。查询以问题格式编写。

"CREATE TABLE IF NOT EXISTS " + TABLE_ATTENDEE +
" (" + COLUMN_Att_Event_ID + " TEXT," +
COLUMN_Att_Email + " TEXT, PRIMARY KEY(" + COLUMN_Att_Event_ID + "," + COLUMN_Att_Email + "))"

如果表只有一个PRIMARY KEY,那么

"CREATE TABLE IF NOT EXISTS " + TABLE_ATTENDEE +
" (" + COLUMN_Att_Event_ID + " TEXT PRIMARY KEY," +
COLUMN_Att_Email + " TEXT"