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
相关文档:
MySQL Cluster配置step by step
来源:http://space.itpub.net/15415488/viewspace-620903
公司有个项目是测试distributed DB,其中一项是针对MySQL Cluster的测试。
于是花了两天时间装机器和配置MySQL Cluster。整个过程还是比较顺利的,当然如果对MySQL常用命令比较熟悉的话会更顺利。
留下step by step配 ......
数据库特点
--使用partition,存在上百个分区
--建表时指定了data_dir和index_dir,数据不是存储在默认位置,而是在mysqld的数据目录下link到真正的数据文件
备份恢复要求
--备份出来的数据恢复时要恢复成不同的表名
--恢复出来的数据实际存储位置也要存储在与原表不同的位置
问题
如果直接mysqldump-sourc ......
我的系统是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 ......
public class select {
public List XiuGai_select(String keyword){
List list=new ArrayList();
Connection conn = null;
Statement stmt = null;
String sql=null;
ResultSet res = null;
get ......
一、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); ......