如何使用Barracuda文件格式创建表

时间:2017-05-13 16:04:46

标签: mysql docker mariadb

由于我需要几个中间文本字段,我需要梭子鱼文件格式。关于如何将现有的羚羊表转换为梭子鱼,有很多关于如何使用梭子鱼创建新表的艺术品和视频。使用MariaDB是否容易实现?如果可能,我想使用码头工具箱。

2 个答案:

答案 0 :(得分:1)

尝试:

MariaDB [_]> SELECT VERSION();
+-----------------+
| VERSION()       |
+-----------------+
| 10.1.23-MariaDB |
+-----------------+
1 row in set (0.00 sec)

MariaDB [_]> SHOW VARIABLES LIKE 'innodb_file_format';
+--------------------+----------+
| Variable_name      | Value    |
+--------------------+----------+
| innodb_file_format | Antelope |
+--------------------+----------+
1 row in set (0.01 sec)

MariaDB [_]> CREATE TABLE `barracuda_table` (`col` MEDIUMTEXT) ROW_FORMAT=DYNAMIC;
Query OK, 0 rows affected, 2 warnings (0.00 sec)

MariaDB [_]> SHOW WARNINGS;
+---------+------+--------------------------------------------------------------------+
| Level   | Code | Message                                                            |
+---------+------+--------------------------------------------------------------------+
| Warning | 1478 | InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. |
| Warning | 1478 | InnoDB: assuming ROW_FORMAT=COMPACT.                               |
+---------+------+--------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [_]> SELECT ROW_FORMAT
    -> FROM `information_schema`.`tables`
    -> WHERE `TABLE_SCHEMA` = DATABASE() AND
    ->       `TABLE_NAME` = 'barracuda_table';
+------------+
| ROW_FORMAT |
+------------+
| Compact    |
+------------+
1 row in set (0.00 sec)

MariaDB [_]> DROP TABLE `barracuda_table`;
Query OK, 0 rows affected (0.00 sec)

MariaDB [_]> SET @@GLOBAL.innodb_file_format = 'Barracuda';
Query OK, 0 rows affected (0.00 sec)

MariaDB [_]> SHOW VARIABLES LIKE 'innodb_file_format';
+--------------------+-----------+
| Variable_name      | Value     |
+--------------------+-----------+
| innodb_file_format | Barracuda |
+--------------------+-----------+
1 row in set (0.00 sec)

MariaDB [_]> CREATE TABLE `barracuda_table` (`col` MEDIUMTEXT) ROW_FORMAT=DYNAMIC;
Query OK, 0 rows affected (0.00 sec)

MariaDB [_]> SELECT ROW_FORMAT
    -> FROM `information_schema`.`tables`
    -> WHERE `TABLE_SCHEMA` = DATABASE() AND
    ->       `TABLE_NAME` = 'barracuda_table';
+------------+
| ROW_FORMAT |
+------------+
| Dynamic    |
+------------+
1 row in set (0.00 sec)

MariaDB [_]> SELECT `NAME`, `FILE_FORMAT`, `ROW_FORMAT`
    -> FROM `information_schema`.`INNODB_SYS_TABLES`
    -> WHERE `NAME` = '_/barracuda_table';
+-------------------+-------------+------------+
| NAME              | FILE_FORMAT | ROW_FORMAT |
+-------------------+-------------+------------+
| _/barracuda_table | Barracuda   | Dynamic    |
+-------------------+-------------+------------+
1 row in set (0.00 sec)

请参阅XtraDB/InnoDB Storage Formats

答案 1 :(得分:1)

5.6(MariaDB 10.0和10.1)中的混乱:

SET GLOBAL innodb_file_format=Barracuda;
SET GLOBAL innodb_file_per_table=1;
SET GLOBAL innodb_large_prefix=1;     -- optional (if you also need wide indexes)
ALTER TABLE tbl ROW_FORMAT=DYNAMIC;

它可能在5.7(MariaDB 10.2)中正确默认。