站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > MySQL 5.1参考手册中文版

Chapter聽1.聽General Information - MySQL 5.1参考手册中文版

绗1绔狅細涓鑸俊鎭

MySQL杞欢鎻愪緵浜嗗崄鍒嗗揩閫熺殑澶氱嚎绋嬨佸鐢ㄦ埛銆佺墷闈犵殑SQL锛堢粨鏋勫寲鏌ヨ璇█锛夋暟鎹簱鏈嶅姟鍣ㄣ MySQL鏈嶅姟鍣ㄥ畾浣嶄簬浠诲姟鍏抽敭鍨嬨侀噸璐熻嵎鐢熶骇绯荤粺锛屽苟鑳藉祵鍏ュ湪澶ч噺閮ㄧ讲鐨勮蒋浠朵腑銆侻ySQL鏄疢ySQL AB鐨勬敞鍐屽晢鏍囥

MySQL杞欢閲囩敤鍙岃鍙柟寮忋傜敤鎴峰彲鏍规嵁GNU閫氱敤鍏叡璁稿彲锛http://www.fsf.org/licenses/锛夋潯娆撅紝灏哅ySQL杞欢浣滀负寮鏀炬簮鐮佷骇鍝佷娇鐢紝鎴栦粠MySQL AB鍏徃璐拱鏍囧噯鐨勫晢涓氳鍙瘉銆傚叧浜庢垜鏂硅鍙瓥鐣ョ殑鏇村淇℃伅锛岃鍙傝http://www.mysql.com/company/legal/licensing/

鍦ㄤ笅闈㈢殑娓呭崟涓紝浠嬬粛浜嗘湰鎵嬪唽鎰熷叴瓒g殑涓浜涚壒娈婇儴鍒嗐

閲嶈璇存槑锛

璇峰皢閿欒鎶ュ憡锛堥氬父绉颁负缂洪櫡锛変互鍙婇棶棰樺拰璇勮鍙戦佸埌http://bugs.mysql.com銆傝鍙傝1.7.1.3 鈥滃浣曢氭姤缂洪櫡鍜岄棶棰樷

濡傛灉鍦∕ySQL鏈嶅姟鍣ㄤ腑鍙戠幇鏁忔劅鐨勫畨鍏ㄧ己闄凤紝璇蜂娇鐢ㄧ數瀛愰偖浠剁珛鍒婚氱煡鎴戜滑锛security@mysql.com

1.1. 鍏充簬鏈墜鍐

杩欐槸鍏充簬5.1鐗堣嚦5.1.2-alpha鐗圡ySQL鏁版嵁搴撶郴缁熺殑鍙傝冩墜鍐屻傝鎵嬪唽涓嶉傜敤浜庢棫鐗堟湰MySQL杞欢锛岃繖鏄洜涓哄湪MySQL 5.1鍜屼互鍓嶇殑鐗堟湰瀛樺湪寰堝鍔熻兘鎬у樊寮傚拰鍏朵粬宸紓銆傚鏋滄鍦ㄤ娇鐢∕ySQL杞欢鐨勮緝鏃х増鏈紝璇峰弬闃MySQL 5.0鍙傝冩墜鍐锛岃鎵嬪唽娑电洊浜哅ySQL 5.0锛屾垨鍙傞槄MySQL 4.1鍙傝冩墜鍐锛岃鎵嬪唽娑电洊浜哅ySQL 3.22銆3.23銆4.0鍜4.1绯诲垪銆傚湪鎵嬪唽鐨勬枃鏈腑锛岄氳繃寮曠敤鍙戝竷鐗堟湰鍙凤紙5.1.x锛夛紝娉ㄦ槑浜哅ySQL 5.1鐨勪簩绾х増鏈

鐢变簬鏈墜鍐屾槸浣滀负鍙傝冩墜鍐岃岀紪鍒剁殑锛屽湪鏈墜鍐屼腑鏈彁渚涘叧浜嶴QL鎴栧叧鑱旀暟鎹簱姒傚康鐨勪竴鑸鏄庛傚湪鏈墜鍐屼腑锛屼篃涓嶅寘鍚浣曚娇鐢ㄦ搷浣滅郴缁熸垨鍛戒护琛岃В閲婂櫒鏂归潰鐨勪俊鎭

MySQL鏁版嵁搴撹蒋浠跺缁堝湪鍙戝睍锛屽弬鑰冩墜鍐屼篃浼氱浉搴斿湴棰戠箒鏇存柊銆傛湰鎵嬪唽鐨勬渶鏂扮増鏈互鍦ㄧ嚎鏂瑰紡鎻愪緵锛岃浣跨敤http://dev.mysql.com/doc/涓婄殑鎼滅储琛ㄥ崟銆備篃鎻愪緵澶氶噸鍏朵粬鏍煎紡锛屽寘鎷琀TML銆丳DF銆佸拰Windows CHM鐗堟湰銆

涓昏鏂囨。鏄DocBook XML鏂囦欢鐨勯泦鍚堛傚浜嶩TML鐗堟湰鍜屽叾浠栨牸寮忥紝瀹冧滑鏄娇鐢DocBook XSL stylesheets鑷姩鐢熸垚鐨勩

濡傛灉浣犳湁浠讳綍鍏充簬鏈墜鍐屽簲澧炲姞鍐呭鎴栨洿姝e唴瀹规柟闈㈢殑寤鸿锛岃灏嗗叾鍙戦佺粰鏂囨。缂栧埗鍥㈤槦锛docs@mysql.com

鏈墜鍐屾渶鍒濇槸鐢盌avid Axmark鍜孧ichael 鈥Monty鈥 Widenius缂栧埗鐨勩傜敱MySQL鏂囨。缂栧埗鍥㈤槦璐熻矗缁存姢锛屽洟闃熸垚鍛樺寘鎷琍aul DuBois銆丼tefan Hinz銆丮ike Hillyer鍜孞on Stephens銆傚叧浜庝腑澶氬叾浠栬础鐚汉锛岃鍙傝闄勫綍C锛氭劅璋

鏈墜鍐岀殑鐗堟潈褰掔憺鍏稿叕鍙窶ySQL AB鎵鏈夈侻ySQL鍜孧ySQL寰芥爣鍧囨槸MySQL AB鐨勬敞鍐屽晢鏍囥傛湰鎵嬪唽涓紩鐢ㄧ殑鍏朵粬鍟嗘爣鍜屾敞鍐屽晢鏍囨槸鐩稿簲鎵鏈変汉鐨勮储浜э紝鍦ㄦ湰鎵嬪唽涓粎灏嗗叾鐢ㄤ簬杈ㄨ瘑鐩殑銆

1.2. 鏈墜鍐岄噰鐢ㄧ殑鎯緥

鏈墜鍐岄噰鐢ㄤ簡鐗瑰畾鐨勫嵃鍒锋儻渚嬶細

         杩欑被椋庢牸鐨勬枃鏈敤浜嶴QL璇彞锛屾暟鎹簱銆佽〃鍜屽垪鍚嶇О锛孋鍜孭erl浠g爜锛屼互鍙婄幆澧冨彉閲忋備緥濡傦細 瑕佹兂閲嶆柊鍔犺浇鎺堟潈琛紝璇蜂娇鐢FLUSH PRIVILEGES璇彞銆

杩欑被椋庢牸鐨勬枃鏈鐢ㄤ簬鎸囨槑閿叆鐨勬暟濡備俊鎭

         杩欑被椋庢牸鐨勬枃鏈鐢ㄤ簬鎸囨槑鍙墽琛岀▼搴忓拰鑴氭湰鐨勫悕绉帮紝渚嬪mysql锛圡ySQL鍛戒护琛屽鎴风绋嬪簭锛夊拰mysqld锛圡ySQL鏈嶅姟鍣ㄦ墽琛岀▼搴忥級銆

         杩欑被椋庢牸鐨勬枃鏈鐢ㄤ簬鍙橀噺杈撳叆锛屽簲浣跨敤浣犻夋嫨鐨勫兼浛鎹㈠畠銆

         鏂囦欢鍚嶅拰鐩綍鍚嶉噰鍙栦笅杩版柟寮忥細 鈥滃叏绋my.cnf浣嶄簬鐩綍/etc涓

         瀛楃搴忓垪閲囧彇涓嬭堪鏂瑰紡锛 鈥滆鎯充娇鐢ㄩ氶厤绗︼紝璇蜂娇鐢ㄥ瓧绗%鈥濄

         杩欑被椋庢牸鐨勬枃鏈鐢ㄤ簬寮鸿皟銆

         杩欑被椋庢牸鐨勬枃鏈鐢ㄤ簬琛ㄥご锛屽苟鐢ㄤ簬浼犻掑己璋冧俊鎭

褰撳嚭鐜板噯澶囧湪鐗瑰畾绋嬪簭涓墽琛岀殑鍛戒护鏃讹紝璇ョ▼搴忓皢鐢变綅浜庡懡浠ゅ墠鐨勬彁绀虹鎸囨槑銆備緥濡傦紝shell>鎸囨槑鍛戒护灏嗕粠娉ㄥ唽澶栧3绋嬪簭涓墽琛岋紝mysql>鎸囨槑鍛戒护灏嗕粠mysql瀹㈡埛绔绋嬪簭涓墽琛

shell> type a shell command here锛堝湪姝よ緭鍏hell鍛戒护锛
mysql> type a mysql statement here锛堝湪姝よ緭鍏ysql璇彞锛

shell鈥濇槸鍛戒护瑙i噴绋嬪簭銆鍦║nix骞冲彴涓婏紝瀹冮氬父鏄▼搴忥紝濡shcshbash銆傚湪Windows骞冲彴涓嬶紝绛夋晥绋嬪簭涓command.comcmd.exe锛岄氬父杩愯鍦ㄦ帶鍒跺彴绐楀彛涓

杈撳叆绀轰緥涓樉绀虹殑鍛戒护鎴栬鍙ユ椂锛屼笉瑕佽緭鍏ョず渚嬩腑缁欏嚭鐨勬彁绀虹銆

鏁版嵁搴撱佽〃鍜岋紱鍒楀悕蹇呴』浠e叆璇彞涓備负浜嗘寚鏄庤浠e叆鏄繀瑕佺殑锛屽湪鏈墜鍐屼腑浣跨敤浜db_nametbl_namecol_name銆渚嬪锛屼綘灏嗚鍒板涓嬫墍绀虹殑璇彞锛

mysql> SELECT col_name FROM db_name.tbl_name;

杩欐剰鍛崇潃锛屽鏋滀綘杈撳叆浜嗙被浼肩殑璇彞锛屽簲鎻愪緵浣犵殑鏁版嵁搴撱佽〃鍜屽垪鍚嶏紝濡備笅渚嬫墍绀猴細

mysql> SELECT author_name FROM biblio_db.author_list;

SQL鍏抽敭瀛椾笉鍖哄垎澶у皬鍐欙紝鍥犳鍗冲彲涓哄ぇ鍐欎篃鍙负灏忓啓銆傚湪鏈墜鍐屼腑閲囩敤澶у啓銆

鍦ㄨ娉曚粙缁嶄腑锛屾柟鎷彿锛堚淸鈥濆拰鈥淽鈥濓級鐢ㄤ簬鎸囨槑鍙夊瓧鎴栧瓙鍙ャ備緥濡傦紝鍦ㄤ笅闈㈢殑璇彞涓紝IF EXISTS鏄彲閫夌殑锛

DROP TABLE [IF EXISTS] tbl_name

褰撴煇涓璇硶鎴愬垎鐢卞涓彲閫夐」缁勬垚鏃讹紝鍙夐」搴旂敤绔栫嚎鈥渱鈥濆垎寮銆傚綋鍙兘閫夋嫨涓缁勯夋嫨涓殑鏌愪竴鎴愬憳鏃讹紝鍙夐」灏嗗垪鍦ㄦ柟鎷彿锛堚淸鈥濆拰鈥淽鈥濓級涓

TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)

褰撳繀椤婚夋嫨涓缁勯夋嫨涓殑鏌愪竴鎴愬憳鏃讹紝鍙夐」灏嗗垪鍦ㄥぇ鎷彿锛堚{鈥濆拰鈥}鈥濓級涓

{DESCRIBE | DESC} tbl_name [col_name | wild]

鐪佺暐鍙凤紙锛夎〃鏄庣渷鐣ヤ簡璇彞鐨勬煇涓閫夋嫨锛岄氬父鏄负浜嗘彁渚涘鏉傝娉曠殑绠鐭〃杩般備緥濡傦紝INSERT ... SELECT鏄悗璺烻LECT璇彞鐨INSERT璇彞鐨勭畝鐭舰寮忋

鐪佺暐鍙疯繕鑳芥寚鏄庤鍙ョ殑鍓嶉儴鍒嗚娉曞厓绱犲彲閲嶅銆傚湪涓嬮潰鐨勭ず渚嬩腑锛屽彲缁欏畾澶氫釜reset_option鍊硷紝绗1涓煎悗姣忎竴涓彲鐢遍楀彿鍒嗗紑锛

RESET reset_option [,reset_option] ...

瀵逛簬鐢ㄦ潵璁剧疆shell鍙橀噺鐨勫懡浠わ紝閲囩敤Bourne shell璇硶缁欏嚭銆備緥濡傦紝鐢ㄤ簬璁剧疆鐜鍙橀噺鐨勫簭鍒楀拰杩愯鍛戒护鐨勫簭鍒楋紝涓庝笅杩癇ourne shell璇硶缁欏嚭鐨勭被浼硷細

shell> VARNAME=value some_command

濡傛灉浣犳鍦ㄤ娇鐢cshtcsh锛屽繀椤讳娇鐢ㄧ暐鏈変笉鍚岀殑鍛戒护銆傚簲鎵ц涓庝笅渚嬫墍绀虹被浼肩殑搴忓垪锛

shell> setenv VARNAME value
shell> some_command

1.3. MySQL AB姒傝堪

MySQL AB鏄敱MySQL鍒涘浜哄拰涓昏寮鍙戜汉鍒涘姙鐨勫叕鍙搞侻ySQL AB鏈鍒濇槸鐢盌avid Axmark銆丄llan Larsson鍜孧ichael鈥Monty鈥漌idenius鍦ㄧ憺鍏稿垱鍔炵殑銆

鎴戜滑鑷村姏浜庡紑鍙慚ySQL鏁版嵁搴撹蒋浠讹紝骞跺悜鏂扮敤鎴峰浼犳帹骞垮畠銆侻ySQL AB鎷ユ湁MySQL婧愪唬鐮併丮ySQL寰芥爣鍜岋紙娉ㄥ唽锛夊晢鏍囥佷互鍙婃湰鎵嬪唽鐨勭増鏉冦傝鍙傝

1.4 鈥淢ySQL鏁版嵁搴撶鐞嗙郴缁熸杩扳

MySQL鐨勬牳蹇冧环鍊煎彇鍚戞寚鏄庝簡鎴戜滑瀵筂ySQL鍜屽紑鍙戞簮鐮佺殑璐$尞銆

杩欎簺鏍稿績浠峰煎彇鍚戣瀹氫簡MySQL AB涓嶮ySQL鏈嶅姟鍣ㄨ蒋浠剁殑鍗忎綔鏂瑰紡锛

         鎴愪负涓栫晫涓婃渶濂藉拰浣跨敤鏈骞挎硾鐨勬暟鎹簱銆

         闈㈠悜鎵鏈変汉锛岃屼笖鎵鏈変汉鍧囪兘鏀粯寰楄捣銆

         浣跨敤绠鍗曘

         鍦ㄤ繚鎸佸揩閫熷拰瀹夊叏鐨勫悓鏃朵笉鏂敼杩涖

         浣跨敤鍜屾敼杩涘厖婊′箰瓒c

         涓嶅瓨鍦ㄧ己闄枫

杩欏氨鏄疢ySQL AB鍏徃鍙婂叾闆囧憳鐨勬牳蹇冧环鍊煎彇鍚戙

         鎴戜滑鍚屾剰寮鏀炬簮鐮佺悊蹇碉紝骞舵敮鎸佸紑鏀炬簮鐮佺兢銆

         鎴戜滑鐨勭洰鏍囨槸鎴愪负鏈浣冲叕姘戙

         鎴戜滑鍊惧悜浜庨偅浜涗笌鎴戜滑鏈夊叡鍚屼环鍊煎彇鍚戝拰鎬濇兂鍊惧悜鐨勫悎浣滀紮浼淬

         鎴戜滑灏嗗洖澶嶇數瀛愰偖浠跺苟鎻愪緵鏀寔銆

         鎴戜滑鏄竴瀹朵笌鍏朵粬鏂硅仈绯诲湪涓璧风殑鈥滆櫄鎷熲濆叕鍙搞

         鎴戜滑鍙嶅杞欢涓撳埄銆

鍦∕ySQL鐨勭綉绔欙紙http://www.mysql.com/锛変笂锛岀粰鍑轰簡鍏充簬MySQL鍜孧ySQL鐨勬渶鏂颁俊鎭

椤轰究鎻愬強涓涓嬶紝鍏徃鍚嶄腑鐨勨淎B鈥濇槸鐟炲吀璇aktiebolag鈥濇垨鈥滆偂浠藉叕鍙糕濈殑棣栧瓧姣嶇缉鍐欍傚彲灏嗗叾缈昏瘧涓衡淢ySQL鏈夐檺鍏徃鈥濄備簨瀹炰笂锛孧ySQL鏈夐檺鍏徃鍜孧ySQLGmbH鍧囨槸MySQL AB瀛愬叕鍙哥殑鍚嶇О銆傚畠浠垎鍒綅浜庣編鍥藉拰寰峰浗銆

1.4. MySQL鏁版嵁搴撶鐞嗙郴缁熸杩

MySQL鏄渶娴佽鐨勫紑鏀炬簮鐮丼QL鏁版嵁搴撶鐞嗙郴缁燂紝瀹冩槸鐢盡ySQL AB鍏徃寮鍙戙佸彂甯冨苟鏀寔鐨勩侻ySQL AB鏄敱澶氬悕MySQL寮鍙戜汉鍒涘姙鐨勪竴瀹跺晢涓氬叕鍙搞傚畠鏄竴瀹剁浜屼唬寮鏀炬簮鐮佸叕鍙革紝缁撳悎浜嗗紑鏀炬簮鐮佷环鍊煎彇鍚戙佹柟娉曞拰鎴愬姛鐨勫晢涓氭ā鍨嬨

鍦∕ySQL鐨勭綉绔欙紙http://www.mysql.com/锛変笂锛岀粰鍑轰簡鍏充簬MySQL鍜孧ySQL鐨勬渶鏂颁俊鎭

         MySQL鏄竴绉嶆暟鎹簱绠$悊绯荤粺銆

鏁版嵁搴撴槸鏁版嵁鐨勭粨鏋勫寲闆嗗悎銆傚畠鍙互鏄换浣曚笢瑗匡紝浠庣畝鍗曠殑璐墿娓呭崟鍒扮敾灞曪紝鎴栦紒涓氱綉缁滀腑鐨勬捣閲忎俊鎭傝鎯冲皢鏁版嵁娣诲姞鍒版暟鎹簱锛屾垨璁块棶銆佸鐞嗚绠楁満鏁版嵁搴撲腑淇濆瓨鐨勬暟鎹紝闇瑕佷娇鐢ㄦ暟鎹簱绠$悊绯荤粺锛屽MySQL鏈嶅姟鍣ㄣ傝绠楁満鏄鐞嗗ぇ閲忔暟鎹殑鐞嗘兂宸ュ叿锛屽洜姝わ紝鏁版嵁搴撶鐞嗙郴缁熷湪璁$畻鏂归潰鎵紨鐫鍏抽敭鐨勪腑蹇冭鑹诧紝鎴栨槸浣滀负鐙珛鐨勫疄鐢ㄥ伐鍏凤紝鎴栨槸浣滀负鍏朵粬搴旂敤绋嬪簭鐨勭粍鎴愰儴鍒嗐

  • MySQL鏄竴绉嶅叧鑱旀暟鎹簱绠$悊绯荤粺銆

    鍏宠仈鏁版嵁搴撳皢鏁版嵁淇濆瓨鍦ㄤ笉鍚岀殑琛ㄤ腑锛岃屼笉鏄皢鎵鏈夋暟鎹斁鍦ㄤ竴涓ぇ鐨勪粨搴撳唴銆傝繖鏍峰氨澧炲姞浜嗛熷害骞舵彁楂樹簡鐏垫椿鎬с侻ySQL鐨凷QL鎸囧緱鏄滅粨鏋勫寲鏌ヨ璇█鈥濄係QL鏄敤浜庤闂暟鎹簱鐨勬渶甯哥敤鏍囧噯鍖栬瑷锛屽畠鏄敱ANSI/ISO SQL鏍囧噯瀹氫箟鐨勩係QL鏍囧噯鑷1986骞翠互鏉ヤ笉鏂紨鍖栧彂灞曪紝鏈夋暟绉嶇増鏈傚湪鏈墜鍐屼腑锛屸SQL-92鈥濇寚寰楁槸1992骞村彂甯冪殑鏍囧噯锛屸淪QL:1999鈥濇寚寰楁槸1999骞村彂甯冪殑鏍囧噯锛屸淪QL:2003鈥濇寚寰楁槸鏍囧噯鐨勫綋鍓嶇増鏈鎴戜滑閲囩敤鏈鈥淪QL鏍囧噯鈥濇爣绀篠QL鏍囧噯鐨勫綋鍓嶇増鏈

  • MySQL杞欢鏄竴绉嶅紑鏀炬簮鐮佽蒋浠躲

    鈥滃紑鏀炬簮鐮佲濇剰鍛崇潃浠讳綍浜洪兘鑳戒娇鐢ㄥ拰鏀瑰彉杞欢銆備换浣曚汉閮借兘浠嶪nternet涓嬭浇MySQL杞欢锛岃屾棤闇鏀粯浠讳綍璐圭敤銆傚鏋滄効鎰忥紝浣犲彲浠ョ爺绌舵簮鐮佸苟杩涜鎭板綋鐨勬洿鏀癸紝浠ユ弧瓒充綘鑷繁鐨勯渶姹傘侻ySQL杞欢閲囩敤浜咷PL锛圙NU閫氱敤鍏叡璁稿彲璇侊級锛http://www.fsf.org/licenses/锛屽畾涔変簡鍦ㄤ笉鍚屾儏鍐典笅鍙互鐢ㄨ蒋浠朵綔鐨勪簨鍜屼笉鍙綔鐨勪簨銆傚鏋滀綘瀵笹PL涓嶆弧鎰忥紝鎴栭渶瑕佸湪鍟嗕笟搴旂敤绋嬪簭涓祵鍏ySQL浠g爜锛屽彲浠庢垜鏂硅喘涔板晢涓氳鍙増鏈傛洿澶氫俊鎭紝璇峰弬瑙丮ySQL璁稿彲姒傝堪锛http://www.mysql.com/company/legal/licensing/锛夈

  • MySQL鏁版嵁搴撴湇鍔″櫒鍏锋湁蹇熴佸彲闈犲拰鏄撲簬浣跨敤鐨勭壒鐐广

    濡傛灉瀹冩鏄綘鎵瀵绘壘鐨勶紝涓嶅Θ涓璇曘侻ySQL鏈嶅姟鍣ㄨ繕鏈変竴濂楀疄鐢ㄧ殑鐗规ч泦鍚堬紝杩欎簺鐗规ф槸閫氳繃涓庢垜浠敤鎴风殑瀵嗗垏鍚堜綔鑰屽紑鍙戠殑銆傚湪鎴戜滑鐨勫熀鍑嗘祴璇曚富椤典笂锛岀粰鍑轰簡MySQL鏈嶅姟鍣ㄥ拰鍏朵粬鏁版嵁搴撶鐞嗗櫒鐨勬瘮杈冪粨鏋溿傝鍙傝7.1.4 鈥淢ySQL鍩哄噯濂椾欢鈥

    MySQL鏈嶅姟鍣ㄦ渶鍒濇槸涓哄鐞嗗ぇ鍨嬫暟鎹簱鑰屽紑鍙戠殑锛屼笌宸叉湁鐨勮В鍐虫柟妗堢浉姣旓紝瀹冪殑閫熷害鏇村揩锛屽骞翠互鏉ワ紝瀹冨凡鎴愬姛鐢ㄤ簬浼楀瑕佹眰寰堥珮鐨勭敓浜х幆澧冦傚敖绠ySQL濮嬬粓鍦ㄤ笉鏂彂灞曪紝浣嗙洰鍓峂ySQL鏈嶅姟鍣ㄥ凡鑳芥彁渚涗赴瀵屽拰鏈夌敤鐨勫姛鑳姐傚畠鍏锋湁鑹ソ鐨勮繛閫氭с侀熷害鍜屽畨鍏ㄦэ紝杩欎娇鐨凪ySQL鍗佸垎閫傚悎浜庤闂甀nternet涓婄殑鏁版嵁搴撱

  • MySQL鏈嶅姟鍣ㄥ伐浣滃湪瀹㈡埛绔/鏈嶅姟鍣ㄦā寮忎笅锛屾垨宓屽叆寮忕郴缁熶腑銆

    MySQL鏁版嵁搴撹蒋浠舵槸涓绉嶅鎴风/鏈嶅姟鍣ㄧ郴缁燂紝鐢辨敮鎸佷笉鍚屽悗绔殑1涓绾跨▼SQL鏈嶅姟鍣紝鏁扮涓嶅悓鐨勫鎴风绋嬪簭鍜屽簱锛屼紬澶氱鐞嗗伐鍏峰拰骞挎硾鐨勫簲鐢ㄧ紪绋嬫帴鍙PI缁勬垚銆

    鎴戜滑杩樿兘浠ュ祵鍏ュ紡澶氱嚎绋嬪簱鐨勫舰寮忔彁渚汳ySQL鏈嶅姟鍣紝浣犲彲浠ュ皢鍏堕摼鎺ュ埌浣犵殑搴旂敤绋嬪簭锛屼粠鑰岃幏寰楁洿灏忋佹洿蹇佸拰鏇存槗绠$悊鐨勪骇鍝併

  • 鏈夊ぇ閲忓彲鐢ㄧ殑鍏变韩MySQL杞欢銆

    浣犳墍鍠滄鐨勫簲鐢ㄧ▼搴忓拰璇█鍧囨敮鎸丮ySQL鏁版嵁搴撴湇鍔″櫒锛岃繖绉嶆儏鍐靛崄鍒嗗彲鑳姐

MySQL鈥濈殑姝e紡鍙戦煶鏄My Ess Que Ell鈥濓紙鑰屼笉鏄my sequel鈥濓級,浣嗘垜浠苟涓嶄粙鎰忎綘鐨勫彂闊虫柟寮忔槸鈥my sequel鈥濇垨鍏朵粬褰撳湴鏂瑰紡銆

1.4.1. MySQL鐨勫巻鍙

鎴戜滑鏈鍒濈殑鍑哄彂鐐规槸锛屼娇鐢╩SQL鏉ヨ繛鎺ユ垜浠殑琛紝杩欑被琛ㄩ噰鐢ㄤ簡鎴戜滑鐨勫揩閫熶綆灞傞潰锛圛SAM锛夊瓙绋嬪簭銆傜劧鑰岋紝缁忚繃涓浜涙祴璇曞悗锛屾垜浠緱鍑虹粨璁猴紝mSQL鐨勯熷害鎴栫伒娲绘т笉瓒充互婊¤冻鎴戜滑鐨勮姹傘傚叾缁撴灉鏄紝涓烘垜浠殑鏁版嵁搴撴彁渚涗簡鏂扮殑SQL鎺ュ彛锛屼絾API鎺ュ彛涓巑SQL鐨勫嚑涔庝竴鏍枫傝璁¤API鐨勭洰鐨勫湪浜庯紝鍏佽灏嗕负mSQL缂栧啓鐨勭涓夋柟浠g爜鏂逛究鍦扮Щ妞嶅埌MySQL銆

