mysql 5.0存储过程学习总结
mysql 5.0存储过程学习总结
一.创建存储过程
1.基本语法:
create procedure
sp_name()
begin
………
end
2.参数传递
二.调用存储过程
1.基本语法:call
sp_name()
注意:存储过程名称后面必须加括号,哪怕该存储过程没有参数传递
三.删除存储过程
1.基本语法:
drop procedure
sp_name//
2.注意事项
(1)不能在一个存储过程中删除另一个存储过程,只能调用另一个存储过程
四.区块,条件,循环
1.区块定义,常用
begin
……
end;
也可以给区块起别名,如:
lable:begin
………..
end
lable;
可以用leave lable;跳出区块,执行区块以后的代码
2.条件语句
if
条件
then
statement
else
statement
end
if
;
3.循环语句
(1).while循环
[
label:
]
WHILE
expression DO
statements
END
WHILE
[
label
]
;
(2).loop循环
[
label:
]
LOOP
statements
END
LOOP
[
label
]
;
(3).repeat until循环
[
label:
]
REPEAT
statements
UNTIL expression
END
REPEAT
[
label
]
;
五.其他常用命令
1.show procedure
status
显示数据库中所有存储的存储过程基本信息,包括所属数据库,存储过程名称,创建时间等
2.show create procedure
sp_name
显示某一个存储过程的详细信息
mysql存储过程中要用到的运算符
mysql存储过程学习总结-操作符
算术运算符
+ 加 SET var1=2+2; 4
- 减 SET
var2=3-2; 1
* 乘 SET var3=3*2; 6
/ 除 SET
var4=10/3; 3.3333
DIV 整除 SET var5=10 DIV 3; 3
% 取模 SET
var6=10%3 ; 1
比较运算符
>
大于 1>2 False
< &n
相关文档:
Explain MySQL architecture
. - The front layer
takes care of network connections and security authentications, the
middle layer does the SQL query parsing, and then the query is handled
off to the storage engine. A storage engine could be either a default
one supp ......
I found a solution to anyone else who may be having this problem.
First start mysql using skip grant tables
root@ns1 [/var/lib/mysql/mysql]# service mysql start --skip-grant-tables
Starting MySQL [ OK ]
now with mysql started, you can repair the mysql/user table
root@ns1 [/var/lib/mysql ......
所以除了给账户权限以外 还有修改 /etc/mysql/my.cnf
找到 bind-address = 127.0.0.1 修改为 bind-address = 0.0.0.0
重启mysql : sudo /etc/init.d/mysql restart
否则会报 ERROR 2003 (HY000): Can't connect to MySQL server on 'x.x.x.x' (111)
好吧 我是mysql菜鸟 以前都是走localhost的
......
一个简单示例--
1,准备:MySQL数据库驱动包【mysql-connector-java-5.1.10-bin.jar】导入
2,创建测试连接主程序
package mysqlConnection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class JdbcDemo {
public static void main(String[] args) {
......
<?php
/**
* 操作mysql
的基础类,其它与mysql有关的类都继承于此基类
*
* 此class中的$table都是已经包含表前缀的完整表名
*
* ver 20090717
* 使用范例
* $db = new DB('localhost','root','password','database','utf8');
* $db->debug = true;
* $db->primaryKeys = array (
* 'table_1 ......