zoukankan      html  css  js  c++  java
  • Mysql 使用存储过程添加新字段

    -- 1, 注意SQL 语句开始处不要空格
    -- 2, 在使用 [--] 进行注释时,后面请加空格
    USE `test`;
    
    -- lastUpdateTime
    drop procedure if exists schema_change;
    delimiter ';;';
    create procedure schema_change() begin
    if exists (select * from information_schema.columns where table_name = 't_my_table' and column_name = 'lastUpdateTime') then
            alter table t_my_table drop column lastUpdateTime;
    end if;
    alter table t_my_table add column lastUpdateTime  datetime DEFAULT NULL;
    end;;
    delimiter ';';
    call schema_change();
    -- myScore 
    drop procedure if exists schema_change;
    delimiter ';;';
    create procedure schema_change() begin
    if exists (select * from information_schema.columns where table_name = 't_my_table' and column_name = 'myScore') then
            alter table t_my_table drop column myScore;
    end if;
    alter table t_my_table add column myScore int(11) DEFAULT '0';
    end;;
    delimiter ';';
    call schema_change();
    drop procedure if exists schema_change;
  • 相关阅读:
    jq原创幻灯片插件slideV1.0
    jq原创弹出层折叠效果
    jq实现鼠标经过图片翻滚效果
    开源代码的来源
    名词解析
    Joomla软件的简单介绍
    Java集合类的使用
    笔记
    MySQL基础篇一
    MySQL基础篇一
  • 原文地址:https://www.cnblogs.com/web1992/p/4812402.html
Copyright © 2011-2022 走看看