MySQL鍚嶇О鐨勮捣婧愪笉鏄庛10澶氬勾鏉ワ紝鎴戜滑鐨勫熀鏈洰褰曚互鍙婂ぇ閲忓簱鍜屽伐鍏峰潎閲囩敤浜嗗墠缂鈥渕y鈥濄備笉杩囷紝鍏卞悓鍒涘姙浜篗onty Widenius鐨勫コ鍎垮悕瀛椾篃鍙淢y鈥濄傛椂鑷充粖鏃ワ紝MySQL鍚嶇О鐨勮捣婧愪粛鏄竴涓糠锛屽嵆浣垮鎴戜滑涔熶竴鏍枫

MySQL Dolphin锛堟垜鏂瑰窘鏍囷級鐨勫悕绉颁负鈥Sakila鈥濓紝瀹冩槸鐢盡ySQL AB鍏徃鐨勫垱鍔炰汉浠庣敤鎴峰湪鈥Dolphin鍛藉悕鈥濇瘮璧涗腑鎻愪緵鐨勪紬澶氬缓璁腑閫夊畾鐨勩傝鍚嶇О鏄敱鏉ヨ嚜闈炴床鏂▉澹叞鐨勫紑鏀炬簮鐮佽蒋浠跺紑鍙戜汉Ambrose Twebaze鎻愬嚭鐨勩傛牴鎹瓵mbrose鐨勮娉曪紝鎸夋柉濞佸+鍏扮殑鏈湴璇█锛屽コ鎬у寲鍚嶇ОSakila婧愯嚜SiSwati銆係akila涔熸槸鍧︽灏间簹銆丄rusha鍦板尯鐨勪竴涓晣鐨勯晣鍚嶏紝闈犺繎Ambrose鐨勬瘝鍥戒箤骞茶揪銆

1.4.2. MySQL鐨勭殑涓昏鐗规

涓嬮潰浠嬬粛浜哅ySQL鏁版嵁搴撹蒋浠剁殑涓浜涢噸瑕佺壒鎬с傚叧浜庡綋鍓嶇壒鎬у拰鍗冲皢鎻愪緵鐗规х殑鏇村淇℃伅锛岋紝璇峰弬瑙1.6鑺傦紝鈥淢ySQL鍙戝睍澶т簨璁扳

         鍐呴儴鏋勪欢鍜屽彲绉绘鎬

o        浣跨敤C鍜孋++缂栧啓

o        鐢ㄤ紬澶氫笉鍚岀殑缂栬瘧鍣ㄨ繘琛屼簡娴嬭瘯

o        鑳藉宸ヤ綔鍦ㄤ紬澶氫笉鍚岀殑骞冲彴涓娿傝鍙傝2.1.1 鈥淢ySQL鏀寔鐨勬搷浣滅郴缁熲

o        浣跨敤GNU Automake銆丄utoconf鍜孡ibtool杩涜绉绘銆

o        鎻愪緵浜嗙敤浜嶤銆丆++銆丒iffel銆丣ava銆丳erl銆丳HP銆丳ython銆丷uby鍜孴cl鐨凙PI銆傝鍙傝绗25绔狅細API鍜屽簱

o        閲囩敤鏍稿績绾跨▼鐨勫畬鍏ㄥ绾跨▼ 濡傛灉鏈夊涓狢PU锛屽畠鑳芥柟渚垮湴浣跨敤杩欎簺CPU銆

o        鎻愪緵浜嗕簨鍔℃у拰闈炰簨鍔℃у瓨鍌ㄥ紩鎿庛

o        浣跨敤浜嗘瀬蹇殑鈥淏鏍戔濈鐩樿〃锛MyISAM锛夊拰绱㈠紩鍘嬬缉銆

o        娣诲姞鍙︿竴涓瓨鍌ㄥ紩鎿庣浉瀵圭畝鍗曘傚鏋滄墦绠椾负鍐呴儴鏁版嵁搴撴坊鍔犱竴涓猄QL鎺ュ彛锛岃鐗规у崄鍒嗘湁鐢ㄣ

o        鏋佸揩鐨勫熀浜庣嚎绋嬬殑鍐呭瓨鍒嗛厤绯荤粺銆

o        閫氳繃浣跨敤浼樺寲鐨勨滃崟鎵弿澶氳繛鎺モ濓紝鑳藉疄鐜版瀬蹇殑杩炴帴銆

o        瀛樺偍鍣ㄤ腑鐨勫搱甯岃〃鐢ㄤ綔涓存椂琛ㄣ

o        SQL鍑芥暟鏄娇鐢ㄩ珮搴︿紭鍖栫殑绫诲簱瀹炵幇鐨勶紝杩愯寰堝揩銆傞氬父锛屽湪瀹屾垚鏌ヨ鍒濆鍖栧悗锛屼笉瀛樺湪瀛樺偍鍣ㄥ垎閰嶃

o        閲囩敤Purify锛堝晢涓氬唴瀛樻孩鍑烘娴嬪櫒锛変互鍙奊PL宸ュ叿Valgrind锛http://developer.kde.org/~sewardj/锛夋祴璇曚簡MySQL浠g爜銆

o        鏈嶅姟鍣ㄥ彲浣滀负鍗曠嫭绋嬪簭杩愯鍦ㄥ鎴风/鏈嶅姟鍣ㄨ仈缃戠幆澧冧笅銆傚畠涔熷彲浣滀负搴撴彁渚涳紝鍙祵鍏ワ紙閾炬帴锛夊埌鐙珛鐨勫簲鐢ㄧ▼搴忎腑銆傝繖绫诲簲鐢ㄧ▼搴忓彲鍗曠嫭浣跨敤锛屼篃鑳藉湪缃戠粶鐜涓嬩娇鐢ㄣ

  • 鍒楃被鍨

    • 浼楀鍒楃被鍨嬶細 甯︾鍙/鏃犵鍙锋暣鏁帮紝1銆2銆3銆4銆8瀛楄妭闀匡紝FLOATDOUBLECHARVARCHARTEXTBLOBDATETIMEDATETIMETIMESTAMPYEARSETENUM锛屼互鍙奜penGIS绌洪棿绫诲瀷銆傝鍙傝绗11绔狅細鍒楃被鍨

    • 瀹氶暱鍜屽彲鍙橀暱搴﹁褰曘

  • 璇彞鍜屽嚱鏁

    • 鍦⊿ELECT鍜屾煡璇㈢殑WHERE瀛愬彞涓紝鎻愪緵瀹屾暣鐨勬搷浣滅鍜屽嚱鏁版敮鎸併備緥濡傦細

      mysql> SELECT CONCAT(first_name, ' ', last_name)
          -> FROM citizen
          -> WHERE income/dependents > 10000 AND age > 30;
      
    • 瀵筍QL GROUP BYORDER BY瀛愬彞鐨勫叏闈㈡敮鎸併傛敮鎸佽仛鍚堝嚱鏁(COUNT(), COUNT(DISTINCT ...)AVG()STD()SUM()MAX()MIN()GROUP_CONCAT())銆

    • 鏀寔LEFT OUTER JOINRIGHT OUTER JOIN锛岄噰鐢ㄦ爣鍑嗙殑SQL鍜孫DBC璇硶銆

    • 鎸夌収鏍囧噯SQL鐨勮姹傦紝鏀寔琛ㄥ埆鍚嶅拰鍒楀埆鍚嶃

    • DELETE銆両NSERTREPLACE鍜孶PDATE杩斿洖鏇存敼锛堝奖鍝嶏級鐨勮鏁般杩炴帴鍒版湇鍔″櫒鏃讹紝鍙氳繃璁剧疆鏍囧織杩斿洖鍖归厤鐨勮鏁般

    • MySQL鐨SHOW鍛戒护鍙敤浜庢绱㈠叧浜庢暟鎹簱銆佹暟鎹簱寮曟搸銆佽〃鍜岀储寮曠殑淇℃伅銆侲XPLAIN鍛戒护鍙敤浜庣‘瀹氫紭鍖栧櫒澶勭悊鏌ヨ鐨勬柟寮忋

    • 鍑芥暟鍚嶄笌琛ㄥ悕鎴栧垪鍚嶄笉鍐茬獊銆備緥濡傦紝ABS鏄湁鏁堢殑鍒楀悕銆傚敮涓鐨勯檺鍒跺湪浜庯紝璋冪敤鍑芥暟鏃讹紝鍑芥暟鍚嶅拰闅忓悗鐨勭鍙封(鈥濅箣闂翠笉寰楁湁绌烘牸銆傝鍙傝9.6 鈥淢ySQL涓繚鐣欏瓧鐨勫鐞嗏

    • 鍙互灏嗕笉鍚屾暟鎹簱鐨勮〃娣峰悎鍦ㄧ浉鍚岀殑鏌ヨ涓紙灏卞儚MySQL 3.22涓偅鏍凤級銆

  • 瀹夊叏

    • 鍗佸垎鐏垫椿鍜屽畨鍏ㄧ殑鏉冮檺鍜屽瘑鐮佺郴缁燂紝鍏佽鍩轰簬涓绘満鐨勯獙璇併傝繛鎺ュ埌鏈嶅姟鍣ㄦ椂锛屾墍鏈夌殑瀵嗙爜浼犺緭鍧囬噰鐢ㄥ姞瀵嗗舰寮忥紝浠庤屼繚璇佷簡瀵嗙爜瀹夊叏銆

  • 鍙几缂╂у拰闄愬埗

    • 澶勭悊澶у瀷鏁版嵁搴擄細 鎴戜滑浣跨敤浜哅ySQL鏈嶅姟鍣ㄥ拰鍚5鍗冧竾鏉¤褰曠殑鏁版嵁搴撱傛垜浠繕鍚锛屾湁浜涚敤鎴峰皢MySQL鐢ㄤ簬鍚60000涓〃鍜岀害50浜胯鐨勬暟鎹簱銆

    • 姣忎釜琛ㄥ彲鏀寔楂樿揪64鏉$储寮曪紙鍦∕ySQL 4.1.2涔嬪墠涓32鏉★級銆傛瘡鏉$储寮曞彲鐢1锝16涓垪鎴栧垪鍏冪礌缁勬垚銆傛渶澶х储寮曞搴︿负1000瀛楄妭锛堝湪MySQL 4.1.2涔嬪墠涓500锛夈傜储寮曞彲浣跨敤鍏峰CHARVARCHARBLOBTEXT鍒楃被鍨嬬殑鍒楀墠缂銆

  • 杩炴帴鎬

    • 鍦ㄤ换浣曞钩鍙颁笂锛屽鎴风鍙娇鐢═CP/IP鍗忚杩炴帴鍒癕ySQL鏈嶅姟鍣ㄣ傚湪Windows绯荤粺鐨凬T绯诲垪涓紙NT銆2000銆乆P鎴2003锛夛紝瀹㈡埛绔彲浣跨敤鍛藉悕绠¢亾杩涜杩炴帴銆傚湪Unix绯荤粺涓紝瀹㈡埛绔彲浣跨敤Unix鍩熷鎺ュ瓧鏂囦欢寤虹珛杩炴帴銆

    • 鍦∕ySQL 4.1鍜屾洿楂樼殑鐗堟湰涓紝濡傛灉鏄互鈥--shared-memory鈥濋夐」寮濮嬶紝Windows鏈嶅姟鍣ㄨ繕鏀寔鍏变韩鍐呭瓨杩炴帴銆傚鎴风鍙娇鐢ㄢ--protocol=memory鈥濋夐」锛岄氳繃鍏变韩鍐呭瓨寤虹珛杩炴帴銆

    • Connector/ODBC (MyODBC)鎺ュ彛涓轰娇鐢∣DBC锛堝紑鏀惧紡鏁版嵁搴撹繛鎺ユэ級杩炴帴鐨勫鎴风绋嬪簭鎻愪緵浜哅ySQL鏀寔銆備緥濡傦紝鍙互浣跨敤MS Access杩炴帴鍒颁綘鐨凪ySQL鏈嶅姟鍣ㄣ傚鎴风鍙繍琛屽湪Windows鎴朥nix骞冲彴涓娿傛彁渚涗簡MyODBC婧愩傛敮鎸佹墍鏈夌殑ODBC 2.5鍑芥暟锛屼互鍙婁紬澶氬叾浠栧嚱鏁般傝鍙傝绗26绔狅細杩炴帴鍣

    • Connector/J鎺ュ彛涓轰娇鐢↗DBC杩炴帴鐨凧ava瀹㈡埛绔▼搴忔彁渚涗簡MySQL鏀寔銆傚鎴风鍙繍琛屽湪Windows鎴朥nix骞冲彴涓娿傛彁渚涗簡Connector/J婧愮爜銆傝鍙傝绗26绔狅細杩炴帴鍣

  • 鏈湴鍖

    • 鏈嶅姟鍣ㄥ彲浣跨敤澶氱璇█鍚戝鎴风鎻愪緵閿欒娑堟伅銆傝鍙傝5.10.2鑺傦紝鈥滆缃敊璇秷鎭瑷鈥

    • 瀵规暟绉嶄笉鍚屽瓧绗﹂泦鐨勫叏闈㈡敮鎸侊紝鍖呮嫭latin1 (cp1252)銆germanbig5ujis绛夈渚嬪锛屽湪琛ㄥ悕鍜屽垪鍚嶄腑鍏佽浣跨敤鏂牚鐨勭撼缁翠簹瀛楃鈥鈥欍佲鈥欏拰鈥鈥欍備粠MySQL 4.1寮濮嬶紝鎻愪緵浜哢nicode鏀寔銆

    • 鎵鏈夋暟鎹潎浠ユ墍閫夌殑瀛楃闆嗕繚瀛樸傛甯稿瓧绗︿覆鍒楃殑姣旇緝涓嶅尯鍒嗗ぇ灏忓啓銆

    • 鍒嗙被鏄牴鎹墍閫夌殑瀛楃闆嗭紙榛樿鎯呭喌涓嬶紝浣跨敤鐟炲吀鏍″锛夎繘琛岀殑銆傚惎鍔∕ySQL鏈嶅姟鍣ㄦ椂锛屽彲鏇存敼璇ラ」璁剧疆銆傝鎯虫煡鐪嬮珮绾у垎绫荤殑绀轰緥锛岃鍙傝Czech鍒嗙被浠g爜銆侻ySQL鏈嶅姟鍣ㄦ敮鎸佷紬澶氫笉鍚岀殑瀛楃闆嗭紝杩欑被瀛楃闆嗗彲鍦ㄧ紪璇戞椂鍜岃繍琛屾椂鎸囧畾銆

  • 瀹㈡埛绔拰宸ュ叿

    • MySQL鏈嶅姟鍣ㄦ彁渚涗簡瀵筍QL璇彞鐨勫唴閮ㄦ敮鎸侊紝鍙敤浜庢鏌ャ佷紭鍖栧拰淇琛ㄣ傞氳繃mysqlcheck瀹㈡埛绔紝鍙湪鍛戒护琛屼笂浣跨敤杩欑被璇彞銆侻ySQL杩樺寘鎷myisamchk锛岃繖鏄竴绉嶅緢蹇殑鍛戒护琛屽疄鐢ㄥ伐鍏凤紝鍙敤浜庡湪MyISAM琛ㄤ笂鎵ц杩欑被鎿嶄綔銆璇峰弬瑙绗5绔狅細鏁版嵁搴撶鐞

    • 瀵逛簬鎵鏈塎ySQL绋嬪簭锛屽潎鑳介氳繃鈥-help鈥濇垨鈥-?鈥濋夐」璋冪敤锛屼互鑾峰彇鑱旀満甯姪淇℃伅銆

1.4.3. MySQL绋冲畾鎬

鏈妭鍥炵瓟浜嗗涓嬮棶棰橈細鈥淢ySQL鏈嶅姟鍣ㄦ湁澶氱ǔ瀹氾紵鈥濓紝浠ュ強鈥滃湪鏈」鐩腑鎴戣兘渚濋潬MySQL鏈嶅姟鍣ㄥ悧鈥濓紵 鎴戜滑灏嗗皾璇曢槓鏄庤繖绫婚棶棰橈紝骞跺洖绛斿緢澶氭綔鍦ㄧ敤鎴峰叧蹇冪殑鏌愪簺閲嶈闂銆傛湰鑺傛墍缁欏嚭鐨勪俊鎭熀浜庨氳繃閭欢鍒楄〃鏀堕泦鐨勬暟鎹紝鍦ㄧ‘瀹氶棶棰樺拰閫氭姤浣跨敤绫诲瀷鏂归潰锛岄偖浠跺垪琛ㄥ崄鍒嗘湁鐢ㄣ

鏈鍒濈殑浠g爜鍙洖婧嚦20涓栫邯80骞翠唬鍒濄傚畠鎻愪緵浜嗙ǔ瀹氱殑缂栫爜鍩烘暟锛屾渶鍒濆瓨鍌ㄥ紩鎿庝娇鐢ㄧ殑ISAM琛ㄦ牸寮忎粛淇濇寔鍚戝悗鍏煎鎬с傚湪MySQL AB鍏徃鐨勫墠韬玊cX锛岃嚜1996骞翠腑鏈熶互鏉ワ紝MySQL浠g爜鍦ㄥ涓」鐩腑宸ヤ綔鑹ソ锛屾湭鍑虹幇浠讳綍闂銆傚綋MySQL鏁版嵁搴撹蒋浠堕娆″悜鏇村箍娉涚殑鍏紬鍙戝竷鏃讹紝鎴戜滑鐨勭敤鎴峰緢蹇彂鐜颁簡涓浜涙湭缁忔祴璇曠殑浠g爜娈点傝嚜閭d互鍚庯紝灏界姣忎釜鏂扮増鏈叿鏈夊緢澶氭柊鐨勭壒鎬э紝浣嗘瘡娆℃柊鍙戝竷鐨勭増鏈潎瀛樺湪灏戦噺鐨勭Щ妞嶆ч棶棰樸

姣忔鍙戝竷鐨凪ySQL鏈嶅姟鍣ㄥ潎鏄彲鐢ㄧ殑銆備粎褰撶敤鎴峰皾璇曟簮鑷滅伆鑹插尯鍩熲濈殑浠g爜鏃舵墠浼氬嚭鐜伴棶棰樸傚綋鐒讹紝鏂扮敤鎴蜂笉浜嗚В鈥滅伆鑹插尯鍩熲濇槸浠涔堛傚洜姝わ紝鍦ㄦ湰鑺備腑锛屾垜浠粙缁嶄簡鐩墠宸茬煡鐨勮繖绫诲尯鍩熴傛湰鑺傛墍浣滅殑浠嬬粛涓昏閽堝MySQL鏈嶅姟鍣3.23鐗堝拰鏇撮珮鐗堟湰銆傚湪鏈鏂扮殑鐗堟湰涓紝鏇存浜嗘墍鏈夊凡鐭ュ拰閫氭姤鐨勭己闄凤紝浣嗏滅己闄封濅竴鑺傛墍鍒楃殑闄ゅ锛岃繖绫荤己闄蜂笌璁捐鏈夊叧銆傝鍙傝A.8鑺傦紝鈥淢ySQL涓殑宸茬煡浜嬪疁鈥

MySQL鏈嶅姟鍣ㄩ噰鐢ㄤ簡澶氬眰璁捐鍜岀嫭绔嬫ā鍧椼傚湪姝ゅ垪鍑轰簡涓浜涜緝鏂扮殑妯″潡锛屽苟鎸囨槑浜嗗畠浠殑娴嬭瘯鎯呭喌銆

         Replication锛堢ǔ瀹氾級

澶ч噺浣跨敤澶嶅埗鍔熻兘鐨勬湇鍔″櫒鍧囧浜庣敓浜фā寮忎笅锛岀粨鏋滆壇濂姐傚湪MySQL 5.x涓紝灏嗙户缁寮哄鍒跺姛鑳姐

         InnoDB琛紙绋冲畾锛

3.23.49鐗堜互鏉ワ紝InnoDB浜嬪姟瀛樺偍寮曟搸涓鐩村緢绋冲畾銆InnoDB姝g敤浜庡ぇ鍨嬨侀噸璐熻嵎鐢熶骇绯荤粺銆

         BDB琛紙绋冲畾锛

Berkeley DB鐮佸崄鍒嗙ǔ瀹氾紝浣嗗湪MySQL鏈嶅姟鍣ㄤ腑锛屾垜浠粛鍦ㄦ敼杩BDB浜嬪姟瀛樺偍寮曟搸銆

         鍏ㄦ枃鏈悳绱紙绋冲畾锛

鍏ㄦ枃鏈悳绱㈢殑浣跨敤鑼冨洿鍗佸垎骞挎硾銆傚湪MySQL 4.0鍜4.1涓紝澧炲姞浜嗛噸瑕佺殑鐗规у寮恒

         MyODBC 3.51锛堢ǔ瀹氾級

MyODBC 3.51閲囩敤浜哋DBC SDK 3.51锛屽苟骞挎硾鐢ㄤ簬鐢熶骇娲诲姩涓傛煇浜涘嚭鐜扮殑鎯呭喌鐪嬩笂鍘讳笌搴旂敤绋嬪簭鐩稿叧锛屼笌ODBC椹卞姩绋嬪簭鎴栧簳灞傛暟鎹簱鏈嶅姟鍣ㄦ棤鍏炽

1.4.4. MySQL琛ㄦ渶澶ц兘杈惧埌澶氬皯

MySQL 3.22闄愬埗鐨勮〃澶у皬涓4GB銆傜敱浜庡湪MySQL 3.23涓娇鐢ㄤ簡MyISAM瀛樺偍寮曟搸锛屾渶澶ц〃灏哄澧炲姞鍒颁簡65536TB锛2567 1瀛楄妭锛夈傜敱浜庡厑璁哥殑琛ㄥ昂瀵告洿澶э紝MySQL鏁版嵁搴撶殑鏈澶ф湁鏁堣〃灏哄閫氬父鏄敱鎿嶄綔绯荤粺瀵规枃浠跺ぇ灏忕殑闄愬埗鍐冲畾鐨勶紝鑰屼笉鏄敱MySQL鍐呴儴闄愬埗鍐冲畾鐨勩

InnoDB瀛樺偍寮曟搸灏InnoDB琛ㄤ繚瀛樺湪涓涓〃绌洪棿鍐咃紝璇ヨ〃绌洪棿鍙敱鏁颁釜鏂囦欢鍒涘缓銆傝繖鏍凤紝琛ㄧ殑澶у皬灏辫兘瓒呰繃鍗曠嫭鏂囦欢鐨勬渶澶у閲忋傝〃绌洪棿鍙寘鎷師濮嬬鐩樺垎鍖猴紝浠庤屼娇寰楀緢澶х殑琛ㄦ垚涓哄彲鑳姐傝〃绌洪棿鐨勬渶澶у閲忎负64TB銆

鍦ㄤ笅闈㈢殑琛ㄦ牸涓紝鍒楀嚭浜嗕竴浜涘叧浜庢搷浣滅郴缁熸枃浠跺ぇ灏忛檺鍒剁殑绀轰緥銆傝繖浠呮槸鍒濇鎸囧崡锛屽苟涓嶆槸鏈缁堢殑銆傝鎯充簡瑙f渶鏂颁俊鎭紝璇峰弬闃呭叧浜庢搷浣滅郴缁熺殑鏂囨。銆

鎿嶄綔绯荤粺

鏂囦欢澶у皬闄愬埗

Linux 2.2-Intel 32-bit

2GB (LFS: 4GB)

Linux 2.4+

(using ext3 filesystem) 4TB

Solaris 9/10

16TB

NetWare w/NSS filesystem

8TB

win32 w/ FAT/FAT32

2GB/4GB

win32 w/ NTFS

2TB锛堝彲鑳芥洿澶э級

MacOS X w/ HFS+

2TB

鍦↙inux 2.2骞冲彴涓嬶紝閫氳繃浣跨敤瀵筫xt2鏂囦欢绯荤粺鐨勫ぇ鏂囦欢鏀寔锛圠FS锛夎ˉ涓侊紝鍙互鑾峰緱瓒呰繃2GB鐨MyISAM琛ㄣ鍦↙inux 2.4骞冲彴涓嬶紝瀛樺湪閽堝ReiserFS鐨勮ˉ涓侊紝鍙敮鎸佸ぇ鏂囦欢锛堥珮杈2TB锛夈傜洰鍓嶅彂甯冪殑澶у鏁癓inux鐗堟湰鍧囧熀浜2.4鍐呮牳锛屽寘鍚墍鏈夋墍闇鐨凩FS琛ヤ竵銆備娇鐢↗FS鍜孹FS锛宲etabyte锛堝崈鍏嗗厗锛夊拰鏇村ぇ鐨勬枃浠朵篃鑳藉湪Linux涓婂疄鐜般傜劧鑰岋紝鏈澶у彲鐢ㄧ殑鏂囦欢瀹归噺浠嶅彇鍐充簬澶氶」鍥犵礌锛屽叾涓箣涓灏辨槸鐢ㄤ簬瀛樺偍MySQL琛ㄧ殑鏂囦欢绯荤粺銆

鍏充簬Linux涓璍FS鐨勮缁嗕粙缁嶏紝璇峰弬瑙丄ndreas Jaeger鐨勨淟inux涓殑澶ф枃浠舵敮鎸佲濋〉闈細http://www.suse.de/~aj/linux_lfs.html

Windows鐢ㄦ埛璇锋敞鎰忥細 FAT鍜孷FAT (FAT32)涓嶉傚悎MySQL鐨勭敓浜т娇鐢ㄣ傚簲浣跨敤NTFS銆

鍦ㄩ粯璁ゆ儏鍐典笅锛孧ySQL鍒涘缓鐨MyISAM琛ㄥ厑璁哥殑鏈澶у昂瀵镐负4GB銆備綘鍙互浣跨敤SHOW TABLE STATUS璇彞鎴myisamchk -dv tbl_name妫鏌ヨ〃鐨勬渶澶у昂瀵搞傝鍙傝13.5.4鑺傦紝鈥淪HOW璇硶鈥

濡傛灉闇瑕佷娇鐢ㄥぇ浜4GB鐨MyISAM琛紙鑰屼笖浣犵殑鎿嶄綔绯荤粺鏀寔澶ф枃浠讹級锛屽彲浣跨敤鍏佽AVG_ROW_LENGTHMAX_ROWS閫夐」鐨凜REATE TABLE璇彞銆傝鍙傝13.1.5鑺傦紝鈥淐REATE TABLE璇硶鈥銆傚垱寤轰簡琛ㄥ悗锛屼篃鍙互浣跨敤ALTER TABLE鏇存敼杩欎簺閫夐」锛浠ュ鍔犺〃鐨勬渶澶у厑璁稿閲忋傝鍙傝13.1.2鑺傦紝鈥淎LTER TABLE璇硶鈥

澶勭悊MyISAM琛ㄦ枃浠跺ぇ灏忕殑鍏朵粬鏂瑰紡锛

         濡傛灉浣犵殑澶ц〃鏄彧璇荤殑锛屽彲浣跨敤myisampack鍘嬬缉瀹冦myisampack閫氬父鑳藉皢琛ㄥ帇缂╄嚦灏50锛咃紝鍥犺岋紝浠庣粨鏋滀笂鐪嬶紝鍙幏寰楁洿澶х殑琛ㄣ傛澶栵紝myisampack杩樿兘灏嗗涓〃鍚堝苟涓1涓〃銆傝鍙傝8.2鑺傦紝鈥渕yisampack锛氱敓鎴愬帇缂┿佸彧璇籑yISAM琛ㄢ

         MySQL鍖呭惈涓涓厑璁稿鐞MyISAM琛ㄩ泦鍚堢殑MERGE搴擄紝杩欑被MyISAM琛ㄥ叿鏈変笌鍗曚釜MERGE琛ㄧ浉鍚岀殑缁撴瀯銆傝鍙傝15.3鑺傦紝鈥淢ERGE瀛樺偍寮曟搸鈥

1.4.5. 2000骞村吋瀹规

MySQL鏈嶅姟鍣ㄦ湰韬笉瀛樺湪2000骞达紙Y2K锛夊吋瀹规ч棶棰橈細

         MySQL鏈嶅姟鍣ㄩ噰鐢ㄤ簡Unix鐨勬椂闂村姛鑳斤紝瀵逛簬TIMESTAMP鍊硷紝鍙鐞嗙殑鏃ユ湡鑷2037骞淬傚浜DATE鍜孌ATETIME鍊硷紝鍙帴鍙楃殑鏃ユ湡鍙嚦9999骞淬

         鎵鏈夌殑MySQL鏃ユ湡鍑芥暟鍧囨槸鍦1涓簮鏂囦欢sql/time.cc涓疄鐜扮殑锛屽苟缁忚繃浜嗘伆褰撶紪鐮佷互纭繚2000骞村畨鍏ㄣ

         鍦∕ySQL 3.22鍜屼互鍚庣殑鐗堟湰涓紝YEAR鍒楃被鍨嬭兘澶熷湪1涓瓧鑺傚唴淇濆瓨0骞翠互鍙1901锝2155骞达紝骞惰兘浣跨敤涓や綅鎴栧洓浣嶆暟瀛楁樉绀哄畠浠鎵鏈夌殑涓や綅鏁板瓧骞翠唤鍧囪瑙嗕负浠嬩簬1970锝2069骞翠箣闂达紝杩欐剰鍛崇潃锛屽鏋滀綘鍦╕EAR鍒椾腑淇濆瓨浜01锛孧ySQL鏈嶅姟鍣ㄤ細灏嗗叾褰撲綔2001骞淬

閫氳繃涓嬮潰鐨勭畝鍗曟紨绀虹ず渚嬶紝琛ㄦ槑MySQL鏈嶅姟鍣ㄥ湪澶勭悊鐩磋嚦9999骞寸殑DATEDATETIME鍊兼柟闈笉瀛樺湪闂锛屽湪澶勭悊2030骞翠互鍓嶇殑TIMESTAMP鍊兼柟闈篃涓嶅瓨鍦ㄩ棶棰橈細

mysql> DROP TABLE IF EXISTS y2k;
Query OK, 0 rows affected (0.01 sec)
 
mysql> CREATE TABLE y2k (date DATE,
    ->                   date_time DATETIME,
    ->                   time_stamp TIMESTAMP);
Query OK, 0 rows affected (0.01 sec)
 
mysql> INSERT INTO y2k VALUES
    -> ('1998-12-31','1998-12-31 23:59:59',19981231235959),
    -> ('1999-01-01','1999-01-01 00:00:00',19990101000000),
    -> ('1999-09-09','1999-09-09 23:59:59',19990909235959),
    -> ('2000-01-01','2000-01-01 00:00:00',20000101000000),
    -> ('2000-02-28','2000-02-28 00:00:00',20000228000000),
    -> ('2000-02-29','2000-02-29 00:00:00',20000229000000),
    -> ('2000-03-01','2000-03-01 00:00:00',20000301000000),
    -> ('2000-12-31','2000-12-31 23:59:59',20001231235959),
    -> ('2001-01-01','2001-01-01 00:00:00',20010101000000),
    -> ('2004-12-31','2004-12-31 23:59:59',20041231235959),
    -> ('2005-01-01','2005-01-01 00:00:00',20050101000000),
    -> ('2030-01-01','2030-01-01 00:00:00',20300101000000),
    -> ('2040-01-01','2040-01-01 00:00:00',20400101000000),
    -> ('9999-12-31','9999-12-31 23:59:59',99991231235959);
Query OK, 14 rows affected (0.01 sec)
Records: 14  Duplicates: 0  Warnings: 2
 
mysql> SELECT * FROM y2k;
+------------+---------------------+----------------+
| date       | date_time           | time_stamp     |
+------------+---------------------+----------------+
| 1998-12-31 | 1998-12-31 23:59:59 | 19981231235959 |
| 1999-01-01 | 1999-01-01 00:00:00 | 19990101000000 |
| 1999-09-09 | 1999-09-09 23:59:59 | 19990909235959 |
| 2000-01-01 | 2000-01-01 00:00:00 | 20000101000000 |
| 2000-02-28 | 2000-02-28 00:00:00 | 20000228000000 |
| 2000-02-29 | 2000-02-29 00:00:00 | 20000229000000 |
| 2000-03-01 | 2000-03-01 00:00:00 | 20000301000000 |
| 2000-12-31 | 2000-12-31 23:59:59 | 20001231235959 |
| 2001-01-01 | 2001-01-01 00:00:00 | 20010101000000 |
| 2004-12-31 | 2004-12-31 23:59:59 | 20041231235959 |
| 2005-01-01 | 2005-01-01 00:00:00 | 20050101000000 |
| 2030-01-01 | 2030-01-01 00:00:00 | 20300101000000 |
| 2040-01-01 | 2040-01-01 00:00:00 | 00000000000000 |
| 9999-12-31 | 9999-12-31 23:59:59 | 00000000000000 |
+------------+---------------------+----------------+
14 rows in set (0.00 sec)

鏈鍚2涓TIMESTAMP鍒楃殑鍊间负0锛岃繖鏄洜涓哄勾浠藉硷紙2040锛9999锛夎秴鍑轰簡TIMESTAMP鐨勬渶澶ц寖鍥淬TIMESTAMP鏁版嵁绫诲瀷鐢ㄤ簬淇濆瓨褰撳墠鏃堕棿锛屽湪32浣嶆満鍣ㄤ笂锛屾敮鎸佺殑鍙栧艰寖鍥存槸1970010100000020300101000000锛堝甫绗﹀彿鍊硷級銆傚湪64浣嶆満鍣ㄤ笂锛TIMESTAMP鑳藉鐞嗙殑鍊艰揪2106锛堟棤绗﹀彿鍊硷級

灏界MySQL鏈嶅姟鍣ㄦ湰韬笉瀛樺湪2000骞村畨鍏ㄩ棶棰橈紝浣嗗鏋滀娇鐢ㄤ簡瀛樺湪Y2K闂鐨勫簲鐢ㄧ▼搴忥紝涔熶細閬囧埌闂銆備緥濡傦紝寰堝鏃╂湡鐨勫簲鐢ㄧ▼搴忛噰鐢2浣嶆暟鍊硷紙涓ゅ彲鎬э級鑰屼笉鏄4浣嶆暟鍊兼潵淇濆瓨鍜屽鐞嗗勾浠芥暟鎹傝繖绫婚棶棰樺彲鑳戒細琚娇鐢ㄢ00鈥濇垨鈥99鈥濈殑搴旂敤绋嬪簭鍚堝苟涓衡滀涪澶扁濆兼寚绀虹銆傚緢涓嶅垢锛岃繖绫婚棶棰樻垨璁稿緢闅炬洿姝o紝杩欐槸鍥犱负涓嶅悓鐨勫簲鐢ㄧ▼搴忔槸鐢变笉鍚岀殑绋嬪簭鍛樼紪鍐欑殑锛屾瘡浣嶇▼搴忓憳鍙兘浣跨敤浜嗕笉鍚岀殑鎯緥闆嗗拰鏃ユ湡澶勭悊鍑芥暟銆

鍥犳锛屽敖绠ySQL鏈嶅姟鍣ㄤ笉瀛樺湪Y2K闂锛屼絾搴旂敤绋嬪簭椤绘彁渚涙棤姝т箟鐨勮緭鍏ュ笺傚叧浜嶮ySQL鏈嶅姟鍣ㄥ湪澶勭悊鍚2浣嶅勾浠芥暟鍊肩殑涓ゅ彲鎬ф棩鏈熻緭鍏ユ暟鎹柟闈㈢殑浣滅敤锛岃鍙傝11.3.4鑺傦紝鈥淵2K浜嬪疁鍜屾棩鏈熺被鍨嬧

1.5. MaxDB鏁版嵁搴撶鐞嗙郴缁熸杩

MaxDB鏄竴绉嶅ぇ鍨嬮珮鏁堢殑浼佷笟鏁版嵁搴撱傛暟鎹簱绠$悊閫氳繃浜哠AP璁よ瘉銆

MaxDB鏄暟鎹簱绠$悊绯荤粺鐨勬柊鍚嶇О锛屼互鍓嶇О涓篠AP DB銆2003骞达紝SAP AG鍜孧ySQL AB纭珛浜嗗悎浣滀紮浼村叧绯伙紝骞跺皢鏁版嵁搴撶郴缁熼噸鍛藉悕涓篗axDB銆傝嚜姝や互鍚庯紝MaxDB鐨勫紑鍙戜竴鐩寸敱SAP寮鍙戣呭洟闃熻礋璐o紝灏卞儚浠ュ墠閭f牱銆

MySQL AB涓嶮axDB鍥㈤槦鍦⊿AP澶勪繚鎸佺潃瀵嗗垏鐨勫悎浣滐紝浠ヤ笉鏂敼杩汳axDB浜у搧銆備袱鑰呯殑鑱斿悎鍔姏鍖呮嫭锛氬紑鍙戞柊鐨勫浐鏈夐┍鍔ㄧ▼搴忥紝浠ヤ究鑳藉鍦ㄥ紑鍙戞簮鐮佺ぞ鍖轰腑鏇存湁鏁堝湴浣跨敤MaxDB锛屽苟涓嶆柇鏀瑰杽鍚勭鏂囨。锛屼互鎷撳睍MaxDB鐨勭敤鎴峰熀鏁般傛澶栵紝MySQL鍜孧axDB鏁版嵁搴撶殑鍗忓悓鎬т篃琚涓轰竴椤归噸瑕佸洜绱狅紝渚嬪锛屾柊鐨凪axDB鍚屾绠$悊鍣ㄦ敮鎸佷粠MaxDB鍒癕ySQL鐨勬暟鎹悓姝ャ

MaxDB鏁版嵁搴撶鐞嗙郴缁熷拰MySQL鏁版嵁搴撶鐞嗙郴缁熸湭鍏变韩鍏敤缂栫爜鍩烘暟銆侻axDB鍜孧ySQL鏁版嵁搴撶鐞嗙郴缁熸槸鐢盡ySQL AB鍏徃鎻愪緵鐨勭嫭绔嬩骇鍝併

MySQL AB涓篗axDB鎻愪緵浜嗗叏闈㈢殑涓撲笟鏈嶅姟缁勫悎銆

1.5.1. 浠涔堟槸MaxDB锛

MaxDB鏄吋瀹笰NSI SQL-92锛堝叆闂ㄧ骇锛夈佺敱SAP AG鎻愪緵鐨勫叧鑱旀暟鎹簱绠$悊绯荤粺锛圧DBMS)锛屼篃鍙敱MySQL AB鎻愪緵銆侻axDB鑳藉婊¤冻浼佷笟绾у簲鐢ㄧ殑瑕佹眰锛 瀹夊叏鎬э紝鍙几缂╂э紝楂樺害骞惰鎬э紝浠ュ強寮哄ぇ鐨勬ц兘銆傚畠鑳借繍琛屽湪鎵鏈変富瑕佺殑鎿嶄綔绯荤粺涓嬨傚骞寸殑缁忓巻琛ㄦ槑锛屽畠鑳借繍琛岋紝骞惰兘鍦24x7鐨勮繍浣滀腑杩愯鏁颁互TB璁$殑鏁版嵁銆

