欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

一个mysql存储记录_MySQL

程序员文章站 2024-01-01 22:58:58
...
bitsCN.com

一个mysql存储记录

01BEGIN02#-------------------------tbsysinfo03prepare tempSql from "ALTER TABLE `tbsysinfo` ADD COLUMN `szClass`  varchar(2) NULL  DEFAULT '00'  AFTER `nType`";04execute tempSql; 0506#-------------------------netCard07prepare tempSql from "CREATE TABLE `tbNetCfg` ( `nID` INT(10) NULL AUTO_INCREMENT,  `szCapture` VARCHAR(100) NOT NULL DEFAULT '0',  `szServiceName` VARCHAR(100) NOT NULL DEFAULT '0',  `szServiceIP` VARCHAR(100) NOT NULL DEFAULT '0',    PRIMARY KEY (`nID`))COLLATE='utf8_general_ci' ENGINE=InnoDB;";08execute tempSql;09SELECT szAdminIP into @szAdminIp FROM `tbsyscfg`;10Select szName into @card1 from  tbnetcards where nType = 1 limit 1;11Select szName into @card2 from  tbnetcards where nType = 2 limit 1;12if @card2 is NULL THEN13    set @card2 = @card1;14end if;15insert into tbNetCfg values(NULL,@card1,@card2,@szAdminIp);1617#-------------------------limitSpeed18prepare tmpSqlToRun from "ALTER TABLE `tblimitspeed` ADD COLUMN `nWeekDay`  smallint(1) NOT NULL DEFAULT 1 AFTER `nTimeZDef`,ADD COLUMN `group`  smallint(1) NULL DEFAULT 1 AFTER `nWeekDay`,ADD PRIMARY KEY (`nWeekDay`)";19execute tmpSqlToRun;20select nWeekDay,`group`,nBandWidth,nTimeZDef,nTime0,nTime1,nTime2,nTime3,nTime4,nTime5,nTime6,nTime7,nTime8,nTime9,nTime10,nTime11,nTime12,nTime13,nTime14,nTime15,nTime16,nTime17,nTime18,nTime19,nTime20,nTime21,nTime22,nTime2321into @nWeekDay,@groupp,@BandWidth,@nTimeZDef,@nTime0,@nTime1,@nTime2,@nTime3,@nTime4,@nTime5,@nTime6,@nTime7,@nTime8,@nTime9,@nTime10,@nTime11,@nTime12,@nTime13,@nTime14,@nTime15,@nTime16,@nTime17,@nTime18,@nTime19,@nTime20,@nTime21,@nTime22,@nTime2322from tblimitspeed;23insert into tblimitspeed values(@nTime0,@nTime1,@nTime2,@nTime3,@nTime4,@nTime5,@nTime6,@nTime7,@nTime8,@nTime9,@nTime10,@nTime11,@nTime12,@nTime13,@nTime14,@nTime15,@nTime16,@nTime17,@nTime18,@nTime19,@nTime20,@nTime21,@nTime22,@nTime23,@BandWidth,@nTimeZDef,2,@groupp);  24END

说明

数据库升级写的一个存储过程,记录一下,以前每次写存储过程都需要全网找资料,很烦。

执行修改表结构语句:

prepare tempSql from "ALTER TABLE tbsysinfo ADD COLUMN szClass varchar(2) NULL DEFAULT '00' AFTER nType"; execute tempSql;

结果赋值:

Select szName into @card1 from tbnetcards where nType = 1 limit 1; set @card2 = @card1; 未使用的一种 DECLARE cnt INT DEFAULT 0; select count(*) into cnt from test_tbl; select cnt;

IF语法:

if @card2 is NULL THEN set @card2 = @card1; end if;

最后limitSpeed 部分,20多个字段,没找到简单的多列赋值的方法,蠢办法一个个赋值,真是--!!

bitsCN.com
相关标签: mysql 记录

上一篇:

下一篇: