1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] i cannot insert value on a table with FOREIGN KEY [duplicate]

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 4, 2024 às 05:23.

  1. Stack

    Stack Membro Participativo

    I've tried to insert values on the column but it gives me this error with mySQL 9.0


    Cannot add or update a child row: a foreign key constraint fails (esercitazione_sql.dipendenti, CONSTRAINT dipendenti_ibfk_1 FOREIGN KEY (id_dipendente) REFERENCES rapporto_clienti (id_rapporto))

    CREATE TABLE if not exists dipendenti(
    id_dipendente int not NULL PRIMARY KEY,
    nome varchar (255) not null,
    cognome varchar (255) not null,
    data_assunzione date not null,
    stipendio decimal not null check (stipendio >= 1200 AND stipendio <= 5000),
    telefono varchar (10) not null unique,
    mansione varchar (255) not null,
    FOREIGN KEY (id_dipendente) REFERENCES rapporto_clienti(id_rapporto)
    )


    INSERT into dipendenti (nome, cognome, mansione, data_assunzione, stipendio, telefono, id_dipendente)
    VALUE ('edgar', 'morales', 'gestione contabilità', '12-12-23', '1300', '328868599' , 1 )

    Continue reading...

Compartilhe esta Página