数据库增加表与更新字段语法 GREENDAO

if (newVersion > oldVersion) {
    String sql = "CREATE TABLE NODE_RICH_AND_INFO(CONTENT  TEXT,ANSWER_START_TIME   VARCHAR(12),END_TIME  TIME,START_TIME      TIME,ANSWER_SHOW    BOOLEAN,ANSWER_SHOW_STATUS    INTEGER,STATUS  INTEGER,ID    INTEGER  NOT NULL PRIMARY KEY)";
    String sql1 = "CREATE TABLE SAVE_STUDENT_ANSWER(ANSWER        VARCHAR(200) ,STUDENT_NO   VARCHAR(20),ANSWER_SHEET_ANSWER_ID INTEGER  NOT NULL,ANSWER_SHEET_TEXT_ID  INTEGER   NOT NULL,ID      INTEGER)";
    String sql2 = "CREATE TABLE STUDENT_ANSWER(ACTUAL_SCORE     INTEGER ,ANALYSIS   TEXT,ANSWER   TEXT,ANSWER_SHEET_ANSWER_ID   INTEGER  NOT NULL,ANSWER_SHEET_TEXT_ID  INTEGER   NOT NULL,CLASS_ROOM_ID    INTEGER,CREATE_TIME   TIMESTAMP   ,ID      INTEGER ,IS_TRUE INTEGER ,SCORE INTEGER,STATUS INTEGER,STUDENT_ID INTEGER,STUDENT_NAME VARCHAR(32),TYPE INTEGER,UPDATE_TIME TIMESTAMP)";
    String sql3 = "CREATE TABLE ANSWER(ANALYSIS   TEXT,ANSWER   TEXT,ANSWER_SHEET_TEXT_ID INTEGER,CREATE_TIME TIME,Id INTEGER,SCORE INTEGER,TYPE INTEGER,UPDATE_TIME TIME)";
    String sql4 = "CREATE TABLE ATTACHMENT_LIST_INFO(ANSWER_SHEET_TEXT_ID   INTEGER,ATTACHMENT_ID   TEXT,ATTACHMENT_NAME TEXT,ATTACHMENT_SIZE_IN_STRING TEXT,CREATE_TIME TIME,ID INTEGER,UPDATE_TIME TIME)";
    String sql7 = "ALTER  TABLE NODES_BEAN  ADD ORDER_WEIGHT  INTEGER";
    String sql8 = "ALTER  TABLE NODES_BEAN  ADD  STATUS INTEGER";
    String sql9 = "ALTER  TABLE NODES_BEAN  ADD  TEACHER_ID INTEGER";
    String sql10 = "ALTER  TABLE NODES_BEAN  ADD  IS_DELETE BOOLEAN";
    String sql11 = "ALTER  TABLE NODES_BEAN  ADD  IS_END BOOLEAN";
    String sql12 = "ALTER  TABLE NODES_BEAN  ADD  CREATE_TIME TIME";
    String sql13 = "ALTER  TABLE NODES_BEAN  ADD  UPDATE_TIME TIME";
    String sql6 = "ALTER  TABLE MESSAGE  ADD  ASSOCIATED_ID INTEGER;";
    db.execSQL(sql);
    db.execSQL(sql1);
    db.execSQL(sql2);
    db.execSQL(sql3);
    db.execSQL(sql4);
    db.execSQL(sql6);
    db.execSQL(sql7);
    db.execSQL(sql8);
    db.execSQL(sql9);
    db.execSQL(sql10);
    db.execSQL(sql11);
    db.execSQL(sql12);
    db.execSQL(sql13);
}

你可能感兴趣的:(数据库增加表与更新字段语法 GREENDAO)