易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql存储过程中参数的in,out,inout区别


MySQL存储过程的参数用在存储过程的定义,共有三种参数类型,IN,OUT,INOUT,形式如:
CREATE PROCEDURE([[IN |OUT |INOUT ] 参数名 数据类形...])
1、IN 输入参数:表示该参数的值必须在调用存储过程时指定,在存储过程中修改该参数的值不能被返回,为默认值
2、OUT 输出参数:该值可在存储过程内部被改变,并可返回
3、INOUT 输入输出参数:调用时指定,并且可被改变和返回
 
 
1、MySQL 存储过程参数(in)
MySQL 存储过程 “in” 参数:跟 C 语言的函数参数的值传递类似, MySQL 存储过程内部可能会修改此参数,但对 in 类型参数的修改,对调用者(caller)来说是不可见的(not visible)。
drop procedure if exists pr_param_in;
 
create procedure pr_param_in
(
   in id int -- in 类型的 MySQL 存储过程参数
)
begin
   if (id is not null) then
      set id = id + 1;
   end if;
 
   select id as id_inner;
end;
set @id = 10;
 
call pr_param_in(@id);
 
select @id as id_out;
mysql> call pr_param_in(@id);
+----------+
| id_inner |
+----------+
|       11 |
+----------+
 
mysql> select @id as id_out;
+--------+
| id_out |
+--------+
| 10     |
+--------+
可以看到:用户变量 @id 传入值为 10,执行存储过程后,在过程内部值为:11(id_inner),但外部变量值依旧为:10(id_out)。
2、MySQL 存储过程参数(out)
MySQL 存储过程 “out” 参数:从存储过程内部传值给调用者。在存储过程内部,该参数初始值为 null,无论调用者是否给存储过程参数设置值。
drop procedure if exists pr_param_out;
 
create procedure pr_param_out
(
   out id int
)
begin
   select id as id_inner_1;  -- id 初始值为 null
 
   if (id is not null) then
      set id = id + 1;
 
      select id as id_inner_2;
   else
      select 1 into id;
   end if;
 
   select id as id_inner_3;
end;
set


相关文档:

Quick Test Setup of MySQL Cluster


To familiarize you with the basics, we will describe the simplest
possible configuration for a functional MySQL Cluster. After this,
you should be able to design your desired setup from the
information provided in the other relevant sections of this
chapter.
......

MySQL Cluster Configuration — Basic Example


To support MySQL Cluster, you will need to update
my.cnf
as shown in the following example.
You may also specify these parameters on the command line when
invoking the executables.

Note
The options shown here should not be confused with thos ......

MySQL Cluster配置step by step

MySQL Cluster配置step by step
来源:http://space.itpub.net/15415488/viewspace-620903
公司有个项目是测试distributed DB,其中一项是针对MySQL Cluster的测试。
于是花了两天时间装机器和配置MySQL Cluster。整个过程还是比较顺利的,当然如果对MySQL常用命令比较熟悉的话会更顺利。
留下step by step配 ......

linux mysql忘记密码的多种解决方法。


我的系统是ubuntu6.06,最近新装好的mysql在进入mysql工具时,总是有错误提示:
# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p password 'newpassword'
Enter pass ......

Mysql 复制表及结构

一、CREATE TABLE 方法
整表复制 # create table 新表 select * from 旧表;
结构复制 # create table 新表 select * from 旧表 where 1<>1;
二、INSERT INTO 方法
得到建表语句 # show create table 旧表;
新建表
复制数据到新表 INSERT INTO new_table(col1,col2,...) (SELECT col1,col2,... from old_table); ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号