官术网_书友最值得收藏!

  • MariaDB Cookbook
  • Daniel Bartholomew
  • 352字
  • 2021-07-16 12:19:25

Migrating a table from MyISAM to Aria

MariaDB ships with the MyISAM and Aria storage engines, among many others. The main difference between these two is that Aria is crash safe, whereas MyISAM is not. Being crash safe means that an Aria table can recover from catastrophic power loss or other unexpected failures in a much better way than a MyISAM table can. If we use MyISAM tables, an easy upgrade is to convert them to Aria tables.

Getting ready

Import the ISFDB database as described in the Importing the data exported by mysqldump recipe in this chapter.

How to do it...

  1. Open the mysql command-line client and connect to the isfdb database.
  2. Run the following command line:
    ALTER TABLE authors ENGINE=Aria;
    
  3. The ALTER command will then change the table so that it uses the Aria storage engine.
  4. After it has finished, a message similar to the following will be displayed:
    Query OK, 110829 rows affected (3.14 sec) 
    Records: 110829 Duplicates: 0 Warnings: 0 
    
  5. If our system is older or is under heavy load and it takes longer than 5 seconds for ALTER TABLE to complete, we'll see a progress message letting us know how much of the task has been completed, updated every 5 seconds, until the task is finished.

How it works...

The ALTER TABLE command changes a table in two stages. First, it creates a new table identical in every way to the old table, except that the new table has the changes specified by the command. In our case, the only change is to use the Aria storage engine instead of the MyISAM storage engine. Then, the command copies all of the data to the new table.

In the second stage, ALTER TABLE removes the old table and renames the new table with the name of the old table.

On a table like authors that only has around a hundred thousand rows, the conversion is quick and easy; however, on a table with several billion rows, the conversion process will take significantly longer.

See also

主站蜘蛛池模板: 武汉市| 潼关县| 信阳市| 上思县| 含山县| 牙克石市| 中西区| 新巴尔虎右旗| 庆云县| 巴林左旗| 曲水县| 宿松县| 抚顺市| 安乡县| 烟台市| 威宁| 新蔡县| 游戏| 方城县| 清原| 油尖旺区| 田阳县| 沧州市| 商水县| 平果县| 交口县| 廉江市| 板桥市| 太谷县| 福安市| 广水市| 丁青县| 金湖县| 宁德市| 漳平市| 石林| 新河县| 玉田县| 甘谷县| 彝良县| 云安县|