´øÄãѧϰÓÐÓõÄ֪ʶ

×¢²á/µÇ¼|×î½ü·¢²¼|½ñÈÕÍƼö

Ö÷Ò³ ÈÕ³£°Ù¿ÆУ԰Éú»î½ÌÓý¿Æѧ
µ±Ç°Î»ÖãºÊ×Ò³ > ÈÕ³£

Éù²¨Çå»ÒÆ÷µÄÓÉÀ´ÊÇʲô£¬Éù²¨Çå»Òapp£¨MySQL06--£©

·¢²¼Ê±¼ä£º2023-06-10 22:04ÔðÈα༭£ººî´óʯ¹Ø¼ü´Ê£ºapp,ÓÉÀ´

¹ØÓÚ¡¾Éù²¨Çå»ÒÆ÷µÄÓÉÀ´ÊÇʲô¡¿£¬Éù²¨Çå»Òapp£¬½ñÌì Ä ÄС±à¸øÄú·ÖÏíһϣ¬Èç¹û¶ÔÄúÓÐËù°ïÖú±ðÍüÁ˹Ø×¢±¾Õ¾Å¶¡£

ÄÚÈݵ¼º½£º1¡¢MySQL06-- mysqlË÷Òý2¡¢Éù²¨Çå»ÒÆ÷µÄÓÉÀ´ÊÇʲô

1¡¢MySQL06-- mysqlË÷Òý

Ò».Ë÷Òý½éÉÜ

1.ʲôÊÇË÷Òý

1£©Ë÷Òý¾ÍºÃ±ÈÒ»±¾ÊéµØĿ¼£¬ËüÄÜÈÃÄã¸ü¿ìµÄÕÒµ½×Ô¼ºÏëÒªµÄÄÚÈÝ¡£2£©ÈûñÈ¡µÄÊý¾Ý¸üÓÐÄ¿µÄÐÔ£¬´Ó¶øÌá¸ßÊý¾Ý¿â¼ìË÷Êý¾ÝµÄÐÔÄÜ¡£

2.Ë÷ÒýÀàÐͽéÉÜ

1)BTREE:B+Ê÷Ë÷Òý ( Btree B+tree B*tree)2)HASH£ºHASHË÷Òý (hash key)3)FULLTEXT£ºÈ«ÎÄË÷Òý4)RTREE£ºRÊ÷Ë÷Òý

1.Btree :

2.BtreeË÷Òý£¨ÓÅ»¯Á˲éѯ·¶Î§£¬ÔÚÒ¶×Ó½ÚµãÌí¼ÓÁËÏàÁÚ½ÚµãµÄÖ¸Õ룩

3¡¤B*treeË÷Òý(ÔÚÖ¦½ÚµãÌí¼ÓÁËÖ¸Õë)

3.Ë÷Òý¹ÜÀí

Ë÷Òý½¨Á¢ÔÚ±íµÄÁÐÉÏ(×Ö¶Î)µÄ¡£ÔÚwhereºóÃæµÄÁн¨Á¢Ë÷Òý²Å»á¼Ó¿ì²éѯËٶȡ£pages<---Ë÷Òý£¨ÊôÐÔ£©<----²éÊý¾Ý¡£

1¡¢Ë÷Òý·ÖÀࣺ

Ö÷¼üË÷Òý£¨primary key£©ÆÕͨË÷Òý ( key)ΨһË÷Òý(unique key)

2¡¢Ìí¼ÓË÷Òý£º

4.ʵÀý£¨²Î¿¼£©

