Android之SQLite列操作
1、
目标 :在SQLite中新加一列
操作过程:
alter table [表名] add column [列名] [列数据类型] [列默认值];
示例 :
alter table comment add column user_name int default(0);
2、
目标:修改列名(字段名)
操作过程:以下资料来源——http://www.cnblogs.com/luxiaofeng54/archive/2011/07/13/2104910.html
// Sqlite 不支持直接修改字段的名称,因此,需要以下几个步骤: // 1、修改原表的名称 ALTER TABLE table RENAME TO tableOld; // 2、新建修改字段后的表 CREATE TABLE table(ID INTEGER PRIMARY KEY AUTOINCREMENT, Modify_Username text not null); // 3、从旧表中查询出数据 并插入新表 INSERT INTO table SELECT ID,Username FROM tableOld; // 4、删除旧表 DROP TABLE tableOld;