如何在特定文本字段中设置主键?

时间:2015-08-21 10:51:45

标签: java android eclipse sqlite

我的代码

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 个答案:

答案 0 :(得分: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