Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MySQLѧϰ(1)Procedure,TRIGGER,FUNTCION

MySQLµÄÒ²Ö§³Ö´æ´¢¹ý³Ì£¬º¯Êý£¬´¥·¢Æ÷¡£
ÒÔϸ÷¸ö¹¦ÄܵÄÏêÊö£¬Ö÷ÒªÊÇʾÀý¡£
/**1.¶¨Òå·Ö¸î·û*/
DELIMITER //
/**2.´´½¨º¯Êý-¼ÆËãÁ½ÊýÖ®ºÍ*/
CREATE FUNCTION f_sum(num1 INT,num2 INT) RETURNS INT
BEGIN
RETURN num1+num2;
END;
//
/**
*3.´´½¨´æ´¢¹ý³Ì
*˼·£º3.1.Óиô洢¹ý³ÌÔòɾ³ý£¬3.2ÓÐʹÓõÄÖмä±íҲɾ³ý£¬²¢´´½¨¸Ã±í²åÈëÊý¾Ý£¬3.3ͳ¼Æ±íÖй²ÓжàÉÙÊý¾Ý²¢Í¨¹ýÊä³ö²ÎÊý·µ»Ø¸øµ÷ÓÃÕß 3.4ɾ³ýÖмäʹÓõ½µÄ±í
*/
DROP PROCEDURE IF EXISTS p_count ;//
DROP TABLE IF EXISTS T;//
CREATE TABLE T(i_num INT);//
INSERT INTO T VALUES(1),(2),(3);//
CREATE PROCEDURE p_count(OUT param INT)
BEGIN
SELECT COUNT(*) INTO param from T;
DROP TABLE T;
END;//
CALL p_count(@a);//
/**
*4.´´½¨´¥·¢Æ÷
*/
DROP TABLE IF EXISTS t;//
DROP TABLE IF EXISTS tx;//
CREATE TABLE tx(a INT);//
CREATE TABLE t(a INT);//
INSERT INTO t VALUES(2),(3),(4);//
CREATE TRIGGER tr_insert BEFORE INSERT ON t FOR EACH ROW
BEGIN
temp INT;
SELECT COUNT(*) INTO temp from t;
INSERT INTO tx VALUES(temp);
INSERT INTO tx SET a = NEW.a+1;
INSERT INTO tx VALUES(NEW.A+2);
END;
//
INSERT INTO t VALUES(1);
/**
*5.ʱ¼äÀàÐÍDATE,DATTIME,TIME,TIMESTAMP,YEAR
*²åÈëÊýֵʱ£º¿ÉÒÔÊÇ6£¬8£¬12£¬14λ£¬Î»Êý²»Í¬£¬MySQL²ÉÓõĸñʽ»¯·½Ê½Ò²²»Í¬¡£
*6-YYMMDD,8-YYYYMMDD,12-YYMMDDHHMMSS,14-YYYYMMDDHHMMSS
*²åÈë×Ö·û´®Ê±¸ù¾ÝÒÔÉÏ¿ÉÒÔÀàÍÆ,¾ßÌå¿ÉÒԲο¼MySQLµÄʹÓÃÊÖ²á
*/
DROP TABLE IF EXISTS t;//
CREATE TABLE t(ts TIMESTAMP);//
INSERT INTO t VALUES('09:02:01');//
INSERT INTO t VALUES(090101);
DROP TABLE IF EXISTS t£»//
CREATE TABLE 1P(a INT);
ÒÔÉÏËùÓж¼Í¨¹ý²âÊÔ¡£
MySQLµÄÁ½¸öº¯ÊýSELECT VERSION();--µÃµ½·þÎñÆ÷°æ±¾ÐÅÏ¢
SELECT CURRENT_DATE();--µÃµ½ÏµÍ³µ±Ç°ÈÕÆÚ£¬ÁíÍ⻹ÓÐCURRENT_TIMEµÃµ½µ±Ç°Ê±¼ä¡£
DELIMITER--·Ö¸ô·û£¬¶¨Ò幦ÄÜÓï¾ä½áÊøµÄ±êʶ,ĬÈÏΪ";"¡£
ÔÚд´æ´¢¹ý³ÌµÈ»áÉæ¼°µ½¶à¸ö";"£¬ÓÃËü×÷·Ö¸ô·ûÊDz»»á±àÒëͨ¹ýµÄ¡£
DELIMITER //£¬¶¨Òå"//"Ϊ·Ö¸ô·û£¬×÷ΪÕâ¸öÓï¾ä¿é¶ùµÄ½áÊø±êÖ¾¡£
CALL p£ßcount(@a);@aÔÚ¸ÃÁ¬½ÓÄÚÓÐЧ¡£
ÍØÕ¹£º½«£Í£ù£Ó£Ñ£Ì¿Í»§¶ËµÄËùÓÐÏÔʾÊý¾ÝÊä³öµ½Öƶ¨Îļþ£¬µÇ¼ºó mysql>tee D:/log/log.log
×¢ÒâÎļþµÄĿ¼һ¶¨Ò


