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

大佬们, sql 如何 update 所有字段的值=NULL where 所有字段='NULL'的时候

  •  
  •   zhengfan2016 · Jul 9, 2021 · 3814 views
    This topic created in 1957 days ago, the information mentioned may be changed or developed.

    Rj6Hr4.md.png
    如题,萌新把本地数据库搞坏了,现在有一堆真假 NULL 混在所有字段里,有没有什么办法一件替换啊

    Supplement 1  ·  Jul 10, 2021

    感谢各位大佬,已解决😄Rzy0LF.png

    16 replies  •  2021-07-09 14:35:03 +08:00
    TomatoCLI
    TomatoCLI
    Jul 9, 2021
    1
    六分钟过去了,你一个字段一个字段的改,估计都执行完了
    goxxoo
    goxxoo
    Jul 9, 2021
    2
    我想笑 😂 真 Null 假 Null
    potatowish
    potatowish
    Jul 9, 2021 via iPhone
    3
    实习生?
    usw
    usw
    Jul 9, 2021
    4
    导成 cvs 手动批量替换再导回去(🤭
    cz5424
    cz5424
    Jul 9, 2021❤️1
    5
    只能一个一个字段来,如果你字段太多随便写代码批量生产 sql

    update 字段=NULL where 字段='NULL'
    wangsipeng95
    wangsipeng95
    Jul 9, 2021
    6
    哈哈哈 搁这真假美猴王呢😂
    zakokun
    zakokun
    Jul 9, 2021❤️1
    7
    你把所有 allow null 的字段名拿出来,写个脚本,组装成
    update table set a=null where (a == "null");
    update table set b=null where (b == "null");
    update table set c=null where (c == "null");

    就这样子咯
    zhengfan2016
    zhengfan2016
    OP
    Jul 9, 2021
    8
    @cyrivlclth 有 50 多个表,每个表得有 10 到 20 个字段,一个一个打累死了
    zhengfan2016
    zhengfan2016
    OP
    Jul 9, 2021
    9
    @potatowish 是的😂
    iikebug
    iikebug
    Jul 9, 2021
    10
    查表 查字段 ,直接生成 sql 也用不了 10 分钟吧
    lovelive1024
    lovelive1024
    Jul 9, 2021
    11
    数据不多的话可以直接导出,批量替换‘null’为 null,然后再导入
    lvgsnm
    lvgsnm
    Jul 9, 2021 via iPhone❤️1
    12
    update table set field = NUll where field is null
    IGJacklove
    IGJacklove
    Jul 9, 2021 via Android❤️1
    13
    写个脚本处理呗
    lllllliu
    lllllliu
    Jul 9, 2021❤️1
    14
    isnull 有函数,
    lllllliu
    lllllliu
    Jul 9, 2021❤️1
    15
    select * from testa where isnull(col);
    anzu
    anzu
    Jul 9, 2021❤️1
    16
    MySql 有查询所有表名所有字段的语句,写脚本一个循环完事。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4662 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 94ms · UTC 01:39 · PVG 09:39 · LAX 17:39 · JFK 20:39
    ♥ Do have faith in what you're doing.