powered by simpleCommunicator - 2.0.37     © 2025 Programmizd 02
Форумы / SQLite [игнор отключен] [закрыт для гостей] / Ограничение Foreign Key не даёт ничего добавить.
2 сообщений из 2, страница 1 из 1
Ограничение Foreign Key не даёт ничего добавить.
    #39241736
Arvalon
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Доброго вечера!
Есть 2 таблички:
Код: sql
1.
2.
CREATE TABLE muscle_groups (_id INTEGER PRIMARY KEY AUTOINCREMENT, groups TEXT, group_runame TEXT);
CREATE TABLE muscles (_id INTEGER PRIMARY KEY AUTOINCREMENT, muscle TEXT, groups TEXT, muscle_runame TEXT, muscle_img TEXT, description TEXT,FOREIGN KEY(groups) REFERENCES muscle_groups(groups));


Табличка muscle_groups заполнена.


Но при попытке добавить что-либо в табличку muscles появляется ошибка
Код: sql
1.
INSERT INTO muscles (muscle,groups) VALUES ('newmuscle','feet')


Код: plaintext
foreign key mismatch - "muscles" referencing "muscle_groups"

Специально прикладываю картинку ошибки.

Не понимаю где я ошибся, в создании Foreign Key или в синтаксисе где-то... Какое бы из существующих значений поля groups таблички muscle_groups я не подставлял последним параметром в моём инсёрте.
...
Рейтинг: 0 / 0
Ограничение Foreign Key не даёт ничего добавить.
    #39241750
MrCat
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
[quote З.Ф. Мануал ]If the database schema contains foreign key errors that require looking at more than one table definition to identify, then those errors are not detected when the tables are created. Instead, such errors prevent the application from preparing SQL statements that modify the content of the child or parent tables in ways that use the foreign keys. Errors reported when content is changed are "DML errors" and errors reported when the schema is changed are "DDL errors". So, in other words, misconfigured foreign key constraints that require looking at both the child and parent are DML errors. The English language error message for foreign key DML errors is usually "foreign key mismatch" but can also be "no such table" if the parent table does not exist. Foreign key DML errors are may be reported if:

The parent table does not exist, or
The parent key columns named in the foreign key constraint do not exist, or
The parent key columns named in the foreign key constraint are not the primary key of the parent table and are not subject to a unique constraint using collating sequence specified in the CREATE TABLE, or
The child table references the primary key of the parent without specifying the primary key columns and the number of primary key columns in the parent do not match the number of child key columns. [/quote]
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / SQLite [игнор отключен] [закрыт для гостей] / Ограничение Foreign Key не даёт ничего добавить.
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]