- SQL:
ALTER TABLE mytable ADD (source INTEGER DEFAULT 0, time TEXT, dura TEXT)
ALTER TABLE mytable ADD source INTEGER DEFAULT 0, time TEXT, dura TEXT
- SQLite:
/// 增加 Int 字段
private func addColumn(table: String, columns: [TupleStr]) {
let sqls: [String] = columns.map { (tuple) -> String in
return "ALTER TABLE \(table) ADD \(tuple.0) \(tuple.1)"
}
for sql in sqls {
do {
try db.execute(sql)
LogDebug(.succ("Succ: 增加字段成功 \(sql)"))
} catch {
LogDebug(.error("Error: 增加字段异常 \(sql)"))
}
}
}
网友评论