سؤال

I have an existing database and I'd like to add the UNIQUE flag to one of the columns to prevent duplicates. What exactly would be the command to put in the onUpgrade section to achieve this?

هل كانت مفيدة؟

المحلول

Regretfully SQLite has very basic support for alter table - you can only either rename the table or add a column - see here.

However you can use similar approach to the one we use for renaming a column.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top