2013-07-30 88 views
1

如何設置CREATE_PARENT_M_LIST表的主鍵作爲外鍵CREATE_CHILD_M_LIST如何設置外鍵的android源碼

這裏是我的查詢。

// 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列提前

感謝。

回答

1

becouse你有拼寫錯誤:

foregin key(f_id) references 

將其更改爲

foreign key(f_id) references 
+0

我的眼睛瞎了。謝啦。 – user2085965