-- 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 '';
end;;
delimiter ';';
call schema_change();
drop procedure if exists schema_change;

Mysql 使用存储过程添加新字段的更多相关文章

  1. mysql在某一字段后面添加新字段

    mysql在某一字段后面添加新字段 ALTER TABLE `test` ADD `anyField` TEXT NOT NULL AFTER `id`

  2. ASP.NET MVC 5 - 给电影表和模型添加新字段

    在本节中,您将使用Entity Framework Code First来实现模型类上的操作.从而使得这些操作和变更,可以应用到数据库中. 默认情况下,就像您在之前的教程中所作的那样,使用 Entit ...

  3. 【译】ASP.NET MVC 5 教程 - 9:添加新字段

    原文:[译]ASP.NET MVC 5 教程 - 9:添加新字段 在本节中,我们将使用Entity Framework Code First 数据迁移功能将模型类的改变应用到数据库中. 默认情况下,当 ...

  4. 学习ASP.NET Core Razor 编程系列十——添加新字段

    学习ASP.NET Core Razor 编程系列目录 学习ASP.NET Core Razor 编程系列一 学习ASP.NET Core Razor 编程系列二——添加一个实体 学习ASP.NET ...

  5. Django数据库,在原有表中添加新字段

    1.在你要添加新字段的app的 models.py 文件中添加需要新增的字段(这里新增的是dress字段): from django.db import models # Create your mo ...

  6. SqlServer表中添加新字段

    表中添加新字段ALTER TABLE 表名 ADD 字段名 VARCHAR(20) NULL 表中添加自增idalter table lianxi add id int primary key IDE ...

  7. [转]ASP.NET MVC 5 - 给电影表和模型添加新字段

    在本节中,您将使用Entity Framework Code First来实现模型类上的操作.从而使得这些操作和变更,可以应用到数据库中. 默认情况下,就像您在之前的教程中所作的那样,使用 Entit ...

  8. EF之DataBase添加新字段

    数据库中表添加新字段后,在EF的xml格式的中找到与表名相同的节点添加新字段 (SSDL.CSDL和C-S都要添加相关信息)

  9. SQL SERVER 表添加新字段

    SQL SERVER 表添加新字段 ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL; -- doc_exa 是表名 -- column_b 是新加的 ...

随机推荐

  1. android stuido ndk 开发

    开发环境: Android studio 1.0.2 ndk android-ndk-r10d-windows-x86_64 ------------------------------------ ...

  2. 部署Geoserver tomcat部署geoserver

    1. 下载Geoserver War 包. 2.把geoserver.war文件放到 webapps文件夹下 3.添加Tomcat 用户 解压文件conf文件夹下 修改tomcat-users.xml ...

  3. gcc, g++ - GNU 工程的 C 和 C++ 编译器 (egcs-1.1.2)

    总览 (SYNOPSIS) gcc [ option | filename ]... g++ [ option | filename ]... 警告 (WARNING) 本手册页 内容 摘自 GNU ...

  4. WPF知识点全攻略06- WPF逻辑树(Logical Tree)和可视树(Visual Tree)

    介绍概念之前,先来分析一段代码: xaml代码如下: <Window x:Class="WpfApp1.MainWindow" xmlns="http://sche ...

  5. valgrind测试程序内存泄漏问题

    1.用wincap将valgrind放入系统任意路径下,解压 2.  登录主机后台在需要测试程序的路径下运行此行命令: /opt/valgrind/bin/valgrind ./itb(例) 3. 跑 ...

  6. No package python-pip available

    因为没有此rpm包,此包包含在epel源里面 输入rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarc ...

  7. LeetCode || 递归 / 回溯

    呜呜呜 递归好不想写qwq 求“所有情况”这种就递归 17. Letter Combinations of a Phone Number 题意:在九宫格上按数字,输出所有可能的字母组合 Input: ...

  8. 一. python基础知识

    第一章.变量与判断语句 1.第一个python程序 # -*- coding:utf-8 -*- # Author: Raymond print ("hello world") p ...

  9. (转)iOS 属性字符串

    富文本的基本数据类型是NSAttributedString.**属性化字符串**(attributed string)是把属性设置到某些字符上的字符串.属性可以是任何键值对,但是为了实现富文本,则通常 ...

  10. Android开发——ThreadLocal功能介绍

    个静态的监听器对象,显然是无法接受的. 2.  使用实例 //首先定义一个ThreadLocal对象,选择泛型为Boolean类型 private ThreadLocal<Boolean> ...