Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL - Eine untergeordnete Zeile kann nicht hinzugefügt oder aktualisiert werden:Eine Fremdschlüsseleinschränkung schlägt fehl

Ich habe meine 'Fremdschlüssel-Einschränkung schlägt fehl gelöst ' Probleme durch Hinzufügen des folgenden Codes am Anfang des SQL-Codes (dies diente zum Importieren von Werten in eine Tabelle)

SET @example@sqldat.com@CHARACTER_SET_CLIENT;
SET @example@sqldat.com@CHARACTER_SET_RESULTS;
SET @example@sqldat.com@COLLATION_CONNECTION;
SET NAMES utf8;
SET @example@sqldat.com@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @example@sqldat.com@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @example@sqldat.com@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
SET @example@sqldat.com@SQL_NOTES, SQL_NOTES=0; 

Fügen Sie dann diesen Code am Ende der Datei hinzu

SET example@sqldat.com_SQL_MODE;
SET example@sqldat.com_FOREIGN_KEY_CHECKS;
SET example@sqldat.com_UNIQUE_CHECKS;
SET example@sqldat.com_CHARACTER_SET_CLIENT;
SET example@sqldat.com_CHARACTER_SET_RESULTS;
SET example@sqldat.com_COLLATION_CONNECTION;
SET example@sqldat.com_SQL_NOTES;