Export data

This document will guide you how to export data in MatrixOne.

Before you start

If you use the docker install, please make sure that you have a data directory mounted to the container. For example,

  1. docker run -d -p 6001:6001 -v ~/tmp/docker_export_demo/store:/store:rw --name matrixone matrixorigin/matrixone:0.5.1

Note

MatrixOne does not support using mysqldump to export table structures and data, it only supports SELECT...INTO OUTFILE exporting to text files.

Steps

  1. Create tables in MatrixOne:

    1. create database aaa;
    2. use aaa;
    3. CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));
    4. insert into user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');
    5. select * from user;
    6. +------+-----------+------+
    7. | id | user_name | sex |
    8. +------+-----------+------+
    9. | 1 | weder | man |
    10. | 2 | tom | man |
    11. | 3 | wederTom | man |
    12. +------+-----------+------+
  2. For installation with source code or binary file, export the table to your local directory, for example, ~/tmp/export_demo/export_datatable.txt

    1. select * from user into outfile '~/tmp/export_demo/export_datatable.txt'

    For installation with docker, export the your mounted directory path of container as the following example. The directory store refers to the local path of ~/tmp/docker_export_demo/store.

    1. select * from user into outfile 'store/export_datatable.txt';
  3. Check the table in your directory export_datatable.txt, the result is as below:

    1. id,user_name,sex
    2. 1,"weder","man"
    3. 2,"tom","man"
    4. 3,"wederTom","man"