CREATE TABLE `test_table` (`ID` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Ö÷¼ü',`DOMAIN_CODE` varchar(20) NOT NULL COMMENT '¿¼ÊÔµ¥Î»±àºÅ',`EXAM_NAME` varchar(300) NOT NULL COMMENT '¿¼ÊÔÃû³Æ',`EXAM_TYPE` int(1) NOT NULL COMMENT '¿¼ÊÔÀàÐÍ(Õýʽ¿¼ÊÔ£¬²¹¿¼)',`TARGET_EXAM_ID` bigint(20) DEFAULT NULL COMMENT '¹ØÁªÕýʽ¿¼ÊÔµÄID(Èç¹ûÊDz¹¿¼£¬¸Ã´¦ÊDZØÌî)',`EXAM_PICTURE_PATH` varchar(100) DEFAULT NULL COMMENT 'ͼʾ·¾¶',`EXAM_BEGIN_TIME` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '¿¼ÊÔ¿ªÊ¼Ê±¼ä',`EXAM_END_TIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '¿¼ÊÔ½áÊøʱ¼ä',`EXAM_TIME` int(3) NOT NULL COMMENT '¿¼ÊÔʱ³¤',`EXAM_NEED_SCORE` int(5) NOT NULL COMMENT '¿¼ÊÔËùÐè»ý·Ö',`EXAM_PAPER_TYPE` int(1) DEFAULT NULL COMMENT '¿¼ÊÔÊÔ¾íÀàÐÍ£¨0¹Ì¶¨¡¢1Ëæ»ú£©',`EXAM_SCORE` double(6,2) DEFAULT NULL COMMENT '¿¼ÊÔ×Ü·Ö(¹ØÁªÊÔ¾íºó»ØÌî)',`EXAM_PASS_SCORE` double(6,2) NOT NULL COMMENT '¿¼ÊÔ¼°¸ñ·Ö',`EXAM_COMMIT_NUM` int(2) NOT NULL COMMENT '²Î¿¼×î´ó´ÎÊý',`EXAM_STATUS` int(1) NOT NULL COMMENT '·¢²¼×´Ì¬0δ·¢²¼£¬1ÒÑ·¢²¼',`EXAM_YEAR` varchar(5) NOT NULL COMMENT 'Äê·Ý',`EXAM_PAPER_ID` bigint(20) DEFAULT NULL COMMENT '¹ØÁªÊÔ¾íID',`EXAM_DISCRIPTION` varchar(1000) DEFAULT NULL COMMENT '¿¼ÊÔ±¸×¢',`OPERATOR_USER_ACCOUNT` varchar(20) NOT NULL COMMENT 'ÐÞ¸ÄÈË',`OPERATOR_TIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'ÐÞ¸Äʱ¼ä',`TARGET_DOMAIN_CODE` varchar(20) DEFAULT NULL COMMENT '·¢²¼Ä¿±êµ¥Î»±àºÅ£¨·¢²¼Ê±»ØÌ',`RANK` varchar(100) DEFAULT NULL COMMENT 'Ö°Îñ¼¶±ð£¨·¢²¼Ê±»ØÌ',`EXAM_DIPLOMA_ID` bigint(20) DEFAULT NULL COMMENT '¹ØÁªÖ¤Êé',`DIPLOMA_NAME` varchar(200) DEFAULT NULL COMMENT 'Ö¤Êé±êÌâ(¹ØÁªÖ¤Êéºó»ØÌî',`DIPLOMA_PICTURE_PATH` varchar(200) DEFAULT NULL COMMENT 'Ö¤Êé±³¾°Í¼Æ¬±£´æλÖÃ(¹ØÁªÖ¤Êéºó»ØÌî)',`INDUSTRY_CODES` varchar(1000) DEFAULT NULL,`LANGUAGE` int(2) NOT NULL DEFAULT '1' COMMENT '¨¨¡¥-¨¨¡§€???0:?¡­¡§¨¦?¡§,1:?¡À¡ë¨¨¡¥-,2:??¡ä¨¨¡¥-,3:¨¨¡¯¨¨¡¥-,4:?¡°?¨¨¡¥-??¡ë',`EXT1` int(1) NOT NULL DEFAULT '1' COMMENT '³É¼¨¼ÆÈëѧ·ÖµÄ×ֶαêʶ£¨0 ÊÇ£¬1·ñ£©',`EXT2` int(3) DEFAULT NULL COMMENT '³É¼¨ËùÕ¼±ÈÀý',`EXT3` varchar(1) DEFAULT NULL,`EXT4` varchar(1) DEFAULT NULL,`EXT5` varchar(1) DEFAULT NULL,#Ë÷ÒýPRIMARY KEY (`ID`),KEY `DOMAIN_CODE` (`DOMAIN_CODE`),KEY `EXAM_PAPER_ID` (`EXAM_PAPER_ID`)) ENGINE=InnoDB AUTO_INCREMENT=365 DEFAULT CHARSET=utf8;

5.Ë÷Òý²Ù×÷

#´´½¨ÆÕͨË÷Òýmysql> alter table student4 add index idx_sname(sname);#´´½¨Ö÷¼üË÷Òý mysql> alter table st add primary key pri_id(id);#´´½¨Ë÷Òýcreate index index_name on test(name);#ɾ³ýË÷Òýalter table test drop key index_name;# ÈçºÎÅжϣ¬¸ÃÁÐÊÇ·ñÄÜ´´½¨Î¨Ò»¼ü #ͳ¼ÆÐÐÊýmysql> select count(sgender) from student2; #ͳ¼ÆÈ¥ÖغóµÄÐÐÊýmysql> select count(distinct(sgender)) from student2;#Ìí¼ÓΨһÐÔË÷Òýalter table student add unique key uni_xxx(xxx);#²é¿´±íÖÐÊý¾ÝÐÐÊýselect count(*) from city;#²é¿´È¥ÖØÊý¾ÝÐÐÊýselect count(distinct name) from city;#²é¿´Ë÷ÒýÈýÖÖ·½Ê½mysql> desc student4;mysql> show index from student4;mysql> show create table student4;

6.ǰ׺Ë÷Òý

¸ù¾Ý×ֶεÄÇ°N¸ö×Ö·û½¨Á¢Ë÷Òý

#´´½¨Ç°×ºË÷Òý mysql> alter table student2 add index idx_sname2(sname(3));

1.±ÜÃâ¶Ô´óÁÐ ½¨Ë÷Òý2.Èç¹ûÓУ¬¾ÍʹÓÃǰ׺Ë÷Òý

7.ÁªºÏË÷Òý

¶à¸ö×ֶν¨Á¢Ò»¸öË÷Òý

Àý£ºwhere a.Å®Éú and b.Éí¸ß and c.ÌåÖØ and d.Éí²ÄºÃindex(a,b,c)Ìص㣺ǰ׺ÉúЧÌØÐÔa,ab,ac,abc,abcd ¿ÉÒÔ×ßË÷Òý»ò²¿·Ö×ßË÷Òýb bc bcd cd c d ba ... ²»×ßË÷Òý

Ô­Ôò£º°Ñ×î³£ÓÃÀ´×÷ΪÌõ¼þ²éѯµÄÁзÅÔÚ×îÇ°Ãæ

ÀýÈ磺ÏàÇ×ÍøÕ¾ sex money body age hight weight face name phone QQ wechat

»áÒ»°ã°Ñsex ÐÔ±ð·ÅÔÚµÚһλ¡£

#´´½¨people±ícreate table xiangqin( id, name varchar(10), age int, money bigint, body varchar(10), hight int, weight int, face varchar(10), phone varchar(11), sex enum('f','m')); #´´½¨ÁªºÏË÷Òý mysql> alter table xiangqin add index idx_all(sex,money,body,face); insert into xiangqin values('ly',30,999999999,'perfact',158,90,'nice','133','f'), ('qbl',58,1000000,'bad',150,150,'very bad','000','f'), ('wbq',50,9999999,'suibian',170,120,'suiyi',132,'m');#²éѯ ×ßË÷Òýmysql> select * from xiangqin where sex='f' and money>10000000 and body='perfact' and face='nice'; ²»×ßË÷Òýmysql> select * from xiangqin where money>10000000 and body='perfact' and face='nice'; mysql> select * from xiangqin where money>10000000 and body='perfact' and face='nice' and sex='f';

8.´´½¨Ë÷Òý×ܽ᣺

1.²»ÒªÔÚËùÓÐ×Ö¶ÎÉ϶¼´´½¨Ë÷Òý

2.Èç¹ûÓÐÐèÇó×ֶαȽ϶࣬ѡÔñÁªºÏË÷Òý

3.Èç¹ûÓÐÐèÇó×Ö¶ÎÊý¾Ý±È½Ï´ó£¬Ñ¡Ôñǰ׺Ë÷Òý

**4.Èç¹û¿ÉÒÔ´´½¨Î¨Ò»Ë÷Òý£¬Ò»¶¨´´½¨Î¨Ò»Ë÷Òý **

2¡¢Éù²¨Çå»ÒÆ÷µÄÓÉÀ´ÊÇʲô

Éù²¨Çå»ÒÆ÷µÄÓÉÀ´ÊÇʲô£¿

ÓÉÀ´£ºÔÚ20ÊÀ¼Í60Äê´úÄ©£¬ÈðµäÈ˳ɹ¦µØÑÐÖƳöÀûÓÃÉù²¨Çå»Ò¼¼ÊõÇå³ý¹ø¯Ñ̵ÀÄڵĻý»Ò£¬ºÜ¿ìÍƹãÓ¦ÓÃÓÚÅ·ÖÞ¡¢ÃÀ¹úºÍÈÕ±¾µÈ·¢´ï¹ú¼ÒµÄµçÕ¾¹ø¯¡£µ½ÉÏÊÀ¼Í80Äê´ú³õ£¬½öÅ·ÖÞ¾ÍÓÐ500¶ą̀¹ø¯°²×°ÁËÉù²¨Çå»Ò×°Ö㬲¢È¡µÃÁËÁ¼ºÃµÄʹÓÃЧ¹ûºÍÉç»á¾­¼ÃЧÒæ¡£¸Ã¼¼ÊõÔÚÖйúµçÕ¾ºÍÒ±½ðÐÐÒµÓ¦ÓõÄʱ¼äËä²»³¤£¬Í¬ÑùҲȡµÃÁ˽ϺõÄÓ¦ÓÃЧ¹ûºÍÉç»á¾­¼ÃЧÒæ¡£½á¹¹Ô­Àí£º Éù²¨Çå»ÒÆ÷ÓÉÆø--Éùת»»×°Ö㨵ÍƵ--ÐýµÑ½á¹¹ºÍĤƬ½á¹¹£¬¸ßƵ--¹þÌØÂüÉڽṹ£©¡¢Éù²¨µ¼¹Ü£¨À®°È£©¡¢Æø·¿ØÖÆ×é¼°¿ØÖƹñ£¨Ï䣩×é³É¡£Éù²¨Çå»ÒÆ÷½«Ñ¹Á¦ÆøÌ壨ѹËõ¿ÕÆø¡¢µªÆøµÈ£©µÄ¶¯ÄÜת»»ÎªÉù²¨µÄ²¨¶¯ÄÜÁ¿£¬ÀûÓÃÉù²¨µÄ²¨¶¯ÄÜÁ¿£¬Ê¹¸÷ÖֶѻýÎï²úÉúλÒƶøÀ뿪ԭÀ´Î»Ö㬴Ӷø´ïµ½Çå³ý»ý»ÒºÍÊèͨµÄÄ¿µÄ¡£

Éù²¨Çå»ÒÆ÷³ý»ÒЧ¹û£¿

Éù²¨Çå»ÒÆ÷Ö÷Òª¾ÍÊÇÓÃÀ´³ý»ÒµÄ£¬Ò»°ã¹ºÂòÕâÖÖÉ豸µÄ¿Í»§¶¼ÊÇÆóÒµÓû§£¬ÕâÖÖÉ豸ÓÉÓÚÒ»°ã²É¹º¶¼ÊǺü¸Ì¨½øÐж©¹º£¬ËùÒÔ»¨·ÑµÄ·ÑÓÃ×ÔÈ»²»ÉÙ£¬ºÜ¶àÈ˶¼ÔÚÖÊÒÉÉù²¨Çå»ÒÆ÷ÕæµÄ¿ÉÒÔÇå³ý»ý»ÒÂð?ÆäʵÕâÒ²ÊÇ´óÖÚÓû§µÄÐÄÀí£¬Ç뿴רҵ·ÖÎö¡£

Éù²¨Çå»ÒÆ÷ÆäʵÔÚÖйúÊг¡Æð²½²»ËãÔ磬µ«ÊÇËæ×ÅÖйú¹¤ÒµµÄ·¢Õ¹£¬»·±£µÄ¼ÓÇ¿£¬Ê¹µÃÕâÖÖ¾»»¯·ÏÆøµÄÉ豸µÃµ½ÁË´óÁ¿µÄʹÓ㬴«Í³µÄÇå»ÒÆ÷£¬²»½öÌå»ý´ó£¬¶øÇÒ°²×°À§ÄÑ£¬·ÑÓÃÒ²·Ç³£µÄ¸ß£¬Çå»ÒЧ¹ûÒ²²»³¹µ×£¬Éù²¨Çå»ÒÆ÷µÄ³öÏÖ½â¾öÁËÕâЩÎÊÌ⣬ÆäʵÏñÊг¡ÉÏËù˵µÄÍÑÏúÉù²¨Çå»ÒÆ÷£¬Éù²¨Éù²¨´µ»ÒÆ÷µÈ£¬¾ÍÊǽñÌìËù½éÉܵÄË׳ÆÉù²¨Çå»ÒÆ÷£¬Ö»²»¹ýÊÇÓкܶà±ðÃû¶øÒÑ¡£ÊµÖʶ¼ÊÇÒ»ÑùµÄ£¬Ã»ÓÐÌ«´óµÄÇø·Ö¡£

Éù²¨Çå»ÒÆ÷Æäʵ¾ÍÖ÷Òª»¹ÊÇÓÃÓÚÆóÒµ¹ø¯´µ»Òµ±ÖУ¬ÓÉÓÚ¹ø¯³¤Ê±¼äʹÓûáÔì³É´óÁ¿µÄ»ý»Ò¶ÂÈû£¬Èç¹û²»½øÐÐÇå³ý£¬¿Ï¶¨»áÓ°Ïì¹ø¯µÄʹÓÃÊÙÃü£¬Éù²¨Çå»Ò²É¹ºÉù²¨Õð¶¯Ê¹¹ø¯ÄڵĻý»Ò½øÐÐÍÑÂä»òÕßÒƶ¯£¬È»ºó½øÐÐÅÅ·Å£¬ÕâÖÖÔ­ÀíÅÅ·Å»ý»Ò¸ü¼ÓµÄ³¹µ×£¬Í¬Ê±µ±¹ø¯ÔËʱ£¬Í¬Ê±¿ªÆôÉù²¨Éù²¨´µ»ÒÆ÷£¬ÕâÑù¾Í¿ÉÒÔ½øÐÐÇå»ÒÁË£¬²Ù×÷Ò²·Ç³£µÄ¼òµ¥£¬¶øÇÒÏà±È´«Í³Çå»ÒÉ豸¸ü¼ÓµÄ½ÚÔ¼³É±¾¡£

ÖйúËäÈ»²»Êǹ¤Òµ·¢´ï¹ú¼Ò£¬µ«ÊÇËæןĸ↑·ÅÖ®ÒԺ󣬹¤ÒµµÃµ½Á˾޴óµÄ·¢Õ¹£¬Éù²¨Çå»ÒÆ÷Ö÷ÒªÓÃÓÚ¹¤Òµ¹ø¯Çå»Ò£¬ÕâÖÖÉ豸¾ßÓÐÒ»¶¨µÄ»·±£ÐÔ£¬ÊʺϹúÄڵķ¢Õ¹ÐèÇó¡£

Éù²¨Çå»ÒÆ÷¿ÉÒÔÓ¦ÓÃÔÚÄÄЩ³¡Ëù£¿

1¡¢Çå³ý·ç»úҶƬÉϵĻý»Ò£¬½â¾öË®ÄàĥϵͳµÄÑ­»··ç»ú»ý»ÒÑÏÖصÄÎÊÌ⣬ÇåÀí²»¾ÃÓÖÕ³ÔÚ·çÒ¶ÉÏÔì³É·ç»úµÄ·çÁ¿´ó·ù¼õÉÙµÄÏÖÏó;

2¡¢ÔËÓÃÉù²¨¿ÉÒÔ±£³Ö¶à¿×°åÇå½à²¢È·±£ÕýÈ·µÄÆøÁ÷·Ö²¼;

3¡¢¿É×÷Ϊ´üʽ³ý³¾Æ÷µÄ¸¨ÖúÇå»Ò»òµ¥¶ÀÇå»Òϵͳ;

4¡¢¶Ô¾²µç³ý³¾Æ÷¼«°åºÍ¼«Ïߵĸ¨ÖúÇå»Ò;

5¡¢Çå³ý¾²µç³ý³¾Æ÷Èë¿Ú¾ùÁ÷¿×°åµÄ»ý»Ò;

6¡¢Ìá¸ßµç³ý³¾Æ÷ÓëÂË´üÊÒµÄÊÕ³¾Ð§¹û£¬´Ù½øÎïÁÏÁ÷¶¯£¬ÓÐ×èÓÚÑÓ³¤ÂË´üÊÒ¼°¿ÕÆøÎÛȾ¿ØÖÆÉ豸µÄʹÓÃÊÙÃü;

7¡¢Çå³ý·ç»úÄڿǺÍת×ÓÉϵĻý»Ò;

8¡¢Çå³ýÁϲ֡¢»Ò¶·ÄÚ±ÚÉϵĻý»Ò;

9¡¢Çå³ý¹ø¯¹Ü·ºÍ¿ÕÆøÔ¤ÈÈÆ÷¡¢Ê¡ÃºÆ÷¡¢»»ÈÈÆ÷±íÃæ»ý»ÒµÈ;

10¡¢Çå³ý¹ÜµÀÄڵĻý»Ò;

11¡¢Çå³ýÁϲ֡¢»Ò¶·ÄڵļÜÇÅ¡¢Êó¶´ÏÖÏó;

12¡¢Çå³ýÅçÎí¸ÉÔïËþÄÚ±Ú½á¿é; ? ? ? ? ? ? ? ? ?

±¾ÎĹؼü´Ê£ºÉù²¨Çå»ÒÆ÷µÄ¹¤×÷Ô­Àí£¬Éù²¨Çå»ÒÆ÷µÄÓÉÀ´ÊÇʲôÑùµÄ£¬Éù²¨Çå»ÒÒôƵ£¬Éù²¨ÇåÀí»Ò³¾ÊÇÕæÊǼ٣¬Éù²¨Çå»ÒÆ÷Ч¹û¡£Õâ¾ÍÊǹØÓÚ¡¶Éù²¨Çå»ÒÆ÷µÄÓÉÀ´ÊÇʲô£¬Éù²¨Çå»Òapp£¨MySQL06--£©¡·µÄËùÓÐÄÚÈÝ£¬Ï£Íû¶ÔÄúÄÜÓÐËù°ïÖú£¡

֪ʶÍƼö

¸ßÓÅ֪ʶÍø¡ª¡ª·ÖÏíÓÐÓõÄÉú»î°Ù¿Æ£¬Ò»ÆðѧϰÓÅÐãµÄ֪ʶ¡£ À¬»øÐÅÏ¢´¦ÀíÓÊÏä tousu446@163.com ÍøÕ¾µØͼ
icp±¸°¸ºÅ ÃöICP±¸2023005118ºÅ-3 »¥ÁªÍø°²È«¹ÜÀí±¸°¸ ²»Á¼ÐÅÏ¢¾Ù±¨Æ½Ì¨ Copyright 2023 www.gaoyou91.com All Rights Reserved