Mysql???????輰???
???????????? ???????[ 2017/1/4 10:56:09 ] ????????MySQL ?????
????MySQL?????????
?????????????????????(InnoDB???????????????????????????)??????????????????????м???????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????λ????????????????????????????????????????м?????????????????????????е???????
?????????????????????????????????o?????????????????????????????????????????????????????o?????????б??????????????where??????????????????????С?????????????????????б?????????????????
????1. ??????? ???????(??????KEY??INDEX?????????)??????????????????????????????????Щ????????????????(WHERE column = ...)??????????(ORDER BY column)?е??????д????????????п???????????????????????????????(????????????????????)????????????
????–??????????(length???????????1ength?????)
????CREATE INDEX index_name ON table_name(column_name(length))
????–????????????????
????ALTER TABLE table_name ADD INDEX index_name ON (column_name)
????–????????????????????
????CREATE TABLE `table_name` (
????`id` int(11) NOT NULL AUTO_INCREMENT ??
????`title` char(255) NOT NULL ??
????PRIMARY KEY (`id`)??
????INDEX index_name (title)
????) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
????–???????
????DROP INDEX index_name ON table_name;
???????????????? ??
????CREATE INDEX mytable_categoryid_userid ON mytable (category_id??user_id);
????????????????????????"????_???1??_???2??"????
????2. ???? ???????????????????????????е?????????????п????????????????????????????????????????????????????????????????????
????????????????????н???????????????????????????????д????????????????ù????UNIQUE???????????????????????????????????MySQL?????????????????????????????????????Ч???????MySQL???????????????????????????????????????ε???????????????????????????????????????MySQL????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????–????????
????CREATE UNIQUE INDEX index_name ON table_name(column_name)
????–?????
????ALTER TABLE table_name ADD UNIQUE index_name ON (column_name)
????–????????????????
????CREATE TABLE `table_name` (
????`id` int(11) NOT NULL AUTO_INCREMENT ??
????`title` char(255) NOT NULL ??
????PRIMARY KEY (`id`)??
????UNIQUE index_name (title)
????);
????3.?????? ?????????????????????????????????????δ???????????????????????ν??"??????"??????????????????????????????????????????PRIMARY??????UNIQUE??
????4.??????? ????????????????ζ????????????????????MySQL???????????????????????????Ч??????????????????????????
????5. ?????????FULLTEXT?? MySQL??3.23.23?濪?????????????????????fulltext???????????? MyISAM ???????????CHAR??VARCHAR??TEXT???????CREATE TABLE??????????????????????????ALTER TABLE ??CREATE INDEX??????////?????????????????????????????????FULLTEXT????????У???????????????????????????????FULLTEXT??????????????????м?????????????????????????????????????????????????????????????
???????????????????????????????????????????????(?????????????????)???м???????????????????????????????????????????????????????????????????????????????????LIKE %word%?????????????MySQL????????????????????????????????????????
?????????????????????(full-text index)??????????????????????????????????????MySQL??????????г???????е???????????嵥???????????????????嵥??????й????????????????????????????????????????????????б????????????????????????
????ALTER TABLE table_name ADD FULLTEXT(column1?? column2)
???????????????????????SELECT??????????????Щ???????????????????????????????????????????????????????
????SELECT * FROM table_name
????WHERE MATCH(column1?? column2) AGAINST('word1'?? 'word2'?? 'word3')
??????????????????column1??column2???????word1??word2??word3????????????????????
????–????????????????????
????CREATE TABLE `table_name` (
????`id` int(11) NOT NULL AUTO_INCREMENT ??
????`content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL ??
????PRIMARY KEY (`id`)??
????FULLTEXT (content)
????);
????–???????????????
????ALTER TABLE table_name ADD FULLTEXT index_name(column_name)
????–??????????
????CREATE FULLTEXT INDEX index_name ON table_name (column_name)
????6. ?????????????????? ???????????????????????????Ч????????????в?????MySQL???????????????????????????????????????????????
????5. ???(????)???????????? ?????SQL??????????б???????????????????????????MySQL??Ч????????????????????????????????title??time????????????????ALTER TABLE article ADD INDEX index_titme_time (title(50)??time(10))?????????????????????????????????????????????????????
????–title??time
????–title
??????????time???????????????????????MySQL???????“????”??????????????????????????????????????????????е???????????????????????????????SQL???
????–?????????????
????SELECT * FROM article WHREE title='????' AND time=1234567890;
????SELECT * FROM article WHREE title='????';
????–??????????????
????SELECT * FROM article WHREE time=1234567890;
????MySQL????????? ???涼????????????????????????????????????????á??????????????????????????????????????????????????±?????????????INSERT??UPDATE??DELETE????????±????MySQL????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Ч?????????????????MySQL?д????????????????????о???????????????????????????????Щ??????????MySQL??????????????????????? 1. ?????t????????????????? ???????? ??t?????? ??÷??????? ?о????????????? ??? ??? ???????Χ??????? ??? ????? ?????????? ????? ????? С???????? ??? ????? ?????????? ????? ??? ??????μ??? ????? ??? ????? ??? ??? ?????? ??? ??? ???????????? ????? ??? 2. ?????????????NULL????? ?????а?????NULL????????????????????У?????????????????к???NULL??????????ж???????????????Ч?????????????????????????????ε??????NULL??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11