MysqlÂÒÂë
PHP ´æÈ¡ MySQL ÂÒÂëÎÊÌâ
ÉÏһƪ / ÏÂһƪ 2007-06-04 03:33:50 / ¸öÈË·ÖÀࣺPHPѧϰ
²é¿´( 239 ) / ÆÀÂÛ( 0 ) / ÆÀ·Ö( 0 / 0 )
MySQL µÄ×Ö·û¼¯Ö§³Ö(Character Set Support)ÓÐÁ½¸ö·½Ã棺×Ö·û¼¯(Character set)ºÍÅÅÐò·½Ê½(Collation)¡£¶ÔÓÚ×Ö·û¼¯µÄÖ§³Öϸ»¯µ½Ëĸö²ã´Î: ·þÎñÆ÷(server)£¬Êý¾Ý¿â(database)£¬Êý¾Ý±í(table)ºÍÁ¬½Ó£¨connection£©¡£
²é¿´ÏµÍ³µÄ×Ö·û¼¯ºÍÅÅÐò·½Ê½µÄÉ趨¿ÉÒÔͨ¹ýÏÂÃæµÄÁ½ÌõÃüÁ
²é¿´×Ö·û¼¯£º
mysql> SHOW VARIABLES LIKE 'character_set_%';
ÏÔʾ×Ö·û¼¯ÉèÖÃÈçÏ£º
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
²é¿´ÅÅÐò·½Ê½(Collation)
mysql> SHOW VARIABLES LIKE 'collation_%';
ÏÔʾĬÈÏÖµ£º
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
ÉÏÃæÁгöµÄÖµ¾ÍÊÇϵͳµÄĬÈÏÖµ¡£Èç¹ûÄãÆæ¹ÖϵͳÔõôĬÈÏÊÇlatin1µÄÈðµäÓïÅÅÐò·½Ê½,ÔÒòÊÇMySQLÓÉÈðµäµÄT.c.X.DataKonsultAB¹«Ë¾(Ä¿Ç°¹«Ë¾Ãû³ÆΪMySQL AB)¿ª·¢£¬²»ÓÃÔÙ¶à˵ÁË°É¡£
µ±ÎÒÃÇ°´ÕÕÔÀ´µÄ·½Ê½Í¨¹ýPHP´æÈ¡MySQLÊý¾Ý¿âʱ£¬¾ÍËãÉèÖÃÁ˱íµÄĬÈÏ×Ö·û¼¯Îªutf8²¢ÇÒͨ¹ýUTF-8±àÂë·¢ËͲéѯ£¬Äã»á·¢ÏÖ´æÈëÊý¾Ý¿âµÄÈÔÈ»ÊÇÂÒÂë¡£ÎÊÌâ¾Í³öÔÚÕâ¸öconnectionÁ¬½Ó²ãÉÏ¡£½â¾ö·½·¨ÊÇÔÚ·¢ËͲéѯǰִÐÐÒ»ÏÂÏÂÃæÕâ¾ä£º
SET NAMES ‘utf8′;
ËüÏ൱ÓÚÏÂÃæµÄÈý¾äÖ¸Á
SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;
ÔÙÊÔÊÔ¿´£¬Õý³£ÁË°
Ïà¹ØÎĵµ£º
ÄÚ´æ±íʹÓùþϣɢÁÐË÷Òý°ÑÊý¾Ý±£´æÔÚÄÚ´æÖУ¬Òò´Ë¾ßÓм«¿ìµÄËٶȣ¬Êʺϻº´æÖÐСÐÍÊý¾Ý¿â£¬µ«ÊÇʹÓÃÉÏÊܵ½Ò»Ð©ÏÞÖÆ£¬ÒÔÏÂÊÇÀ¶²ÝʹÓõÄһЩ¸ÐÊÜ¡£
1¡¢heap¶ÔËùÓÐÓû§µÄÁ¬½ÓÊǿɼûµÄ£¬ÕâʹµÃËü·Ç³£ÊʺÏ×ö»º´æ¡£
2¡¢½öÊʺÏʹÓõij¡ºÏ¡£heap²»ÔÊÐíʹÓÃxxxTEXTºÍxxxBLOBÊý¾ÝÀàÐÍ£»Ö»ÔÊÐíʹÓÃ=ºÍ<=>²Ù×÷·ûÀ´ËÑË÷¼Ç¼£¨²» ......
1¡¢Ñ¡È¡×îÊÊÓõÄ×Ö¶ÎÊôÐÔ
¡¡¡¡MySQL¿ÉÒԺܺõÄÖ§³Ö´óÊý¾ÝÁ¿µÄ´æÈ¡£¬µ«ÊÇÒ»°ã˵À´£¬Êý¾Ý¿âÖеıíԽС£¬ÔÚËüÉÏÃæÖ´ÐеIJéѯҲ¾Í»áÔ½¿ì¡£Òò´Ë£¬ÔÚ´´½¨±íµÄʱºò£¬ÎªÁË»ñµÃ¸üºÃµÄÐÔÄÜ£¬ÎÒÃÇ¿ÉÒÔ½«±íÖÐ×ֶεĿí¶ÈÉèµÃ¾¡¿ÉÄÜС¡£ÀýÈ磬ÔÚ¶¨ÒåÓÊÕþ±àÂëÕâ¸ö×Ö¶Îʱ£¬Èç¹û½«ÆäÉèÖÃΪCHAR(255),ÏÔÈ»¸øÊý¾Ý¿âÔö¼ÓÁ˲»±ØÒªµÄ¿Õ¼ä£¬ÉõÖÁʹ ......
1. mysql Ð޸ıíÃû×Ö
ALTER TABLE t1 RENAME t2;
2. ÐÞ¸ÄÁеÄÃû×Ö
>ALTER TABLE stock CHANGE COLUMN stock_id id INT(6);
3. Ôö¼ÓÁÐ
>ALTER TABLE ab ADD COLUMN id INT(3);
4. ¼õÉÙÁÐ
>ALTER TABLE ab DROP COLUMN id;
5. ÐÞ¸ÄÁ ......
µ¼ÈëÊý¾ÝÖ¸¶¨ÁÐ
load data local infile 'D:\\service_func_utf8.txt' into table service_func fields terminated by '\t' (service_id, func_id1, func_id2, func_id3, func_id4, func_id5, func_id6);
MYSQL½«²éѯ½á¹ûµ¼³öµ½Îļþ
select * from tablename into outfile '/tmp/test.txt';
MYSQLÁªºÏÖ÷¼ü
create  ......