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

mysql Ë÷Òý

1
Ë÷ÒýµÄÒâÒ壺
Óŵ㣺
Ë÷ÒýÓÃÀ´¿ìËÙµØÑ°ÕÒÄÇЩ¾ßÓÐÌØ¶¨ÖµµÄ¼Ç¼£¬Èç¹ûûÓÐË÷Òý£¬Ö´Ðвéѯʱ±ØÐë´ÓµÚÒ»¸ö¼Ç¼¿ªÊ¼É¨Ãè±íÖÐËùÓмǼ£¬±íÀïÃæµÄ¼Ç¼ÊýÁ¿Ô½¶à£¬Õâ¸ö²Ù×÷µÄ´ú¼Û¾ÍÔ½¸ß¡£
    
ȱµã£º
Ë÷ÒýÒªÕ¼ÓôÅÅ̿ռ䣻ÇÒÈκÎд²Ù×÷Éæ¼°µÄË÷Òý¸öÊý¶àµÄ»°»áÒýÆð½µËÙ£¬ÒòΪ
MySQL
²»½öÒª°Ñ¸Ä¶¯Êý¾ÝдÈëÊý¾ÝÎļþ£¬¶øÇÒËü»¹Òª°ÑÕâЩ¸Ä¶¯Ð´ÈëË÷ÒýÎļþ¡£
ÒÔϾͶÔË÷Òý£º
Index Test (col1,col2,col3)
½øÐзÖÎö£¬ÈçÓв»×¼È·Ö®´¦£¬»¶Ó­´ó¼ÒÅÄש¡£
2

´Ó×óÖÁÓÒµÄÕýÏòË÷ÒýÆ¥Å䣨µÚÒ»ÐÐÊÇË÷Òý¿ÉÓó¡¾°£¬µÚ¶þÐÐÊÇË÷Òý²»¿ÉÓó¡¾°£©
ÓұߵÄÊÊÓÃ
where
col1=$para1;
where
col1=$para1and col2=$para2;
where col1=$para1
and col2=$para2 and col3=$para3;
ÓұߵIJ»ÊÊÓÃ
where
col2=$para2;
where
col1=$para1and col3=$para3;
where col2=$para2
and col3=$para3;
 
 
 
3
like
ÓëË÷ÒýÓÐЧÐԵĹØÏµ£¨µÚÒ»ÐÐÊÇË÷Òý¿ÉÓó¡¾°£¬µÚ¶þÐÐÊÇË÷Òý²»¿ÉÓó¡¾°£©
ÓұߵÄÊÊÓÃ
where col1 like
‘aaa%’;
where col1 like
‘aaa%’ and col2 like ‘bbb%’ ;
where col1 like
‘aa%a%’ and col2 like ‘bb%b%’ ;
ÓұߵIJ»ÊÊÓÃ
where col1 like
‘%aaa’;  (
ͨÅä·ûÔÚǰ£¬ÎÞÈ·¶¨·¶Î§
)
where col1 like
‘%aaa’ and col2 like ‘%bbb’ ;
where col1 like
‘%aa%a’ and col2 like ‘%bb%b’
;
 
 
 
4
or
¡¢
and
ÓëË÷ÒýÓÐЧÐԵĹØÏµ£¨µÚÒ»ÐÐÊÇË÷Òý¿ÉÓó¡¾°£¬µÚ¶þÐÐÊÇË÷Òý²»¿ÉÓó¡¾°£©
ÓұߵÄÊÊÓÃ
where
col1=$para1and col2=$para2;
where
col1=$para1or col1=$para11; (
ͬһ
column
)
where col1=$para1
or col1=$para11 and col2=$para2;
ÓұߵIJ»ÊÊÓÃ
where
col1=$para1or col2=$para2;  (
ÎÞÈ·¶¨·¶Î§
)
where col1 like
‘%aaa’ or col2 like ‘%bbb’ ;
where col1=$para1
or col2=$para2 and
col3=$para3;
 
 
 
5

ÆäËû
mysql
ÄÚÖú¯ÊýÓëË÷ÒýÓÐЧÐԵĹØÏµ
(
ÒÔ
col1
¾ÙÀý
)

£¨µÚ¶þÁÐÊÇ¿ÉÓó¡¾°£¬µÚÈýÁÐÊDz»¿ÉÓó¡¾°£©
º¯ÊýÃû
¿ÉÓó¡¾°
²»¿ÉÓó¡¾°
Ìæ´ú°ì·¨
SUBSTRING
--
SUBSTRING
£¨
col1,1,2
£©
²»¿ÉÓ㬲ð·ÖÁË
sq


Ïà¹ØÎĵµ£º

MysqlÃüÁî

MySQL ÃüÁîÐÐ
µÚÒ»ÕС¢mysql·þÎñµÄÆô¶¯ºÍÍ£Ö¹
net stop mysql
net start mysql
µÚ¶þÕС¢µÇ½mysql
Óï·¨ÈçÏ£º mysql -uÓû§Ãû -pÓû§ÃÜÂë
¼üÈëÃüÁîmysql -uroot -p£¬ »Ø³µºóÌáʾÄãÊäÈëÃÜÂ룬ÊäÈë12345£¬È»ºó»Ø³µ¼´¿É½øÈëµ½mysqlÖÐÁË£¬mysqlµÄÌáʾ·ûÊÇ£º
mysql>
×¢Ò⣬Èç¹ûÊÇÁ¬½Óµ½ÁíÍâµÄ»úÆ÷ÉÏ£¬ÔòÐèÒª¼ÓÈëÒ»¸ö² ......

phpѧϰ±Ê¼Ç£¨9£©:Mysql¼ò½éºÍ´´½¨ÐµÄÊý¾Ý¿â

 
 Ò»¡¢MySql¼ò½é¸ÅÒª
MySQLÊÇÒ»¸öСÐ͹ØÏµÐÍÊý¾Ý¿â¹ÜÀíϵͳ£¬¿ª·¢ÕßΪÈðµäMySQL AB¹«Ë¾£¬ºóÀ´
±»Sun¹«Ë¾ÊÕ¹º£¬ÏÖÔÚÕýÔÚ±»¼×¹ÇÎÄÊÕ¹º£¬Ö§³ÖFreeBSD¡¢Linux¡¢MAC¡¢Windows
µÈ¶àÖÖ²Ù×÷ϵͳ ÓëÆäËûµÄ´óÐÍÊý¾Ý¿âÀýÈçOracle¡¢DB2¡¢SQL ServerµÈÏà±È¹¦ÄÜÉÔÈõ
һЩ  ÌâÍâ»°£ºPostgresql&n ......

mysql ÂÒÂëÎÊÌâ¡£

show variables like 'character%';²é¿´×Ö·û±àÂë
--¸ü¸Ä×Ö·û¼¯
SET character_set_client = utf-8 ;
SET character_set_connection = utf-8 ;
SET character_set_database = utf-8 ;
SET character_set_results = utf-8 ;
SET character_set_server = utf-8 ;
SET collation_connection = utf8 ;
SET colla ......

MYSQLÖÐµÄ constraint Óë CONSTRAINT

һֱϰ¹ßʹÓÃСдµÄSQL±£Áô×Ö£¬Ã»Ïëµ½½ñÌì¾ÓÈ»Óöµ½ÁËÂé·³¹þ£¡£¡ºÍгһÏÂMYSQLÀ²£¡
»·¾³£ºServer version: 5.1.37-1ubuntu5 (Ubuntu)
alter table child_table_name
add constraint constraint_name

foreign key (column_1)
references reference_table_name(reference_column_1);
ºÍ
ALTER  TABLE child_t ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