Вопрос

I'm unable to delete record from sqlite db using Navicat. The error reads: `Error constraint failed'

I get the same thing if I try to delete with the console using an sql command:

sqlite> delete from myTable where sort = '965';
constraint failed
sqlite> 

any idea why this might be happening.

thanks for the help

Это было полезно?

Решение

It looks like this table has a Field which is referenced as a FK in another table, so the SQlite saying

"I can,'t delete it, its inuse in another table"

Другие советы

Use the .schema command of the sqlite3 shell to show all table definitions. Then you can see which constraint on myTable or a child table blocks you from deleting.

If there is a foreign key constraint in another table, you have to delete all records in that table that reference your 965 record before you can delete the record itself.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top