MySQLѧϰ(3) ÊÓͼ£¬Óα꣬Óï¾ä¿é¶ù
1.MySQL´´½¨ÊÓͼµÄ¼òµ¥Óï¾äΪ£ºCREATE VIEW view_name AS SELECT * from TABLE_NAME;
²»ÄܶԴ¥·¢Æ÷´´½¨ÊÓͼ(VIEW)¡£µ«ÊÇÔÚ5.1.4ÖÐÊÇÕâÑùÃèÊöµÄ£¬A view can be created from many kinds of SELECT statements. It can refer to base tables or other views. It can use joins, UNION, and subqueries¡£´óÖÂÒâ˼ÊÇÊÓͼ¿ÉÒÔÓÉ´ó¶àÊýSELECTÓï¾ä×é³É£¬¿ÉÒÔÊDzο¼»ù´¡±í»òÆäËûµÄÊÓͼ¡£ÄÜʹÓÃÁ¬½Ó£¬ºÏ²¢ºÍ×Ó²éѯ¡£
2.Óαê(CURSOR)£¬ÓαêÔÚ´æ´¢¹ý³ÌÖеÄʹÓá£
ÓαêÊÇÒ»ÖÖÔÚÊý¾Ý¿â·þÎñÆ÷¶Ë²Ù×÷½á¹û¼¯µÄ·½Ê½£¬Èç¹ûûÓÐÓαêÎÒÃÇÒª¶Ô²éѯµÄ½á¹û¼¯½øÐд¦Àí¾ÍҪʹÓø߼¶ÓïÑÔ±à³ÌʵÏÖ£¬ÕâÑùÔö¼ÓÁ˲»±ØÒªµÄÍøÂç´«Êä¡£MySQLÔÚ5.0.3Ö§³ÖÁËÓαꡣ
ѧϰµÄ´úÂëÈçÏ£º
DELIMITER /
/**
*1.Ð޸ıíÁÐ
*1.1Ôö¼Ó±íÁÐ,1.2
*/
ALTER TABLE t ADD COLUMN ii INT;
ALTER TABLE t
/**
*2.MD5º¯Êý£¬ÏÖÔڵļÓÃܹ¤×÷¶¼½»¸øÊý¾Ý¿âÁË£¬²»ÓÃÔÚÓ¦ÓÃÖмÓÃÜÁË¡£
**/
SELECT MD5('LEST');
/**
*3.ÊÓͼVIEW£¬ÕâÑùÎÒÃÇÖ»Òª²éѯÊÓͼ¾Í¿ÉÒÔ¿´µ½ÎÒÃÇÒª²é¿´µÄÊý¾Ý£¬µ±È»Ç°ÌáÊÇÎÒÃǵÄSELECT Óï¾ä°üÀ¨ÁËËûÃÇ¡£
*/
CREATE OR REPLACE VIEW v_t AS SELECT i from t;
SELECT * from v_t;
DESC v_t;
CREATE PROCEDURE p_iu()
BEGIN
INSERT INTO userinfo VALUES('bill',30);
UPDATE userinfo SET age=20 WHERE username='admin1234';
COMMIT;
EXCEPTION
ROLLBACK;
END;
/**4.½«¸÷¸ö²Ù×÷ÏÞÖÆÔÚÒ»Æ𣬳ɹ¦µÄÌõ¼þÊÇÕû¸ö²Ù×÷˳ÀûÍê³É*/
BEGIN
INSERT INTO t VALUES(12,12);
INSERT INTO tx VALUES(11);
END;
/
/**
*5.ÓαêCURSOR£¬´æ´¢¹ý³ÌºÍº¯ÊýÖ§³Ö¼òµ¥µÄÓα꣬ʹÓÃÓαêÊÇÊý¾Ý¿â·þÎñÆ÷¿ÉÄܻὫ½á¹û±í¸´ÖÆÒ»·Ý£¬Ò²¿ÉÄܲ»»á,Ö»ÄÜÔÚ´æ´¢¹ý³ÌºÍº¯ÊýÖÐʹÓá£
*1.¼òµ¥µÄÓαêÓ¦Óã¬doneÊÇÓÖÓαêµÄʵÏÖÕß²Ù×÷£¬¶ÔÆäÖµ½øÐÐÐÞ¸Ä
**/
DROP TABLE IF EXISTS t;//
CREATE TABLE t(i_a INT);//
INSERT INTO t VALUES(2);//
CREATE PROCEDURE p_cur()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE a INT;
DECLARE cur1 CURSOR FOR SELECT * from t;
OPEN cur1;
REPEAT
FETCH cur1 INTO a;
UNTIL done END REPEAT;
CLOSE cur1;
END;
//
DELIMITER ¸ù¾ÝÐèÒª¸Ä±ä¡£
Ïà¹ØÎĵµ£º
MySQL·ÖÇø£¨Partition£©¹¦ÄÜÊÔÑé2008-07-06 20:02Ŀ¼
[¸ÅÊö]
[·ÖÇø±íºÍδ·ÖÇø±íÊÔÑé¹ý³Ì]
[·ÖÇøÃüÁîÏê½â]
[¸ÅÊö]
×Ô5.1¿ªÊ¼¶Ô·ÖÇø(Partition)ÓÐÖ§³Ö£¬6.0Ó¦±È½ÏÎȶ¨
= ˮƽ·ÖÇø£¨¸ù¾ÝÁÐÊôÐÔ°´Ðз֣©=
¾Ù¸ö¼òµ¥Àý×Ó£ºÒ»¸ö°üº¬Ê®Ä귢Ʊ¼Ç¼µÄ±í¿ÉÒÔ±»·ÖÇøΪʮ¸ö²»Í¬µÄ·ÖÇø£¬Ã¿¸ö·ÖÇø°üº¬µÄÊÇÆäÖÐÒ»ÄêµÄ¼Ç¼¡£
=== Ë® ......
mysql µ¼Êý¾Ý¿âÃüÁî
mysqlÃüÁîµ¼Êý¾Ý¿â½Å±¾¡£
mysql>create database databaseName
mysql>use yourDatabase
mysql>source d:yourSql.sql
=========================
1.mysql -u root -p Javascript:tagshow(event, '%CA%FD%BE%DD%BF%E2');" href="http://www.xland.com.cn/article/74/76/0704/Javascript:;" ......
grant replication slave on *.* to 'guest'@'192.168.1.%' identified by '123456'
change master to master_host='192.168.1.190',master_user='guest',master_password='123456',master_port=3306
mysql> change master to master_host='192.168.1.190',master_user='guest',master_password='123456',master_log ......
MySQL
ÊÇÒ»¸ö·Ç³£Á÷ÐеÄСÐ͹ØϵÐÍÊý¾Ý¿â¹ÜÀíϵͳ£¬2008Äê1ÔÂ16ºÅ±»Sun¹«Ë¾ÊÕ¹º¡£Ä¿Ç°MySQL±»¹ã·ºµØÓ¦ÓÃÔÚInternetÉϵÄÖÐСÐÍÍøÕ¾ÖС£ÓÉ
ÓÚÆäÌå»ýС¡¢Ëٶȿ졢×ÜÌåÓµÓгɱ¾µÍ£¬ÓÈÆäÊÇ¿ª·ÅÔ´ÂëÕâÒ»Ìص㣬Ðí¶àÖÐСÐÍÍøվΪÁ˽µµÍÍøÕ¾×ÜÌåÓµÓгɱ¾¶øÑ¡ÔñÁËMySQL×÷ΪÍøÕ¾Êý¾Ý¿â¡£
1¡¢phpMyAdmin£¨http://www.phpmyadmin.ne ......
mysqlÊÇÒ»¸öÓÅÐãµÄ¿ªÔ´Êý¾Ý¿â£¬ËüÏÖÔÚµÄÓ¦Ó÷dz£µÄ¹ã·º£¬Òò´ËºÜÓбØÒª¼òµ¥µÄ½éÉÜÒ»ÏÂÓÃpython²Ù×÷mysqlÊý¾Ý¿âµÄ·½·¨¡£python²Ù×÷Êý¾Ý¿âÐèÒª°²×°Ò»¸öµÚÈý·½µÄÄ£¿é£¬ÔÚhttp://mysql-python.sourceforge.net/
ÓÐÏÂÔغÍÎĵµ¡£
ÓÉÓÚpythonµÄÊý¾Ý¿âÄ£¿éÓÐרÃŵÄÊý¾Ý¿âÄ£¿éµÄ¹æ·¶£¬ËùÒÔ£¬Æäʵ²»¹ÜʹÓÃÄÄÖÖÊý¾ ......