mysql設置單表大小的方法:1、創(chuàng)建表時的修改方法;2、修改已存在表的方法,代碼為【alter table tbl_name max_rows=1000000000 avg_row_length=15000】。
mysql設置單表大小的方法:
一、mysql數(shù)據(jù)庫的innodb存儲 引擎單表大小限制已經(jīng)不是有mysql數(shù)據(jù)庫本身來決定(限制擴大到64pb),而是由所在主機的os上面的文件系統(tǒng)來決定了。
在mysql5.0版本之前,myisam存儲引擎默認表的大小4gb,可以用一下命令來查看:
[root@robert test]# cd /data/mysql/mysql_3306/data/test[root@robert test]# myisamchk -dv t2innodb file: t2record format: fixed lengthcharacter set: latin1_swedish_ci (8)file-version: 1creation time: 2014-12-29 14:13:17status: checked,analyzed,optimized keys,sorted index pagesdata records: 0 deleted blocks: 0datafile parts: 0 deleted data: 0datafile pointer (bytes): 6 keyfile pointer (bytes): 3datafile length: 0 keyfile length: 1024max datafile length: 3096224743817214 max keyfile length: 17179868159recordlength: 11table description:key start len index type rec/key root blocksizedatafile length:當前數(shù)據(jù)文件的大小
keyfile length:索引文件的大小
max datafile length: 最大數(shù)據(jù)文件的大小
max keyfile length:最大索引文件的大小
如果需要使用大于4gb的innodb表(而且你的操作系統(tǒng)支持大文件),可使用允許avg_row_length和max_rows選項的create table語句。創(chuàng)建了表后,也可以使用alter table更改這些選項,以增加表的最大允許容量。
創(chuàng)建表時的修改方法
create table tbl_name (a integer not null primary key,b char(18) not null) max_rows = 1000000000 avg_row_length = 32;修改已存在表的方法
alter table tbl_name max_rows=1000000000 avg_row_length=15000;二:innodb存儲引擎分為兩種的,一種是共享表空間存儲方式,還有一種是獨享表空間存儲方式。
1)共享表空間存儲方式的時候,innodb的所有數(shù)據(jù)保存在一個單獨的表空間里面(但是每個表都有一個.frm表結構文件),而這個表空間可以由很多個文件組成,一個表可以跨多個文件存在,所 以其大小限制不再是文件大小的限制,而是其自身的限制。
從innodb的官方文檔中可以看到,其表空間的最大限制為64tb,也就是說,innodb的單 表限制基本上也在64tb左右了,當然這個大小是包括這個表的所有索引等其他相關數(shù)據(jù)。
2)獨享表空間來存放innodb的表的時候,每個表的數(shù)據(jù)以一個單獨的文件來存放,這個時候的單表限制,又變成文件系統(tǒng)的大小限制了。
操作系統(tǒng) 大小限制
win32 w/ fat/fat32 2gb/4gbwin32 w/ ntfs 2tb(可能更大)linux 2.2-intel 32-bit 2gb (lfs: 4gb)linux 2.4 4tb(ext3)solaris 9/10 16tbnetware w/nss filesystem 8tbmacos x w/ hfs 2tb更多相關免費學習推薦:mysql教程(視頻)