1

如何将 CREATE_PARENT_M_LIST 表的主键设置为 CREATE_CHILD_M_LIST 的外键

这是我的疑问。

// My parent table.
public static String CREATE_PARENT_M_LIST = "create table if not exists "+
DATABASE_TABLE1 + " ( p_id integer primary key autoincrement, "
        + "table_name text);"; 

// my child table.
public static String CREATE_CHILD_M_LIST = "create table if not exists "
        + DATABASE_TABLE2 + " ( id integer primary key autoincrement, "
        + " symbol text," + " f_id integer," 
        + " foregin key(f_id) references " + DATABASE_TABLE1 + "(p_id));";

我在 f_id 列附近收到语法错误

提前致谢。

4

1 回答 1

1

因为你有一个拼写错误:

foregin key(f_id) references 

将其更改为

foreign key(f_id) references 
于 2013-07-30T08:39:02.960 回答