开发者社区 问答 正文

sql 语句在sqlite 中重复执行

alter table TL_Init add BalYear FLOAT NOT NULL DEFAULT (0.00);

语句在sqlite 中怎么重复执行

展开
收起
a123456678 2016-07-19 14:31:58 3362 分享 版权
1 条回答
写回答
取消 提交回答
  • 只能多次调用exec();
    我之前试过,类似

    String sql = "alter table TL_Init add BalYear FLOAT NOT NULL DEFAULT (0.00);alter table TL_Init add BalYear_2 FLOAT NOT NULL DEFAULT (0.00);";
    db.exec(sql)
    应该报错。虽然在sqliteexpert里可以执行。但是代码中不能这样。必须执行两次:

    db.exec("alter table TL_Init add BalYear FLOAT NOT NULL DEFAULT (0.00);");
    db.exec("alter table TL_Init add BalYear_2 FLOAT NOT NULL DEFAULT (0.00);")

    2019-07-17 19:58:23
    赞同 展开评论