zoukankan      html  css  js  c++  java
  • mysql 重复执行创建表、新增字段脚本

    #bigint 可重复执行创建表脚本

    1 Create Table If Not Exists `库名`.`表名`(
    2 字段列表
    3 ) ENGINE=InnoDB DEFAULT CHARSET=uft8 COMMENT='表名描述'

    #end 重复创建表脚本

    #bigint 可重复执行添加表字段脚本

    /*=====bigint DBeaver tool 执行脚本 ======*/
    DROP PROCEDURE if exists add_tal_column;
    DELIMITER ####
    CREATE PROCEDURE add_tal_column()
      begin
         IF NOT EXISTS(SELECT 1 FROM information_schema.COLUMNS
             WHERE TABLE_SCHEMA='库名'
             AND TABLE_NAME='表名'
             AND COLUMN_NAME='字段名')
      then
         添加已有表字段脚本
      end if;
    END
    ####
    delimiter;
    CALL add_tbl_column
    DROP PROCEDURE add_tbl_column;
    /*=====end DBeaver tool 执行脚本 ======*/
    
    /*=====bigint Navicat Premium tool 执行脚本 ======*/
    DELIMITER $$
    DROP PROCEDURE if exists add_tal_column;
    CREATE PROCEDURE add_tal_column()
      begin
         IF NOT EXISTS(SELECT 1 FROM information_schema.COLUMNS
             WHERE TABLE_SCHEMA='库名'
             AND TABLE_NAME='表名'
             AND COLUMN_NAME='字段名')
      then
         添加已有表字段脚本
      end if;
    END;
    CALL add_tbl_column
    DROP PROCEDURE add_tbl_column;
    /*=====end Navicat Premium tool 执行脚本 ======*/

    #end 可重复执行新增表字段脚本

  • 相关阅读:
    PHP 文件上传七牛云
    Ubuntu Nginx 配置
    Ubuntu Sublime 配置
    Ubuntu Apache 域名配置
    Ubuntu Apache 配置
    LAMP 搭建
    vue函数防抖和节流
    vs code 同步
    常用软件
    vue
  • 原文地址:https://www.cnblogs.com/PingleDay/p/15682694.html
Copyright © 2011-2022 走看看