android.database.sqlite.SQLiteException: duplicate column name: text (code 1): 之类的问题解决

最近在回看郭霖的第一行代码,在看到数据库sqllite部分时,自己新建了两个表,建表的语句如下:

(1)

public static    final String CREATE_DB_BOOK = "create table book("
           + "id integer primary key autoincrement,"
           + "author text,"
           + "price real,"
           + "pages integer,"
           + "name text)";
 public static   final String CREATE_DB_PERSON = "create table person("
           + "id integer primary key autoincrement,"
           + "name, text,"
           + "sex ,text)";

(2)

public static    final String CREATE_DB_BOOK = "create table book("
           + "id integer primary key autoincrement,"
           + "author text,"
           + "price real,"
           + "pages integer,"
           + "name text)";
 public static   final String CREATE_DB_PERSON = "create table person("
           + "id integer primary key autoincrement,"
           + "name text,"
           + "sex text)";

错误截图:



对就是这两个表,建成以后,死活报如上错误,虚拟机不行,换真机,各种尝试均失败,后来经过一番摸索,才发现自己的建表语句有bug  。。。。。。

   仔细看,person 表,自己手残不小心在sql语句中name和sex后加了一个逗号,关键就在这,加上这个逗号就表示,这个表中有了重复字段,这数据库是不能忍的。

   记录在这给自己提个醒,以后写代码,一定要认真。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值