MySQL+JSP MySQL安装eclipse中Hibernate的配置

  • X4_690735
    了解作者
  • 12.5MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-01 10:00
    上传日期
MySQL安装视频,基本语法,PPT文档,示例文档, eclipse中Hibernate的配置,中文帮助。
MY1-MySQL.zip
内容介绍
mysql> delimiter // //说明语句的结束符(进入) mysql> delimiter ; //说明语句的结束符(退出) mysql> create procedure p1() -> select * from student; -> // Query OK, 0 rows affected (0.00 sec) mysql> call p1(); -> // +------+--------+------+ | sid | sname | sage | +------+--------+------+ | 1000 | aptech | 20 | | 1001 | aptech | 22 | +------+--------+------+ 2 rows in set (0.00 sec) Query OK, 0 rows affected (0.00 sec) ===========================================单句过程(in参数-默认) mysql> create procedure p1(p int) -> set @x = p; -> // Query OK, 0 rows affected (0.00 sec) mysql> call p1(7369); -> // Query OK, 0 rows affected (0.00 sec) mysql> select @x; -> // +------+ | @x | +------+ | 7369 | +------+ 1 row in set (0.00 sec) ===========================================单句过程(out参数) mysql> create procedure p1(out p int) -> set p = 7369; -> // Query OK, 0 rows affected (0.00 sec) mysql> call p1(@x);// Query OK, 0 rows affected (0.00 sec) mysql> select @x; -> // +------+ | @x | +------+ | 7369 | +------+ 1 row in set (0.00 sec) ===========================================会话变量 mysql> create procedure p1() -> begin -> set @x = 7369; -> set @y = 100; -> select * from student; -> end;// Query OK, 0 rows affected (0.00 sec) mysql> call p1(); -> // +------+--------+------+ | sid | sname | sage | +------+--------+------+ | 1000 | aptech | 20 | | 1001 | aptech | 22 | +------+--------+------+ 2 rows in set (0.00 sec) Query OK, 0 rows affected (0.00 sec) ============================================内部变量 mysql> create procedure p1() -> begin -> declare x int; -> declare y int default 100; -> set x = 111; -> select * from student; -> end; // Query OK, 0 rows affected (0.00 sec) mysql> call p1(); -> // +------+--------+------+ | sid | sname | sage | +------+--------+------+ | 1000 | aptech | 20 | | 1001 | aptech | 22 | +------+--------+------+ 2 rows in set (0.00 sec) Query OK, 0 rows affected (0.00 sec) ============================================作用域变量 mysql> create procedure p1() -> begin -> declare x int default 100; -> begin -> declare x int default 111; -> select x; -> end; -> select x; -> end; // Query OK, 0 rows affected (0.00 sec) mysql> call p1(); // +------+ | x | +------+ | 111 | +------+ 1 row in set (0.00 sec) +------+ | x | +------+ | 100 | +------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.00 sec) ===========================================参数类型(in/out/inout) mysql> create procedure selectName(in id int, out name varchar(20)) -> begin -> select sname into name from student where sid=id; -> end; // Query OK, 0 rows affected (0.00 sec) mysql> call selectName(1000,@n); // Query OK, 0 rows affected (0.00 sec) mysql> select @n; -> // +--------+ | @n | +--------+ | aptech | +--------+ 1 row in set (0.00 sec) ============================================控制语句 1)条件语句-if if x = 2 then ... end if; --------------- if x = 2 then ... else ... end if; --------------- if x = 2 then ... else if x = 3 then ... else ... end if; --------------- if x = 2 then if y = 3 then ... end if; end if; --------------- 2) 条件语句-case case x when 0 then ...; when 1 then ...; else ...; end case; case when x = 0 then ...; when x = 1 then ...; else ...; end case; 3) 循环语句-LOOP LOOP_LABLE:loop ... if x = xy then leave LOOP_LABLE; end if; ... end loop; ----------------- mysql> create procedure showX() -> begin -> declare i int default 1; -> x:loop -> select i; -> set i = i + 1; -> if i = 10 then -> leave x; -> end if; -> end loop; -> end; // Query OK, 0 rows affected (0.00 sec) 4) 循环语句-WHILE while x < 9 do ... end while; ----------------- mysql> CREATE PROCEDURE showX() -> BEGIN -> declare i int default 1; -> while i < 10 do -> select i; -> set i = i + 1; -> end while; -> END; // Query OK, 0 rows affected (0.00 sec) 5) 循环语句-REPEAT //它在执行操作后检查结果,而while则是执行前进行检查 repeat ... until v >= 5 end repeat; ------------------ mysql> create procedure showX() -> BEGIN -> declare i int default 1; -> repeat -> select i; -> set i = i + 1; -> until i >= 10 -> end repeat; -> END; // Query OK, 0 rows affected (0.00 sec) 6) 语句-ITERATE: ITERATE只可以出现在LOOP, REPEAT, 和WHILE语句内。ITERATE意思为:“再次循环” mysql> create procedure showx() -> begin -> declare i int default 1; -> declare total int default 0; -> x:loop -> set i = i + 1; -> if i%2=1 then -> iterate x; //continue -> end if; -> set total = total + i; -> if i >= 10 then -> leave x; -> end if; -> end loop; -> select total; -> end; // Query OK, 0 rows affected (0.00 sec) 7) 语句-LEAVE: 这个语句被用来退出任何被标注的流程控制构造。 语法: LEAVE label; 8) 游标 mysql> CREATE PROCEDURE SHOWX() -> BEGIN -> DECLARE done BOOLEAN DEFAULT 0; -> DECLARE v_num INT; -> DECLARE v_cur CURSOR FOR select sid from student; -> DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1; --退出条件 -> OPEN v_cur; -> FETCH v_cur INTO v_num; -> WHILE done=0 DO -> select v_num; -> FETCH v_cur INTO v_num; -> END WHILE; -> CLOSE v_cur; -> END; // Query OK, 0 rows affected (0.00 sec) mysql> CALL SHOWX(); // +-------+ | v_num | +-------+ | 1000 | +-------+ 1 row in set (0.00 sec) +-------+ | v_num | +-------+ | 1001 | +-------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.02 sec)
评论
    相关推荐