MYSQL·Ö±íÓÅ»¯
ÎÒÃǵÄÏîÄ¿ÖÐÓкö಻µÈÓÚµÄÇé¿ö¡£½ñÌìдÕâƪÎÄÕ¼òµ¥µÄ·ÖÎöÒ»ÏÂÔõô¸öÓÅ»¯·¨¡£
ÕâÀïµÄ·Ö±íÂß¼ÊǸù¾Ýt_group±íµÄuser_name×éµÄ¸öÊýÀ´·ÖµÄ¡£
ÒòΪÕâÖÖÇé¿öµ¥¶Àuser_name×Ö¶ÎÉϵÄË÷Òý¾ÍÊôÓÚÀÃË÷Òý¡£Æð²»ÁËɶÃûÃ÷ÏÔµÄЧ¹û¡£
1¡¢ÊÔÑéPROCEDURE.
DELIMITER $$
DROP PROCEDURE `t_girl`.`sp_split_table`$$
CREATE PROCEDURE `t_girl`.`sp_split_table`()
BEGIN
declare done int default 0;
declare v_user_name varchar(20) default '';
declare v_table_name varchar(64) default '';
-- Get all users' name.
declare cur1 cursor for select user_name from t_group group by user_name;
-- Deal with error or warnings.
declare continue handler for 1329 set done = 1;
-- Open cursor.
open cur1;
while done <> 1
do
fetch cur1 into v_user_name;
if not done then
-- Get table name.
set v_table_name = concat('t_group_',v_user_name);
-- Create new extra table.
set @stmt = concat('create table ',v_table_name,' like t_group');
prepare s1 from @stmt;
execute s1;
drop prepare s1;
-- Load data into it.
set @stmt = concat('insert into ',v_table_name,' select * from t_group where user_name = ''',v_user_name,'''');
prepare s1 from @stmt;
execute s1;
drop prepare s1;
end if;
end while;
-- Close cursor.
close cur1;
-- Free variable from memory.
set @stmt = NULL;
END$$
DELIMITER ;
2¡¢ÊÔÑé±í¡£
ÎÒÃÇÓÃÒ»¸öÓÐһǧÍòÌõ¼Ç¼µÄ±íÀ´×ö²âÊÔ¡£
mysql> select count(*) from t_group;
+----------+
| count(*) |
+----------+
| 10388608 |
+----------+
1 row in set (0.00 sec)
±í½á¹¹¡£
mysql> desc t_group;
+-------------+------------------+------+----
Ïà¹ØÎĵµ£º
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@localhost]# mysql -u root -p
Enter password:
ERROR 2002 (H ......
mysql> SOURCE [·¾¶]ÎļþÃû
ÓÐÁ½ÖÖд·¨£º
1¡¢
mysql> SOURCE cr_pet_tbl.sql
Õâ¸öʱºò£¬cr_pet_tbl.sql±ØÐë·ÅÔÚÄãµÄmysql/binĿ¼ÏÂÃ棬¼´¸úmysql.exeͬһĿ¼
2¡£
mysql> SOURCE c:\cr_pet_tbl.sql
Õâ¸öʱºòλÖÃλÖÃÕýÈ·¼´¿É£¬ ......
mysqldump -uÓû§Ãû -pÃÜÂë Êý¾Ý¿âÃû >dumpÎļþµÄ·¾¶ºÍÃû³Æ
mysql> source dump.sql
There are three general ways to invoke mysqldump:
shell> mysqldump [options] db_name [tbl_name ...]
shell> mysqldump [options] --databases db_name ...
shell> mysqldump [options] --all-databases
......
---------------------------------------------------------------------------
---- ±¾ÎÄΪandkylee¸öÈËÔ´´£¬ÇëÔÚ×ðÖØ×÷ÕßÀͶ¯³É¹ûµÄÇ°ÌáϽøÐÐתÔØ£»
---- תÔØÎñ±Ø×¢Ã÷Ôʼ³ö´¦
:
http://blog.csdn.net/andkylee
--- 2010-05-31 18:46:12
---- ¹Ø¼ü×Ö£º MySQL ·ÖÒ³ limit
----------------------- ......
¹«Ë¾¿ª·¢ÁËÒ»¸öÍøÕ¾£¬¹À¼Æ×î¸ßÔÚÏßÈËÊýÊÇ3 Íò£¬²¢·¢ÈËÊý×î¶à100 ÈË¡£¿ª·¢µÄÍøÕ¾ÊÇ·ñÄÜ·ñ³ÐÊÜÕâ¸öѹÁ¦£¬ÈçºÎÈ·±£ÍøÕ¾µÄ¸ººÉûÓÐÎÊÌ⣬¾¹ýÑо¿¾ö¶¨ÈçÏ£º
£¨1 £©²ÉÓøºÔØƽºâºÍ¼¯Èº¼¼Êõ£¬³õ²½»ú¹¹²ÉÓÃApache Tomcat µÄ»úȺ¼¼Êõ¡£
£¨2 £©²ÉÓÃѹÁ¦²âÊÔ¹¤¾ß£¬²âÊÔѹÁ¦¡£¹¤¾ßÊÇLoadrunner.
Ó²¼þ»·¾³´î½¨£º
ΪÁËÄܹ»½øÐÐѹÁ¦² ......