mysqlÄÚ´æ±íheapʹÓÃ×ܽá
ÄÚ´æ±íʹÓùþϣɢÁÐË÷Òý°ÑÊý¾Ý±£´æÔÚÄÚ´æÖУ¬Òò´Ë¾ßÓм«¿ìµÄËٶȣ¬Êʺϻº´æÖÐСÐÍÊý¾Ý¿â£¬µ«ÊÇʹÓÃÉÏÊܵ½Ò»Ð©ÏÞÖÆ£¬ÒÔÏÂÊÇÀ¶²ÝʹÓõÄһЩ¸ÐÊÜ¡£
1¡¢heap¶ÔËùÓÐÓû§µÄÁ¬½ÓÊǿɼûµÄ£¬ÕâʹµÃËü·Ç³£ÊʺÏ×ö»º´æ¡£
2¡¢½öÊʺÏʹÓõij¡ºÏ¡£heap²»ÔÊÐíʹÓÃxxxTEXTºÍxxxBLOBÊý¾ÝÀàÐÍ£»Ö»ÔÊÐíʹÓÃ=ºÍ<=>²Ù×÷·ûÀ´ËÑË÷¼Ç¼£¨²»ÔÊÐí<¡¢>¡¢<=»ò>=£©£»²»Ö§³Öauto_increment£»Ö»ÔÊÐí¶Ô·Ç¿ÕÊý¾ÝÁнøÐÐË÷Òý£¨not null£©¡£
×¢£º²Ù×÷·û “<=>” ˵Ã÷£ºNULL-safe equal.Õâ¸ö²Ù×÷·ûºÍ“=”²Ù×÷·ûÖ´ÐÐÏàͬµÄ±È½Ï²Ù×÷£¬²»¹ýÔÚÁ½¸ö²Ù×÷Âë¾ùΪNULLʱ£¬ÆäËùµÃֵΪ1¶ø²»ÎªNULL£¬¶øµ±Ò»¸ö²Ù×÷ÂëΪNULLʱ£¬ÆäËùµÃֵΪ0¶ø²»ÎªNULL¡£
3¡¢Ò»µ©·þÎñÆ÷ÖØÆô£¬ËùÓÐheap±íÊý¾Ý¶ªÊ§£¬µ«ÊÇheap±í½á¹¹ÈÔÈ»´æÔÚ£¬ÒòΪheap±í½á¹¹ÊÇ´æ·ÅÔÚʵ¼ÊÊý¾Ý¿â·¾¶Ïµģ¬²»»á×Ô¶¯É¾³ý¡£ÖØÆôÖ®ºó£¬heap½«±»Çå¿Õ£¬Õâʱºò¶ÔheapµÄ²éѯ½á¹û¶¼Êǿյġ£
4¡¢Èç¹ûheapÊǸ´ÖƵÄijÊý¾Ý±í£¬Ôò¸´ÖÆÖ®ºóËùÓÐÖ÷¼ü¡¢Ë÷Òý¡¢×ÔÔöµÈ¸ñʽ½«²»¸´´æÔÚ£¬ÐèÒªÖØÐÂÌí¼ÓÖ÷¼üºÍË÷Òý£¬Èç¹ûÐèÒªµÄ»°¡£
5¡¢¶ÔÓÚÖØÆôÔì³ÉµÄÊý¾Ý¶ªÊ§£¬ÓÐÒÔϵĽâ¾ö°ì·¨£º
¡¡a¡¢ÔÚÈκβéѯ֮ǰ£¬Ö´ÐÐÒ»´Î¼òµ¥µÄ²éѯ£¬ÅжÏheap±íÊÇ·ñ´æÔÚÊý¾Ý£¬Èç¹û²»´æÔÚ£¬Ôò°ÑÊý¾ÝÖØÐÂдÈ룬»òÕßDROP±íÖØи´ÖÆijÕÅ±í¡£ÕâÐèÒª¶à×öÒ»´Î²éѯ¡£²»¹ý¿ÉÒÔд³ÉincludeÎļþ£¬ÔÚÐèÒªÓøÃheap±íµÄÒ³ÃæËæʱµ÷Ó㬱ȽϷ½±ã¡£
¡¡b¡¢¶ÔÓÚÐèÒª¸Ãheap±íµÄÒ³Ã棬ÔÚ¸ÃÒ³ÃæµÚÒ»´ÎÇÒ½öÔÚµÚÒ»´Î²éѯ¸Ã±íʱ£¬¶ÔÊý¾Ý¼¯½á¹û½øÐÐÅжϣ¬Èç¹û½á¹ûΪ¿Õ£¬ÔòÐèÒªÖØÐÂдÈëÊý¾Ý¡£ÕâÑù¿ÉÒÔ½ÚÊ¡Ò»´Î²éѯ¡£
¡¡c¡¢¸üºÃµÄ°ì·¨ÊÇÔÚmysqlÿ´ÎÖØÐÂÆô¶¯Ê±×Ô¶¯Ð´ÈëÊý¾Ýµ½heap£¬µ«ÊÇÐèÒªÅäÖ÷þÎñÆ÷£¬¹ý³Ì±È½Ï¸´ÔÓ£¬Í¨ÓÃÐÔÊܵ½ÏÞÖÆ¡£
¡¡À¶²ÝÄ¿Ç°²ÉÓõÄÊǵڶþÖÖ°ì·¨¡£
6¡¢Ò»Ð©Ô¤ÆÚ¿ÉÄÜÓõ½µÄsqlÓï¾ä
//Èç¹û±í´æÔÚ£¬Ôòɾ³ý
DROP TABLE IF EXISTS `abc`;
//¸´ÖÆÕûÕűíxyzΪheap±íabc£¨°üº¬ËùÓÐÊý¾Ý£©
CREATE TABLE `abc` type=heap select * from `xyz`;
//Ìí¼ÓÖ÷¼üid
ALTER TABLE `abc` ADD PRIMARY KEY (`id`);
//Ìí¼ÓË÷Òýusername
ALTER TABLE `abc` ADD INDEX `abc` (`username`);
7.½¨±íʵÀý
CREATE TABLE `DB` (
`id` int(11) default NULL,
`songname` varchar(255) NOT NULL default '',
`singer` varchar(255) NOT NULL default '',
KEY `songname` (`songname`,`singer`)
) TYPE=HEAP
½¨±íʱTABLE TYPE Ñ¡ÏîÒ²ÓÐ
Õâ¸ö±í½á¹¹¾ÍÊǽ¨Á¢ÁËÄÚ´
Ïà¹ØÎĵµ£º
×î½üÔÚMySQLÉÏ×öÁ˵㹤×÷£¬·¢ÏֺܶàÈ˶¼ÔÚѯÎÊMySQLǶÌײéѯµÄÎÊÌ⣬Ðí¶àÈ˶¼¾õµÃMySQL²»Ö§³ÖǶÌײéѯ£¬ÆäʵMySQl´Ó4.11°æºóÒѾÍêÈ«Ö§³ÖǶÌײéѯÁË£¬ÄÇôÏÂÃæÎÒ¾ÙЩ¼òµ¥µÄǶÌײéѯµÄÀý×Ó°É£¨Ô´³ÌÐòÀ´×ÔMySQL User Manual£©£º
1. SELECTÓï¾äµÄ×Ó²éѯ:
Óï·¨: SELECT ... from (subquery) AS name ...
ÏÈ´´½¨Ò»¸ö±í:
......
DELIMITER $$
DROP PROCEDURE IF EXISTS `heli`.`prodtest` $$
CREATE PROCEDURE `heli`.`prodtest` ()
BEGIN
/*¾Ö²¿±äÁ¿µÄ¶¨Òå declare*/
declare pid varchar(45) default '';
declare pq int default 0;
declare pk double default 0.0;
declare cur1 CURSOR FOR SELECT pro ......
ÎÒÔڵǼMySQLºóµÄÃüÁîÐÐÊÇÕâ¸öÑù×ӵģº
warmbupt@pchuang:/windows/MyCode/SS$ mysql -u root -ppassw0rd
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.1.37-1ubuntu5.1 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the curr ......
¹«Ë¾mysqlͳһÓÃlatin1µÄ±àÂ룬ÕæÊǽÐÈ˿಻¿°ÑÔ¡£DjangoÓÃĬÈÏUTF8·ÃÎÊMYSQLÊý¾Ý¿â¡£ÔÚ²Ù×÷Êý¾Ý¿âʱ£¬²»¹ÜÄãÔõôתÂ룬×îÖÕдµ½Êý¾Ý¿âÀïµÄÖÐÎĶ¼ÊÇÂÒÂë¡£ÔÚÍøÉÏÕÒÁ˺ܾã¬Ò²Ã»½â¾öÕâ¸öÎÊÌâ¡£
ºóÀ´¿´ÁËÒ»¸öDJANGOµÄMYSQL²Ù×÷µÄÔ´Â룬·¢ÏÖÁËһЩÎÊÌâ ÏÈÊÇ/d ......