MySQL??????????20+??????
???????????? ???????[ 2015/5/20 16:10:06 ] ?????????????
????9.???ENUM??????VARCHAR
????ENUM??????????????????????????????TINYINT????????????????????????????????????????????Щ????б?????????????
????????????????Σ?????“???”??“”??“????”??“??”??“????”?????????Щ??ε??????????????????????????????ENUM??????VARCHAR??
????MySQL??????“????”????????????????????????????????????????????VARCHAR????????????????????????ENUM????????PROCEDURE ANALYSE()?????????????顣
????10.??PROCEDURE ANALYSE()??y???
????PROCEDURE ANALYSE()????MySQL??????????????κ????????????????????Щ???????顣??б????????????????Щ????????????????????Щ???????????????????????????
???????磬????????????INT?????????????????????????????????????PROCEDURE ANALYSE()????????????ε???????MEDIUMINT????????????????VARCHAR??Σ????????????????????????????????ENUM????顣??Щ???飬?????????????????????????????ò??????
??????phpmyadmin??????????????????“Propose table structure”??????Щ????
?????????????Щ?????飬??е???????????????????????Щ???????????????????????????????????????
????11.??????????NOT NULL
????????????????????????????NULL???????????????????α???NOT NULL?????????????е????飬?????????
??????????????????“Empty”??“NULL”?ж????????????INT??????0??NULL?????????????????????????????????????NULL?????????????Oracle??NULL??Empty???????????????)
??????????NULL???????????????????????????????б????????????????????????????????????????NULL????????????????????????Щ????£?????????NULL???
???????????MySQL??????????
????“NULL columns require additional space in the row to record whether their values are NULL.For MyISAM tables??each NULL column takes one bit extra??rounded up to the nearest byte.”
????12.Prepared Statements
????Prepared Statements????洢????????????????????SQL??伯??????????????prepared statements??ú????????????????????????????
????Prepared Statements???????Щ?????????????????????????????????“SQL????”??????????????????????????????Щ?????????????????????????????????????????????????????????Щframework????ORM??????????????????Щ??
????????????棬??????????????????ε??????????????????????????????????ЩPrepared Statements?????Щ????????MySQL????????Ρ?
????????°汾??MySQL?????Prepared Statements????????????????????????????紫??????Ч???
?????????????Щ????£???????????????Prepared Statements???????????????檔??????汾5.1????????
??????PHP??????prepared statements????????????????mysqli????????????????????磺PDO.
????//????prepared statement
????if($stmt=$mysqli->prepare("SELECT username FROM user WHERE state=?")){
????//??????
????$stmt->bind_param("s"??$state);
????//???
????$stmt->execute();
????//?????
????$stmt->bind_result($username);
????//????α?
????$stmt->fetch();
????printf("%s is from%s
"??$username??$state);
????$stmt->close();
????}
????13.????????
??????????????£?????????????????????????SQL????????????????????????????SQL??????????????????????????С?????????????????????????????
??????????????飬??PHP?????????????????????????mysql_unbuffered_query()??????
????“mysql_unbuffered_query()sends the SQL query query to MySQL without automatically fetching and buffering the result rows as mysql_query()does.This saves a considerable amount of memory with SQL queries that produce large result sets??and you can start working on the result set immediately after the first row has been retrieved as you don’t have to wait until the complete SQL query has been performed.”
??????????仰????????????mysql_unbuffered_query()???????SQL???MySQL????????mysql_query()???????fethch?????????????????????????棬????????Щ???????????????????????????????????е?????????????????????????????????????????????????????????
???????????????Щ???????????????????ж??????????????????????ε????????mysql_free_result()?????????????mysql_num_rows()??mysql_data_seek()???????á?????????????????????????????????
????14.??IP??????UNSIGNED INT
????????????????????VARCHAR(15)??????????????????IP?????????ε?IP???????????????????????4????????????????ж???????Ρ???????????????????????????????????????????????WHERE??????IP between ip1 and ip2??
???????????????UNSIGNED INT?????IP????????????32λ??????????Ρ?
?????????????????????INET_ATON()????????????IP?????????Σ??????INET_NTOA()????????????????????IP????PHP?У?????????????ip2long()??long2ip()??
????$r="UPDATE users SET ip=INET_ATON('{$_SERVER['REMOTE_ADDR']}')WHERE user_id=$user_id";
????15.?????????????
??????????е???????ζ???“???????”???????????????“static”??“fixed-length”?????磬??????????????????Σ?VARCHAR??TEXT??BLOB????????????????????Щ??Σ????????????“???????????”?????????MySQL??????????????????????
?????????????????????????MySQL??????????Щ???????Щ???????????????????????????????????????????????????????????β???????????????????????????????????????????????
??????????????????????????????????????????????????????????????λ?????Щ??????????????????????ò???????????????????????
???????“??????”????????????????????????????????????????????????????????????
????16.??????
????“??????”????????????е????б????????????????????????????????ε????????????????????????????????????????????????????100?????Σ???????
????????????Users?????????????????????????????????Σ?????????????????????????????????????????????????????????д?????Ρ????????????????????????????????????????????и????????????????????????????????????????????????????ID????????????????????????????á?С???????????к???????
????????????????????“last_login”????Σ???????????????????????????????θ????????????????汻????????????????????η??????????У??????????????????ID???????????????????????????????????????????????????
??????????????????????Щ??????????????γ??????????????Join????????????????????????????????????????????????????????
????17.?????DELETE??INSERT???
?????????????????????????????????????DELETE??INSERT?????????????С?????????????????????????????????????????????????????????????????????????????????
????Apache???к???????????????????乤??????????Ч??????????????????????????????????????????????????????????????????????飬????????檔
????????????????????????????30????????????????к???????????????????30???????????????/????????????????????????????????????????WEB????Crash???????????????????????????????
???????????????????????????????????????????LIMIT???????????????????????????????
????while(1){
????//??????1000??
????mysql_query("DELETE FROM logs WHERE log_date<='2009-11-01'LIMIT 1000");
????if(mysql_affected_rows()==0){
????//?????????????
????break;
????}
????//??ζ?????????
????usleep(50000);
????}
????18.?С???л????
????????????????????????????????????????????????????????????????y???????????????а????????????????????????
?????ο?MySQL?????Storage Requirements?????е??????????
????????????????м??а?????????????????????????????????????????INT?????????????MEDIUMINT??SMALLINT?????С??TINYINT????????Щ???????????????????DATE???DATETIME????
??????????????????????????????????????????????£???????????????ο?Slashdot???????2009??11??06????????????ALTER TABLE??仨??3????С???????????????????????????
????19.????????洢????
??????MySQL?????????洢????MyISAM??InnoDB????????涼?????б?????????????MySQL:InnoDB????MyISAM??????????????顣
????MyISAM??????Щ????????????????????????д???д???????????á?????????????update?????Σ???????????????????????????????????????????????????????ɡ?????MyISAM????SELECT COUNT(*)??????????????????
????InnoDB????????????????????洢???棬?????ЩС???????????MyISAM???????????????“????”????????д??????????????????????????????????????????磺????
??????????MySQL?????
????target=”_blank”MyISAM Storage Engine
????InnoDB Storage Engine
????20.???????????????????Object Relational Mapper??
???????ORM(Object Relational Mapper)??????????????????????????ORM???????????????飬??????????д??????????????????????????
????ORM?????????“Lazy Loading”????????????????????????????????????????????????С???????????????????????п??????????????????С?????????????????
????ORM??????????SQL?????????????????????????????????
?????????????????PHP??ORM???Doctrine??
????21.С??“????”
????“????”??????????????????′???MySQL??????????????????????????????????????????????????????????????????????????????????Apache?????????????????——??????????ε?HTTP?????????Apache???????????????????MySQL?????
????PHP???mysql_pconnect()
????????????????????????????????????????????饗???????????????????????????????????鷳?????????????????????????????????????????????????
?????????Apache???????????е?????У????????????????????????????“????”????????????????????????????“????”??????????ú???????????????????????
??????
???·???
??????????????????
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