zoukankan      html  css  js  c++  java
  • MySql新增列的时候判断是否存在

    drop procedure if exists schema_change;
    delimiter ';;';
    create procedure schema_change() begin
        if not exists( select * from information_schema.`COLUMNS` where TABLE_NAME='QYTB_DYAQ' and COLUMN_NAME='BDCQYWBSM') then
            alter table QYTB_DYAQ add BDCQYWBSM CHAR(1);
        end if;
    end;;
    delimiter ';';
    -- 调用存储过程
    call schema_change(); 
    drop procedure if exists schema_change;

    我们通过这段代码感觉只要存储过程的内容体就能实现目的,为什么还要创建一个存储过程来处理呢?

    因为Mysql不支持直接写入如上内容体的格式。于是只能曲线救国了。

  • 相关阅读:
    Swift
    Swift
    书籍
    Swift
    Swift
    iOS系统架构
    Reveal真机(越狱)查看任意APP
    Swift
    Swift
    Swift
  • 原文地址:https://www.cnblogs.com/duanjt/p/13391320.html
Copyright © 2011-2022 走看看