mysql error in creating Foreign key

Asked

Viewed 46 times

0

I’m trying to create a Foreign key, but it’s wrong. Follow the code I’m using:

 CREATE TABLE foto(
    id INT(10),
    img varchar(25),
    nome varchar(25),
    link varchar(25),
    vew INT(10),
    tkm VARCHAR(100),
    moder INT(1),
    CONSTRAINT fot_id_pk
    PRIMARY KEY (id)
);
 CREATE TABLE inter(
        id INT(10),
        img varchar(25),
        nome varchar(25),
        link varchar(25),
        vew INT(10),
        tkm VARCHAR(100),
        moder INT(5),
        CONSTRAINT int_id_pk
        PRIMARY KEY (id),
        CONSTRAINT int_moder_fk
        FOREIGN key (moder)
        REFERENCES foto (moder)
    );

error: inserir a descrição da imagem aqui

1 answer

2


The problem is that the columns are incompatible.

Column in the photo table: moder INT(1)
Column in inter table: moder INT(5)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.