zoukankan      html  css  js  c++  java
  • Mysql有没有语法可以在增加列前进行判断该列是否存在

    Mysql没有直接的语法可以在增加列前进行判断该列是否存在,需要写一个存储过程完成同样任务,下面例子是:在sales_order表中增加一列has_sent列 

    drop procedure if exists schema_change;
    delimiter ';;';
    create procedure schema_change() begin
    if exists (select * from information_schema.columns where table_name = 'sales_order' and column_name = 'has_sent') then
            alter table sales_order drop column has_sent;
    end if;
    alter table sales_order add column has_sent boolean;
    end;;
    delimiter ';';
    call schema_change();
    drop procedure if exists schema_change;
  • 相关阅读:
    KafKa 发消息到Storm
    HBase的优化
    HBase部署与使用
    Scala 类
    Scala高阶函数
    模式匹配
    Scala数据结构
    scala基础语法
    Scala安装配置
    Kafka工作流程分析
  • 原文地址:https://www.cnblogs.com/yplong/p/3743239.html
Copyright © 2011-2022 走看看