鏁版嵁搴撳紑鍙戞槸浜1977骞村湪鏌忔灄鎶鏈ぇ瀛︿綔涓轰竴涓爺绌堕」鐩紑濮嬬殑銆傚湪20涓栫邯80骞翠唬鏃╂湡锛屽畠鍙戝睍鎴愪负鏁版嵁搴撲骇鍝侊紝闅忓悗褰扤ixdorf銆丼iemens Nixdorf銆丼oftware AG鎵鏈夛紝鐩墠褰扴AP AG鎵鏈夈傚湪杩欎竴鍙戝睍鍘嗙▼涓紝瀹冨厛鍚庤鍛藉悕涓篤DN銆丷eflex銆丼upra 2銆丏DB/4銆丒ntire SQL-DB-Server鍜孉DABAS D銆1997骞达紝SAP浠庤蒋浠禔P鎵嬩腑鎺ョ浜嗚杞欢锛屽苟灏嗗叾閲嶆柊鍛藉悕涓篠AP DB銆傝嚜2000骞10鏈堣捣锛屼緷GNU閫氱敤鍏叡璁稿彲鐨勫悕涔夊彂甯冧簡浼楀鐨凷AP DB婧愮爜锛堣鍙傝闄勫綍J锛欸NU閫氱敤鍏叡璁锛夈

2003骞达紝SAP AG鍜孧ySQL AB纭珛浜嗗悎浣滀紮浼村叧绯伙紝骞跺皢鏁版嵁搴撶郴缁熼噸鍛藉悕涓篗axDB銆

1.5.2. MaxDB鐨勫巻鍙

MaxDB鐨勫巻鍙插彲杩芥函鑷砈AP DB銆丼AP AG鐨凞BMS锛屼篃灏辨槸璇达紝MaxDB鏄疭AP DB鐨勯噸鍛藉悕鍜屽寮虹増鏈傚骞存潵锛孧axDB宸叉垚鍔熺敤浜巑ySAP涓氬姟濂椾欢鐨勫皬鍨嬨佷腑鎬у拰澶у瀷瀹夎瀹炰緥锛屼互鍙婇渶瑕佷紒涓氱骇DBMS鐨勫叾浠栬姹傝嫑鍒荤殑SQL搴旂敤锛堟秹鍙婄敤鎴锋暟銆佷簨鍔″伐浣滈噺銆佷互鍙婃暟鎹簱鐨勫ぇ灏忥級銆

闄や簡绗笁鏂规暟鎹簱绯荤粺澶栵紝濡侽racle銆丮icrosoft SQL Server浠ュ強IBM DB2锛孲AP DB鎰忓懗鐫鍙︿竴绉嶉夋嫨銆2000骞10鏈堬紝SAP AG渚 GNU GPL璁稿彲锛堣鍙傝闄勫綍J锛欸NU閫氱敤鍏叡璁锛夊彂甯冧簡SAP DB锛屼粠鑰屼娇寰楀叾鎴愪负寮鏀炬簮鐮佽蒋浠躲

鐩墠锛孧axDB宸茶涓栫晫鍚勫湴绾3500涓猄AP瀹㈡埛浣跨敤銆備笉浠呭姝わ紝鍦⊿AP鐨処T閮ㄩ棬鍐咃紝澶у鏁板畨瑁呭湪Unix鍜孡inux骞冲彴涓婄殑DBMS鍧囦緷璧栦簬MaxDB銆侻axDB姝h浆鍚戦噸璐熻嵎鑱旀満浜嬪姟澶勭悊锛圤LTP锛夛紝鐢ㄦ埛鏁颁互鍗冭锛屾暟鎹簱鐨勫ぇ灏忎粠鏁扮櫨GB鍒版暟TB銆

2003骞达紝SAP鍜孧ySQL纭珛浜嗗悎浣滀紮浼村叧绯伙紝骞惰揪鎴愪簡寮鍙戝悎浣滃崗璁備綔涓哄叾缁撴灉锛岃嚜7.5鐗堝彂甯冧互鏉ワ紙2003骞11鏈堬級锛孲AP鐨勬暟鎹簱绯荤粺SAP DB浠ySQL鐨凪axDB鍚嶄箟鎻愪緵銆

MaxDB 7.5鐗堟槸SAP DB 7.4缂栫爜鍩烘暟鐨勭洿鎺ユ敼杩涖傚洜姝わ紝MaxDB杞欢7.5鐗堝彲鐢ㄤ簬SAP DB 7.2.04鐗堝拰鏇撮珮鐗堟湰鐨勭洿鎺ュ崌绾с

涓庝互寰鐩稿悓锛岀洰鍓嶏紝浣嶄簬SAP AG鐨勫墠SAP DB寮鍙戝洟闃熶粛璐熻矗MaxDB鐨勫紑鍙戝拰鏀寔銆侻ySQL AB涓庝綅浜嶴AP鐨凪axDB鍥㈤槦瀵嗗垏鍚堜綔锛岃嚧鍔涗簬鏀硅繘MaxDB浜у搧锛岃鍙傝1.5鑺傦紝鈥淢axDB鏁版嵁搴撶鐞嗙郴缁熸杩扳銆係AP AG鍜孧ySQL AB鍧囪礋璐axDB鐨勯攢鍞拰鍒嗗彂銆侻axDB鍜孧ySQL鏈嶅姟鍣ㄧ殑鎻愬崌淇冭繘浜嗕紒涓氬崗浣滐紝浠庤屼娇寰椾袱绉嶄骇鍝佺郴鍒楀潎浠庝腑鍙楃泭銆

涓嶴AP瑙e喅鏂规涓璧锋彁渚涗箣鍓嶏紝鎴栨斁鍦∕ySQL绔欑偣渚涗笅杞戒箣鍓嶏紝MaxDB鍙桽AP AG鍏ㄩ潰璐ㄩ噺淇濊瘉璁″垝鐨勬帶鍒躲

1.5.3. MaxDB鐨勭壒鎬

MaxDB鏄竴绉嶅ぇ鍨嬨侀氳繃SAP璁よ瘉鐨勫紑鏀炬簮鐮佹暟鎹簱锛屽彲鐢ㄤ簬OLTP鍜孫LAP锛屽畠鍏锋湁楂樼殑鍙潬鎬с佸彲鐢ㄦу拰鍙几缂╂э紝浠ュ強鐩稿綋瀹屽杽鐨勭壒鎬ч泦銆傚畠瀹氫綅浜庡ぇ鍨媘ySAP鍟嗕笟濂椾欢鐜锛屼互鍙婇渶瑕佹渶澶т紒涓氱骇鏁版嵁搴撳姛鑳界殑鍏朵粬搴旂敤锛屾澶栵紝瀹冭繕琛ュ厖浜哅ySQL鏁版嵁搴撴湇鍔″櫒銆

MaxDB鏄噰鐢ㄥ鎴风/鏈嶅姟鍣ㄦā寮忚繍浣滅殑浜у搧銆傚紑鍙戝畠鐨勭洰鐨勫湪浜庢弧瓒砄LTP鍜屾暟鎹粨搴/OLAP/鍐崇瓥鏀寔鏂归潰鐨勫畨瑁呴渶姹傘浼樼偣锛

         绠鍗曠殑閰嶇疆鍜岀鐞嗭細 鍩轰簬GUI锛堝浘褰㈠寲鐢ㄦ埛鐣岄潰锛夌殑瀹夎绠$悊鍣ㄥ拰鏁版嵁搴撶鐞嗗櫒锛屽彲浣滀负DBMS鎿嶄綔鐨勫崟涓鐞嗗伐鍏枫

         涓嶉棿鏂搷浣滐紝鏃犻渶璁″垝鐨勫仠鏈烘椂闂达紝涔熶笉闇瑕佹寔涔呮х淮鎶锛氳嚜鍔ㄧ┖闂寸鐞嗭紝鏃犻渶閲嶇粍銆

         绮惧績璁捐鐨勫浠藉拰鎭㈠鑳藉姏锛氳仈鏈哄浠藉拰澧為噺澶囦唤锛屾仮澶嶅悜瀵间互鎸囧浣犲畬鎴愭暣涓仮澶嶆楠ゃ

         鏀寔澶ч噺鐢ㄦ埛锛屾暟TB鐨勬暟鎹簱澶у皬锛屼互鍙婅嫑鍒荤殑宸ヤ綔閲忚姹傦細 楂樼殑鍙潬鎬э紝鎬ц兘鍜屽彲浼哥缉鎬

         楂樺彲鐢ㄦэ細 绨囨敮鎸侊紝寰呮満閰嶇疆锛岀儹寰呮満閰嶇疆

1.5.4. 璁稿彲鍜屾敮鎸

浣跨敤MySQL AB鎻愪緵鐨勫叾浠栦骇鍝佺殑璁稿彲璇侊紝鍙娇鐢∕axDB銆傚洜姝わ紝鍙湪GNU閫氱敤鍏叡璁稿彲涓嬩互鍙婂晢涓氳鍙笅浣跨敤MaxDB銆傚叧浜庤鍙殑鏇村淇℃伅锛岃璁块棶http://www.mysql.com/company/legal/licensing/

MySQL AB璐熻矗涓洪潪SAP瀹㈡埛鎻愪緵MaxDB鎶鏈敮鎸併侻axDB鏀寔鍙湪鍚勭灞傞潰涓婃彁渚涳紙鍩烘湰锛岄摱璐ㄥ拰閲戣川锛夛紝灏嗘棤闄愮殑鐢靛瓙閭欢/Web鏀寔鎵╁睍涓哄涓氬姟鍏抽敭绯荤粺鐨勫叏澶╁欑數璇濇敮鎸併

褰揗axDB涓嶴ap搴旂敤绋嬪簭锛堝SAP NetWeaver鍜宮ySAP鍟嗕笟濂椾欢锛変竴璧蜂娇鐢ㄦ椂锛孧ySQL AB杩樿兘涓哄叾鎻愪緵璁稿彲璇佸拰鏀寔銆傚叧浜庤兘婊¤冻鎮ㄩ渶姹傜殑璁稿彲鍜屾敮鎸佹柟闈㈢殑鏇村淇℃伅锛璇疯仈绯MySQL AB銆

鎴戜滑涔熸彁渚涘挩璇㈠拰鍩硅鏈嶅姟銆侻ySQL灏嗗畾鏈熸彁渚汳axDB璇剧▼锛屽叧浜庤绋嬭〃锛岃鍙傝http://www.mysql.com/training/

1.5.5. MaxDB鍜孧ySQL涔嬮棿鐨勭壒鎬у樊寮

MaxDB鏄疢ySQL AB鍏徃閫氳繃SAP璁よ瘉鐨勬暟鎹簱銆侻axDB鏁版嵁搴撴湇鍔″櫒琛ュ厖浜哅ySQL AB浜у搧绯诲垪銆傛煇浜汳axDB鐗规у湪MySQL鏁版嵁搴撴湇鍔″櫒涓婁笉鍙敤锛屽弽涔嬩害鐒躲

涓嬮潰绠瑕佷粙缁嶄簡MaxDB鍜孧ySQL鐨勪富瑕佸樊鍒紝浣嗗苟涓嶅畬鍏ㄣ

         MaxDB鏄噰鐢ㄥ鎴风/鏈嶅姟鍣ㄦā寮忚繍浣滅殑绯荤粺銆侻ySQL鑳藉浣滀负瀹㈡埛绔/鏈嶅姟鍣ㄧ郴缁熻繍琛岋紝涔熻兘浣滀负宓屽叆寮忕郴缁熻繍琛屻

         MaxDB鎴栬涓嶈兘杩愯鍦∕ySQL鏀寔鐨勬墍鏈夊钩鍙颁笂銆

         MaxDB閲囩敤浜嗛拡瀵瑰鎴风锛忔湇鍔″櫒閫氫俊鐨勪笓鏈夌綉缁滃崗璁侻ySQL閲囩敤浜員CP/IP锛堥噰鐢ㄦ垨鏈噰鐢⊿SL鍔犲瘑锛夈佸鎺ュ瓧鍗忚锛堢被浼糢nix鐨勭郴缁熶笅锛夋垨鍛藉悕绠¢亾锛圵indows NT绯诲垪涓嬶級銆

         MaxDB鏀寔瀛樺偍绋嬪簭銆傚浜嶮ySQL锛屽湪5.0鐗堟湰涓疄鐜颁簡瀛樺偍绋嬪簭銆侻axDB杩樻敮鎸侀氳繃SQL鎵╁睍杩涜鐨勮Е鍙戠▼搴忕紪绋嬶紝璇ュ姛鑳借鍒掑湪MySQL 5.1涓疄鐜般侻axDB鍖呭惈閽堝瀛樺偍绋嬪簭璇█鐨勮皟璇曠▼搴忥紝鑳藉灏嗗涓祵濂楀紡瑙﹀彂绋嬪簭涓茶仈鍦ㄤ竴璧凤紝鑰屼笖姣忎釜鍔ㄤ綔鍜岃鍧囨敮鎸佸涓Е鍙戠▼搴忋

         MaxDB鐨勫彂甯冮噰鐢ㄤ簡鍩轰簬鏂囨湰銆佸浘褰㈡垨Web鐨勭敤鎴风晫闈€侻ySQL鐨勫彂甯冧粎閲囩敤鍩轰簬鏂囨湰鐨勭敤鎴风晫闈細鍥惧舰鍖栫敤鎴风晫闈紙MySQL鎺у埗涓績銆丮ySQL绠$悊鍣級涓庝富鍙戝竷鐗堟湰鏄崟鐙彁渚涚殑銆傞拡瀵筂ySQL鐨勫熀浜嶹eb鐨勭敤鎴风晫闈㈡槸鐢辩涓夋柟鎻愪緵鐨勩

         MaxDB鏀寔澶氱涔熻MySQL鏀寔鐨勭紪绋嬫帴鍙c備负浜嗕娇鐢∕axDB杩涜寮鍙戯紝杩樻彁渚涗簡MaxDB ODBC椹卞姩绋嬪簭锛孲QL鏁版嵁搴撹繛閫氾紙SQLDBC锛夛紝JDBC椹卞姩绋嬪簭锛孭erl鍜孭ython妯″潡锛屼互鍙奙axDB PHP鎵╁睍锛堥氳繃浣跨敤PHP鏉ヨ闂甅ySQL MaxDB鏁版嵁搴擄級銆傜涓夋柟缂栫▼鎺ュ彛锛 鏀寔OLE DB銆丄DO銆丏AO銆丷DO銆佷互鍙.NET鍜孫DBC銆侻axDB鏀寔宓屽叆寮廠QL鍜孋/C++銆

         MaxDB鍖呭惈MySQL涓嶅叿澶囩殑绠$悊鐗规э細 鎸夋椂闂淬佷簨浠跺拰鍛婅杩涜瑙勫垝瀹夋帓锛屽苟鑳藉湪杈惧埌鍛婅闃堝兼椂灏嗘秷鎭彂閫佺粰鏁版嵁搴撶鐞嗗櫒銆

1.5.6. MaxDB鍜孧ySQL涔嬮棿鐨勫崗鍚屾

