Maison > base de données > tutoriel mysql > 一个mysql存储记录_MySQL

一个mysql存储记录_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Libérer: 2016-06-01 13:30:09
original
862 Les gens l'ont consulté

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
Copier après la connexion

说明

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

执行修改表结构语句:

prepare tempSql from "ALTER TABLE tbsysinfo ADD COLUMN szClass varchar(2) NULL DEFAULT '00' AFTER nType"; execute tempSql;
Copier après la connexion

结果赋值:

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;
Copier après la connexion

IF语法:

if @card2 is NULL THEN set @card2 = @card1; end if;
Copier après la connexion

 

 

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

bitsCN.com
Étiquettes associées:
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Derniers numéros
MySQL arrête le processus
Depuis 1970-01-01 08:00:00
0
0
0
Env中mysql
Depuis 1970-01-01 08:00:00
0
0
0
Erreur lors de l'installation de MySQL sous Linux
Depuis 1970-01-01 08:00:00
0
0
0
php - problème de surveillance MySQL
Depuis 1970-01-01 08:00:00
0
0
0
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal