dqluw20882 2012-10-16 08:00
浏览 254

如何从MySQL大表中删除列

I have a 250GB 500M rows MySQL table and would like to delete one of its columns. The column is VARCHAR(255). I would like to perform this operation with as little as possible down-time. Thoughts:

  1. Is there any configuration I can add that will help this operation?
  2. Would it be better to iterate in php before on each row and delete the value inside it?
  3. Would it require OPTIMIZE TABLE afterwards?
  4. What would be a reasonable time estimation for such a procedure?
  • 写回答

1条回答 默认 最新

  • dongshi7350 2012-10-16 08:05
    关注

    To assure minimal downtime I would personally backup and restore to an alternative database and then do the 'drop column' before restoring again.

    1. link

    2. It might be, but it will take longer time and is more prone to errors I would say.

    3. Yes, good idea, also, consider using ANALYZE TABLE before hand

    OPTIMIZE TABLE; The OPTIMIZE command should be run when the DBMS is offline for scheduled maintenance. The command is nonstandard SQL.

    评论

报告相同问题?

悬赏问题

  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题