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£©À´ËµÊDz»¿É¼ûµÄ£¨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
Ïà¹ØÎĵµ£º
1.mysqlµ¼³öÊý¾Ý¿âÃüÁî
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû (±íÃû) > c:\\ÎļþÃû.sql
2.mysqlµ¼ÈëÊý¾Ý¿âÃüÁî
£¨1£©½â¾öÖÐÎÄÂÒÂëÎÊÌ⣺ִÐÐÈçÏÂÃüÁîÔÙµ¼È룺set names utf8
£¨2£©µÇ¼mysql£¬Ö´ÐÐÈçÏÂÃüÁ
mysql> source c:\\ÎļþÃû.sql;
3½â¾öÖÐÎÄÂÒÂëÎÊÌ⣺ִР......
//µÃ·Ö¼ÆËãËÄÉáÎåÈë
SELECT ROUND((SUM(getfeng)/SUM(totalfeng))*100) as feng from answerdata WHERE uid='151' AND targetid IS NOT NULL
1.ceil £¨£© /ceiling£¨£© ÏòÉÏÈ¡Õû
Àý£º ceil£¨1.2£© = 2
2.floor £¨£© ÏòÏÂÈ¡Õû
Àý£º floor£¨1.2£© = 1
3.round£¨£© ËÄÉáÎåÈë
&n ......
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 ......
°²×°µÄOSΪSolaris10,mysql °æ±¾ÊÇ5.1.38
Ò»¡¢Ê¹ÓÃRPM°ü½øÐа²×°
Ê×ÏÈ¿ÉÒÔ´Ó°²×°¹âÅÌÖлòÕßµ½mysqlµÄÍøÕ¾ÉÏÏÂÔضÔÓ¦°æ±¾µÄrpm°üÈçÏ£º
MySQL-server-community-5.1.38-0.rhel5.i386.rpm
MySQL-client-community-5.1.38-0.rhel5.i386.rpm
½Ó×ÅÎÒÃÇ¿ÉÒÔʹÓÃrpmÃü ......
1. Á¬½Ómysql:
mysql -h Ö÷»úµØÖ· -u Óû§Ãû £p
2.Í˳ömysql:exit
3. ÐÞ¸ÄÃÜÂë:
mysqlbinmysqladmin -uroot -p(oldpassword) password newpassword
4.Ôö¼ÓÓû§£º
Ìí¼ÓÒ»¸öÓû§test1 ÃÜÂëΪABC£»ÈÃËû¿ÉÒÔÔÚÈκÎÖ÷»úÉϵǼ,²¢¶ÔËùÓÐÊý¾Ý¿âÓвéѯ¡¢²åÈë¡¢Ð޸ġ¢É¾³ýµÄȨÏÞ¡£Ê×ÏÈÓÃÒÔrootÓû§Á¬Èë
mysql,È»ºó¼üÈëÒÔÏÂÃü ......