MaxDB鍜孧ySQL鏄嫭绔嬬殑鏁版嵁搴撶鐞嗘湇鍔″櫒銆傜郴缁熼棿鐨勫崗鍚屾ф槸鍙兘鐨勶紝閫氳繃鐩稿簲鐨勬柟寮忥紝绯荤粺鑳藉褰兼浜ゆ崲鏁版嵁銆傝鎯冲湪MaxDB鍜孧ySQL涔嬮棿浜ゆ崲鏁版嵁锛屽彲浣跨敤绯荤粺鐨勫鍏ュ拰瀵煎嚭宸ュ叿锛屾垨MaxDB鍚屾绠$悊鍣ㄣ傚浜庡鍏ュ拰瀵煎嚭宸ュ叿锛屽彲鍦ㄦ墜鍔ㄦā寮忎笅浼犺緭鏁版嵁锛堝緢灏戝嚭鐜帮級銆侻axDB鍚屾绠$悊鍣ㄦ彁渚涗簡鏇村揩鐨勬暟鎹紶杈撳姛鑳姐

MaxDB瑁呰浇鍣ㄥ彲鐢ㄤ簬瀵煎嚭鏁版嵁鍜屽璞″畾涔夈傝杞藉櫒鑳藉浠axDB鍐呴儴浜岃繘鍒舵牸寮忓拰鏂囨湰鏍煎紡锛圕SV锛夊鍑烘暟鎹傚浜庝互鏂囨湰鏍煎紡浠嶮axDB瀵煎嚭鐨勬暟鎹紝鍙娇鐢mysqldump鏁版嵁搴撳浠界▼搴忓皢鍏堕噸鏂板鍏ュ埌MySQL涓傝鎯冲皢MySQL鏁版嵁瀵煎叆鍒癕axDB锛屽彲浣跨敤mysqldump鍒涘缓INSERT璇彞鎴朣ELECT ... INTO OUTFILE璇彞浠ュ垱寤烘枃鏈枃浠讹紙CSV锛夈備娇鐢∕axDB瑁呰浇鍣ㄨ杞界敱MySQL鐢熸垚鐨勬暟鎹枃浠躲

鍙互浣跨敤MaxDB瑁呰浇鍣ㄥ拰MySQL宸ュ叿mysqldump锛屽湪绯荤粺闂翠氦鎹㈡暟鎹畾涔夈傜敱浜庝袱绉嶇郴缁熶娇鐢ㄧ殑SQL鈥滄柟瑷鈥濈暐鏈夊樊寮傦紝鑰屼笖MaxDB鎷ユ湁鐩墠灏氫笉琚玀ySQL鏀寔鐨勭壒鎬э紙濡係QL绾︽潫锛夛紝鎴戜滑寤鸿浠ユ墜鍔ㄦ柟寮忚皟鏁村畾涔夋枃浠躲Mysqldump宸ュ叿鎻愪緵浜嗏--compatible-name = maxdb鈥濋夐」鏉ョ敓鎴愪笌MaxDB鍏煎鐨勮緭鍑猴紝浠ヤ究浣跨Щ妞嶆洿涓虹畝鍗曘

浣滀负MaxDB 7.6鐨勭粍鎴愰儴浠斤紝鍙戝竷浜哅axDB鍚屾绠$悊鍣ㄣ傚悓姝ョ鐞嗗櫒鏀寔鏁颁釜MaxDB瀹炰緥闂寸殑寮傛澶嶅埗銆備絾鏄紝涔熻璁¤鍒掍簡鍗忓悓鐗规э紝鍥犳锛屽悓姝ョ鐞嗗櫒鏀寔澶嶅埗鍒癕ySQL鏈嶅姟鍣ㄧ殑鎿嶄綔锛屼互鍙婃潵鑷狹ySQL鏈嶅姟鍣ㄧ殑澶嶅埗鎿嶄綔銆

鍦ㄩ娆″彂甯冪殑鐗堟湰涓紝鍚屾绠$悊鍣ㄦ敮鎸佸皢鏁版嵁鎻掑叆鍒癕ySQL銆傝繖鎰忓懗鐫锛屽湪寮濮嬫椂浠呮敮鎸佷粠MaxDB鍒癕ySQL鐨勫鍒躲傚湪2005骞寸殑瀹夋帓涓紝灏嗗鍔犳妸鏁版嵁浠嶮ySQL鏈嶅姟鍣ㄥ鍑哄埌鍚屾绠$悊鍣ㄧ殑鍔熻兘锛屽洜鑰屽鍔犱簡瀵逛粠MySQL鍒癕axDB鐨勫鍒舵敮鎸併

1.5.7. 涓嶮axDB鏈夊叧鐨勯摼鎺

鍏充簬MaxDB淇℃伅鐨勪富椤典綅浜http://www.mysql.com/products/maxdb銆傚湪璇ラ〉闈笂锛岃缁嗕粙缁嶄簡MaxDB鏁版嵁搴撶鐞嗙郴缁熺殑鐗规э紝骞舵彁渚涗簡鎸囧悜鏂囨。鐨勫涓秴绾ч摼鎺ャ

闄や簡鏈珷缁欏嚭鐨勪粙缁嶅锛孧ySQL鍙傝冩墜鍐屼笉鍚换浣昅axDB鏂囨。銆侻axDB鏈夎嚜宸辩殑鏂囨。锛岀О涓篗axDB搴撱侻axDB搴撳彲浠庝笅杩扮綉鍧鑾峰緱锛http://dev.mysql.com/doc/maxdb/index.html

MySQL AB杩愯鐫涓涓叧浜嶮axDB鐨勭ぞ鍖洪偖浠跺垪琛紝璇峰弬瑙http://lists.mysql.com/maxdb銆傝鍒楄〃缁欏嚭浜嗙敓鍔ㄦ椿娉肩殑绀惧尯璁ㄨ銆傚緢澶氭牳蹇冨紑鍙戜汉鍛樺潎涓哄叾鎻愪緵浜嗙浉搴旂殑璐$尞銆備骇鍝佸彂甯冨皢琚彂閫佽嚦璇ュ垪琛ㄣ

MaxDB鐨刉eb璁哄潧缃戝潃鏄http://forums.mysql.com/銆傝璁哄潧涓昏澶勭悊鍏充簬MaxDB鐨勯棶棰橈紝鑰屼笉鏄叧浜嶴AP搴旂敤绋嬪簭鐨勯棶棰樸

1.6. MySQL鍙戝睍澶т簨璁

鍦ㄦ湰鑺備腑锛屼粙缁嶄簡MySQL鍙戝睍鍘嗙▼涓殑閲嶈浜嬩欢锛屽寘鎷悇绉峂ySQL鐗堟湰涓凡瀹炵幇鐨勪富瑕佺壒鎬ф垨瑙勫垝涓殑鐗规с傚湪涓嬭妭涓紝浠嬬粛浜嗗悇鍙戝竷绯诲垪鐨勭浉鍏充俊鎭

褰撳墠鐨勭敓浜х増鏈郴鍒楁槸MySQL 5.0锛屾嵁绉板畠鑳界ǔ瀹氬湴鐢ㄤ簬鐢熶骇鐜锛屽2005骞10鏈堝彂甯冪殑5.0.15鐗堛備互鍓嶇殑鐢熶骇鐗堟湰绯诲垪鏄疢ySQL 4.1锛屾嵁绉板畠涔熻兘绋冲畾鍦扮敤浜庣敓浜х幆澧冿紝濡2004骞10鏈堝彂甯冪殑4.1.7鐗堛傗滅敓浜х姸鎬佲濇剰鍛崇潃鏈潵鐨5.0鍜4.1寮鍙戜粎闄愪簬淇缂洪櫡銆傚浜庤緝鏃╃殑MySQL 4.0鍜3.23绯诲垪锛屼粎浼氬鍏抽敭缂洪櫡杩涜鏇存銆

瀵逛簬MySQL 5.0鍜5.1绯诲垪锛岀浉鍏崇殑MySQL寮鍙戞鍦ㄧН鏋佽繘琛屽綋涓紝骞朵細涓哄悗鑰呭鍔犳柊鐨勭壒鎬с

浠1涓増鏈郴鍒楀崌绾у埌涓嬩竴涓増鏈郴鍒椾箣鍓嶏紝璇峰弬瑙2.10鑺傦紝鈥滃崌绾ySQL鈥鐨勪粙缁嶃

鍦ㄤ笅闈㈢殑琛ㄦ牸涓紝褰掔撼浜嗚姹傛渶杩垏鐨勭壒鎬э紝浠ュ強瀹炴柦浜嗚繖浜涚壒鎬ф垨璁″垝瀹炴柦杩欎簺鐗规х殑鐗堟湰锛

鐗规

MySQ绯诲垪

Foreign keys

3.23锛堥拡瀵InnoDB瀛樺偍寮曟搸锛

Unions

4.0

Subqueries

4.1

R-trees

4.1锛堥拡瀵MyISAM 瀛樺偍寮曟搸锛

Stored procedures

5.0

Views

5.0

Cursors

5.0

XA transactions

5.0

Foreign keys

5.1锛堝湪3.23涓疄鏂斤紝瀵逛簬InnoDB

Triggers

5.05.1

Full outer joins

5.1

Constraints

5.1锛堝湪3.23涓疄鏂斤紝瀵逛簬InnoDB

Partitioning

5.1

Pluggable Storage Engine API

5.1

Row-Based Replication

5.1

1.6.1. MySQL 5.1鐨勬柊鐗规

鍏充簬鎴戜滑鎵撶畻鍦∕ySQL 5.1涓鍔犵殑鐗规у垪琛紝璇峰弬瑙1.6鑺傦紝鈥淢ySQL鍙戝睍澶т簨璁扳銆傞殢鐫5.1鐗堢殑涓嶆柇鍙戝睍锛屾垜浠皢鍦ㄦ湰鑺傚鍔犳洿澶氳缁嗕俊鎭

鍙﹁鍙傝绗18绔狅細鍒嗗尯

1.7. MySQL淇℃伅婧

1.7.1. MySQL閭欢鍒楄〃

鍦ㄦ湰鑺備腑浠嬬粛浜哅ySQL閭欢鍒楄〃锛屽苟缁欏嚭浜嗕娇鐢ㄩ偖浠跺垪琛ㄧ殑鎸囧崡銆傝璐偖浠跺垪琛ㄥ悗锛屽皢浠ョ數瀛愰偖浠舵秷鎭殑褰㈠紡鏀跺埌鎵鏈夊凡璁板綍鐨勪俊鎭備綘涔熷彲浠ュ皢鑷繁鐨勯棶棰樺拰瑙g瓟鍙戦佽嚦閭欢鍒楄〃銆

1.7.1.1. MySQL閭欢鍒楄〃

瑕佹兂璁㈣喘鏈妭鎵浠嬬粛鐨勯偖浠跺垪琛ㄦ垨鍙栨秷璁㈣喘锛岃璁块棶http://lists.mysql.com/銆傚浜庡ぇ澶氭暟閭欢鍒楄〃锛屽彲閫夋嫨鑳藉鑾峰彇鍗曠嫭娑堟伅鐨勬瑙勫垪琛ㄧ増鏈紝鎴栭夋嫨鎸夊ぉ鍙戝竷鐨勫寘鍚ぇ閲忔秷鎭殑鏂囨憳鐗堟湰銆

涓嶈灏嗚璐俊鎭垨鍙栨秷璁㈣喘鐨勪俊鎭彂閫佸埌閭欢鍒楄〃锛屽師鍥犲湪浜庯紝杩欑被娑堟伅灏嗚嚜鍔ㄥ垎鍙戠粰鏁板崈浣嶅叾浠栫敤鎴枫

鍦ㄤ綘鐨勬墍鍦ㄥ湴锛屽彲鑳芥湁寰堝MySQL閭欢鍒楄〃鐨勮鎴枫傚鏋滄槸杩欐牱锛岃鍦扮偣鍙兘浼氭湁鏈湴閭欢鍒楄〃锛岃繖鏍凤紝浠lists.mysql.com鍙戝嚭鐨勬秷鎭皢琚紶鎾埌鏈湴鍒楄〃銆鍦ㄨ繖绫绘儏褰笅锛岃涓庝綘鐨勭郴缁熺鐞嗗憳鑱旂郴锛屾坊鍔犳垨鍒犻櫎鏈湴MySQL鍒楄〃銆

濡傛灉甯屾湜灏嗛偖浠跺垪琛ㄧ殑淇℃伅浼犻佸埌閭欢绋嬪簭鐨勯偖绠变腑锛岃鏍规嵁娑堟伅鏍囬璁剧疆杩囨护鍣ㄣ傚彲浠ヤ娇鐢ㄥ垪琛↖D锛 鎴栨姇閫掕嚦锛 璇嗗埆鍒楄〃娑堟伅鐨勬爣棰樸

MySQL鍒楄〃鍖呭惈锛

         閫氬憡

璇ュ垪琛ㄧ敤浜庨氬憡鏂扮殑MySQL鐗堟湰鍜岀浉鍏崇▼搴忋傝繖鏄1绉嶄綆瀹归噺鍒楄〃锛屾墍鏈夌殑MySQL鐢ㄦ埛鍧囧簲璁㈣喘瀹冦

         mysql

杩欐槸鍏充簬涓鑸琈ySQL璁ㄨ鐨勪富瑕佸垪琛ㄣ傝娉ㄦ剰锛屽浜庢煇浜涗富棰樻潵璇达紝鍦ㄦ洿涓撻棬鐨勫垪琛ㄤ腑浼氬緱鍒版洿濂藉湴璁ㄨ銆傚鏋滃皢闂寮犺创鍒颁簡閿欒鐨勫垪琛紝鍙兘涓嶄細寰楀埌鍥炵瓟銆

         缂洪櫡

璇ュ垪琛ㄩ潰鍚戦偅浜涘笇鏈涢殢鏃朵簡瑙h嚜涓婃MySQL鐗堟湰鍙戝竷浠ユ潵宸查氭姤浜嬪疁鐨勪汉鍛橈紝鎴栧笇鏈涚Н鏋佸弬涓庣己闄峰鎵惧拰鏇存杩涚▼鐨勪汉鍛樸傝鍙傝1.7.1.3鑺傦紝鈥滃浣曢氭姤缂洪櫡鍜岄棶棰樷

         鍐呴儴鏋勪欢

璇ュ垪琛ㄩ潰鍚戦偅浜涗笌MySQL浠g爜鎵撲氦閬撶殑浜哄憳銆傚畠涔熸槸璁ㄨMySQL寮鍙戝苟寮犺创琛ヤ竵鐨勮鍧涖

         mysqldoc

璇ュ垪琛ㄩ潰鍚戦偅浜涗笌MySQL鏂囨。鎵撲氦閬撶殑浜哄憳锛 MySQL AB鍏徃鐨勪汉鍛橈紝璇戣咃紝浠ュ強鍏朵粬绀惧尯鎴愬憳銆

         鍩哄噯

璇ュ垪琛ㄩ潰鍚戜换浣曞鎬ц兘浜嬪疁鎰熷叴瓒g殑浜哄憳銆傝璁轰富瑕侀泦涓湪鏁版嵁搴撴ц兘鏂归潰锛堜笉闄愪簬MySQL锛夛紝涔熷寘鎷洿骞跨殑绫诲埆锛屽鍐呮牳鎬ц兘銆佹枃浠剁郴缁熴佺鐩樼郴缁熺瓑銆

         packagers锛堝寘瑁呯▼搴忥級

璇ュ垪琛ㄤ富瑕佽璁哄寘瑁呭拰鍒嗗彂MySQL鏂归潰鐨勯棶棰樸傝繖鏄緵鍒嗗彂鐗堢淮鎶や汉鍛樹氦娴丮ySQL鎵撳寘浜嬪疁鐨勮鍧涳紝涓虹殑鏄‘淇濆湪鎵鏈夋敮鎸佺殑骞冲彴鍜屾搷浣滅郴缁熶笂锛孧ySQL鐨勫瑙傚拰鎰熻灏藉彲鑳界被浼笺

         java

璇ュ垪琛ㄤ富瑕佽璁篗ySQL鏈嶅姟鍣ㄥ拰Java鏂归潰鐨勯棶棰樸傚畠涓昏璁ㄨJDBC椹卞姩绋嬪簭锛屽寘鎷琈ySQL Connector/J銆

         win32

璇ュ垪琛ㄦ兜鐩栦簡鍦∕icrosoft鎿嶄綔绯荤粺鐜涓嬶紙濡俉indows 9x, Me, NT, 2000, XP鍜2003锛変笌MySQL杞欢鏈夊叧鐨勬墍鏈変富棰橈紝

         myodbc

璇ュ垪琛ㄦ兜鐩栦簡涓庝娇鐢∣DBC杩炴帴鍒癕ySQL鏈嶅姟鍣ㄦ湁鍏崇殑鎵鏈変富棰樸

         gui-tools

璇ュ垪琛ㄦ兜鐩栦簡涓嶮ySQL GUI宸ュ叿鏈夊叧鐨勬墍鏈変富棰橈紝鍖呮嫭MySQL绠$悊鍛樹互鍙奙ySQL鎺у埗涓績鍥惧舰瀹㈡埛绔

         cluster

璇ュ垪琛ㄤ富瑕佽璁篗ySQL绨囥

         dotnet

璇ュ垪琛ㄤ富瑕佽璁篗ySQL鏈嶅姟鍣ㄥ拰.NET骞冲彴鏂归潰鐨勯棶棰樸傚畠涓嶮ySQL Connector/Net鎻愪緵浜虹殑鍏崇郴鏈瀵嗗垏銆

         plusplus

璇ュ垪琛ㄦ兜鐩栦簡浣跨敤C++ API杩涜MySQL缂栫▼鐨勬墍鏈変富棰樸

         perl

璇ュ垪琛ㄦ兜鐩栦簡涓嶱erl瀵筂ySQL鏀寔銆佷互鍙DBD::mysql鏈夊叧鐨勬墍鏈変富棰樸

濡傛灉鏃犳硶浠嶮ySQL閭欢鍒楄〃鎴栬鍧涜幏寰楅棶棰樿В绛旓紝涓绉嶉夋嫨鏄喘涔癕ySQL AB鐨勬敮鎸佹湇鍔°傝繖鏍凤紝浣犲氨鑳戒笌MySQL寮鍙戜汉鍛樼洿鎺ヨ仈绯汇

涓嬮潰浠嬬粛浜嗕竴浜涜嫳璇互澶栧叾浠栬瑷鐨凪ySQL閭欢鍒楄〃銆傝繖浜涢偖浠跺垪琛ㄤ笉鏄敱MySQL AB杩愯惀鐨勩

         <mysql-france-subscribe@yahoogroups.com>

娉曡閭欢鍒楄〃銆

         <list@tinc.net>

鏈濋矞璇偖浠跺垪琛ㄣ傚彂閫佺數瀛愰偖浠惰璐mysql your@email.address

         <mysql-de-request@lists.4t2.com>

寰疯閭欢鍒楄〃銆傚彂閫佺數瀛愰偖浠惰璐mysql-de your@email.addresshttp://www.4t2.com/mysql/绔欑偣涓婏紝鍙壘鍒板叧浜庤閭欢鍒楄〃鐨勬洿澶氫俊鎭

         <mysql-br-request@listas.linkway.com.br>

钁¤悇鐗欒閭欢鍒楄〃銆傚彂閫佺數瀛愰偖浠惰璐mysql-br your@email.address

         <mysql-alta@elistas.net>

瑗跨彮鐗欒閭欢鍒楄〃銆傚彂閫佺數瀛愰偖浠惰璐mysql your@email.address

1.7.1.2. 璇锋暀闂鎴栭氭姤缂洪櫡

寮犺创缂洪櫡鎶ュ憡鎴栭棶棰樹箣鍓嶏紝璇凤細

         棣栧厛鎼滅储MySQL鍦ㄧ嚎鎵嬪唽锛http://dev.mysql.com/doc/銆傛垜浠粡甯告洿鏂拌鎵嬪唽锛屼互浣胯鎵嬪唽淇濇寔鏈鏂帮紝鍏朵腑鍖呭惈鐩稿簲鐨勮В鍐虫柟妗堝拰鏂板彂鐜扮殑闂銆傚彉鏇村彶锛http://dev.mysql.com/doc/mysql/en/News.html锛夊彲鑳芥洿鏈夌敤锛屽師鍥犲湪浜庯紝鍦ㄨ緝鏂扮殑鐗堟湰涓彲鑳藉寘鍚浣犳墍鎻愬嚭闂鐨勮В鍐虫柟妗堛

         鎼滅储缂洪櫡鏁版嵁搴擄紝http://bugs.mysql.com/锛屾煡鎵捐缂洪櫡鏄惁宸查氭姤鎴栨洿姝c

         鎼滅储MySQL閭欢鍒楄〃妗f锛http://lists.mysql.com/

         浣犱篃鍙互浣跨敤http://www.mysql.com/search/鏉ユ悳绱ySQL AB缃戠珯涓婄殑鎵鏈夌綉椤碉紙鍖呭惈鎵嬪唽锛夈

濡傛灉鏃犳硶鍦ㄦ墜鍐屾垨妗f涓壘鍒扮瓟妗堬紝璇蜂笌鏈湴MySQL涓撳鍗忓晢銆傚鏋滀粛鏃犳硶鑾峰緱瑙g瓟锛屽湪涓庢垜浠仈绯讳箣鍓嶏紝璇锋寜鐓т粙缁嶅彂閫佺數瀛愰偖浠惰嚦MySQL閭欢鍒楄〃锛屽叿浣撳唴瀹硅涓嬩竴鑺傘

1.7.1.3. 濡備綍閫氭姤缂洪櫡鍜岄棶棰

閫氭姤缂洪櫡鐨勬甯稿湴鍧鏄http://bugs.mysql.com/锛屽畠涔熸槸鎴戞柟缂洪櫡鏁版嵁搴撶殑鍦板潃銆傝繖鏄1涓叕鍏辨暟鎹簱锛屼换浣曚汉閮借兘娴忚瀹冨苟杩涜鐩稿簲鐨勬悳绱€傚鏋滅櫥褰曞埌绯荤粺锛屽彲杈撳叆鏂扮殑鎶ュ憡銆

缂栧啓鑹ソ鐨勭己闄锋姤鍛婇渶瑕佽愬績锛屼絾鍦ㄧ1鏃堕棿姝g‘鍦板畬鎴愬畠涓嶄粎鑳借妭鐪佹垜浠殑鏃堕棿锛屼篃鑳借妭鐪佷綘鑷繁鐨勬椂闂淬傝壇濂界殑缂洪櫡鎶ュ憡搴斿寘鍚缂洪櫡鐨勫畬鏁存祴璇曟儏鍐碉紝浠ヤ究鎴戜滑鑳藉鍦ㄤ笅涓増鏈腑鏇存璇ョ己闄枫傛湰鑺備粙缁嶇殑鍐呭鐢ㄤ簬甯姪浣犳纭湴缂栧啓鎶ュ憡锛屼粠閬垮厤灏嗕綘鐨勬椂闂存氮璐瑰湪瀵规垜浠府鍔╀笉澶ф垨娌℃湁甯姪鐨勪簨涓婏紝

鎴戜滑榧撳姳浠讳綍浜轰娇鐢mysqlbug鑴氭湰鏉ョ敓鎴愮己闄锋姤鍛婏紙鎴栭氭姤闂锛夈Mysqlbug鍙湪鑴氭湰鐩綍涓嬫壘鍒帮紙婧愮爜鍒嗗彂鐗堬級锛屼篃鑳藉湪MySQL瀹夎鐩綍鐨刡in瀛愮洰褰曚笅鎵惧埌锛堜簩杩涘埗鍒嗗彂鐗堬級銆傚鏋滀笉鑳戒娇鐢mysqlbug锛堜緥濡傦紝濡傛灉浣犳鍦╓indows骞冲彴涓婅繍琛岋級锛屽簲鍖呮嫭鏈妭鎵杩扮殑鎵鏈夊繀瑕佷俊鎭紙鏇撮噸瑕佺殑鏄紝搴斾粙缁嶆搷浣滅郴缁熷拰MySQL鐗堟湰锛夛紝杩欑偣鍗佸垎閲嶈銆

閫氳繃鑷姩纭畾涓嬭堪淇℃伅锛mysqlbug鑴氭湰鑳藉甯姪浣犵敓鎴愭姤鍛婏紝浣嗘槸锛屽鏋滈仐婕忎簡鏌愪簺閲嶈浜嬮」锛岃灏嗗叾鍖呭惈鍦ㄦ秷鎭腑銆傝璁ょ湡闃呰鏈妭锛屽苟纭繚鍦ㄤ綘鐨勬姤鍛婁腑鍖呭惈浜嗘湰鑺傛墍杩扮殑鎵鏈変俊鎭

鍦ㄥ紶璐撮棶棰樺墠锛屾渶濂戒娇鐢∕ySQL鏈嶅姟鍣ㄧ殑鏈鏂扮敓浜х増鎴栧紑鍙戠増瀵归棶棰樿繘琛屾祴璇曘傞氳繃鍦ㄦ墍鍚殑娴嬭瘯鑼冧緥涓婁娇鐢ㄢmysql test < script_file锛屾垨杩愯缂洪櫡鎶ュ憡涓墍鍚殑Shell鎴朠erl鑴氭湰锛屼换浣曚汉鍧囧簲鑳介噸澶嶈缂洪櫡銆

瀵逛簬鍦ㄧ己闄锋暟鎹簱锛http://bugs.mysql.com/锛変腑寮犺创鐨勬墍鏈夌己闄凤紝鍧囦細琚撼鍏ユ垨璁板綍鍦ㄤ笅涓涓狹ySQL鐗堟湰涓傚鏋滃彧闇瑕佸皯閲忔洿鏀瑰氨鑳芥洿姝i棶棰橈紝鎴戜滑鎴栬浼氱粰鍑烘洿姝h闂鐨勮ˉ涓併

濡傛灉鍙戠幇MySQL涓瓨鍦ㄦ晱鎰熺殑瀹夊叏缂洪櫡锛岃鍙戦佺數瀛愰偖浠惰嚦security@mysql.com

濡傛灉鏈1浠藉彲閲嶅鐨勭己闄锋姤鍛婏紝璇峰皢鍏舵彁浜ゅ埌缂洪櫡鏁版嵁搴擄紝http://bugs.mysql.com/銆傛敞鎰忥紝鍗充娇鍦ㄨ鎯呭喌涓嬶紝涔熷簲棣栧厛杩愯mysqlbug鑴氭湰浠ユ壘鍑轰笌浣犵殑绯荤粺鏈夊叧鐨勪俊鎭紝杩欐槸涓涓笉閿欑殑涔犳儻銆傚浜庝换浣曟垜浠兘鍐嶇幇鐨勭己闄凤紝鍦ㄤ笅涓涓狹ySQL鐗堟湰涓慨姝e畠鐨勬満浼氬緢澶с

瑕佹兂閫氭姤鍏朵粬闂锛岃浣跨敤MySQL閭欢鍒楄〃銆

