[Qgis-user] add unique constraint to geopackage in QGIS DB Manager

Janneke van Dijk janneke.qgis at gmail.com
Wed Mar 20 02:51:40 PDT 2019


Dear list,

I would like to make an existing field in a geopackage layer unique - it 
does not contain any data at the moment. In the DB Manager (both QGIS 
2.18 and 3.4 on Windows 10) I have tried many variations of the below:

ALTER TABLE 'RUJWASCO_follow_up' ADD CONSTRAINT 'result_account_uq' 
UNIQUE('result_account');

I have written it without quotes, with double quotes, some with some 
without single and double quotes. I have written it with a space between 
UNIQUE and the bracket. First question is: is it possible to add a 
unique constraint to a geopackage layer? If yes, my second question is - 
what would be the correct syntax? (And maybe: where can I find 
documentation about geopackage sql syntax?).

Thanks for any insights...

Janneke




More information about the Qgis-user mailing list