2012-09-28 166 views
0
public static final String TABLE_COMMENTS = "comments"; 
    public static final String COLUMN_ID = "_id"; 
    public static final String COLUMN_COMMENT = "comment"; 

// Database creation sql statement 
    private static final String DATABASE_CREATE = "create table " 
     + TABLE_COMMENTS + "(" + COLUMN_ID 
     + " integer primary key autoincrement, " + COLUMN_COMMENT 
     + " text not null);"; 

任何人可以请解释一下上面这行中,我们正在创造?为什么我们使用表做.AM新android.Is TABLE_COMMENT列“(”?SQlite数据库创建?

+0

这是一个比Android特定的更多的SQL问题。 – TheZ

+0

它的表名,COLUMN_ID和COLUMN_COMMENT是列.. –

+0

你应该看看SQLite文档http://www.sqlite.org/lang_createtable.html – zapl

回答

0

TABLE_COMMENTS:!表的名称

COLUMN_ID:自动增量ID字段的名称。

COLUMN_COMMENT:评论,在表

为什么你曾用“(”一个文本框列的名字,因为那是语法

0

TABLE_COMMENTS是你的表的名称,其解析comments

private static final String DATABASE_CREATE = "create table " 
     + TABLE_COMMENTS + "(" + COLUMN_ID 
     + " integer primary key autoincrement, " + COLUMN_COMMENT 
     + " text not null);"; 

完整的查询将成为

create table comments (
     id integer primary key autoincrement, 
     comment text not null 
); 
0

的TABLE_COMMENTS是一个命名表:?comments

该COLUMN_ID和COLUMN_COMENT是列

"("是打开表的喜好,代码的功能:Create a table > (inside the brackets it creates the columns.)