璇锋敞鎰忥紝鎴戜滑鍙兘浼氬鍖呭惈杩囧淇℃伅鐨勬秷鎭仛鍑哄搷搴旓紝浣嗕笉澶細瀵瑰寘鍚繃灏戜俊鎭殑娑堟伅鍋氬嚭鍥炲簲銆備汉浠父浼氱渷鐣ユ帀涓浜涗簨瀹烇紝鍥犱负浠栦滑璁や负鑷繁鐭ラ亾浜嗘晠闅滅殑鍘熷洜锛屽苟鎯冲綋鐒跺湴璁や负杩欑被缁嗚妭鏃犲叧绱ц銆傝壇濂界殑鍘熷垯鏄細 濡傛灉浣犲闄堣堪鏌愪簨鐘硅鲍涓嶅畾锛岃闄堣堪涔嬨傚鏋滄垜浠姹備綘鎻愪緵鍒濆鎶ュ憡涓己灏戠殑淇℃伅锛屽湪鎶ュ憡涓紪鍐欏琛屼俊鎭簮姣旂瓑鍊欏洖澶嶈蹇紝楹荤儲涔熸洿灏忋

鍦ㄧ己闄锋姤鍛婁腑锛屾渶甯哥姱鐨勯敊璇寘鎷細锛坅锛夋湭鍖呭惈鎵浣跨敤MySQL鐨勭増鏈彿锛屼互鍙婏紙b锛夋湭瀹屽叏鎻忚堪瀹夎浜哅ySQL鏈嶅姟鍣ㄧ殑骞冲彴锛堝寘鎷钩鍙扮被鍨嬶紝浠ュ強鐗堟湰鍙凤級銆傝繖鏄珮搴︾浉鍏崇殑淇℃伅锛屽鏋滄病鏈夊畠锛99锛呯殑缂洪櫡鎶ュ憡鏃犵敤銆傛垜浠亣鍒拌繖绫婚棶棰橈紝鈥滀负浣曞畠瀵规垜娌$敤鈥濓紵 闅忓悗锛屾垜浠彂鐜板湪璇ySQL鐗堟湰涓紝鎵璇锋眰鐨勭壒鎬у皻鏈疄鏂斤紝鎴栧湪杈冩柊鐨凪ySQL鐗堟湰涓凡鏇存浜嗘姤鍛婁腑鎻忚堪鐨勭己闄枫傛湁浜涙椂鍊欙紝閿欒涓庡钩鍙扮浉鍏筹紝鍦ㄨ繖绫绘儏鍐典笅锛屽鏋滀笉鐭ラ亾鎿嶄綔绯荤粺鍜屽钩鍙扮殑鐗堟湰鍙凤紝鎴戜滑鍑犱箮涓嶅彲鑳芥洿姝d换浣曢棶棰樸

濡傛灉浣犳槸浠庢簮鐮佺紪璇慚ySQL鐨勶紝濡傛灉涓庨棶棰樻湁鍏筹紝杩樺簲鎻愪緵鏈夊叧缂栬瘧鍣ㄧ殑淇℃伅銆傞棶棰樼粡甯稿嚭鍦ㄧ紪璇戝櫒锛屼絾浜轰滑鍗磋涓洪棶棰樹笌MySQL鏈夊叧銆傚ぇ澶氭暟缂栬瘧鍧囧浜庝笉鏂殑寮鍙戣繃绋嬩腑锛屽苟浼氬彉寰楄秺鏉ヨ秺濂姐備负浜嗙‘瀹氶棶棰樻槸鍚︿笌浣犵殑缂栬瘧鍣ㄦ湁鍏筹紝鎴戜滑闇瑕佺煡閬撲綘鎵浣跨敤鐨勭紪璇戝櫒銆傛敞鎰忥紝鎵鏈夌殑缂栬瘧闂鍧囧簲琚綋浣滅己闄峰苟浜堜互閫氭姤銆

鍦ㄤ綘鐨勬姤鍛婁腑鍖呭惈鑹ソ鐨勯棶棰樻弿杩版椂锛屾姤鍛婃渶鏈夊府鍔┿備篃灏辨槸璇达紝搴旂粰鍑虹ず渚嬶紝鎸囨槑瀵艰嚧闂鐨勬墍鏈変簨椤癸紝骞跺噯纭弿杩伴棶棰樻湰韬傛渶濂界殑鎶ュ憡搴斿寘鍚畬鏁寸殑绀轰緥锛岃繖绫荤ず渚嬪簲闃愭槑鍐嶇幇缂洪櫡鎴栭棶棰樼殑鏂瑰紡銆傝鍙傝E.1.6鑺傦紝鈥滃鏋滃嚭鐜拌〃宕╂簝锛岃鐢熸垚娴嬭瘯妗堜緥鈥

濡傛灉绋嬪簭浜х敓浜嗛敊璇秷鎭紝涔熷簲灏嗗叾鍖呭惈鍦ㄤ綘鐨勬姤鍛婁腑锛岃繖鐐瑰緢閲嶈銆傚鏋滄垜浠墦绠椾娇鐢ㄧ▼搴忔悳绱㈡。妗堬紝鏈濂芥槸閫氭姤鐨勯敊璇秷鎭笌绋嬪簭鐢熸垚鐨勯敊璇秷鎭噯纭尮閰嶃傦紙鍗充娇鏄瓧姣嶇殑澶у皬鍐欎篃搴旇冭檻鍦ㄥ唴锛夈傛案杩滀笉瑕佸皾璇曚粠璁板繂涓啀鐜伴敊璇秷鎭紝鑰屾槸搴斿皢鏁翠釜娑堟伅鎷疯礉骞剁矘璐村埌鎶ュ憡涓

濡傛灉閬囧埌涓嶤onnector/ODBC (MyODBC)鏈夊叧鐨勯棶棰橈紝璇风敓鎴1浠借窡韪枃浠讹紝骞朵笌鎶ュ憡涓璧峰彂閫佺粰鎴戜滑銆傝鍙傝26.1.1.9鑺傦紝鈥滃浣曢氭姤MyODBC闂鎴栫己闄封

璇疯浣忥紝寰堝闃呰浣犳姤鍛婄殑浜哄憳浼氫娇鐢80鍒楃殑鏄剧ず鍣ㄣ備娇鐢mysql鍛戒护琛屽伐鍏风敓鎴愭姤鍛婃垨绀轰緥鏃讹紝濡傛灉杈撳嚭鍐呭鍙兘浼氳秴杩囪繖绫绘樉绀哄櫒鐨勫彲鐢ㄥ搴︼紝搴斾娇鐢ㄢ--vertical鈥濋夐」锛堟垨鈥\G鈥濊鍙ョ粓缁撶锛夛紝渚嬪EXPLAIN SELECT璇彞锛岃鍙傝鏈妭鍚庨潰缁欏嚭鐨勭ず渚嬨

璇峰湪浣犵殑鎶ュ憡涓寘鍚笅杩颁俊鎭細

         浣犳墍浣跨敤鐨凪ySQL鍒嗗彂鐗堢殑鐗堟湰鍙凤紙渚嬪MySQL 4.0.12锛夈傞氳繃鎵цmysqladmin version锛屽嵆鍙簡瑙f鍦ㄨ繍琛岀増鏈Mysqladmin绋嬪簭浣嶄簬MySQL瀹夎鐩綍鐨刡in瀛愮洰褰曚笅銆

         鍑虹幇闂鐨勬満鍣ㄧ殑鍒堕犲晢鍜屽瀷鍙枫

         鎿嶄綔绯荤粺鐨勫悕绉板拰鐗堟湰銆傚鏋滀綘浣跨敤鐨勬槸Windows鎿嶄綔绯荤粺锛岄氬父鑳介氳繃鍙屽嚮鈥滄垜鐨勭數鑴戔濆浘鏍囧苟鐐瑰嚮鈥甯姪/鍏充簬Windows鈥濊彍鍗曟潵浜嗚В鎿嶄綔绯荤粺鐨勫悕绉板拰鐗堟湰銆傚浜庡ぇ澶氭暟Unix鎿嶄綔绯荤粺锛屽彲閫氳繃鎵ц鍛戒护uname a鑾峰彇杩欑被淇℃伅銆

         鏌愪簺鏃跺欙紝鍐呭瓨瀹归噺锛堝疄闄呭唴瀛樺拰铏氭嫙鍐呭瓨锛変篃鏈夊叧绯汇傚鏋滄鐤戝畠锛屼篃搴斿寘鍚繖绫绘暟鍊笺

         濡傛灉浣犳鍦ㄤ娇鐢ㄧ殑鏄疢ySQL杞欢鐨勬簮鐮佸垎鍙戠増锛岃繕椤绘彁渚涙墍浣跨敤缂栬瘧鍣ㄧ殑鍚嶇О鍜岀増鏈傚鏋滀娇鐢ㄧ殑鏄簩杩涘埗鍒嗗彂鐗堬紝闇瑕佹彁渚涘叾鍚嶇О銆

         濡傛灉鍦ㄧ紪璇戣繃绋嬩腑鍑虹幇闂锛屽簲缁欏嚭鍑嗙‘鐨勯敊璇秷鎭紝鍑洪敊鏂囦欢涓殑涓嶈壇浠g爜锛屼互鍙婅浠g爜闄勮繎鐨勬暟琛屽唴瀹广

         濡傛灉mysqld鍋滄杩愯锛岃繕搴旈氭姤瀵艰嚧mysqld宕╂簝鐨勬煡璇€傞氬父锛岃兘澶熼氳繃杩愯鍚敤浜嗘煡璇㈡棩蹇楀姛鑳界殑mysqld鎵惧嚭瀹冿紝鐒跺悗鍦mysqld宕╂簝鍚庢煡鎵炬棩蹇椼傝鍙傝E.1.5鑺傦紝鈥滀娇鐢ㄦ棩蹇楁枃浠舵壘鍑簃ysqld涓殑閿欒鍘熷洜

         濡傛灉鏁版嵁搴撹〃涓庨棶棰樻湁鍏筹紝杩樺簲鍖呭惈mysqldump --no-data db_name tbl_name鐨勮緭鍑恒傝繖鏄竴绉嶄簡瑙f暟鎹簱涓〃鐩稿叧淇℃伅鐨勭畝鍗曟槗琛岃屼笖鍔熻兘寮哄ぇ鐨勬柟寮忋傝淇℃伅鑳藉府鍔╂垜浠缓绔嬩笌浣犳墍閬囧埌鐨勬儏鍐电浉鍖归厤鐨勫満鏅

         瀵逛簬涓SELECT璇彞鐨勯熷害鏈夊叧鐨勭己闄锋垨闂锛屾诲簲鍖呭惈鈥淓XPLAIN SELECT ...鈥濈殑杈撳嚭锛屼互鍙奡ELECT璇彞鐢熸垚鐨勮鏁锛堣嚦灏戯級銆傚浜庢瘡涓秹鍙婄殑琛紝搴斿寘鍚SHOW CREATE TABLE tbl_name鐨勮緭鍑恒備綘鎵鎻愪緵鐨勫叧浜庡叿浣撴儏鍐电殑淇℃伅瓒婂锛屽緱鍒板府鍔╃殑鍙兘鎬у氨瓒婂ぇ銆

涓嬮潰缁欏嚭浜嗕竴涓壇濂界己闄锋姤鍛婄殑绀轰緥銆傚簲浣跨敤mysqlbug鑴氭湰寮犺创瀹冦傛湰渚嬮噰鐢ㄤ簡mysql鍛戒护琛屽伐鍏枫傚浜庤緭鍑哄唴瀹瑰彲鑳戒細瓒呰繃80鍒楁樉绀哄櫒鍙敤瀹藉害鐨勮鍙ワ紝搴斾娇鐢ㄢ\G鈥濊鍙ョ粓缁撶銆

mysql> SHOW VARIABLES;
mysql> SHOW COLUMNS FROM ...\G
       <output from SHOW COLUMNS>
mysql> EXPLAIN SELECT ...\G
       <output from EXPLAIN>
mysql> FLUSH STATUS;
mysql> SELECT ...;
       <A short version of the output from SELECT,
       including the time taken to run the query>
mysql> SHOW STATUS;
       <output from SHOW STATUS>

         濡傛灉鍦ㄨ繍琛mysqld鏃跺嚭鐜伴敊璇垨闂锛屽簲鎻愪緵瀵艰嚧寮傚父鐨勮緭鍏ヨ剼鏈傝鑴氭湰搴斿寘鍚换浣曟墍闇鐨勬簮鏂囦欢銆傝秺鑳藉啀鐜板叿浣撴儏鍐电殑鑴氭湰瓒婂ソ銆傚鏋滆兘澶熷垱寤哄彲鍐嶇幇鐨勬祴璇曡寖渚嬶紝璇峰皢鍏跺紶璐村埌http://bugs.mysql.com/锛屽畠灏嗗緱鍒颁紭鍏堝寰呫

濡傛灉浣犱笉鑳芥彁渚涜剼鏈紝鑷冲皯搴斿湪浣犵殑閭欢涓寘鍚mysqladmin variables extended-status processlist鐨勮緭鍑猴紝浠ユ彁渚涘叧浜庣郴缁熸墽琛屾儏鍐电殑鏌愪簺淇℃伅銆

         濡傛灉涓嶈兘鐢熸垚鍖呭惈鏁拌鍐呭鐨勬祴璇曡寖渚嬶紝鎴栬呭鏋滄祴璇曡〃杩囧ぇ浠ヨ嚦浜庢棤娉曞彂閫佸埌閭欢鍒楄〃锛堣秴杩10琛岋級锛屽簲浣跨敤mysqldump杞偍琛紝骞跺垱寤烘弿杩伴棶棰樼殑README鏂囦欢銆

浣跨敤targzipzip鍒涘缓鏂囦欢鐨勫帇缂╁寘妗f锛屽苟浣跨敤FTP灏嗘。妗堜紶杈撳埌ftp://ftp.mysql.com/pub/mysql/upload/銆傜劧鍚庡皢闂鎻愪氦鍒版垜浠殑缂洪櫡鏁版嵁搴撲腑锛http://bugs.mysql.com/

         濡傛灉浣犺涓篗ySQL鏈嶅姟鍣ㄧ敓鎴愪簡濂囨殑鏌ヨ缁撴灉锛屼笉浠呭簲鍖呭惈缁撴灉锛岃繕搴旂粰鍑轰綘瀵硅缁撴灉鐨勭湅娉曪紝浠ュ強鏀寔瑙傜偣鐨勫熀纭銆

         鎻愪緵闂鐨勭ず渚嬫椂锛屾渶濂戒娇鐢ㄥ疄闄呮儏鍐典笅宸叉湁鐨勫彉閲忓悕銆佽〃鍚嶇瓑锛岃屼笉鏄柊鍚嶇О銆傞棶棰樺彲鑳戒笌鍙橀噺鍚嶆垨琛ㄥ悕鏈夊叧銆傛垨璁歌繖绫绘儏鍐靛緢缃曡锛屼絾瀹夊叏鎬绘瘮閬撴瓑寮恒傚綊鏍圭粨搴曪紝瀵逛綘鏉ヨ锛屾彁渚涘叧浜庡疄闄呮儏鍐电殑绀轰緥瑕佺畝鍗曚簺锛屽綋鐒跺鎴戜滑涔熸洿濂姐傚鏋滀綘鐨勬暟鎹笉鎵撶畻灞曠ず缁欏叾浠栦汉锛岃浣跨敤FTP灏嗗叾浼犺緭鍒ftp://ftp.mysql.com/pub/mysql/upload/銆傚鏋滀俊鎭槸楂樺害淇濆瘑鐨勶紝鑰屼笖浣犵敋鑷充笉鎵撶畻鍚戞垜浠睍绀猴紝璇蜂娇鐢ㄥ叾浠栧悕绉扮粰鍑虹ず渚嬶紝浣嗚娉ㄦ剰锛岃繖搴旀槸鏈鍚庣殑閫夋嫨銆

         濡傛灉鍙兘锛屽簲鍖呭惈鐩稿叧绋嬪簭鐨勬墍鏈夐夐」銆備緥濡傦紝搴旀寚鏄庡惎鍔mysqld鏈嶅姟鍣ㄦ椂浣跨敤鐨勯夐」锛屼互鍙婄敤鏉ヨ繍琛孧ySQL瀹㈡埛绔▼搴忕殑閫夐」銆傚浜庣▼搴忥紙濡mysqldmysql锛夐夐」浠ュ強configure鑴氭湰鐨勯夐」锛岄氬父鏄В绛旈棶棰樼殑鍏抽敭锛屽叧绯诲崄鍒嗗瘑鍒囥鍖呭惈瀹冧滑鎬讳笉鏄潖涓绘剰銆傚鏋滀娇鐢ㄤ簡浠讳綍妯″潡锛屽Perl鎴朠HP绛夛紝杩樺簲缁欏嚭瀹冧滑鐨勭増鏈

         濡傛灉浣犵殑闂涓庢潈闄愮郴缁熸湁鍏筹紝璇风粰鍑mysqlaccess鐨勮緭鍑猴紝mysqladmin reload鐨勮緭鍑猴紝浠ュ強杩涜杩炴帴鏃惰幏寰楃殑鎵鏈夐敊璇秷鎭傛祴璇曟潈闄愭椂锛岄鍏堝簲杩愯mysqlaccess銆傛帴涓嬫潵锛屾墽琛mysqladmin reload version锛屽苟涓庡鑷撮棶棰樼殑绋嬪簭鐩歌繛銆mysqlaccess鍙湪MySQL瀹夎鐩綍鐨刡in瀛愮洰褰曚笅鎵惧埌銆

         濡傛灉浣犳湁鍏充簬鏌愪竴缂洪櫡鐨勮ˉ涓侊紝涔熻灏嗗畠鍖呭惈鍦ㄥ唴銆備絾涓嶈璁や负璇ヨˉ涓佹槸鎴戜滑鎵闇鐨勫叏閮紝濡傛灉鏈彁渚涜ˉ涓佹墍鏇存缂洪櫡鐨勫繀瑕佷俊鎭紙濡傛祴璇曡寖渚嬶級锛屼笉瑕佸亣瀹氭垜浠細浣跨敤瀹冦傛垜浠彲鑳戒細閫氳繃琛ヤ竵鍙戠幇闂锛屾垨鑰呬笉鑳界悊瑙h琛ヤ竵锛屽鏋滄槸杩欐牱锛屾垜浠笉浼氫娇鐢ㄨ琛ヤ竵銆

濡傛灉鎴戜滑涓嶈兘鍑嗙‘鏍稿疄琛ヤ竵鐨勭洰鐨勶紝灏嗕笉浼氫娇鐢ㄥ畠銆傛祴璇曡寖渚嬩細瀵规垜浠湁鎵甯姪銆傝鎸囨槑璇ヨˉ涓佽兘澶勭悊鎵鏈夌殑闂銆傚鏋滄垜浠彂鐜拌ˉ涓佷笉鑳藉伐浣滅殑涓寸晫鎯呭喌锛堝嵆浣垮緢缃曡锛夛紝瀹冨彲鑳芥槸鏃犵敤鐨勩

         鍏充簬缂洪櫡鏄粈涔堛佸嚭鐜板師鍥犮佷互鍙婄己闄峰鍥犵殑鐚滄祴閫氬父鏄敊鐨勩傚嵆浣挎槸MySQL鍥㈤槦锛屽湪鏈娇鐢ㄨ皟璇曞櫒鍒ゅ畾缂洪櫡鐪熷疄鍘熷洜鐨勬儏鍐典笅锛屼篃涓嶈兘濡勫姞鐚滄祴銆

         璇峰湪浣犵殑缂洪櫡鎶ュ憡涓寚鏄庯紝浣犲凡鍙傞槄浜嗗弬鑰冩墜鍐屽苟瀵勫嚭浜嗘。妗堬紝浠ヤ究璁╁叾浠栦汉鐭ラ亾浣犲凡浣滀簡鑷瑙e喅闂鐨勫皾璇曘

         濡傛灉閬囧埌瑙f瀽閿欒锛岃浠旂粏妫鏌ヨ娉曘傚鏋滀笉鑳芥壘鍑洪敊璇嚭鐜板湪閭i噷锛屽緢鍙兘鏄洜涓轰綘浣跨敤鐨凪ySQL鏈嶅姟鍣ㄧ増鏈笉鏀寔浣犱娇鐢ㄧ殑璇硶銆傚鏋滀綘浣跨敤鐨勬槸http://dev.mysql.com/doc/涓婃彁渚涚殑褰撳墠鐗堟湰鍜屾墜鍐岋紝涓嶈鍖呭惈浣犳墍浣跨敤鐨勮娉曪紝MySQL鏈嶅姟鍣ㄤ笉鏀寔浣犵殑鏌ヨ銆傚湪杩欑鎯呭喌涓嬶紝鍞竴鐨勯夋嫨鏄嚜琛屽疄鏂借娉曪紝鎴栧彂閫佺數瀛愰偖浠惰嚦<licensing@mysql.com>锛屽苟瀵绘眰瀹炴柦鏂规銆

濡傛灉鎵嬪唽涓兜鐩栦簡浣犳墍浣跨敤鐨勮娉曪紝浣嗕綘浣跨敤鐨勬槸鏃х増鏈琈ySQL鏈嶅姟鍣紝璇锋鏌ySQL鍙樻洿鍙诧紝浠ユ煡鐪嬭娉曠殑瀹炴柦鏃堕棿銆傚湪杩欑鎯呭喌涓嬶紝鍙互閫夋嫨鍗囩骇鍒拌緝鏂扮殑MySQL鏈嶅姟鍣ㄧ増鏈傝鍙傝闄勫綍D锛歁ySQL鍙樻洿鍙

         濡傛灉闂鍦ㄤ簬鏁版嵁宕╂簝锛屾垨璁块棶鐗规畩琛ㄦ椂鍑洪敊锛岄鍏堝簲浣跨敤CHECK TABLEREPAIR TABLE鎴myisamchk杩涜妫鏌ュ苟灏濊瘯淇銆傝鍙傝绗5绔狅細鏁版嵁搴撶鐞

濡傛灉浣犱娇鐢ㄧ殑鎿嶄綔绯荤粺鏄疻indows锛岃浣跨敤SHOW VARIABLES LIKE 'lower_case_table_names'鍛戒护鏍稿疄鈥lower_case_table_names鐨勫笺

         濡傛灉缁忓父鑾峰緱宕╂簝鐨勮〃锛岃灏濊瘯鎵惧嚭鍙戠敓鐨勬椂闂村拰鍘熷洜銆傚湪杩欑鎯呭喌涓嬶紝MySQL鏁版嵁鐩綍涓嬬殑閿欒鏃ュ織鍙兘浼氬寘鍚叧浜庡畠鐨勪竴浜涗俊鎭傦紙杩欐槸鍚嶇О涓寘鍚.err鍚庣紑鐨勬枃浠锛夈傝鍙傝5.11.1鑺傦紝鈥滈敊璇棩蹇椻銆傚湪浣犵殑缂洪櫡鎶ュ憡涓紝璇峰寘鍚鏂囦欢鎻愪緵鐨勭浉鍏充俊鎭傚鏋滃湪鏇存柊鏈熼棿锛屾湭鏉姝绘洿鏂拌繘绋嬶紝姝e父鎯呭喌涓嬶紝mysqld涓嶄細閫犳垚琛ㄦ崯鍧忋傚鏋滀綘鑳藉鎵惧埌mysqld鍋滄鐨勫師鍥狅紝鎴戜滑浼氭洿瀹规槗鍦颁负浣犳彁渚涙洿姝e畠鐨勮ˉ涓併傝鍙傝A.1鑺傦紝鈥滃浣曠‘瀹氬鑷撮棶棰樼殑鍘熷洜鈥

         濡傛灉鍙兘锛岃涓嬭浇骞跺畨瑁呮渶鏂扮増鏈殑MySQL鏈嶅姟鍣紝骞舵鏌ヤ綘鐨勯棶棰樻槸鍚﹀緱鍒拌В鍐炽傛墍鏈夌増鏈殑MySQL杞欢鍧囩粡杩囧交搴曟祴璇曪紝骞跺簲鑳芥棤鏁呴殰杩愯銆傛垜浠嚧鍔涗簬灏藉彲鑳藉湴鍚戝悗鍏煎锛屼綘涔熷簲鑳藉姣笉鍥伴毦鍦板湪涓嶅悓鐨凪ySQL鐗堟湰闂磋繘琛屽垏鎹€傝鍙傝2.1.2鑺傦紝鈥滈夋嫨瑕佸畨瑁呯殑MySQL鍒嗗彂鐗堚

濡傛灉浣犳槸浜彈鏀寔鏈嶅姟鐨勫鎴凤紝璇峰皢缂洪櫡鎶ュ憡浜ゅ弶寮犺创鍦mysql-support@mysql.com锛屼互鑾峰緱鏇撮珮鐨勪紭鍏堢骇锛屽苟灏嗗叾寮犺创鍒版伆褰撶殑閭欢鍒楄〃锛屼互鏌ョ湅鏄惁鏈変汉閬囧埌浜嗙被浼奸棶棰橈紙鎴栬В鍐充簡闂锛

鍏充簬閫氭姤MyODBC涓瓨鍦ㄧ己闄风殑鏇村淇℃伅锛岃鍙傝26.1.1.9鑺傦紝鈥滃浣曢氭姤MyODBC闂鎴栫己闄封

鍏充簬鏌愪簺甯歌闂鐨勮В鍐虫柟妗堬紝璇峰弬瑙闄勫綍A锛闂鍜屽父瑙侀敊璇

灏嗙瓟妗堝崟鐙彂閫佺粰浣犺屼笉鏄彂閫佸埌閭欢鍒楄〃鏃讹紝鑹ソ鐨勭ぜ鑺傛槸锛屽鍥炵瓟杩涜褰掔撼鎬荤粨骞跺皢缁撴灉鍙戦佸埌閭欢鍒楄〃锛屼互渚垮叾浠栦汉涔熻兘浠庝綘鎵鏀跺埌銆佸苟瑙e喅浜嗛棶棰樼殑鍥炲簲涓彈鐩娿

1.7.1.4. 鍦ㄩ偖浠跺垪琛ㄤ笂鍥炵瓟闂鐨勬寚鍗

濡傛灉浣犺涓鸿嚜宸辩殑瑙g瓟浼氬紩璧峰箍娉涘叧娉紝鍙互灏嗗叾寮犺创鍒伴偖浠跺垪琛紝鑰屼笉鏄洿鎺ュ洖澶嶈鏁欑殑涓汉銆傚敖閲忎娇浣犵殑瑙g瓟鍏锋湁鏅亶鎬э紝浠ヤ究闄ゅ垵濮嬪彂璧蜂汉涔嬪鐨勫叾浠栦汉涔熻兘浠庝腑鍙楃泭銆傚皢瑙g瓟寮犺创鍒伴偖浠跺垪琛ㄦ椂锛岃纭浣犵殑瑙g瓟涓嶆槸宸叉湁绛旀鐨勫鍒跺搧銆

鍦ㄤ綘鐨勫洖澶嶄腑锛屽簲灏介噺褰掔撼闂鐨勫熀鏈儴鍒嗭紝娌℃湁蹇呰涓瀹氬紩鐢ㄥ叏閮ㄥ垵濮嬩俊鎭

鍦ㄨ鍦ㄦ墦寮HTML妯″紡鐨勬儏鍐典笅浠庢祻瑙堝櫒寮犺创閭欢淇℃伅銆傚緢澶氱敤鎴蜂笉浣跨敤娴忚鍣ㄦ潵闃呰閭欢銆

1.7.2. IRC锛堝湪绾胯亰澶╃郴缁燂級涓婄殑MySQL绀惧尯鏀寔

