This is probably a silly question but i haven't been able to find the answer yet.
I want to use a TEXT column with my own unique names as the primary key in a table.
the little section of code to define this looks something like this in my project:
...blahblah..."CREATE TABLE " + CAT_BUD_TAB + " (" + CAT_ITEM_ID + "_ID TEXT PRIMARY KEY, "...blahblah..
Will this work as i intend? Or perhaps i need to use "AS ID"? I only ever see single tables with _ID as an autoincrementing integer in. Also this was intended to be a foreign key in another table but since i designed my database i've read more information and i'm not sure that'll really matter using android & SQLITE?
Thanks to the posters below but i'm a bit slow and not sure if i'm applying the info right, could you check?
So if i have a create statement like this:
"CREATE TABLE " + CAT_BUD_TAB + " (" + CAT_ITEM_ID + " TEXT PRIMARY KEY, " +
IN_OUT + " TEXT, " + BUDGET_AMOUNT + " REAL, " + ACTUAL_AMOUNT_SPENT + " REAL, "
+ AMOUNT_STRAYED + " REAL, " + OVERBUDGET_TF + " INTEGER, " + AUTOSPEND_TF +
" INTEGER);"
Then have:
db.execSQL("SELECT ID, ID AS CAT_ITEM_ID")
Can i then use them interchangeably? am i even anywhere near close? haha sorry i am trying!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…