Ïà¹ØÎĵµ£º

Mysql my.ini ÅäÖÃÎļþÏê½â

Mysql my.ini ÅäÖÃÎļþÏê½â
#BEGIN CONFIG INFO
#DESCR: 4GB RAM, ֻʹÓÃInnoDB, ACID, ÉÙÁ¿µÄÁ¬½Ó, ¶ÓÁиºÔØ´ó
#TYPE: SYSTEM
#END CONFIG INFO
#
# ´ËmysqlÅäÖÃÎļþÀý×ÓÕë¶Ô4GÄÚ´æ
# Ö÷ҪʹÓÃINNODB
#´¦Àí¸´ÔÓ¶ÓÁв¢ÇÒÁ¬½ÓÊýÁ¿½ÏÉÙµÄmysql·þÎñÆ÷
#
# ½«´ËÎļþ¸´ÖƵ½/etc/my.cnf ×÷Ϊȫ¾ÖÉèÖÃ,
# mysql-data-d ......

mysql¹ØÓÚÍøÉÏÁ÷תµÄ£¬Éú³É£³£¬£¶Ö®¼äµÄËæ»úÕûÊý

Èç¹ûÄãËÑË÷GOOGLE£¬Äã»áÕÒµ½ºÜ¶à¹ØÓÚmysqlµÄËæ»úÊý£¬ËûÃÇ»áÕâÑù˵
Éú³É£³£¬£¶Ö®¼äµÄËæ»úÕûÊý
FLOOR(3 + (RAND() * 6))
ÔÚ4ºóÃæÌí¼ÓÒ»¸ö3µ½6Ö®¼äµÄÕûÊý
CONCAT(343,FLOOR(3 + (RAND() * 6)))
ÔÚijһ×ֶκóÃæÌí¼Óһλ£³£¬£¶Ö®¼äµÄÕûÊý
UPDATE test SET xx= CONCAT(xx,FLOOR(3 +(RAND() * 6)));
µ«ÊÇÎÒ˽×Ô²âÊÔÁËһϣ¬ ......

MySQL connection strings

MySQL ODBC connection strings
Open connection to local MySQL database using MySQL ODBC 3.51 Driver
"Provider=MSDASQL; DRIVER={MySQL ODBC 3.51Driver}; SERVER= localhost; DATABASE=Your_MySQL_Database; UID= Your_Username; PASSWORD=Your_Password; OPTION=3"
MySQL OLE DB & OleDbConnection (.NET fr ......

MySQL´æ´¢¹ý³Ìѧϰ


http://www.mysql.cn/
ÊÂÎñ£¬²ÎÊý£¬Ç¶Ì×µ÷Óã¬Óα꣬ѭ»·, ´¥·¢Æ÷£¬ÊÓͼ£¬Ô¼Êø, Ë÷Òý£¬¡£¡£¡£
1. ´´½¨ÊµÀýÊý¾Ý¿â
   create database db5;
   use db5;
2.´´½¨Ò»¸ö¼òµ¥µÄ¹¤×÷±í,²¢²åÈëÊý¾Ý
   create table t(s1 int);
   insert into t values(5);
3.´´½¨³ÌÐòʵÀý crea ......

mysql ÈÕÖ¾ÎļþµÄʹÓÃ

MYSQLÓв»Í¬ÀàÐ͵ÄÈÕÖ¾Îļþ(¸÷×Ô´æ´¢Á˲»Í¬ÀàÐ͵ÄÈÕÖ¾)£¬´ÓËüÃǵ±ÖпÉÒÔ²éѯµ½MYSQLÀﶼ×öÁËЩʲô£¬¶ÔÓÚMYSQLµÄ¹ÜÀí¹¤×÷£¬ÕâЩÈÕÖ¾ÎļþÊDz»¿ÉȱÉٵġ£
1.´íÎóÈÕÖ¾(The error log)£º¼Ç¼ÁËÊý¾Ý¿âÆô¶¯¡¢ÔËÐÐÒÔ¼°Í£Ö¹¹ý³ÌÖдíÎóÐÅÏ¢£»
2.ISAM²Ù×÷ÈÕÖ¾(The isam log)£º¼Ç¼ÁËËùÓжÔISAM±íµÄÐ޸ģ¬¸ÃÈÕÖ¾½ö½öÓÃÓÚµ÷ÊÔISAMģʽ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