闄や簡鍚勭MySQL閭欢鍒楄〃澶栵紝鍦↖RC锛堝湪绾胯亰澶╃郴缁燂級涓婏紝涔熻兘鍙戠幇鏈夌粡楠岀殑绀惧尯鎴愬憳銆備互涓嬫槸鐩墠鎴戜滑宸茬煡鐨勬渶濂界殑缃戠粶锛忔笭閬擄細

         Freenode锛堣鍙傝http://www.freenode.net/浠ユ煡鎵炬湇鍔″櫒淇℃伅锛

o        #mysql锛屼富瑕侀拡瀵筂ySQL闂锛屼篃娆㈣繋鍏朵粬鏁版嵁搴撳拰涓鑸殑SQL闂銆備笌MySQL涓璧蜂娇鐢≒HP銆丳erl鎴朇鏂归潰鐨勯棶棰樹篃寰堝父瑙併

濡傛灉浣犳鍦ㄥ鎵綰RC瀹㈡埛绔蒋浠讹紝浠ヤ究杩炴帴鍒癐RC缃戠粶锛岃璁块棶xChathttp://www.xchat.org/锛夈俋-Chat锛圙PL璁稿彲锛夊嵆鑳界敤浜嶶nix骞冲彴锛屼篃閫傜敤浜嶹indows骞冲彴锛堝厤璐圭殑闈㈠悜Windows鐨刋-Chat鍙粠绔欑偣http://www.silverex.org/download/涓婁笅杞斤級銆

1.7.3. MySQL璁哄潧涓婄殑MySQL绀惧尯鏀寔

鏈鏂扮殑绀惧尯鏀寔璧勬簮鏄綅浜庝笅杩扮珯鐐圭殑璁哄潧锛http://forums.mysql.com

鏈夊悇绉嶅彲鐢ㄨ鍧涳紝鍒嗕负浠ヤ笅澶х被锛

         绉绘

         MySQL鐢ㄦ硶

         MySQL杩炴帴鍣

         缂栫▼璇█

         宸ュ叿

         绗笁鏂瑰簲鐢ㄧ▼搴

         瀛樺偍寮曟搸

         MySQL鎶鏈

         SQL鏍囧噯

         涓氬姟

1.8. MySQL鏍囧噯鐨勫吋瀹规

鍦ㄦ湰鑺備腑锛屼粙缁嶄簡MySQL涓嶢NSI/ISO SQL鏍囧噯鐨勫叧绯汇侻ySQL鏈嶅姟鍣ㄦ湁寰堝瀵筍QL鏍囧噯鐨勬墿灞曚箣澶勶紝杩欓噷浠嬬粛浜嗗畠浠槸浠涔堬紝浠ュ強浣跨敤瀹冧滑鐨勬柟娉曘備綘涔熻兘浜嗚В鍏充簬MySQL鏈嶅姟鍣ㄧ己澶卞姛鑳界殑淇℃伅锛屼互鍙婂浣曞鐞嗘煇浜涘樊寮傜殑鏂规硶銆

SQL鏍囧噯鑷1986骞翠互鏉ヤ笉鏂紨鍖栧彂灞曪紝鏈夋暟绉嶇増鏈傚湪鏈墜鍐屼腑锛屸SQL-92鈥濇寚寰楁槸1992骞村彂甯冪殑鏍囧噯锛屸淪QL:1999鈥濇寚寰楁槸1999骞村彂甯冪殑鏍囧噯锛屸淪QL:2003鈥濇寚寰楁槸鏍囧噯鐨勫綋鍓嶇増鏈鎴戜滑閲囩敤鏈鈥淪QL鏍囧噯鈥濇爣绀篠QL鏍囧噯鐨勫綋鍓嶇増鏈

鎴戜滑鐨勭洰鏍囨槸鍦ㄦ病鏈夎壇濂界悊鐢辩殑鎯呭喌涓嬩笉闄愬埗MySQL鏈嶅姟鍣ㄧ殑鍙敤鎬с傚嵆浣挎垜浠病鏈夎冻澶熺殑璧勬簮灏辨瘡绉嶅彲鑳界殑搴旂敤杩涜寮鍙戯紝鎴戜滑濮嬬粓鎰挎剰甯姪閭d簺鍦ㄦ柊棰嗗煙浣跨敤MySQL鏈嶅姟鍣ㄧ殑浜哄憳锛屽苟鍚戜粬浠彁渚涘缓璁

瀵逛簬璇ヤ骇鍝侊紝鎴戜滑鐨勪竴椤逛富瑕佺洰鏍囨槸锛岀户缁嚧鍔涗簬涓嶴QL鏍囧噯鐨勫吋瀹规э紝浣嗕笉浠ョ壓鐗查熷害鍜屽彲闈犳т负浠d环銆傚鏋滃畠浠兘鏄捐憲澧炲姞鎷ユ湁澶ч噺鐢ㄦ埛鍩烘暟鐨凪ySQL鏈嶅姟鍣ㄧ殑鍙敤鎬э紝鎴戜滑鏃犳儳浜庝负SQL娣诲姞鎵╁睍锛屼篃鏃犳儳浜庝负闈濻QL鐗规ф彁渚涙敮鎸併侻ySQL鏈嶅姟鍣4.0涓殑HANDLER鎺ュ彛鍗虫槸璇ョ瓥鐣ョ殑渚嬪瓙銆璇峰弬瑙13.2.3鑺傦紝鈥淗ANDLER璇硶鈥

鎴戜滑灏嗙户缁敮鎸佷簨鍔℃у拰闈炰簨鍔℃ф暟鎹簱锛屼互婊¤冻浠诲姟鍏抽敭鍨嬪叏澶╁欏簲鐢紝浠ュ強楂樿礋杞絎eb鎴栨棩蹇楀簲鐢ㄣ

MySQL鏈嶅姟鍣ㄦ渶鍒濇槸涓哄皬鍨嬭绠楁満绯荤粺涓婁腑绛夎妯$殑鏁版嵁搴撹璁$殑锛100涓-1浜胯锛屾垨姣忎釜琛ㄧ殑澶у皬涓100MB锛夈傜洰鍓嶏紝MySQL鏈嶅姟鍣ㄨ兘澶勭悊TB绾у埆鐨勬暟鎹簱锛屼篃鑳藉湪閽堝渚挎惡寮忚澶囨垨宓屽叆寮忚澶囩殑绮剧畝鐗堟湰涓娇鐢ㄣ侻ySQL鏈嶅姟鍣ㄧ殑绮剧畝璁捐浣垮緱鍙屽悜寮鍙戞垚涓哄彲鑳斤紝涓嶄細鍦ㄦ簮鐮佹爲涓骇鐢熶换浣曞啿绐併

鐩墠锛屾垜浠苟鏈畾浣嶄簬瀹炴椂鏀寔锛岃櫧璇碝ySQL澶嶅埗鐗规ф彁渚涗簡寮哄ぇ鐨勫姛鑳姐

鍦ㄤ紬澶氱涓夋柟绨囪В鍐虫柟妗堜腑鍧囨湁鏁版嵁搴撶皣鏀寔鐗规э紝鑷4.1.2鐗堜互鏉ワ紝瀵逛簬鎴戜滑鎵闇鐨凬DB绨囨妧鏈泦鎴愭柟妗堬紝鍚屾牱璇峰弬瑙绗17绔狅細MySQL绨

鎴戜滑涔熸鐫鎵嬪湪鏁版嵁搴撴湇鍔″櫒涓彁渚沊ML鏀寔銆

1.8.1. MySQL閬典粠鐨勬爣鍑嗘槸浠涔

鎴戜滑鑷村姏浜庢敮鎸佸叏濂桝NSI/ISO SQL鏍囧噯锛屼絾涓嶄細浠ョ壓鐗蹭唬鐮佺殑閫熷害鍜岃川閲忎负浠d环銆

ODBC绾у埆0-3.51銆

1.8.2. 閫夋嫨SQL妯″紡

MySQL鏈嶅姟鍣ㄨ兘澶熷伐浣滃湪涓嶅悓鐨凷QL妯″紡涓嬶紝骞惰兘閽堝涓嶅悓鐨勫鎴风浠ヤ笉鍚岀殑鏂瑰紡搴旂敤杩欎簺妯″紡銆傝繖鏍凤紝搴旂敤绋嬪簭灏辫兘瀵规湇鍔″櫒鎿嶄綔杩涜閲忚韩瀹氬埗浠ユ弧瓒宠嚜宸辩殑闇姹傘

杩欑被妯″紡瀹氫箟浜哅ySQL搴旀敮鎸佺殑SQL璇硶锛屼互鍙婂簲璇ュ湪鏁版嵁涓婃墽琛屼綍绉嶇‘璁ゆ鏌ャ傝繖鏍凤紝灏辫兘鍦ㄤ紬澶氫笉鍚岀殑鐜涓嬨佷笌鍏朵粬鏁版嵁搴撴湇鍔″櫒涓璧锋洿瀹规槗鍦颁娇鐢∕ySQL銆

鍙互浣跨敤鈥--sql-mode="modes"鈥濋夐」锛岄氳繃鍚姩mysqld鏉ヨ缃粯璁ょ殑SQL妯″紡銆備粠MySQL 4.1寮濮嬶紝涔熻兘鍦ㄥ惎鍔ㄤ箣鍚庯紝浣跨敤ET [SESSION|GLOBAL] sql_mode='modes'璇彞锛閫氳繃璁剧疆sql_mode鍙橀噺鏇存敼妯″紡銆

鍏充簬璁剧疆鏈嶅姟鍣ㄦā寮忕殑鏇村淇℃伅锛岃鍙傝5.3.2鑺傦紝鈥淪QL鏈嶅姟鍣ㄦā寮忊

1.8.3. 鍦ˋNSI妯″紡涓嬭繍琛孧ySQL

浣犲彲浠ヤ娇鐢ㄢ--ansi鈥濆惎鍔ㄩ夐」锛岃姹mysqld浣跨敤ANSI妯″紡銆傝鍙傝5.3.1鑺傦紝鈥mysqld鍛戒护琛岄夐」鈥

鍦ˋNSI妯″紡涓嬭繍琛屾湇鍔″櫒涓庝娇鐢ㄨ閫夐」鍚姩瀹冪殑鏁堟灉涓鏍凤紙鍦ㄤ竴琛屼笂鎸囧畾鈥--sql_mode鈥濆硷級锛

--transaction-isolation=SERIALIZABLE
--sql-mode=REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,
IGNORE_SPACE

鍦∕ySQL 4.1涓紝鑳藉鐢ㄤ笅杩颁袱鏉¤鍙ュ疄鐜扮浉鍚岀殑鏁堟灉锛堝湪涓琛屼笂鎸囧畾鈥sql_mode鈥濆锛夛細

SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SET GLOBAL sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,
IGNORE_SPACE';

璇峰弬瑙1.8.2鑺傦紝鈥滈夋嫨SQL妯″紡鈥

鍦∕ySQL 4.1.1涓紝涔熻兘鐢ㄤ笅杩拌鍙ヨ缃sql_mode閫夐」锛

SET GLOBAL sql_mode='ansi';

鍦ㄦ湰渚嬩腑锛屽皢sql_mode鍙橀噺鐨勫艰缃负涓嶢NSI妯″紡鐩稿叧鐨勬墍鏈夐夐」銆浣犲彲浠ユ鏌ュ叾缁撴灉锛屽涓嬫墍绀猴細

mysql> SET GLOBAL sql_mode='ansi';
mysql> SELECT @@global.sql_mode;
        -> 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,
            IGNORE_SPACE,ANSI';

1.8.4. MySQL瀵规爣鍑哠QL鐨勬墿灞

MySQL鏈嶅姟鍣ㄥ寘鍚竴浜涘叾浠朣QL DBMS涓笉鍏峰鐨勬墿灞曘傛敞鎰忥紝濡傛灉浣跨敤浜嗗畠浠紝灏嗘棤娉曟妸浠g爜绉绘鍒板叾浠朣QL鏈嶅姟鍣ㄣ傚湪鏌愪簺鎯呭喌涓嬶紝浣犲彲浠ョ紪鍐欏寘鍚玀ySQL鎵╁睍鐨勪唬鐮侊紝浣嗕粛淇濇寔鍏跺彲绉绘鎬э紝鏂规硶鏄敤鈥/*... */鈥濇敞閲婃帀杩欎簺鎵╁睍銆傚湪鏈緥涓紝MySQL鏈嶅姟鍣ㄨ兘澶熻В鏋愬苟鎵ц娉ㄩ噴涓殑浠g爜锛屽氨鍍忓寰呭叾浠朚ySQL璇彞涓鏍凤紝浣嗗叾浠朣QL鏈嶅姟鍣ㄥ皢蹇界暐杩欎簺鎵╁睍銆備緥濡傦細

SELECT /*! STRAIGHT_JOIN */ col_name FROM table1,table2 WHERE ...

濡傛灉鍦ㄥ瓧绗︹!鈥濆悗娣诲姞浜嗙増鏈彿锛屼粎褰揗ySQL鐨勭増鏈瓑浜庢垨楂樹簬鎸囧畾鐨勭増鏈彿鏃舵墠浼氭墽琛屾敞閲婁腑鐨勮娉曪細

CREATE /*!32302 TEMPORARY */ TABLE t (a INT);

杩欐剰鍛崇潃锛屽鏋滀綘鐨勭増鏈彿涓3.23.02鎴栨洿楂橈紝MySQL鏈嶅姟鍣ㄥ皢浣跨敤TEMPORARY鍏抽敭瀛椼

涓嬮潰鎸夌被鍒粙缁嶄簡鍚勭MySQL鎵╁睍銆

         纾佺洏涓婄殑鏁版嵁缁勭粐

MySQL鏈嶅姟鍣ㄤ細灏嗘瘡涓暟鎹簱鏄犲皠鍒癕ySQL鏁版嵁鐩綍涓嬬殑1涓洰褰曚腑锛屽苟灏嗘暟鎹簱涓殑琛ㄦ槧灏勫埌鏁版嵁搴撶洰褰曚笅鐨勬枃浠跺悕銆傚畠鍏锋湁涓嬭堪鍚箟锛

o        濡傛灉鎿嶄綔绯荤粺鐨勬枃浠跺悕鍖哄垎澶у皬鍐欙紙濡傚ぇ澶氭暟Unix绯荤粺锛夛紝褰揗ySQL鏈嶅姟鍣ㄨ繍琛屽湪杩欑被鎿嶄綔绯荤粺涓婃椂锛屾暟鎹簱鍚嶅拰琛ㄥ悕涔熷尯鍒嗗ぇ灏忓啓銆傝鍙傝9.2.2鑺傦紝鈥滆瘑鍒澶у皬鍐欐晱鎰熸р

o        浣犲彲浠ヤ娇鐢ㄦ爣鍑嗙殑绯荤粺鍛戒护鏉ュ浠姐侀噸鍛藉悕銆佺Щ鍔ㄣ佸垹闄ゃ佸苟鎷疯礉鐢MyISAMISAM瀛樺偍寮曟搸绠$悊鐨勮〃銆渚嬪锛岃鎯抽噸鍛藉悕MyISAM琛紝鍙噸鍛藉悕琛ㄥ搴旂殑.MYD.MYI銆佷互鍙.frm鏂囦欢銆

鏁版嵁搴撱佽〃銆佺储寮曘佸垪鎴栧埆鍚嶈兘澶熶互鏁板瓧寮澶达紙浣嗘垨璁镐笉鑳藉叏閮ㄧ敱鏁板瓧鏋勬垚锛夈

         閫氱敤璇█璇硶

o        鍙互浣跨敤鈥鈥濇垨鈥鈥濇嫭浣忓瓧绗︿覆锛岃屼笉浠呮槸鈥鈥濄

o        鍦ㄥ瓧绗︿覆涓娇鐢ㄢ\鈥濅綔涓鸿浆涔夊瓧绗︺

o        鍦⊿QL璇彞涓紝鍙互浣跨敤鈥db_name.tbl_name鈥濊娉曡闂笉鍚屾暟鎹簱涓殑琛ㄣ傛煇浜汼QL鏈嶅姟鍣ㄦ彁渚涗簡鐩稿悓鐨勫姛鑳斤紝浣嗚皟鐢ㄨ鐢ㄦ埛绌洪棿闄ゅ銆侻ySQL鏈嶅姟鍣ㄤ笉鏀寔琛ㄧ┖闂达紝濡備笅杩拌鍙ヤ腑浣跨敤鐨勯偅鏍凤細 CREATE TABLE ralph.my_table...IN my_tablespace.

         SQL璇彞鐨勮娉

o        ANALYZE TABLECHECK TABLEOPTIMIZE TABLE锛屼互鍙REPAIR TABLE璇彞銆

o        CREATE DATABASEDROP DATABASE璇彞銆傝鍙傝13.1.3鑺傦紝鈥淐REATE DATABASE璇硶鈥

o        DO璇彞銆

o        EXPLAIN SELECT鑾峰彇濡備綍鑱斿悎琛ㄧ殑浠嬬粛銆

o        FLUSHRESET璇彞銆

o        SET璇彞銆傝鍙傝13.5.3鑺傦紝鈥淪ET璇硶鈥

o        SHOW璇彞銆傝鍙傝13.5.4鑺傦紝鈥淪HOW璇硶鈥

o        浣跨敤LOAD DATA INFILE銆傚湪寰堝鎯呭喌涓嬶紝璇ヨ娉曚笌Oracle鐨LOAD DATA INFILE鍏煎銆傝鍙傝13.2.5鑺傦紝鈥淟OAD DATA INFILE璇硶鈥

o        RENAME TABLE鐨勪娇鐢銆傝鍙傝13.1.9鑺傦紝鈥淩ENAME TABLE璇硶鈥

o        浣跨敤REPLACE鍙栦唬DELETE + INSERT銆傝鍙傝13.2.6鑺傦紝鈥淩EPLACE璇硶鈥

o        ALTER TABLE璇彞涓娇鐢–HANGE col_nameDROP col_name銆佹垨DROP INDEXIGNORERENAME銆傚湪ALTER TABLE璇彞涓娇鐢澶氫釜ADDALTERDROPCHANGE瀛愬彞銆傝鍙傝13.1.2鑺傦紝鈥淎LTER TABLE璇硶鈥

o        浣跨敤绱㈠紩鍚嶏紝瀛楁鍓嶇紑涓婄殑绱㈠紩锛屽苟鍦CREATE TABLE璇彞涓娇鐢↖NDEXKEY銆璇峰弬瑙13.1.5鑺傦紝鈥淐REATE TABLE璇硶鈥

o        CREATE TABLE涓璧蜂娇鐢═EMPORARYIF NOT EXISTS

o        DROP TABLE涓璧蜂娇鐢↖F EXISTS銆

o        浣跨敤鍗曚釜DROP TABLE璇彞锛岃兘澶熻垗寮冨涓〃銆

o        UPDATEDELETE璇彞鐨凮RDER BYLIMIT瀛愬彞銆

o        INSERT INTO ... SET col_name = ... syntax.

o        INSERTREPLACE璇彞鐨凞ELAYED瀛愬彞銆

o        INSERTREPLACEDELETEUPDATE璇彞鐨凩OW_PRIORITY瀛愬彞銆

o        SELECT璇彞涓娇鐢↖NTO OUTFILESTRAIGHT_JOIN銆璇峰弬瑙13.2.7鑺傦紝鈥淪ELECT璇硶鈥

o        SELECT璇彞涓殑SQL_SMALL_RESULT閫夐」銆

o        涓嶉渶瑕佸湪GROUP BY閮ㄥ垎鍛藉悕鎵鏈夐夋嫨鐨勫垪銆瀵逛簬鏌愪簺鍗佸垎鐗规畩浣嗙浉褰撴甯哥殑鏌ヨ锛屽畠鑳芥彁渚涙洿濂界殑鎬ц兘銆傝鍙傝12.10鑺傦紝鈥滀笌GROUP BY瀛愬彞鍚屾椂浣跨敤鐨勫嚱鏁板拰淇敼绋嬪簭

o        鍙互涓GROUP BY涓璧锋寚瀹欰SC鍜孌ESC銆

o        鑳藉鍦ㄥ甫鏈夆:=鈥濊祴鍊兼搷浣滅鐨勮鍙ヤ腑璁剧疆鍙橀噺銆

o                     mysql> SELECT @a:=SUM(total),@b=COUNT(*),@a/@b AS avg
o                         -> FROM test_table;
o                     mysql> SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;

         鍒楃被鍨

o        鍒楃被鍨MEDIUMINTSETENUM銆佷互鍙婁笉鍚岀殑BLOBTEXT绫诲瀷銆

o        鍒楀睘鎬AUTO_INCREMENTBINARYNULLUNSIGNED浠ュ強ZEROFILL

         鍑芥暟鍜屾搷浣滅

o        涓轰簡浣垮叾浠朣QL鐜涓嬬殑鐢ㄦ埛鏇村鏄撳叆鎵嬶紝MySQL鏈嶅姟鍣ㄥ寰堝鍑芥暟鍧囨敮鎸佸埆鍚嶇壒鎬с備緥濡傦紝鎵鏈夌殑瀛楃涓插嚱鏁板潎鏀寔鏍囧噯SQL璇硶鍜孫DBC璇硶銆

o        MySQL鏈嶅姟鍣ㄨ兘澶熺悊瑙b||鈥濆拰鈥&&鈥濇搷浣滅锛屽皢鍏跺綋浣滈昏緫OR鍜孉ND锛屽氨鍍忓湪C缂栫▼璇█涓偅鏍枫傚湪MySQL鏈嶅姟鍣ㄤ腑锛||鍜孫R鏄悓涔夎瘝锛&&鍜孉ND涔熸槸鍚屼箟璇嶃傜敱浜庨噰鐢ㄤ簡璇ヤ紭寮傜殑璇硶浣撶郴锛孧ySQL鏈嶅姟鍣ㄤ笉鏀寔SQL閽堝瀛楃涓茶繛鎺ョ殑鈥||鎿嶄綔绗︼紝鑰岄噰鐢ㄤ簡CONCAT()鍙栬屼唬涔嬨鐢变簬CONCAT()鑳藉鎺ュ彈浠绘剰鏁扮洰鐨勫弬閲忥紝寰堝鏄撳皢浣跨敤鈥||鈥濇搷浣滅鐨勬儏鍐佃浆鎹负MySQL鏈嶅姟鍣ㄦ敮鎸佺殑绫诲瀷銆

o        璇峰湪鏈夊浜1涓厓绱犵殑鍦哄悎涓嬩娇鐢COUNT(DISTINCT list)

o        榛樿鎯呭喌涓嬶紝鎵鏈夌殑瀛楃涓叉瘮杈冨潎鍖哄垎澶у皬鍐欙紝鍏跺垎绫婚『搴忕敱褰撳墠瀛楃闆嗙‘瀹氾紙榛樿涓篶p1252 Latin1锛夈傚鏋滀綘涓嶅枩娆㈣鐐癸紝搴斾娇鐢BINARY灞炴ф垨BINARY cast澹版槑鍒楋紝杩欐牱锛屽氨浼氫娇鐢ㄥ熀鏈殑瀛楃浠g爜鍊艰繘琛屾瘮杈冿紝鑰屼笉鏄瘝姹囬『搴忋

o        %鈥濇搷浣滅绛夊悓浜MOD()銆備篃灏辨槸璇粹N % M绛夊悓浜嶮OD(N,M)銆侰yuyan鐨勭▼搴忓憳鏀寔鈥%鈥濓紝鑰屼笖瀹冧篃鏄负浜嗗吋瀹筆ostgreSQL鑰屼娇鐢ㄧ殑銆

o        鍦ㄥ垪姣旇緝涓紝鍙湪SELECT璇彞鐨凢ROM宸︿晶浣跨敤=<><=<>=><<>><=>ANDORLIKE鎿嶄綔绗銆備緥濡傦細

o                     mysql> SELECT col1=1 AND col2=2 FROM tbl_name;

o        杩斿洖鏈杩AUTO_INCREMENT鍊肩殑LAST_INSERT_ID()鍑芥暟銆傝鍙傝12.9.3鑺傦紝鈥滀俊鎭嚱鏁扳

o        鍏佽鍦ㄦ暟鍊煎垪涓婁娇鐢↙IKE銆

o        REGEXPNOT REGEXP鎵╁睍浜嗗父瑙勭殑琛ㄨ揪寮忔搷浣滅銆

o        鍏锋湁1涓垨2涓互涓婂弬閲忕殑CONCAT()CHAR()銆傦紙鍦∕ySQL鏈嶅姟鍣ㄤ腑锛岃繖浜涘嚱鏁板彲浠ユ湁浠绘剰鏁扮洰鐨勫弬閲忥級銆

o        BIT_COUNT()CASEELT()FROM_DAYS()FORMAT()IF()PASSWORD()ENCRYPT()MD5()ENCODE()DECODE()PERIOD_ADD()PERIOD_DIFF()TO_DAYS()銆佷互鍙WEEKDAY()鍑芥暟銆

o        浣跨敤TRIM()鏉ヨ皟鏁村瓙瀛楃涓层傛爣鍑哠QL浠呮敮鎸佸崟涓瓧绗︾殑鍒犻櫎銆

GROUP BY鍑芥暟STD()BIT_OR()BIT_AND()BIT_XOR()銆浠ュ強GROUP_CONCAT()銆傝鍙傝12.10鑺傦紝鈥滀笌GROUP BY瀛愬彞鍚屾椂浣跨敤鐨勫嚱鏁板拰淇敼绋嬪簭

1.8.5. MySQL涓庢爣鍑哠QL鐨勫樊鍒

鎴戜滑璇曞浘浣縈ySQL鏈嶅姟鍣ㄩ伒浠嶢NSI SQL鏍囧噯鍜孫DBC SQL鏍囧噯锛屼絾鍦ㄦ煇浜涙儏鍐典笅MySQL鏈嶅姟鍣ㄦ墽琛岀殑鎿嶄綔鏈夋墍涓嶅悓锛

         瀵逛簬VARCHAR鍒楋紝瀛樺偍鍊兼椂鍒犻櫎浜嗗熬閮ㄧ┖闂淬傦紙鍦∕ySQL 5.0.3涓洿姝o級銆傝鍙傝A.8鑺傦紝鈥淢ySQL涓殑宸茬煡浜嬪疁鈥

         鍦ㄦ煇浜涙儏鍐典笅锛屽畾涔夎〃鎴栨洿鏀瑰叾缁撴瀯鏃讹紝灏CHAR鍒楄浆鎹负VARCHAR鍒椼锛堝湪MySQL 5.0.3涓洿姝o級銆傝鍙傝13.1.5.1鑺傦紝鈥滄矇瀵傜殑鍒楄鏍煎彉鏇粹

         鍒犻櫎琛ㄦ椂锛屼笉鑷姩鍙栨秷鍏充簬琛ㄧ殑鏉冮檺銆傚繀椤绘槑纭彂鍑REVOKE璇彞锛屼互鎾ら攢閽堝琛ㄧ殑鏉冮檺銆璇峰弬瑙13.5.1.3鑺傦紝鈥淕RANT鍜孯EVOKE璇硶鈥

         CAST()鍑芥暟涓嶆敮鎸佸REALBIGINT鐨勬姏寮銆傝鍙傝12.8鑺傦紝鈥淐ast鍑芥暟鍜屾搷浣滅鈥

         鏍囧噯SQL瑕佹眰锛SELECT璇彞涓殑HAVING瀛愬彞鑳藉寮曠敤GROUP BY瀛愬彞涓殑鍒椼傚湪MySQL 5.0.2涔嬪墠锛屼笉鑳藉畬鎴愯鍔熻兘銆

