V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
raickey
V2EX  ›  MySQL

请问,导入数据提示:#1062 - Duplicate entry '19978' for key 'PRIMARY' 怎么解决?

  •  
  •   raickey · 2014-09-24 02:31:06 +08:00 · 6839 次点击
    这是一个创建于 3504 天前的主题,其中的信息可能已经有所发展或是发生改变。
    小白啊,劳烦详细说一下。我在网上查是什么主键重复?但是貌似数字不一样。网上是1,我是19987.晕了。。
    9 条回复    2014-09-25 07:43:19 +08:00
    jerry
        1
    jerry  
       2014-09-24 03:34:56 +08:00   ❤️ 1
    意思是你表内已经有主键为19978的记录了
    ericls
        2
    ericls  
       2014-09-24 03:47:20 +08:00 via Android   ❤️ 1
    你已经有一个19987了
    yappa
        3
    yappa  
       2014-09-24 05:50:45 +08:00 via Android   ❤️ 1
    好奇楼主是怎么在网上查的
    mrco
        4
    mrco  
       2014-09-24 08:08:50 +08:00   ❤️ 1
    整个sqlyog,登录,看看表数据,编号19987的项目,已经有了,删除它,重新导入。
    arnofeng
        5
    arnofeng  
       2014-09-24 08:50:03 +08:00 via Android   ❤️ 1
    加 if not exists字段
    tonic
        6
    tonic  
       2014-09-24 09:52:12 +08:00   ❤️ 1
    如果是mysql也可以 on duplicate update xxx
    raickey
        7
    raickey  
    OP
       2014-09-24 14:07:51 +08:00
    @jerry
    @ericls
    @mrco
    @arnofeng
    @tonic

    各位各位,我是纯小白,能否再说得详细一些?怎么找?怎么删?
    我导入的数据是已经被我删除的数据,怎么会有重复的呢?

    on duplicate update xxx 是一个命令吗?直接在sql里面输入这个就行了吗?
    VYSE
        8
    VYSE  
       2014-09-24 16:32:44 +08:00
    insert ignore
    holyghost
        9
    holyghost  
       2014-09-25 07:43:19 +08:00
    @raickey truncate table xx 一遍再倒进去
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2904 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 14:49 · PVG 22:49 · LAX 07:49 · JFK 10:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.