鏁版嵁搴撴蹇碉細鏂囦欢浣滀负鏁版嵁搴擄紝鏁版嵁鏍煎紡鍗冨樊涓囧埆
灏嗕繚瀛樻暟鎹殑鍦版柟缁熶竴璧锋潵
MySQL锛氱敤浜庣鐞嗘枃浠剁殑涓�涓蒋浠讹紙涓や釜绋嬪簭锛壜� 涓�娆惧簲鐢ㄨ蒋浠讹紝鐢ㄦ潵甯綘鎿嶄綔鏂囦欢鐨�
鍙鏄熀浜庣綉缁滈�氫俊锛屽簳灞傞兘鏄痵ocket
聽 聽 鏈嶅姟绔細
-socket鏈嶅姟绔�氫俊
-鏀跺彂娑堟伅锛堟湰鍦版枃浠舵搷浣滐級
-瑙f瀽鍛戒护锛坰ql璇彞锛�
瀹㈡埛绔細聽 锛堝鎴风鍙互鏈夊緢澶氫釜锛宲ython,java,php,c++閮藉彲浠ョ紪绋嬩竴涓鎴风锛岀敤浠g爜鎸囧畾ip port杩炴帴涓婃湇鍔$鍗冲彲鎿嶄綔锛�
-socket瀹㈡埛绔�氫俊
-鏀跺彂娑堟伅锛堝彂閫佹寚浠わ級
-瑙f瀽鍛戒护锛坰ql璇彞锛�
DBA:鏁版嵁搴撶鐞嗗憳
sql璇彞浼樺寲聽 锛堜笉鍚岀殑瀹㈡埛绔繛鍚屼竴涓湇鍔″櫒锛岃瑷�涓嶅悓鏃犳硶瀹炵幇浜ゆ祦锛屾墍浠ュ簲璇ユ湁鍏卞悓鐨勮瑷� 銆嬨�嬭В鏋愭寚浠ql璇彞锛�
RDBMS:鏁版嵁搴撶鐞嗙郴缁�
mysql鍙槸涓�绉嶈兘澶熷府鍔╂垜浠鐞嗘暟鎹殑杞欢锛岃繕鏈夊叾浠栫被浼肩殑杞欢涔熸槸閫氳繃鍙戦�佹寚浠ゆ潵甯綘绠$悊鏁版嵁搴撱��
鍏崇郴鍨嬫暟鎹簱锛氬瓨鍌ㄦ暟鎹殑鏃跺�欙紝瀵逛簬鏁版嵁鏈夋潯浠堕檺鍒�
鏁版嵁涓庢暟鎹箣闂存湁鍏宠仈
閫氬父閮芥槸浠ヨ〃鏍肩殑鏂瑰紡瀛樺偍
1銆佺涓�姝ラ渶瑕佸垱寤鸿〃缁撴瀯
oracle /sqlite /db2 /sql server /MySQL /access
闈炲叧绯诲瀷鏁版嵁搴擄細鏁版嵁瀛樺偍鏂瑰紡鏄痥锛寁閿�煎鐨勫舰寮�
redis/mongodb/memcache
鎬荤粨锛歮ysql灏辨槸甯姪鎴戜滑杩滅▼鍦ㄦ枃浠朵笂鍋氱浉搴旀搷浣滅殑
鏂囦欢澶癸紙搴擄級
鏂囦欢锛堣〃锛�>>>琛ㄥご锛氬瓧娈�
鏁版嵁/璁板綍锛堣〃鏁版嵁锛�
MySQL
瀹夎聽 鏈嶅姟绔拰瀹㈡埛绔�
瀹㈡埛绔繛鎺ユ湇鍔″櫒
鍩烘湰鎿嶄綔聽 瀛︿範sql璇彞瑙勫垯锛屾寚瀹氭湇鍔$鍋氫换浣曟搷浣�
cmd = input(MySQL>>>:)
1銆佸皢mysql 鍚姩鏂囦欢璺緞娣诲姞鍒扮幆澧冨彉閲�
2銆佸皢mysqld锛堟湇鍔$锛夊埗浣滄垚绯荤粺鏈嶅姟(寮�鏈鸿嚜鍚姩)锛堝埗浣滀箣鍓嶄竴瀹氳鍏堟妸mysql鍏抽棴锛�
mysqld --install
3銆佽缃�(淇敼)瀵嗙爜
聽 聽 绗竴娆′慨鏀瑰瘑鐮侊紝娌℃湁鍘熷瘑鐮侊紝鐩存帴杈撳叆鏂板瘑鐮侊細mysqladmin -uroot -p password 123
聽 聽 绗竴娆′慨鏀瑰畬瀵嗙爜浠ュ悗锛屼箣鍚庡啀淇敼瀵嗙爜闇�瑕佽緭鍏ワ細mysqladmin -uroot -p123 password 123456
4銆佺牬瑙e瘑鐮�(蹇樿瀵嗙爜鐨勬椂鍊欎娇鐢�)
聽 聽 锛�1锛夊厛鍏抽棴鏈嶅姟鍣�
聽 聽 锛�2锛変互璺宠繃鐢ㄦ埛瀵嗙爜璁よ瘉妯″紡(璺宠繃鎺堟潈琛�)閲嶅惎mysqld鏈嶅姟鍣細mysqld --skip-grant-tables
聽 聽 聽 (3)瀹㈡埛绔洿鎺ヤ互鏃犲瘑鐮佺殑鏂瑰紡鐧诲綍root鐢ㄦ埛淇敼瀵嗙爜锛歮ysql -uroot -p
聽 聽 锛�4锛変慨鏀圭鐞嗗憳瀵嗙爜锛屼慨鏀筸ysql搴撻噷闈㈢殑user琛紙灏介噺浠ュ瘑鏂囪缃瘑鐮侊紝璋冪敤聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 password=password(瀵嗙爜)锛墂here鍚庨潰鏄姞闄愬埗
update mysql.user set password=password(88404620) where user='root' and host='localhost';
聽 聽 聽 聽 鍒锋柊鏉冮檺锛歠lush privileges;
聽 聽 锛�5锛夊厛鍏抽棴璺宠繃楠岃瘉鐨勬湇鍔″櫒锛屼互姝e父妯″紡鍚姩鏈嶅姟绔�
鍛戒护琛屾潃姝籱ysqld鏈嶅姟锛毬� 聽 锛坅锛変竴瀹氳鍏堝皢mysqld鏉�姝伙細
銆恗ac绯荤粺涓嬨�戯細ps aux | grep msqld/node銆愬彲浠ユ槸浠讳綍鎯崇湅鐨勮繘绋�(鏍规嵁杩涚▼鍚�)銆�
sudo lsof -i :3306銆愭煡鐪嬫寚瀹氱鍙g殑杩涚▼銆�
銆恗ac绯荤粺涓嬨�戯細kill -9
銆恮in绯荤粺涓嬨�戯細tasklist |finstr mysqld 銆愭壘鍒拌繘绋嬪彿锛堟煡鐪媘ysqld杩涚▼锛夈��
銆恮in绯荤粺涓嬨�戯細tasklist /F /PID 'PID鍙�' 銆愮粓姝紝鏉�姝籱ysqld杩涚▼銆�
锛坆锛夋煡鐪嬭绠楁満褰撳墠杩愯绋嬪簭鏁帮細
銆恗ac绯荤粺涓嬨�戯細launchctl list 銆愭煡鐪嬫墍鏈夎繘绋嬫湇鍔★紝涓�鑸彲鏌ョ湅PID銆�
銆恮in绯荤粺涓嬨�戯細services.msc
聽 聽 锛�6锛夋湇鍔$鐞嗘甯稿惎鍔╩ysqld,杈撳叆鐢ㄦ埛瀵嗙爜姝e父鐧诲綍
****
瑙e喅缂栫爜闂
mysql鍛戒护(鏌ョ湅缂栫爜)锛歕s 鎴栬�卻how variables like "%char%";
聽 聽 聽 聽 聽 聽 鍙戠幇鎴戜滑鍒涘缓鐨勬暟鎹簱銆佹暟鎹〃缂栫爜鏋滅劧鏄痩atin锛歴how create database mysql;
show create table user;
聽 聽 聽 聽 缁熶竴瀛楃缂栫爜锛�
銆恗ac绯荤粺涓嬨�戯細
锛�1锛塵ysql/support-files涓嬮潰鏈塵y-default.cnf锛�
鎷疯礉mysql瀹夎鐩綍涓媠upport-files涓嬮潰鐨刴y-default.cnf鏂囦欢鍒�/etc鐩綍涓嬶紱
淇敼锛�
鎼滅储鎵惧埌锛歔client] 鐨刣efault-character-set=utf-8
[mysqld] default-character-set=utf-8
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 缁熺粺淇敼涓簎tf-8鍗冲彲锛�
(2)support-files涓嬮潰鏄病鏈塵y-default.cnf:
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 杩涘叆/etc鏂囦欢澶逛腑锛堟敞鎰忥細/etc鏄殣钘忔枃浠讹級锛�
鍒涘缓my.cnf鏂囦欢
娉ㄦ剰锔忥細淇敼鍚庨噸鍚湇鍔″櫒鎵嶄細鐢熸晥
my.cnf鍐呭锛�
****
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
default-character-set=utf8
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
character-set-server=utf8
init_connect='SET NAMES utf8
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
character-set-server=utf8
init_connect='SET NAMES utf8'
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# binary logging format - mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,
# MASTER_USER=, MASTER_PASSWORD= ;
#
# where you replace , ,聽 by quoted strings and
#聽 by the master's port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave - required
#master-host =
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user =
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port =
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/mysql/data
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/data
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
default-character-set=utf8
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
---------------------------------------------------------------------------------------------------------
杩樻湁涓�绉嶆柟寮忔槸鍦ㄧ粓绔彃鍏ワ細
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 杩涘叆cd /ect
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 缂栬緫sudo vim my.cnf
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 绮樿创涓婇潰my.cnf鍐呭锛宔sc ==> :wq! 锔忔湁鍐掑彿
娉ㄦ剰锛岃繖閲屼竴瀹氳sudo锛屽洜涓篹tc鏄噸瑕佺洰褰曪紝鍒涘缓鐨勬枃浠朵笉鐢╯udo璇曟病娉曚繚瀛樼殑锛�
銆恮indows绯荤粺涓嬨�戯細
mysql鍛戒护:\s聽 鏌ョ湅缂栫爜
淇敼閰嶇疆鏂囦欢,鎵ц鏃朵細鑷姩鏌ユ壘my.ini鏂囦欢
mysql涓嶈緭鐢ㄦ埛鍚嶅拰瀵嗙爜锛屼細榛樿浠ユ父瀹㈡ā寮忕櫥闄嗭紝涓嶅ソ锛�
# my.ini閰嶇疆鏂囦欢鐗圭偣
[mysql]
聽 聽 聽 聽 聽 聽 # 缁堢杈撳叆mysql鎵撳ご鐨勫懡浠ゅ氨浼氬姞杞戒笅闈㈢殑閰嶇疆
username='root'聽 # 婕旂ず纭疄鍔犺浇璇ユ枃浠讹紝浣嗘槸username鍙玼ser鎵嶆纭�
password = '123'
[mysqld]
聽 聽 聽 聽 聽 聽 閫氱敤閰嶇疆锛�
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
聽 聽 锔忛噸鏂板惎鍔╩ysql鏈嶅姟绔紝閰嶇疆鎵嶄細鐢熸晥
----------------------------------------------------------------
鍚姩
鏈嶅姟绔紙鏈�濂界敤绠$悊鍛樼櫥褰曪級
mysqld
聽 聽 瀹㈡埛绔紙瑕佹柊寮�涓�涓獥鍙o級
mysql -h 127.0.0.1 -P 3306 -uroot -p
聽 聽 聽 聽 涔熸敮鎸佺畝鍐欙紙鍦ㄦ湰鏈虹櫥褰昺ysql鏈嶅姟绔級锛歮ysql -uroot -p
聽 聽 聽 聽 鍥炶溅鍚庤緭鍏ュ瘑鐮侊紝涓嶇敤绠$洿鎺ユ暡鍥炶溅
sql璇彞绗竴鏉″懡浠わ細
娉ㄦ剰锔忥細杈撳叆sql璇彞鐨勬椂鍊欙紝涓�瀹氳鐢ㄨ嫳鏂囧垎鍙风粨鏉�
鏌ョ湅鎵�鏈夋暟鎹簱锛堣癄閲婃枃浠跺す鍜屽簱姒傚康锛夛細show databases;
聽 聽 聽 聽 濡傛灉杈撳叆鐨剆ql璇彞鍑洪敊锛屼笉鎯虫墽琛岀殑璇濆彲浠ュ湪鍚庨潰璺熶笂\c鍙栨秷璇ュ懡浠ょ殑鎵ц
閫�鍑哄鎴风锛歟xit,quit
----------------------------------------------------------------
鍩烘湰sql璇彞鎿嶄綔鈥斺�斿鏁版嵁鐨勫鍒犳敼鏌�
锔弒ql涔﹀啓閿欒锛屽彧瑕佹病鍔犲垎鍙凤紝鍙互鍔燶c浣垮墠闈㈢殑sql璇彞澶辨晥
閽堝鏂囦欢澶圭殑銆愬簱銆�
澧�:create databases db1 charset utf-8;
聽 聽 聽 聽 鏌�:show create database db1;(鏌ュ垱寤虹殑鎸囧畾鏁版嵁搴�)
聽 聽 聽 聽 聽 show databases;(鏌ョ湅鎵�鏈夋暟鎹簱)
聽 聽 聽 聽 鏀�:alter database db1 charset gbk;
聽 聽 聽 聽 鍒�:drop database db1;
聽 聽 閽堝鏂囦欢鐨勩�愯〃銆�
鏂囦欢棣栧厛闇�瑕佸湪鏂囦欢澶逛笅闈紝鎵�浠ュ湪鎿嶄綔鏂囦欢涔嬪墠锛屽簲璇ュ厛纭畾鎿嶄綔鐨勬槸鍝釜鏂囦欢澶逛笅闈㈢殑鏂囦欢
锛�1锛夊垏鎹㈠埌鎸囧畾鐨勫簱鍐�
use 搴撳悕;
聽 聽 聽 聽 聽 聽 select database();聽 # 鏌ョ湅褰撳墠鎵�鍦ㄧ殑搴�
锛�2锛夋搷浣�
澧�:create table userinfo(id int,name char);聽 # 蹇呴』鎸囧畾绫诲瀷char(16)鏈�濂借瀹氬ソ闀垮害锛屼笉鐒堕粯璁ゆ槸1
聽 聽 聽 聽 聽 聽 澶氫釜鏂囦欢锛岃В鑰︾鐞�
鏌�:show tables;
show create table userinfo;
聽 聽 聽 聽 聽 聽 聽 desc userinfo聽 鐩稿綋浜巇escribe userinfo;
聽 聽 聽 聽 聽 聽 鏀�:alter table userinfo modify name char(16);
聽 聽 聽 聽 聽 聽 聽 聽 鎻愰啋锛氬湪鍒涘缓char绫诲瀷瀛楁鐨勬椂鍊欙紝寤鸿鍔犱笂鏁板瓧char(16)
聽 聽 聽 聽 聽 聽 聽 聽 鏇存敼stu琛ㄤ腑sex瀛楁鍚嶄负char(5)鐨刧ender鏂板瓧娈�: alter table stu change gender sex char(5);
聽 聽 聽 聽 聽 聽 鍒狅細drop table userinfo;
聽 聽 閽堝鏁版嵁鐨勩�愯褰曘��
澧烇細insert into db1.t1 values(1,'egon'),(2,'kevin'),(3,'jason');聽 # into鍙姞鍙笉鍔狅紝db1鍙互涓嶆寚瀹氾紝榛樿灏辨槸鍦ㄥ綋鍓嶅簱涓�
鏌�:select id,name from db1.t1;聽 # db1鍙笉鎸囧畾锛岄粯璁ゅ綋鍓嶅簱涓�
select * from t1;
聽 聽 聽 聽 鏀癸細update db1.t1 set name='wpp' where id>1;
聽 聽 聽 聽 聽 聽 update db1.t1 set name='wpr' where id =2 or id =3;聽 # 鍒ゆ柇鏉′欢澶氭椂锛屾渶濂藉姞涓婃嫭鍙�
鍒�:delete from db1.t1 where id=3;
聽 聽 聽 聽 聽 delete from t1 where name='wpp';聽 # 杩欓噷娉ㄦ剰濡傛灉灏戜簡涓�涓紩鍙凤紝鍚庨潰鏃犺鏁蹭粈涔堥兘娌℃湁鐢ㄤ簡锛岄渶瑕佸皢寮曞彿琛ュ叏
琛ㄦ搷浣�
----------------------------------------------------------------
瀛樺偍寮曟搸
瀛樺偍寮曟搸鐨勪綔鐢ㄥ氨鏄瀹氫簡鏁版嵁瀛樺偍鏃剁殑瀛樺偍缁撴瀯锛岀敱瀹為檯涓氬姟鍐冲畾銆�
鏂囦欢鏍煎紡鏈夊緢澶氱锛屽搴旂殑杞欢涔熸湁寰堝绉峵xt,pdf绛�
閽堝涓嶅悓绫诲瀷鐨勬枃浠讹紝闇�瑕佸搴旀湁涓嶅悓鐨勮蒋浠跺府鍔╂垜浠幓鎿嶄綔
鏌ョ湅鎵�鏈夌殑瀛樺偍寮曟搸锛歴how engines;
聽 聽 mysql瀛樺偍寮曟搸浠嬬粛锛�
#InnoDB 瀛樺偍寮曟搸
鏀寔浜嬪姟,鍏惰璁$洰鏍囦富瑕侀潰鍚戣仈鏈轰簨鍔″鐞�(OLTP)鐨勫簲鐢ㄣ�傚叾
鐗圭偣鏄閿佽璁°�佹敮鎸佸閿�,骞舵敮鎸佺被浼糘racle 鐨勯潪閿佸畾璇�,鍗抽粯璁よ鍙栨搷浣滀笉浼氫骇鐢熼攣銆� 浠嶮ySQL 5.5.8 鐗堟湰寮�濮嬫槸榛樿鐨勫瓨鍌ㄥ紩鎿庛��
InnoDB 瀛樺偍寮曟搸灏嗘暟鎹斁鍦ㄤ竴涓�昏緫鐨勮〃绌洪棿涓�,杩欎釜琛ㄧ┖闂村氨鍍忛粦鐩掍竴鏍风敱InnoDB 瀛樺偍寮曟搸鑷韩鏉ョ鐞嗐�備粠MySQL 4.1(鍖呮嫭4.1)鐗堟湰寮�濮�,鍙互灏嗘瘡涓狪nnoDB 瀛樺偍寮曟搸鐨� 琛ㄥ崟鐙瓨鏀惧埌涓�涓嫭绔嬬殑ibd 鏂囦欢涓�傛澶�,InnoDB 瀛樺偍寮曟搸鏀寔灏嗚8璁惧(row disk)鐢� 浜庡缓绔嬪叾琛ㄧ┖闂淬��
InnoDB 閫氳繃浣跨敤澶氱増鏈苟鍙戞帶鍒�(MVCC)鏉ヨ幏寰楅珮骞跺彂鎬�,骞朵笖瀹炵幇浜哠QL 鏍囧噯 鐨�4 绉嶉殧绂荤骇鍒�,榛樿涓篟EPEATABLE 绾у埆,鍚屾椂浣跨敤涓�绉嶇О涓簄etx-key locking 鐨勭瓥鐣ユ潵 閬垮厤骞昏(phantom)鐜拌薄鐨勪骇鐢熴�傞櫎姝や箣澶�,InnoDB 瀛樺偍寮曟搸杩樻彁渚涗簡鎻掑叆缂撳啿(insert buffer)銆佷簩娆″啓(double write)銆佽嚜閫傚簲鍝堝笇绱㈠紩(adaptive hash index)銆侀璇�(read ahead) 绛夐珮鎬ц兘鍜岄珮鍙敤鐨勫姛鑳姐��
瀵逛簬琛ㄤ腑鏁版嵁鐨勫瓨鍌�,InnoDB 瀛樺偍寮曟搸閲囩敤浜嗚仛闆�(clustered)鐨勬柟寮�,姣忓紶琛ㄩ兘鏄寜 涓婚敭鐨勯『搴忚繘琛屽瓨鍌ㄧ殑,濡傛灉娌℃湁鏄惧紡鍦板湪琛ㄥ畾涔夋椂鎸囧畾涓婚敭,InnoDB 瀛樺偍寮曟搸浼氫负姣忎竴 琛岀敓鎴愪竴涓�6 瀛楄妭鐨凴OWID,骞朵互姝や綔涓轰富閿��
InnoDB 瀛樺偍寮曟搸鏄疢ySQL 鏁版嵁搴撴渶涓哄父鐢ㄧ殑涓�绉嶅紩鎿�,Facebook銆丟oogle銆乊ahoo 绛� 鍏徃鐨勬垚鍔熷簲鐢ㄥ凡缁忚瘉鏄庝簡InnoDB 瀛樺偍寮曟搸鍏峰楂樺彲鐢ㄦ�с�侀珮鎬ц兘浠ュ強楂樺彲鎵╁睍鎬с�傚鍏� 搴曞眰瀹炵幇鐨勬帉鎻″拰鐞嗚В涔熼渶瑕佹椂闂村拰鎶�鏈殑绉疮銆傚鏋滄兂娣卞叆浜嗚ВInnoDB 瀛樺偍寮曟搸鐨勫伐浣� 鍘熺悊銆佸疄鐜板拰搴旂敤,鍙互鍙傝�冦�奙ySQL 鎶�鏈唴骞�:InnoDB 瀛樺偍寮曟搸銆嬩竴涔︺��
#MyISAM 瀛樺偍寮曟搸
涓嶆敮鎸佷簨鍔°�佽〃閿佽璁°�佹敮鎸佸叏鏂囩储寮�,涓昏闈㈠悜涓�浜汷LAP 鏁� 鎹簱搴旂敤,鍦∕ySQL 5.5.8 鐗堟湰涔嬪墠鏄粯璁ょ殑瀛樺偍寮曟搸(闄indows 鐗堟湰澶�)銆傛暟鎹簱绯荤粺 涓庢枃浠剁郴缁熶竴涓緢澶х殑涓嶅悓鍦ㄤ簬瀵逛簨鍔$殑鏀寔,MyISAM 瀛樺偍寮曟搸鏄笉鏀寔浜嬪姟鐨勩�傜┒鍏舵牴 鏈�,杩欎篃骞朵笉闅剧悊瑙c�傜敤鎴峰湪鎵�鏈夌殑搴旂敤涓槸鍚﹂兘闇�瑕佷簨鍔″憿?鍦ㄦ暟鎹粨搴撲腑,濡傛灉娌℃湁ETL 杩欎簺鎿嶄綔,鍙槸绠�鍗曞湴閫氳繃鎶ヨ〃鏌ヨ杩橀渶瑕佷簨鍔$殑鏀寔鍚�?姝ゅ,MyISAM 瀛樺偍寮曟搸鐨� 鍙︿竴涓笌浼椾笉鍚岀殑鍦版柟鏄�,瀹冪殑缂撳啿姹犲彧缂撳瓨(cache)绱㈠紩鏂囦欢,鑰屼笉缂撳瓨鏁版嵁鏂囦欢,杩欎笌 澶у鏁扮殑鏁版嵁搴撻兘涓嶇浉鍚屻��
#NDB 瀛樺偍寮曟搸
骞�,MySQL AB 鍏徃浠嶴ony Ericsson 鍏徃鏀惰喘浜哊DB 瀛樺偍寮曟搸銆侼DB 瀛樺偍寮曟搸鏄竴涓泦缇ゅ瓨鍌ㄥ紩鎿�,绫讳技浜嶰racle 鐨凴AC 闆嗙兢,涓嶈繃涓嶰racle RAC 鐨剆hare everything 缁撴瀯涓嶅悓鐨勬槸,鍏剁粨鏋勬槸share nothing 鐨勯泦缇ゆ灦鏋�,鍥犳鑳芥彁渚涙洿楂樼骇鍒殑 楂樺彲鐢ㄦ�с�侼DB 瀛樺偍寮曟搸鐨勭壒鐐规槸鏁版嵁鍏ㄩ儴鏀惧湪鍐呭瓨涓�(浠�5.1 鐗堟湰寮�濮�,鍙互灏嗛潪绱㈠紩鏁� 鎹斁鍦ㄧ鐩樹笂),鍥犳涓婚敭鏌ユ壘(primary key lookups)鐨勯�熷害鏋佸揩,骞朵笖鑳藉鍦ㄧ嚎娣诲姞NDB 鏁版嵁瀛樺偍鑺傜偣(data node)浠ヤ究绾挎�у湴鎻愰珮鏁版嵁搴撴�ц兘銆傜敱姝ゅ彲瑙�,NDB 瀛樺偍寮曟搸鏄珮鍙敤銆� 楂樻�ц兘銆侀珮鍙墿灞曟�х殑鏁版嵁搴撻泦缇ょ郴缁�,鍏堕潰鍚戠殑涔熸槸OLTP 鐨勬暟鎹簱搴旂敤绫诲瀷銆�
#Memory 瀛樺偍寮曟搸
姝e鍏跺悕,Memory 瀛樺偍寮曟搸涓殑鏁版嵁閮藉瓨鏀惧湪鍐呭瓨涓�,鏁版嵁搴撻噸 鍚垨鍙戠敓宕╂簝,琛ㄤ腑鐨勬暟鎹兘灏嗘秷澶便�傚畠闈炲父閫傚悎浜庡瓨鍌∣LTP 鏁版嵁搴撳簲鐢ㄤ腑涓存椂鏁版嵁鐨勪复鏃惰〃,涔熷彲浠ヤ綔涓篛LAP 鏁版嵁搴撳簲鐢ㄤ腑鏁版嵁浠撳簱鐨勭淮搴﹁〃銆侻emory 瀛樺偍寮曟搸榛樿浣跨敤鍝堝笇 绱㈠紩,鑰屼笉鏄�氬父鐔熸倝鐨凚+ 鏍戠储寮曘��
#Infobright 瀛樺偍寮曟搸
绗笁鏂圭殑瀛樺偍寮曟搸銆傚叾鐗圭偣鏄瓨鍌ㄦ槸鎸夌収鍒楄�岄潪琛岀殑,鍥犳闈炲父 閫傚悎OLAP 鐨勬暟鎹簱搴旂敤銆傚叾瀹樻柟缃戠珯鏄痟ttp://www.infobright.org/,涓婇潰鏈変笉灏戞垚鍔熺殑鏁版嵁 浠撳簱妗堜緥鍙緵鍒嗘瀽銆�
#NTSE 瀛樺偍寮曟搸
缃戞槗鍏徃寮�鍙戠殑闈㈠悜鍏跺唴閮ㄤ娇鐢ㄧ殑瀛樺偍寮曟搸銆傜洰鍓嶇殑鐗堟湰涓嶆敮鎸佷簨鍔�, 浣嗘彁渚涘帇缂┿�佽绾х紦瀛樼瓑鐗规��,涓嶄箙鐨勫皢鏉ヤ細瀹炵幇闈㈠悜鍐呭瓨鐨勪簨鍔℃敮鎸併��
#BLACKHOLE
聽 聽 聽 聽 榛戞礊瀛樺偍寮曟搸锛屽彲浠ュ簲鐢ㄤ簬涓诲澶嶅埗涓殑鍒嗗彂涓诲簱銆�
鏌ョ湅涓嶅悓瀛樺偍寮曟搸瀛樺偍琛ㄧ粨鏋勬枃浠剁壒鐐癸細create table t1(id int)engine=innodb;
create table t2(id int)engine=myisam;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 create table t3(id int)engine=blackhole;聽 # 寰�琛ㄥ唴鎻掑叆浠讳綍鏁版嵁锛岄兘鐩稿綋浜庝涪鍏ラ粦娲烇紝琛ㄥ唴姘歌繙涓嶅瓨璁板綍
create table t4(id int)engine=memory;聽 # 鍦ㄩ噸鍚痬ysql鎴栬�呴噸鍚満鍣ㄥ悗锛岃〃鍐呮暟鎹竻绌�
insert into t1 values(1);
insert into t2 values(1);
insert into t3 values(1);
insert into t4 values(1);