相关疑难解决方法(0)

错误代码:1062.重复输入'PRIMARY'

所以,我的教授给了我表格将其插入数据库但是当我执行他的代码时,MySQL不断给出错误代码:1062.这是冲突表和插入:

TABLES

CREATE TABLE FABRICANTES(
COD_FABRICANTE integer NOT NULL,
NOMBRE         VARCHAR(15), 
PAIS           VARCHAR(15),
primary key (cod_fabricante)
);

CREATE TABLE ARTICULOS(
ARTICULO       VARCHAR(20)NOT NULL,
COD_FABRICANTE integer NOT NULL,
PESO           integer NOT NULL ,
CATEGORIA      VARCHAR(10) NOT NULL,
PRECIO_VENTA   integer,
PRECIO_COSTO   integer,
EXISTENCIAS    integer,
primary key (articulo,cod_fabricante),
foreign key (cod_fabricante) references Fabricantes(cod_fabricante)
);
Run Code Online (Sandbox Code Playgroud)

插入:

INSERT INTO FABRICANTES VALUES(10,'CALVO', 'ESPAÑA');
INSERT INTO FABRICANTES VALUES(15,'LU', 'BELGICA');
INSERT INTO FABRICANTES VALUES(20,'BARILLA', 'ITALIA');
INSERT INTO FABRICANTES VALUES(25,'GALLO', 'ESPAÑA');
INSERT INTO FABRICANTES VALUES(30,'PRESIDENT', 'FRANCIA');

INSERT INTO ARTICULOS …
Run Code Online (Sandbox Code Playgroud)

mysql primary-key duplicates mysql-error-1062

5
推荐指数
2
解决办法
5万
查看次数

标签 统计

duplicates ×1

mysql ×1

mysql-error-1062 ×1

primary-key ×1