› 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
yaoweber
V2EX  ›  MySQL

mysql 中,如果一张表没有主键也没有索引,执行 delete 会进行怎么样的操作?

  •  
  •   yaoweber · Feb 14, 2019 · 6312 views
    This topic created in 2788 days ago, the information mentioned may be changed or developed.

    例如: 表 1: id name addr 1 zhangsan xxx 2 lisi xxx 3 wangwu xxx

    将进行 delete 操作: delete from 表 1 where id=3; 数据库会进行什么操作?

    是全表扫描一列一列的对比?生成的 binlog 会是什么样呢?

    8 replies  •  2019-02-22 18:57:21 +08:00
    banxi1988
        1
    banxi1988  
       Feb 14, 2019   ❤️ 1
    其实你没有设置主键,MySQL 内部也会维护一个跟主键类似的东西。
    wd
        2
    wd  
       Feb 14, 2019 via iPhone
    全表扫描 一行一行比
    keepmovingbuddy
        3
    keepmovingbuddy  
       Feb 14, 2019
    用 explain 命令执行一下就知道数据库具体怎么执行你的命令了
    yaoweber
        4
    yaoweber  
    OP
       Feb 14, 2019
    @banxi1988 现在问题是我都不会走主键
    yaoweber
        5
    yaoweber  
    OP
       Feb 14, 2019
    @wd 一行一行对比没有毛病,但是已经定位到某一行,然后怎么比呢?
    wd
        6
    wd  
       Feb 14, 2019 via iPhone
    @yaoweber #5 比你的 where 指定的那列呀
    msg7086
        7
    msg7086  
       Feb 14, 2019
    已经定位到某一行了还比什么?直接删掉这行啊!
    c4f36e5766583218
        8
    c4f36e5766583218  
       Feb 22, 2019
    @yaoweber 你不是写了 where id=3 ?(读取一行判断 id=3,删除,继续下一行
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   946 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 23:48 · PVG 07:48 · LAX 16:48 · JFK 19:48
    ♥ Do have faith in what you're doing.