2015-08-21 72 views
1

我的代碼在這裏如何在特定的文本字段中設置主鍵?

db.execSQL("create table if not exists data(patient_name varchar,patient_id INTEGER PRIMARY KEY ,patient_phone varchar,patient_mail varchar,patient_age,patient_gender varchar,patient_address varchar,patient_lvd varchar,patient_nvd varchar,patient_notes varchar)"); 

回答

1

嘗試這種方式,

String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " 
      + DATABASE_TABLE + "(" 
      + patient_id + " INTEGER PRIMARY KEY AUTOINCREMENT, " 
      + patient_phone + " TEXT, " 
      + patient_name + " TEXT, " 
      + patient_phone + " TEXT )"; 

db.execSQL(CREATE_TABLE); 

您可以按照SQLite Database Tutorial

相關問題