mysql µ¼³ö csvÊý¾ÝÃüÁî
µ¼³ö
select field1,field2,field3 from tablename into outfile '/home/output1.csv' fields terminated by ','optionally enclosed by ''lines terminated by '\n';
µ¼Èë
load data local infile '/home/output1.csv' into table tablename fields terminated by ','lines terminated by '\n'(field1,field2,field3);
×¢Òâ:
1.дÎļþµÄÄ¿±êĿ¼ÐèÒªÊÇmysqlÓµÓÐдȨÏÞµÄĿ¼¡£
Ïà¹ØÎĵµ£º
½ñÌìÓöµ½Êý¾Ý¿âµÄÒ»¸öÎÊÌ⣬¾ÍÊÇÿµ±´ÓÖ÷±íÖÐɾ³ýÒ»¸öÖ÷¼üidʱ£¬ÓÉÓÚÓëËûÏà¹ØÁªµÄ±íÖÐÓÐÏà¹ØµÄ×Ö¶ÎÊý¾Ý£¬ËùÒÔÎÞ·¨É¾³ý¡£²éÁËÒ»´ó¶Ñ×ÊÁÏ£¬·¢ÏÖÎÒ½¨±í¹ØÁªÓõÄÊÇon Restrict.¿ÉÄÜÎÊÌâ¾Í³öÔÚÕâÀï°É¡£
Íâ¼üÔ¼Êø¶Ô×Ó±íµÄº¬Òå:
Èç¹ûÔÚ¸¸±íÖÐÕÒ²»µ½ºòÑ¡¼ü,Ôò²»ÔÊÐíÔÚ×Ó±íÉϽøÐÐinsert/update
Íâ¼üÔ¼Êø ......
¸÷λ¸ßÊֺá£Ð¡µÜѧϰJAVA²»¾Ã£¬È»ºóÔÙÓÃMYSQLÊý¾Ý¿â¡£
ÓÉÓÚÊÇÓñðÈ˵ĵķ¶Àýѧϰ£¬ËùÒÔ³öÏֺܶàÆæ¹ÖµÄÎÊÌâ
ÎÒÓÃ×Ô¼ºµÄMYSQL ·þÎñÆ÷£¬È»ºó°Ñ±ðÈ˵ÄÊý¾Ý¿âµ¼½øÀ´¡£È»ºó³öÏÖ°æ±¾ÎÊÌâ¡£
ÎÊÌâÈçÏÂ
Table './db_librarysys/tb_manager' was created with a different version of MySQL and cannot be read
2010-4-28 22:44 ......
ERROR 1005 (HY000): Can't create table ' ****.frm' (errno: 150)
ÎÒÊÇ´ÓÒÔϼ¸¸ö·½Ãæ½â¾öÁË´ËÎÊÌ⣺
1¡¢È·±£²ÎÕյıíºÍ×Ö¶ÎÊÇ´æÔڵģ»
2¡¢×é³ÉÍâ¼üµÄ×Ö¶ÎÒªÇó±»Ë÷Òý(Ö÷ÒªÊÇÍâ¼üÄǸö×Ö¶ÎÒªÇóÔÚÆäËû±íÖÐÊÇÖ÷¼ü)£»
3¡¢Íâ¼ü¹ØÁªµÄÁ½±í»ò¶à±íÒªÇó¶¼ÊÇINNODBÀàÐÍµÄ±í£»
4¡¢×Ö¶ÎÀàÐÍ£¨ËµÃ÷£©ÒªÒ»Ñù`itemId` varchar( ......
½ñÌìÔÚʵ¼Ê¿ª·¢ÖжÔÓÚMySQLÊý¾Ý¿â½øÐÐÒÆÖ²·¢ÉúµÄÎÊÌâÀ´ËµÏÂ. ¿ªÊ¼°Ñ±¾µØdataÖеÄÊý¾Ý¿âÎļþ¿½±´µ½Áíһ̨»ú×ÓÉÏTest, Ö´ÐÐshow tables ; ¿ÉÒÔ¿´µ½Êý¾Ý¿â±í,µ«ÊǶԱí½øÐÐÈκβÙ×÷¶¼±¨´í: ±í²»´æÔÚ , ÔÒÔΪMysqlµÄÊý¾Ý¿âÎļþ(.frm)Copy->stickµ½±¾µØ°²×°MySQLDBĿ¼µÄdataÎļþ¼ÐϾͿÉÒÔ.ÊÂʵ²»Ê ......
ÕâÀïÊÕ¼¯¸÷ÖÖMysqlµÄ»ù´¡ÖªÊ¶,ΪÁËijЩ³¡ºÏµÄÐèÒª,»¹ÊÇÉáÆúnavicatÖ®ÀàµÄ¹¤¾ß¹Ô¹ÔÓÃÃüÁîÐаÉ
£¨×¢ÒâÓеÄÃüÁîÐèÒª·ÖºÅÓеIJ»ÐèÒª)
Ò».»ù±¾²Ù×÷
1.怬
mysql -u Óû§Ãû -pÃÜÂë Êý¾Ý¿âÃû
ÕâÀïÐè ......