简体   繁体   English

错误代码1062 SQL

[英]Error code 1062 sql

I'm getting the error 我遇到了错误

code 1062 in the INSERT code below (for the table 'Tech'). 下面的INSERT代码(表“ Tech”)中的代码1062。

Any help would be greatly appreciated! 任何帮助将不胜感激!

CREATE TABLE IF NOT EXISTS `Tech` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`),
  FOREIGN KEY (id) REFERENCES AppliedTech(id_questions)
) ENGINE=InnoDB   DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

INSERT INTO `Tech` (`id`, `name`) VALUES
(1, 'Applied Tech'),
(2, 'Communications Equipment'),
(3, 'Computer Systems'),
(4, 'Internet/Digital Media'),
(5, 'Semiconductors'),
(6, 'IT Services'),
(7, 'Payments Processing'),
(8, 'Software');

看来您面对另一个表AppliedTech中的重复键

The table Tech already exists and has data. Tech已存在并具有数据。 CREATE TABLE IF NOT EXISTS don't re-create table and in insert you have duplicate key violation. CREATE TABLE IF NOT EXISTS则创建表,请不要重新创建表,并且在插入时会出现重复的键冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM