ERROR 1114 (HY000): The table 'test1' is full 的解決

xchui702發表於2016-09-19

今天執行sql碰到 1114的錯誤,如下:
mysql> insert into test1 select * from test;
Query OK, 1778 rows affected (0.06 sec)
Records: 1778  Duplicates: 0  Warnings: 0

mysql> insert into test1 select * from test;
ERROR 1114 (HY000): The table 'test1' is full

檢視官方的文件,並沒有答案,裡面說到作業系統檔案的限制引起了這個錯誤,可以理解,作業系統單個檔案大小最大是2G,那麼採用innodb_file_per_table=on 時,會把一個表資料建立在一個檔案中,那麼這個表資料的大小隻能是2G了。
http://dev.mysql.com/doc/refman/5.7/en/full-table.html

問題是我的表沒有2G:
mysql> select * from information_schema.tables where table_name='test' \G
*************************** 1. row ***************************
  TABLE_CATALOG: def
   TABLE_SCHEMA: test
     TABLE_NAME: test
     TABLE_TYPE: BASE TABLE
         ENGINE: MEMORY
        VERSION: 10
     ROW_FORMAT: Fixed
     TABLE_ROWS: 1778
 AVG_ROW_LENGTH: 9440
    DATA_LENGTH: 16855944
MAX_DATA_LENGTH: 16765440
   INDEX_LENGTH: 0
      DATA_FREE: 0
 AUTO_INCREMENT: NULL
    CREATE_TIME: 2016-09-19 13:45:37
    UPDATE_TIME: NULL
     CHECK_TIME: NULL
TABLE_COLLATION: utf8_general_ci
       CHECKSUM: NULL
 CREATE_OPTIONS:
  TABLE_COMMENT:
1 row in set (0.00 sec)


大約16M, 另一個有用的資訊是這個表的儲存引擎是 MEMORY.
這個是由於 create table test like information_schema.tables, create table test1 like test; 而information_schema.tables是tables表是memory儲存引擎所致。
 

而 memory 的大小受到 'max_heap_table_size' 引數影響
mysql> show variables like 'max_heap_table_size';
+---------------------+----------+
| Variable_name       | Value    |
+---------------------+----------+
| max_heap_table_size | 16777216 |
+---------------------+----------+

修改此引數大小驗證一下:
set max_heap_table_size=167772160
還是報錯。


根據網上的資料,修改my.cnf檔案,然後重新啟動:
tmp_table_size = 256M
max_heap_table_size = 256M

再次執行就可以了
mysql> insert into test2 select * from test2;
Query OK, 9216 rows affected (1.22 sec)
Records: 9216  Duplicates: 0  Warnings: 0

此時表的最大長度也變為 256M了。
mysql> select * from information_schema.tables where table_name='test2' \G
*************************** 1. row ***************************
  TABLE_CATALOG: def
   TABLE_SCHEMA: test
     TABLE_NAME: test2
     TABLE_TYPE: BASE TABLE
         ENGINE: MEMORY
        VERSION: 10
     ROW_FORMAT: Fixed
     TABLE_ROWS: 18432
 AVG_ROW_LENGTH: 9440
    DATA_LENGTH: 174807384
MAX_DATA_LENGTH: 268313120
   INDEX_LENGTH: 0
      DATA_FREE: 0
 AUTO_INCREMENT: NULL
    CREATE_TIME: 2016-09-19 14:37:29
    UPDATE_TIME: NULL
     CHECK_TIME: NULL
TABLE_COLLATION: utf8_general_ci
       CHECKSUM: NULL
 CREATE_OPTIONS:
  TABLE_COMMENT:



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/674865/viewspace-2125150/,如需轉載,請註明出處,否則將追究法律責任。

相關文章