Foreign key error in SQL

Asked

Viewed 55 times

0

The error is in the last two lines. Whereas code is primary key of city and acronym is primary key of sector.

CREATE TABLE funcionario(
    codigo int NOT NULL,
    nome varchar(30) NOT NULL,
    sexo char,
    estcivil varchar(10),
    rg int(11),
    cpf int(11) NOT NULL,
    datanasc date,
    naturalidade varchar(15),
    dataadm date,
    endereco varchar(30),
    complemento varchar(10),
    bairro varchar(15),
    cidade varchar(15),
    cep int (11),
    fone int (11),
    celular int (11),
    funcao varchar(15),
    setor varchar(3),
    salario decimal(10,2),
    CONSTRAINT pk_funcionario PRIMARY key(codigo),
    CONSTRAINT fk_cidade FOREIGN key(cidade) REFERENCES cidade(codigo)
);
No answers

Browser other questions tagged

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