1.8.5.1.聽瀛愭煡璇

MySQL 4.1鏀寔瀛愭煡璇㈠拰瀵煎嚭琛ㄣ傗滃瓙鏌ヨ鈥濇寚鐨勬槸宓屽鍦ㄥ彟涓璇彞涓殑SELECT璇彞銆傗滃鍑鸿〃鈥濓紙鏈懡鍚嶈鍥撅級鏄彟涓璇彞鐨凢ROM瀛愬彞涓殑瀛愭煡璇€傝鍙傝13.2.8鑺傦紝鈥淪ubquery璇硶鈥

浠嶮ySQL 4.1鐗堣捣锛屽彲浠ヤ娇鐢ㄨ仈鍚堟垨鍏朵粬鏂规硶閲嶅啓澶у鏁板瓙鏌ヨ銆傚叧浜庡浣曞畬鎴愯浠诲姟鐨勬洿澶氫俊鎭紝璇峰弬瑙13.2.8.11鑺傦紝鈥滃浜庤緝鏃╃殑MySQL鐗堟湰锛岄噰鐢ㄨ仈鍚堟柟娉曢噸鍐欏瓙鏌ヨ鈥

1.8.5.2.聽SELECT INTO TABLE

MySQL鏈嶅姟鍣ㄤ笉鏀寔Sybase SQL鎵╁睍锛 SELECT ... INTO TABLE ....銆備絾MySQL鏈嶅姟鍣ㄦ敮鎸佹爣鍑嗙殑SQL璇硶INSERT INTO ... SELECT ...锛屽畠鍩烘湰涓婄浉鍚屻傝鍙傝13.2.4.1鑺傦紝鈥淚NSERT ... SELECT璇硶鈥

INSERT INTO tbl_temp2 (fld_id)
    SELECT tbl_temp1.fld_order_id
    FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;

浣滀负澶囬夋柟寮忥紝鍙互浣跨敤SELECT INTO OUTFILE ...CREATE TABLE ... SELECT銆

浠5.0鐗堝紑濮嬶紝MySQL鏀寔SELECT ... INTO锛屼互鍙婄敤鎴峰彉閲忋傚湪浣跨敤鍏夋爣鍜屽眬閮ㄥ彉閲忕殑瀛樺偍绋嬪簭涓篃鍙互浣跨敤鐩稿悓鐨勮娉曘傝鍙傝20.2.9.3鑺傦紝鈥淪ELECT ... INTO璇彞鈥

1.8.5.3. 浜嬪姟鍜屽師瀛愭搷浣

MySQL鏈嶅姟鍣紙3.23鑷宠绯诲垪鐨勬渶楂樼増鏈紝鎵鏈4.0鐗堟湰锛屼互鍙婃洿楂樼増鏈級鏀寔閲囩敤InnoDB鍜孊DB浜嬪姟瀛樺偍寮曟搸鐨勪簨鍔°侷nnoDB鎻愪緵浜嗗叏闈㈢殑ACID鍏煎鎬с璇峰弬瑙绗15绔狅細瀛樺偍寮曟搸鍜岃〃绫诲瀷

MySQL鏈嶅姟鍣ㄤ腑鐨勫叾浠栭潪浜嬪姟鎬у瓨鍌ㄥ紩鎿庯紙濡MyISAM锛夐伒浠庝笉鍚岀殑鏁版嵁瀹屾暣鎬ц寖渚嬶紝绉颁箣涓衡滃師瀛愭搷浣溾濄傛寜鐓т簨鍔℃湳璇紝MyISAM琛ㄦ昏兘楂樻晥鍦板伐浣滃湪AUTOCOMMIT=1妯″紡涓嬨傚師瀛愭搷浣滈氬父鑳芥彁渚涘彲姣旇緝鐨勫畬鏁存т互鍙婃洿濂界殑鎬ц兘銆

鐢变簬MySQL鏈嶅姟鍣ㄦ敮鎸佷袱绉嶈寖渚嬶紝鍥犺屼綘鑳藉喅瀹氭槸鍚﹀埄鐢ㄥ師瀛愭搷浣滅殑閫熷害鏇村ソ鍦版湇鍔′簬浣犵殑搴旂敤绋嬪簭锛屾垨浣跨敤浜嬪姟鐗规с傝閫夋嫨鍙寜琛ㄨ繘琛屻

姝e鎵闃愯堪鐨勯偅鏍凤紝浜嬪姟鎬у拰闈炰簨鍔℃ц〃绫诲瀷涔嬮棿鐨勬潈琛′富瑕佸彇鍐充簬鎬ц兘銆備簨鍔℃ц〃瀵瑰唴瀛樺拰纾佺洏绌洪棿鐨勮姹傛洿楂橈紝CPU寮閿涔熸洿澶с傚彟涓鏂归潰锛屽绉嶄簨鍔℃ц〃绫诲瀷锛屽InnoDB锛屼篃鑳芥彁渚涘緢澶氭樉钁楃壒鎬сMySQL鏈嶅姟鍣ㄧ殑妯″潡鍖栬璁″厑璁稿悓鏃朵娇鐢ㄤ笉鍚岀殑瀛樺偍寮曟搸锛屼互婊¤冻涓嶅悓鐨勮姹傦紝骞跺湪鎵鏈夋儏褰笅锛屾彁渚涙渶浣虫ц兘銆

浣嗘槸锛屽嵆渚夸娇鐢ㄩ潪浜嬪姟鎬MyISAM琛紝浣犲皢濡備綍浣跨敤MySQL鏈嶅姟鍣ㄧ殑鐗规ф潵淇濇寔涓ユ牸鐨勫畬鏁存у憿锛熻繖浜涚壒鎬т笌浜嬪姟鎬ц〃绫诲瀷鐩告瘮鍙堝浣曞憿锛

1.    濡傛灉搴旂敤绋嬪簭閲囩敤浜嗙壒瀹氱殑缂栧啓鏂瑰紡锛屼緷璧栦簬鍦ㄥ叧閿儏鍐典笅鑳藉璋冪敤ROLLBACK鑰屼笉鏄疌OMMIT锛岄偅涔堜簨鍔℃х被鍨嬫洿鏂逛究銆浣跨敤浜嬪姟锛岃繕鑳界‘淇濇湭瀹屾垚鐨勬洿鏂版垨宕╂簝鐨勬椿鍔ㄤ笉琚彁浜ゅ埌鏁版嵁搴擄紝鑳戒负鏈嶅姟鍣ㄦ彁渚涜嚜鍔ㄥ洖婊氱殑鏈轰細锛屽苟淇濆瓨浣犵殑鏁版嵁搴撱

濡傛灉浣跨敤闈炰簨鍔℃ц〃锛孧ySQL鏈嶅姟鍣ㄥ嚑涔庡湪鎵鏈夋儏鍐典笅鍧囧厑璁镐綘瑙e喅娼滃湪鐨勯棶棰橈紝鏂瑰紡鏄湪鏇存柊鍓嶈繘琛岀畝鍗曟鏌ワ紝骞惰繍琛屾鏌ユ暟鎹簱涓鑷存х殑绠鍗曡剼鏈紝濡傛灉鍑虹幇涓嶄竴鑷存э紝璇ヨ剼鏈兘鑷姩淇瀹冩垨缁欏嚭鍛婅銆傛敞鎰忥紝浠呬娇鐢∕ySQL鏃ュ織鎴栧鍔犻澶栨棩蹇楋紝閫氬父鑳藉畬缇庡湴鏇存琛紝鍚屾椂涓嶄細閫犳垚鏁版嵁瀹屾暣鎬ф崯澶便

2.    鍦ㄥ緢澶氭儏鍐典笅锛岃兘澶熷鍏抽敭鐨勪簨鍔℃洿鏂拌繘琛岄噸鍐欙紝浣夸箣鎴愪负鈥滃師瀛愨濈被鍨嬨備竴鑸岃█锛屾墍鏈夌敱浜嬪姟瑙e喅鐨勫畬鏁存ч棶棰樺潎鑳界敤LOCK TABLES鎴栧師瀛愭洿鏂拌В鍐筹紝浠庤岀‘淇濅簡鏈嶅姟鍣ㄤ笉浼氳嚜鍔ㄤ腑鏂紝鍚庤呮槸浜嬪姟鎬ф暟鎹簱绯荤粺鐨勫父瑙侀棶棰樸

3.    涓轰簡瀹夊叏浣跨敤MySQL鏈嶅姟鍣紝鏃犺鏄惁浣跨敤浜嬪姟鎬ц〃锛屼粎闇鍚敤澶囦唤鍜屼簩杩涘埗鏃ュ織鍔熻兘銆傝繖鏍凤紝浣犲氨鑳借В鍐充娇鐢ㄥ叾浠栦簨鍔℃ф暟鎹簱绯荤粺鏃堕亣鍒扮殑浠讳綍闂銆傛棤璁轰娇鐢ㄧ殑鏁版嵁搴撶郴缁熸槸浠涔堬紝鍚敤澶囦唤鎬绘槸涓ソ涓绘剰銆

浜嬪姟鑼冨瀷鏈夎嚜宸辩殑浼樼偣鍜屼笉瓒充箣澶勩傚緢澶氱敤鎴峰拰搴旂敤绋嬪簭寮鍙戜汉鍛樺枩娆㈣繖绫荤畝鍗曟э紝鍦ㄥ嚭鐜伴棶棰樻椂鎴栧繀瑕佹椂锛岄氳繃浠g爜瑙e喅闂銆備絾鏄紝鍗充娇浣犳槸鍘熷瓙鎿嶄綔鑼冨瀷鐨勬柊鎵嬶紝鎴栨洿鐔熸倝浜嬪姟锛屼篃璇疯冭檻闈炰簨鍔℃ц〃鐨勯熷害鐩婂锛屼笌缁忚繃浼樺寲璋冩暣鐨勬渶蹇殑浜嬪姟鎬ц〃鐩告瘮锛屽畠鐨勯熷害蹇3锝5鍊嶃

鍦ㄥ畬鏁存у叿鏈夋渶楂橀噸瑕佹х殑鎯呭喌涓嬶紝鍗充娇鏄闈炰簨鍔℃ц〃锛孧ySQL涔熻兘鎻愪緵浜嬪姟绾у埆鐨勫彲闈犳у拰瀹夊叏鎬с傚鏋滀娇鐢LOCK TABLES閿佸畾浜嗚〃锛鎵鏈夋洿鏂板潎灏嗚鏆傛椂涓鐩磋嚦瀹屾暣鎬ф鏌ュ畬鎴愩傚鏋滀綘鑾峰緱浜嗗鏌愪竴琛ㄧ殑READ LOCAL閿佸畾锛堜笌鍐欓攣瀹氱浉瀵癸級锛岃琛ㄥ厑璁稿湪琛ㄥ熬鎵ц骞惰鎻掑叆锛屽綋鍏朵粬瀹㈡埛绔墽琛屾彃鍏ユ搷浣滄椂锛屽厑璁告墽琛岃鎿嶄綔銆傛柊鎻掑叆鐨勮褰曚笉浼氳鏈夎閿佸畾灞炴х殑瀹㈡埛绔湅鍒帮紝鐩磋嚦瑙i櫎浜嗚閿佸畾涓烘銆備娇鐢INSERT DELAYED锛岃兘澶熷皢鎻掑叆椤圭疆浜庢湰鍦伴槦鍒椾腑锛岀洿鑷抽攣瀹氳В闄わ紝涓嶄細璁╁鎴风绛夊緟鎻掑叆瀹屾垚銆傝鍙傝13.2.4.2鑺傦紝鈥淚NSERT DELAYED璇硶鈥

浠庢垜浠祴涓庡叾鍚嶇О鐨勬剰涔変笂锛屸滃師瀛愨濈粷闈炰笉鍙濊鐨勩傚畠浠呮剰鍛崇潃锛屼綘鑳界‘淇″湪姣忎釜鐗规ф洿鏂拌繍琛岀殑鍚屾椂锛屽叾浠栫敤鎴蜂笉鑳藉共娑夊畠锛岃屼笖涓嶄細鍑虹幇鑷姩鍥炴粴锛堝鏋滀綘涓嶅皬蹇冿紝瀵逛簬浜嬪姟鎬ц〃锛岃繖绉嶆儏鍐靛彲鑳藉彂鐢燂級銆侻ySQL鏈嶅姟鍣ㄨ繕鑳戒繚璇佷笉瀛樺湪鑴忚銆

涓嬮潰鍒楀嚭浜嗕娇鐢ㄩ潪浜嬪姟鎬ц〃鐨勪竴浜涙妧鏈細

         瀵逛簬闇瑕佷簨鍔$殑寰幆锛岄氬父鑳戒娇鐢LOCK TABLES杩涜缂栫爜锛屼笉闇瑕佸厜鏍囨潵鏇存柊姝e湪澶勭悊鐨勮褰曘

         瑕佹兂閬垮厤浣跨敤ROLLBACK锛屽彲閲囧彇涓嬭堪绛栫暐锛

1.    浣跨敤LOCK TABLES閿佸畾鎵鏈夊笇鏈涜闂殑琛ㄣ

2.    鎵ц鏇存柊鍓嶏紝娴嬭瘯蹇呴』涓虹湡鐨勬潯浠躲

3.    濡傛灉涓鍒囨甯革紝鎵ц鏇存柊銆

4.    浣跨敤UNLOCK TABLES瑙i櫎閿佸畾銆

涓庝娇鐢ㄥ叿鏈夊洖婊氬彲鑳芥х殑浜嬪姟鎬ц〃鐩告瘮锛屽畠閫氬父鍏锋湁鏇村揩鐨勯熷害锛岃櫧鐒跺苟闈炲缁堝姝ゃ傝瑙e喅鏂规鍞竴涓嶈兘澶勭悊鐨勬儏褰㈡槸锛屽湪鏇存柊涓旀潃姝讳簡绾跨▼銆傚湪杩欑鎯呭喌涓嬶紝灏嗛噴鏀炬墍鏈夐攣瀹氾紝浣嗘煇浜涙洿鏂板彲鑳藉皻鏈墽琛屻

         涔熷彲浠ヤ娇鐢ㄥ嚱鏁板湪鍗曚竴鎿嶄綔涓洿鏂拌褰曘傞噰鐢ㄤ笅杩版妧鏈紝鑳借幏寰楁晥鐜囧緢楂樼殑搴旂敤绋嬪簭銆

o        鏍规嵁鍏跺綋鍓嶅兼洿鏀瑰垪銆

o        浠呮洿鏂板嚭鐜板疄闄呭彉鍖栫殑鍒椼

渚嬪锛屽綋鎴戜滑鏇存柊鏌愪簺瀹㈡埛淇℃伅鏃讹紝浠呮洿鏂板凡鏇存敼鐨勫鎴锋暟鎹紝涓庡師濮嬭鐩告瘮锛屼粎娴嬭瘯宸叉洿鏀圭殑鏁版嵁鎴栦緷璧栦簬宸叉洿鏀规暟鎹殑鏁版嵁鏄惁鏈嚭鐜板彉鍖栥傚浜庡凡鏇存敼鏁版嵁鐨勬祴璇曪紝瀹冩槸閫氳繃UPDATE璇彞鐨刉HERE瀛愬彞瀹屾垚鐨勩濡傛灉璁板綍鏈洿鏂帮紝灏嗗悜瀹㈡埛绔彂鍑烘秷鎭細 鈥滀竴浜涗綘鏀瑰彉鐨勬暟鎹凡琚叾浠栫敤鎴锋洿鏀光濄傛帴涓嬫潵锛屾垜浠湪绐楀彛涓粰鍑轰簡鏃ц鍜屾柊琛岋紝浠ヤ究鐢ㄦ埛鍐冲畾浣跨敤鍝釜鐗堟湰銆

杩欑粰鍑轰簡涓庡垪閿佸畾绫讳技鐨勭粨鏋滐紝浣嗘晥鏋滄洿濂斤紝浣跨敤鐩稿浜庡叾褰撳墠鍊肩殑鍊硷紝浠呮洿鏂颁簡鏌愪簺鍒椼傝繖鎰忓懗鐫锛屽吀鍨嬬殑UPDATE璇彞涓庝笅闈㈢粰鍑虹殑绫讳技锛

UPDATE tablename SET pay_back=pay_back+125;
 
UPDATE customer
  SET
    customer_date='current_date',
    address='new address',
    phone='new phone',
    money_owed_to_us=money_owed_to_us-125
  WHERE
    customer_id=id AND address='old address' AND phone='old phone';

瀹冨緢鏈夋晥锛屽嵆浣垮叾浠栧鎴风鏇存敼浜pay_backmoney_owed_to_us鍒椾腑鐨勫硷紝涔熻兘浣跨敤銆

         鍦ㄥ緢澶氭儏鍐典笅锛岀敤鎴峰笇鏈涘皢LOCK TABLES鍜岋紡鎴ROLLBACK鐢ㄤ簬绠$悊鍞竴ID銆傚彲浠ュ湪涓嶄娇鐢ㄩ攣瀹氬姛鑳芥垨鍥炴粴鐨勬儏鍐典笅锛屼娇鐢AUTO_INCREMENT鍒椾互鍙奓AST_INSERT_ID() SQL鍑芥暟鎴mysql_insert_id() C API鍑芥暟锛屾洿鏈夋晥鍦板鐞嗕箣銆傝鍙傝12.9.3鑺傦紝鈥滀俊鎭嚱鏁扳銆傝鍙傝25.2.3.36鑺傦紝鈥渕ysql_insert_id()鈥

鎴戜滑閫氬父鑳戒娇鐢ㄤ唬鐮佹潵澶勭悊琛岀骇閿佸畾鏂归潰鐨勯渶姹傘傚湪鏌愪簺鎯呭喌涓嬶紝瀹為檯涓婁笉闇瑕佸畠锛InnoDB琛ㄦ敮鎸佽绾ч攣瀹氥閫氳繃MyISAM琛紝鑳藉鍦ㄨ〃涓娇鐢ㄦ爣蹇楀垪锛屽苟瀹屾垚绫讳技涓嬮潰鐨勬搷浣滐細

UPDATE tbl_name SET row_flag=1 WHERE id=ID;

濡傛灉鎵惧埌琛岋紝鑰屼笖鍘熷琛屼腑鐨row_flag涓嶆槸1锛屽浜庡彈褰卞搷鐨勮鏁帮紝MySQL杩斿洖1銆

浣犲彲浠ヨ涓篗ySQL灏嗗墠杩版煡璇㈡洿鏀逛负锛

UPDATE tbl_name SET row_flag=1 WHERE id=ID AND row_flag <> 1;

1.8.5.4. 瀛樺偍绋嬪簭鍜岃Е鍙戠▼搴

瀵逛簬MySQL锛屽湪5.0鐗堟湰涓疄鐜颁簡瀛樺偍绋嬪簭銆傝鍙傝绗20绔狅細瀛樺偍绋嬪簭鍜屽嚱鏁

浠5.0.2鐗堝紑濮嬶紝鍦∕ySQL涓疄鐜颁簡鍩烘湰鐨勮Е鍙戝櫒鍔熻兘锛岃鍒掑湪MySQL 5.1涓繘涓姝ュ彂灞曞畠銆傝鍙傝绗21绔狅細瑙﹀彂绋嬪簭

1.8.5.5. 澶栭敭

鍦∕ySQL鏈嶅姟鍣3.23.44鍜屾洿楂樼増鏈腑锛InnoDB瀛樺偍寮曟搸鏀寔瀵瑰閿害鏉熺殑妫鏌ュ姛鑳斤紝杩欎簺绾︽潫鍖呮嫭CASCADEON DELETEON UPDATE銆傝鍙傝15.2.6.4鑺傦紝鈥淔OREIGN KEY绾︽潫鈥

瀵逛簬InnoDB涔嬪鐨勫叾浠栧瓨鍌ㄥ紩鎿庯紝MySQL鏈嶅姟鍣ㄨ兘澶熻В鏋CREATE TABLE璇彞涓殑FOREIGN KEY璇硶锛屼絾涓嶈兘浣跨敤鎴栦繚瀛樺畠銆鏈潵灏嗚繘琛屾墿灞曪紝鑳藉灏嗚繖绫讳俊鎭繚瀛樺埌琛ㄨ鑼冩枃浠朵腑锛屼互渚胯兘琚mysqldump鍜孫DBC妫绱€傜◢鍚庯紝杩樺皢涓MyISAM琛ㄥ疄鐜板閿害鏉熴

澶栭敭澧炲己涓烘暟鎹簱寮鍙戜汉鍛樻彁渚涗簡澶氶」鐩婂锛

         鍋囧畾鍏宠仈璁捐鎭板綋锛屽閿害鏉熶娇寰楃▼搴忓憳鏇撮毦灏嗕笉涓鑷存у紩鍏ユ暟鎹簱銆

         鏁版嵁搴撴湇鍔″櫒鍏锋湁闆嗕腑寮忕害鏉熸鏌ュ姛鑳斤紝鍥犺屾病鏈夊繀瑕佸湪搴旂敤绋嬪簭涓渚ф墽琛岃繖绫绘鏌ャ傝繖鏍凤紝灏辨秷闄や簡涓嶅悓搴旂敤绋嬪簭浣跨敤涓嶅悓鏂瑰紡妫鏌ョ害鏉熺殑鍙兘鎬с

         浣跨敤绾ц仈鏇存柊鍜屽垹闄わ紝绠鍖栦簡搴旂敤绋嬪簭浠g爜銆

         璁捐鎭板綋鐨勫閿湁鍔╀簬浠ユ枃妗f柟寮忚褰曡〃闂寸殑鍏崇郴銆

璇疯浣忥紝杩欎簺濂藉鏄互鏁版嵁搴撴湇鍔″櫒涓烘墽琛屽繀瑕佹鏌ヨ岄渶鐨勯澶栧紑閿涓轰唬浠风殑銆傛湇鍔″櫒棰濆妫鏌ヤ細褰卞搷鎬ц兘锛屽浜庢煇浜涘簲鐢ㄧ▼搴忥紝璇ョ壒鎬т笉鍙楁杩庯紝搴斿敖閲忛伩鍏嶃傦紙鍑轰簬璇ュ師鍥狅紝鍦ㄤ竴浜涗富瑕佺殑鍟嗕笟搴旂敤绋嬪簭涓紝鍦ㄥ簲鐢ㄧ▼搴忕骇鍒笂瀹炴柦浜嗗閿昏緫锛夈

MySQL鍏佽鏁版嵁搴撳紑鍙戜汉鍛橀夋嫨瑕佷娇鐢ㄧ殑鏂规硶銆傚鏋滀綘涓嶉渶瑕佸閿紝骞跺笇鏈涢伩鍏嶄笌寮哄埗寮曠敤瀹屾暣鎬ф湁鍏崇殑寮閿锛屽彲閫夋嫨鍙︿竴绉嶈〃绫诲瀷鍙栬屼唬涔嬶紝濡MyISAM銆锛堜緥濡傦紝MyISAM瀛樺偍寮曟搸涓轰粎鎵цINSERTSELECT鎿嶄綔鐨勫簲鐢ㄧ▼搴忔彁渚涗簡鏋佸揩鐨勬ц兘锛岃繖鏄洜涓烘彃鍏ヨ兘鍜屾绱㈠悓鏃惰繘琛岋級銆璇峰弬瑙7.3.2鑺傦紝鈥滆〃閿佸畾浜嬪疁鈥

濡傛灉浣犱笉鎵撶畻鍒╃敤寮曠敤瀹屾暣鎬ф鏌ュ叿澶囩殑浼樼偣锛岃璁颁綇涓嬭堪瑕佺偣锛

         涓嶅瓨鍦ㄦ湇鍔″櫒绔閿叧鑱旀鏌ユ椂锛屽簲鐢ㄧ▼搴忔湰韬繀椤诲鐞嗚繖绫诲叧鑱斾簨瀹溿備緥濡傦紝灏嗚鎸夋伆褰撻『搴忔彃鍏ヨ〃鏃跺簲璋ㄦ厧锛屽苟搴旈伩鍏嶄骇鐢熷绔嬬殑瀛愯褰曘傚繀椤昏兘澶熷湪澶氳褰曟彃鍏ユ搷浣滄湡闂存洿姝e嚭鐜扮殑閿欒銆

         濡傛灉ON DELETE鏄簲鐢ㄧ▼搴忔墍闇鐨勫敮涓寮曠敤瀹屾暣鎬у姛鑳斤紝璇锋敞鎰忥紝浠嶮ySQL鏈嶅姟鍣4.0璧凤紝鍙互浣跨敤澶氳〃DELETE璇彞锛岀敤鍗曚竴璇彞浠庡涓〃涓垹闄よ銆璇峰弬瑙13.2.1鑺傦紝鈥淒ELETE璇硶鈥

         浠庡叿鏈夊閿殑琛ㄥ垹闄よ褰曟椂锛屽湪缂哄皯ON DELETE鐨勬儏鍐典笅锛屼竴绉嶈В鍐虫柟寮忔槸涓哄簲鐢ㄧ▼搴忓鍔犳伆褰撶殑DELETE璇彞銆瀹為檯涓婏紝瀹冧笌浣跨敤澶栭敭鍚屾牱蹇紝鑰屼笖绉绘鎬ф洿濂姐

娉ㄦ剰锛屼娇鐢ㄥ閿湪鏌愪簺鎯呭喌涓嬩細瀵艰嚧闂銆

         澶栭敭鏀寔鑳藉鐞嗗緢澶氬紩鐢ㄥ畬鏁存т簨瀹滐紝浣嗕粛闇瑕佷粩缁嗚璁¢敭鐨勫叧绯伙紝浠ラ伩鍏嶅惊鐜鍒欐垨涓嶆纭殑绾ц仈鍒犻櫎缁勫悎銆

         DBA闇瑕佸垱寤哄叧鑱旀嫇鎵戯紝杩欎細浣夸粠澶囦唤涓仮澶嶅崟鐙〃鍙樺緱鍥伴毦锛岃绫绘儏褰㈠苟涓嶇綍瑙併傦紙鍔犺浇渚濊禆鍏朵粬琛ㄧ殑琛ㄦ椂锛孧ySQL鍏佽浣犱复鏃剁姝㈠閿鏌ワ紝浠庤岄檷浣庝簡璇ラ毦搴︼級銆傝鍙傝15.2.6.4鑺傦紝鈥淔OREIGN KEY绾︽潫鈥銆傚湪MySQL 4.1.1浠ュ墠銆傞噸鏂板姞杞芥椂锛mysqldump鑳藉鐢熸垚鑷姩鍒╃敤璇ユц兘鐨勮浆鍌ㄦ枃浠躲

娉ㄦ剰锛孲QL涓殑澶栭敭鐢ㄤ簬妫鏌ュ拰寮哄埗寮曠敤瀹屾暣鎬э紝鑰屼笉鏄仈鍚堣〃銆傚鏋滄墦绠楃敤SELECT璇彞鑾峰彇澶氫釜琛ㄧ殑缁撴灉锛屽彲鍦ㄨ〃涔嬮棿鎵ц鑱斿悎鎿嶄綔锛

SELECT * FROM t1, t2 WHERE t1.id = t2.id;

璇峰弬瑙13.2.7.1鑺傦紝鈥淛OIN璇硶鈥銆傝鍙傝3.6.6鑺傦紝鈥滀娇鐢ㄥ閿

