zoukankan      html  css  js  c++  java
  • Mysql 修改字段默认值问题

    临下班前,测试测出所有的返回报文中有一个版本号的值没有上送,最后定位是由于数据库配置表里版本号是空。

    这应该属于前辈们留下的bug了....

    首先试了下

    ALTER TABLE newftp alter column command_version varchar(10) not NULL default 'v1.0'

    报错了:[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar(10) not NULL  default 'v1.0'' at line 1;

    之后又从网上搜了:

    ALTER TABLE newftp add DEFAULT ('v1.0') for command_version WITH VALUES,然而也是执行失败:

    [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT ('v1.0') for command_version WITH VALUES' at line 1

    后来用navcat工具修改字段默认值,然后点SQL预览,

    拿出一条新SQL:

    ALTER TABLE `newftp` MODIFY COLUMN `command_version` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT "v1.0" COMMENT '版本号'

    后来我把之前的alter换成了modify

    ALTER TABLE newftp MODIFY column command_version varchar(10) not NULL default 'v1.0'

    执行成功了...

  • 相关阅读:
    Websocket基础知识简记
    jmeter websocket接口测试
    软件测试的艺术 笔记(上)
    错误提示Unable to preventDefault inside passive event listener解决方法
    vue-cil3关闭eslint语法检查
    mongoDB无法启动服务器
    Vue之todoList
    react踩坑第一章
    父组件向孙子组件传值(Context)特性
    变量声明
  • 原文地址:https://www.cnblogs.com/twelve-eleven/p/6961312.html
Copyright © 2011-2022 走看看