Robert Robert - 6 months ago 9
SQL Question

How can the primary key be designated as this if it is not defined as column?

I have the following SQLite query stored as a java string:

"CREATE TABLE " + Table_name +
"(" + Col_A + " TEXT, " + Col_B + " TEXT, " +
Col_C + " TEXT, " + "CONSTRAINT user_grp_id PRIMARY KEY " +
"(" + Col_A + ", " + Col_B + ", " + Col_C + ")" +
")"


Where Table_name, Col_A, Col_B, Col_C are string variables.

My question is, if user_grp_id is not a column in the table, how can it be declared as the primary key?

Answer

It's the name of the primary key, not the column itself. The columns come after the PRIMARY KEY