ODBC搴旂敤绋嬪簭甯镐娇鐢ㄤ笉甯︹ON DELETE ...鈥濈殑FOREIGN KEY璇硶鏉ョ敓鎴愯嚜鍔WHERE瀛愬彞銆

1.8.5.6. 瑙嗗浘

鍦∕ySQL鏈嶅姟鍣5.0鐗堜腑瀹炵幇浜嗚鍥惧姛鑳斤紙鍖呮嫭鍙洿鏂拌鍥撅級銆傚湪5.0.1鍜屾洿楂樼増鏈腑锛屾彁渚涗簡浜岃繘鍒剁増鐨勮鍥惧姛鑳姐傝鍙傝绗22绔狅細瑙嗗浘

View锛堣鍥撅級鍗佸垎鏈夌敤锛屽畠鍏佽鐢ㄦ埛鍍忓崟涓〃閭f牱璁块棶涓缁勫叧绯伙紙琛級锛岃屼笖浠呭厑璁稿瀹冧滑鐨勮繖绫昏闂傝鍥句篃鑳介檺鍒跺琛岀殑璁块棶锛堢壒瀹氳〃鐨勫瓙闆嗭級銆傚浜庡垪鎺у埗鐨勮闂紝鍙娇鐢∕ySQL鏈嶅姟鍣ㄤ腑鐨勯珮绾ф潈闄愮郴缁熴傝鍙傝5.7鑺傦紝鈥淢ySQL璁块棶鏉冮檺绯荤粺鈥

鍦ㄨ璁¤鍥剧殑杩囩▼涓紝鎴戜滑鐨勫畯浼熺洰鏍囨槸锛屽湪SQL鐨勮寖鍥村唴灏藉彲鑳戒笌鍏宠仈鏁版嵁搴撶郴缁熺殑鈥Codd's Rule #6鈥濆吋瀹广鈥滄墍鏈夌悊璁轰笂鍙洿鏂扮殑瑙嗗浘锛屽疄闄呬笂涔熷簲鏄彲鏇存柊鐨勨濄

1.8.5.7. 鈥--鈥欎綔涓烘敞閲婅捣濮嬫爣璁

涓浜涘叾浠朣QL鏁版嵁搴撻噰鐢ㄢ--鈥濅綔涓烘敞閲婂紑濮嬫爣蹇椼侻ySQL鏈嶅姟鍣ㄩ噰鐢ㄢ#鈥濅綔涓烘敞閲婅捣濮嬪瓧绗︺傚浜嶮ySQL鏈嶅姟鍣紝涔熻兘浣跨敤C椋庢牸鐨勬敞閲婏細/*璇ュ涓烘敞閲*/銆璇峰弬瑙9.5鑺傦紝鈥滄敞閲婅娉曗

MySQL鏈嶅姟鍣3.23.3鍜屾洿楂樼増鏈敮鎸佲--鈥濇敞閲婇鏍硷紝浣嗚姹傛敞閲婂悗闈㈣窡1绌烘牸锛堟垨鎺у埗瀛楃锛屽鏂拌锛夈備箣鎵浠ヨ姹備娇鐢ㄧ┖鏍硷紝鏄负浜嗛槻姝笌鑷姩鐢熸垚SQL鏌ヨ鏈夊叧鐨勯棶棰橈紝瀹冮噰鐢ㄤ簡绫讳技涓嬮潰鐨勪唬鐮侊紝鍏朵腑锛岃嚜鍔ㄤ负鈥!payment!鈥濇彃鍏モpayment鈥濈殑鍊硷細

UPDATE account SET credit=credit-!payment!

鑰冭檻涓涓嬶紝濡傛灉鈥payment鈥濈殑鍊间负璐熸暟濡傗-1鈥濇椂浼氬嚭鐜颁粈涔堟儏鍐碉細

UPDATE account SET credit=credit--1

鍦⊿QL涓credit--1鏄悎娉曠殑琛ㄨ揪寮忥紝浣嗘槸锛屽鏋--1琚В閲婁负娉ㄩ噴寮濮嬶紝閮ㄥ垎琛ㄨ揪寮忓皢琚垗寮冦鍏剁粨鏋滄槸锛岃〃杈惧紡鐨勬剰涔変笌棰勬湡鐨勬剰涔夊畬鍏ㄤ笉鍚屻

UPDATE account SET credit=credit

璇ヨ鍙ヤ笉浼氬鍊间綔浠讳綍鏇存敼锛佽繖琛ㄦ槑锛屽厑璁告敞閲婁互鈥--鈥濆紑濮嬩細浜х敓涓ラ噸鍚庢灉銆

閲囩敤MySQL鏈嶅姟鍣3.23.3鍜屾洿楂樼増鏈腑鐨勮繖绫绘敞閲婃柟娉曪紝鈥credit--1鈥濆疄闄呬笂寰堝畨鍏ㄣ

鍙︿竴涓畨鍏ㄧ壒鎬ф槸锛mysql鍛戒护琛屽鎴风灏嗗垹闄ゆ墍鏈変互鈥--鈥濆紑澶寸殑琛屻

浠呭綋浣跨敤楂樹簬3.23.3鐨凪ySQL鏃讹紝涓嬭堪淇℃伅鎵嶆湁鎰忎箟锛

濡傛灉鏈1涓枃鏈枃浠跺舰寮忕殑SQL绋嬪簭锛岃鏂囦欢鍖呭惈鈥--鈥濇敞閲婏紝搴旀寜涓嬭堪鏂瑰紡浣跨敤replace瀹炵敤宸ュ叿锛屽皢鍏惰浆鎹负浣跨敤鈥#鈥濆瓧绗︾殑娉ㄩ噴锛

shell> replace " --" " #" < text-file-with-funny-comments.sql \
         | mysql db_name

鑰屼笉鏄氬父鐨勶細

shell> mysql db_name < text-file-with-funny-comments.sql

浣犱篃鍙互缂栬緫娉ㄩ噴鏂囦欢锛屽皢鈥--鈥濇敞閲婃洿鏀逛负鈥#鈥濇敞閲婏細

shell> replace " --" " #" -- text-file-with-funny-comments.sql

浣跨敤涓嬭堪鍛戒护灏嗗叾鏀瑰洖鍘伙細

shell> replace " #" " --" -- text-file-with-funny-comments.sql

1.8.6. MySQL澶勭悊绾︽潫鐨勬柟寮

浣跨敤MySQL锛屼綘鍙互浣跨敤鍏佽鍥炴粴鐨勪簨鍔¤〃锛屼互鍙婁笉鍏佽鍥炴粴鐨勯潪浜嬪姟琛ㄣ傚洜姝わ紝鍦∕ySQL涓殑绾︽潫澶勭悊鍔熻兘涓庡叾浠朌BMS涓殑鐣ユ湁涓嶅悓銆傚湪闈炰簨鍔℃ц〃涓彃鍏ユ垨鏇存柊澶ч噺琛屾椂锛屽綋鍑虹幇閿欒浠ヨ嚦浜庝笉鑳藉洖婊氭墍浣滅殑鍙樻洿鏃讹紝蹇呴』澶勭悊璇ユ儏鍐点

鍏跺熀鏈師鐞嗗湪浜庯紝鍦ㄨВ鏋愬皢瑕佹墽琛岀殑璇彞鐨勫悓鏃讹紝MySQL鏈嶅姟鍣ㄤ細灏介噺涓烘娴嬪埌鐨勯棶棰樼敓鎴愰敊璇俊鎭紝骞朵細鍦ㄦ墽琛岃鍙ョ殑鍚屾椂灏介噺鎭㈠鍑虹幇鐨勯敊璇傚湪澶у鏁版儏鍐典笅鎴戜滑鍧囨槸杩欐牱浣滅殑锛屼絾涓嶅寘鎷墍鏈夋儏鍐点

鍑虹幇閿欒鏃讹紝MySQL鍙夋嫨涓斾腑姝㈣鍙ワ紝鎴栧敖鍙兘鎭㈠骞剁户缁墽琛岃鍙ャ傞粯璁ゆ儏鍐典笅锛屾湇鍔″櫒灏嗛噰鍙栧悗涓绉嶈矾绾裤傝繖鎰忓懗鐫锛屾湇鍔″櫒鍙兘浼氬己鍒跺皢闈炴硶鍊煎彉涓烘渶鎺ヨ繎鐨勫悎娉曞硷紙渚嬪锛夈

浠嶮ySQL 5.0.2寮濮嬶紝鎻愪緵浜嗘暟绉峉QL妯″紡锛屼娇鐢ㄥ畠浠紝鑳藉瀵瑰浣曟帴鍙楀彲鑳戒负涓嶈壇鏁版嵁鍊肩殑鏂瑰紡杩涜鏇村ソ鐨勬帶鍒讹紝涔熻兘鍦ㄥ嚭鐜伴敊璇椂锛屽鏄惁缁х画鎵ц璇彞鎴栨斁寮冭鍙ヨ繘琛屾帶鍒躲備娇鐢ㄨ繖浜涢夐」锛岃兘澶熷皢MySQL鏈嶅姟鍣ㄩ厤缃负鏇翠负浼犵粺鐨勯鏍硷紝绫讳技浜庢嫆缁濅笉鎭板綋杈撳叆鐨勫叾浠朌BMS銆傚彲浠ュ湪杩愯鏃惰缃甋QL妯″紡锛岃繖鏍凤紝鍚勫鎴风灏辫兘閫夋嫨涓庡叾闇姹傛渶涓鸿创鍒囩殑琛屼负銆傝鍙傝5.3.2鑺傦紝鈥淪QL鏈嶅姟鍣ㄦā寮忊

鍦ㄤ互涓嬮儴鍒嗭紝浠嬬粛浜嗕娇鐢ㄤ笉鍚岀害鏉熺被鍨嬬殑鎯呭喌銆

1.8.6.1.聽PRIMARY KEY鍜孶NIQUE绱㈠紩绾︽潫

閫氬父鎯呭喌涓嬶紝褰撲綘璇曞浘INSERTUPDATE浼氬鑷翠富閿佸敮涓閿垨澶栭敭鍐茬獊鐨勮鏃讹紝灏嗗嚭鐜伴敊璇濡傛灉浣犳鍦ㄤ娇鐢ㄤ簨鍔℃у瓨鍌ㄥ紩鎿庢椂锛屽InnoDB锛MySQL浼氳嚜鍔ㄥ洖婊氳鍙ャ傚鏋滀綘姝e湪浣跨敤闈炰簨鍔℃у瓨鍌ㄥ紩鎿庯紝MySQL灏嗗湪鍑洪敊鐨勮涓婂仠姝㈡墽琛岃鍙ワ紝鍓╀綑鐨勮涔熶笉鍐嶅鐞嗐

濡傛灉浣犲笇鏈涘拷鐣ヨ繖绫婚敭鍐茬獊锛屽彲浣跨敤MySQL鏀寔鐨勩佺敤浜INSERTUPDATEIGNORE鍏抽敭瀛椼鍦ㄨ繖绉嶆儏鍐典笅锛孧ySQL灏嗗拷鐣ヤ换浣曢敭鍐茬獊锛屽苟缁х画澶勭悊涓嬩竴琛屻傝鍙傝13.2.4鑺傦紝鈥淚NSERT璇硶鈥銆傝鍙傝3.2.10鑺傦紝鈥淯PDATE璇硶鈥

浣跨敤mysql_info() C API鍑芥暟锛岃兘澶熻幏鍙栧叧浜庡疄闄呮彃鍏ユ垨鏇存柊琛屾暟鐨勪俊鎭傝鍙傝25.2.3.34鑺傦紝鈥渕ysql_info()鈥銆傚湪MySQL 4.1鍜屾洿楂樼増鏈腑锛屼篃鑳戒娇鐢SHOW WARNINGS璇彞銆傝鍙傝13.5.4.22鑺傦紝鈥淪HOW WARNINGS璇硶鈥

鐩墠锛屽彧鏈InnoDB琛ㄦ敮鎸佸閿璇峰弬瑙15.2.6.4鑺傦紝鈥淔OREIGN KEY绾︽潫鈥銆傝鍒掑湪MySQL 5.1涓疄鏂藉MyISAM琛ㄧ殑澶栭敭鏀寔銆

1.8.6.2. 瀵规棤鏁堟暟鎹殑绾︽潫

鍦∕ySQL 5.0.2涔嬪墠锛孧ySQL瀵归潪娉曟垨涓嶅綋鍊煎苟涓嶄弗鍘夛紝鑰屼笖涓轰簡鏁版嵁杈撳叆杩樹細寮哄埗灏嗗畠浠彉涓哄悎娉曞笺傚湪MySQL 5.0.2鍜屾洿楂樼増鏈腑锛屼繚鐣欎簡浠ュ墠鐨勯粯璁よ涓猴紝浣嗕綘鍙互涓轰笉鑹奸夋嫨鏇翠紶缁熺殑澶勭悊鏂规硶锛屼粠鑰屼娇寰楁湇鍔″櫒鑳藉鎷掔粷骞舵斁寮冨嚭鐜颁笉鑹肩殑璇彞銆傛湰鑺備粙缁嶄簡MySQL鐨勯粯璁よ涓猴紙瀹藉ぇ琛屼负锛夛紝鏂扮殑涓ユ牸鐨凷QL妯″紡锛屼互鍙婂畠浠殑鍖哄埆銆

濡傛灉浣犳湭浣跨敤涓ユ牸妯″紡锛屼笅杩版儏鍐垫槸鐪熷疄鐨勩傚鏋滃皢鈥滀笉姝g‘鈥濈殑鍊兼彃鍏ュ埌鍒楋紝濡傚皢NULL鍊兼彃鍏ラ潪NULL鍒楋紝鎴栧皢杩囧ぇ鐨勬暟鍊兼彃鍏ユ暟鍊煎垪锛孧ySQL浼氬皢杩欎簺鍒楄缃负鈥滄渶鍙兘鐨勫尖濓紝鑰屼笉鏄敓鎴愰敊璇俊鎭

         濡傛灉璇曞浘灏嗚秴鑼冨洿鐨勫间繚瀛樺埌鏁板煎垪锛孧ySQL鏈嶅姟鍣ㄥ皢淇濆瓨0锛堟渶灏忕殑鍙兘鍊硷級鍙栬屼唬涔嬶紝鎴栨渶澶х殑鍙兘鍊笺

         瀵逛簬瀛楃涓诧紝MySQL鎴栦繚瀛樼┖瀛楃涓诧紝鎴栧皢瀛楃涓插敖鍙兘澶氱殑閮ㄥ垎淇濆瓨鍒板垪涓

         濡傛灉鎵撶畻灏嗕笉鏄互鏁板煎紑澶寸殑瀛楃涓蹭繚瀛樺埌鏁板煎垪锛孧ySQL灏嗕繚瀛0銆

         MySQL鍏佽灏嗙壒瀹氱殑涓嶆纭棩鏈熷间繚瀛樺埌DATE鍜孌ATETIME鍒楋紙濡傗2000-02-31鈥濇垨鈥2000-02-00鈥濓級銆鍏惰鐐瑰湪浜庯紝楠岃瘉鏃ユ湡涓嶆槸SQL鏈嶅姟鍣ㄧ殑浠诲姟銆傚鏋淢ySQL鑳戒繚瀛樻棩鏈熷煎苟鍑嗙‘妫绱㈢浉鍚岀殑鍊硷紝MySQL灏辫兘鎸夌粰瀹氱殑鍊间繚瀛樺畠銆傚鏋滄棩鏈熷畬鍏ㄤ笉姝g‘锛堣秴鍑烘湇鍔″櫒鑳戒繚瀛樼殑鑼冨洿锛夊皢鍦ㄥ垪涓繚瀛樼壒娈婄殑鏃ユ湡鍊尖0000-00-00鈥濆彇鑰屼唬涔嬨

         濡傛灉璇曞浘灏哊ULL鍊间繚瀛樺埌涓嶆帴鍙桸ULL鍊肩殑鍒楋紝瀵逛簬鍗曡INSERT璇彞锛屽皢鍑虹幇閿欒銆傚浜庡琛INSERT璇彞鎴朓NSERT INTO ... SELECT璇彞锛孧ySQL鏈嶅姟鍣ㄤ細淇濆瓨閽堝鍒楁暟鎹被鍨嬬殑闅愬惈榛樿鍊笺涓鑸儏鍐典笅锛屽浜庢暟鍊肩被鍨嬶紝瀹冩槸0锛屽浜庡瓧绗︿覆绫诲瀷锛屽畠鏄┖瀛楃涓('')锛屽浜庢棩鏈熷拰鏃堕棿绫诲瀷鏄渮ero鈥濄傚湪13.1.5鑺傦紝鈥淐REATE TABLE璇硶鈥涓鑺備腑锛岃璁轰簡闅愬惈鐨勯粯璁ゅ笺

         濡傛灉INSERT璇彞鏈负鍒楁寚瀹氬硷紝濡傛灉鍒楀畾涔夊寘鍚槑纭殑DEFAULT瀛愬彞锛MySQL灏嗘彃鍏ラ粯璁ゅ笺傚鏋滃湪瀹氫箟涓病鏈夎繖绫DEFAULT瀛愬彞锛MySQL浼氭彃鍏ュ垪鏁版嵁绫诲瀷鐨勯殣鍚粯璁ゅ笺

閲囩敤鍓嶈堪瑙勫垯鐨勫師鍥犲湪浜庯紝鍦ㄨ鍙ュ紑濮嬫墽琛屽墠锛屾棤娉曟鏌ヨ繖浜涚姸鍐点傚鏋滃湪鏇存柊浜嗘暟琛屽悗閬囧埌杩欑被闂锛屾垜浠笉鑳戒粎闈犲洖婊氳В鍐筹紝杩欐槸鍥犱负瀛樺偍寮曟搸鍙兘涓嶆敮鎸佸洖婊氥備腑姝㈣鍙ュ苟涓嶆槸鑹ソ鐨勯夋嫨锛屽湪璇ユ儏鍐典笅锛屾洿鏂板畬鎴愪簡鈥滀竴鍗娾濓紝杩欐垨璁告槸鏈宸殑鎯呭喌銆傚浜庢湰渚嬶紝杈冨ソ鐨勬柟娉曟槸鈥滀粎鍙兘鍋氬埌鏈濂解濓紝鐒跺悗灏卞儚浠涔堥兘鏈彂鐢熼偅鏍风户缁

鍦∕ySQL 5.0.2鍜屾洿楂樼増鏈腑锛屽彲浠ヤ娇鐢STRICT_TRANS_TABLESSTRICT_ALL_TABLES SQL妯″紡锛岄夋嫨鏇翠弗鏍肩殑澶勭悊鏂瑰紡銆傝鍙傝5.3.2鑺傦紝鈥淪QL鏈嶅姟鍣ㄦā寮忊

STRICT_TRANS_TABLES鐨勫伐浣滄柟寮忥細

         瀵逛簬浜嬪姟鎬у瓨鍌ㄥ紩鎿庯紝鍦ㄨ鍙ヤ腑浠讳綍鍦版柟鍑虹幇鐨勪笉鑹暟鎹煎潎浼氬鑷存斁寮冭鍙ュ苟鎵ц鍥炴粴銆

         瀵逛簬闈炰簨鍔℃у瓨鍌ㄥ紩鎿庯紝濡傛灉閿欒鍑虹幇鍦ㄨ鎻掑叆鎴栨洿鏂扮殑绗1琛岋紝灏嗘斁寮冭鍙ャ傦紙鍦ㄨ繖绉嶆儏鍐典笅锛屽彲浠ヨ涓鸿鍙ユ湭鏀瑰彉琛紝灏卞儚浜嬪姟琛ㄤ竴鏍凤級銆傞琛屽悗鍑虹幇鐨勯敊璇笉浼氬鑷存斁寮冭鍙ャ傚彇鑰屼唬涔嬬殑鏄紝灏嗚皟鏁翠笉鑹暟鎹硷紝骞剁粰鍑哄憡璀︼紝鑰屼笉鏄敊璇傛崲鍙ヨ瘽璁诧紝浣跨敤STRICT_TRANS_TABLES鍚庯紝閿欒鍊间細瀵艰嚧MySQL鎵ц鍥炴粴鎿嶄綔锛屽鏋滃彲浠ワ紝鎵鏈夋洿鏂板埌姝や负姝€

瑕佹兂鎵ц鏇翠弗鏍肩殑妫鏌ワ紝璇峰惎鐢STRICT_ALL_TABLES銆闄や簡闈炰簨鍔℃у瓨鍌ㄥ紩鎿庯紝瀹冧笌STRICT_TRANS_TABLES绛夊悓锛屽嵆浣垮綋涓嶈壇鏁版嵁鍑虹幇鍦ㄩ琛屽悗鐨勫叾浠栬锛屾墍浜х敓鐨勯敊璇篃浼氬鑷存斁寮冭鍙ャ杩欐剰鍛崇潃锛屽鏋滈敊璇嚭鐜板湪闈炰簨鍔℃ц〃澶氳鎻掑叆鎴栨洿鏂拌繃绋嬬殑涓旓紝浠呮洿鏂伴儴鍒嗙粨鏋溿傚墠闈㈢殑琛屽皢瀹屾垚鎻掑叆鎴栨洿鏂帮紝浣嗛敊璇嚭鐜扮偣鍚庨潰鐨勮鍒欎笉鐒躲傚浜庨潪浜嬪姟鎬ц〃锛屼负浜嗛伩鍏嶈繖绉嶆儏鍐电殑鍙戠敓锛屽彲浣跨敤鍗曡璇彞锛屾垨鑰呭湪鑳芥帴鍙楄浆鎹㈣鍛婅屼笉鏄敊璇殑鎯呭喌涓嬩娇鐢STRICT_TRANS_TABLES銆瑕佹兂鍦ㄧ1鍦哄悎闃叉闂鐨勫嚭鐜帮紝涓嶈浣跨敤MySQL鏉ユ鏌ュ垪鐨勫唴瀹广傛渶瀹夊叏鐨勬柟寮忥紙閫氬父涔熻緝蹇級鏄紝璁╁簲鐢ㄧ▼搴忚礋璐o紝浠呭皢鏈夋晥鍊间紶閫掔粰鏁版嵁搴撱

鏈変簡涓ユ牸鐨勬ā寮忛夐」鍚庯紝鍙娇鐢INSERT IGNOREUPDATE IGNORE鑰屼笉鏄笉甯GNORE鐨処NSERTUPDATE锛屽皢閿欒褰撲綔鍛婅瀵瑰緟銆

1.8.6.3.聽ENUM鍜孲ET绾︽潫

ENUMSET鍒楁彁渚涗簡瀹氫箟浠呰兘鍖呭惈缁欏畾鍊奸泦鍚堢殑鍒楃殑鏈夋晥鏂瑰紡銆浣嗘槸锛屼粠MySQL 5.0.2璧凤紝ENUMSET涓嶆槸瀹為檯绾︽潫銆傚叾鍘熷洜涓庝笉閲嶈NOT NULL鐨勫師鍥犱竴鏍枫璇峰弬瑙1.8.6.2鑺傦紝鈥滃鏃犳晥鏁版嵁鐨勭害鏉熲

ENUM鍒楁绘湁1涓粯璁ゅ笺傚鏋滄湭鎸囧畾榛樿鍊硷紝瀵逛簬鍖呭惈NULL鐨勫垪锛岄粯璁ゅ间负NULL锛涘惁鍒欙紝绗1涓灇涓惧煎皢琚綋浣滈粯璁ゅ笺

濡傛灉鍦ENUM鍒椾腑鎻掑叆浜嗕笉姝g‘鐨勫硷紝鎴栬咃紝濡傛灉浣跨敤IGNORE灏嗗煎己鍒舵彃鍏ヤ簡ENUM鍒楋紝浼氬皢鍏惰缃负淇濈暀鐨勬灇涓惧0锛屽浜庡瓧绗︿覆鎯呭舰锛屽皢鏄剧ず涓虹┖瀛楃涓层傝鍙傝11.4.4鑺傦紝鈥淓NUM绫诲瀷鈥

濡傛灉鍦SET鍒椾腑鎻掑叆浜嗕笉姝g‘鍊硷紝璇ュ煎皢琚拷鐣ャ渚嬪锛屽鏋滃垪鑳藉寘鍚尖渁鈥濄佲渂鈥濆拰鈥渃鈥濓紝骞惰祴鍊尖渁,x,b,y鈥濓紝缁撴灉涓衡渁,b鈥濄傝鍙傝11.4.5鑺傦紝鈥淪ET绫诲瀷鈥

浠5.0.2寮濮嬶紝鍙互瀵规湇鍔″櫒杩涜閰嶇疆锛屼互浣跨敤涓ユ牸鐨凷QL妯″紡銆傝鍙傝5.3.2鑺傦紝鈥淪QL鏈嶅姟鍣ㄦā寮忊銆傚惎鐢ㄤ弗鏍兼ā寮忓悗锛ENUMSET鍒楃殑瀹氫箟鍙綔涓哄杈撳叆鑷冲垪鐨勫肩殑绾︽潫銆濡傛灉鍊间笉婊¤冻涓嬭堪鏉′欢锛屽皢鍑虹幇閿欒锛

         ENUM鍊煎繀椤绘槸鍦ㄥ垪瀹氫箟涓粰鍑虹殑鍊间箣涓锛屾垨鍐呴儴鐨勬暟瀛楃瓑鍚岀墿銆璇ュ间笉鑳芥槸閿欒鍊硷紙鍗筹紝0鎴栫┖瀛楃涓诧級銆傚浜庡畾涔変负ENUM('a','b','c')鐨勫垪锛岃濡'''d''ax'绛夛紝鍧囨槸闈炴硶鐨勶紝骞跺皢琚嫆銆

         SET鍊煎繀椤绘槸绌哄瓧绗︿覆锛屾垨鐢1涓垨澶氫釜鍦ㄥ垪瀹氫箟涓粰鍑虹殑涓旂敤閫楀彿闅斿紑鐨勫肩粍鎴愩 瀵逛簬瀹氫箟涓SET('a','b','c')鐨勫垪锛岃濡'd''a,b,c,d'绛夛紝鍧囨槸闈炴硶鐨勶紝骞跺皢琚嫆銆

濡傛灉浣跨敤浜INSERT IGNOREUPDATE IGNORE锛屽湪涓ユ牸妯″紡涓嬶紝鍙姂鍒舵棤鏁堝煎鑷寸殑閿欒銆鍦ㄨ繖绉嶆儏鍐典笅锛屽皢鐢熸垚璀﹀憡鑰屼笉鏄敊璇傚浜嶦NUM锛屽煎皢浣滀负閿欒鎴愬憳(0)鎻掑叆銆傚浜SET锛屼細灏嗙粰瀹氬兼彃鍏ワ紝浣嗘棤鏁堢殑瀛愬瓧绗︿覆灏嗚鍒犻櫎銆渚嬪锛'a,x,b,y'鐨勭粨鏋滄槸'a,b'锛屽氨鍍忓墠闈粙缁嶇殑閭f牱銆


杩欐槸MySQL鍙傝冩墜鍐岀殑缈昏瘧鐗堟湰锛屽叧浜嶮ySQL鍙傝冩墜鍐岋紝璇疯闂dev.mysql.com銆 鍘熷鍙傝冩墜鍐屼负鑻辨枃鐗堬紝涓庤嫳鏂囩増鍙傝冩墜鍐岀浉姣旓紝鏈炕璇戠増鍙兘涓嶆槸鏈鏂扮殑銆