diff --git a/dev/404.html b/dev/404.html index 1878eec7e..db93acd2d 100644 --- a/dev/404.html +++ b/dev/404.html @@ -11,7 +11,7 @@ - + @@ -2116,6 +2116,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9266,7 +9486,7 @@

    404 - Not found

    - + diff --git a/dev/MatrixOne/Contribution-Guide/Code-Style/code-comment-style/index.html b/dev/MatrixOne/Contribution-Guide/Code-Style/code-comment-style/index.html index 872d6a0b2..d4223b719 100644 --- a/dev/MatrixOne/Contribution-Guide/Code-Style/code-comment-style/index.html +++ b/dev/MatrixOne/Contribution-Guide/Code-Style/code-comment-style/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9620,7 +9845,7 @@

    Tips for a good comment

    - + diff --git a/dev/MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/index.html b/dev/MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/index.html index 9c9f4a580..7bb2e13f6 100644 --- a/dev/MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/index.html +++ b/dev/MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9379,6 +9599,11 @@ + + + + + @@ -9516,7 +9741,7 @@

    Attribution

    - + diff --git a/dev/MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/index.html b/dev/MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/index.html index 546d6a0c5..912e7fa4f 100644 --- a/dev/MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/index.html +++ b/dev/MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/index.html @@ -13,7 +13,7 @@ - + @@ -2127,6 +2127,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9403,6 +9623,11 @@ + + + + + @@ -9573,7 +9798,7 @@

    Pull Request description style

    - + diff --git a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/index.html b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/index.html index 3d6767613..ac181aa23 100644 --- a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/index.html +++ b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9351,6 +9571,11 @@ + + + + + @@ -9475,7 +9700,7 @@

    Code review

    - + diff --git a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/index.html b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/index.html index 161a0f74e..782fe6082 100644 --- a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/index.html +++ b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9595,7 +9820,7 @@

    Contribute a blog article - + diff --git a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/index.html b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/index.html index 77584a6af..37fcb3fe2 100644 --- a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/index.html +++ b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9423,7 +9648,7 @@

    Process

    - + diff --git a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/preparation/index.html b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/preparation/index.html index c6dfa6e77..b2600b9e0 100644 --- a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/preparation/index.html +++ b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/preparation/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9445,6 +9665,11 @@ + + + + + @@ -9677,7 +9902,7 @@

    Install and Run MatrixOne - + diff --git a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/index.html b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/index.html index 75a3342ff..fe5a2fd43 100644 --- a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/index.html +++ b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9351,6 +9571,11 @@ + + + + + @@ -9515,7 +9740,7 @@

    Good First Issues

    - + diff --git a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/index.html b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/index.html index 0c88e598a..c2bbea614 100644 --- a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/index.html +++ b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9337,6 +9557,11 @@ + + + + + @@ -9456,7 +9681,7 @@

    Checking pull requests

    - + diff --git a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/index.html b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/index.html index 3079e1a9a..1dd1c3fa3 100644 --- a/dev/MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/index.html +++ b/dev/MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9337,6 +9557,11 @@ + + + + + @@ -9494,7 +9719,7 @@

    Other Contributions

    - + diff --git a/dev/MatrixOne/Contribution-Guide/make-your-first-contribution/index.html b/dev/MatrixOne/Contribution-Guide/make-your-first-contribution/index.html index 28fac0d80..6f26ee587 100644 --- a/dev/MatrixOne/Contribution-Guide/make-your-first-contribution/index.html +++ b/dev/MatrixOne/Contribution-Guide/make-your-first-contribution/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9513,6 +9733,11 @@ + + + + + @@ -9674,7 +9899,7 @@

    Step 8: After mergi
    - + diff --git a/dev/MatrixOne/Deploy/MatrixOne-Operator-mgmt/index.html b/dev/MatrixOne/Deploy/MatrixOne-Operator-mgmt/index.html index ff0927171..a07d0c604 100644 --- a/dev/MatrixOne/Deploy/MatrixOne-Operator-mgmt/index.html +++ b/dev/MatrixOne/Deploy/MatrixOne-Operator-mgmt/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9431,6 +9651,11 @@ + + + + + @@ -9619,7 +9844,7 @@

    Uninstall

    - + diff --git a/dev/MatrixOne/Deploy/MatrixOne-cluster-Scale/index.html b/dev/MatrixOne/Deploy/MatrixOne-cluster-Scale/index.html index 99395ff8c..bf4d89a6c 100644 --- a/dev/MatrixOne/Deploy/MatrixOne-cluster-Scale/index.html +++ b/dev/MatrixOne/Deploy/MatrixOne-cluster-Scale/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9431,6 +9651,11 @@ + + + + + @@ -9749,7 +9974,7 @@

    - + diff --git a/dev/MatrixOne/Deploy/MatrixOne-start-stop/index.html b/dev/MatrixOne/Deploy/MatrixOne-start-stop/index.html index 99bae6670..80a803df8 100644 --- a/dev/MatrixOne/Deploy/MatrixOne-start-stop/index.html +++ b/dev/MatrixOne/Deploy/MatrixOne-start-stop/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9457,6 +9677,11 @@ + + + + + @@ -9602,7 +9827,7 @@

    Check Pod status

    - + diff --git a/dev/MatrixOne/Deploy/deploy-MatrixOne-cluster/index.html b/dev/MatrixOne/Deploy/deploy-MatrixOne-cluster/index.html index 51834f9d8..c25e609ed 100644 --- a/dev/MatrixOne/Deploy/deploy-MatrixOne-cluster/index.html +++ b/dev/MatrixOne/Deploy/deploy-MatrixOne-cluster/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9725,6 +9945,11 @@ + + + + + @@ -10454,7 +10679,7 @@

    6. Connect to MatrixOne cluster<
    - + diff --git a/dev/MatrixOne/Deploy/deployment-topology/experience-deployment-topology/index.html b/dev/MatrixOne/Deploy/deployment-topology/experience-deployment-topology/index.html index eca62c7de..39ed11a9e 100644 --- a/dev/MatrixOne/Deploy/deployment-topology/experience-deployment-topology/index.html +++ b/dev/MatrixOne/Deploy/deployment-topology/experience-deployment-topology/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9363,6 +9583,11 @@ + + + + + @@ -9520,7 +9745,7 @@

    Deployment Software Module Requ
    - + diff --git a/dev/MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/index.html b/dev/MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/index.html index aa31a07b0..12f1bd20a 100644 --- a/dev/MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/index.html +++ b/dev/MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9363,6 +9583,11 @@ + + + + + @@ -9527,7 +9752,7 @@

    Deployment Software Module Requ
    - + diff --git a/dev/MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/index.html b/dev/MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/index.html index e65502596..751d728a0 100644 --- a/dev/MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/index.html +++ b/dev/MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9508,7 +9733,7 @@

    Other configuration

    - + diff --git a/dev/MatrixOne/Deploy/deployment-topology/topology-overview/index.html b/dev/MatrixOne/Deploy/deployment-topology/topology-overview/index.html index feb08dc90..cacfd0ee4 100644 --- a/dev/MatrixOne/Deploy/deployment-topology/topology-overview/index.html +++ b/dev/MatrixOne/Deploy/deployment-topology/topology-overview/index.html @@ -9,13 +9,13 @@ - + - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9309,6 +9529,11 @@ + + + + + @@ -9343,7 +9568,7 @@

    Topology deployment document

    @@ -9471,6 +9691,11 @@ + + + + + @@ -10374,7 +10599,7 @@

    View Pod Status

    - + diff --git a/dev/MatrixOne/Deploy/import-data-from-minio-to-mo/index.html b/dev/MatrixOne/Deploy/import-data-from-minio-to-mo/index.html index b232a5800..3c5c37e7b 100644 --- a/dev/MatrixOne/Deploy/import-data-from-minio-to-mo/index.html +++ b/dev/MatrixOne/Deploy/import-data-from-minio-to-mo/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9403,6 +9623,11 @@ + + + + + @@ -9561,7 +9786,7 @@

    Build and execute the Load stateme
    - + diff --git a/dev/MatrixOne/Deploy/mgmt-cn-group-using-proxy/index.html b/dev/MatrixOne/Deploy/mgmt-cn-group-using-proxy/index.html index e90849a82..ac6ae871e 100644 --- a/dev/MatrixOne/Deploy/mgmt-cn-group-using-proxy/index.html +++ b/dev/MatrixOne/Deploy/mgmt-cn-group-using-proxy/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9443,6 +9663,11 @@ + + + + + @@ -9843,7 +10068,7 @@

    Implementing Load Isolation

    - + diff --git a/dev/MatrixOne/Deploy/update-MatrixOne-cluster/index.html b/dev/MatrixOne/Deploy/update-MatrixOne-cluster/index.html index e90a10077..f524fdb4e 100644 --- a/dev/MatrixOne/Deploy/update-MatrixOne-cluster/index.html +++ b/dev/MatrixOne/Deploy/update-MatrixOne-cluster/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9443,6 +9663,11 @@ + + + + + @@ -9673,7 +9898,7 @@

    4. Check if the upgrade is success
    - + diff --git a/dev/MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/index.html b/dev/MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/index.html new file mode 100644 index 000000000..eabbfdb86 --- /dev/null +++ b/dev/MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/index.html @@ -0,0 +1,9922 @@ + + + + + + + + + + + + + + + + + + + + + + Visualizing MatrixOne Data with FineBI - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    Visualizing MatrixOne Data with FineBI

    +

    Overview

    +

    FineBI is a next-generation big data analytics tool that empowers business professionals to gain deep insights and leverage their data. In FineBI, users can easily create diverse visualizations, analyze data freely, and explore their datasets. FineBI boasts various data connectivity features and can be used to build complex reports constructing data-driven decision analysis systems. It finds wide application in corporate management, production control, financial intelligence, and sales operations.

    +

    MatrixOne supports integration with the data visualization tool FineBI. This article will guide you on connecting to the standalone version of MatrixOne using FineBI and creating various visual data reports, assembling them into dashboards for data analysis and exploration.

    +

    Before you start

    + +
    +

    Note

    +

    The FineBI version used in the operations shown in this document is FineBI Linux 6.0. You can choose to install the Linux_unix_FineBI6_0-CN.sh package.

    +
    +

    Connecting to MatrixOne Service via FineBI

    +
      +
    1. +

      After logging into FineBI, select Management System > Data Connection > Data Connection Management > New Data Connection as shown below, then choose MySQL:

      +

      image-20230808174909411

      +
    2. +
    3. +

      Fill in the MatrixOne connection configuration, including the database name, host, port, username, and password. Other parameters can be left at their default settings. You can click the Test Connection button to verify if the connection is functional and then click Save :

      +

      image-20230808182330603

      +
    4. +
    +

    Creating Visual Reports Using MatrixOne Data

    +
      +
    1. +

      Create Demo Data:

      +

      First, log in to the MatrixOne database and execute the following SQL statements to create the necessary data tables and views for the demo:

      +
      create database orders;
      +use orders;
      +CREATE TABLE `category` (`product_category_name` VARCHAR(255) DEFAULT NULL,
      +`product_category_name_english` VARCHAR(255) DEFAULT NULL );
      +CREATE TABLE `item` (`order_id` VARCHAR(255) NOT NULL, `order_item_id` INT DEFAULT null,
      +`product_id` VARCHAR(255) DEFAULT null,
      +`seller_id` VARCHAR(255) DEFAULT null, `shipping_limit_date` DATETIME DEFAULT null,
      +`price` DECIMAL(10,2) DEFAULT null,
      +`freight_value` DECIMAL(10,2) DEFAULT null
      +);
      +CREATE TABLE `review` (
      +`review_id` VARCHAR(255) NOT NULL,
      +`order_id` VARCHAR(255) DEFAULT null,
      +`review_score` TINYINT DEFAULT null,
      +`review_comment_title` VARCHAR(255) DEFAULT null,
      +`review_comment_message` TEXT DEFAULT null,
      +`review_creation_date` DATETIME DEFAULT null,
      +`review_answer_timestamp` DATETIME DEFAULT null,
      +PRIMARY KEY (`review_id`)
      +);
      +CREATE TABLE `order_time` (
      +`order_id` VARCHAR(255) NOT NULL,
      +`customer_id` VARCHAR(255) DEFAULT null,
      +`y` INT DEFAULT null,
      +`q` INT DEFAULT null,
      +`m` INT DEFAULT null,
      +`d` DATE DEFAULT null,
      +`h` INT DEFAULT null,
      +`order_purchase_timestamp` DATETIME DEFAULT null
      +);
      +CREATE TABLE `orders` (
      +`order_id` VARCHAR(255) NOT NULL,
      +`customer_id` VARCHAR(255) DEFAULT null,
      +`order_status` VARCHAR(255) DEFAULT null,
      +`order_purchase_timestamp` DATETIME DEFAULT null,
      +`order_approved_at` DATETIME DEFAULT null,
      +`order_delivered_carrier_date` DATETIME DEFAULT null,
      +`order_delivered_customer_date` DATETIME DEFAULT null,
      +`order_estimated_delivery_date` DATETIME DEFAULT null,
      +PRIMARY KEY (`order_id`)
      +);
      +CREATE TABLE `product` (
      +`product_id` VARCHAR(255) NOT NULL,
      +`product_category_name` VARCHAR(255) DEFAULT null,
      +`product_name_lenght` INT DEFAULT null,
      +`product_description_lenght` INT DEFAULT null,
      +`product_photos_qty` INT DEFAULT null,
      +`product_weight_g` INT DEFAULT null,
      +`product_length_cm` INT DEFAULT null,
      +`product_height_cm` INT DEFAULT null,
      +`product_width_cm` INT DEFAULT null,
      +PRIMARY KEY (`product_id`)
      +);
      +CREATE TABLE `rfm` (
      +`customer_id` VARCHAR(255) DEFAULT null,
      +`user_type` VARCHAR(255) DEFAULT null,
      +`shijian` DATE DEFAULT null
      +);
      +
      +CREATE view total_order_value as select  t.order_id,product_id,seller_id,(price*total)+(freight_value*total) as order_value  from (select order_id,count(*) as total  from item group by order_id) t join item on t.order_id=item.order_id;
      +
      +CREATE view order_detail as select a.order_id,product_id,seller_id, customer_id,round(order_value,2) as order_value, y,q,m,d,h,order_purchase_timestamp from total_order_value a inner join order_time b on a.order_id=b.order_id;
      +
      +

      Next, use the following SQL import statements to import the prepared demo data into the respective tables of the MatrixOne database.

      +
      +

      Note

      +

      Please note that the path /root/data/table_name.csv is the path to the data files for each table. You can generate your data following a similar process.

      +
      +
      use orders;
      +load data local infile '/root/data/category.csv' into table category FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\r\n";
      +load data local infile '/root/data/review.csv' into table review FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\r\n";
      +load data local infile '/root/data/product.csv' into table product FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\r\n";
      +load data local infile '/root/data/item.csv' into table item FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\r\n";
      +load data local infile '/root/data/order_time.csv' into table order_time FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\r\n";
      +load data local infile '/root/data/orders.csv' into table orders FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\r\n";
      +load data local infile '/root/data/rfm.csv' into table rfm FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\r\n";
      +
      +
    2. +
    3. +

      Add Data Sets:

      +

      In FineBI, click Public Data, then click New Folder to create and select a folder. After that, click New Data Set, choose SQL Data Set, and add the SQL query to the selected folder. Enter the dataset name and input the SQL query as shown below:

      +
      select d,
      +count(order_id) as order_num,
      +count(DISTINCT customer_id)
      +from orders.order_detail
      +group by d
      +order by d
      +
      +

      You can click the Preview button to view the results of the SQL query and then click OK to save it:

      +

      image-20230809091306270

      +

      Below are examples of all the query SQL used in this demo:

      +
      -- Daily active users and order count
      +select d,
      +count(order_id) as order_num,
      +count(DISTINCT customer_id)
      +from orders.order_detail
      +group by d
      +order by d
      +
      +-- Monthly active users and order count
      +select count(DISTINCT customer_id),
      +count(order_id),
      +concat(y, '-', m)
      +from orders.order_detail
      +group by y,m
      +order by y,m
      +
      +-- Active users and order count in different periods
      +select h,
      +count(DISTINCT customer_id),
      +count(order_id) order_num
      +from orders.order_detail
      +group by h
      +order by h
      +
      +-- User count by type
      +SELECT count(*),
      +user_type
      +from orders.rfm
      +GROUP BY user_type
      +
      +-- Monthly GMV
      +select y,m,
      +sum(order_value),
      +concat(y, "-", m) month
      +from orders.order_detail
      +group by y,m
      +order by y,m
      +
      +-- Quarterly GMV
      +select y,q,
      +sum(order_value) gmv,
      +concat(y, "季度", q) as quator
      +from orders.order_detail
      +group by y,q
      +order by concat(y, "季度", q) asc
      +
      +-- Quarterly ARPU
      +select y,q,
      +round((sum(order_value)/count(DISTINCT customer_id)),2) arpu,
      +concat(y, "季度", q) as quator
      +from orders.order_detail
      +group by y,q
      +order by y,q
      +
      +-- Monthly ARPU
      +select y,m,
      +round((sum(order_value)/count(DISTINCT customer_id)),2) arpu,
      +concat(y, "-", m) as month
      +from orders.order_detail
      +group by y,m
      +order by y,m
      +
      +-- Important retained users' popularity index
      +SELECT e.product_category_name_english good_type,
      +SUM(a.order_value) ordder_total_value,
      +ROUND(AVG(c.review_score), 2) good_review_score,
      +(0.7*SUM(a.order_value)+0.3*10000*ROUND(AVG(c.review_score), 7))
      +top_rank_rate
      +FROM orders.order_detail a
      +INNER JOIN
      +(SELECT customer_id
      +from orders.rfm
      +WHERE user_type='重要挽留用户' ) as b ON a.customer_id=b.customer_id
      +LEFT JOIN orders.review c ON a.order_id=c.order_id
      +LEFT JOIN orders.product d ON a.product_id=d.product_id
      +LEFT JOIN orders.category e ON d.product_category_name=e.product_category_name
      +where e.product_category_name_english is not NULL
      +GROUP BY e.product_category_name_english limit 50
      +
      +-- General retained users' popularity index
      +SELECT e.product_category_name_english good_type,
      +SUM(a.order_value) ordder_total_value,
      + ROUND(AVG(c.review_score), 2) good_review_score,
      +(0.7*SUM(a.order_value)+0.3*10000*ROUND(AVG(c.review_score), 7))
      +top_rank_rate
      +FROM orders.order_detail a
      +INNER JOIN
      +(SELECT customer_id from orders.rfm
      +WHERE user_type='一般挽留用户' ) as b ON a.customer_id=b.customer_id
      +LEFT JOIN orders.review c ON a.order_id=c.order_id
      +LEFT JOIN orders.product d ON a.product_id=d.product_id
      +LEFT JOIN orders.category e ON d.product_category_name=e.product_category_name
      +where e.product_category_name_english is not NULL
      +GROUP BY e.product_category_name_english limit 50
      +
      +
    4. +
    5. +

      Update Data:

      +

      After saving the dataset, you need to click the Update Data button and wait for the data update to complete before proceeding with the analysis:

      +

      image-20230809091814920

      +
    6. +
    7. +

      Create Analytic Themes:

      +

      The analytic theme in this example is used to visually present data for general retained users, important retained users, monthly ARPU, quarterly ARPU, active users in different periods, daily active users, monthly active users, and order counts. It assists in decision-making and improving business operations. Here are the specific steps to create an analytic theme:

      +
        +
      • Click My Analysis, then click New Folder to create and select a folder.
      • +
      • Click New Analytic Theme, select the dataset created in the previous step, and then click OK.
      • +
      +

      image-20230809092959252

      +

      Note: You can use the Batch Selection feature to select multiple datasets for theme analysis.

      +

      image-20230809092959252

      +

      Click the Add Component button, choose the chart type, drag the fields from the left to the right as needed, double-click to modify the field visualization name, and change the component name below to describe the content of the report analyzed by the component:

      +

      image-20230809092959252

      +

      image-20230809092959252

      +
    8. +
    9. +

      Assemble Dashboards:

      +

      Click Add Dashboard to add the components you just created to the dashboard. You can freely drag and resize the components and change the component names below to describe the report's content analyzed by the component.

      +

      image-20230810123913230

      +
    10. +
    11. +

      Publish Dashboards:

      +

      After assembling the dashboard, click Publish, set the publication name, publication node, and display platform. Then click Confirm, and your dashboard will be successfully published.

      +

      image-20230810123913230

      +

      Now, see the newly published dashboard under Navigation and see how it looks.

      +

      image-20230810131752645

      +
    12. +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/index.html b/dev/MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/index.html new file mode 100644 index 000000000..9b26fc624 --- /dev/null +++ b/dev/MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/index.html @@ -0,0 +1,9963 @@ + + + + + + + + + + + + + + + + + + + + + + Visual Monitoring of MatrixOne with Superset - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + + + + + +
    +
    + + + + + + + + + + + + +

    Visual Monitoring of MatrixOne with Superset

    +

    Overview

    +

    Superset is an open-source, modern, and lightweight BI analysis tool that can connect to multiple data sources, provide rich visualizations, and support custom dashboards, making it easy for users to explore and present data.

    +

    MatrixOne version 1.0 now supports integration with the data visualization tool Superset. This guide will walk you through the quick deployment of MatrixOne and Superset environments. Combining MatrixOne with Superset's visualization capabilities allows you to create a simple monitoring dashboard to track the 'system_metric' data within the MatrixOne database.

    +

    If you wish to extend the functionality further, you can explore other configuration options to monitor various aspects of the entire MatrixOne database.

    +

    Before you start

    + +

    This practice does not require high hardware specifications. A small virtual machine with 2 cores and 4GB of RAM is sufficient for experiencing the functionality of this process.

    +
      +
    • Recommended hardware resources: 8 cores and 32GB of RAM for a virtual machine.
    • +
    + +

    Before proceeding with this practice, you need to install and configure the following software environment:

    +
      +
    • Docker, with a version of 23.0.1 or higher.
    • +
    • MatrixOne
    • +
    • Superset, recommended version 2.1.0.
    • +
    +

    You can follow the steps in the following sections to install and configure them step by step.

    +

    Installing Docker

    +

    All software environments in this practice are based on Docker installation. You can refer to the official Docker documentation for installing and starting Docker.

    +

    Installing MatrixOne

    +

    You can install and deploy MatrixOne based on your operating system environment by following these links:

    + +

    Installing Superset

    +

    Here are the steps for deploying a single-node Superset using Docker:

    +
      +
    1. +

      After installing and starting Docker, use the following command to pull the Superset image from Docker Hub:

      +
      docker pull amancevice/superset
      +
      +
    2. +
    3. +

      Start the Superset image with the following command:

      +
      docker run -e "SUPERSET_SECRET_KEY=your_secret_key_here" --name superset -u 0 -d -p 8088:8088 amancevice/superset
      +
      +
      +

      Note

      +

      You can generate a secure secret key using openssl rand -base64 42. Alternatively, you can set it using the SUPERSET_SECRET_KEY environment variable.

      +
      +
    4. +
    5. +

      Initialize the Superset database with the following command:

      +
      docker exec -it superset superset db upgrade
      +
      +
    6. +
    7. +

      Create a Superset admin user by running the following command and providing the requested registration information:

      +
      docker exec -it superset superset fab create-admin
      +
      +
    8. +
    9. +

      Create default roles and permissions using the following command:

      +
      docker exec -it superset superset init
      +
      +
    10. +
    11. +

      Start the Superset service with threads, auto-reloading, and debugging using the following command:

      +
      docker exec -it superset superset run --with-threads --reload --debugger
      +
      +
    12. +
    +

    Connecting MatrixOne with Superset

    +
      +
    1. +

      Access the Superset login page, typically at http://ip:8080. Then, enter your username and password to log in to Superset.

      +

      Superset Login Page

      +

      Note: The port for Superset may be either 8080 or 8088, depending on your configuration. The username and password are the ones you set during the Superset deployment.

      +

      After logging in, you will see the main interface of Superset.

      +

      Superset Main Interface

      +
    2. +
    3. +

      Create a database connection:

      +

      In Superset, you first need to create a database connection to MatrixOne. Click on Settings in the top right corner and select Database Connections.

      +

      Click the + DATABASE button on the Database Connections page and choose MySQL as the database type.

      +

      Fill in the connection information for the MatrixOne database, including the host, port, username, and password.

      +

      Create Database Connection

      +

      After filling in the details, click the CONNECT button and then click FINISH.

      +

      Create Query

      +
    4. +
    +

    Creating Visual Monitoring Dashboards

    +

    Now, you can use the MatrixOne database to create a monitoring dashboard.

    +
      +
    1. +

      Click on SQL > SQL Lab on the page, select the MatrixOne database connection you created earlier, and write SQL queries to select the tables you want to monitor.

      +

      image-20230807201143069

      +

      You can write multiple queries to monitor different metrics. Here are example SQL statements for some queries:

      +
        +
      • CPU Usage:
      • +
      +
      SELECT metric_name, collecttime, value
      +FROM metric
      +WHERE metric_name = 'sys_cpu_combined_percent' OR metric_name = 'sys_cpu_seconds_total'
      +ORDER BY collecttime DESC;
      +
      +
        +
      • Storage Usage:
      • +
      +
      SELECT metric_name, value, collecttime
      +FROM metric
      +WHERE metric_name = 'server_storage_usage'
      +ORDER BY collecttime DESC;
      +
      +
        +
      • Number of Connections:
      • +
      +
      SELECT metric_name, value, collecttime
      +FROM metric
      +WHERE metric_name = 'server_connections'
      +ORDER BY collecttime DESC;
      +
      +
        +
      • Disk Read and Write:
      • +
      +
      SELECT metric_name, value, collecttime
      +FROM metric
      +WHERE metric_name = 'sys_disk_read_bytes' OR metric_name = 'sys_disk_write_bytes'
      +ORDER BY collecttime DESC;
      +
      +
        +
      • Network Receive and Send:
      • +
      +
      SELECT metric_name, value, collecttime
      +FROM metric
      +WHERE metric_name = 'sys_net_sent_bytes' OR metric_name = 'sys_net_recv_bytes'
      +ORDER BY collecttime DESC;
      +
      +
        +
      • Memory Usage:
      • +
      +
      SELECT metric_name, value, collecttime
      +FROM metric
      +WHERE metric_name = 'sys_memory_available' OR metric_name = 'sys_memory_used'
      +ORDER BY collecttime DESC;
      +
      +
    2. +
    3. +

      Transaction Errors:

      +
      SELECT metric_name, value, collecttime
      +FROM metric
      +WHERE metric_name = 'sql_transaction_errors' OR metric_name = 'sql_transaction_total'
      +ORDER BY collecttime DESC;
      +
      +
    4. +
    5. +

      SQL Errors:

      +
      SELECT metric_name, value, collecttime
      +FROM metric
      +WHERE metric_name = 'sql_statement_errors' OR metric_name = 'sql_statement_total'
      +ORDER BY collecttime DESC;
      +
      +
    6. +
    7. +

      Click SAVE > Save dataset > SAVE & EXPLORE to save each of the queries above and use them as data sources for subsequent charts.

      +
    8. +
    9. +

      Edit the charts:

      +

      Here, we'll use one of the queries as an example to demonstrate how to edit a visual chart. First, select the 'disk_read_write' query as the data source for the chart. In the SQL Lab, click CREATE CHART below the corresponding query, or if you've saved the query in the previous step, the page will redirect to the Chart editing page:

      +

      Create Dashboard

      +
    10. +
    11. +

      In the chart editing page, choose chart type, time field, metric columns from the query, grouping columns, and other options. Once configured, select RUN:

      +

      View Dashboard

      +
    12. +
    13. +

      Click UPDATE CHART > SAVE to save the edited chart.

      +
    14. +
    +

    Organizing Dashboards

    +
      +
    1. +

      After creating multiple charts, you can assemble them in Superset to create a monitoring dashboard:

      +

      Click on Dashboards, then click + DASHBOARD to create a new dashboard or edit an existing one.

      +

      image-20230808101636134

      +
    2. +
    3. +

      In the dashboard editing page, you can drag the charts you've created from the CHARTS list on the right onto the dashboard for assembly. You can also freely adjust the position of charts, add titles, and more.

      +

      image-20230808102033250

      +
    4. +
    +

    You have successfully connected the MatrixOne database with Superset and created a simple monitoring dashboard to visualize key metrics of the MatrixOne database.

    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/index.html b/dev/MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/index.html new file mode 100644 index 000000000..fa630b626 --- /dev/null +++ b/dev/MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/index.html @@ -0,0 +1,9752 @@ + + + + + + + + + + + + + + + + + + + + + + Visualizing MatrixOne Reports with Yonghong BI - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    Visualizing MatrixOne Reports with Yonghong BI

    +

    Overview

    +

    Yonghong BI is a comprehensive big data platform that integrates self-service data preparation, exploratory self-service analysis, in-depth analysis, enterprise-level management, and high-performance computing capabilities, providing an all-in-one big data solution. Yonghong BI aims to provide flexible and user-friendly end-to-end big data analysis tools for enterprises of all sizes, enabling users to easily uncover the value of big data and gain profound insights.

    +

    MatrixOne supports connectivity to the intelligent data analysis tool, Yonghong BI. This article will guide you on connecting to the standalone version of MatrixOne through Yonghong BI and creating various visual data reports.

    +

    Before you start

    +
      +
    • MatrixOne installation and startup are completed. Install and Start MatrixOne.
    • +
    • Yonghong BI is installed. Yonghong BI is a free intelligent data analysis tool based on native installation, eliminating the need for complex deployment steps.
    • +
    +

    Connecting MatrixOne Services with Yonghong BI

    +

    Adding a Data Source

    +

    Open Yonghong BI, select Add Data Source > + (New Data Source) on the left, and choose MySQL in the pop-up database options.

    +

    Add Data Source

    +

    After filling in the connection information related to the MatrixOne database, you can select the Test Connection button in the upper right corner to ensure a successful connection.

    +

    Once the connection is successful, click Save to save the data source information we just filled in.

    +

    Connect to MatrixOne

    +

    Creating a Dataset

    +

    In Yonghong BI, select the Create Dataset menu on the left, then choose the data source you added just now. You will see tables and views from the MatrixOne database. To meet your business needs, add Custom SQL, then click Refresh Data. The query results will be displayed on the right. After confirming that the query results meet expectations, click Save to save the dataset.

    +

    Create Dataset

    +

    Creating Reports

    +

    First, in Yonghong BI, select the Create Report menu on the left, then choose the appropriate Chart Component from the right and drag it to the left.

    +

    Create Report

    +

    Select the dataset you just created, set the time dimension as the X-axis, and set the daily order count and active user count as the Y-axis. You can drag the measurement and dimension fields to their respective positions as needed. After editing, click Save to save the report you created.

    +

    Create Report

    +

    Viewing Reports

    +

    Finally, in Yonghong BI, select View Report, then click on the report name we created in the tree menu on the left. You will be able to view the report we created above.

    +

    View Report

    +

    You have successfully connected to the MatrixOne database using Yonghong BI and created a simple report for visualizing MatrixOne data.

    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/index.html b/dev/MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/index.html new file mode 100644 index 000000000..1be7d65b8 --- /dev/null +++ b/dev/MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/index.html @@ -0,0 +1,10048 @@ + + + + + + + + + + + + + + + + + + + + + + Writing Data to MatrixOne Using DataX - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + + + + + +
    +
    + + + + + + + + + + + + +

    Writing Data to MatrixOne Using DataX

    +

    Overview

    +

    This article explains using the DataX tool to write data to offline MatrixOne databases.

    +

    DataX is an open-source heterogeneous data source offline synchronization tool developed by Alibaba. It provides stable and efficient data synchronization functions to achieve efficient data synchronization between various heterogeneous data sources.

    +

    DataX divides the synchronization of different data sources into two main components: Reader (read data source) and Writer (write to the target data source). The DataX framework theoretically supports data synchronization work for any data source type.

    +

    MatrixOne is highly compatible with MySQL 8.0. However, since the MySQL Writer plugin with DataX is adapted to the MySQL 5.1 JDBC driver, the community has separately modified the MatrixOneWriter plugin based on the MySQL 8.0 driver to improve compatibility. The MatrixOneWriter plugin implements the functionality of writing data to the target table in the MatrixOne database. In the underlying implementation, MatrixOneWriter connects to the remote MatrixOne database via JDBC and executes the corresponding insert into ... SQL statements to write data to MatrixOne. It also supports batch commits for performance optimization.

    +

    MatrixOneWriter uses DataX to retrieve generated protocol data from the Reader and generates the corresponding insert into ... statements based on your configured writeMode. In the event of primary key or uniqueness index conflicts, conflicting rows are excluded, and writing continues. For performance optimization, we use the PreparedStatement + Batch method and set the rewriteBatchedStatements=true option to buffer data to the thread context buffer. The write request is triggered only when the data volume in the buffer reaches the specified threshold.

    +

    DataX

    +
    +

    Note

    +

    To execute the entire task, you must have permission to execute insert into .... Whether other permissions are required depends on the preSql and postSql in your task configuration.

    +
    +

    MatrixOneWriter mainly aims at ETL development engineers who use MatrixOneWriter to import data from data warehouses into MatrixOne. At the same time, MatrixOneWriter can also serve as a data migration tool for users such as DBAs.

    +

    Before you start

    +

    Before using DataX to write data to MatrixOne, you need to complete the installation of the following software:

    + +

    Steps

    +

    Create a MatrixOne Table

    +

    Connect to MatrixOne using the MySQL Client and create a test table in MatrixOne:

    +
    CREATE DATABASE mo_demo;
    +USE mo_demo;
    +CREATE TABLE m_user(
    +    M_ID INT NOT NULL,
    +    M_NAME CHAR(25) NOT NULL
    +);
    +
    +

    Configure the Data Source

    +

    In this example, we use data generated in memory as the data source:

    +
    "reader": {
    +   "name": "streamreader",  
    +   "parameter": {
    +       "column" : [ # You can write multiple columns
    +           {
    +               "value": 20210106,   # Represents the value of this column
    +               "type": "long"       # Represents the type of this column
    +           },
    +           {
    +               "value": "matrixone",
    +               "type": "string"
    +           }
    +       ],
    +       "sliceRecordCount": 1000     # Indicates how many times to print
    +   }
    +}
    +
    +

    Write the Job Configuration File

    +

    Use the following command to view the configuration template:

    +
    python datax.py -r {YOUR_READER} -w matrixonewriter
    +
    +

    Write the job configuration file stream2matrixone.json:

    +
    {
    +    "job": {
    +        "setting": {
    +            "speed": {
    +                "channel": 1
    +            }
    +        },
    +        "content": [
    +            {
    +                 "reader": {
    +                    "name": "streamreader",
    +                    "parameter": {
    +                        "column" : [
    +                            {
    +                                "value": 20210106,
    +                                "type": "long"
    +                            },
    +                            {
    +                                "value": "matrixone",
    +                                "type": "string"
    +                            }
    +                        ],
    +                        "sliceRecordCount": 1000
    +                    }
    +                },
    +                "writer": {
    +                    "name": "matrixonewriter",
    +                    "parameter": {
    +                        "writeMode": "insert",
    +                        "username": "root",
    +                        "password": "111",
    +                        "column": [
    +                            "M_ID",
    +                            "M_NAME"
    +                        ],
    +                        "preSql": [
    +                            "delete from m_user"
    +                        ],
    +                        "connection": [
    +                            {
    +                                "jdbcUrl": "jdbc:mysql://127.0.0.1:6001/mo_demo",
    +                                "table": [
    +                                    "m_user"
    +                                ]
    +                            }
    +                        ]
    +                    }
    +                }
    +            }
    +        ]
    +    }
    +}
    +
    +

    Start DataX

    +

    Execute the following command to start DataX:

    +
    $ cd {YOUR_DATAX_DIR_BIN}
    +$ python datax.py stream2matrixone.json
    +
    +

    View the Results

    +

    Connect to MatrixOne using the MySQL Client and use select to query the inserted results. The 1000 records in memory have been successfully written to MatrixOne.

    +
    mysql> select * from m_user limit 5;
    ++----------+-----------+
    +| m_id     | m_name    |
    ++----------+-----------+
    +| 20210106 | matrixone |
    +| 20210106 | matrixone |
    +| 20210106 | matrixone |
    +| 20210106 | matrixone |
    +| 20210106 | matrixone |
    ++----------+-----------+
    +5 rows in set (0.01 sec)
    +
    +mysql> select count(*) from m_user limit 5;
    ++----------+
    +| count(*) |
    ++----------+
    +|     1000 |
    ++----------+
    +1 row in set (0.00 sec)
    +
    +

    Parameter Descriptions

    +

    Here are some commonly used parameters for MatrixOneWriter:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Parameter NameParameter DescriptionMandatoryDefault Value
    jdbcUrlJDBC connection information for the target database. DataX will append some attributes to the provided jdbcUrl during runtime, such as yearIsDateType=false&zeroDateTimeBehavior=CONVERT_TO_NULL&rewriteBatchedStatements=true&tinyInt1isBit=false&serverTimezone=Asia/Shanghai.YesNone
    usernameUsername for the target database.YesNone
    passwordPassword for the target database.YesNone
    tableName of the target table. Supports writing to one or more tables. If configuring multiple tables, make sure their structures are consistent.YesNone
    columnFields in the target table that must be written with data, separated by commas. For example: "column": ["id","name","age"]. To write all columns, you can use *, for example: "column": ["*"].YesNone
    preSqlStandard SQL statements to be executed before writing data to the target table.NoNone
    postSqlStandard SQL statements to be executed after writing data to the target table.NoNone
    writeModeControls the SQL statements used when writing data to the target table. You can choose insert or update.insert or updateinsert
    batchSizeSize of records for batch submission. This can significantly reduce network interactions between DataX and MatrixOne, improving overall throughput. However, setting it too large may cause DataX to run out of memory.No1024
    +

    Type Conversion

    +

    MatrixOneWriter supports most MatrixOne data types, but a few types still need to be supported, so you need to pay special attention to your data types.

    +

    Here is a list of type conversions that MatrixOneWriter performs for MatrixOne data types:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    DataX Internal TypeMatrixOne Data Type
    Longint, tinyint, smallint, bigint
    Doublefloat, double, decimal
    Stringvarchar, char, text
    Datedate, datetime, timestamp, time
    Booleanbool
    Bytesblob
    +

    Additional References

    +
      +
    • +

      MatrixOne is compatible with the MySQL protocol. MatrixOneWriter is a modified version of the MySQL Writer with adjustments for JDBC driver versions. You can still use the MySQL Writer to write to MatrixOne.

      +
    • +
    • +

      To add the MatrixOne Writer in DataX, you need to download matrixonewriter.zip and unzip it into the plugin/writer/ directory in the root directory of your DataX project.

      +
    • +
    +

    Ask and Questions

    +

    Q: During runtime, I encountered the error "Configuration information error, the configuration file you provided /{YOUR_MATRIXONE_WRITER_PATH}/plugin.json does not exist." What should I do?

    +

    A: DataX attempts to find the plugin.json file by searching for similar folders when it starts. If the matrixonewriter.zip file also exists in the same directory, DataX will try to find it in .../datax/plugin/writer/matrixonewriter.zip/plugin.json. In the MacOS environment, DataX will also attempt to see it in .../datax/plugin/writer/.DS_Store/plugin.json. In this case, you need to delete these extra files or folders.

    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/index.html b/dev/MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/index.html new file mode 100644 index 000000000..a2c58a81b --- /dev/null +++ b/dev/MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/index.html @@ -0,0 +1,9870 @@ + + + + + + + + + + + + + + + + + + + + + + Writing Data to MatrixOne Using SeaTunnel - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    Writing Data to MatrixOne Using SeaTunnel

    +

    Overview

    +

    SeaTunnel is a distributed, high-performance, and highly scalable data integration platform that focuses on synchronizing and transforming massive data, including offline and real-time data. MatrixOne supports using SeaTunnel to synchronize data from other databases and can efficiently handle hundreds of billions of records.

    +

    This document will explain how to use SeaTunnel to write data to MatrixOne.

    +

    Before you start

    +

    Before using SeaTunnel to write data to MatrixOne, make sure to complete the following preparations:

    +
      +
    • +

      Install and start MatrixOne by following the steps in Install and Start MatrixOne.

      +
    • +
    • +

      Install SeaTunnel Version 2.3.3 by downloading it from here. After installation, you can define the installation path of SeaTunnel using a shell command:

      +
    • +
    +
    export SEATNUNNEL_HOME="/root/seatunnel"
    +
    +

    Steps

    +

    Create Test Data

    +
      +
    1. +

      Create a MySQL database named test1 and create a table named test_table within it. Store this in a file named mysql.sql under the root directory. Here's the MySQL DDL statement:

      +
      create database test1;
      +use test1;
      +CREATE TABLE `test_table` (
      +  `name` varchar(255) DEFAULT NULL,
      +  `age` int(11) DEFAULT NULL
      +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
      +
      +
    2. +
    3. +

      Use the mo_ctl tool to import the MySQL DDL statements into MatrixOne directly. Execute the following command:

      +
      mo_ctl sql /root/mysql.sql
      +
      +
    4. +
    +

    Install the Connectors Plugin

    +

    This document will explain how to use SeaTunnel's connector-jdbc connection plugin to connect to MatrixOne.

    +
      +
    1. +

      In the ${SEATNUNNEL_HOME}/config/plugin_config file of SeaTunnel, add the following content:

      +
      --connectors-v2--
      +connector-jdbc
      +--end--
      +
      +
    2. +
    3. +

      SeaTunnel binary package version 2.3.3 does not provide connector dependencies by default. You need to install the connectors when using SeaTunnel for the first time by running the following command:

      +
      sh bin/install-plugin.sh 2.3.3
      +
      +

      Note: This document uses the SeaTunnel engine to write data to MatrixOne without relying on Flink or Spark.

      +
    4. +
    +

    Define the Task Configuration File

    +

    In this document, we use the test_table table in the MySQL database as the data source, and we write data directly to the test_table table in the MatrixOne database without data processing.

    +

    Due to data compatibility issues, you need to configure the task configuration file ${SEATNUNNEL_HOME}/config/v2.batch.config.template, which defines how SeaTunnel handles data input, processing, and output logic after it starts.

    +

    Edit the configuration file with the following content:

    +
    env {
    +  execution.parallelism = 2
    +  job.mode = "BATCH"
    +}
    +
    +source {
    +    Jdbc {
    +        url = "jdbc:mysql://192.168.110.40:3306/test"
    +        driver = "com.mysql.cj.jdbc.Driver"
    +        connection_check_timeout_sec = 100
    +        user = "root"
    +        password = "123456"
    +        query = "select * from test_table"
    +    }
    +}
    +
    +transform {
    +
    +}
    +
    +sink {
    +   jdbc {
    +        url = "jdbc:mysql://192.168.110.248:6001/test"
    +        driver = "com.mysql.cj.jdbc.Driver"
    +        user = "root"
    +        password = "111"
    +        query = "insert into test_table(name,age) values(?,?)"
    +   }
    +}
    +
    +

    Install Database Dependencies

    +

    Download mysql-connector-java-8.0.33.jar and copy the file to the ${SEATNUNNEL_HOME}/plugins/jdbc/lib/ directory.

    +

    Run the SeaTunnel Application

    +

    Execute the following command to start the SeaTunnel application:

    +
    ./bin/seatunnel.sh --config ./config/v2.batch.config.template -e local
    +
    +

    View the Results

    +

    After SeaTunnel finishes running, it will display statistics similar to the following, summarizing the time taken for this write operation, the total number of data read, the total number of writes, and the total number of write failures:

    +
    ***********************************************
    +           Job Statistic Information
    +***********************************************
    +Start Time                : 2023-08-07 16:45:02
    +End Time                  : 2023-08-07 16:45:05
    +Total Time(s)             :                   3
    +Total Read Count          :             5000000
    +Total Write Count         :             5000000
    +Total Failed Count        :                   0
    +***********************************************
    +
    +

    You have successfully synchronized data from a MySQL database into the MatrixOne database.

    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Develop/Ecological-Tools/dolphinScheduler/index.html b/dev/MatrixOne/Develop/Ecological-Tools/dolphinScheduler/index.html new file mode 100644 index 000000000..00ed77d1a --- /dev/null +++ b/dev/MatrixOne/Develop/Ecological-Tools/dolphinScheduler/index.html @@ -0,0 +1,9796 @@ + + + + + + + + + + + + + + + + + + + + + + Connecting MatrixOne with DolphinScheduler - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    Connecting MatrixOne with DolphinScheduler

    +

    Overview

    +

    Apache DolphinScheduler is a distributed, highly scalable open-source system for visual DAG (Directed Acyclic Graph) workflow task scheduling. It provides a solution for visually orchestrating tasks, workflows, and the entire data processing lifecycle.

    +

    The main goal of Apache DolphinScheduler is to address complex dependencies in large-scale data tasks. It assembles tasks streamingly using DAGs, allowing real-time monitoring of task execution status and supporting operations such as task retries, specifying node recovery for failures, and pausing, resuming, and terminating tasks.

    +

    MatrixOne supports integration with DolphinScheduler, a visual DAG workflow task scheduling system. This document will guide you on connecting MatrixOne to DolphinScheduler and creating task workflows.

    +

    Before you start

    + +

    Operating Steps

    +

    Step 1: Configure the MySQL Driver

    +
      +
    1. +

      Download the MySQL driver and copy it to the libs directory:

      +

      After installation, you need to manually download the mysql-connector-java driver (version 8.0.16). Then, copy it to four directories in the DolphinScheduler installation directory: api-server/libs, alert-server/libs, master-server/libs, and worker-server/libs.

      +
      +

      Note

      +

      It is recommended to use mysql-connector-java-8.0.16.jar as the MySQL driver package.

      +
      +
    2. +
    3. +

      Restart DolphinScheduler:

      +

      After copying the driver package, you need to restart the DolphinScheduler service. First, go to the DolphinScheduler installation directory and then execute the following command to restart the DolphinScheduler service:

      +
      # Stop the Standalone Server service
      +bash ./bin/dolphinscheduler-daemon.sh stop standalone-server
      +# Start the Standalone Server service
      +bash ./bin/dolphinscheduler-daemon.sh start standalone-server
      +
      +
    4. +
    5. +

      Log in to DolphinScheduler:

      +

      Use the default username admin and password dolphinscheduler123. Access the DolphinScheduler web user interface by visiting http://ip:12345/dolphinscheduler/ui, as shown below:

      +

      image-20230809145317885

      +
    6. +
    7. +

      Create a Data Source:

      +

      Click on Data Source Center > Create Data Source and enter the MatrixOne data connection information. Afterward, click on Test Connection; if the connection is successful, click OK to save it:

      +

      image-20230809145935857

      +
    8. +
    +

    Step 2: Create a Project Workflow

    +
      +
    1. +

      Create a Tenant:

      +

      In the Security Center, click on Create Tenant and enter the tenant name, as shown below:

      +

      image-20230809160632965

      +
      +

      Note

      +

      In a production environment, it is not recommended to use root as the tenant.

      +
      +
    2. +
    3. +

      Create a Project:

      +

      In Project Management, click on Create Project and enter the project name, as shown below:

      +

      image-20230809150528364

      +
    4. +
    5. +

      Create a Workflow and Add Nodes:

      +

      Click on the Project Name created in the previous step and then click on Create Workflow. Drag the SQL node from the left to the canvas on the right. Fill in the Node Name, Data Source Information, SQL Type, and SQL Statement, then click OK. As shown below:

      +

      The node created in this step is for creating a table, and the SQL statement is used to create a table.

      +

      image-20230809151554568

      +

      Next, create Insert Data and Query Data nodes in a similar way. The dependency relationship between these three nodes is shown below, and you can manually connect them:

      +

      image-20230809153149428

      +

      The SQL statements for these three nodes are as follows:

      +
      #create_table
      +
      +CREATE TABLE IF NOT EXISTS test_table (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL)
      +
      +#insert_data
      +
      +INSERT INTO test_table (name) VALUES ('John Doe')
      +
      +#select_data
      +
      +SELECT * FROM test_table
      +
      +

      Connect these three nodes based on their dependency relationship, then click Save. Enter the Workflow Name, select the previously created Tenant, choose Parallel as the execution policy, and click OK.

      +

      image-20230809161503945

      +

      Once the workflow is created, you can see it in the Workflow Relations page with the status "Workflow Offline":

      +

      image-20230809161909925

      +

      Similarly, you can also see the defined workflow in the Workflow Definitions page with the status "Offline":

      +

      image-20230809162411368

      +
    6. +
    7. +

      Publish and Run the Workflow:

      +

      A workflow must be published before it can be run. Click the Publish button to publish the workflow created earlier:

      +

      image-20230809162245088

      +

      After publishing, the workflow status will appear as follows:

      +

      image-20230809163722777

      +

      Next, click the Run button, set the configuration parameters before starting, and then click OK:

      +

      image-20230809162828049

      +

      Finally, return to the Project Overview to check whether the workflow and the three tasks below it have run successfully, as shown below:

      +

      image-20230809163533339

      +
    8. +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Develop/Publish-Subscribe/multi-account-overview/index.html b/dev/MatrixOne/Develop/Publish-Subscribe/multi-account-overview/index.html index a2649606c..dd32acb5d 100644 --- a/dev/MatrixOne/Develop/Publish-Subscribe/multi-account-overview/index.html +++ b/dev/MatrixOne/Develop/Publish-Subscribe/multi-account-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2188,6 +2188,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9337,6 +9557,11 @@ + + + + + @@ -9427,7 +9652,7 @@

    Account-to-Account Publish/Subscrib
    - + diff --git a/dev/MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/index.html b/dev/MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/index.html index ace618a64..0690a60b5 100644 --- a/dev/MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/index.html +++ b/dev/MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2249,6 +2249,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9459,6 +9679,11 @@ + + + + + @@ -9736,7 +9961,7 @@

    Subscriber Reference

    - + diff --git a/dev/MatrixOne/Develop/Transactions/common-transaction-overview/index.html b/dev/MatrixOne/Develop/Transactions/common-transaction-overview/index.html index 58999ff96..e94fe50a2 100644 --- a/dev/MatrixOne/Develop/Transactions/common-transaction-overview/index.html +++ b/dev/MatrixOne/Develop/Transactions/common-transaction-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2222,6 +2222,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9405,6 +9625,11 @@ + + + + + @@ -9649,7 +9874,7 @@

    Transaction Isolation

    - + diff --git a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/index.html b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/index.html index c64689e8a..4d48776b9 100644 --- a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/index.html +++ b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/index.html @@ -15,7 +15,7 @@ - + @@ -2190,6 +2190,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9533,7 +9758,7 @@

    Cross-Database Transaction
    - + diff --git a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/index.html b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/index.html index e8323c165..c38fc923e 100644 --- a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/index.html +++ b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/index.html @@ -15,7 +15,7 @@ - + @@ -2206,6 +2206,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9420,7 +9645,7 @@

    Switch Transaction Mode

    Note: If you only add the transaction mode parameter mode = "optimistic", but do not add isolation = "SI", the system will default to SI isolation in the optimistic transaction mode.

    Restart MatrixOne to make the switched transaction mode take effect.

    -

    For more information on the configuration parameters, see Distributed Common Parameters Configuration.

    +

    For more information on the configuration parameters, see Distributed Common Parameters Configuration.

    @@ -9496,7 +9721,7 @@

    Switch Transaction Mode

    - + diff --git a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/index.html b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/index.html index 586771735..18fc3b3b4 100644 --- a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/index.html +++ b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/index.html @@ -15,7 +15,7 @@ - + @@ -2203,6 +2203,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9365,6 +9585,11 @@ + + + + + @@ -9617,7 +9842,7 @@

    Implicit Transactions Example

    - + diff --git a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/index.html b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/index.html index 67c80d9d2..1def78ab9 100644 --- a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/index.html +++ b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/index.html @@ -15,7 +15,7 @@ - + @@ -2223,6 +2223,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9405,6 +9625,11 @@ + + + + + @@ -9625,7 +9850,7 @@

    Snapshot Isolation Example

    - + diff --git a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/mvcc/index.html b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/mvcc/index.html index 4c58dd1e2..da8a45306 100644 --- a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/mvcc/index.html +++ b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/mvcc/index.html @@ -15,7 +15,7 @@ - + @@ -2145,6 +2145,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9265,6 +9485,11 @@ + + + + + @@ -9350,7 +9575,7 @@

    MVCC

    - + diff --git a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/index.html b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/index.html index 8c7aac75c..40826e345 100644 --- a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/index.html +++ b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/index.html @@ -15,7 +15,7 @@ - + @@ -2196,6 +2196,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9351,6 +9571,11 @@ + + + + + @@ -9553,7 +9778,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/index.html b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/index.html index 52232d694..81466b648 100644 --- a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/index.html +++ b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/index.html @@ -15,7 +15,7 @@ - + @@ -2245,6 +2245,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9449,6 +9669,11 @@ + + + + + @@ -9619,7 +9844,7 @@

    Snapshot Isolation

    - + diff --git a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/index.html b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/index.html index 38c24387a..b205a612f 100644 --- a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/index.html +++ b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/index.html @@ -15,7 +15,7 @@ - + @@ -2203,6 +2203,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9365,6 +9585,11 @@ + + + + + @@ -9571,7 +9796,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/scenario/index.html b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/scenario/index.html index 92fee50b2..121f8b5e9 100644 --- a/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/scenario/index.html +++ b/dev/MatrixOne/Develop/Transactions/matrixone-transaction-overview/scenario/index.html @@ -15,7 +15,7 @@ - + @@ -2147,6 +2147,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9267,6 +9487,11 @@ + + + + + @@ -9356,7 +9581,7 @@

    Transaction ascenarios in MatrixOne
    - + diff --git a/dev/MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/index.html b/dev/MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/index.html index 8b3fe780f..f95fe41f9 100644 --- a/dev/MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/index.html +++ b/dev/MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/index.html @@ -15,7 +15,7 @@ - + @@ -2208,6 +2208,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9377,6 +9597,11 @@ + + + + + @@ -9539,7 +9764,7 @@

    Test the SSL configuration

    - + diff --git a/dev/MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/index.html b/dev/MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/index.html index 1ca107e36..36b355f9e 100644 --- a/dev/MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/index.html +++ b/dev/MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/index.html @@ -15,7 +15,7 @@ - + @@ -2195,6 +2195,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9351,6 +9571,11 @@ + + + + + @@ -9537,7 +9762,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Develop/connect-mo/database-client-tools/index.html b/dev/MatrixOne/Develop/connect-mo/database-client-tools/index.html index 27285c1e0..40ba3337c 100644 --- a/dev/MatrixOne/Develop/connect-mo/database-client-tools/index.html +++ b/dev/MatrixOne/Develop/connect-mo/database-client-tools/index.html @@ -15,7 +15,7 @@ - + @@ -2195,6 +2195,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9351,6 +9571,11 @@ + + + + + @@ -9542,7 +9767,7 @@

    Connect to the MatrixOn
    - + diff --git a/dev/MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/index.html b/dev/MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/index.html index d44c7e196..4d7c73861 100644 --- a/dev/MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/index.html +++ b/dev/MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/index.html @@ -15,7 +15,7 @@ - + @@ -2190,6 +2190,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9491,7 +9716,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/index.html b/dev/MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/index.html index 942e07362..8acb67b0d 100644 --- a/dev/MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/index.html +++ b/dev/MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/index.html @@ -15,7 +15,7 @@ - + @@ -2223,6 +2223,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9405,6 +9625,11 @@ + + + + + @@ -9578,7 +9803,7 @@

    2. Add Configuration

    - + diff --git a/dev/MatrixOne/Develop/connect-mo/python-connect-to-matrixone/index.html b/dev/MatrixOne/Develop/connect-mo/python-connect-to-matrixone/index.html index 4d33c4fe6..ab2558adc 100644 --- a/dev/MatrixOne/Develop/connect-mo/python-connect-to-matrixone/index.html +++ b/dev/MatrixOne/Develop/connect-mo/python-connect-to-matrixone/index.html @@ -15,7 +15,7 @@ - + @@ -2195,6 +2195,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9351,6 +9571,11 @@ + + + + + @@ -9544,7 +9769,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Develop/develop-overview/index.html b/dev/MatrixOne/Develop/develop-overview/index.html index 52e8b0f41..e524563c2 100644 --- a/dev/MatrixOne/Develop/develop-overview/index.html +++ b/dev/MatrixOne/Develop/develop-overview/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9270,6 +9490,11 @@ + + + + + @@ -9330,7 +9555,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Develop/export-data/modump/index.html b/dev/MatrixOne/Develop/export-data/modump/index.html index 5404a5dd8..36e61b471 100644 --- a/dev/MatrixOne/Develop/export-data/modump/index.html +++ b/dev/MatrixOne/Develop/export-data/modump/index.html @@ -15,7 +15,7 @@ - + @@ -2208,6 +2208,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9377,6 +9597,11 @@ + + + + + @@ -9540,7 +9765,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Develop/export-data/select-into-outfile/index.html b/dev/MatrixOne/Develop/export-data/select-into-outfile/index.html index 06ca0b2ad..382e203ac 100644 --- a/dev/MatrixOne/Develop/export-data/select-into-outfile/index.html +++ b/dev/MatrixOne/Develop/export-data/select-into-outfile/index.html @@ -15,7 +15,7 @@ - + @@ -2201,6 +2201,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9363,6 +9583,11 @@ + + + + + @@ -9510,7 +9735,7 @@

    Steps

    - + diff --git a/dev/MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/index.html b/dev/MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/index.html new file mode 100644 index 000000000..4b2ac6152 --- /dev/null +++ b/dev/MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/index.html @@ -0,0 +1,9920 @@ + + + + + + + + + + + + + + + + + + Load data from S3 - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    Load data from S3

    +

    Overview

    +

    S3 (Simple Storage Service) object storage refers to Amazon's Simple Storage Service. You can also store almost any type and size of data with S3-compatible object storage, including data lakes, cloud-native applications, and mobile apps. If you are unfamiliar with S3 object service, you may look up some basic introductions in AWS.

    +

    AWS S3 has been remarkably successful for over a decade, so it became the de facto standard for object storage. Thus almost every mainstream public cloud vendors provide an S3-compatible object storage service.

    +

    MatrixOne supports loading files from S3-compatible object storage services into databases. MatrixOne supports AWS and mainstream cloud vendors in China (Alibaba Cloud, Tencent Cloud).

    +

    In MatrixOne, there are two methods to import the data from S3-compatible object storage:

    +
      +
    • Use Load data with an s3option to load the file into MatrixOne. This method will load the data into MatrixOne, and all next queries will happen inside MatrixOne.
    • +
    • Create an external table with an s3option mapping to an S3 file, and query this external table directly. This method allows data access through an S3-compatible object storage service; each query's networking latency will be counted.
    • +
    +

    When importing data from public clouds like AWS S3 or Alibaba Cloud OSS, the appropriate access permissions are required. Generally, there are two methods to choose from: role-based access and key-based access.

    +
      +
    • +

      Role-Based Access: This involves creating a specific role within the public cloud account where the data is stored. This role is authorized to grant MatrixOne applications the necessary data access permissions. This approach is more secure and offers greater ease in managing and adjusting data access permissions.

      +
    • +
    • +

      Key-Based Access: Data can be accessed using the Access Key ID and Secret Access Key of a user with the required data access permissions. While this method is relatively straightforward, it is less secure because exposing the Access Key ID and Secret Access Key could lead to severe consequences.

      +
    • +
    +

    Method 1: LOAD DATA

    +

    Syntax

    +
    LOAD DATA
    +    | URL s3options {"endpoint"='<string>', "access_key_id"='<string>', "secret_access_key"='<string>', "bucket"='<string>', "role_arn"='xxxx', "external_id"='yyy', "filepath"='<string>', "region"='<string>', "compression"='<string>'}
    +    INTO TABLE tbl_name
    +    [{FIELDS | COLUMNS}
    +        [TERMINATED BY 'string']
    +        [[OPTIONALLY] ENCLOSED BY 'char']
    +        [ESCAPED BY 'char']
    +    ]
    +    [IGNORE number {LINES | ROWS}]
    +    [PARALLEL {'TRUE' | 'FALSE'}]
    +
    +

    Parameter Description

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterDescription
    endpointThe URL that can connect to the object storage service. For example: s3.us-west-2.amazonaws.com
    Note: LOAD DATA supports only URLs for AWS object storage services and Alibaba Cloud external object storage services.
    access_key_idAccess key ID used for authentication.
    secret_access_keySecret access key associated with the access key ID.
    bucketSpecifies the bucket in S3 storage.
    role_arnThe Amazon Resource Name (ARN) of an AWS role, typically used for cross-account access.
    Note: It is recommended to use role-based access. If you choose role-based access, you do not need to fill in access_key_id and secret_access_key. Only the role_arn parameter needs to be provided.
    external_idAn external ID used in conjunction with the role ARN.
    filepathrelative file path. regex expression is supported as /files/*.csv.
    regionobject storage service region
    compressionCompressed format of S3 files. If empty or "none", it indicates uncompressed files. Supported fields or Compressed format are "auto", "none", "gzip", "bz2", and "lz4".
    +

    The other paramaters are identical to a ordinary LOAD DATA, see LOAD DATA for more details.

    +

    Statement Examples

    +
      +
    • Role-Based Access
    • +
    +
    # LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression
    +LOAD DATA URL s3option{"endpoint"='s3.us-east-1.amazonaws.com', "bucket"='test-load-mo', "role_arn"='xxxx', "filepath"='test.csv', "region"='us-east-1', "compression"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n';
    +
    +# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression
    +LOAD DATA URL s3option{"endpoint"='oss-cn-shanghai.aliyuncs.com', "bucket"='test-load-data', "role_arn"='xxxx', "filepath"='/test/*.csv', "region"='oss-cn-shanghai', "compression"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n';
    +
    +
      +
    • Key-Based Access
    • +
    +
    # LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression
    +LOAD DATA URL s3option{"endpoint"='s3.us-east-1.amazonaws.com', "access_key_id"='XXXXXX', "secret_access_key"='XXXXXX', "bucket"='test-load-mo', "filepath"='test.csv', "region"='us-east-1', "compression"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n';
    +
    +# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression
    +LOAD DATA URL s3option{"endpoint"='oss-cn-shanghai.aliyuncs.com', "access_key_id"='XXXXXX', "secret_access_key"='XXXXXX', "bucket"='test-load-data', "filepath"='/test/*.csv', "region"='oss-cn-shanghai', "compression"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n';
    +
    +# LOAD a csv file from Tencent Cloud COS Shanghai region, test-1252279971 bucket, without bz2 compression
    +LOAD DATA URL s3option{"endpoint"='cos.ap-shanghai.myqcloud.com', "access_key_id"='XXXXXX', "secret_access_key"='XXXXXX', "bucket"='test-1252279971', "filepath"='test.csv.bz2', "region"='ap-shanghai', "compression"='bz2'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n';
    +
    +
    +

    Note

    +

    MatrixOne provides security assurance for S3 authentication information, such as access_key_id and secret_access_key sensitive information will be hidden in the system table (statement_info) records to ensure your account security.

    +
    +

    Tutorial: Load a file from AWS S3

    +

    In this tutorial, we will walk you through the process of loading a .csv file from AWS S3; we assume that you already have an AWS account and already have your data file ready in your S3 service. If you do not already have that, please sign up and upload your data file first; you may check on the AWS S3 official tutorial. The process for Alibaba Cloud OSS and Tencent Cloud COS is similar to AWS S3.

    +
    +

    Note

    +

    This code example does not show account information such as access_key_id and secret_access_key because of account privacy. +You can read this document to understand the main steps; specific data and account information will not be shown.

    +
    +
      +
    1. +

      Enter into AWS S3 > buckets > Create bucket, create a bucket test-loading with a public access and upload the file char_varchar_1.csv.

      +

      +

      public block

      +
    2. +
    3. +

      Get or create your AWS api key. Enter into Your Account Name > Security Credentials.

      +
        +
      • Method 1 - Role-Based Access (Recommended): To obtain your ARN, navigate to Security Credentials:
      • +
      +

      Access Key

      +
        +
      • Method 2 - Key-Based Access (Not Recommended): To get your existing Access Key or create a new one. If you can't access your AWS Access key, you can contact your AWS administrator.
      • +
      +

      +

      Within Security Credentials > Create access key, you can obtain the Access key and Secret access key either from the downloaded credentials or from this web page.

      +

      Access Key

      +

      Retrieve Access Key

      +
    4. +
    5. +

      Launch the MySQL Client, create tables in MatrixOne, for example:

      +
      create database db;
      +use db;
      +drop table if exists t1;
      +create table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));
      +
      +
    6. +
    7. +

      Import the file into MatrixOne:

      +
        +
      • Method 1 - Role-Based Access (Recommended):
      • +
      +
      LOAD DATA URL s3option{"endpoint"='s3.us-east-1.amazonaws.com', "bucket"='test-loading', "role_arn"='xxxx", "filepath"='char_varchar_1.csv', "region"='us-east-1', "compression"='none'} INTO TABLE t1;
      +
      +
        +
      • Method 2 - Key-Based Access (Not Recommended)
      • +
      +
      LOAD DATA URL s3option{"endpoint"='s3.us-east-1.amazonaws.com', "access_key_id"='XXXXXX', "secret_access_key"='XXXXXX', "bucket"='test-loading', "filepath"='char_varchar_1.csv', "region"='us-east-1', "compression"='none'} INTO TABLE t1;
      +
      +
    8. +
    9. +

      After the import is successful, you can run SQL statements to check the result of imported data:

      +
      mysql> select * from t1;
      ++-----------+-----------+-----------+-----------+
      +| col1      | col2      | col3      | col4      |
      ++-----------+-----------+-----------+-----------+
      +| a         | b         | c         | d         |
      +| a         | b         | c         | d         |
      +| 'a'       | 'b'       | 'c'       | 'd'       |
      +| 'a'       | 'b'       | 'c'       | 'd'       |
      +| aa,aa     | bb,bb     | cc,cc     | dd,dd     |
      +| aa,       | bb,       | cc,       | dd,       |
      +| aa,,,aa   | bb,,,bb   | cc,,,cc   | dd,,,dd   |
      +| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |
      +| aa"aa     | bb"bb     | cc"cc     | dd"dd     |
      +| aa"aa     | bb"bb     | cc"cc     | dd"dd     |
      +| aa"aa     | bb"bb     | cc"cc     | dd"dd     |
      +| aa""aa    | bb""bb    | cc""cc    | dd""dd    |
      +| aa""aa    | bb""bb    | cc""cc    | dd""dd    |
      +| aa",aa    | bb",bb    | cc",cc    | dd",dd    |
      +| aa"",aa   | bb"",bb   | cc"",cc   | dd"",dd   |
      +|           |           |           |           |
      +|           |           |           |           |
      +| NULL      | NULL      | NULL      | NULL      |
      +|           |           |           |           |
      +| "         | "         | "         | "         |
      +| ""        | ""        | ""        | ""        |
      ++-----------+-----------+-----------+-----------+
      +21 rows in set (0.03 sec)
      +
      +
    10. +
    +

    Method 2: Specify S3 file to an external table

    +

    Syntax

    +
    create external table t(...) URL s3option{"endpoint"='<string>', "access_key_id"='<string>', "secret_access_key"='<string>', "bucket"='<string>', "filepath"='<string>', "region"='<string>', "compression"='<string>'}     
    +[{FIELDS | COLUMNS}
    +        [TERMINATED BY 'string']
    +        [[OPTIONALLY] ENCLOSED BY 'char']
    +]
    +[IGNORE number {LINES | ROWS}];
    +
    +
    +

    Note

    +

    MatrixOne only supports select on external tables. Delete, insert, and update are not supported.

    +
    +

    Parameter Description

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterDescription
    endpointA endpoint is a URL that can conncect to object storage service. For example: s3.us-west-2.amazonaws.com
    access_key_idAccess key ID
    secret_access_keySecret access key
    bucketS3 Bucket to access
    filepathrelative file path. regex expression is supported as /files/*.csv.
    regionobject storage service region
    compressionCompressed format of S3 files. If empty or "none", it indicates uncompressed files. Supported fields or Compressed format are "auto", "none", "gzip", "bz2", and "lz4".
    +

    The other paramaters are identical to a ordinary LOAD DATA, see LOAD DATA for more details.

    +

    For more information about External Table, see CREATE EXTERNAL TABLE.

    +

    Statement Examples:

    +
    ## Create a external table for a .csv file from AWS S3
    +create external table t1(col1 char(225)) url s3option{"endpoint"='s3.us-east-1.amazonaws.com', "access_key_id"='XXXXXX', "secret_access_key"='XXXXXX', "bucket"='test-loading', "filepath"='test.csv', "region"='us-east-1', "compression"='none'} fields terminated by ',' enclosed by '\"' lines terminated by '\n';
    +
    +## Create a external table for a .csv file compressed with BZIP2 from Tencent Cloud
    +create external table t1(col1 char(225)) url s3option{"endpoint"='cos.ap-shanghai.myqcloud.com', "access_key_id"='XXXXXX', "secret_access_key"='XXXXXX', "bucket"='test-1252279971', "filepath"='test.csv.bz2', "region"='ap-shanghai', "compression"='bz2'} fields terminated by ',' enclosed by '\"' lines terminated by '\n' ignore 1 lines;
    +
    +

    Tutorial: Create an external table with S3 file

    +

    This tutorial will walk you through the whole process of creating an external table with a .csv file from AWS S3.

    +
    +

    Note

    +

    This code example does not show account information such as access_key_id and secret_access_key because of account privacy. +You can read this document to understand the main steps; specific data and account information will not be shown.

    +
    +
      +
    1. +

      Download the data file. Enter into AWS S3 > buckets, create a bucket test-loading with a public access and upload the file char_varchar_1.csv.

      +

      +

      public block

      +
    2. +
    3. +

      Get or create your AWS api key. Enter into Your Account Name > Security Credentials, get your existing Access Key or create a new one.

      +

      +

      Access Key

      +

      You can get the access key id and secret access key from the downloaded credentials or this webpage.

      +

      Retrieve Access Key

      +
    4. +
    5. +

      Launch the MySQL Client, and specify the S3 file to an external table:

      +
      create database db;
      +use db;
      +drop table if exists t1;
      +create external table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225)) url s3option{"endpoint"='s3.us-east-1.amazonaws.com', "access_key_id"='XXXXXX', "secret_access_key"='XXXXXX', "bucket"='test-loading', "filepath"='char_varchar_1.csv', "region"='us-east-1', "compression"='none'} fields terminated by ',' enclosed by '\"' lines terminated by '\n';
      +
      +
    6. +
    7. +

      After the import is successful, you can run SQL statements to check the result of the imported data. You can see that the query speed is significantly slower than querying from a local table.

      +
      select * from t1;
      ++-----------+-----------+-----------+-----------+
      +| col1      | col2      | col3      | col4      |
      ++-----------+-----------+-----------+-----------+
      +| a         | b         | c         | d         |
      +| a         | b         | c         | d         |
      +| 'a'       | 'b'       | 'c'       | 'd'       |
      +| 'a'       | 'b'       | 'c'       | 'd'       |
      +| aa,aa     | bb,bb     | cc,cc     | dd,dd     |
      +| aa,       | bb,       | cc,       | dd,       |
      +| aa,,,aa   | bb,,,bb   | cc,,,cc   | dd,,,dd   |
      +| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |
      +| aa"aa     | bb"bb     | cc"cc     | dd"dd     |
      +| aa"aa     | bb"bb     | cc"cc     | dd"dd     |
      +| aa"aa     | bb"bb     | cc"cc     | dd"dd     |
      +| aa""aa    | bb""bb    | cc""cc    | dd""dd    |
      +| aa""aa    | bb""bb    | cc""cc    | dd""dd    |
      +| aa",aa    | bb",bb    | cc",cc    | dd",dd    |
      +| aa"",aa   | bb"",bb   | cc"",cc   | dd"",dd   |
      +|           |           |           |           |
      +|           |           |           |           |
      +| NULL      | NULL      | NULL      | NULL      |
      +|           |           |           |           |
      +| "         | "         | "         | "         |
      +| ""        | ""        | ""        | ""        |
      ++-----------+-----------+-----------+-----------+
      +21 rows in set (1.32 sec)
      +
      +
    8. +
    9. +

      (Optional)If you need to import external table data into a data table in MatrixOne, you can use the following SQL statement:

      +

      Create a new table t2 in MatrixOne:

      +
      create table t2(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));
      +
      +

      Import the external table t1 to t2:

      +
      insert into t2 select * from t1;
      +
      +
    10. +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/index.html b/dev/MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/index.html index 1a2236c22..d899bc1b0 100644 --- a/dev/MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/index.html +++ b/dev/MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2212,6 +2212,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9381,6 +9601,11 @@ + + + + + @@ -9485,7 +9710,7 @@

    More import capabilities

    - + diff --git a/dev/MatrixOne/Develop/import-data/bulk-load/load-csv/index.html b/dev/MatrixOne/Develop/import-data/bulk-load/load-csv/index.html index 5397f7189..e7de8350e 100644 --- a/dev/MatrixOne/Develop/import-data/bulk-load/load-csv/index.html +++ b/dev/MatrixOne/Develop/import-data/bulk-load/load-csv/index.html @@ -15,7 +15,7 @@ - + @@ -2239,6 +2239,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9435,6 +9655,11 @@ + + + + + @@ -9691,7 +9916,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Develop/import-data/bulk-load/load-jsonline/index.html b/dev/MatrixOne/Develop/import-data/bulk-load/load-jsonline/index.html index e40c1f4c8..10b2caed8 100644 --- a/dev/MatrixOne/Develop/import-data/bulk-load/load-jsonline/index.html +++ b/dev/MatrixOne/Develop/import-data/bulk-load/load-jsonline/index.html @@ -15,7 +15,7 @@ - + @@ -2199,6 +2199,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9681,7 +9906,7 @@

    Tutorial

    - + diff --git a/dev/MatrixOne/Develop/import-data/bulk-load/load-s3/index.html b/dev/MatrixOne/Develop/import-data/bulk-load/load-s3/index.html index 0d38b43fc..25297cbde 100644 --- a/dev/MatrixOne/Develop/import-data/bulk-load/load-s3/index.html +++ b/dev/MatrixOne/Develop/import-data/bulk-load/load-s3/index.html @@ -15,7 +15,7 @@ - + @@ -2232,6 +2232,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9421,6 +9641,11 @@ + + + + + @@ -9770,7 +9995,7 @@

    Tutorial: Create an exte
    - + diff --git a/dev/MatrixOne/Develop/import-data/bulk-load/using-source/index.html b/dev/MatrixOne/Develop/import-data/bulk-load/using-source/index.html index 42af1e6b1..10112274b 100644 --- a/dev/MatrixOne/Develop/import-data/bulk-load/using-source/index.html +++ b/dev/MatrixOne/Develop/import-data/bulk-load/using-source/index.html @@ -15,7 +15,7 @@ - + @@ -2239,6 +2239,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9435,6 +9655,11 @@ + + + + + @@ -9554,7 +9779,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Develop/import-data/delete-data/index.html b/dev/MatrixOne/Develop/import-data/delete-data/index.html index 14e1b5cf6..9c75c19df 100644 --- a/dev/MatrixOne/Develop/import-data/delete-data/index.html +++ b/dev/MatrixOne/Develop/import-data/delete-data/index.html @@ -15,7 +15,7 @@ - + @@ -2222,6 +2222,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9405,6 +9625,11 @@ + + + + + @@ -9634,7 +9859,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Develop/import-data/insert-data/index.html b/dev/MatrixOne/Develop/import-data/insert-data/index.html index 7059f4c90..2089f4641 100644 --- a/dev/MatrixOne/Develop/import-data/insert-data/index.html +++ b/dev/MatrixOne/Develop/import-data/insert-data/index.html @@ -15,7 +15,7 @@ - + @@ -2270,6 +2270,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9499,6 +9719,11 @@ + + + + + @@ -9970,7 +10195,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Develop/import-data/prepared/index.html b/dev/MatrixOne/Develop/import-data/prepared/index.html index 52f70465f..a5e93cb19 100644 --- a/dev/MatrixOne/Develop/import-data/prepared/index.html +++ b/dev/MatrixOne/Develop/import-data/prepared/index.html @@ -15,7 +15,7 @@ - + @@ -2208,6 +2208,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9377,6 +9597,11 @@ + + + + + @@ -9565,7 +9790,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Develop/import-data/update-data/index.html b/dev/MatrixOne/Develop/import-data/update-data/index.html index bd72649c2..dee1e356a 100644 --- a/dev/MatrixOne/Develop/import-data/update-data/index.html +++ b/dev/MatrixOne/Develop/import-data/update-data/index.html @@ -15,7 +15,7 @@ - + @@ -2208,6 +2208,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9377,6 +9597,11 @@ + + + + + @@ -9640,7 +9865,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Develop/read-data/cte/index.html b/dev/MatrixOne/Develop/read-data/cte/index.html index a8410b689..f528edc51 100644 --- a/dev/MatrixOne/Develop/read-data/cte/index.html +++ b/dev/MatrixOne/Develop/read-data/cte/index.html @@ -15,7 +15,7 @@ - + @@ -2181,6 +2181,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9426,7 +9651,7 @@

    Examples of Using CTE Statements

    We used a recursive CTE named EmployeeHierarchy, which first selects top-level managers (MANAGER_ID IS NULL), and then recursively joins to find each employee's direct subordinates while keeping track of the hierarchy level. This allows us to query the detailed information of the employee hierarchy using the CTE.

    The non-recursive CTE example selects basic information of all employees from the EMPLOYEES table, including EMPLOYEE_ID, NAME, and MANAGER_ID.

    The RECURSIVE keyword is needed to declare a recursive CTE.

    -

    For more information on using CTEs, see WITH (Common Table Expressions).

    +

    For more information on using CTEs, see WITH (Common Table Expressions).

    @@ -9502,7 +9727,7 @@

    Examples of Using CTE Statements

    - + diff --git a/dev/MatrixOne/Develop/read-data/multitable-join-query/index.html b/dev/MatrixOne/Develop/read-data/multitable-join-query/index.html index 62e55b7d2..e06406059 100644 --- a/dev/MatrixOne/Develop/read-data/multitable-join-query/index.html +++ b/dev/MatrixOne/Develop/read-data/multitable-join-query/index.html @@ -15,7 +15,7 @@ - + @@ -2228,6 +2228,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9417,6 +9637,11 @@ + + + + + @@ -9853,7 +10078,7 @@

    Implicit join

    - + diff --git a/dev/MatrixOne/Develop/read-data/query-data-single-table/index.html b/dev/MatrixOne/Develop/read-data/query-data-single-table/index.html index 225b4d86f..f0e3d99a0 100644 --- a/dev/MatrixOne/Develop/read-data/query-data-single-table/index.html +++ b/dev/MatrixOne/Develop/read-data/query-data-single-table/index.html @@ -15,7 +15,7 @@ - + @@ -2222,6 +2222,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9405,6 +9625,11 @@ + + + + + @@ -9598,7 +9823,7 @@

    Aggregate queries

    - + diff --git a/dev/MatrixOne/Develop/read-data/subquery/index.html b/dev/MatrixOne/Develop/read-data/subquery/index.html index 18a7b6942..c872a65ca 100644 --- a/dev/MatrixOne/Develop/read-data/subquery/index.html +++ b/dev/MatrixOne/Develop/read-data/subquery/index.html @@ -15,7 +15,7 @@ - + @@ -2221,6 +2221,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9403,6 +9623,11 @@ + + + + + @@ -9697,7 +9922,7 @@

    Correlated subquery

    - + diff --git a/dev/MatrixOne/Develop/read-data/views/index.html b/dev/MatrixOne/Develop/read-data/views/index.html index e3e0b3f05..e0bce4846 100644 --- a/dev/MatrixOne/Develop/read-data/views/index.html +++ b/dev/MatrixOne/Develop/read-data/views/index.html @@ -15,7 +15,7 @@ - + @@ -2222,6 +2222,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9405,6 +9625,11 @@ + + + + + @@ -9558,7 +9783,7 @@

    Drop view

    - + diff --git a/dev/MatrixOne/Develop/read-data/window-function/index.html b/dev/MatrixOne/Develop/read-data/window-function/index.html index 2ecd743fd..f91f0d6fb 100644 --- a/dev/MatrixOne/Develop/read-data/window-function/index.html +++ b/dev/MatrixOne/Develop/read-data/window-function/index.html @@ -15,7 +15,7 @@ - + @@ -2181,6 +2181,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9499,7 +9724,7 @@

    How to use window functions

    - + diff --git a/dev/MatrixOne/Develop/schema-design/1.1-overview/index.html b/dev/MatrixOne/Develop/schema-design/1.1-overview/index.html new file mode 100644 index 000000000..d006ef954 --- /dev/null +++ b/dev/MatrixOne/Develop/schema-design/1.1-overview/index.html @@ -0,0 +1,9715 @@ + + + + + + + + + + + + + + + + + + Database Schema Design Overview - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + + + + + +
    +
    + + + + + + + + + + + + +

    Database Schema Design Overview

    +

    This document provides the basics of MatrixOne database schema design. This document introduces terminology related to MatrixOne databases and subsequent data read and write examples.

    +

    Key concept in MatrixOne

    +

    Database Schema: The database schema mentioned in this article is the same as the logical object database. It is the same as MySQL.

    +

    Database

    +

    A database in MatrixOne is a collection of objects such as tables.

    +

    To view the default database contained by MatrixOne, ues SHOW DATABASES; statment.

    +

    To create a new database, ues CREATE DATABASE database_name; statement.

    +

    Table

    +

    A table is a collection of related data in a database.

    +

    Each table consists of rows and columns. Each value in a row belongs to a specific column. Each column allows only a single data type. To further qualify columns, you can add some constraints.

    +

    Index

    +

    An index is a data structure used to find data in database tables quickly. It can be seen as a 'table of contents' that contains pointers to the data of each row in the table, making it possible for queries to locate data that meets specific conditions more quickly.

    +

    The indexes commonly used in databases include primary key indexes, secondary indexes, etc. Among them, unique indexes are used to ensure the uniqueness of specific columns or combinations of columns, ordinary indexes are used to improve query performance, and full-text indexes are used for full-text search in text data.

    +

    There are two common types of indexes, namely:

    +
      +
    • Primary Key: Primary key index, the index that identifies the primary key column. The primary key index uniquely identifies each row of data in the table.
    • +
    • Secondary index: The secondary index is identified on the non-primary key. The secondary index, a non-clustered index, is used to improve query performance and speed up data retrieval.
    • +
    +

    Note: Currently, MatrixOne only supports Primary Key.

    +

    Vector

    +

    MatrixOne now supports storing and querying vectors. Vector is a numerical array generally produced by AI models, including Large Language Models. These vectors can be seamlessly stored and queried, allowing for tasks like finding nearest neighbors, all while accommodating relational data.

    +

    Note: Currently, MatrixOne only supports inserting and querying vector data.

    +

    For more information, see vector

    +

    Other supported logical objects

    +

    MatrixOne supports the following logical objects at the same level as the table:

    +
      +
    • +

      View: a view acts as a virtual table whose schema is defined by the SELECT statement that creates the view.

      +
    • +
    • +

      Temporary table: a table whose data is not persistent.

      +
    • +
    +

    Access Control

    +

    MatrixOne supports both user-based and role-based access control. To allow users to view, modify, or delete data, for more information, see Access control in MatrixOne.

    +

    Object limitations

    +

    Limitations on identifier length

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Identifier typeMaximum length (number of characters allowed)
    Database64
    Table64
    Column64
    Sequence64
    +

    Limitations on a single table

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    TypeUpper limit (default value)
    ColumnsDefaults to 1017 and can be adjusted up to 4096
    Partitions8192
    Size of a single line6 MB by default
    Size of a single column6 MB
    +

    Limitations on data types

    +

    For more information on data types, see Data Types.

    +

    Number of rows

    +

    MatrixOne supports an unlimited number of rows by adding nodes to the cluster.

    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Develop/schema-design/1.1-vector/index.html b/dev/MatrixOne/Develop/schema-design/1.1-vector/index.html new file mode 100644 index 000000000..cc4a1ea90 --- /dev/null +++ b/dev/MatrixOne/Develop/schema-design/1.1-vector/index.html @@ -0,0 +1,9753 @@ + + + + + + + + + + + + + + + + + + Vectors - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    Vectors

    +

    What Are Vectors

    +

    A vector is a numerical representation that encodes data content, such as text or audio, using embedding models. These vectors can be effectively stored and queried alongside relational data. Vector queries encompass tasks like locating nearest neighbors, which can significantly improve search retrievals, as seen in applications like facial recognition or enhancing Generative AI results.

    +

    Vector database Use Cases

    +

    The database's capability to manage vectors reflects its capacity to store, retrieve, and analyze vector-based data. These vectors often play a pivotal role in complex data analysis, machine learning, and mining projects. Vector databases offer a wide range of versatile use cases:

    +
      +
    • +

      Generative AI Applications: These databases can serve as a backend for Generative AI applications, enabling them to fetch the nearest neighbor results in response to user-provided queries, enhancing the output quality and relevance.

      +
    • +
    • +

      Advanced Object Recognition: They are invaluable for developing advanced object recognition platforms that discern similarities among diverse datasets. This has practical applications in plagiarism detection, facial recognition, and DNA matching.

      +
    • +
    • +

      Personalized Recommendation Systems: Vector databases can be leveraged to augment recommendation systems by incorporating user preferences and choices. This leads to more accurate and tailored recommendations, improving the user experience and engagement.

      +
    • +
    • +

      Anomaly Detection: Vector databases can store feature vectors representing normal behavior. Anomalies can then be detected by comparing incoming vectors to the stored ones. This is useful in cybersecurity and industrial quality control.

      +
    • +
    +

    Before you start

    +

    Before reading this document, make sure that the following tasks are completed:

    + +

    How to Use Vectors

    +

    The syntax for using vectors is the same as that for regular table creation, data insertion, and data querying:

    +

    Creating

    +

    Using the following SQL statement, you can create two vector columns, one of type Float32 and the other of type Float64. You can also set the dimensions for both vector columns to 3.

    +
    create table t1(a int, b vecf32(3), c vecf64(3));
    +
    +

    Inserting

    +

    MatrixOne supports inserting vectors in two formats.

    +

    Textual Format

    +
    insert into t1 values(1, "[1,2,3]", "[4,5,6]");
    +
    +

    Binary Format

    +

    Suppose you are working with Python NumPy arrays. In that case, you can directly insert the NumPy array into MatrixOne by performing hexadecimal encoding on the array instead of converting it into a comma-separated textual format. This approach is faster when inserting vectors with higher dimensions.

    +
    insert into t1 (a, b) values
    +(2, decode("7e98b23e9e10383b2f41133f", "hex"));
    +
    +-- "7e98b23e9e10383b2f41133f" represents the hexadecimal encoding of the little-endian []float32{0.34881967, 0.0028086076, 0.5752134}
    +
    +-- "hex" represents hexadecimal encoding
    +
    +

    Querying

    +

    Vector columns can also be read in two formats.

    +

    Textual Format

    +
    mysql> select a, b from t1;
    ++------+---------------------------------------+
    +| a    | b                                     |
    ++------+---------------------------------------+
    +|    1 | [1, 2, 3]                             |
    +|    2 | [0.34881967, 0.0028086076, 0.5752134] |
    ++------+---------------------------------------+
    +2 rows in set (0.00 sec)
    +
    +

    Binary Format

    +

    The binary format is very useful if you need to directly read the vector result set into a NumPy array with minimal conversion cost.

    +
    mysql> select encode(b, "hex") from t1;
    ++--------------------------+
    +| encode(b, hex)           |
    ++--------------------------+
    +| 0000803f0000004000004040 |
    +| 7e98b23e9e10383b2f41133f |
    ++--------------------------+
    +2 rows in set (0.00 sec)
    +
    +

    Example - Top K Queries

    +

    Top K queries are a database query operation that retrieves the top K data items or records from a database. These queries find application in various scenarios, including recommendation systems, search engines, and data analysis, among other fields.

    +

    First, we create a table named t1 that contains vector data b and insert some sample data. Then, we perform top K queries using the given SQL statements for l1_distance, l2_distance, cosine similarity, and cosine distance, limiting the results to the top 5 matches.

    +
    -- Sample table 't1' with vector data 'b'
    +CREATE TABLE t1 (
    +    id int,
    +    b vecf64(3)
    +);
    +
    +-- Insert some sample data
    +INSERT INTO t1 (id,b) VALUES (1, '[1,2,3]'), (2, '[4,5,6]'), (3, '[2,1,1]'), (4, '[7,8,9]'), (5, '[0,0,0]'), (6, '[3,1,2]');
    +
    +-- Top K Queries using l1_distance
    +SELECT * FROM t1 ORDER BY l1_norm(b - '[3,1,2]') LIMIT 5;
    +
    +-- Top K Queries using l2_distance
    +SELECT * FROM t1 ORDER BY l2_norm(b - '[3,1,2]') LIMIT 5;
    +
    +-- Top K Queries using cosine similarity
    +SELECT * FROM t1 ORDER BY cosine_similarity(b, '[3,1,2]') LIMIT 5;
    +
    +-- Top K Queries using cosine distance
    +SELECT * FROM t1 ORDER BY 1 - cosine_similarity(b, '[3,1,2]') LIMIT 5;
    +
    +

    These queries demonstrate retrieving the top 5 vectors most similar to the given vector [3,1,2] using different distance and similarity measures. With these queries, you can find the data that best matches your target vector based on different measurement criteria.

    +

    Best Practices

    +
      +
    • +

      Casting between Vectors: When casting a vector from one type to another, it is also advisable to specify the dimension. For instance:

      +
      SELECT b + CAST("[1,2,3]" AS vecf32(3)) FROM t1;
      +
      +

      This practice ensures accuracy and consistency in vector-type conversions.

      +
    • +
    • +

      Utilizing Binary Format: To enhance overall insertion performance, consider using binary rather than textual format. Ensure the array is in little-endian format before converting it into hexadecimal encoding. Here's a sample Python code:

      +
      import binascii
      +
      +# 'value' is a NumPy object
      +def to_binary(value):
      +    if value is None:
      +        return value
      +
      +   # Little-endian float array
      +   value = np.asarray(value, dtype='<f')
      +
      +   if value.ndim != 1:
      +       raise ValueError('expected ndim to be 1')
      +
      +   return binascii.b2a_hex(value)
      +
      +

      This approach can significantly improve data insertion efficiency.

      +
    • +
    +

    Constriants

    +
      +
    • Currently, MatrixOne Vector type supports float32 and float64 types.
    • +
    • Vector cannot be Primary Key or Unique Key.
    • +
    • Vector maximum dimension is 65536.
    • +
    +

    Certainly, let's refine the original text in English:

    +

    Reference

    +

    For more documentation on vector functions, see:

    + + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Develop/schema-design/create-database/index.html b/dev/MatrixOne/Develop/schema-design/create-database/index.html index d3a3b2f3a..682b69dcc 100644 --- a/dev/MatrixOne/Develop/schema-design/create-database/index.html +++ b/dev/MatrixOne/Develop/schema-design/create-database/index.html @@ -15,7 +15,7 @@ - + @@ -2202,6 +2202,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9365,6 +9585,11 @@ + + + + + @@ -9486,7 +9711,7 @@

    Rules in database creation

    - + diff --git a/dev/MatrixOne/Develop/schema-design/create-secondary-index/index.html b/dev/MatrixOne/Develop/schema-design/create-secondary-index/index.html index 59246797a..adfa66b4e 100644 --- a/dev/MatrixOne/Develop/schema-design/create-secondary-index/index.html +++ b/dev/MatrixOne/Develop/schema-design/create-secondary-index/index.html @@ -15,7 +15,7 @@ - + @@ -2202,6 +2202,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9365,6 +9585,11 @@ + + + + + @@ -9489,7 +9714,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Develop/schema-design/create-table/index.html b/dev/MatrixOne/Develop/schema-design/create-table/index.html index b3e9988c0..1cb3eae16 100644 --- a/dev/MatrixOne/Develop/schema-design/create-table/index.html +++ b/dev/MatrixOne/Develop/schema-design/create-table/index.html @@ -15,7 +15,7 @@ - + @@ -2270,6 +2270,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9501,6 +9721,11 @@ + + + + + @@ -9823,7 +10048,7 @@

    Guidelines to follow wh
    - + diff --git a/dev/MatrixOne/Develop/schema-design/create-temporary-table/index.html b/dev/MatrixOne/Develop/schema-design/create-temporary-table/index.html index d5411367e..0ce997f74 100644 --- a/dev/MatrixOne/Develop/schema-design/create-temporary-table/index.html +++ b/dev/MatrixOne/Develop/schema-design/create-temporary-table/index.html @@ -15,7 +15,7 @@ - + @@ -2202,6 +2202,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9365,6 +9585,11 @@ + + + + + @@ -9522,7 +9747,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Develop/schema-design/create-view/index.html b/dev/MatrixOne/Develop/schema-design/create-view/index.html index 2d47d1cc5..75d1803ab 100644 --- a/dev/MatrixOne/Develop/schema-design/create-view/index.html +++ b/dev/MatrixOne/Develop/schema-design/create-view/index.html @@ -15,7 +15,7 @@ - + @@ -2202,6 +2202,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9365,6 +9585,11 @@ + + + + + @@ -9525,7 +9750,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/index.html b/dev/MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/index.html index 55058ba2e..ba66f3e3d 100644 --- a/dev/MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/index.html +++ b/dev/MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/index.html @@ -15,7 +15,7 @@ - + @@ -2190,6 +2190,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9475,7 +9700,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/index.html b/dev/MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/index.html index 9717a5130..f20334bba 100644 --- a/dev/MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/index.html +++ b/dev/MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/index.html @@ -15,7 +15,7 @@ - + @@ -2210,6 +2210,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9379,6 +9599,11 @@ + + + + + @@ -9601,7 +9826,7 @@

    Example 3 - Multi-level foreign key - + diff --git a/dev/MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/index.html b/dev/MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/index.html index b7dafffd2..77759a4cc 100644 --- a/dev/MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/index.html +++ b/dev/MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/index.html @@ -15,7 +15,7 @@ - + @@ -2183,6 +2183,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9325,6 +9545,11 @@ + + + + + @@ -9419,7 +9644,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/index.html b/dev/MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/index.html index bdea2bae8..dd68bbae0 100644 --- a/dev/MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/index.html +++ b/dev/MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/index.html @@ -15,7 +15,7 @@ - + @@ -2176,6 +2176,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9311,6 +9531,11 @@ + + + + + @@ -9415,7 +9640,7 @@

    Integrity Constraints Types

    - + diff --git a/dev/MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/index.html b/dev/MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/index.html index 8cf883a91..cd42c984c 100644 --- a/dev/MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/index.html +++ b/dev/MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/index.html @@ -15,7 +15,7 @@ - + @@ -2190,6 +2190,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9469,7 +9694,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/index.html b/dev/MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/index.html index ac96fb0d4..85817ddf9 100644 --- a/dev/MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/index.html +++ b/dev/MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/index.html @@ -15,7 +15,7 @@ - + @@ -2183,6 +2183,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9325,6 +9545,11 @@ + + + + + @@ -9418,7 +9643,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Develop/schema-design/overview/index.html b/dev/MatrixOne/Develop/schema-design/overview/index.html index 79be818de..098c549e4 100644 --- a/dev/MatrixOne/Develop/schema-design/overview/index.html +++ b/dev/MatrixOne/Develop/schema-design/overview/index.html @@ -15,7 +15,7 @@ - + @@ -2250,6 +2250,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9461,6 +9681,11 @@ + + + + + @@ -9629,7 +9854,7 @@

    Number of rows

    - + diff --git a/dev/MatrixOne/FAQs/deployment-faqs/index.html b/dev/MatrixOne/FAQs/deployment-faqs/index.html index 184308164..285b802cb 100644 --- a/dev/MatrixOne/FAQs/deployment-faqs/index.html +++ b/dev/MatrixOne/FAQs/deployment-faqs/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9511,6 +9731,11 @@ + + + + + @@ -9824,7 +10049,7 @@

    - + diff --git a/dev/MatrixOne/FAQs/product-faqs/index.html b/dev/MatrixOne/FAQs/product-faqs/index.html index 612aceab8..850f17069 100644 --- a/dev/MatrixOne/FAQs/product-faqs/index.html +++ b/dev/MatrixOne/FAQs/product-faqs/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9261,6 +9481,11 @@ + + + + + @@ -9378,7 +9603,7 @@

    Product FAQs

    - + diff --git a/dev/MatrixOne/FAQs/sql-faqs/index.html b/dev/MatrixOne/FAQs/sql-faqs/index.html index ead8b2a8c..b59e4ac6e 100644 --- a/dev/MatrixOne/FAQs/sql-faqs/index.html +++ b/dev/MatrixOne/FAQs/sql-faqs/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9261,6 +9481,11 @@ + + + + + @@ -9371,7 +9596,7 @@

    SQL FAQs

    - + diff --git a/dev/MatrixOne/Get-Started/basic-sql/index.html b/dev/MatrixOne/Get-Started/basic-sql/index.html index 2c8d40c3e..c2ff5f27a 100644 --- a/dev/MatrixOne/Get-Started/basic-sql/index.html +++ b/dev/MatrixOne/Get-Started/basic-sql/index.html @@ -15,7 +15,7 @@ - + @@ -2214,6 +2214,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9674,7 +9899,7 @@

    Basic SQL about CREATE, GR
    - + diff --git a/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/index.html b/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/index.html index e7b44db1f..9639e1635 100644 --- a/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/index.html +++ b/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/index.html @@ -15,7 +15,7 @@ - + @@ -2265,6 +2265,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9489,6 +9709,11 @@ + + + + + @@ -9815,7 +10040,7 @@

    Step 5: Connect to MatrixOne

    - + diff --git a/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/index.html b/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/index.html index 29e2333f3..29c674cfc 100644 --- a/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/index.html +++ b/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/index.html @@ -15,7 +15,7 @@ - + @@ -2251,6 +2251,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9461,6 +9681,11 @@ + + + + + @@ -9698,7 +9923,7 @@

    Step 5: Connect to MatrixOne

    - + diff --git a/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/index.html b/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/index.html index 6c8ce7cf8..da71b141d 100644 --- a/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/index.html +++ b/dev/MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/index.html @@ -15,7 +15,7 @@ - + @@ -2210,6 +2210,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9379,6 +9599,11 @@ + + + + + @@ -9557,7 +9782,7 @@

    Connect to MatrixOne

    - + diff --git a/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/index.html b/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/index.html index 0087f0285..6ecfad87c 100644 --- a/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/index.html +++ b/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/index.html @@ -15,7 +15,7 @@ - + @@ -2258,6 +2258,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9475,6 +9695,11 @@ + + + + + @@ -9802,7 +10027,7 @@

    Step 5: Connect to MatrixOne

    - + diff --git a/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/index.html b/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/index.html index f6aa3160a..5c8c56148 100644 --- a/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/index.html +++ b/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/index.html @@ -15,7 +15,7 @@ - + @@ -2264,6 +2264,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9487,6 +9707,11 @@ + + + + + @@ -9736,7 +9961,7 @@

    Step 5: Connect to MatrixOne

    - + diff --git a/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/index.html b/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/index.html index ca651394a..f79ddb340 100644 --- a/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/index.html +++ b/dev/MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/index.html @@ -15,7 +15,7 @@ - + @@ -2210,6 +2210,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9379,6 +9599,11 @@ + + + + + @@ -9571,7 +9796,7 @@

    Connect to MatrixOne

    - + diff --git a/dev/MatrixOne/Get-Started/install-standalone-matrixone/index.html b/dev/MatrixOne/Get-Started/install-standalone-matrixone/index.html index feb7b9780..12bce6d51 100644 --- a/dev/MatrixOne/Get-Started/install-standalone-matrixone/index.html +++ b/dev/MatrixOne/Get-Started/install-standalone-matrixone/index.html @@ -15,7 +15,7 @@ - + @@ -2188,6 +2188,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9337,6 +9557,11 @@ + + + + + @@ -9481,7 +9706,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Maintain/backup-restore/backup-restore-overview/index.html b/dev/MatrixOne/Maintain/backup-restore/backup-restore-overview/index.html index 45633a677..f0fd0638e 100644 --- a/dev/MatrixOne/Maintain/backup-restore/backup-restore-overview/index.html +++ b/dev/MatrixOne/Maintain/backup-restore/backup-restore-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9403,6 +9623,11 @@ + + + + + @@ -9561,7 +9786,7 @@

    Using Command-Line Batch I
    - + diff --git a/dev/MatrixOne/Maintain/backup-restore/key-concepts/index.html b/dev/MatrixOne/Maintain/backup-restore/key-concepts/index.html index 1443863e7..a57733d54 100644 --- a/dev/MatrixOne/Maintain/backup-restore/key-concepts/index.html +++ b/dev/MatrixOne/Maintain/backup-restore/key-concepts/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9499,6 +9719,11 @@ + + + + + @@ -9607,7 +9832,7 @@

    Complete Recovery vs. Incomple
    - + diff --git a/dev/MatrixOne/Maintain/backup-restore/modump-backup-restore/index.html b/dev/MatrixOne/Maintain/backup-restore/modump-backup-restore/index.html index 587db06a1..cf79f4e9b 100644 --- a/dev/MatrixOne/Maintain/backup-restore/modump-backup-restore/index.html +++ b/dev/MatrixOne/Maintain/backup-restore/modump-backup-restore/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9363,16 +9583,21 @@ + + + + +

    Backup and Restore by using mo-dump

    It is essential to back up your databases to recover your data and be up and running again in case problems occur, such as system crashes, hardware failures, or users deleting data by mistake. Backups are also essential as a safeguard before upgrading a MatrixOne installation, and they can be used to transfer a MatrixOne building to another system.

    -

    MatrixOne currently only supports logical backup through the modump utility. modump is a command-line utility used to generate the logical backup of the MatrixOne database. It produces SQL Statements that can be used to recreate the database objects and data. You can look up the syntax and usage guide in the modump chapter.

    +

    MatrixOne currently only supports logical backup through the modump utility. modump is a command-line utility used to generate the logical backup of the MatrixOne database. It produces SQL Statements that can be used to recreate the database objects and data. You can look up the syntax and usage guide in the modump chapter.

    We will take a simple example to walk you through the backup and restore process with the modump utility.

    Steps

    -

    1. Build the modump binary

    -

    For more information on how to build the modump binary, see Build the modump binary.

    +

    1. Build the modump binary

    +

    For more information on how to build the modump binary, see Build the modump binary.

    If the modump binary has been built, you can continue to browse the next chapter Generate the backup of a single database.

    2. Generate the backup of a single database

    We have a database t which is created by the following SQL.

    @@ -9500,7 +9725,7 @@

    3. Restore the backup to Matri
    - + diff --git a/dev/MatrixOne/Maintain/mo-directory-structure/index.html b/dev/MatrixOne/Maintain/mo-directory-structure/index.html index 40d3c6bc6..bf2504b5d 100644 --- a/dev/MatrixOne/Maintain/mo-directory-structure/index.html +++ b/dev/MatrixOne/Maintain/mo-directory-structure/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9261,6 +9481,11 @@ + + + + + @@ -9373,7 +9598,7 @@

    MatrixOne Directory Structure

    - + diff --git a/dev/MatrixOne/Maintain/mo_ctl/index.html b/dev/MatrixOne/Maintain/mo_ctl/index.html index 4ca2036ae..51b52193a 100644 --- a/dev/MatrixOne/Maintain/mo_ctl/index.html +++ b/dev/MatrixOne/Maintain/mo_ctl/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9681,6 +9901,11 @@ + + + + + @@ -10192,7 +10417,7 @@

    watchdog - Keep Alive MatrixOne

    - + diff --git a/dev/MatrixOne/Maintain/mount-data-by-docker/index.html b/dev/MatrixOne/Maintain/mount-data-by-docker/index.html index 655b22928..e95cabf33 100644 --- a/dev/MatrixOne/Maintain/mount-data-by-docker/index.html +++ b/dev/MatrixOne/Maintain/mount-data-by-docker/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9495,7 +9720,7 @@

    Mount the customized config
    - + diff --git a/dev/MatrixOne/Migrate/migrate-from-mysql-to-matrixone/index.html b/dev/MatrixOne/Migrate/migrate-from-mysql-to-matrixone/index.html index 4c89d2652..53fa325a6 100644 --- a/dev/MatrixOne/Migrate/migrate-from-mysql-to-matrixone/index.html +++ b/dev/MatrixOne/Migrate/migrate-from-mysql-to-matrixone/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9551,6 +9771,11 @@ + + + + + @@ -9768,7 +9993,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Migrate/migrate-from-oracle-to-matrixone/index.html b/dev/MatrixOne/Migrate/migrate-from-oracle-to-matrixone/index.html index 4cabd494c..b6d2573af 100644 --- a/dev/MatrixOne/Migrate/migrate-from-oracle-to-matrixone/index.html +++ b/dev/MatrixOne/Migrate/migrate-from-oracle-to-matrixone/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9511,6 +9731,11 @@ + + + + + @@ -9859,7 +10084,7 @@

    Step 3: Check the data

    - + diff --git a/dev/MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/index.html b/dev/MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/index.html index 3283b8131..fd50ecaf2 100644 --- a/dev/MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/index.html +++ b/dev/MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9537,6 +9757,11 @@ + + + + + @@ -9913,7 +10138,7 @@

    Reference example

    - + diff --git a/dev/MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/index.html b/dev/MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/index.html index 3572e5520..98f6d9a43 100644 --- a/dev/MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/index.html +++ b/dev/MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9497,6 +9717,11 @@ + + + + + @@ -9779,7 +10004,7 @@

    Step 3: Check the data

    - + diff --git a/dev/MatrixOne/Migrate/migrate-overview/index.html b/dev/MatrixOne/Migrate/migrate-overview/index.html index f1a4cc60d..2091b7086 100644 --- a/dev/MatrixOne/Migrate/migrate-overview/index.html +++ b/dev/MatrixOne/Migrate/migrate-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9361,6 +9581,11 @@ + + + + + @@ -9456,7 +9681,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/index.html b/dev/MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/index.html new file mode 100644 index 000000000..44ce48dd0 --- /dev/null +++ b/dev/MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/index.html @@ -0,0 +1,9750 @@ + + + + + + + + + + + + + + + + + + MatrixOne Architecture Design - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + + + + + +
    +
    + + + + + + + + + + + + +

    MatrixOne Architecture Design

    +

    MatrixOne Overview

    +

    MatrixOne is a future-oriented hyperconverged cloud & edge native DBMS that supports transactional, analytical, and streaming workload with a simplified and distributed database engine working across multiple datacenters, clouds, edges, and other heterogenous infrastructures. This combination of engines is called HSTAP.

    +

    As a redefinition of the HTAP database, HSTAP aims to meet all the needs of Transactional Processing (TP) and Analytical Processing (AP) within a single database. Compared with the traditional HTAP, HSTAP emphasizes its built-in streaming capability used for connecting TP and AP tables. This provides users with an experience that a database can be used just like a Big Data platform, with which many users are already familiar thanks to the Big Data boom. With minimal integration efforts, MatrixOne frees users from the limitations of Big Data and provides one-stop coverage for all TP and AP scenarios for enterprises.

    +

    MatrixOne Architecture Layers

    +

    MatrixOne implements three independent layers, each with its object units and responsibilities. Different nodes can freely scale, no longer constrained by other layers. These three layers are:

    +

    +
      +
    • Compute Layer: Based on Compute Nodes (CNs), MatrixOne enables serverless computing and transaction processing with its cache, which is capable of random restarts and scaling.
    • +
    • Transaction Layer: Based on Transaction Nodes and Log Services, MatrixOne provides complete logging services and metadata information, with built-in Logtail for recent data storage.
    • +
    • Storage Layer: Full data is stored in object storage, represented by S3, implementing a low-cost, infinitely scalable storage method. A unified File Service enables seamless operations on underlying storage by different nodes.
    • +
    +

    +

    After deciding on TAE as the sole storage engine, multiple design adjustments were made to the fused TAE engine, resulting in the TAE storage engine. This engine has the following advantages:

    +
      +
    • Columnar Storage Management: Uniform columnar storage and compression methods provide inherent performance advantages for OLAP businesses.
    • +
    • Transaction Processing: Shared logs and TN nodes jointly support transaction processing for compute nodes.
    • +
    • Hot and Cold Separation: Using S3 object storage as the target for File Service, each compute node has its cache.
    • +
    +

    +

    The compute engine is based on the fundamental goal of being compatible with MySQL, with higher requirements for node scheduling, execution plans, and SQL capabilities. The high-performance compute engine has both MPP (massively parallel processing) and experimental architecture:

    +
      +
    • MySQL Compatible: Supports MySQL protocol and syntax.
    • +
    • Fused Engine: Rebuilds execution plans based on DAG, capable of executing both TP and AP.
    • +
    • Node Scheduling: Future support for adaptive intra-node and inter-node scheduling, meeting both concurrency and parallelism requirements.
    • +
    • Comprehensive SQL Capability: Supports subqueries, window functions, CTE, and spill memory overflow processing.
    • +
    • Vector Support: Supports vector storage and querying, making it a valuable storage tool for various machine learning applications, including facial recognition, recommendation systems, and genomics analytics.
    • +
    +

    MatrixOne Architecture Design

    +

    The MatrixOne architecture is as follows:

    +

    MatrixOne Architecture

    +

    The architecture of MatrixOne is divided into several layers:

    +

    Cluster Management Layer

    +

    Being responsible for cluster management, it interacts with Kubernetes to obtain resources dynamically when in the cloud-native environment, while in the on-premises deployment, it gets hold of resources based on the configuration. Cluster status is continuously monitored with the role of each node allocated based on resource information. Maintenance works are carried out to ensure that all system components are up and running despite occasional node and network failures. It rebalances the loads on nodes when necessary as well. Major components in this layer are:

    +
      +
    • Prophet Scheduler: take charge of load balancing and node keep-alive.
    • +
    • Resource Manager: being responsible for physical resources provision.
    • +
    +

    Serverless Layer

    +

    Serverless Layer is a general term for a series of stateless nodes, which, as a whole, contains three categories:

    +
      +
    • Background tasks: the most important one is called Offload Worker, which is responsible for offloading expensive compaction tasks and flushing data to S3 storage.
    • +
    • SQL compute nodes: responsible for executing SQL requests, here divided into write nodes and read nodes. The former also provides the ability to read the freshest data.
    • +
    • Stream task processing node: responsible for executing stream processing requests.
    • +
    +

    Log(Reliability) Layer

    +

    As MatrixOne's Single Source of Truth, data is considered as persistently stored in MatrixOne once it is written into the Log Layer. It is built upon our world-class expertise in the Replicated State Machine model to guarantee state-of-the-art high throughput, high availability, and strong consistency for our data. Following a fully modular and disaggregated design by itself, it is also the central component that helps to decouple the storage and compute layers. This in turn earns our architecture much higher elasticity when compared with traditional NewSQL architecture.

    +

    Storage Layer

    +

    The storage layer transforms the incoming data from the Log Layer into an efficient form for future processing and storage. This includes cache maintenance for fast accessing data that has already been written to S3.

    +

    In MatrixOne, TAE (Transactional Analytic Engine) is the primary interface exposed by the Storage Layer, which can support both row and columnar storage together with transaction capabilities. Besides, the Storage Layer includes other internally used storage capabilities as well, e.g. the intermediate storage for streaming.

    +

    Storage Provision Layer

    +

    As an infrastructure agnostic DBMS, MatrixOne stores data in shared storage of S3 / HDFS, or local disks, on-premise servers, hybrid, and any cloud, or even smart devices. The Storage Provision Layer hides such complexity from upper layers by just presenting them with a unified interface for accessing such diversified storage resources.

    +

    MatrixOne System Components

    +

    MatrixOne Component

    +

    In MatrixOne, to achieve the integration of distributed and multi-engine, a variety of different system components are built to complete the functions of the architecture-related layers:

    +

    File Service

    +

    File Service is the component of MatrixOne responsible for reading and writing all storage media. Storage media include memory, disk, object storage, and so on., which provide the following features:

    +
      +
    • File Service provides a unified interface so that reading and writing of different media can use the same interface.
    • +
    • The design of the interface follows the concept of immutable data. After the file is written, no further updates are allowed. The update of the data is realized by generating a new file.
    • +
    • This design simplifies operations such as data caching, migration, and verification and is conducive to improving the concurrency of data operations.
    • +
    • Based on a unified read-write interface, File Service provides a hierarchical cache and a flexible cache strategy to balance read-write speed and capacity.
    • +
    +

    Log Service

    +

    Log Service is a component specially used to process transaction logs in MatrixOne, and it has the following features:

    +
      +
    • The Raft protocol ensures consistency, and multiple copies are used to ensure availability.
    • +
    • Save and process all transaction logs in MatrixOne, ensure that Log Service logs are read and written typically before the transaction is committed, and check and replay the log content when the instance is restarted.
    • +
    • After the transaction is submitted and placed, truncate the content of the Log Service to control the size of the Log Service. The content that remains in the Log Service after truncation is called Logtail.
    • +
    • If multiple Log Service copies are down at the same time, the entire MatrixOne will be down.
    • +
    +

    Transaction Node

    +

    The Transaction Node (TN) is the carrier used to run MatrixOne's distributed storage engine TAE, which provides the following features:

    +
      +
    • Manage metadata information in MatrixOne and transaction log content saved in Log Service.
    • +
    • Receive distributed transaction requests sent by Computing Node (CN), adjudicate the read and write requests of distributed transactions, push transaction adjudication results to CN, and push transaction content to Log Service to ensure the ACID characteristics of transactions.
    • +
    • Generate a snapshot according to the checkpoint in the transaction to ensure the snapshot isolation of the transaction, and release the snapshot information after the transaction ends.
    • +
    +

    Computing Node

    +

    The computing node (CN) is a component of Matrixone that accesses user requests and processes SQL. The toolkit includes the following modules:

    +
      +
    • Frontend, it handles the client SQL protocol, accepts the client's message, parses it to get the executable SQL of MatrixOne, calls other modules to execute the SQL, organizes the query results into a message, and returns it to the client.
    • +
    • Plan, parse the SQL processed by Frontend, generate a logical execution plan based on MatrixOne's calculation engine and send it to Pipeline.
    • +
    • Pipeline, which parses the logical plan, converts the logical plan into an actual execution plan and then runs the execution plan through Pipeline.
    • +
    • Disttae, responsible for specific read and write tasks, including synchronizing Logtail from TN and reading data from S3, and sending the written data to TN.
    • +
    +

    Stream Engine

    +

    Stream Engine is a new component within MatrixOne, serving as an integrated stream engine designed for real-time querying, processing, and enriching data stored in a series of incoming data points, also known as data streams. With Stream Engine, you can employ SQL to define and create streaming processing pipelines, offering real-time data backend services. Additionally, you can utilize SQL to query data within streams and establish connections with non-streaming datasets, thereby further streamlining the data stack.

    +

    Proxy

    +

    The Proxy component is a powerful tool mainly used for load balancing and SQL routing. It has the following functions:

    +
      +
    • Through SQL routing, resource isolation between different accounts is realized, ensuring that the CNs of different accounts will not affect each other.
    • +
    • Through SQL routing, users can do a second split in the resource group of the same account, improving resource utilization.
    • +
    • The load balancing between different CNs is realized in the second split resource group, making the system more stable and efficient.
    • +
    +

    Learn More

    +

    This page outlines the overall architecture design of MatrixOne. For information on other options that are available when trying out MatrixOne, see the following:

    + + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/index.html b/dev/MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/index.html index 77c4e5be9..97d8bcd8c 100644 --- a/dev/MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/index.html +++ b/dev/MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/index.html @@ -15,7 +15,7 @@ - + @@ -2215,6 +2215,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9610,7 +9835,7 @@

    Query Preheating

    - + diff --git a/dev/MatrixOne/Overview/architecture/architecture-logservice/index.html b/dev/MatrixOne/Overview/architecture/architecture-logservice/index.html index e75af7c86..dfee1987b 100644 --- a/dev/MatrixOne/Overview/architecture/architecture-logservice/index.html +++ b/dev/MatrixOne/Overview/architecture/architecture-logservice/index.html @@ -15,7 +15,7 @@ - + @@ -2262,6 +2262,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9485,6 +9705,11 @@ + + + + + @@ -9684,7 +9909,7 @@

    Truncation

    - + diff --git a/dev/MatrixOne/Overview/architecture/architecture-proxy/index.html b/dev/MatrixOne/Overview/architecture/architecture-proxy/index.html index bb2e732e5..08d0ccd95 100644 --- a/dev/MatrixOne/Overview/architecture/architecture-proxy/index.html +++ b/dev/MatrixOne/Overview/architecture/architecture-proxy/index.html @@ -15,7 +15,7 @@ - + @@ -2181,6 +2181,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9435,7 +9660,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Overview/architecture/architecture-tae/index.html b/dev/MatrixOne/Overview/architecture/architecture-tae/index.html index 9f9bd9634..dce642591 100644 --- a/dev/MatrixOne/Overview/architecture/architecture-tae/index.html +++ b/dev/MatrixOne/Overview/architecture/architecture-tae/index.html @@ -15,7 +15,7 @@ - + @@ -2216,6 +2216,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9393,6 +9613,11 @@ + + + + + @@ -9603,7 +9828,7 @@

    MVCC (Multi-Version Concurrency
    - + diff --git a/dev/MatrixOne/Overview/architecture/matrixone-architecture-design/index.html b/dev/MatrixOne/Overview/architecture/matrixone-architecture-design/index.html index cc7141809..57519f701 100644 --- a/dev/MatrixOne/Overview/architecture/matrixone-architecture-design/index.html +++ b/dev/MatrixOne/Overview/architecture/matrixone-architecture-design/index.html @@ -15,7 +15,7 @@ - + @@ -2285,6 +2285,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9531,6 +9751,11 @@ + + + + + @@ -9710,7 +9935,7 @@

    Learn More

    - + diff --git a/dev/MatrixOne/Overview/architecture/streaming/index.html b/dev/MatrixOne/Overview/architecture/streaming/index.html index 1bc0874c9..60d06d48c 100644 --- a/dev/MatrixOne/Overview/architecture/streaming/index.html +++ b/dev/MatrixOne/Overview/architecture/streaming/index.html @@ -15,7 +15,7 @@ - + @@ -2194,6 +2194,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9349,6 +9569,11 @@ + + + + + @@ -9463,7 +9688,7 @@

    Streams

    - + diff --git a/dev/MatrixOne/Overview/feature/cost-effective/index.html b/dev/MatrixOne/Overview/feature/cost-effective/index.html index ed114a0cd..7d72e9d24 100644 --- a/dev/MatrixOne/Overview/feature/cost-effective/index.html +++ b/dev/MatrixOne/Overview/feature/cost-effective/index.html @@ -15,7 +15,7 @@ - + @@ -2209,6 +2209,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9379,6 +9599,11 @@ + + + + + @@ -9491,7 +9716,7 @@

    Compatibility with MySQL

    - + diff --git a/dev/MatrixOne/Overview/feature/feature-overview/index.html b/dev/MatrixOne/Overview/feature/feature-overview/index.html index 7b4cab4aa..966c50819 100644 --- a/dev/MatrixOne/Overview/feature/feature-overview/index.html +++ b/dev/MatrixOne/Overview/feature/feature-overview/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9352,6 +9572,11 @@ + + + + + @@ -9446,7 +9671,7 @@

    Flexible Resource Allocation

    - + diff --git a/dev/MatrixOne/Overview/feature/high-availability/index.html b/dev/MatrixOne/Overview/feature/high-availability/index.html index bb1016c55..33043f275 100644 --- a/dev/MatrixOne/Overview/feature/high-availability/index.html +++ b/dev/MatrixOne/Overview/feature/high-availability/index.html @@ -15,7 +15,7 @@ - + @@ -2236,6 +2236,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9433,6 +9653,11 @@ + + + + + @@ -9546,7 +9771,7 @@

    Proxy

    - + diff --git a/dev/MatrixOne/Overview/feature/key-feature-htap/index.html b/dev/MatrixOne/Overview/feature/key-feature-htap/index.html index fc2ad9e20..2f93feb52 100644 --- a/dev/MatrixOne/Overview/feature/key-feature-htap/index.html +++ b/dev/MatrixOne/Overview/feature/key-feature-htap/index.html @@ -15,7 +15,7 @@ - + @@ -2289,6 +2289,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9539,6 +9759,11 @@ + + + + + @@ -9771,7 +9996,7 @@

    Manufacturing Execution System

    - + diff --git a/dev/MatrixOne/Overview/feature/key-feature-multi-accounts/index.html b/dev/MatrixOne/Overview/feature/key-feature-multi-accounts/index.html index af6ec311c..c5db78d9e 100644 --- a/dev/MatrixOne/Overview/feature/key-feature-multi-accounts/index.html +++ b/dev/MatrixOne/Overview/feature/key-feature-multi-accounts/index.html @@ -15,7 +15,7 @@ - + @@ -2262,6 +2262,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9485,6 +9705,11 @@ + + + + + @@ -9673,7 +9898,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Overview/feature/mysql-compatibility/index.html b/dev/MatrixOne/Overview/feature/mysql-compatibility/index.html index ad78ddf2a..b02eafea8 100644 --- a/dev/MatrixOne/Overview/feature/mysql-compatibility/index.html +++ b/dev/MatrixOne/Overview/feature/mysql-compatibility/index.html @@ -15,7 +15,7 @@ - + @@ -2450,6 +2450,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9861,6 +10081,11 @@ + + + + + @@ -10147,7 +10372,7 @@

    Other support tools

    - + diff --git a/dev/MatrixOne/Overview/feature/scalability/index.html b/dev/MatrixOne/Overview/feature/scalability/index.html index d268c8bfd..d4ef6d0fe 100644 --- a/dev/MatrixOne/Overview/feature/scalability/index.html +++ b/dev/MatrixOne/Overview/feature/scalability/index.html @@ -15,7 +15,7 @@ - + @@ -2188,6 +2188,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9337,6 +9557,11 @@ + + + + + @@ -9447,7 +9672,7 @@

    Advantages

    - + diff --git a/dev/MatrixOne/Overview/matrixone-feature-list/index.html b/dev/MatrixOne/Overview/matrixone-feature-list/index.html index 01d87cdda..9ffbdb57d 100644 --- a/dev/MatrixOne/Overview/matrixone-feature-list/index.html +++ b/dev/MatrixOne/Overview/matrixone-feature-list/index.html @@ -15,7 +15,7 @@ - + @@ -2256,6 +2256,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9475,6 +9695,11 @@ + + + + + @@ -10225,7 +10450,7 @@

    Deployment Method

    - + diff --git a/dev/MatrixOne/Overview/matrixone-introduction/index.html b/dev/MatrixOne/Overview/matrixone-introduction/index.html index 4bf1eb128..6027936b2 100644 --- a/dev/MatrixOne/Overview/matrixone-introduction/index.html +++ b/dev/MatrixOne/Overview/matrixone-introduction/index.html @@ -15,7 +15,7 @@ - + @@ -2241,6 +2241,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9445,6 +9665,11 @@ + + + + + @@ -9647,7 +9872,7 @@

    Learn More

    - + diff --git a/dev/MatrixOne/Overview/whats-new/index.html b/dev/MatrixOne/Overview/whats-new/index.html index f607c7609..de5791a52 100644 --- a/dev/MatrixOne/Overview/whats-new/index.html +++ b/dev/MatrixOne/Overview/whats-new/index.html @@ -15,7 +15,7 @@ - + @@ -2141,6 +2141,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9261,6 +9481,11 @@ + + + + + @@ -9344,7 +9569,7 @@

    What's New

    - + diff --git a/dev/MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/index.html b/dev/MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/index.html index 82dd69fc3..b03c6dc74 100644 --- a/dev/MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/index.html +++ b/dev/MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9290,6 +9510,11 @@ + + + + + @@ -9419,7 +9644,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Performance-Tuning/explain/explain-aggregation/index.html b/dev/MatrixOne/Performance-Tuning/explain/explain-aggregation/index.html index 8c4339dc3..dd403d3e8 100644 --- a/dev/MatrixOne/Performance-Tuning/explain/explain-aggregation/index.html +++ b/dev/MatrixOne/Performance-Tuning/explain/explain-aggregation/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9335,6 +9555,11 @@ + + + + + @@ -9451,7 +9676,7 @@

    Hash Aggregation

    - + diff --git a/dev/MatrixOne/Performance-Tuning/explain/explain-joins/index.html b/dev/MatrixOne/Performance-Tuning/explain/explain-joins/index.html index 1dcb4ad42..8d21021f1 100644 --- a/dev/MatrixOne/Performance-Tuning/explain/explain-joins/index.html +++ b/dev/MatrixOne/Performance-Tuning/explain/explain-joins/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9335,6 +9555,11 @@ + + + + + @@ -9486,7 +9711,7 @@

    Hash Join

    - + diff --git a/dev/MatrixOne/Performance-Tuning/explain/explain-overview/index.html b/dev/MatrixOne/Performance-Tuning/explain/explain-overview/index.html index 4fdbe79df..508c6a746 100644 --- a/dev/MatrixOne/Performance-Tuning/explain/explain-overview/index.html +++ b/dev/MatrixOne/Performance-Tuning/explain/explain-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9337,6 +9557,11 @@ + + + + + @@ -9459,7 +9684,7 @@

    EXPLAIN Example

    - + diff --git a/dev/MatrixOne/Performance-Tuning/explain/explain-subqueries/index.html b/dev/MatrixOne/Performance-Tuning/explain/explain-subqueries/index.html index c2c5c7e3d..5e465694f 100644 --- a/dev/MatrixOne/Performance-Tuning/explain/explain-subqueries/index.html +++ b/dev/MatrixOne/Performance-Tuning/explain/explain-subqueries/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9349,6 +9569,11 @@ + + + + + @@ -9569,7 +9794,7 @@

    Correlated subquery

    - + diff --git a/dev/MatrixOne/Performance-Tuning/explain/explain-views/index.html b/dev/MatrixOne/Performance-Tuning/explain/explain-views/index.html index c7da4198e..c8a32f06a 100644 --- a/dev/MatrixOne/Performance-Tuning/explain/explain-views/index.html +++ b/dev/MatrixOne/Performance-Tuning/explain/explain-views/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9309,6 +9529,11 @@ + + + + + @@ -9462,7 +9687,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Performance-Tuning/explain/explain-walkthrough/index.html b/dev/MatrixOne/Performance-Tuning/explain/explain-walkthrough/index.html index 85563da66..369ea26a9 100644 --- a/dev/MatrixOne/Performance-Tuning/explain/explain-walkthrough/index.html +++ b/dev/MatrixOne/Performance-Tuning/explain/explain-walkthrough/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9375,6 +9595,11 @@ + + + + + @@ -9534,7 +9759,7 @@

    How to use EXPLAIN ANALYZE?

    - + diff --git a/dev/MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/index.html b/dev/MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/index.html new file mode 100644 index 000000000..c0e320093 --- /dev/null +++ b/dev/MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/index.html @@ -0,0 +1,10083 @@ + + + + + + + + + + + + + + + + + + 1.1 through partition pruning - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + + + + + +
    +
    + + + + + + + + + + + + +

    1.1 through partition pruning

    + +

    Partition Pruning

    +

    Overview

    +

    Partition pruning is a method used for query optimization, applicable only when dealing with partitioned tables. By analyzing the filtering conditions in a query statement, partition pruning selects the partitions that may satisfy the conditions, thus avoiding scanning partitions that do not match the criteria and significantly reducing the amount of data that needs to be processed.

    +

    For example:

    +
    CREATE TABLE t1 (
    +    col1 INT NOT NULL,
    +    col2 DATE NOT NULL,
    +    col3 INT NOT NULL,
    +    PRIMARY KEY(col1, col3)
    +) PARTITION BY KEY(col1, col3) PARTITIONS 4;
    +
    +INSERT INTO t1 VALUES
    +(1, '1980-12-17', 7369),
    +(2, '1981-02-20', 7499),
    +(3, '1981-02-22', 7521),
    +(4, '1981-04-02', 7566),
    +(5, '1981-09-28', 7654),
    +(6, '1981-05-01', 7698),
    +(7, '1981-06-09', 7782),
    +(8, '0087-07-13', 7788),
    +(9, '1981-11-17', 7839),
    +(10, '1981-09-08', 7844),
    +(11, '2007-07-13', 7876),
    +(12, '1981-12-03', 7900),
    +(13, '1987-07-13', 7980),
    +(14, '2001-11-17', 7981),
    +(15, '1951-11-08', 7982),
    +(16, '1927-10-13', 7983),
    +(17, '1671-12-09', 7984),
    +(18, '1981-11-06', 7985),
    +(19, '1771-12-06', 7986),
    +(20, '1985-10-06', 7987),
    +(21, '1771-10-06', 7988),
    +(22, '1981-10-05', 7989),
    +(23, '2001-12-04', 7990),
    +(24, '1999-08-01', 7991),
    +(25, '1951-11-08', 7992),
    +(26, '1927-10-13', 7993),
    +(27, '1971-12-09', 7994),
    +(28, '1981-12-09', 7995),
    +(29, '2001-11-17', 7996),
    +(30, '1981-12-09', 7997),
    +(31, '2001-11-17', 7998),
    +(32, '2001-11-17', 7999);
    +
    +mysql> EXPLAIN VERBOSE SELECT * FROM t1 WHERE (col1 = 1 AND col3 = 7369) OR (col1 = 6 AND col3 = 7698);
    ++-----------------------------------------------------------------------------------------------------+
    +| QUERY PLAN                                                                                          |
    ++-----------------------------------------------------------------------------------------------------+
    +| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000)                                            |
    +|   Output: t1.col1, t1.col2, t1.col3                                                                 |
    +|   ->  Table Scan on db2.t1 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1)              |
    +|         Output: t1.col1, t1.col2, t1.col3                                                           |
    +|         Table: 't1' (0:'col1', 1:'col2', 2:'col3')                                                  |
    +|         Hit Partition: p0, p2                                                                       |
    +|         Filter Cond: (((t1.col1 = 1) and (t1.col3 = 7369)) or ((t1.col1 = 6) and (t1.col3 = 7698))) |
    ++-----------------------------------------------------------------------------------------------------+
    +7 rows in set (0.00 sec)
    +
    +

    This query prunes the partitions and scans only the p0 and p2 partitions.

    +

    Usage scenarios of Partition Pruning in KEY Partitioned Tables

    +

    Applicable Scenarios in KEY Partitioned Tables

    +

    Only equality comparison query conditions that match the partition key can support partition pruning for KEY partitioned tables.

    +
    CREATE TABLE t1 (
    +    col1 INT NOT NULL,
    +    col2 DATE NOT NULL,
    +    col3 INT PRIMARY KEY
    +) PARTITION BY KEY(col3) PARTITIONS 4;
    +
    +mysql> EXPLAIN SELECT * FROM t1 WHERE col3 = 7990 OR col3 = 7988;
    ++-------------------------------------------------------------------+
    +| QUERY PLAN                                                        |
    ++-------------------------------------------------------------------+
    +| Project                                                           |
    +|   ->  Table Scan on db1.t1                                        |
    +|         Hit Partition: p0, p1                                     |
    +|         Filter Cond: ((t1.col3 = 7990) or (t1.col3 = 7988))       |
    +|         Block Filter Cond: ((t1.col3 = 7990) or (t1.col3 = 7988)) |
    ++-------------------------------------------------------------------+
    +5 rows in set (0.00 sec)
    +
    +

    In this SQL statement, the condition col3 = 7990 can determine that all results are located in partition p0. The condition col3 = 7988 can determine that all results are situated in partition p1. Since these two conditions are combined using OR, only partitions p0 and p1 need to be scanned, resulting in partition pruning with the outcome of p0 and p1.

    +

    Inapplicable Scenarios in KEY Partitioned Tables

    +

    Scenario 1

    +

    Conditions that cannot determine if the query results are within a single partition, such as between, > < >= <=, and similar conditions, cannot benefit from partition pruning optimization.

    +
    mysql> EXPLAIN SELECT * FROM t1 WHERE col3 >= 7782;
    ++----------------------------------------------+
    +| QUERY PLAN                                   |
    ++----------------------------------------------+
    +| Project                                      |
    +|   ->  Table Scan on db1.t1                   |
    +|         Hit Partition: all partitions        |
    +|         Filter Cond: (t1.col3 >= 7782)       |
    +|         Block Filter Cond: (t1.col3 >= 7782) |
    ++----------------------------------------------+
    +5 rows in set (0.00 sec)
    +
    +

    Scenario 2

    +

    In scenarios where filtering conditions can only be obtained during the execution plan generation phase, partition pruning optimization cannot be utilized.

    +
    mysql> EXPLAIN SELECT * FROM t1 WHERE col3 = (SELECT col3 FROM t2 WHERE t1.col3 = t2.col3 AND t2.col1 < 5);
    ++------------------------------------------------------+
    +| QUERY PLAN                                           |
    ++------------------------------------------------------+
    +| Project                                              |
    +|   ->  Filter                                         |
    +|         Filter Cond: (t1.col3 = t2.col3
    +
    +)             |
    +|         ->  Join                                     |
    +|               Join Type: SINGLE                      |
    +|               Join Cond: (t1.col3 = t2.col3)         |
    +|               ->  Table Scan on db1.t1               |
    +|                     Hit Partition: all partitions    |
    +|               ->  Table Scan on db1.t2               |
    +|                     Hit Partition: all partitions    |
    +|                     Filter Cond: (t2.col1 < 5)       |
    +|                     Block Filter Cond: (t2.col1 < 5) |
    ++------------------------------------------------------+
    +12 rows in set (0.00 sec)
    +
    +

    This query retrieves results from a subquery and constructs an equality filter condition col3 = ? for each row read. However, partition pruning only takes effect during the query plan generation phase, not during execution, making it ineffective in this scenario.

    +

    Usage scenarios of Partition Pruning in HASH Partitioned Tables

    +

    Applicable Scenarios in HASH Partitioned Tables

    +

    HASH partitioned tables are similar to KEY partitioned tables, where only equality comparison query conditions can benefit from HASH partition pruning.

    +
    CREATE TABLE employees (
    +    id INT NOT NULL,
    +    fname VARCHAR(30),
    +    lname VARCHAR(30),
    +    hired DATE NOT NULL DEFAULT '1970-01-01',
    +    separated DATE NOT NULL DEFAULT '9999-12-31',
    +    job_code INT,
    +    store_id INT
    +)
    +PARTITION BY HASH(store_id) PARTITIONS 4;
    +
    +INSERT INTO employees VALUES
    +(10001, 'Georgi', 'Facello', '1953-09-02','1986-06-26',120, 1),
    +(10002, 'Bezalel', 'Simmel', '1964-06-02','1985-11-21',150, 7),
    +(10003, 'Parto', 'Bamford', '1959-12-03','1986-08-28',140, 3),
    +(10004, 'Chirstian', 'Koblick', '1954-05-01','1986-12-01',150, 3),
    +(10005, 'Kyoichi', 'Maliniak', '1955-01-21','1989-09-12',150, 18),
    +(10006, 'Anneke', 'Preusig', '1953-04-20','1989-06-02',150, 15),
    +(10007, 'Tzvetan', 'Zielinski', '1957-05-23','1989-02-10',110, 6),
    +(10008, 'Saniya', 'Kalloufi', '1958-02-19','1994-09-15',170, 10),
    +(10009, 'Sumant', 'Peac', '1952-04-19','1985-02-18',110, 13),
    +(10010, 'Duangkaew', 'Piveteau', '1963-06-01','1989-08-24',160, 10),
    +(10011, 'Mary', 'Sluis', '1953-11-07','1990-01-22',120, 8),
    +(10012, 'Patricio', 'Bridgland', '1960-10-04','1992-12-18',120, 7),
    +(10013, 'Eberhardt', 'Terkki', '1963-06-07','1985-10-20',160, 17),
    +(10014, 'Berni', 'Genin', '1956-02-12','1987-03-11',120, 15),
    +(10015, 'Guoxiang', 'Nooteboom', '1959-08-19','1987-07-02',140, 8),
    +(10016, 'Kazuhito', 'Cappelletti', '1961-05-02','1995-01-27',140, 2),
    +(10017, 'Cristinel', 'Bouloucos', '1958-07-06','1993-08-03',170, 10),
    +(10018, 'Kazuhide', 'Peha', '1954-06-19','1987-04-03',170, 2),
    +(10019, 'Lillian', 'Haddadi', '1953-01-23','1999-04-30',170, 13),
    +(10020, 'Mayuko', 'Warwick', '1952-12-24','1991-01-26',120, 1),
    +(10021, 'Ramzi', 'Erde', '1960-02-20','1988-02-10',120, 9),
    +(10022, 'Shahaf', 'Famili', '1952-07-08','1995-08-22',130, 10),
    +(10023, 'Bojan', 'Montemayor', '1953-09-29','1989-12-17',120, 5),
    +(10024, 'Suzette', 'Pettey', '1958-09-05','1997-05-19',130, 4),
    +(10025, 'Prasadram', 'Heyers', '1958-10-31','1987-08-17',180, 8),
    +(10026, 'Yongqiao', 'Berztiss', '1953-04-03','1995-03-20',170, 4),
    +(10027, 'Divier', 'Reistad', '1962-07-10','1989-07-07',180, 10),
    +(10028, 'Domenick', 'Tempesti', '1963-11-26','1991-10-22',110, 11),
    +(10029, 'Otmar', 'Herbst', '1956-12-13','1985-11-20',110, 12),
    +(10030, 'Elvis', 'Demeyer', '1958-07-14','1994-02-17',110, 1),
    +(10031, 'Karsten', 'Joslin', '1959-01-27','1991-09-01',110, 10),
    +(10032, 'Jeong', 'Reistad', '1960-08-09','1990-06-20',120, 19),
    +(10033, 'Arif', 'Merlo', '1956-11-14','1987-03-18',120, 14),
    +(10034, 'Bader', 'Swan', '1962-12-29','1988-09-21',130, 16),
    +(10035, 'Alain', 'Chappelet', '1953-02-08','1988-09-05',130, 3),
    +(10036, 'Adamantios', 'Portugali', '1959-08-10','1992-01-03',130, 14),
    +(10037, 'Pradeep', 'Makrucki', '1963-07-22','1990-12-05',140, 12),
    +(10038, 'Huan', 'Lortz', '1960-07-20','1989-09-20',140, 7),
    +(10039, 'Alejandro', 'Brender', '1959-10-01','1988-01-19',110, 20),
    +(10040, 'Weiyi', 'Meriste', '1959-09-13','1993-02-14',140, 17);
    +
    +mysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10;
    ++------------------------------------------------+
    +| QUERY PLAN                                     |
    ++------------------------------------------------+
    +| Project                                        |
    +|   ->  Table Scan on db1.employees              |
    +|         Hit Partition: p0                      |
    +|         Filter Cond: (employees.store_id = 10) |
    ++------------------------------------------------+
    +4 rows in set (0.00 sec)
    +
    +

    In this SQL statement, since the partition key for the partitioned table is store_id, the condition store_id = 10 can determine that all results are within a single partition. The value 10 is hashed to partition p0. Therefore, it is only necessary to scan partition p0, without accessing partitions p1, p2, and p3, which do not contain relevant results. As seen in the execution plan, there is only one TableScan operator, specifying Hit Partition as p0, ensuring the effectiveness of partition pruning.

    +

    Inapplicable Scenarios in HASH Partitioned Tables

    +

    Scenario 1

    +

    Conditions that cannot determine if the query results are within a single partition, such as between, > < >= <=, and similar conditions, cannot benefit from partition pruning optimization.

    +
    CREATE TABLE employees (
    + id INT NOT NULL,
    + fname VARCHAR(30),
    + lname VARCHAR(30),
    + hired DATE NOT NULL DEFAULT '1970-01-01',
    + separated DATE NOT NULL DEFAULT '9999-12-31',
    + job_code INT,
    + store_id INT
    +)
    +PARTITION BY HASH(store_id) PARTITIONS 4;
    +
    +mysql> EXPLAIN SELECT * FROM employees WHERE store_id > 15;
    ++------------------------------------------------+
    +| QUERY PLAN                                     |
    ++------------------------------------------------+
    +| Project                                        |
    +|   ->  Table Scan on db1.employees              |
    +|         Hit Partition: all partitions          |
    +|         Filter Cond: (employees.store_id > 15) |
    ++------------------------------------------------+
    +4 rows in set (0.00 sec)
    +
    +

    In this SQL statement, the condition store_id > 15 cannot determine the corresponding Hash partition, and therefore, partition pruning optimization cannot be used.

    +

    Scenario 2

    +

    In scenarios where filtering conditions can only be obtained during the execution plan generation phase, partition pruning optimization cannot be utilized.

    +
    mysql> EXPLAIN SELECT * FROM t1 WHERE col1 = (SELECT store_id FROM employees WHERE employees.store_id = t1.col1 AND employees.id = 10010);
    ++---------------------------------------------------------+
    +| QUERY PLAN                                              |
    ++---------------------------------------------------------+
    +| Project                                                 |
    +|   ->  Filter                                            |
    +|         Filter Cond: (t1.col1 = employees.store_id)     |
    +|         ->  Join                                        |
    +|               Join Type: SINGLE                         |
    +|               Join Cond: (t1.col1 = employees.store_id) |
    +|               ->  Table Scan on db1.t1                  |
    +|                     Hit Partition: all partitions       |
    +|               ->  Table Scan on db1.employees           |
    +|                     Hit Partition: all partitions       |
    +|                     Filter Cond: (employees.id = 10010) |
    ++---------------------------------------------------------+
    +11 rows in set (0.01 sec)
    +
    +

    This query retrieves results from a subquery and constructs an equality filter condition col3 = ? for each row read. However, partition pruning only takes effect during the query plan generation phase, not during execution, making it ineffective in this scenario.

    +

    Scenario 3

    +

    Using function expressions as partitioning expressions for HASH partitioned tables is not supported for partition pruning.

    +
    CREATE TABLE t3 (
    +col1 INT,
    +col2 CHAR(10),
    +col3 DATETIME
    +) PARTITION BY HASH (YEAR(col3)) PARTITIONS 4;
    +
    +INSERT INTO t3 VALUES
    +(10001, 'Georgi', '1999-04-05 11:01:02'),
    +(10002, 'Bezalel', '2004-04-03 13:11:10'),
    +(10003, 'Parto', '1997-04-05 11:01:02'),
    +(10004, 'Chirstian', '2004-04-03 13:11:10'),
    +(10005, 'Mary', '1998-04-05 11:01:02'),
    +(10006, 'Patricio', '2004-04-03 13:11:10'),
    +(10007, 'Eberhardt', '1953-09-02 13:11:10'),
    +(10008, 'Kazuhide', '1986-06-26 19:21:10'),
    +(10009, 'Tempesti', '1956-11-14 08:11:10'),
    +(10010, 'Nooteboom', '1987-03-18 23:11:10');
    +
    +mysql> EXPLAIN SELECT * FROM t3 WHERE YEAR(col3) = 1999;
    ++---------------------------------------------+
    +| QUERY PLAN                                  |
    ++---------------------------------------------+
    +| Project                                     |
    +|   ->  Table Scan on db1.t3                  |
    +|         Hit Partition: all partitions       |
    +|         Filter Cond: (YEAR(t3.col3) = 1999) |
    ++---------------------------------------------+
    +4 rows in set (0.00 sec)
    +
    +mysql> SELECT * FROM t3 WHERE YEAR(col3) = 1999;
    ++-------+--------+---------------------+
    +| col1  | col2   | col3                |
    ++-------+--------+---------------------+
    +| 10001 | Georgi | 1999-04-05 11:01:02 |
    ++-------+--------+---------------------+
    +1 row in set (0.01 sec)
    +
    +

    Performance Tuning Examples for Partition Pruning

    +

    Example 1

    +

    Equality Conditions in KEY Partitioned Table:

    +
    CREATE TABLE t1 (
    +    col1 INT NOT NULL,
    +    col2 DATE NOT NULL,
    +    col3 INT NOT NULL,
    +    PRIMARY KEY(col1, col3)
    +) PARTITION BY KEY(col1, col3) PARTITIONS 4;
    +
    +mysql> EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col3 = 7369;
    ++------------------------------------------------+
    +| QUERY PLAN                                     |
    ++------------------------------------------------+
    +| Project                                        |
    +|   ->  Table Scan on db2.t1                     |
    +|         Hit Partition: p0                      |
    +|         Filter Cond: ((t1.col1 = 1) and (t1.col3 = 7369)) |
    ++------------------------------------------------+
    +5 rows in set (0.00 sec)
    +
    +

    In this query, only partition p0 is accessed after partition pruning because the query conditions match the data in partition p0.

    +

    Example 2

    +

    OR Conditions in KEY Partitioned Table:

    +
    mysql> EXPLAIN SELECT * FROM t1 WHERE (col1 = 1 AND col3 = 7369) OR (col1 = 6 AND col3 = 7698);
    ++-----------------------------------------------------------------------------------------------------+
    +| QUERY PLAN                                                                                          |
    ++-----------------------------------------------------------------------------------------------------+
    +| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000)                                            |
    +|   Output: t1.col1, t1.col2, t1.col3                                                                 |
    +|   ->  Table Scan on db2.t1 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1)              |
    +|         Output: t1.col1, t1.col2, t1.col3                                                           |
    +|         Table: 't1' (0:'col1', 1:'col2', 2:'col3')                                                  |
    +|         Hit Partition: p0, p2                                                                       |
    +|         Filter Cond: (((t1.col1 = 1) and (t1.col3 = 7369)) or ((t1.col1 = 6) and (t1.col3 = 7698))) |
    ++-----------------------------------------------------------------------------------------------------+
    +7 rows in set (0.00 sec)
    +
    +

    This query prunes partitions p0 and p2 because the query conditions match the data in these two partitions.

    +

    Example 3

    +

    Equality Condition in HASH Partitioned Table:

    +
    CREATE TABLE employees (
    +    id INT NOT NULL,
    +    fname VARCHAR(30),
    +    lname VARCHAR(30),
    +    hired DATE NOT NULL DEFAULT '1970-01-01',
    +    separated DATE NOT NULL DEFAULT '9999-12-31',
    +    job_code INT,
    +    store_id INT
    +) PARTITION BY HASH(store_id) PARTITIONS 4;
    +
    +mysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10;
    ++------------------------------------------------+
    +| QUERY PLAN                                     |
    ++------------------------------------------------+
    +| Project                                        |
    +|   ->  Table Scan on db1.employees              |
    +|         Hit Partition: p0                      |
    +|         Filter Cond: (employees.store_id = 10) |
    ++------------------------------------------------+
    +4 rows in set (0.00 sec)
    +
    +

    In this query, only partition p0 contains data matching the condition store_id = 10, so only partition p0 is scanned.

    +

    Example 4

    +

    Multiple Conditions in HASH Partitioned Table:

    +
    mysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10 OR store_id = 15;
    ++---------------------------------------------------+
    +| QUERY PLAN                                        |
    ++---------------------------------------------------+
    +| Project                                           |
    +|   ->  Table Scan on db1.employees                 |
    +|         Hit Partition: p0, p3                     |
    +|         Filter Cond: ((employees.store_id = 10) or (employees.store_id = 15)) |
    ++---------------------------------------------------+
    +5 rows in set (0.00 sec)
    +
    +

    This query prunes partitions p0 and p3 because these two partitions contain data matching the condition store_id = 10 OR store_id = 15.

    +

    Example 5

    +

    Scenarios Inapplicable for Partition Pruning:

    +
    mysql> EXPLAIN SELECT * FROM t1 WHERE col1 > 5;
    ++------------------------------------------------+
    +| QUERY PLAN                                     |
    ++------------------------------------------------+
    +| Project                                        |
    +|   ->  Table Scan on db1.t1                     |
    +|         Hit Partition: all partitions          |
    +|         Filter Cond: (t1.col1 > 5)             |
    +|         Block Filter Cond: (t1.col1 > 5)       |
    ++------------------------------------------------+
    +5 rows in set (0.00 sec)
    +
    +

    In this query, the condition col1 > 5 cannot determine the corresponding partition, and therefore, partition pruning cannot be used.

    +

    Constraints

    +

    MatrixOne supports four partitioning methods: Key, Hash, Range, and List:

    +
      +
    • +

      However, partition pruning is currently supported only for Key and Hash partitioned tables, with pruning for other types planned for future implementation.

      +
    • +
    • +

      List partitioning and Range partitioning currently do not accelerate query performance.

      +
    • +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/index.html b/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/index.html index 7a3a07df6..7e2f359ba 100644 --- a/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/index.html +++ b/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9309,6 +9529,11 @@ + + + + + @@ -9405,7 +9630,7 @@

    How to operate

    - + diff --git a/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/index.html b/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/index.html index 51277605c..350250fb1 100644 --- a/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/index.html +++ b/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9363,6 +9583,11 @@ + + + + + @@ -9504,7 +9729,7 @@

    To consider when using Cluster
    - + diff --git a/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/index.html b/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/index.html index 2d4268e86..42d9b4fe8 100644 --- a/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/index.html +++ b/dev/MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9352,6 +9572,11 @@ + + + + + @@ -9570,7 +9795,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Performance-Tuning/performance-tuning-overview/index.html b/dev/MatrixOne/Performance-Tuning/performance-tuning-overview/index.html index 701fe9bcb..28d2ec55d 100644 --- a/dev/MatrixOne/Performance-Tuning/performance-tuning-overview/index.html +++ b/dev/MatrixOne/Performance-Tuning/performance-tuning-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9261,6 +9481,11 @@ + + + + + @@ -9368,7 +9593,7 @@

    SQL Performance Tuning Methods
    - + diff --git a/dev/MatrixOne/Reference/1.1-System-tables/index.html b/dev/MatrixOne/Reference/1.1-System-tables/index.html new file mode 100644 index 000000000..be9929ce3 --- /dev/null +++ b/dev/MatrixOne/Reference/1.1-System-tables/index.html @@ -0,0 +1,11526 @@ + + + + + + + + + + + + + + + + + + MatrixOne System Database and Tables - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + + + + + +
    +
    + + + + + + + + + + + + +

    MatrixOne System Database and Tables

    +

    MatrixOne system database and tables are where MatrixOne stores system information. We can access the system information through them. MatrixOne creates 6 system databases at initialization: mo_catalog, information_schema, system_metrcis, system, mysql, and mo_task. mo_task is under development and have no direct impact on users. +The other system databases and table functions are described in this document.

    +

    The system can only modify system databases and tables, and users can only read from them.

    +

    mo_catalog database

    +

    mo_catalog stores the metadata of MatrixOne objects: databases, tables, columns, system variables, accounts, users, and roles.

    +

    Start with MatrixOne 0.6 has introduced the concept of multi-account, the default sys account and other accounts have slightly different behaviors. The system table mo_account, which serves the multi-tenancy management, is only visible for the sys account; the other accounts don't see this table.

    +

    mo_database table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    dat_idbigint unsignedPrimary key ID
    datnamevarchar(100)Database name
    dat_catalog_namevarchar(100)Database catalog name, default as def
    dat_createsqlvarchar(100)Database creation SQL statement
    ownerint unsignedRole id
    creatorint unsignedUser id
    created_timetimestampCreate time
    account_idint unsignedAccount id
    dat_typevarchar(23)Database type, common library or subscription library
    +

    mo_tables table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    rel_idbigint unsignedPrimary key, table ID
    relnamevarchar(100)Name of the table, index, view, and so on.
    reldatabasevarchar(100)The database that contains this relation. reference mo_database.datname
    reldatabase_idbigint unsignedThe database id that contains this relation. reference mo_database.datid
    relpersistencevarchar(100)p = permanent table, t = temporary table
    relkindvarchar(100)r = ordinary table, e = external table, i = index, S = sequence, v = view, m = materialized view
    rel_commentvarchar(100)
    rel_createsqlvarchar(100)Table creation SQL statement
    created_timetimestampCreate time
    creatorint unsignedCreator ID
    ownerint unsignedCreator's default role id
    account_idint unsignedAccount id
    partitionedblobPartition by statement
    partition_infoblobthe information of partition
    viewdefblobView definition statement
    constraintvarchar(5000)Table related constraints
    rel_versionINT UNSIGNED(0)Version number of Primary key or table
    catalog_versionINT UNSIGNED(0)Version number of the system table
    +

    mo_columns table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Columntypecomments
    att_uniq_namevarchar(256)Primary Key. Hidden, composite primary key, format is like "${att_relname_id}-${attname}"
    account_idint unsignedaccountID
    att_database_idbigint unsigneddatabaseID
    att_databasevarchar(256)database Name
    att_relname_idbigint unsignedtable id
    att_relnamevarchar(256)The table this column belongs to.(references mo_tables.relname)
    attnamevarchar(256)The column name
    atttypvarchar(256)The data type of this column (zero for a dropped column).
    attnumintThe number of the column. Ordinary columns are numbered from 1 up.
    att_lengthintbytes count for the type.
    attnotnulltinyint(1)This represents a not-null constraint.
    atthasdeftinyint(1)This column has a default expression or generation expression.
    att_defaultvarchar(1024)default expression
    attisdroppedtinyint(1)This column has been dropped and is no longer valid. A dropped column is still physically present in the table, but is ignored by the parser and so cannot be accessed via SQL.
    att_constraint_typechar(1)p = primary key constraint, n=no constraint
    att_is_unsignedtinyint(1)unsigned or not
    att_is_auto_incrementtinyint(1)auto increment or not
    att_commentvarchar(1024)comment
    att_is_hiddentinyint(1)hidden or not
    attr_has_updatetinyint(1)This columns has update expression
    attr_updatevarchar(1024)update expression
    attr_is_clusterbytinyint(1)Whether this column is used as the cluster by keyword to create the table
    +

    mo_table_partitions table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    table_idBIGINT UNSIGNED(64)The ID of the current partitioned table.
    database_idBIGINT UNSIGNED(64)The ID of the database to which the current partitioned table belongs.
    numberSMALLINT UNSIGNED(16)The current partition number. All partitions are indexed in the order they are defined, with 1 assigned to the first partition.
    nameVARCHAR(64)The name of the partition.
    partition_typeVARCHAR(50)Stores the partition type information for the table. For partitioned tables, the values can be "KEY", "LINEAR_KEY", "HASH", "LINEAR_KEY_51", "RANGE", "RANGE_COLUMNS", "LIST", "LIST_COLUMNS". For non-partitioned tables, the value is an empty string. Note: MatrixOne does not currently support RANGE and LIST partitioning.
    partition_expressionVARCHAR(2048)The expression for the partitioning function used in the CREATE TABLE or ALTER TABLE statement that created the partitioned table's partitioning scheme.
    description_utf8TEXT(0)This column is used for RANGE and LIST partitions. For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be an integer or MAXVALUE. For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a comma-separated list of integer values. For partitions with partition_type other than RANGE or LIST, this column is always NULL. Note: MatrixOne does not currently support RANGE and LIST partitioning, so this column is NULL.
    commentVARCHAR(2048)The text of the comment, if the partition has one. Otherwise, this value is empty.
    optionsTEXT(0)Partition options information, currently set to NULL.
    partition_table_nameVARCHAR(1024)The name of the subtable corresponding to the current partition.
    +

    mo_account table (Only visible for sys account)

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    account_idint unsignedaccount id, primary key
    account_namevarchar(100)account name
    statusvarchar(100)open/suspend
    created_timetimestampcreate time
    commentsvarchar(256)comment
    suspended_timeTIMESTAMPTime of the account's status is changed
    versionbigint unsignedthe version status of the current account
    +

    mo_role table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    role_idint unsignedrole id, primary key
    role_namevarchar(100)role name
    creatorint unsigneduser_id
    ownerint unsignedMOADMIN/ACCOUNTADMIN ownerid
    created_timetimestampcreate time
    commentstextcomment
    +

    mo_user table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    user_idintuser id, primary key
    user_hostvarchar(100)user host address
    user_namevarchar(100)user name
    authentication_stringvarchar(100)authentication string encrypted with password
    statusvarchar(8)open,locked,expired
    created_timetimestampuser created time
    expired_timetimestampuser expired time
    login_typevarchar(16)ssl/password/other
    creatorintthe creator id who created this user
    ownerintthe admin id for this user
    default_roleintthe default role id for this user
    +

    mo_user_grant table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    role_idint unsignedID of the authorized role, associated primary key
    user_idint unsignedObtain the user ID of the authorized role and associate the primary key
    granted_timetimestampgranted time
    with_grant_optionboolWhether to allow an authorized user to license to another user or role
    +

    mo_role_grant table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    granted_idintthe role id being granted, associated primary key
    grantee_idintthe role id to grant others, associated primary key
    operation_role_idintoperation role id
    operation_user_idintoperation user id
    granted_timetimestampgranted time
    with_grant_optionboolWhether to allow an authorized role to be authorized to another user or role
    +

    mo_role_privs table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    role_idintrole id, associated primary key
    role_namevarchar(100)role name: accountadmin/public
    obj_typevarchar(16)object type: account/database/table, associated primary key
    obj_idbigint unsignedobject id, associated primary key
    privilege_idintprivilege id, associated primary key
    privilege_namevarchar(100)privilege name: the list of privileges
    privilege_levelvarchar(100)level of privileges, associated primary key
    operation_user_idint unsignedoperation user id
    granted_timetimestampgranted time
    with_grant_optionboolIf permission granting is permitted
    +

    mo_stages table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    stage_idINT UNSIGNED(32)data stage ID
    stage_nameVARCHAR(64)data stage name
    urlTEXT(0)Path to object storage (without authentication), path to file system
    stage_credentialsTEXT(0)Authentication information, encrypted and saved
    stage_statusVARCHAR(64)ENABLED/DISABLED Default: DISABLED
    created_timeTIMESTAMP(0)creation time
    commentTEXT(0)comment
    +

    mo_user_defined_function table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    function_idINT(32)ID of the function, primary key
    nameVARCHAR(100)the name of the function
    ownerINT UNSIGNED(32)ID of the role who created the function
    argsTEXT(0)Argument list for the function
    rettypeVARCHAR(20)return type of the function
    bodyTEXT(0)function body
    languageVARCHAR(20)language used by the function
    dbVARCHAR(100)database where the function is located
    definerVARCHAR(50)name of the user who defined the function
    modified_timeTIMESTAMP(0)time when the function was last modified
    created_timeTIMESTAMP(0)creation time of the function
    typeVARCHAR(10)type of function, default FUNCTION
    security_typeVARCHAR(10)security processing method, uniform value DEFINER
    commentVARCHAR(5000)Create a comment for the function
    character_set_clientVARCHAR(64)Client character set: utf8mb4
    collation_connectionVARCHAR(64)Connection sort: utf8mb4_0900_ai_ci
    database_collationVARCHAR(64)Database connection collation: utf8mb4_0900_ai_ci
    +

    mo_mysql_compatbility_mode table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    configuration_idINT(32)Configuration item id, an auto-increment column, used as a primary key to distinguish different configurations
    account_nameVARCHAR(300)The name of the tenant where the configuration is located
    dat_nameVARCHAR(5000)The name of the database where the configuration is located
    configurationJSON(0)Configuration content, saved in JSON format
    +

    mo_pubs table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    pub_nameVARCHAR(64)publication name
    database_nameVARCHAR(5000)The name of the published data
    database_idBIGINT UNSIGNED(64)ID of the publishing database, corresponding to dat_id in the mo_database table
    all_tableBOOL(0)Whether the publishing library contains all tables in the database corresponding to database_id
    all_accountBOOL(0)Whether all accounts can subscribe to the library
    table_listTEXT(0)When it is not all table, publish the list of tables contained in the library, and the table name corresponds to the table under the database corresponding to database_id
    account_listTEXT(0)Account list that is allowed to subscribe to the publishing library when it is not all accounts
    created_timeTIMESTAMP(0)Time when the release repository was created
    ownerINT UNSIGNED(32)The role ID corresponding to the creation of the release library
    creatorINT UNSIGNED(32)The ID of the user who created the release library
    commentTEXT(0)Remarks for creating a release library
    +

    mo_indexes table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    idBIGINT UNSIGNED(64)index ID
    table_idBIGINT UNSIGNED(64)ID of the table where the index resides
    database_idBIGINT UNSIGNED(64)ID of the database where the index resides
    nameVARCHAR(64)name of the index
    typeVARCHAR(11)The type of index, including primary key index (PRIMARY), unique index (UNIQUE), secondary index (MULTIPLE)
    is_visibleTINYINT(8)Whether the index is visible, 1 means visible, 0 means invisible (currently all MatrixOne indexes are visible indexes)
    hiddenTINYINT(8)Whether the index is hidden, 1 is a hidden index, 0 is a non-hidden index
    commentVARCHAR(2048)Comment information for the index
    column_nameVARCHAR(256)The column name of the constituent columns of the index
    ordinal_positionINT UNSIGNED(32)Column ordinal in index, starting from 1
    optionsTEXT(0)options option information for index
    index_table_nameVARCHAR(5000)The table name of the index table corresponding to the index, currently only the unique index contains the index table
    +

    mo_sessions view

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    node_idVARCHAR(65535)Unique identifier for MatrixOne nodes. Once started, it cannot be changed.
    conn_idINT UNSIGNEDUnique identifier associated with client's TCP connections in MatrixOne, generated by Hakeeper.
    session_idVARCHAR(65535)Unique UUID used to identify sessions. A new UUID is generated for each new session.
    accountVARCHAR(65535)Name of the tenant.
    userVARCHAR(65535)Name of the user.
    hostVARCHAR(65535)IP address and port where the CN node receives client requests.
    dbVARCHAR(65535)Name of the database used when executing SQL.
    session_startVARCHAR(65535)Timestamp when the session was created.
    commandVARCHAR(65535)Type of MySQL command, such as COM_QUERY, COM_STMT_PREPARE, COM_STMT_EXECUTE, etc.
    infoVARCHAR(65535)The executed SQL statement. Multiple statements may be present within a single SQL statement.
    txn_idVARCHAR(65535)Unique identifier for the related transaction.
    statement_idVARCHAR(65535)Unique identifier (UUID) for a statement within the SQL.
    statement_typeVARCHAR(65535)Type of a statement within the SQL, such as SELECT, INSERT, UPDATE, etc.
    query_typeVARCHAR(65535)Category of a statement within the SQL, such as DQL (Data Query Language), TCL (Transaction Control Language), etc.
    sql_source_typeVARCHAR(65535)Source of a statement within the SQL, such as external or internal.
    query_startVARCHAR(65535)Timestamp when a statement within the SQL started execution.
    client_hostVARCHAR(65535)IP address and port of the client.
    roleVARCHAR(65535)Role name of the user.
    +

    mo_locks view

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypecomments
    txn_idVARCHAR(65535)Transaction holding the lock.
    table_idVARCHAR(65535)The table on which the lock is placed.
    lock_typeVARCHAR(65535)Type of lock, which can be point or range.
    lock_contentVARCHAR(65535)Locked content, represented in hexadecimal. For range locks, it represents a range; for point locks, it represents a single value.
    lock_modeVARCHAR(65535)Lock mode, which can be shared or exclusive.
    lock_statusVARCHAR(65535)Lock status can be wait, acquired, or none.
    wait: No transaction holds the lock, but transactions are waiting for it.
    acquired: A transaction holds the lock.
    none: No transaction holds the lock, and no transactions await it.
    waiting_txnsVARCHAR(65535)Transactions waiting on this lock.
    +

    system_metrics database

    +

    system_metrics collect the status and statistics of SQL statements, CPU & memory resource usage.

    +

    system_metrics tables have more or less same column types, fields in these tables are described as follows:

    +
      +
    • collecttime:Collection time
    • +
    • +

      value: the value of the collecting metric

      +
    • +
    • +

      node: the MatrixOne node uuid

      +
    • +
    • role: the MatrixOne node role, can be CN, TN or LOG.
    • +
    • account: default as "sys", the account who fires the SQL request.
    • +
    • type:SQL type, can be select, insert, update, delete, other types.
    • +
    +

    metric table

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypeComment
    metric_nameVARCHAR(128)metric name, like: sql_statement_total, server_connections, process_cpu_percent, sys_memory_used, ..
    collecttimeDATETIMEmetric data collect time
    valueDOUBLEmetric value
    nodeVARCHAR(36)MatrixOne node uuid
    roleVARCHAR(32)MatrixOne node role
    accountVARCHAR(128)account name, default "sys"
    TypeVARCHAR(32)SQL type: like insert, select, update ...
    +

    The other tables are all views of the metric table:

    +
      +
    • process_cpu_percent table: Process CPU busy percentage.
    • +
    • process_open_fs table: Number of open file descriptors.
    • +
    • process_resident_memory_bytes table: Resident memory size in bytes.
    • +
    • server_connection table: Server connection numbers.
    • +
    • sql_statement_errors table: Counter of sql statements executed with errors.
    • +
    • sql_statement_total table: Counter of executed sql statement.
    • +
    • sql_transaction_errors table: Counter of transactional statements executed with errors.
    • +
    • sql_statement_hotspot table: records the most extended SQL query executed by each tenant within each minute. Only those SQL queries whose execution time does not exceed a certain aggregation threshold will be included in the statistics.
    • +
    • sql_transaction_total table: Counter of transactional sql statement.
    • +
    • sys_cpu_combined_percent table: System CPU busy percentage, average among all logical cores.
    • +
    • sys_cpu_seconds_total table: System CPU time spent in seconds, normalized by number of cores
    • +
    • sys_disk_read_bytes table: System disk read in bytes.
    • +
    • sys_disk_write_bytes table: System disk write in bytes.
    • +
    • sys_memory_available table: System memory available in bytes.
    • +
    • sys_memory_used table: System memory used in bytes.
    • +
    • sys_net_recv_bytes table: System net received in bytes.
    • +
    • sys_net_sent_bytes table: System net sent in bytes.
    • +
    +

    system database

    +

    System database stores MatrixOne historical SQL statements, system logs, error information.

    +

    statement_info table

    +

    It records user and system SQL statement with detailed information.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypeComments
    statement_idVARCHAR(36)statement unique id
    transaction_idVARCHAR(36)Transaction unique id
    session_idVARCHAR(36)session unique id
    accountVARCHAR(1024)account name
    userVARCHAR(1024)user name
    hostVARCHAR(1024)user client ip
    databaseVARCHAR(1024)what database current session stay in
    statementTEXTsql statement
    statement_tagTEXTnote tag in statement(Reserved)
    statement_fingerprintTEXTnote tag in statement(Reserved)
    node_uuidVARCHAR(36)node uuid, which node gen this data
    node_typeVARCHAR(64)node type in MO, val in [TN, CN, LOG]
    request_atDATETIMErequest accept datetime
    response_atDATETIMEresponse send datetime
    durationBIGINTexec time, unit: ns
    statusVARCHAR(32)sql statement running status, enum: Running, Success, Failed
    err_codeVARCHAR(1024)error code
    errorTEXTerror message
    exec_planJSONstatement execution plan
    rows_readBIGINTrows read total
    bytes_scanBIGINTbytes scan total
    statsJSONglobal stats info in exec_plan
    statement_typeVARCHAR(1024)statement type, val in [Insert, Delete, Update, Drop Table, Drop User, ...]
    query_typeVARCHAR(1024)query type, val in [DQL, DDL, DML, DCL, TCL]
    role_idBIGINTrole id
    sql_source_typeTEXTType of SQL source internally generated by MatrixOne
    aggr_countBIGINT(64)the number of statements aggregated
    result_countBIGINT(64)the number of rows of sql execution results
    +

    rawlog table

    +

    It records very detailed system logs.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ColumnTypeComments
    raw_itemVARCHAR(1024)raw log item
    node_uuidVARCHAR(36)node uuid, which node gen this data.
    node_typeVARCHAR(64)node type in MO, val in [TN, CN, LOG]
    span_idVARCHAR(16)span unique id
    statement_idVARCHAR(36)statement unique id
    logger_nameVARCHAR(1024)logger name
    timestampDATETIMEtimestamp of action
    levelVARCHAR(1024)log level, enum: debug, info, warn, error, panic, fatal
    callerVARCHAR(1024)where it log, like: package/file.go:123
    messageTEXTlog message
    extraJSONlog dynamic fields
    err_codeVARCHAR(1024)error log
    errorTEXTerror message
    stackVARCHAR(4096)
    span_nameVARCHAR(1024)span name, for example: step name of execution plan, function name in code, ...
    parent_span_idVARCHAR(16)parent span unique id
    start_timeDATETIME
    end_timeDATETIME
    durationBIGINTexec time, unit: ns
    resourceJSONstatic resource information
    +

    The other 3 tables(log_info, span_info and error_info) are views of statement_info and rawlog table.

    +

    information_schema database

    +

    Information Schema provides an ANSI-standard way of viewing system metadata. MatrixOne also provides a number of custom information_schema tables, in addition to the tables included for MySQL compatibility.

    +

    Many INFORMATION_SCHEMA tables have a corresponding SHOW command. The benefit of querying INFORMATION_SCHEMA is that it is possible to join between tables.

    +

    Tables for MySQL compatibility

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Table NameDescription
    KEY_COLUMN_USAGEDescribes the key constraints of the columns, such as the primary key constraint.
    COLUMNSProvides a list of columns for all tables.
    PROFILINGProvides some profiling information during SQL statement execution.
    PROCESSLISTProvides similar information to the command SHOW PROCESSLIST.
    USER_PRIVILEGESSummarizes the privileges associated with the current user.
    SCHEMATAProvides similar information to SHOW DATABASES.
    CHARACTER_SETSProvides a list of character sets the server supports.
    TRIGGERSProvides similar information to SHOW TRIGGERS.
    TABLESProvides a list of tables that the current user has visibility of. Similar to SHOW TABLES.
    PARTITIONSProvides information about table partitions.
    VIEWSProvides information about views in the database.
    ENGINESProvides a list of supported storage engines.
    ROUTINESProvides some information about stored procedures.
    PARAMETERSProvides information about stored procedures' parameters and return values ​​.
    KEYWORDSProvide information about keywords in the database; see Keywords for details.
    +

    CHARACTER_SETS table

    +

    The description of columns in the CHARACTER_SETS table is as follows:

    +
      +
    • CHARACTER_SET_NAME: The name of the character set.
    • +
    • DEFAULT_COLLATE_NAME The default collation name of the character set.
    • +
    • DESCRIPTION The description of the character set.
    • +
    • MAXLEN The maximum length required to store a character in this character set.
    • +
    +

    COLUMNS table

    +

    The description of columns in the COLUMNS table is as follows:

    +
      +
    • TABLE_CATALOG: The name of the catalog to which the table with the column belongs. The value is always def.
    • +
    • TABLE_SCHEMA: The name of the schema in which the table with the column is located.
    • +
    • TABLE_NAME: The name of the table with the column.
    • +
    • COLUMN_NAME: The name of the column.
    • +
    • ORDINAL_POSITION: The position of the column in the table.
    • +
    • COLUMN_DEFAULT: The default value of the column. If the explicit default value is NULL, or if the column definition does not include the default clause, this value is NULL.
    • +
    • IS_NULLABLE: Whether the column is nullable. If the column can store null values, this value is YES; otherwise, it is NO.
    • +
    • DATA_TYPE: The type of data in the column.
    • +
    • CHARACTER_MAXIMUM_LENGTH: For string columns, the maximum length in characters.
    • +
    • CHARACTER_OCTET_LENGTH: For string columns, the maximum length in bytes.
    • +
    • NUMERIC_PRECISION: The numeric precision of a number-type column.
    • +
    • NUMERIC_SCALE: The numeric scale of a number-type column.
    • +
    • DATETIME_PRECISION: For time-type columns, the fractional seconds precision.
    • +
    • CHARACTER_SET_NAME: The name of the character set of a string column.
    • +
    • COLLATION_NAME: The name of the collation of a string column.
    • +
    • COLUMN_TYPE: The column type.
    • +
    • COLUMN_KEY: Whether this column is indexed. This field might have the following values:
        +
      • Empty: This column is not indexed, or this column is indexed and is the second column in a multi-column non-unique index.
      • +
      • PRI: This column is the primary key or one of multiple primary keys.
      • +
      • UNI: This column is the first column of the unique index.
      • +
      • MUL: The column is the first column of a non-unique index, in which a given value is allowed to occur for multiple times.
      • +
      +
    • +
    • EXTRA: Any additional information of the given column.
    • +
    • PRIVILEGES: The privilege that the current user has on this column.
    • +
    • COLUMN_COMMENT: Comments contained in the column definition.
    • +
    • GENERATION_EXPRESSION: For generated columns, this value displays the expression used to calculate the column value. For non-generated columns, the value is empty.
    • +
    • SRS_ID: This value applies to spatial columns. It contains the column SRID value that indicates the spatial reference system for values stored in the column.
    • +
    +

    ENGINES table

    +

    The description of columns in the ENGINES table is as follows:

    +
      +
    • ENGINES: The name of the storage engine.
    • +
    • SUPPORT: The level of support that the server has on the storage engine.
    • +
    • COMMENT: The brief comment on the storage engine.
    • +
    • TRANSACTIONS: Whether the storage engine supports transactions.
    • +
    • XA: Whether the storage engine supports XA transactions.
    • +
    • SAVEPOINTS: Whether the storage engine supports savepoints.
    • +
    +

    PARTITIONS table

    +

    The description of columns in the PARTITIONS table is as follows:

    +
      +
    • TABLE_CATALOG: The name of the catalog to which the table belongs. This value is always def.
    • +
    • TABLE_SCHEMA: The name of the schema (database) to which the table belongs.
    • +
    • TABLE_NAME: The name of the table containing the partition.
    • +
    • PARTITION_NAME: The name of the partition.
    • +
    • SUBPARTITION_NAME: If the PARTITIONS table row represents a subpartition, the name of subpartition; otherwise NULL.
    • +
    • PARTITION_ORDINAL_POSITION: All partitions are indexed in the same order as they are defined, with 1 being the number assigned to the first partition. The indexing can change as partitions are added, dropped, and reorganized; the number shown is this column reflects the current order, taking into account any indexing changes.
    • +
    • SUBPARTITION_ORDINAL_POSITION: Subpartitions within a given partition are also indexed and reindexed in the same manner as partitions are indexed within a table.
    • +
    • PARTITION_METHOD: One of the values RANGE, LIST, HASH, LINEAR HASH, KEY, or LINEAR KEY. Note: MatrixOne does not currently support RANGE and LIST partitioning.
    • +
    • SUBPARTITION_METHOD: One of the values HASH, LINEAR HASH, KEY, or LINEAR KEY.
    • +
    • PARTITION_EXPRESSION: The expression for the partitioning function used in the CREATE TABLE or ALTER TABLE statement that created the table's current partitioning scheme.
    • +
    • SUBPARTITION_EXPRESSION: This works in the same fashion for the subpartitioning expression that defines the subpartitioning for a table as PARTITION_EXPRESSION does for the partitioning expression used to define a table's partitioning. If the table has no subpartitions, this column is NULL.
    • +
    • PARTITION_DESCRIPTION: This column is used for RANGE and LIST partitions. For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be either an integer or MAXVALUE. For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a list of comma-separated integer values. For partitions whose PARTITION_METHOD is other than RANGE or LIST, this column is always NULL. Note: MatrixOne does not currently support RANGE and LIST partitioning.
    • +
    • TABLE_ROWS: The number of table rows in the partition.
    • +
    • AVG_ROW_LENGTH: The average length of the rows stored in this partition or subpartition, in bytes. This is the same as DATA_LENGTH divided by TABLE_ROWS.
    • +
    • DATA_LENGTH: The total length of all rows stored in this partition or subpartition, in bytes; that is, the total number of bytes stored in the partition or subpartition.
    • +
    • INDEX_LENGTH: The length of the index file for this partition or subpartition, in bytes.
    • +
    • DATA_FREE: The number of bytes allocated to the partition or subpartition but not used.
    • +
    • CREATE_TIME: The time that the partition or subpartition was created.
    • +
    • UPDATE_TIME: The time that the partition or subpartition was last modified.
    • +
    • CHECK_TIME: The last time that the table to which this partition or subpartition belongs was checked.
    • +
    • CHECKSUM: The checksum value, if any; otherwise NULL.
    • +
    • PARTITION_COMMENT: The text of the comment, if the partition has one. If not, this value is empty. The maximum length for a partition comment is defined as 1024 characters, and the display width of the PARTITION_COMMENT column is also 1024, characters to match this limit.
    • +
    • NODEGROUP: This is the nodegroup to which the partition belongs.
    • +
    • TABLESPACE_NAME: The name of the tablespace to which the partition belongs. The value is always DEFAULT.
    • +
    +

    PROCESSLIST table

    +

    Fields in the PROCESSLIST table are described as follows:

    +
      +
    • ID: The ID of the user connection.
    • +
    • USER: The name of the user who is executing PROCESS.
    • +
    • HOST: The address that the user is connecting to.
    • +
    • DB: The name of the currently connected default database.
    • +
    • COMMAND: The command type that PROCESS is executing.
    • +
    • TIME: The current execution duration of PROCESS, in seconds.
    • +
    • STATE: The current connection state.
    • +
    • INFO: The requested statement that is being processed.
    • +
    +

    SCHEMATA table

    +

    The SCHEMATA table provides information about databases. The table data is equivalent to the result of the SHOW DATABASES statement. Fields in the SCHEMATA table are described as follows:

    +
      +
    • CATALOG_NAME: The catalog to which the database belongs.
    • +
    • SCHEMA_NAME: The database name.
    • +
    • DEFAULT_CHARACTER_SET_NAME: The default character set of the database.
    • +
    • DEFAULT_COLLATION_NAME: The default collation of the database.
    • +
    • SQL_PATH: The value of this item is always NULL.
    • +
    • DEFAULT_TABLE_ENCRYPTION: defines the default encryption setting for databases and general tablespaces.
    • +
    +

    TABLES table

    +

    The description of columns in the TABLES table is as follows:

    +
      +
    • TABLE_CATALOG: The name of the catalog which the table belongs to. The value is always def.
    • +
    • TABLE_SCHEMA: The name of the schema which the table belongs to.
    • +
    • TABLE_NAME: The name of the table.
    • +
    • TABLE_TYPE: The type of the table. The base table type is BASE TABLE, the view table type is VIEW, and the INFORMATION_SCHEMA table type is SYSTEM VIEW.
    • +
    • ENGINE: The type of the storage engine.
    • +
    • VERSION: Version. The value is 10 by default.
    • +
    • ROW_FORMAT: The row format. The value is Compact, Fixed, Dynamic, Compressed, Redundant.
    • +
    • TABLE_ROWS: The number of rows in the table in statistics. For INFORMATION_SCHEMA tables, TABLE_ROWS is NULL.
    • +
    • AVG_ROW_LENGTH: The average row length of the table. AVG_ROW_LENGTH = DATA_LENGTH / TABLE_ROWS.
    • +
    • DATA_LENGTH: Data length. DATA_LENGTH = TABLE_ROWS * the sum of storage lengths of the columns in the tuple.
    • +
    • MAX_DATA_LENGTH: The maximum data length. The value is currently 0, which means the data length has no upper limit.
    • +
    • INDEX_LENGTH: The index length. INDEX_LENGTH = TABLE_ROWS * the sum of lengths of the columns in the index tuple.
    • +
    • DATA_FREE: Data fragment. The value is currently 0.
    • +
    • AUTO_INCREMENT: The current step of the auto- increment primary key.
    • +
    • CREATE_TIME: The time at which the table is created.
    • +
    • UPDATE_TIME: The time at which the table is updated.
    • +
    • CHECK_TIME: The time at which the table is checked.
    • +
    • TABLE_COLLATION: The collation of strings in the table.
    • +
    • CHECKSUM: Checksum.
    • +
    • CREATE_OPTIONS: Creates options.
    • +
    • TABLE_COMMENT: The comments and notes of the table.
    • +
    +

    USER_PRIVILEGES table

    +

    The USER_PRIVILEGES table provides information about global privileges.

    +

    Fields in the USER_PRIVILEGES table are described as follows:

    +
      +
    • GRANTEE: The name of the granted user, which is in the format of 'user_name'@'host_name'.
    • +
    • TABLE_CATALOG: The name of the catalog to which the table belongs. This value is always def.
    • +
    • PRIVILEGE_TYPE: The privilege type to be granted. Only one privilege type is shown in each row.
    • +
    • IS_GRANTABLE: If you have the GRANT OPTION privilege, the value is YES; otherwise, the value is NO.
    • +
    +

    VIEW table

    +
      +
    • TABLE_CATALOG: The name of the catalog the view belongs to. The value is def.
    • +
    • TABLE_SCHEMA: The name of the database to which the view belongs.
    • +
    • TABLE_NAME: The name of the view.
    • +
    • VIEW_DEFINITION: The SELECT statement that provides the view definition. It contains most of what you see in the "Create Table" column generated by SHOW Create VIEW.
    • +
    • CHECK_OPTION: The value of the CHECK_OPTION property. Values are NONE, CASCADE, or LOCAL.
    • +
    • IS_UPDATABLE: Set a flag called the view updatable flag when CREATE VIEW; if UPDATE and DELETE (and similar operations) are legal for the view, the flag is set to YES(true). Otherwise, the flag is set to NO(false).
    • +
    • DEFINER: The account of the user who created the view, in the format username@hostname.
    • +
    • SECURITY_TYPE: View the SQL SECURITY attribute. Values ​​are DEFINER or INVOKER.
    • +
    • CHARACTER_SET_CLIENT: The session value of the character_set_client system variable when the view was created.
    • +
    • COLLATION_CONNECTION: The session value of the collation_connection system variable when the view was created.
    • +
    +

    STATISTICS Table

    +

    Obtain detailed information about database table indexes and statistics. For example, you can check whether an index is unique, understand the order of columns within an index, and estimate the number of unique values in an index.

    +
      +
    • TABLE_CATALOG: The catalog name of the table (always 'def').
    • +
    • TABLE_SCHEMA: The name of the database to which the table belongs.
    • +
    • TABLE_NAME: The name of the table.
    • +
    • NON_UNIQUE: Indicates whether the index allows duplicate values. If 0, the index is unique.
    • +
    • INDEX_SCHEMA: The database name to which the index belongs.
    • +
    • INDEX_NAME: The name of the index.
    • +
    • SEQ_IN_INDEX: The position of the column within the index.
    • +
    • COLUMN_NAME: The name of the column.
    • +
    • COLLATION: The collation of the column.
    • +
    • CARDINALITY: An estimated count of unique values in the index.
    • +
    • SUB_PART: The length of the index part. For the entire column, this value is NULL.
    • +
    • PACKED: Indicates whether compressed storage is used.
    • +
    • NULLABLE: Indicates whether the column allows NULL values.
    • +
    • INDEX_TYPE: The index type (e.g., BTREE, HASH, etc.).
    • +
    • COMMENT: Comment information about the index.
    • +
    +

    mysql database

    +

    Grant system tables

    +

    These system tables contain grant information about user accounts and their privileges:

    +
      +
    • user: user accounts, global privileges, and other non-privilege columns.
    • +
    • db: database-level privileges.
    • +
    • tables_priv: table-level privileges.
    • +
    • columns_priv: column-level privileges.
    • +
    • procs_priv: stored procedure and stored function privileges.
    • +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/Data-Types/blob-text-type/index.html b/dev/MatrixOne/Reference/Data-Types/blob-text-type/index.html index c2f2872a9..b6e75a0d2 100644 --- a/dev/MatrixOne/Reference/Data-Types/blob-text-type/index.html +++ b/dev/MatrixOne/Reference/Data-Types/blob-text-type/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9263,6 +9483,11 @@ + + + + + @@ -9357,7 +9582,7 @@

    The BLOB and TEXT Type

    - + diff --git a/dev/MatrixOne/Reference/Data-Types/data-type-conversion/index.html b/dev/MatrixOne/Reference/Data-Types/data-type-conversion/index.html index 550707a42..b354dca07 100644 --- a/dev/MatrixOne/Reference/Data-Types/data-type-conversion/index.html +++ b/dev/MatrixOne/Reference/Data-Types/data-type-conversion/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9303,6 +9523,11 @@ + + + + + @@ -9563,7 +9788,7 @@

    Data Type Conversion

    - + diff --git a/dev/MatrixOne/Reference/Data-Types/data-types/index.html b/dev/MatrixOne/Reference/Data-Types/data-types/index.html index 69e442713..07fd57b59 100644 --- a/dev/MatrixOne/Reference/Data-Types/data-types/index.html +++ b/dev/MatrixOne/Reference/Data-Types/data-types/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9615,6 +9835,11 @@ + + + + + @@ -10327,7 +10552,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Reference/Data-Types/date-time-data-types/timestamp-initialization/index.html b/dev/MatrixOne/Reference/Data-Types/date-time-data-types/timestamp-initialization/index.html index b439ecf8f..26c8c7371 100644 --- a/dev/MatrixOne/Reference/Data-Types/date-time-data-types/timestamp-initialization/index.html +++ b/dev/MatrixOne/Reference/Data-Types/date-time-data-types/timestamp-initialization/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9265,6 +9485,11 @@ + + + + + @@ -9403,7 +9628,7 @@

    Automa
    - + diff --git a/dev/MatrixOne/Reference/Data-Types/date-time-data-types/year-type/index.html b/dev/MatrixOne/Reference/Data-Types/date-time-data-types/year-type/index.html index 005e96552..6a06bcbba 100644 --- a/dev/MatrixOne/Reference/Data-Types/date-time-data-types/year-type/index.html +++ b/dev/MatrixOne/Reference/Data-Types/date-time-data-types/year-type/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9311,6 +9531,11 @@ + + + + + @@ -9493,7 +9718,7 @@

    Two-Digit Years in Dates

    - + diff --git a/dev/MatrixOne/Reference/Data-Types/enum-type/index.html b/dev/MatrixOne/Reference/Data-Types/enum-type/index.html index 2c7338e4f..e57d1afba 100644 --- a/dev/MatrixOne/Reference/Data-Types/enum-type/index.html +++ b/dev/MatrixOne/Reference/Data-Types/enum-type/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9403,6 +9623,11 @@ + + + + + @@ -9551,7 +9776,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Data-Types/fixed-point-types/index.html b/dev/MatrixOne/Reference/Data-Types/fixed-point-types/index.html index e7af81ecf..6851618ff 100644 --- a/dev/MatrixOne/Reference/Data-Types/fixed-point-types/index.html +++ b/dev/MatrixOne/Reference/Data-Types/fixed-point-types/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9309,6 +9529,11 @@ + + + + + @@ -9432,7 +9657,7 @@

    DECIMAL Data Type Characteristics

    - + diff --git a/dev/MatrixOne/Reference/Data-Types/json-type/index.html b/dev/MatrixOne/Reference/Data-Types/json-type/index.html index 235afed8a..03c4f1d2e 100644 --- a/dev/MatrixOne/Reference/Data-Types/json-type/index.html +++ b/dev/MatrixOne/Reference/Data-Types/json-type/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9441,7 +9666,7 @@

    Normalization of JSON Values

    - + diff --git a/dev/MatrixOne/Reference/Data-Types/uuid-type/index.html b/dev/MatrixOne/Reference/Data-Types/uuid-type/index.html index 9fc9f122b..0ab00ed5c 100644 --- a/dev/MatrixOne/Reference/Data-Types/uuid-type/index.html +++ b/dev/MatrixOne/Reference/Data-Types/uuid-type/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9309,6 +9529,11 @@ + + + + + @@ -9495,7 +9720,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/index.html new file mode 100644 index 000000000..0fa901b8f --- /dev/null +++ b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/index.html @@ -0,0 +1,9689 @@ + + + + + + + + + + + + + + + + + + Arithemetic Operators - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    Arithemetic Operators

    +

    MatrixOne supports the basic arithmetic operators like Add, Subtract, Multiply, Divide on vector. These operator performs element-wise arithemetic operation and return a new vector.

    +
    +

    Note

    +

    Sub(-), Multipy(*) and Divide(/) are all similar to the Add example.

    +
    +

    Add

    +

    Description

    +

    This operator is used to add two vectors element-wise by using the + operator.

    +

    Syntax

    +
    > SELECT vector1 + vector2 AS result_vector FROM table_name;
    +
    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    ++------+-----------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select b + "[1,2,3]" from vec_table;
    ++-------------+
    +| b + [1,2,3] |
    ++-------------+
    +| [2, 4, 6]   |
    ++-------------+
    +1 row in set (0.00 sec)
    +
    +

    Constraints

    +
      +
    • Both the argument vectors should be of same dimension
    • +
    • If operation is performed between vecf32 and vecf64, the result is cast to vecf64
    • +
    • If one of the argument is VECTOR in textual format, then the other argument should be of VECTOR type. If both the arguments are TEXT, then Query Engine would treat it like string operation.
    • +
    +

    Divide

    +

    Description

    +

    This operator is used to divide two vectors element-wise by using the / operator.

    +

    Syntax

    +
    > SELECT vector1 / vector2 AS result_vector FROM table_name;
    +
    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    ++------+-----------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select b/b from vec_table;
    ++-----------+
    +| b / b     |
    ++-----------+
    +| [1, 1, 1] |
    ++-----------+
    +1 row in set (0.00 sec)
    +
    +

    Constraints

    +
      +
    • If one of the element in denominator vector is zero, then it will throw Division By Zero error. +-Both the argument vectors should be of same dimension
    • +
    • If operation is performed between vecf32 and vecf64, the result is cast to vecf64
    • +
    • If one of the argument is VECTOR in textual format, then the other argument should be of VECTOR type. If both the arguments are TEXT, then Query Engine would treat it like string operation.
    • +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/cosine_similarity/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/cosine_similarity/index.html new file mode 100644 index 000000000..bdca4d823 --- /dev/null +++ b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/cosine_similarity/index.html @@ -0,0 +1,9590 @@ + + + + + + + + + + + + + + + + + + cosine_similarity() - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    cosine_similarity()

    +

    Description

    +

    Cosine similarity measures the cosine of the angle between two vectors, indicating their similarity by how closely they align in a multi-dimensional space, with 1 denoting perfect similarity and -1 indicating perfect dissimilarity. Consine similarity is calculated by dividing Inner Product of two vectors, by the product of their l2 norms.

    +

    cosine_similarity

    +

    Syntax

    +
    > SELECT cosine_similarity(vector1, vector2) AS similarity FROM table_name;
    +
    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    ++------+-----------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select cosine_similarity(b,"[1,2,3]") from vec_table;
    ++-------------------------------+
    +| cosine_similarity(b, [1,2,3]) |
    ++-------------------------------+
    +|                             1 |
    ++-------------------------------+
    +1 row in set (0.00 sec)
    +
    +

    Constraints

    +
      +
    • Both the argument vectors should have same dimensions
    • +
    • Cosine similarity value lies between -1 and 1.
    • +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/inner_product/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/inner_product/index.html new file mode 100644 index 000000000..72018bdb6 --- /dev/null +++ b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/inner_product/index.html @@ -0,0 +1,9587 @@ + + + + + + + + + + + + + + + + + + inner_product() - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    inner_product()

    +

    Description

    +

    The INNER PRODUCT function is used to calculate the inner/dot product between two vectors, which is the result of multiplying corresponding elements of two vectors and then adding them together.

    +

    inner_product

    +

    Syntax

    +
    > SELECT inner_product(vector1, vector2) AS result FROM table_name;
    +
    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    ++------+-----------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select inner_product(b,"[1,2,3]") from vec_table;
    ++---------------------------+
    +| inner_product(b, [1,2,3]) |
    ++---------------------------+
    +|                        14 |
    ++---------------------------+
    +1 row in set (0.00 sec)
    +
    +

    Constraints

    +

    Both the argument vector shoulds be of same dimensions.

    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l1_norm/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l1_norm/index.html new file mode 100644 index 000000000..012a04978 --- /dev/null +++ b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l1_norm/index.html @@ -0,0 +1,9582 @@ + + + + + + + + + + + + + + + + + + l1_norm() - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    l1_norm()

    +

    Description

    +

    The l1_norm function is used to calculate the L1/Manhattan/TaxiCab norm. The L1 norm is obtained by summing the absolute value of vector elements.

    +

    l1_normy

    +

    You can use L1 Norm to calculate L1 Distance.

    +
    l1_distance(a,b) = l1_norm(a-b)
    +
    +

    Same is appicable for calculating L2 distance from L2_Norm.

    +

    Syntax

    +
    > SELECT l1_norm(vector) AS result FROM table_name;
    +
    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    ++------+-----------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select l1_norm(b) from vec_table;
    ++------------+
    +| l1_norm(b) |
    ++------------+
    +|          6 |
    ++------------+
    +1 row in set (0.00 sec)
    +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l2_norm/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l2_norm/index.html new file mode 100644 index 000000000..f770fd37f --- /dev/null +++ b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l2_norm/index.html @@ -0,0 +1,9578 @@ + + + + + + + + + + + + + + + + + + l2_norm() - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    l2_norm()

    +

    Description

    +

    The l2_norm function is used to calculate the L2/Euclidean norm. The L2 norm is obtained by taking the square root of the sum of the squares of the vector elements.

    +

    l2_normy

    +

    Syntax

    +
    > SELECT l2_norm(vector) AS result FROM table_name;
    +
    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    ++------+-----------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select l2_norm(b) from vec_table;
    ++--------------------+
    +| l2_norm(b)         |
    ++--------------------+
    +| 3.7416573867739413 |
    ++--------------------+
    +1 row in set (0.01 sec)
    +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/index.html new file mode 100644 index 000000000..ca833a37a --- /dev/null +++ b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/index.html @@ -0,0 +1,9855 @@ + + + + + + + + + + + + + + + + + + Misc Function - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    Misc Function

    +

    Other support functions on vector include.

    +

    SQRT

    +

    Description

    +

    The sqrt function is used to calculate the square root of each element in a vector.

    +

    Syntax

    +
    > SELECT sqrt(vector_column) FROM table_name;
    +
    +

    Return Type

    +

    Return a new vector of type vecf64 containing the square root of each element in the original vector.

    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    ++------+-----------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select sqrt(b) from vec_table;
    ++---------------------------------------------+
    +| sqrt(b)                                     |
    ++---------------------------------------------+
    +| [1, 1.4142135623730951, 1.7320508075688772] |
    ++---------------------------------------------+
    +1 row in set (0.00 sec)
    +
    +

    Constraints

    +
      +
    • Elements of the vector cannot have -ve.
    • +
    +

    ABS

    +

    Description

    +

    The abs function is used to calculate the absolute value of a vector.

    +

    Syntax

    +
    > SELECT ABS(vector_column) FROM table_name;
    +
    +

    Return Type

    +

    Return a new vector of same type, containing the absolute values of each element in the original vector.

    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[-1,-2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-------------+-----------+
    +| a    | b           | c         |
    ++------+-------------+-----------+
    +|    1 | [-1, -2, 3] | [4, 5, 6] |
    ++------+-------------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select abs(b) from vec_table;
    ++-----------+
    +| abs(b)    |
    ++-----------+
    +| [1, 2, 3] |
    ++-----------+
    +1 row in set (0.01 sec)
    +
    +

    CAST

    +

    Description

    +

    The cast function is used to explicitly convert vector from one vector type to another.

    +

    Syntax

    +
    > SELECT CAST(vector AS vector_type) FROM table_name;
    +
    +

    Arguments

    +
      +
    • vector: input vector
    • +
    • vector_type: new vector type
    • +
    +

    Return Type

    +

    The new vector_type vector.

    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    ++------+-----------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select b + cast("[1,2,3]" as vecf32(3)) from vec_table;
    ++--------------------------------+
    +| b + cast([1,2,3] as vecf32(3)) |
    ++--------------------------------+
    +| [2, 4, 6]                      |
    ++--------------------------------+
    +1 row in set (0.00 sec)
    +
    +

    SUMMATION

    +

    Description

    +

    The summation function returns the sum of all the elements in a vector.

    +

    Syntax

    +
    > SELECT SUMMATION(vector_column) FROM table_name;
    +
    +

    Return Type

    +

    Returns a FLOAT64 value, the sum of all the elements in the vector.

    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    ++------+-----------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> select summation(b) from vec_table;
    ++--------------+
    +| summation(b) |
    ++--------------+
    +|            6 |
    ++--------------+
    +1 row in set (0.00 sec)
    +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/vector_dims/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/vector_dims/index.html new file mode 100644 index 000000000..a6cb97e48 --- /dev/null +++ b/dev/MatrixOne/Reference/Functions-and-Operators/1.1-Vector/vector_dims/index.html @@ -0,0 +1,9580 @@ + + + + + + + + + + + + + + + + + + vector_dims() - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    vector_dims()

    +

    Description

    +

    The vector_dims function is used to determine the dimension of a vector.

    +

    Syntax

    +
    > SELECT vector_dims(vector) AS dimension_count FROM table_name;
    +
    +

    Examples

    +
    drop table if exists vec_table;
    +create table vec_table(a int, b vecf32(3), c vecf64(3));
    +insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
    +insert into vec_table values(2, "[7,8,9]", "[1,2,3]");
    +mysql> select * from vec_table;
    ++------+-----------+-----------+
    +| a    | b         | c         |
    ++------+-----------+-----------+
    +|    1 | [1, 2, 3] | [4, 5, 6] |
    +|    2 | [7, 8, 9] | [1, 2, 3] |
    ++------+-----------+-----------+
    +2 row in set (0.00 sec)
    +
    +mysql> select vector_dims(b) from vec_table;
    ++----------------+
    +| vector_dims(b) |
    ++----------------+
    +|              3 |
    +|              3 |
    ++----------------+
    +2 row in set (0.01 sec)
    +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/index.html index 54ff7bbfc..9e70eba21 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9504,7 +9729,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/index.html index be2245270..054507b3d 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9509,7 +9734,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/index.html index 716b30ea6..56e405615 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9470,7 +9695,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/index.html index 0d272a9c7..abfe39181 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9470,7 +9695,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/index.html index 90032afd8..8aacd5b7a 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9470,7 +9695,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/index.html index 1c7f92a45..ec5b56185 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9501,7 +9726,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/index.html index 9fdc8d92c..7132f6fec 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9519,7 +9744,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/index.html index 7629afbba..83e133756 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9498,7 +9723,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/index.html index 0deae040d..fceb9c5cd 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9530,7 +9755,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/index.html index 533b12c79..1644f6c9a 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9498,7 +9723,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/index.html index fa50de3c9..68f30a7be 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9478,7 +9703,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/index.html index a31a202da..a645d9852 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9520,7 +9745,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/index.html index 8f0ef9b78..332714ed3 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9476,7 +9701,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/index.html index e80facd4a..c59476fb3 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9467,7 +9692,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/index.html index bb851ef64..5b4feed38 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9501,7 +9726,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/index.html index d877a0c58..50c14930b 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9489,7 +9714,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/index.html index 8b3ce9a75..92549bc40 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9395,6 +9615,11 @@ + + + + + @@ -9750,7 +9975,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/index.html index 9bf46ca07..984a78143 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9490,7 +9715,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date/index.html index 695e6fb1a..5e7e6d446 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/date/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9506,7 +9731,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/index.html index bfa6c758a..58842de36 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9494,7 +9719,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/day/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/day/index.html index 1e012e329..5a3bda4ae 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/day/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/day/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9482,7 +9707,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/index.html index 3cbb5983f..5f8cb80e1 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9515,7 +9740,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/extract/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/extract/index.html index 5f1351525..f662c9c44 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/extract/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/extract/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9486,7 +9711,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/index.html index 07b3947ea..cc9a8670b 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9491,7 +9716,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/hour/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/hour/index.html index 814cd3bdc..97f07ba34 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/hour/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/hour/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9488,7 +9713,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/minute/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/minute/index.html index 30900433d..63fac51af 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/minute/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/minute/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9503,7 +9728,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/month/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/month/index.html index c1db0d04a..a2fc563bb 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/month/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/month/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9367,6 +9587,11 @@ + + + + + @@ -9546,7 +9771,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/second/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/second/index.html index 8483ae4a6..0395b6840 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/second/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/second/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9491,7 +9716,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/time/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/time/index.html index dc364880d..6b46bfc00 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/time/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/time/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9463,7 +9688,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/index.html index 87b597936..1c0e67a8b 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9517,7 +9742,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/index.html index 053617ebe..da9f38e5a 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9498,7 +9723,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/index.html index 746c5ce48..8b00c5742 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9504,7 +9729,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/index.html index 55472dc41..1f748439e 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9487,7 +9712,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/index.html index 1251a3295..4f010d8ff 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9453,7 +9678,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/index.html index 3de1fca41..109f980f6 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9469,7 +9694,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/index.html index 90d49a0cf..e3c6dbd69 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9395,6 +9615,11 @@ + + + + + @@ -9553,7 +9778,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/index.html index 3bee54a74..db354b014 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9381,6 +9601,11 @@ + + + + + @@ -9597,7 +9822,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/week/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/week/index.html index be344427a..6c1156a70 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/week/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/week/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9505,7 +9730,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/index.html index ce330d62e..1219a3e9a 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9367,6 +9587,11 @@ + + + + + @@ -9546,7 +9771,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/year/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/year/index.html index 5a2b2003e..f8f781bbe 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/year/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Datetime/year/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9505,7 +9730,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Json/json-functions/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Json/json-functions/index.html index b7e050a8e..8bf09e96c 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Json/json-functions/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Json/json-functions/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9703,7 +9928,7 @@

    JSON_UNQUOTE()

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/index.html index 8fe8edbec..3c627751f 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9470,7 +9695,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/index.html index 4d3724c22..423816193 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9469,7 +9694,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/index.html index fb74c7a50..dd96ebaac 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9469,7 +9694,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/index.html index b2e94b4d2..6b43f9952 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9498,7 +9723,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/index.html index 11c962460..121ea9052 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9469,7 +9694,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/index.html index ce0969a38..2d0d36885 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9477,7 +9702,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/index.html index 6839b43a4..41b920646 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9469,7 +9694,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/index.html index 5e3065678..8ce31ad30 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9521,7 +9746,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/index.html index 81a9f81ec..9be455f80 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9327,6 +9547,11 @@ + + + + + @@ -9412,7 +9637,7 @@

    Syntax

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/log/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/log/index.html index e4c7b3620..504eaafe1 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/log/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/log/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9483,7 +9708,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/index.html index 43317bb22..04f847a56 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9461,7 +9686,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/power/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/power/index.html index 925121a3b..ea1a53faa 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/power/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/power/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9487,7 +9712,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/index.html index 7478ea2fc..689256011 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9518,7 +9743,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/round/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/round/index.html index b5cb40632..43f4e521b 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/round/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/round/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9533,7 +9758,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/index.html index 381874e3d..7e951d8a1 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9469,7 +9694,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/index.html index 93cbea56c..241c037f6 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9468,7 +9693,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/index.html index 4ea2eb699..eb3ff515d 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9469,7 +9694,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Other/sleep/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Other/sleep/index.html index 0d78e8f07..31eb8a085 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Other/sleep/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Other/sleep/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9546,7 +9771,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Other/uuid/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Other/uuid/index.html index 0d4d1caf1..31b489f7e 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Other/uuid/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Other/uuid/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9481,7 +9706,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/index.html index dfbe42329..b2a578521 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9564,7 +9789,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/index.html index afaa7513d..68b1ce59a 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9480,7 +9705,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/index.html index 5583aded6..26e48546b 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9502,7 +9727,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/index.html index 72c439a0b..35083a048 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9494,7 +9719,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/index.html index 551046f8b..bb29ca3dd 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9486,7 +9711,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/index.html index 567e646ce..e1ea22f7e 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9483,7 +9708,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/bin/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/bin/index.html index 7cc29cfcf..f153bfa87 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/bin/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/bin/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9472,7 +9697,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/bit-length/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/bit-length/index.html index 2dbed0b41..d0dfdac13 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/bit-length/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/bit-length/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9463,7 +9688,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/char-length/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/char-length/index.html index 33b004b97..6640715e2 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/char-length/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/char-length/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9469,7 +9694,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/concat-ws/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/concat-ws/index.html index ec5cb59f6..763757f1d 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/concat-ws/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/concat-ws/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9478,7 +9703,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/concat/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/concat/index.html index 53e5bdf5c..49f1758da 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/concat/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/concat/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9489,7 +9714,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/empty/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/empty/index.html index e0244f32b..d8b23da8f 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/empty/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/empty/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9484,7 +9709,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/endswith/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/endswith/index.html index 4ac2d4ca1..67ae6cfd3 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/endswith/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/endswith/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9506,7 +9731,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/field/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/field/index.html index c9d6fc624..cea6da78e 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/field/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/field/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9563,7 +9788,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/find-in-set/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/find-in-set/index.html index 6c024b455..a789e6de6 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/find-in-set/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/find-in-set/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9466,7 +9691,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/format/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/format/index.html index 02dc11e0a..6c6936386 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/format/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/format/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9519,7 +9744,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/hex/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/hex/index.html index 5d2be9d2b..e5bc32894 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/hex/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/hex/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9477,7 +9702,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/instr/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/instr/index.html index d617a6757..1c025a871 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/instr/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/instr/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9520,7 +9745,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/left/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/left/index.html index b93ef6633..b5318141c 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/left/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/left/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9502,7 +9727,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/length/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/length/index.html index 017949c12..2329d27c2 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/length/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/length/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9462,7 +9687,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/lpad/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/lpad/index.html index 80b7cb189..b4332f244 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/lpad/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/lpad/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9518,7 +9743,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/ltrim/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/ltrim/index.html index 6201b45e6..021eca067 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/ltrim/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/ltrim/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9466,7 +9691,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/oct/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/oct/index.html index 3d20b6c8d..c3d52a1ea 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/oct/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/oct/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9463,7 +9688,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/repeat/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/repeat/index.html index 669bf4879..7f30646bb 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/repeat/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/repeat/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9475,7 +9700,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/reverse/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/reverse/index.html index 5e374e75a..5841ba4f3 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/reverse/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/reverse/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9487,7 +9712,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/rpad/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/rpad/index.html index 1f2a82d98..ccc03e36f 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/rpad/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/rpad/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9518,7 +9743,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/rtrim/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/rtrim/index.html index 5853222a0..7fa1c597c 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/rtrim/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/rtrim/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9466,7 +9691,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/space/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/space/index.html index 018c69a00..4e7e41825 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/space/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/space/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9482,7 +9707,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/split_part/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/split_part/index.html index f58440e8a..9b6a0b421 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/split_part/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/split_part/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9505,7 +9730,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/startswith/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/startswith/index.html index 7b17e7d33..87f228216 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/startswith/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/startswith/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9369,6 +9589,11 @@ + + + + + @@ -9505,7 +9730,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/substring-index/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/substring-index/index.html index 88a89b61a..fe0d74d64 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/substring-index/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/substring-index/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9521,7 +9746,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/substring/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/substring/index.html index 33f379ff5..83d31ca5b 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/substring/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/substring/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9505,7 +9730,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/String/trim/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/String/trim/index.html index e40f44a3d..350ef961e 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/String/trim/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/String/trim/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9507,7 +9732,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Table/unnest/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Table/unnest/index.html index 5314f6c46..460f9cd84 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Table/unnest/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Table/unnest/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9514,7 +9739,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/index.html index ed6109f6e..e532ab82e 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9470,7 +9695,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/index.html index e189e3331..d42d7edd7 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9475,7 +9700,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/index.html index e36220ade..91d8434c7 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9473,7 +9698,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/index.html index 506c9470a..0e92e68bb 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9447,7 +9672,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/index.html index 9c41d0e2b..e60ecdd24 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9434,7 +9659,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/index.html index c0b4aba44..95c0c2983 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9434,7 +9659,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/index.html index c942d0e63..f30effbae 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9434,7 +9659,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/index.html index 37797e17f..5e35e5bae 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9512,7 +9737,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/version/index.html b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/version/index.html index 447479f98..5716a2c1e 100644 --- a/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/version/index.html +++ b/dev/MatrixOne/Reference/Functions-and-Operators/system-ops/version/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9270,6 +9490,11 @@ + + + + + @@ -9327,7 +9552,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Reference/Language-Structure/comment/index.html b/dev/MatrixOne/Reference/Language-Structure/comment/index.html index 2dfec5f22..a96fd8ea8 100644 --- a/dev/MatrixOne/Reference/Language-Structure/comment/index.html +++ b/dev/MatrixOne/Reference/Language-Structure/comment/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9337,6 +9557,11 @@ + + + + + @@ -9504,7 +9729,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Language-Structure/keywords/index.html b/dev/MatrixOne/Reference/Language-Structure/keywords/index.html index bf4405ac3..88fcae436 100644 --- a/dev/MatrixOne/Reference/Language-Structure/keywords/index.html +++ b/dev/MatrixOne/Reference/Language-Structure/keywords/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -10033,6 +10253,11 @@ + + + + + @@ -10646,7 +10871,7 @@

    Z

    - + diff --git a/dev/MatrixOne/Reference/Limitations/mo-jdbc-feature-list/index.html b/dev/MatrixOne/Reference/Limitations/mo-jdbc-feature-list/index.html index d812c7586..2269dfe07 100644 --- a/dev/MatrixOne/Reference/Limitations/mo-jdbc-feature-list/index.html +++ b/dev/MatrixOne/Reference/Limitations/mo-jdbc-feature-list/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9403,6 +9623,11 @@ + + + + + @@ -10322,7 +10547,7 @@

    DisplaySize, P
    - + diff --git a/dev/MatrixOne/Reference/Limitations/mo-partition-support/index.html b/dev/MatrixOne/Reference/Limitations/mo-partition-support/index.html index a827e9841..70866f002 100644 --- a/dev/MatrixOne/Reference/Limitations/mo-partition-support/index.html +++ b/dev/MatrixOne/Reference/Limitations/mo-partition-support/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9443,6 +9663,11 @@ + + + + + @@ -9632,7 +9857,7 @@

    HASH Partitioning

    - + diff --git a/dev/MatrixOne/Reference/Operators/interval/index.html b/dev/MatrixOne/Reference/Operators/interval/index.html index b045278ef..eaa3e49cf 100644 --- a/dev/MatrixOne/Reference/Operators/interval/index.html +++ b/dev/MatrixOne/Reference/Operators/interval/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9435,6 +9655,11 @@ + + + + + @@ -9793,7 +10018,7 @@

    Example 5

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/index.html b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/index.html index 7cd89eebb..a572a6c86 100644 --- a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9460,7 +9685,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/index.html b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/index.html index 495e6876c..97ef2bfb0 100644 --- a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9315,6 +9535,11 @@ + + + + + @@ -9451,7 +9676,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/div/index.html b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/div/index.html index 807822747..6814f220a 100644 --- a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/div/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/div/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9461,7 +9686,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/division/index.html b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/division/index.html index 2d3110260..905b691b8 100644 --- a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/division/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/division/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9461,7 +9686,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/index.html b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/index.html index 1c7cc5133..d7287fc92 100644 --- a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9460,7 +9685,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/index.html b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/index.html index d0c4def60..4d4d7f462 100644 --- a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9458,7 +9683,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/index.html b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/index.html index ed0c29577..041416bb5 100644 --- a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9460,7 +9685,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/index.html b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/index.html index 8475d0696..203ea6d6e 100644 --- a/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9449,7 +9674,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/index.html b/dev/MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/index.html index c87345e24..4a38e5284 100644 --- a/dev/MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9309,6 +9529,11 @@ + + + + + @@ -9404,7 +9629,7 @@

    Assignment Operators Overview - + diff --git a/dev/MatrixOne/Reference/Operators/operators/assignment-operators/equal/index.html b/dev/MatrixOne/Reference/Operators/operators/assignment-operators/equal/index.html index 62b6a6b98..463b9ee23 100644 --- a/dev/MatrixOne/Reference/Operators/operators/assignment-operators/equal/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/assignment-operators/equal/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9454,7 +9679,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bit-functions-and-operators-overview/index.html b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bit-functions-and-operators-overview/index.html index 222492054..cd4f57562 100644 --- a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bit-functions-and-operators-overview/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bit-functions-and-operators-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9269,6 +9489,11 @@ + + + + + @@ -9384,7 +9609,7 @@

    Bit Functions and Operators - + diff --git a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/index.html b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/index.html index 1bd270209..b0f700f6d 100644 --- a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9456,7 +9681,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/index.html b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/index.html index 9bcfdafa9..9bec1500e 100644 --- a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9462,7 +9687,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/index.html b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/index.html index 372751dd0..322e40dee 100644 --- a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9472,7 +9697,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/index.html b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/index.html index 5aadbbe62..7d829fea9 100644 --- a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9481,7 +9706,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/index.html b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/index.html index 8741ee9e8..65d64f7ef 100644 --- a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9474,7 +9699,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/index.html b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/index.html index dc6f02f08..56529d8ec 100644 --- a/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9474,7 +9699,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/index.html b/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/index.html index 267f2f6b6..3c30f945e 100644 --- a/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9474,7 +9699,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast-functions-and-operators-overview/index.html b/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast-functions-and-operators-overview/index.html index 3e0082486..07ce5e08b 100644 --- a/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast-functions-and-operators-overview/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast-functions-and-operators-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9269,6 +9489,11 @@ + + + + + @@ -9370,7 +9595,7 @@

    Cast Functions and Operators - + diff --git a/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/index.html b/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/index.html index 62cf0c09e..20b1fdb3b 100644 --- a/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9371,6 +9591,11 @@ + + + + + @@ -9509,7 +9734,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/index.html b/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/index.html index 9de3d7711..34cb4dcd9 100644 --- a/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9371,6 +9591,11 @@ + + + + + @@ -9515,7 +9740,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/index.html index a0ffbed40..caa17f767 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9455,7 +9680,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/index.html index 7745abb44..8d6ecd85d 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9456,7 +9681,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/index.html index 1bf8ca466..c4ba0d11c 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9633,7 +9858,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/comparison-functions-and-operators-overview/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/comparison-functions-and-operators-overview/index.html index 85176715f..e37572187 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/comparison-functions-and-operators-overview/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/comparison-functions-and-operators-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9269,6 +9489,11 @@ + + + + + @@ -9438,7 +9663,7 @@

    Comparison Function
    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/index.html index 2e1a8c145..bcdd05e07 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9270,6 +9490,11 @@ + + + + + @@ -9321,7 +9546,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/index.html index 04a6777b8..a90922c87 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9466,7 +9691,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_least/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_least/index.html index 1f482b53b..292b926db 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_least/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_least/index.html @@ -11,7 +11,7 @@ - + @@ -2116,6 +2116,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9234,6 +9454,11 @@ + + + + + @@ -9279,7 +9504,7 @@

    Function least

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/index.html index 4c425a40a..47f85ed9c 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9270,6 +9490,11 @@ + + + + + @@ -9321,7 +9546,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/index.html index 0818333de..e3c25c815 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9453,7 +9678,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/index.html index 1aa35318e..19bdf1669 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9457,7 +9682,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/index.html index 8bf814d07..373f4d45e 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9446,7 +9671,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/index.html index 4ef682ee2..9a87235b5 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9477,7 +9702,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/index.html index 4e605b0eb..1bf61e458 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9461,7 +9686,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/index.html index 6dc21714e..07d75680a 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9436,7 +9661,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/index.html index 81d656b63..3bbf1cd39 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9458,7 +9683,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/index.html index 8258f8694..0bfefa951 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9459,7 +9684,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/index.html index d1d461db0..5d2ee112b 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9456,7 +9681,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/index.html index 5576fa29d..b60a2225e 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9465,7 +9690,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/index.html index caa6982f6..bc4b11964 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9463,7 +9688,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/index.html index 6ff1d2e17..4835bb44e 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9455,7 +9680,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/index.html index c656c4a14..cc6fe9990 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9453,7 +9678,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/index.html index 2b84b564a..bb5b4a236 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9480,7 +9705,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/index.html b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/index.html index b49c225d7..5849c8802 100644 --- a/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9458,7 +9683,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/index.html b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/index.html index 9c91ea8da..d491e7575 100644 --- a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9468,7 +9693,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/flow-control-functions-overview/index.html b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/flow-control-functions-overview/index.html index 38a2a278f..e04305a6a 100644 --- a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/flow-control-functions-overview/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/flow-control-functions-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9269,6 +9489,11 @@ + + + + + @@ -9374,7 +9599,7 @@

    Flow Control Functions

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/index.html b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/index.html index 9d8ebc92c..b1aecaa90 100644 --- a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9512,7 +9737,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/index.html b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/index.html index bd938aad9..7b032049c 100644 --- a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9445,7 +9670,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/index.html b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/index.html index 856e45cec..9804ae8a7 100644 --- a/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9444,7 +9669,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/logical-operators/and/index.html b/dev/MatrixOne/Reference/Operators/operators/logical-operators/and/index.html index 40505bc5e..1fc615dc8 100644 --- a/dev/MatrixOne/Reference/Operators/operators/logical-operators/and/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/logical-operators/and/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9468,7 +9693,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/logical-operators/logical-operators-overview/index.html b/dev/MatrixOne/Reference/Operators/operators/logical-operators/logical-operators-overview/index.html index 7c8e2a874..73ce91fbd 100644 --- a/dev/MatrixOne/Reference/Operators/operators/logical-operators/logical-operators-overview/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/logical-operators/logical-operators-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9269,6 +9489,11 @@ + + + + + @@ -9374,7 +9599,7 @@

    Logical Operators

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/logical-operators/not/index.html b/dev/MatrixOne/Reference/Operators/operators/logical-operators/not/index.html index 61a471901..502663d17 100644 --- a/dev/MatrixOne/Reference/Operators/operators/logical-operators/not/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/logical-operators/not/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9357,6 +9577,11 @@ + + + + + @@ -9481,7 +9706,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/logical-operators/or/index.html b/dev/MatrixOne/Reference/Operators/operators/logical-operators/or/index.html index f2e6ed206..1bb1ba09c 100644 --- a/dev/MatrixOne/Reference/Operators/operators/logical-operators/or/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/logical-operators/or/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9483,7 +9708,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/logical-operators/xor/index.html b/dev/MatrixOne/Reference/Operators/operators/logical-operators/xor/index.html index e11305511..2de2dbe9e 100644 --- a/dev/MatrixOne/Reference/Operators/operators/logical-operators/xor/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/logical-operators/xor/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9343,6 +9563,11 @@ + + + + + @@ -9476,7 +9701,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/operator-precedence/index.html b/dev/MatrixOne/Reference/Operators/operators/operator-precedence/index.html index 9645944bb..f0a44cbbc 100644 --- a/dev/MatrixOne/Reference/Operators/operators/operator-precedence/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/operator-precedence/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9267,6 +9487,11 @@ + + + + + @@ -9429,7 +9654,7 @@

    Operator Precedence

    - + diff --git a/dev/MatrixOne/Reference/Operators/operators/operators/index.html b/dev/MatrixOne/Reference/Operators/operators/operators/index.html index effcf78f8..a7fb891ac 100644 --- a/dev/MatrixOne/Reference/Operators/operators/operators/index.html +++ b/dev/MatrixOne/Reference/Operators/operators/operators/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9397,6 +9617,11 @@ + + + + + @@ -9729,7 +9954,7 @@

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/index.html index 9d1a104d1..6cc3bf249 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9304,6 +9524,11 @@ + + + + + @@ -9452,7 +9677,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/index.html index 9ce45d516..54c05dbda 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9407,6 +9627,11 @@ + + + + + @@ -9577,7 +9802,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/index.html index 810dcda1c..40441ab5f 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9379,6 +9599,11 @@ + + + + + @@ -9500,7 +9725,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/index.html index 319c78374..58699d622 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9489,7 +9714,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/index.html index b18b0271a..4fa6dd6dd 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9428,7 +9653,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/index.html index 880c7e85c..4da7b37cc 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9419,6 +9639,11 @@ + + + + + @@ -9535,7 +9760,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/index.html index 0d7b83776..aa3b75f52 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9431,7 +9656,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/index.html index 49c65c58f..535197e84 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9431,7 +9656,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/index.html index b512b780b..03274f53e 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9431,7 +9656,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/index.html index 4b62abe0f..5ce58527a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9445,6 +9665,11 @@ + + + + + @@ -9615,7 +9840,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/index.html index 2fdbba420..225a7d7b2 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9462,7 +9687,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence/index.html new file mode 100644 index 000000000..03ee38261 --- /dev/null +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence/index.html @@ -0,0 +1,9684 @@ + + + + + + + + + + + + + + + + + + ALTER SEQUENCE - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    ALTER SEQUENCE

    +

    Description

    +

    ALTER SEQUENCE is used to modify an existing sequence.

    +

    Syntax

    +
    > ALTER SEQUENCE [ IF EXISTS ] SEQUENCE_NAME
    +[ AS data_type ]
    +[ INCREMENT [ BY ] increment ]
    +[ MINVALUE minvalue] [ MAXVALUE maxvalue]
    +[ START [ WITH ] start ] [ [ NO ] CYCLE ]
    +
    +

    Explanations

    +
      +
    • +

      [ IF EXISTS ]: An optional clause that indicates that if the specified sequence does not exist, it will not raise an error. If this clause is used, the system checks if the sequence exists; if it does not, it will ignore the modification request.

      +
    • +
    • +

      SEQUENCE_NAME: The name of the sequence to be modified.

      +
    • +
    • +

      [ AS data_type ]: An optional clause that allows you to specify the data type for the sequence. Typically, the data type of a sequence is an integer.

      +
    • +
    • +

      [ INCREMENT [ BY ] increment ]: This specifies the increment value for the sequence. The increment value of the sequence is the amount to be added to the current value each time it is incremented or decremented. If the increment value is not specified, it is typically set to 1.

      +
    • +
    • +

      [ MINVALUE minvalue ]: This is the minimum value of the sequence, specifying the minimum value allowed for the sequence. If a minimum value is set, the sequence's current value cannot go below this value.

      +
    • +
    • +

      [ MAXVALUE maxvalue ]: This is the maximum value of the sequence, specifying the maximum value allowed for the sequence. If a maximum value is specified, the sequence's current value cannot exceed this value.

      +
    • +
    • +

      [ START [ WITH ] start ]: This is the sequence's starting value, specifying the sequence's initial value. If the starting value is not specified, it is typically set to 1.

      +
    • +
    • +

      [ [ NO ] CYCLE ]: An optional clause used to specify whether the sequence values should cycle. If NO CYCLE is specified, the sequence will stop incrementing or decrementing after reaching the maximum or minimum value. If this clause is not specified, it typically defaults to not cycling.

      +
    • +
    +

    Examples

    +
    -- Create a sequence named alter_seq_01 with an increment of 2, a minimum value of 30, a maximum value of 100, and enable cycling
    +create sequence alter_seq_01 as smallint increment by 2 minvalue 30 maxvalue 100 cycle;
    +
    +mysql> show sequences;
    ++--------------+-----------+
    +| Names        | Data Type |
    ++--------------+-----------+
    +| alter_seq_01 | SMALLINT  |
    ++--------------+-----------+
    +1 row in set (0.00 sec)
    +
    +mysql> alter sequence alter_seq_01 as bigint;
    +Query OK, 0 rows affected (0.01 sec)
    +
    +mysql> show sequences;
    ++--------------+-----------+
    +| Names        | Data Type |
    ++--------------+-----------+
    +| alter_seq_01 | BIGINT    |
    ++--------------+-----------+
    +1 row in set (0.00 sec)
    +
    +-- Remove cycling for sequence alter_seq_01
    +mysql> alter sequence alter_seq_01 no cycle;
    +Query OK, 0 rows affected (0.01 sec)
    +
    +mysql> select nextval('alter_seq_01'),currval('alter_seq_01');
    ++-----------------------+-----------------------+
    +| nextval(alter_seq_01) | currval(alter_seq_01) |
    ++-----------------------+-----------------------+
    +| 30                    | 30                    |
    ++-----------------------+-----------------------+
    +1 row in set (0.01 sec)
    +
    +mysql> select nextval('alter_seq_01'),currval('alter_seq_01');
    ++-----------------------+-----------------------+
    +| nextval(alter_seq_01) | currval(alter_seq_01) |
    ++-----------------------+-----------------------+
    +| 32                    | 32                    |
    ++-----------------------+-----------------------+
    +1 row in set (0.00 sec)
    +
    +-- Set the starting value of sequence alter_seq_01 to 40
    +mysql> alter sequence alter_seq_01 start with 40;
    +Query OK, 0 rows affected (0.01 sec)
    +
    +mysql> select nextval('alter_seq_01'),currval('alter_seq_01');
    ++-----------------------+-----------------------+
    +| nextval(alter_seq_01) | currval(alter_seq_01) |
    ++-----------------------+-----------------------+
    +| 40                    | 40                    |
    ++-----------------------+-----------------------+
    +1 row in set (0.01 sec)
    +
    +mysql> select nextval('alter_seq_01'),currval('alter_seq_01');
    ++-----------------------+-----------------------+
    +| nextval(alter_seq_01) | currval(alter_seq_01) |
    ++-----------------------+-----------------------+
    +| 42                    | 42                    |
    ++-----------------------+-----------------------+
    +1 row in set (0.00 sec)
    +
    +-- Set the increment value of sequence alter_seq_01 to 3
    +mysql> alter sequence alter_seq_01 increment by 3;
    +Query OK, 0 rows affected (0.01 sec)
    +
    +mysql> select nextval('alter_seq_01'),currval('alter_seq_01');
    ++-----------------------+-----------------------+
    +| nextval(alter_seq_01) | currval(alter_seq_01) |
    ++-----------------------+-----------------------+
    +| 40                    | 40                    |
    ++-----------------------+-----------------------+
    +1 row in set (0.00 sec)
    +
    +mysql> select nextval('alter_seq_01'),currval('alter_seq_01');
    ++-----------------------+-----------------------+
    +| nextval(alter_seq_01) | currval(alter_seq_01) |
    ++-----------------------+-----------------------+
    +| 43                    | 43                    |
    ++-----------------------+-----------------------+
    +1 row in set (0.00 sec)
    +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-replace-view/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-replace-view/index.html new file mode 100644 index 000000000..c8a7fe8f9 --- /dev/null +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-replace-view/index.html @@ -0,0 +1,9635 @@ + + + + + + + + + + + + + + + + + + CREATE OR REPLACE VIEW - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    CREATE OR REPLACE VIEW

    +

    Description

    +

    CREATE OR REPLACE VIEW is used to create a new view or, when the view already exists, replace the existing view. This means updating the definition of the view when it already exists without the need to delete the existing view.

    +

    Syntax

    +
    > CREATE OR REPLACE VIEW view_name AS
    +SELECT column1, column2, ...
    +FROM table_name
    +WHERE condition;
    +
    +

    Explanations

    +
      +
    • +

      view_name: The name of the view to be created or replaced. You need to specify a unique name for the view.

      +
    • +
    • +

      AS: Indicates that the following query statement is the query definition of the view.

      +
    • +
    • +

      SELECT column1, column2, ...: After the AS keyword, you need to specify the query definition of the view. This SELECT statement can select specific columns from a table using computed fields, expressions, and more. The view will use the result of this query as its data.

      +
    • +
    • +

      FROM table_name: The FROM clause is used to specify the table's name to be queried. Select one or more tables and perform related operations in the view.

      +
    • +
    • +

      WHERE condition: An optional WHERE clause used to filter the query results.

      +
    • +
    +

    Examples

    +
    -- Create a table t1 with two columns, a and b
    +create table t1 (a int, b int);
    +
    +-- Insert three rows of data into table t1
    +insert into t1 values (1, 11), (2, 22), (3, 33);
    +
    +-- Create a view v1 that includes all data from table t1
    +create view v1 as select * from t1;
    +
    +-- Query all data from view v1
    +mysql> select * from v1;
    ++------+------+
    +| a    | b    |
    ++------+------+
    +|    1 |   11 |
    +|    2 |   22 |
    +|    3 |   33 |
    ++------+------+
    +3 rows in set (0.01 sec)
    +
    +-- Query data from view v1 where column a is greater than 1
    +mysql> select * from v1 where a > 1;
    ++------+------+
    +| a    | b    |
    ++------+------+
    +|    2 |   22 |
    +|    3 |   33 |
    ++------+------+
    +2 rows in set (0.00 sec)
    +
    +-- Replace view v1 with a new view that only includes data from table t1 where column a is greater than 1
    +create or replace view v1 as select * from t1 where a > 1;
    +
    +-- Query view v1 again, now containing data that meets the new condition
    +mysql> select * from v1;
    ++------+------+
    +| a    | b    |
    ++------+------+
    +|    2 |   22 |
    +|    3 |   33 |
    ++------+------+
    +2 rows in set (0.00 sec)
    +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-stage/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-stage/index.html new file mode 100644 index 000000000..c0d38975a --- /dev/null +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-stage/index.html @@ -0,0 +1,9664 @@ + + + + + + + + + + + + + + + + + + CREATE STAGE - MatrixOne Docs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    + + + + + + + +
    + +
    + + + + +
    +
    + + + +
    +
    +
    + + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    + + + + + + + + + + + + +

    CREATE STAGE

    +

    Description

    +

    The CREATE STAGE command is used in the MatrixOne database to create a named internal or external data stage for data export. By creating a data stage and exporting data to it, you can download data files to your local system or store them in cloud storage services.

    +
      +
    • +

      Internal Stage: Internal stages store data files within the MatrixOne system. Internal stages can be either permanent or temporary.

      +
    • +
    • +

      External Stage: External stages reference data files stored outside the MatrixOne environment. Currently, the following cloud storage services are supported:

      +
        +
      • Amazon S3 buckets
      • +
      • Aliyun buckets
      • +
      +
    • +
    +

    The storage location can be private/protected or public—however, data held in archival cloud storage classes that require restoration before retrieval cannot be accessed.

    +

    An internal or external stage can include a directory table. Directory tables maintain a catalog of staged file directories in cloud storage.

    +
      +
    • +

      Configure a specified path to control the write permissions for user SELECT INTO operations. After creation, users can only write to the set STAGE path.

      +
    • +
    • +

      If no STAGE is created or all STAGE instances are DISABLED, users can write to any path permitted by the operating system or object storage permissions.

      +
    • +
    • +

      If not using a STAGE, users must forcefully include credential information during SELECT INTO operations.

      +
    • +
    +
    +

    Note

    +
      +
    1. Cluster administrators (i.e., root users) and tenant administrators can create data stages.
    2. +
    3. Once created, data tables can only be imported to the paths specified in the STAGE.
    4. +
    +
    +

    Syntax

    +
    > CREATE STAGE [ IF NOT EXISTS ] { stage_name }
    +   { StageParams }
    +   [ directoryTableParams ]
    +   [ COMMENT = '<string_literal>' ]
    +
    +StageParams (for Amazon S3) :
    +URL =  "endpoint"='<string>' CREDENTIALS = {"access_key_id"='<string>', "secret_access_key"='<string>', "filepath"='<string>', "region"='<string>'}
    +
    +StageParams (for Aliyun OSS) :
    +URL =  "endpoint"='<string>' CREDENTIALS = {"access_key_id"='<string>', "secret_access_key"='<string>'}
    +
    +StageParams (for File System) :
    +URL= 'filepath'
    +
    +directoryTableParams :
    +ENABLE = { TRUE | FALSE }
    +
    +

    Explanations

    +
      +
    • +

      IF NOT EXISTS: An optional parameter used to check whether a stage with the same name already exists when creating a stage, avoiding duplicate creations.

      +
    • +
    • +

      stage_name: The name of the stage to be created.

      +
    • +
    • +

      StageParams: This parameter group is used to specify the stage's configuration parameters.

      +
        +
      • +

        endpoint: The connection URL for the stage, indicating the location of the object storage service. This URL's content may vary for object storage services like Amazon S3, Aliyun OSS, or a file system. For example s3.us-west-2.amazonaws.com

        +
      • +
      • +

        CREDENTIALS: This JSON object contains the credentials required to connect to the object storage service.

        +
          +
        • access_key_id: Access key ID used for authentication.
        • +
        • secret_access_key: Key associated with the access key ID for authentication.
        • +
        • "filepath"='<string>': Specifies the file path or directory in the S3 storage.
        • +
        • "region"='<string>': Specifies the AWS region where the Amazon S3 storage is located.
        • +
        +
      • +
      +
    • +
    • +

      directoryTableParams: This parameter group is used to specify the configuration of a directory table associated with the stage.

      +
        +
      • ENABLE: Indicates whether the directory table is enabled, with values TRUE or FALSE values.
      • +
      +
    • +
    +

    Examples

    +
    CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));
    +INSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');
    +
    +-- Create internal data stage
    +mysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;
    +
    +-- Export data from the table to data stage
    +mysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';
    +-- You can see your exported table in your local directory
    +
    +-- After setting the data stage, the data table can only be exported to the specified path, and an error will be reported when exporting to other paths
    +mysql> SELECT * FROM user INTO OUTFILE '~/tmp/csv2/user.txt';
    +ERROR 20101 (HY000): internal error: stage exists, please try to check and use a stage instead
    +
    + + + + + + +
    +
    + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + + + + \ No newline at end of file diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/index.html index 8158374e0..f03f17852 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9353,6 +9573,11 @@ + + + + + @@ -9474,7 +9699,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/index.html index 47e6f2eca..22adb82ab 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9365,6 +9585,11 @@ + + + + + @@ -9539,7 +9764,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/index.html index 1c67fa38e..2f1fd91cb 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9379,6 +9599,11 @@ + + + + + @@ -9688,7 +9913,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/index.html index 61ca52b94..752087507 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9464,7 +9689,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/index.html index c771fd6d9..968eb3a64 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9353,6 +9573,11 @@ + + + + + @@ -9468,7 +9693,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/index.html index 5aa534a20..94b3e798b 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9433,6 +9653,11 @@ + + + + + @@ -9594,7 +9819,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/index.html index d99c3cd1e..53ace6713 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9557,7 +9782,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/index.html index f0f62df5c..1e3747d86 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9367,6 +9587,11 @@ + + + + + @@ -9470,7 +9695,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/index.html index 73f85d232..6aa9a2eb8 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9545,6 +9765,11 @@ + + + + + @@ -9772,7 +9997,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/index.html index a88f1b23f..f082f5666 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9365,6 +9585,11 @@ + + + + + @@ -9537,7 +9762,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/index.html index ca584119d..b777ea46a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9353,6 +9573,11 @@ + + + + + @@ -9529,7 +9754,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/index.html index dc9fd6eb3..72854097b 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9489,6 +9709,11 @@ + + + + + @@ -10199,7 +10424,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/index.html index 0a2cb7e85..eaaaac5e3 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9587,7 +9812,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/index.html index 71ed58c47..eb5bbef13 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9429,7 +9654,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/index.html index 817fea30a..a1aada68f 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9464,7 +9689,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/index.html index 6699ea988..2746e3f43 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9353,6 +9573,11 @@ + + + + + @@ -9462,7 +9687,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/index.html index c061f001d..7c3308d8d 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9429,7 +9654,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/index.html index f5377144a..cfad8b241 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9450,7 +9675,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/index.html index f3ed38d51..314141487 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9429,7 +9654,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/index.html index 0a1ade162..0c7e7eb87 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9433,7 +9658,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/index.html index 5bfdead01..cb5da4a3a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9518,7 +9743,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/index.html index 63d753d03..2f0376f4a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9418,6 +9638,11 @@ + + + + + @@ -9894,7 +10119,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/index.html index f1cea7561..921cb7456 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9290,6 +9510,11 @@ + + + + + @@ -9384,7 +9609,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/index.html index 3b4c0f221..59545315a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9550,7 +9775,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/index.html index c8c39a655..a79c00584 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9270,6 +9490,11 @@ + + + + + @@ -9340,7 +9565,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/index.html index 9bcd61390..96d6952df 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9514,7 +9739,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/index.html index cea123adb..12b7ae7af 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9381,6 +9601,11 @@ + + + + + @@ -9507,7 +9732,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/index.html index a72391eb2..7984b6b6e 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9448,7 +9673,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/index.html index 18ccbe8ee..27a3347f8 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9353,6 +9573,11 @@ + + + + + @@ -9485,7 +9710,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/index.html index d79037f25..6d6d606ba 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9339,6 +9559,11 @@ + + + + + @@ -9466,7 +9691,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/index.html index bbaa1bdc1..be17a2967 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9595,6 +9815,11 @@ + + + + + @@ -10077,7 +10302,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/index.html index 2f087cb65..00a44cc6a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9379,6 +9599,11 @@ + + + + + @@ -9611,7 +9836,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/index.html index e57894cc7..0860cf9a4 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9573,7 +9798,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/index.html index c1e4134fb..9345e4838 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9459,7 +9684,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/index.html index a4c799d81..d5f5e9596 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9471,7 +9696,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/index.html index c70f68f0f..b0657625a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9468,7 +9693,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/index.html index 65c1949ea..ac072ebbd 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9313,6 +9533,11 @@ + + + + + @@ -9472,7 +9697,7 @@

    Description

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/index.html index 1a04fa4e4..213f9ad35 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9472,7 +9697,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/index.html index 348cdd247..fdf32ed45 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9441,7 +9666,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/index.html index f0fac427d..cd86a137b 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9313,6 +9533,11 @@ + + + + + @@ -9419,7 +9644,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/index.html index 2ccf38c36..6b7d95f0d 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9471,7 +9696,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/index.html index 449a0e422..414c1143e 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9477,7 +9702,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/index.html index 69f97b794..f4d956ab1 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9503,6 +9723,11 @@ + + + + + @@ -9725,7 +9950,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/index.html index f5a7cc026..092967242 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9453,7 +9678,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/index.html index ae1c94eb1..152ceb145 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9492,7 +9717,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/index.html index 296a0c9a2..e253d8140 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9487,7 +9712,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/index.html index e8df08fc5..2b503d722 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9481,7 +9706,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/index.html index 7017e7922..2af5a1098 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9455,7 +9680,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/index.html index 056da70fb..8ad1752f9 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9505,7 +9730,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/index.html index 1d4b47805..b4209c627 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9313,6 +9533,11 @@ + + + + + @@ -9426,7 +9651,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/index.html index 1f45c74a3..3a0cc2fb8 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9313,6 +9533,11 @@ + + + + + @@ -9430,7 +9655,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/index.html index 9b30d0632..7d41a11ba 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9407,6 +9627,11 @@ + + + + + @@ -9563,7 +9788,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/index.html b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/index.html index 5b620ca8e..7eaf94494 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9499,6 +9719,11 @@ + + + + + @@ -9810,7 +10035,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/index.html index 09090f0ab..f373f627a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9313,6 +9533,11 @@ + + + + + @@ -9487,7 +9712,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/index.html index 16ae52205..3fa541d15 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9437,6 +9657,11 @@ + + + + + @@ -9820,7 +10045,7 @@

    Sort

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain/index.html index 230cf03cd..37382df53 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/Explain/explain/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9479,6 +9699,11 @@ + + + + + @@ -9760,7 +9985,7 @@

    Node_Delete

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/index.html index c61a7d80f..38e73f9ae 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9481,7 +9706,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/index.html index 223279d50..5caa4e006 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9483,7 +9708,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/index.html index 54b7ed2d5..6d015ffea 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9355,6 +9575,11 @@ + + + + + @@ -9593,7 +9818,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/index.html index c7b6866e0..56a7fe85b 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9367,6 +9587,11 @@ + + + + + @@ -9533,7 +9758,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/index.html index c9079a71e..52ce9be26 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9451,7 +9676,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/index.html index ddaa8c588..57e5a9250 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9447,7 +9672,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/index.html index 550f99a6f..4b087c116 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9443,7 +9668,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/index.html index 1887e371d..403f6cb66 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9446,7 +9671,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/index.html index 1e4e6d65c..097de21be 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9436,7 +9661,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/index.html index a9bf3d5a9..225b3fb3c 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9445,7 +9670,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/index.html index 9ecf1c71b..b1d7d959a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9367,6 +9587,11 @@ + + + + + @@ -9486,7 +9711,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/index.html index 5d86bafe8..0dbde9638 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9456,7 +9681,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/index.html index e49d938e8..013b42286 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9367,6 +9587,11 @@ + + + + + @@ -9534,7 +9759,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/index.html index b658badfb..86e2f3c45 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9581,7 +9806,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/index.html index 72cf645bb..1f909d8ad 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9441,7 +9666,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/index.html index 76ad3facb..e3313dc61 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9461,7 +9686,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/index.html index 552ac8454..10958987a 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9440,7 +9665,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/index.html index 554a0a025..6a56353ba 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9446,7 +9671,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/index.html index 2d90d40ac..add84b343 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9439,7 +9664,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/index.html index 3a8c7f4ff..65a1e724c 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9444,7 +9669,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/index.html index 105183dd4..08988f560 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9367,6 +9587,11 @@ + + + + + @@ -9528,7 +9753,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/Set/set-role/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/Set/set-role/index.html index 0570ca8e8..41f129796 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/Set/set-role/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/Set/set-role/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9421,6 +9641,11 @@ + + + + + @@ -9609,7 +9834,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/kill/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/kill/index.html index 3fbe4337c..90cb5344f 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/kill/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/kill/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9365,6 +9585,11 @@ + + + + + @@ -9479,7 +9704,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/SQL-Reference/Other/use-database/index.html b/dev/MatrixOne/Reference/SQL-Reference/Other/use-database/index.html index 935effddd..8fec62078 100644 --- a/dev/MatrixOne/Reference/SQL-Reference/Other/use-database/index.html +++ b/dev/MatrixOne/Reference/SQL-Reference/Other/use-database/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9341,6 +9561,11 @@ + + + + + @@ -9429,7 +9654,7 @@

    Examples

    - + diff --git a/dev/MatrixOne/Reference/System-Parameters/configuration-settings/index.html b/dev/MatrixOne/Reference/System-Parameters/configuration-settings/index.html index 8abc3f88c..7892c3105 100644 --- a/dev/MatrixOne/Reference/System-Parameters/configuration-settings/index.html +++ b/dev/MatrixOne/Reference/System-Parameters/configuration-settings/index.html @@ -11,7 +11,7 @@ - + @@ -2121,6 +2121,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9270,6 +9490,11 @@ + + + + + @@ -9848,7 +10073,7 @@

    log.toml

    - + diff --git a/dev/MatrixOne/Reference/System-Parameters/distributed-configuration-settings/index.html b/dev/MatrixOne/Reference/System-Parameters/distributed-configuration-settings/index.html index 2c8fac476..643052445 100644 --- a/dev/MatrixOne/Reference/System-Parameters/distributed-configuration-settings/index.html +++ b/dev/MatrixOne/Reference/System-Parameters/distributed-configuration-settings/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9511,6 +9731,11 @@ + + + + + @@ -10167,7 +10392,7 @@

    Extended Parameters

    - + diff --git a/dev/MatrixOne/Reference/System-Parameters/standalone-configuration-settings/index.html b/dev/MatrixOne/Reference/System-Parameters/standalone-configuration-settings/index.html index be3136dc1..69023ecca 100644 --- a/dev/MatrixOne/Reference/System-Parameters/standalone-configuration-settings/index.html +++ b/dev/MatrixOne/Reference/System-Parameters/standalone-configuration-settings/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9511,6 +9731,11 @@ + + + + + @@ -10151,7 +10376,7 @@

    Extended Parameters

    - + diff --git a/dev/MatrixOne/Reference/System-Parameters/system-parameter/index.html b/dev/MatrixOne/Reference/System-Parameters/system-parameter/index.html index 7b491deee..ac0790f34 100644 --- a/dev/MatrixOne/Reference/System-Parameters/system-parameter/index.html +++ b/dev/MatrixOne/Reference/System-Parameters/system-parameter/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9309,6 +9529,11 @@ + + + + + @@ -9411,7 +9636,7 @@

    Reference Documentation

    - + diff --git a/dev/MatrixOne/Reference/System-tables/index.html b/dev/MatrixOne/Reference/System-tables/index.html index 7367ea4ce..92ea8e17d 100644 --- a/dev/MatrixOne/Reference/System-tables/index.html +++ b/dev/MatrixOne/Reference/System-tables/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9843,6 +10063,11 @@ + + + + + @@ -11474,7 +11699,7 @@

    Grant system tables

    - + diff --git a/dev/MatrixOne/Reference/Variable/custom-variable/index.html b/dev/MatrixOne/Reference/Variable/custom-variable/index.html index 36e427497..d44b5a55a 100644 --- a/dev/MatrixOne/Reference/Variable/custom-variable/index.html +++ b/dev/MatrixOne/Reference/Variable/custom-variable/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9467,7 +9692,7 @@

    MySQL compatibility

    - + diff --git a/dev/MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/index.html b/dev/MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/index.html index 64dfb5c3c..8feaeb254 100644 --- a/dev/MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/index.html +++ b/dev/MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9435,6 +9655,11 @@ + + + + + @@ -9634,7 +9859,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Variable/system-variables/save_query_result/index.html b/dev/MatrixOne/Reference/Variable/system-variables/save_query_result/index.html index 2a91675f6..eb6b90375 100644 --- a/dev/MatrixOne/Reference/Variable/system-variables/save_query_result/index.html +++ b/dev/MatrixOne/Reference/Variable/system-variables/save_query_result/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9433,6 +9653,11 @@ + + + + + @@ -9719,7 +9944,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Variable/system-variables/sql-mode/index.html b/dev/MatrixOne/Reference/Variable/system-variables/sql-mode/index.html index aa168c834..ff80a7695 100644 --- a/dev/MatrixOne/Reference/Variable/system-variables/sql-mode/index.html +++ b/dev/MatrixOne/Reference/Variable/system-variables/sql-mode/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9367,6 +9587,11 @@ + + + + + @@ -9611,7 +9836,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Variable/system-variables/system-variables-overview/index.html b/dev/MatrixOne/Reference/Variable/system-variables/system-variables-overview/index.html index 90f6b6581..e44de02c9 100644 --- a/dev/MatrixOne/Reference/Variable/system-variables/system-variables-overview/index.html +++ b/dev/MatrixOne/Reference/Variable/system-variables/system-variables-overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9377,6 +9597,11 @@ + + + + + @@ -9800,10 +10025,7 @@

    System Veariable Reference

    Constraints

    -
      -
    1. To be compatible with MySQL, MatrixOne currently only implements syntax support for the system variables.
    2. -
    3. MatrixOne is compatible with MySQL, except the ONLY_FULL_GROUP_BY mode; other modes of sql_mode only implement syntax support.
    4. -
    +

    MatrixOne is compatible with MySQL, and the SQL mode only supports the ONLY_FULL_GROUP_BY mode; other SQL modes are only supported by syntax and have no actual effect.

    @@ -9879,7 +10101,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/Variable/system-variables/timezone/index.html b/dev/MatrixOne/Reference/Variable/system-variables/timezone/index.html index a8a0be87c..8b6eb119b 100644 --- a/dev/MatrixOne/Reference/Variable/system-variables/timezone/index.html +++ b/dev/MatrixOne/Reference/Variable/system-variables/timezone/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9325,6 +9545,11 @@ + + + + + @@ -9522,7 +9747,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Reference/access-control-type/index.html b/dev/MatrixOne/Reference/access-control-type/index.html index b5d826518..6599ef1f0 100644 --- a/dev/MatrixOne/Reference/access-control-type/index.html +++ b/dev/MatrixOne/Reference/access-control-type/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9431,6 +9651,11 @@ + + + + + @@ -9804,7 +10029,7 @@

    Publish and subscribe permission

    - + diff --git a/dev/MatrixOne/Release-Notes/release-timeline/index.html b/dev/MatrixOne/Release-Notes/release-timeline/index.html index b7beaadab..3b109b0bc 100644 --- a/dev/MatrixOne/Release-Notes/release-timeline/index.html +++ b/dev/MatrixOne/Release-Notes/release-timeline/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9261,6 +9481,11 @@ + + + + + @@ -9391,7 +9616,7 @@

    MatrixOne Release Timeline<
    - + diff --git a/dev/MatrixOne/Release-Notes/v0.1.0/index.html b/dev/MatrixOne/Release-Notes/v0.1.0/index.html index c731cd0e9..79256702f 100644 --- a/dev/MatrixOne/Release-Notes/v0.1.0/index.html +++ b/dev/MatrixOne/Release-Notes/v0.1.0/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9445,6 +9665,11 @@ + + + + + @@ -9610,7 +9835,7 @@

    Contributors

    - + diff --git a/dev/MatrixOne/Release-Notes/v0.2.0/index.html b/dev/MatrixOne/Release-Notes/v0.2.0/index.html index 14bcabba9..6d23f6726 100644 --- a/dev/MatrixOne/Release-Notes/v0.2.0/index.html +++ b/dev/MatrixOne/Release-Notes/v0.2.0/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9349,6 +9569,11 @@ + + + + + @@ -9476,7 +9701,7 @@

    Contributors

    - + diff --git a/dev/MatrixOne/Release-Notes/v0.3.0/index.html b/dev/MatrixOne/Release-Notes/v0.3.0/index.html index 5cc10bfed..cb062af5f 100644 --- a/dev/MatrixOne/Release-Notes/v0.3.0/index.html +++ b/dev/MatrixOne/Release-Notes/v0.3.0/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9261,6 +9481,11 @@ + + + + + @@ -9391,7 +9616,7 @@

    Full Changelog

    - + diff --git a/dev/MatrixOne/Release-Notes/v0.4.0/index.html b/dev/MatrixOne/Release-Notes/v0.4.0/index.html index bd4cabf68..660e92e67 100644 --- a/dev/MatrixOne/Release-Notes/v0.4.0/index.html +++ b/dev/MatrixOne/Release-Notes/v0.4.0/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9261,6 +9481,11 @@ + + + + + @@ -9400,7 +9625,7 @@

    Full Changelog

    - + diff --git a/dev/MatrixOne/Release-Notes/v0.5.0/index.html b/dev/MatrixOne/Release-Notes/v0.5.0/index.html index 327decd81..c4fab624a 100644 --- a/dev/MatrixOne/Release-Notes/v0.5.0/index.html +++ b/dev/MatrixOne/Release-Notes/v0.5.0/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9389,6 +9609,11 @@ + + + + + @@ -9512,7 +9737,7 @@

    Full Changelog

    - + diff --git a/dev/MatrixOne/Release-Notes/v0.5.1/index.html b/dev/MatrixOne/Release-Notes/v0.5.1/index.html index 3c13b21ea..f4a6dc826 100644 --- a/dev/MatrixOne/Release-Notes/v0.5.1/index.html +++ b/dev/MatrixOne/Release-Notes/v0.5.1/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9335,6 +9555,11 @@ + + + + + @@ -9427,7 +9652,7 @@

    Full Changelog

    - + diff --git a/dev/MatrixOne/Release-Notes/v0.6.0/index.html b/dev/MatrixOne/Release-Notes/v0.6.0/index.html index d0e47b190..43803c656 100644 --- a/dev/MatrixOne/Release-Notes/v0.6.0/index.html +++ b/dev/MatrixOne/Release-Notes/v0.6.0/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9389,6 +9609,11 @@ + + + + + @@ -9528,7 +9753,7 @@

    Full Changelog

    - + diff --git a/dev/MatrixOne/Release-Notes/v0.7.0/index.html b/dev/MatrixOne/Release-Notes/v0.7.0/index.html index 5d7be83b9..b77593f06 100644 --- a/dev/MatrixOne/Release-Notes/v0.7.0/index.html +++ b/dev/MatrixOne/Release-Notes/v0.7.0/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9389,6 +9609,11 @@ + + + + + @@ -9515,7 +9740,7 @@

    Full Changelog

    - + diff --git a/dev/MatrixOne/Release-Notes/v0.8.0/index.html b/dev/MatrixOne/Release-Notes/v0.8.0/index.html index e8bcfd1da..7551fe196 100644 --- a/dev/MatrixOne/Release-Notes/v0.8.0/index.html +++ b/dev/MatrixOne/Release-Notes/v0.8.0/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9443,6 +9663,11 @@ + + + + + @@ -9585,7 +9810,7 @@

    Full Changelog

    - + diff --git a/dev/MatrixOne/Release-Notes/v1.0.0-rc1/index.html b/dev/MatrixOne/Release-Notes/v1.0.0-rc1/index.html index 9a7ba40bb..2c437d546 100644 --- a/dev/MatrixOne/Release-Notes/v1.0.0-rc1/index.html +++ b/dev/MatrixOne/Release-Notes/v1.0.0-rc1/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9771,6 +9991,11 @@ + + + + + @@ -9960,7 +10185,7 @@

    Full Changelog

    - + diff --git a/dev/MatrixOne/Security/Authentication/index.html b/dev/MatrixOne/Security/Authentication/index.html index a7ce2a1b8..6d735e3c2 100644 --- a/dev/MatrixOne/Security/Authentication/index.html +++ b/dev/MatrixOne/Security/Authentication/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9349,6 +9569,11 @@ + + + + + @@ -9486,7 +9711,7 @@

    Constraints

    - + diff --git a/dev/MatrixOne/Security/Security-Permission-Overview/index.html b/dev/MatrixOne/Security/Security-Permission-Overview/index.html index e1ca4f02b..7c3335162 100644 --- a/dev/MatrixOne/Security/Security-Permission-Overview/index.html +++ b/dev/MatrixOne/Security/Security-Permission-Overview/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9321,6 +9541,11 @@ + + + + + @@ -9416,7 +9641,7 @@

    Permission Management

    - + diff --git a/dev/MatrixOne/Security/TLS-introduction/index.html b/dev/MatrixOne/Security/TLS-introduction/index.html index 0c3ab1825..8d01a2a63 100644 --- a/dev/MatrixOne/Security/TLS-introduction/index.html +++ b/dev/MatrixOne/Security/TLS-introduction/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9361,6 +9581,11 @@ + + + + + @@ -9630,7 +9855,7 @@

    Step 2: Configure the p
    - + diff --git a/dev/MatrixOne/Security/audit/index.html b/dev/MatrixOne/Security/audit/index.html index 034bb487e..2229e2b97 100644 --- a/dev/MatrixOne/Security/audit/index.html +++ b/dev/MatrixOne/Security/audit/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9349,6 +9569,11 @@ + + + + + @@ -9502,7 +9727,7 @@

    Disable Audit

    - + diff --git a/dev/MatrixOne/Security/how-tos/quick-start-create-account/index.html b/dev/MatrixOne/Security/how-tos/quick-start-create-account/index.html index 22ed0cf4b..29b85ed74 100644 --- a/dev/MatrixOne/Security/how-tos/quick-start-create-account/index.html +++ b/dev/MatrixOne/Security/how-tos/quick-start-create-account/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9480,7 +9705,7 @@

    Steps

    - + diff --git a/dev/MatrixOne/Security/how-tos/quick-start-create-user/index.html b/dev/MatrixOne/Security/how-tos/quick-start-create-user/index.html index 1321857d6..541bd60ea 100644 --- a/dev/MatrixOne/Security/how-tos/quick-start-create-user/index.html +++ b/dev/MatrixOne/Security/how-tos/quick-start-create-user/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9377,6 +9597,11 @@ + + + + + @@ -9624,7 +9849,7 @@

    Step 3: Verify the privilege is va
    - + diff --git a/dev/MatrixOne/Security/how-tos/user-guide/index.html b/dev/MatrixOne/Security/how-tos/user-guide/index.html index fa38baf4f..0e9e883a2 100644 --- a/dev/MatrixOne/Security/how-tos/user-guide/index.html +++ b/dev/MatrixOne/Security/how-tos/user-guide/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9637,6 +9857,11 @@ + + + + + @@ -10222,7 +10447,7 @@

    Revoke privilege of roles

    - + diff --git a/dev/MatrixOne/Security/password-mgmt/index.html b/dev/MatrixOne/Security/password-mgmt/index.html index 8e96b803a..86e5101ea 100644 --- a/dev/MatrixOne/Security/password-mgmt/index.html +++ b/dev/MatrixOne/Security/password-mgmt/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9469,6 +9689,11 @@ + + + + + @@ -9585,7 +9810,7 @@

    Ordinary User Changing their
    - + diff --git a/dev/MatrixOne/Security/role-priviledge-management/about-privilege-management/index.html b/dev/MatrixOne/Security/role-priviledge-management/about-privilege-management/index.html index 34ef2f694..1ac28a2e4 100644 --- a/dev/MatrixOne/Security/role-priviledge-management/about-privilege-management/index.html +++ b/dev/MatrixOne/Security/role-priviledge-management/about-privilege-management/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9565,6 +9785,11 @@ + + + + + @@ -9810,7 +10035,7 @@

    Quick Start

    - + diff --git a/dev/MatrixOne/Security/role-priviledge-management/app-scenarios/index.html b/dev/MatrixOne/Security/role-priviledge-management/app-scenarios/index.html index a995ac660..4105e67df 100644 --- a/dev/MatrixOne/Security/role-priviledge-management/app-scenarios/index.html +++ b/dev/MatrixOne/Security/role-priviledge-management/app-scenarios/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9553,6 +9773,11 @@ + + + + + @@ -9821,7 +10046,7 @@

    Step 2: Use the data user t
    - + diff --git a/dev/MatrixOne/Security/role-priviledge-management/best-practice/index.html b/dev/MatrixOne/Security/role-priviledge-management/best-practice/index.html index 1f0475e6c..1c0af87aa 100644 --- a/dev/MatrixOne/Security/role-priviledge-management/best-practice/index.html +++ b/dev/MatrixOne/Security/role-priviledge-management/best-practice/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9431,7 +9656,7 @@

    Engineer responsible f
    - + diff --git a/dev/MatrixOne/Test/performance-testing/SSB-test-with-matrixone/index.html b/dev/MatrixOne/Test/performance-testing/SSB-test-with-matrixone/index.html index 0f79e3b93..df66e727a 100644 --- a/dev/MatrixOne/Test/performance-testing/SSB-test-with-matrixone/index.html +++ b/dev/MatrixOne/Test/performance-testing/SSB-test-with-matrixone/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9553,6 +9773,11 @@ + + + + + @@ -12656,7 +12881,7 @@

    Multiple tables queries expect
    - + diff --git a/dev/MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/index.html b/dev/MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/index.html index 6088236cf..d5ad304a2 100644 --- a/dev/MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/index.html +++ b/dev/MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9459,6 +9679,11 @@ + + + + + @@ -9866,7 +10091,7 @@

    5. Run TPCC test

    - + diff --git a/dev/MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/index.html b/dev/MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/index.html index f1d0dca6b..8cd0ec508 100644 --- a/dev/MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/index.html +++ b/dev/MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9393,6 +9613,11 @@ + + + + + @@ -12381,7 +12606,7 @@

    6. Expected Results

    - + diff --git a/dev/MatrixOne/Test/testing-tool/mo-tester-reference/index.html b/dev/MatrixOne/Test/testing-tool/mo-tester-reference/index.html index a8d149f49..7cb90166a 100644 --- a/dev/MatrixOne/Test/testing-tool/mo-tester-reference/index.html +++ b/dev/MatrixOne/Test/testing-tool/mo-tester-reference/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9363,6 +9583,11 @@ + + + + + @@ -9565,7 +9790,7 @@

    Set tags in case scripts

    - + diff --git a/dev/MatrixOne/Test/testing-tool/mo-tester/index.html b/dev/MatrixOne/Test/testing-tool/mo-tester/index.html index 8b2c4592d..68d417761 100644 --- a/dev/MatrixOne/Test/testing-tool/mo-tester/index.html +++ b/dev/MatrixOne/Test/testing-tool/mo-tester/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9473,6 +9693,11 @@ + + + + + @@ -9850,7 +10075,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Troubleshooting/common-statistics-query/index.html b/dev/MatrixOne/Troubleshooting/common-statistics-query/index.html index 349f5f1aa..27aa40fcf 100644 --- a/dev/MatrixOne/Troubleshooting/common-statistics-query/index.html +++ b/dev/MatrixOne/Troubleshooting/common-statistics-query/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9447,6 +9667,11 @@ + + + + + @@ -9624,7 +9849,7 @@

    Reference

    - + diff --git a/dev/MatrixOne/Troubleshooting/error-code/index.html b/dev/MatrixOne/Troubleshooting/error-code/index.html index 2b85a8148..202e417a6 100644 --- a/dev/MatrixOne/Troubleshooting/error-code/index.html +++ b/dev/MatrixOne/Troubleshooting/error-code/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9261,6 +9481,11 @@ + + + + + @@ -9939,7 +10164,7 @@

    Error Code

    - + diff --git a/dev/MatrixOne/Troubleshooting/query-table-statistics/index.html b/dev/MatrixOne/Troubleshooting/query-table-statistics/index.html index 0b6724b43..b1b31fa7c 100644 --- a/dev/MatrixOne/Troubleshooting/query-table-statistics/index.html +++ b/dev/MatrixOne/Troubleshooting/query-table-statistics/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9493,6 +9713,11 @@ + + + + + @@ -9720,7 +9945,7 @@

    Example

    - + diff --git a/dev/MatrixOne/Troubleshooting/slow-queries/index.html b/dev/MatrixOne/Troubleshooting/slow-queries/index.html index c8fc9c48d..4086c864c 100644 --- a/dev/MatrixOne/Troubleshooting/slow-queries/index.html +++ b/dev/MatrixOne/Troubleshooting/slow-queries/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9387,6 +9607,11 @@ + + + + + @@ -9608,7 +9833,7 @@

    Query the error of SQL

    - + diff --git a/dev/MatrixOne/Tutorial/develop-golang-crud-demo/index.html b/dev/MatrixOne/Tutorial/develop-golang-crud-demo/index.html index 47f0e5c60..34bdb35b4 100644 --- a/dev/MatrixOne/Tutorial/develop-golang-crud-demo/index.html +++ b/dev/MatrixOne/Tutorial/develop-golang-crud-demo/index.html @@ -15,7 +15,7 @@ - + @@ -2181,6 +2181,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9323,6 +9543,11 @@ + + + + + @@ -9523,7 +9748,7 @@

    Develop your code

    - + diff --git a/dev/MatrixOne/Tutorial/develop-java-crud-demo/index.html b/dev/MatrixOne/Tutorial/develop-java-crud-demo/index.html index 0c1a43be9..4747cc38e 100644 --- a/dev/MatrixOne/Tutorial/develop-java-crud-demo/index.html +++ b/dev/MatrixOne/Tutorial/develop-java-crud-demo/index.html @@ -15,7 +15,7 @@ - + @@ -2222,6 +2222,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9405,6 +9625,11 @@ + + + + + @@ -9737,7 +9962,7 @@

    SELECT

    - + diff --git a/dev/MatrixOne/Tutorial/develop-python-crud-demo/index.html b/dev/MatrixOne/Tutorial/develop-python-crud-demo/index.html index 0f6ece8d2..c4842c8df 100644 --- a/dev/MatrixOne/Tutorial/develop-python-crud-demo/index.html +++ b/dev/MatrixOne/Tutorial/develop-python-crud-demo/index.html @@ -15,7 +15,7 @@ - + @@ -2222,6 +2222,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9405,6 +9625,11 @@ + + + + + @@ -9734,7 +9959,7 @@

    Delete

    - + diff --git a/dev/MatrixOne/Tutorial/gorm-golang-crud-demo/index.html b/dev/MatrixOne/Tutorial/gorm-golang-crud-demo/index.html index 7270f0e0a..540af5a52 100644 --- a/dev/MatrixOne/Tutorial/gorm-golang-crud-demo/index.html +++ b/dev/MatrixOne/Tutorial/gorm-golang-crud-demo/index.html @@ -12,10 +12,10 @@ - + - + @@ -2222,6 +2222,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9405,6 +9625,11 @@ + + + + + @@ -9781,13 +10006,13 @@

    Deleting Data

    -
  • +
  • + + + + @@ -9611,6 +9831,11 @@ + + + + + @@ -10283,7 +10508,7 @@

    - + diff --git a/dev/MatrixOne/Tutorial/springboot-mybatis-crud-demo/index.html b/dev/MatrixOne/Tutorial/springboot-mybatis-crud-demo/index.html index 5512d821e..989b5a30d 100644 --- a/dev/MatrixOne/Tutorial/springboot-mybatis-crud-demo/index.html +++ b/dev/MatrixOne/Tutorial/springboot-mybatis-crud-demo/index.html @@ -15,7 +15,7 @@ - + @@ -2311,6 +2311,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9583,6 +9803,11 @@ + + + + + @@ -10173,7 +10398,7 @@

    5. Test Delete User

    - + diff --git a/dev/MatrixOne/Tutorial/sqlalchemy-python-crud-demo/index.html b/dev/MatrixOne/Tutorial/sqlalchemy-python-crud-demo/index.html index 4fae2be92..4c8f64a1f 100644 --- a/dev/MatrixOne/Tutorial/sqlalchemy-python-crud-demo/index.html +++ b/dev/MatrixOne/Tutorial/sqlalchemy-python-crud-demo/index.html @@ -15,7 +15,7 @@ - + @@ -2215,6 +2215,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9391,6 +9611,11 @@ + + + + + @@ -9886,7 +10111,7 @@

    Delete

    - + diff --git a/dev/MatrixOne/glossary/index.html b/dev/MatrixOne/glossary/index.html index 4e7ea3b15..e48c8f0f8 100644 --- a/dev/MatrixOne/glossary/index.html +++ b/dev/MatrixOne/glossary/index.html @@ -15,7 +15,7 @@ - + @@ -2129,6 +2129,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9319,6 +9539,11 @@ + + + + + @@ -9574,7 +9799,7 @@

    Concepts

    - + diff --git a/dev/index.html b/dev/index.html index 8c6b5d3b0..c5ed28d8d 100644 --- a/dev/index.html +++ b/dev/index.html @@ -13,7 +13,7 @@ - + @@ -2182,6 +2182,226 @@ + + + + + + +
  • + + + + + + + + + + + +
  • + + + + @@ -9331,6 +9551,11 @@ + + + + + @@ -9449,7 +9674,7 @@

    Join us!

    - + diff --git a/dev/search/search_index.json b/dev/search/search_index.json index 1e534a889..9158fc640 100644 --- a/dev/search/search_index.json +++ b/dev/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-,:!=\\[\\]()\"/]+|(?!\\b)(?=[A-Z][a-z])|\\.(?!\\d)|&[lg]t;","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"MatrixOne Documentation","text":"

    Welcome to the MatrixOne documentation center!

    This center holds related concepts and technical architecture introductions, product features, user guides, and reference manuals to help you work with MatrixOne.

    "},{"location":"#recommended-articles","title":"Recommended articles","text":"

    Select one of the articles below to begin your MatrixOne journey. If you ...

    • Are new to MatrixOne, start with Overview to learn about basic concepts, key features and architecture.

    • Are Want to jump to the quickstart to build a standalone MatrixOne and learn the basic knowledge of SQL, start with Getting Started.

    • Are applicators and want to try out MatrixOne as a basic database, select Developing Guide for the tutorial and developing guide.

    • An experienced MatrixOne coder looking for SQL statements, data types functions, or catalog, go to Reference.

    Overview Get Started Developing Guide Reference MatrixOne Introduction Install MatrixOne Java CRUD demo SQL Reference MatrixOne Architecture Basic SQL Python CRUD demo Data Types"},{"location":"#continuous-improvement","title":"Continuous Improvement","text":"

    Whether you're seeking fundamental concepts, step-by-step procedures, curated guides, or handy references, we're crafting content to accommodate your needs.

    We warmly welcome contributions to MatrixOne documentation from everyone. Our community aims to streamline the contribution process, making it simple. Additionally, we'll provide updates every month.

    You'll find an Edit button at the top of each page. Click on it to access a landing page with instructions for suggesting published document changes. These resources are yours for you to use. Your participation is not only encouraged but also crucial!

    If you encounter any documentation issues, please feel free to create an Issue to inform us or directly submit a Pull Request to help us fix or update the content.

    Note

    For how to make contributions to documentation, see Contributing to MatrixOne Documentation.

    "},{"location":"#join-us","title":"Join us!","text":"

    The MatrixOne community on GitHub is dynamic, enthusiastic, and well-informed. Engage in discussions, express your viewpoints, propose features, and delve into the code.

    A similarly passionate community awaits you in the MatrixOne Slack and MatrixOne channel.

    "},{"location":"MatrixOne/glossary/","title":"Glossary","text":""},{"location":"MatrixOne/glossary/#terms","title":"Terms","text":"

    It's helpful to understand a few terms before reading our architecture documentation.

    Term Definition A AST (Abstract syntax tree) Abstract Syntax Trees or ASTs are tree representations of code. They are a fundamental part of the way a compiler works. C Cluster A distributed MatrixOne deployment, which acts as a single logical application. E Explicit Transactions Explicit Transaction has the beginning, ending and rollback of transactions with the command Begin Transaction, Commit Transaction and Rollback Transaction. I Implicit Transactions Implicit Transaction is the auto commit. There is no beginning or ending of the transaction. O Optimistic transaction Optimistic transaction, the optimistic transaction means that when the transaction starts, no conflict detection or lock will be performed, the current relevant data will be cached in the corresponding memory area, and the data will be added, deleted, or modified. P Pessimistic transaction Pessimistic transaction, the default transaction mode of MatrixOne, that is, when the transaction starts, it will assume that the transaction-related tables are in a state where write conflicts will occur and lock the corresponding data table or a data row in advance to complete the locking action Finally, the insertion, modification, or deletion of data is cached in memory. After committing or rolling back, the data is placed on the disk, and the lock is released. S Snapshot Isolation (SI) Snapshot Isolation is a multi-version concurrency control approach that is widely used in practice. MatrixOne supports distributed transaction of snapshot isolation level."},{"location":"MatrixOne/glossary/#concepts","title":"Concepts","text":"

    MatrixOne relies heavily on the following concepts. Being familiar with them will help you understand what our architecture achieves.

    Term Definition A Auto-Rebalance A modern distributed database should do more than just split data amongst a number of servers. The automatic process of storage and workload distribution among servers is called an Auto-Rebalance. C Consistency MatrixOne supports a strong consistency. It is guaranted that after any successful data write, the reading afterwards will get the latest value, no matter from which store. E Execution Plan An execution plan in a database is a simple graphical representation of the operations that the query optimizer generates to calculate the most efficient way to return a set of results. F Fault-Tolerance Fault-Tolerance simply means a system's ability to continue operating uninterrupted despite the failure of one or more of its components. M Monolithic Engine A monolithic database engine is designed to support hybrid workloads: transactional, analytical, streaming, time-series, machine learning, and so on. Materialized View A materialized view is a pre-computed data set derived from a query specification (the SELECT in the view definition) and stored for later use. Materialized view is usually used for increasing performance and efficiency. Metadata Metadata is the data that describes the structure and creation method of data in a database. P Paxos Paxos is an algorithm that is used to achieve consensus among a distributed set of computers that communicate via an asynchronous network. R Raft Raft is a consensus algorithm that is designed to be easy to understand. It's equivalent to Paxos in fault-tolerance and performance. The difference is that it's decomposed into relatively independent subproblems, and it cleanly addresses all major pieces needed for practical systems. Raft Group and Leader Raft defines a strong, single leader and number of followers in a group of peers. The group represents a replicated state machine. Only the leader may service client requests. The leader replicates actions to the followers. S SIMD instruction SIMD is short for Single Instruction/Multiple Data, while the term SIMD operations refers to a computing method that enables processing of multiple data with a single instruction. T Transaction A set of operations performed on your database that satisfy the requirements of ACID semantics. TAE Transactional Analytic Engine. The storage engine is the main public interface of the storage layer, which can support both row and column storage and transaction processing capabilities. V Vectorized Execution Vectorized data processing helps with developing faster analytical query engines by making efficient utilization of CPU cache. Arrow's columnar format allows to use lightweight schemes like dictionary encoding, bit packing, and run length encoding, which favor query performance over compression ratio."},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/","title":"Make Your First Contribution","text":"

    Thank you for your interest in contributing to MatrixOne. Contributions are welcome from everyone.

    This document will help you get started on your first contribution to MatrixOne.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#how-to-contribute","title":"How to Contribute?","text":"

    Before setting out contributions, you need to figure out what area you are trying to help us in. You can see Types of contributions for more details.

    As your first-ever contribution, it can be selected from the following categories which require little technical background of the contributor:

    • To report a bug in the code

    • To improve the MatrixOne documentation

    File an issue to describe the problem before working on it. In addition, you will also find issues labeled with good-first-issue, which represents issues suitable for new contributors. Such Issues contain clear steps and expected output. You may start your first contribution based on these issues.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#assign-your-issue","title":"Assign Your Issue","text":"

    It's difficult to report an issue when you are just a newcomer on account of little knowledge of MatrixOne or relative contents, so we list good-first-issues suitable for new contributors to work with and be easy to fix. After deciding on a suitable issue to work on, you can comment /assign on the issue you would like to work on, and you will be automatically assigned to the issue. You can then find yourself listed under the Assignees section.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#prerequisite","title":"Prerequisite","text":"

    Before working on the issue you are assigned, please make sure you have set up a development environment and installed MatrixOne. You can see Preparation for more details.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#workflow","title":"Workflow","text":""},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-1-fork-the-repository","title":"Step 1: Fork the Repository","text":"

    Visit our Github Repository. On the top right of the page, click the Fork button (top right) to create a cloud-based fork of the repository.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-2-clone-fork-to-local-storage","title":"Step 2: Clone fork to local storage","text":"

    Open the repository you forked from MatrixOne. Click on the Code button and then the Copy to Clipboard icon. Next, move to the working directory you expect in local and launch your terminal. Run the following Git command:

    git clone <content you just copied>\n

    For example:

    git clone git@github.com:<yourname>/matrixone.git\n

    <yourname> is the ID you signed in at GitHub. This Git command downloads the content of MatrixOne repository you forked on GitHub to your local device.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-3-add-matrixone-repo-as-a-remote-repository","title":"Step 3: Add MatrixOne repo as a remote repository","text":"

    You can add MatrixOrigin/MatrixOne repository as a remote repository in local with:

    git remote add upstream https://github.com/matrixorigin/matrixone.git  \n

    upstream is the designation of this remote repository. If you want to replace it with other words you want, don't forget to replace it as well in the next steps, or some errors will happen.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-4-develop","title":"Step 4: Develop","text":""},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#make-some-changes","title":"Make some changes","text":"

    Now you can edit the code, modify the documents, and make whatever changes you want about your issue in the branch you just created.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#run-matrixone-in-a-standalone-mode","title":"Run MatrixOne in a standalone mode","text":"

    If you want to demonstrate whether the changes you made are valid or produce an issue, you need to run MatrixOne in a standalone mode. Before running, make sure you have deployed MatrixOne according to our Deploy standalone MatrixOne.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-5-commit-to-your-local-repo","title":"Step 5: Commit to your local repo","text":"

    Having completed your modification, you can add the files you just modified using the git add command:

    git add <filename>\n

    <filename> is the name of the file you just modified. And you can use the following command to add all the files in the current folder:

    git add .\n

    Next, you can commit these changes using the git commit command:

    git commit -m \"<commit message>\"  -s\n

    Summarize and describe your modification briefly in the place of <commit message>. -s adds your sign-off message to your commit message.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-6-push-to-your-remote-repo","title":"Step 6: Push to your remote repo","text":"

    After committing your modification, you should push your local branch to GitHub using the git push command, and we recommend you to push to a new branch:

    git push origin main:NEW_BRANCH\n

    NEW_BRANCH is the name of the new branch you created and push to. Also, you can replace it with another name you want.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-7-create-a-pull-request","title":"Step 7: Create a pull request","text":"

    Having pushed your changes, you can visit your folk at https://github.com/$user/matrixone, and click the Compare & Pull Request button to create a pull request in NEW_BRANCH for your modification to the MatrixOne repository.

    Note

    You should fill in the required information based on the PR template.

    Once your PR is opened, it will be assigned to reviewers. These reviewers will check your contribution and do a detailed review according to the correctness, bugs, style, sand so on.

    "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-8-after-merging-keep-your-repo-in-sync","title":"Step 8: After merging, Keep your repo in sync","text":"

    Congratulations that your contributions are accepted and merged into the project! And there are some operations left to do, which help keep project committing history clean and keep your local and remote repo synchronized with MatrixOne repo. Overrides local committing history with the following command:

    git pull --force upstream main:main\n

    Lastly, upgrade the main branch of your folk in Github:

    git push --force origin main:main\n
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/","title":"Code Comment Style","text":"

    This document describes the code comment style applied to MatrixOne style. When you are ready to commit, please follow the style to write good code comments.

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#why-does-a-good-comment-matter","title":"Why does a good comment matter?","text":"
    • To speed up the reviewing process
    • To help maintain the code
    • To improve the API document readability
    • To improve the development efficiency of the whole team
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#wherewhen-to-comment","title":"Where/When to comment?","text":"

    Write a comment where/when:

    • For important code
    • For obscure code
    • For tricky or interesting code
    • For a complex code block
    • If a bug exists in the code but you cannot fix it or you just want to ignore it for the moment
    • If the code is not optimal but you don't have a smarter way now
    • To remind yourself or others of missing functionality or upcoming requirements not present in the code

    A comment is generally required for:

    • Package (Go)
    • File
    • Type
    • Constant
    • Function
    • Method
    • Variable
    • Typical algorithm
    • Exported name
    • Test case
    • TODO
    • FIXME
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#how-to-comment","title":"How to comment?","text":""},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#format-of-a-good-comment","title":"Format of a good comment","text":"
    • Go

      • Use // for a single-line comment and trailing comment
      • Use /* ... */ for a block comment (used only when needed)
      • Use gofmt to format your code
    • Place the single-line and block comment above the code it's annotating

    • Fold long lines of comments
    • Each line of text in your code and comment should be at most 100 characters long
    • For a comment containing a URL

      • Use a relative URL if the text is linked to a file within the same GitHub repository
      • Use an absolute URL in docs and docs-cn repositories if the code with this comment is copied from another repository
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#language-for-a-good-comment","title":"Language for a good comment","text":"
    • Word

      • Use American English rather than British English

        • color, canceling, synchronize (Recommended)
        • colour, cancelling, synchronise (Not recommended)
      • Use correct spelling

      • Use standard or official capitalization

        • MatrixOne, Raft, SQL (Right)
        • matrixone, RAFT, sql (Wrong)
      • Use words and expressions consistently

        • \"dead link\" vs. \"broken link\" (Only one of them can appear in a single document)
      • Do not use lengthy compound words

      • Do not abbreviate unless it is absolutely necessary

      • We should be used only when it means the code writer and the reader

    • Sentence

      • Use standard grammar and correct punctuation
      • Use relatively short sentences
    • Capitalize the first letter of sentences and end them with periods

      • If a lower-case identifier comes at the beginning of a sentence, don't capitalize it

        // enterGame causes Players to enter the\n// video game, which is about a romantic\n// story in ancient China.\nfunc enterGame() os.Error {\n    ...\n}\n
    • When used for description, comments should be descriptive rather than imperative

      • Opens the file (Right)
      • Open the file (Wrong)
    • Use \"this\" instead of \"the\" to refer to the current thing

      • Gets the toolkit for this component (Recommended)
      • Gets the toolkit for the component (Not recommended)
    • The Markdown format is allowed

      • Opens the log file
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#tips-for-a-good-comment","title":"Tips for a good comment","text":"
    • Comment code while writing it
    • Do not assume the code is self-evident
    • Avoid unnecessary comments for simple code
    • Write comments as if they were for you
    • Make sure the comment is up-to-date
    • Let the code speak for itself

    Thanks for your contribution!

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/","title":"MatrixOne Code of Conduct","text":""},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#our-pledge","title":"Our Pledge","text":"

    In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity, and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#our-standards","title":"Our Standards","text":"

    Examples of behavior that contributes to creating a positive environment include:

    • Using welcoming and inclusive language
    • Being respectful of differing viewpoints and experiences
    • Gracefully accepting constructive criticism
    • Focusing on what is best for the community
    • Showing empathy towards other community members

    Examples of unacceptable behavior by participants include:

    • The use of sexualized language or imagery and unwelcome sexual attention or advances
    • Trolling, insulting/derogatory comments, and personal or political attacks
    • Public or private harassment
    • Publishing others' private information, such as a physical or electronic address, without explicit permission
    • Other conduct which could reasonably be considered inappropriate in a professional setting
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#our-responsibilities","title":"Our Responsibilities","text":"

    Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

    Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#scope","title":"Scope","text":"

    This Code of Conduct applies within all project spaces, and when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#enforcement","title":"Enforcement","text":"

    Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hai.jin@matrixorigin.io. All complaints will be reviewed and investigated and resulting in a response deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

    Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other the project leadership members.

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#attribution","title":"Attribution","text":"

    This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

    For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/","title":"Commit Message and Pull Request Style","text":"

    This document describes the commit message and Pull Request style applied to all MatrixOrigin repositories. When you are ready to commit, be sure to follow the style guide to write a good commit message, a good Pull Request title, and a description.

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#why-a-good-commit-message-matters","title":"Why a good commit message matters","text":"
    • To speed up the reviewing process
      • Help the reviewers better understand the PR
      • Allow ignoring unimportant commits
    • To help us write good Release Notes
    • To help the future maintainers establish the context
      • Provide better information when browsing the history
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#what-is-a-good-commit-message","title":"What is a good commit message","text":"

    Elements of a good commit message:

    1. What is your change? (mandatory)

      It can be fixing a specific bug, adding a feature, improving performance, reliability, and stability, or just being a change for the sake of correctness.

    2. Why was this change made? (mandatory)

      For short and obvious patches, this part can be omitted, but it should be a clear description of what the approach was.

    3. What effect does the commit have? (optional)

      In addition to the obvious effects, this may include benchmarks, side effects, and so on. For short and obvious patches, this part can be omitted.

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#how-to-write-a-good-commit-message","title":"How to write a good commit message","text":"

    To write a good commitment message, we suggest following a good format, cultivating good habits, and using good language.

    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#format-of-a-good-commit-message","title":"Format of a good commit message","text":"

    Please follow the following style for all your commits:

    <subsystem>: <what changed>\n<BLANK LINE>\n<why this change was made>\n<BLANK LINE>\n<footer>(optional)\n
    • For the first subject line:

      • Use no more than 70 characters.
      • If the changes affect two subsystems, use a comma (and whitespace) to separate them like util/codec, util/types:.
      • If the changes affect three or more subsystems, you can use * instead, like *:.
      • Use a lowercase letter on the text that immediately follows the colon. For example: \"media: update the DM architecture image\"
      • Do not add a period at the end of a commit message.
    • For the second line, always leave it blank.

    • For the why part, if there is no specific reason for the change, you can use one of the generic reasons like \"Improve performance\", \"Improve test coverage.\"
    • For other lines, use no more than 80 characters.
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#habits-for-a-good-commit-message","title":"Habits for a good commit message","text":"
    • Summarize your change
    • Describe clearly one logical change and avoid lazy messages as misc fixes
    • Describe any limitations of the current code
    • Do not end the subject with a period \".\"
    • Do not assume the code is self-evident
    • Do not assume reviewers understand the original issue
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#language-for-a-good-commit-message","title":"Language for a good commit message","text":"
    • Use the imperative mood for the first subject line
    • Use simple verb tenses (eg. use \"add\" not \"added\")
    • Use correct and standard grammar
    • Use words and expressions consistently
    • Use relatively short sentences
    • Do not use lengthy compound words
    • Do not abbreviate unless it's absolutely necessary
    "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#pull-request-description-style","title":"Pull Request description style","text":"

    For the Pull Request description in the Conversation box, please refer to the following Pull Request description template and include the necessary information:

    **What type of PR is this?**\n\n- [ ] API-change\n- [ ] BUG\n- [ ] Improvement\n- [ ] Documentation\n- [ ] Feature\n- [ ] Test and CI\n- [ ] Code Refactoring\n\n**Which issue(s) this PR fixes:**\n\nissue #\n\n**What this PR does / why we need it:**\n\n\n**Special notes for your reviewer:**\n\n\n**Additional documentation (e.g. design docs, usage docs, and so on.):**\n

    You may also use the checklist style to list contents if needed. The Markdown syntax is as follows:

    - [x] A checked line, something already done or fulfilled\n- [ ] An unchecked line, something not finished yet\n

    For short and obvious Pull Requests, you can omit some of the above information.

    Thanks for your contribution\uff01

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/","title":"Contribute Code","text":"

    MatrixOne is an open-source project maintained, improved, and extended by code contributors. This document describes the conventions of development workflow, and some styles and templates you need while contributing code to MatrixOne. If you encounter any problems or find some mistakes in participating in contribution to MatrixOne, please file an issue on GitHub or contact us on other platforms we support.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#before-contributions","title":"Before Contributions","text":"

    Before you start developing, make sure you have read Preparation where you can follow the instructions to learn more about MatrixOne, development knowledge, and how to set up the development environment.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#get-familiar-with-the-style","title":"Get familiar with the style","text":"

    It's necessary to keep a consistent style for code, code comments, commit messages, and pull requests when contributing to MatrixOne. When you put together your pull request, we highly recommend you comply with the following style guides which make MatrixOne easy to review, maintain, and develop.

    • Code Style

    The coding style suggested by the Golang community is used in MatrixOne. See the style doc for details.

    • Code Comment Style

    See the code comment style for details.

    • Commit Message & Pull Request Style

    See the Commit Message & Pull Request Style for details.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#workflow","title":"Workflow","text":"

    You can follow the workflow to operate development, and you can see Make Your First Contribution if you are a newcomer and need more detailed instructions about workflow.

    1. Fork the matrixOne repository on GitHub.

    2. Clone your fork to your local machine with:

    git clone git@github.com:<yourname>/matrixone.git\n

    And add MatrixOne repo as a remote repository with:

    git remote add upstream https://github.com/matrixorigin/matrixone.git\n

    3. Create a new branch. The branch name is up to you.

    git checkout -b topic-branch\n

    4. Commit changes to your own branch locally, add necessary unit tests.

    5. Push to a new branch in your own fork.

    git push origin main:NEW_BRANCH\n

    6. Go back to GitHub, and submit a pull request in NEW_BRANCH so that we can review your changes. Add some labels if needed, and don't forget to refer to the related issue.

    7. Once your PR gets approved, it will be merged sooner. After merging, synchronize your local repository.

    git pull --force upstream main:main\n

    8. Synchronized the main branch of your remote repository in Github.

    git push --force origin main:main\n

    If you still have some trouble, please refer to GitHub Docs for help.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#code-review","title":"Code review","text":"

    When you open a pull request, you can assign some reviewers, or just leave it blank. And you can add some related labels to make it easier to recognize the PR's type/priority/and so on. During the review, reviewers would comment on your code snippet, and you can modify the code on your topic branch locally, commit the changes, and push it to GitHub where the new commits would be attached to the PR automatically.

    For detailed code review tips, See Review a pull request for details.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/","title":"Contributing to MatrixOne Documentation","text":"

    Contributions to the MatrixOne documentation are welcome from everyone. The MatrixOne community strives to make the contribution process simple and straightforward. To do that, we create this page to walk you through the whole process step by step.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#before-you-start","title":"Before you start","text":"

    Before you contribute, please take a minute to familiarize yourself with basic Markdown syntax and look at our Code of Conduct and the Google Developer Documentation Style Guide for some guidance on writing accessible, consistent, and inclusive documentation.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#how-is-matrixone-documentation-project-organized","title":"How is MatrixOne documentation project organized?","text":"

    The MatrixOne documentation is managed in 3 repositories:

    • The english markdown contents are in the matrixorigin.io repo.

    • The chinese markdown contents are in the matrixorigin.io.cn repo.

    • The images and unstructured data are located in the artwork repo.

    The images are referred to as web image links from artwork repo. The matrixorigin.io and matrixorigin.io.cn have implemented a CI&CD project, which will be triggered by a new code merge and manual launch. This CI&CD workflow publishes the documentation to https://docs.matrixorigin.cn/en/.

    The documentation project is based on the mkdocs-material. You can find the corresponding syntax and commands with this project.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#matrixone-documentation-structure","title":"MatrixOne Documentation Structure","text":"

    The MatrixOne documentation content is planned with 6 main modules.

    • Overview: MatrixOne's introduction, features and architecture.

    • Getting Started: How to quickly deploy and run a standalone MatrixOne.

    • Developing Guide: How to develop some applications based on MatrixOne using different programming languages.

    • Deploying: How to quickly deploy and run MatrixOne cluster.

    • Tutorials: Examples of developing application demos.

    • Maintenance: How to maintain MatrixOne, including backing up and restoring data.

    • Migrating: How to migrate data from other databases to MatrixOne.

    • Testing: How to perform a self-test or MatrixOne performance test using the test tool.

    • Performance Tuning: How to tune the MatrixOne performance in a stand-alone or distributed environment.

    • Privilege: Multi-account management, account lifecycle management, and authorization in MatrixOne clusters.

    • Reference: SQL reference, Configuration parameters.

    • Troubleshooting: Introduce common errors and debugging tools.

    • FAQs: Product, Technical Design, SQL, Deployment FAQs.

    • Release Notes: Release notes of all versions.

    • Contribution Guide: How to contribute to MatrixOne project.

    • Glossary: Table of noun definitions.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#lift-a-finger","title":"Lift a finger","text":"

    If you are correcting a typo or grammatical error, feel free to go ahead and create a pull request for English docs or create a pull request for Chinese docs.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#contribute-workflow","title":"Contribute Workflow","text":"

    When you need to change the specific content of the document but do not involve the adjustment of the chapter order and structure organization, you need to modify matrixorigin.io/tree/main/docs/MatrixOne or matrixorigin.io.cn/tree/main/docs/MatrixOne to operate.

    If you need to adjust the chapter order and structure organization, you must modify the matrixorigin.io/blob/main/mkdocs.yml or matrixorigin.io.cn/blob/main/mkdocs.yml.

    The following process shows the case of modifying both, and the actual situation can be simplified according to your needs.

    1. File an English doc issue or File an Chinese doc issue and assign it to yourself by commenting /assign.

    2. Fork matrixorigin.io and matrixorigin.io.cn repos. 3. Clone the matrixorigin.io and matrixorigin.io.cn repos.

    • Clone matrixorigin.io:
    git clone git@github.com:yourusername/matrixorigin.io.git\n
    • Clone the matrixorigin.io.cn:
    git clone git@github.com:yourusername/matrixorigin.io.cn.git\n

    4. Add matrixorigin.io and matrixorigin.io.cn repos as the remote repository in your local folder with:

    • Add matrixorigin.io repo as a remote repository in your local matrixorigin.io folder with:
    git remote add upstream https://github.com/matrixorigin/matrixorigin.io.git\n
    • Add matrixorigin.io.cn repo as a remote repository in your local matrixorigin.io.cn folder with:
    git remote add upstream https://github.com/matrixorigin/matrixorigin.io.cn.git\n

    5. As the local repo has the full documentation project code, you can run mkdocs serve under matrixorigin.io or matrixorigin.io.cn folder, and check http://localhost:8000 to check if this project runs well.

    mkdocs serve\n

    6. Make your modification. If the modification concerns the project settings, update the sitemap with new pages, or update the CI&CD workflow code. You can always check http://localhost:8000 to see if your modification is effective.

    7. Push your git commits to your remote Github matrixorigin.io and matrixone repos. We recommend you push to a new branch using the following commands:

    git push origin main:NEW_BRANCH\n

    8. Go back to GitHub, and submit a pull request in NEW_BRANCH so that we can review your changes.

    9. Once your code for both repositories is merged, you'll wait for a CI&CD workflow to restart running until the documentation website being updated.

    Note

    So once your pull requests are merged, the update to the website is not immediate. We'll need to run a manual launch to update it.

    10. At last, you should update your local and remote repo to help keep committing history clean. Override your local committing repo with:

    git pull --force upstream main:main\n

    Update the main branch of your remote repo in Github:

    git push --force origin main:main\n

    Note

    Most processes should be implemented in both matrixorigin.io and matrixorigin.io.cn.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#contribute-a-blog-article","title":"Contribute a blog article","text":"

    If you would like to write an article for our blog, please file an issue or send it to dengnan@matrixorigin.io. Feel free to submit either a completed draft or any article ideas. All submissions will be reviewed as quickly as possible. If your article or idea seems like a good fit for the blog, we will reach out to you directly.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/","title":"Make a Design Proposal","text":"

    Many changes including bug fixes and documentation improvements, can be implemented and reviewed via the normal GitHub pull request workflow, which we have already introduced in the previous chapter. However, when you come up with a new feature you need or expect MatrixOne to achieve, we encourage you to propose your idea and express it as a technical design document. Therefore, this page is intended to guide you to provide a consistent and controlled path for new features to enter the MatrixOne projects, so that all stakeholders can fully understand the direction the project is evolving towards. This page defines the best practices procedure for making a proposal in MatrixOne projects.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/#before-writing-a-design-document","title":"Before writing a design document","text":"

    Making enough preparations ahead of the design document can promote your working efficiency and increase the likelihood of it being accepted. Oppositely, a rough and casual design document may be rejected quickly. We motivate you to ask for help from experienced developers in order to obtain valuable suggestions to frame your design architecture or fill in details, which undoubtedly will upgrade the document to be desirable.

    The most common channel for preparing for writing a design document is the Github issue. You can file a Feature Request or Refactoring Request to discuss your ideas.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/#process","title":"Process","text":"

    Generally, you can follow these steps to finish the whole process:

    • Create an issue describing the problem, goal, and solution.
    • Get responses from other contributors to see if your proposal is generally acceptable and whether or not you should make some modifications.
    • Create a pull request with a design document based on the design template.
    • Make conversation with reviewers, and revise the text in response.
    • The design document is accepted or rejected when at least two committers reach a consensus and there is no objection from the committer.
    • If accepted, create a tracking issue for the design document or convert one from a previous discussion issue. The tracking issue basically tracks subtasks and progress. And refer to the tracking issue in the design document replacing the placeholder in the template.
    • Merge the pull request of design.
    • Start the implementation.

    Please refer to the tracking issue from subtasks to track the progress.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/","title":"Preparation","text":"

    Before contributing, it's necessary to make some preparations to learn more about MatrixOne and other prerevalant information which can improve developing and reviewing efficiency.

    Thanks for understanding that this repository uses English as a shared language. Maintainers do not use machine translation to avoid miscommunication due to errors in translation. If the description of an issue / PR is written in non-English languages, it may be closed. If English is not your native language and you aren't sure about any of these, don't hesitate to ask for help in your pull request!

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#what-is-matrixone","title":"What is MatrixOne","text":""},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#basic-information","title":"Basic Information","text":"

    You can see MatrixOne Introduction for key features of MatrixOne, MatrixOne Architecture for MatrixOne architecture, and operational logic.

    Besides, you can browse SQL Reference and Custom Functions to know more about our interactive details.

    These introductions will help you go through you the key concepts and user details to understand the project.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#roadmap","title":"Roadmap","text":"

    MatrixOne v1.0.0-rc1 has been released, you can see Release Notes know more information.

    For the long-term project roadmap, please refer to MatrixOne roadmap for a more general overview.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#what-contributions-can-i-make","title":"What Contributions Can I Make","text":"

    Contributions to MatrixOne are not limited to writing code. What follows are different ways to participate in the MatrixOne project and engage with our vibrant open-source community. See Types of Contributions for more details.

    • To report a bug or a problem with the documentation, please file an issue providing the details of the problem. Don't forget to add a proper label for your issue, and follow the issue templates.
    • To propose a new feature, please file a new feature request. Describe the intended feature and discuss the design and implementation with the team and community. Once the team agrees on the plan, you can follow the Contribution Workflow to implement it.
    • To implement a feature or bug-fix for an existing outstanding issue, follow the Contribution workflow. If you need more context on a particular issue, comment on the issue to let people know.
    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#working-directories-and-files","title":"Working Directories and Files","text":"

    For contributing code, matrixone is the main repository you'll be working on. The main working directories are listed below:

    Directory Working Files /LICENSES The license of dependant libraries /cmd The binary entry of Go executables optools The test and deployment utilities pkg The main codebase of MatrixOne project

    For different technical modules, a code structure under /pkg is as shown in the following table.

    Directory Modules frontend/ SQL Frontend sql/ MPP SQL Execution sql/parser SQL Parser sql/vectorize Vectorization of SQL Execution catalog/ Catalog for storing metadata vm/engine Storage engine vm/engine/aoe Analytics Optimized Engine vm/engine/tpe Transaction Processing Engine buildin/ System builtin functions

    For contributing documentation, matrixorigin.io , matrixorigin.io.cn and artwork are all the main repositories you'll be working on. For more details, please refer to Contribute Documentation.

    Directory Working Files matrixone/docs/rfcs The design docs of MatrixOne project matrixorigin.io/docs/MatrixOne The content files of the English MatrixOne documentation website matrixorigin.io.cn/docs/MatrixOne The content files of the Chinese MatrixOne documentation website matrixorigin.io/mkdocs.yml The configuration file of the English documentation website matrixorigin.io.cn/mkdocs.yml The configuration file of the Chinese documentation website artwork/docs The images, screenshots and diagrams of documentation webstie"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#set-up-your-development-environment","title":"Set up your Development Environment","text":""},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#go-environment","title":"Go Environment","text":"

    MatrixOne is written in Go. Before you start contributing code to MatrixOne, you need to set up your GO development environment.

    1. Install Go version 1.19. You can see How to Write Go Code for more information.
    2. Define GOPATH environment variable and modify PATH to access your Go binaries. A common setup is as follows. You could always specify it based on your own flavor.
    export GOPATH=$HOME/go  export PATH=$PATH:$GOPATH/bin\n

    Note

    MatrixOne uses Go Modules to manage dependencies.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#github-git","title":"Github & Git","text":"

    MatrixOne is an open-source project built on Github, providing project maintainers and contributors with a platform to work together. Thus, in order to start working with MatrixOne repository, you will need a GitHub account and learn basic git commands. If you don't have a Github account, please register at https://github.com. In case you do not have SSH keys, you should generate them and then upload them on GitHub. It is required for sending over your patches. It is also possible to use the same SSH keys that you use with any other SSH servers - probably you already have those. For detailed information about Github, you can see Github Docs.

    To work with git repositories, please install git. And you can learn how to use it throuth following introduction:

    • A brief manual can be found here.
    • A detailed manual can be found here.
    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#install-and-run-matrixone","title":"Install and Run MatrixOne","text":"

    See Install Standalone MatrixOne for more details.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/","title":"Report Issues","text":"

    Any problem is encouraged to be published when you participate in MatrixOne, and you can report issues about this problem on GitHub with templates and labels we suggest. This page is intended to introduce templates, labels, and precautions you will follow when you report issues.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#avoid-duplicated-issues","title":"Avoid Duplicated Issues","text":"

    Before reporting an issue, you should see whether the problem has already been reported. You can use the search bar to search for existing issues.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#issue-templates","title":"Issue Templates","text":"

    If the problem you're reporting is not already in the issue tracker, you can file an issue with your GitHub account. MatrixOne uses issue templates for different kinds of issues. Issue templates are a bundle of questions to collect necessary information about the problem to make it easy for other contributors to participate. MatrixOne suggests 6 types of issue templates:

    A Bug report issue template consists of the information below:

    • Detail Environment Describe the details about the operating environment including version, hardware parameters, OS type, and so on.
    • Steps to Reproduce List steps to reproduce what you encountered.
    • Actual & Expected Behavior Describe what's the observed and your expected behavior respectively.

    A Feature Request consists of the information below:

    • Is your feature request related to a problem? A clear and concise description of the problem and state why you need this feature.
    • Describe the feature you'd like: A clear and concise description of what you want to happen.
    • Describe alternatives you've considered: A clear and concise description of any alternative solutions or features you've considered.
    • Teachability, Documentation, Adoption, Migration Strategy: If you can, explain some scenarios in how users might use this, and situations it would be helpful. Any API designs, mockups, or diagrams are also helpful.

    A Documentation Issue consists of the information below:

    • Describe the issue A clear and concise description of what's wrong in the documentation.
    • Additional context Add any other context about the problem here.

    A Performance Question consists of the information below:

    • Detail Environment Describe the details about the operating environment including version, hardware parameters, OS type, and so on.
    • Steps to Reproduce List steps detailedly to reproduce the operations to test performance.
    • Expected & Actual Performance Describe what's the observed and your expected performance respectively.
    • Additional context Add any other context about the problem here. For example:
      • Have you compared MatrixOne with other databases? If yes, what's their difference?

    An Enhancement consists of the information below:

    • What would you like to be added A concise description of what you're expecting/suggesting.
    • Why is this needed A concise description of the reason/motivation.
    • Anything else Anything that will give us more details about your issue!

    A Refactoring Request consists of the information below:

    • Is your refactoring request related to a problem? A clear and concise description of what the problem is.
    • Describe the solution you'd like A clear and concise description of the refactoring you want to do.
    • Describe alternatives you've considered A clear and concise description of any alternative solutions or refactoring methods you've considered.
    • Additional context Add any other context or screenshots about the refactoring request here.

    A General Question:

    If the previous templates don't fit with what you'd like to report or ask, please use this general question template to file the issue.

    Before asking a question, make sure you have:

    • Searched open and closed GitHub issues
    • Read the documentation:
      • MatrixOne Readme
      • MatrixOne Doc
    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#issue-labels","title":"Issue Labels","text":"

    Once your issue is submitted, it will automatically be labeled with needs-triage, a MatrixOne maintainer will look at the issue, tag it with more suitable labels, and assign it to a suitable developer. If you'd like to work on the issue by yourself, you can comment /assign on the issue you would like to work on, and you will be automatically assigned to the issue. You can then find yourself listed under the Assignees section.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#good-first-issues","title":"Good First Issues","text":"

    When you make the first contribution to MatrixOne, you can select one of the issues labeled good-first-issues each of which is relatively approachable for first-time contributors. For detailed suggestions, you need when you make the first contribution, you can see Make Your First Contribution.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/","title":"Reviews","text":"

    For MatrixOne, any type of review for a pull request is crucial, where you can classify the pull request to help look for more suitable experts to solve related problems or propose your suggestions to code for not only content but style. It's not necessary to doubt whether your review is constructive and useful enough because no matter how tiny, a suggestion may profoundly influence MatrixOne. Certainly, before reviewing we ask that you browse this page to learn basic requirements and relative methods.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#principles-of-the-code-review","title":"Principles of the code review","text":"

    When you review a pull request, there are several rules and suggestions you should take to propose better comments. Regardless of the specifics, we suggest you stay friendly first:

    • Be respectful Be respectful to every pull request author and other reviewers. Code review is a part of community activities so you should follow the community requirements.
    • Be careful with tone Try to frame your comments as suggestions or questions instead of commands. If the tone is softer, your reviews will be easier to accept.
    • Be generous with your compliments We recommend you offer encouragement and appreciation to the authors for their good practices in the code segments. In many cases, telling the authors what they did is right is even more valuable than telling them what they did is wrong.

    Additionally, here are some suggestions in terms of content:

    • Provide more We encourage you to provide additional details and context of your review process as much as you can. Undoubtedly, the more detailed your review, the more useful it will be to others. If you test the pull request, please report the result and your test environment details. If you request some changes, try to suggest how.
    • Keep objective Avoid individual biased opinions and subjective emotions. Of course, everyone will comment with more or less subjective opinions. However, as a good reviewer, you should consider the technique and data facts rather than your own personal preferences.
    • Case by case It's difficult to decide whether it's more reasonable to accept or reject when you are faced with a complex problem. Regrettably, we can't provide a certain answer because it always depends on the specific situation, which asks you to balance the pros and cons.
    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#classifying-pull-requests","title":"Classifying pull requests","text":"

    Some pull request authors may not be familiar with MatrixOne, the MatriOne development workflow, or the MatrixOne community. They don't know what labels should be added to the pull requests or which expert could be asked for a review. If you are able to, it would be great for you to triage the pull requests, add suitable labels to the pull requests, and request corresponding experts to review the pull requests. These actions could help more contributors notice the pull requests and make quick responses.

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#checking-pull-requests","title":"Checking pull requests","text":"

    There are some basic aspects to check when you review a pull request:

    • Concentration One pull request should only do one thing. No matter how small it is, the change does exactly one thing and gets it right. Don't mix other changes into it.
    • Tests A pull request should be test covered, whether the tests are unit tests, integration tests, or end-to-end tests. Tests should be sufficient, correct, and don't slow down the CI pipeline largely.
    • Functionality The pull request should implement what the author intends to do, fit well in the existing code base, and resolve a real problem for users. Thus you should check whether or not the pull request achieves the intention and you could follow the discussions in the corresponding GitHub issue.
    • Style Code in the pull request should follow a common programming style. However, sometimes the existing code is inconsistent with the style guide. You should maintain consistency with the existing code or file a new issue to fix the existing code style first.
    • Documentation If a pull request changes how users build, test, interact with, or release code, you must check whether it also updates the related documentation such as README.md and any generated reference docs. Similarly, if a pull request deletes or deprecates code, you must check whether or not the corresponding documentation should also be deleted.
    • Performance If you find the pull request may affect performance, you could ask the author to provide a benchmark result.
    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/","title":"Types of Contributions","text":"

    Contributions to MatrixOne are not limited to writing code. What follows are different ways to participate in the MatrixOne project and engage with our vibrant open-source community:

    "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#contribute-code","title":"Contribute Code","text":"Contribution type Description Report a bug To report a problem with MatrixOne, file an issue on GitHub. Include detailed information about the problem you've encountered. Contribute code You can fix a bug for any outstanding issues on GitHub, improve the code, or propose a design or implementation for a new MatrixOne feature. See Contribute Code for the contribution conventions and best practices. Review or approve pull requests Review or approve pull requests for the MatrixOne project as a reviewer or maintainer."},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#contribute-to-matrixone-documentation","title":"Contribute to MatrixOne Documentation","text":"Contribution type Description Report or fix a technical documentation issue You can either click edit the page directly on the target page of MatrixOne, or file an English document issue/file an Chinese document issue on MatrixOne repository with detailed information, and, if possible, propose changes by creating an English document pull request/creating a Chinese document pull request. Contribute a new piece of technical document Before contributing a full-length technical document, read Contribution Documentation."},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#other-contributions","title":"Other Contributions","text":"Contribution type Description Share your demos and solutions Show MatrixOne users how to leverage the platform in specific scenarios. Send your use case to dengnan@matrixorigin.io and we'll post it in the community. Author a blog article, user story, or whitepapers Write high-quality content that clearly and accurately explains technical details about MatrixOne. Give a tech talk or host a live broadcast Give talks or host live broadcasts that help raise awareness around MatrixOne. Support MatrixOne users Help users on GitHub solve the problems they meet while using MatrixOne. Issue triage Adding descriptive labels to our GitHub issues speeds up routing issues to the right person in charge. It is a great contribution to the operation of the MatrixOne project. Contribute otherwise Any contribution that plays a positive role in the development of MatrixOne and its open-source community will be considered for eligibility."},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/","title":"MatrixOne Operator Management","text":""},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#matrixone-operator-overview","title":"MatrixOne Operator overview","text":"

    MatrixOne Operator is used to define and manage the resource requirements of MatrixOne clusters in Kubernetes, consisting of a set of Kubernetes custom resources (CustomResourceDefinitions, CRD), a set of Kubernetes controllers and a set of WebHook services:

    • CRD: In Kubernetes, CRD is an object that registers a new custom resource type into Kubernetes APIServer. The CRDs contained in MatrixOne Operator register various custom resources, including MatrixOneCluster resources used to describe MatrixOne clusters and resources such as CNSet, TNSet, and LogSet used to describe components in the cluster. After the registration, the client can read and write these resources on the Kubernetes APIServer.

    • Controller: The controller is a long-running automation program responsible for monitoring the desired state of resources in Kubernetes, collecting the actual state of these resources, and automatically operating and maintaining them to drive the actual state to the desired state. The controller in matrixone-operator monitors resources such as MatrixOneCluster, CNSet, TNSet, LogSet, etc., and is responsible for realizing the desired state declared by the user through these resources.

    • Webhook service: A webhook service is a long-running HTTP service. When Kubernetes APIServer receives a request from a user to read and write resources such as MatrixOneCluster, CNSet, TNSet, and LogSet, it will forward the request to the Webhook service, and the Webhook service will perform logic such as request verification and default value filling.

    When using Helm chart to install Matrixone-Operator, it will automatically submit the required CRDs to Kubernetes APIServer, complete the registration of custom resources, and deploy a long-running Matrixone-Operator application. The controller mentioned above, and webhook services are packaged in this application.

    "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#cluster-management","title":"Cluster Management","text":"

    MatrixOne Operator provides users with declarative cluster management capabilities through MatrixOneCluster resources. Specifically, when deploying a MatrixOne cluster on Kubernetes, the user can declare a MatrixOneCluster object in YAML format to describe the cluster, and the controller of the operator will realize the orchestration of the cluster according to the description and update the cluster status to the .status of the MatrixOneCluster object field.

    A MatrixOneCluster cluster consists of components such as Compute Node (CN), Transaction Node (TN), and Log Service, which correspond to sub-resources such as CNSet, TNSet, and LogSet. Therefore, the controller of the MatrixOneCluster resource orchestrates these sub-resources and relies on the controllers of these sub-resources to complete their orchestration.

    "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#deployment-operation-maintenance","title":"Deployment, Operation, Maintenance","text":"

    The deployment, operation, and maintenance environment introduced in this chapter will be based on the environment of MatrixOne Distributed Cluster Deployment.

    The following operations are performed on the master0 node.

    "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#deployment","title":"Deployment","text":"

    Please look at the MatrixOne-Operator deployment chapter of MatrixOne Distributed Cluster Deployment.

    "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#check-status","title":"Check Status","text":"

    We use the Helm tool to deploy MatrixOne Operator. Helm is a Kubernetes application package management tool for managing charts, pre-configured installation package resources, similar to Ubuntu's APT and CentOS YUM. You can use the helm list command to check the deployment status of the Operator.

    [root@master0 ~]# NS=\"matrixone-operator\"\n[root@master0 ~]# helm list -n${NS}\nNAME                    NAMESPACE               REVISION        UPDATED                                 STATUS          CHART                                   APP VERSION\nmatrixone-operator      matrixone-operator      1               2023-05-09 15:19:38.363683192 +0800 CST deployed        matrixone-operator-0.8.0-alpha.2        0.1.0\n
    "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#update","title":"Update","text":"

    The MatrixOne-Operator project is a long-term maintenance and update project; please update to the latest version. You can download the new version of Operator on Github, for example: matrixone-operator-0.8.0-alpha.2.

    Unzip the file with the following command:

    tar xvf ./matrixone-operator-0.8.0-alpha.2.tgz\ncd matrixone-operator\n

    You can use the helm upgrade command to upgrade Matrixone-Operator. You can get the mirror version with the following command:

    cd matrixone-operator\nNS=\"matrixone-operator\"\nhelm upgrade -n \"${NS}\" matrixone-operator ./ --dependency-update\n

    After the upgrade is successful, the code display is as follows:

    Release \"matrixone-operator\" has been upgraded. Happy Helming!\nNAME: matrixone-operator\nLAST DEPLOYED: Tue May  9 17:59:06 2023\nNAMESPACE: matrixone-operator\nSTATUS: deployed\nREVISION: 2\nTEST SUITE: None\n

    After the upgrade is complete, you can view the current version with the following command:

    #Get mirror version\nNS=\"matrixone-operator\"\nkubectl get pod -n${NS} `kubectl get pod -n${NS}  | grep operator | head -1 | awk '{print $1}'` -ojsonpath='{.spec.containers[0].image}'\nmatrixorigin/matrixone-operator:0.8.0-alpha.2\n

    After upgrading Matrixone-Operator, a new Pod of matrixone-operator-xxxx-xxx will be regenerated under the matrixone-operator namespace, and then the old Pod will be deleted.

    Note

    After the upgrade is complete, if the changes brought about by the Matrixone-Operator upgrade will also update the default .spec, then it is possible to roll over the related services or configurations of the MatrixOne cluster so that the MatrixOne service may be restarted. You can monitor the upgrade process with the command: watch -e \"kubectl get pod -nmo-hn -owide\".

    NS=\"matrixone-operator\"\nwatch -e \"kubectl get pod -n${NS} -owide\"\n
    NAME                                 READY   STATUS    RESTARTS   AGE    IP              NODE    NOMINATED NODE   READINESS GATES\nmatrixone-operator-f8496ff5c-s2lr6   1/1     Running   0          164m   10.234.168.43   node1   <none>           <none>\n
    "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#scaling","title":"Scaling","text":"

    Since Operators often use limited resources, there are relatively few scenarios for vertical scaling. Generally speaking, we only need to consider horizontal scaling, increasing or decreasing the number of replicas. Usually, the Operator has a single copy. If we need to enhance the high availability of the Operator, consider expanding it, for example, to two copies. This way, even if the first replica fails (for example, pulling an image fails on its node), the other replica can still function normally. We can expand and shrink the number of Operator replicas by using the Helm Upgrade command and specifying the number of replicaCount in the deployment directory of the current Operator version. This is very important for the deployment and O&M management operations of MO clusters.

    Before scaling up, we can use the following command to view the number of Operators:

    NS=\"matrixone-operator\"\nwatch -e \"kubectl get pod -n${NS} -owide\"\n
    NAME                                 READY   STATUS    RESTARTS   AGE    IP              NODE    NOMINATED NODE   READINESS GATES\nmatrixone-operator-f8496ff5c-s2lr6   1/1     Running   0          164m   10.234.168.43   node1   <none>           <none>\n
    • Expansion: Use the following command line to expand capacity:
    # number of replicas\ncd matrixone-operator\nNUM=2\nNS=\"matrixone-operator\"\nhelm upgrade -n${NS} matrixone-operator ./ --dependency-update --set replicaCount=${NUM}\n

    The expansion is successful, and the printing code example is as follows:

    Release \"matrixone-operator\" has been upgraded. Happy Helming!\nNAME: matrixone-operator\nLAST DEPLOYED: Tue May  9 18:07:03 2023\nNAMESPACE: matrixone-operator\nSTATUS: deployed\nREVISION: 3\nTEST SUITE: None\n

    You can continue to observe the number of operators with the following command:

    watch -e \"kubectl get pod -nmo-hn -owide\"\nNAME                                 READY   STATUS    RESTARTS   AGE    IP              NODE    NOMINATED NODE   READINESS GATES\nmatrixone-operator-f8496ff5c-nt8qs   1/1     Running   0          9s     10.234.60.126   node0   <none>           <none>\nmatrixone-operator-f8496ff5c-s2lr6   1/1     Running   0          167m   10.234.168.43   node1   <none>           <none>\n

    If you need to scale down horizontally, you can use helm upgrade to reduce the number of replicaCount to complete the reduction of the number of replicas of the operator.

    "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#uninstall","title":"Uninstall","text":"

    Warning

    Before uninstalling Matrixone-Operator, confirm clearly, because the uninstallation operation will directly uninstall the resources related to the Matrixone cluster, including SVC, Pod, etc. (but not including the PVC resources used by the log service).

    Uninstall Matrixone-Operator with the following command:

    helm uninstall matrixone-operator -n mo-hn\n
    "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/","title":"Scaling MatrixOne Cluster","text":"

    This document will introduce how to scale the MatrixOne cluster, including the Kubernetes cluster and scaling of individual MatrixOne services.

    The environment introduced in this document will be based on the environment of MatrixOne Distributed Cluster Deployment.

    "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#when-is-it-necessary-to-scale","title":"When is it necessary to scale","text":"

    To determine whether the MatrixOne service needs to be scaled up or down, users need to monitor the nodes where the MatrixOne cluster resides and the resources used by the Pods corresponding to related components. You can do this with the kubectl top command. For more detailed operation steps, please refer to Health Check and Resource Monitoring.

    In general, if the resource usage of a node or Pod exceeds 60% and lasts for some time, consider expanding capacity to cope with the peak load. In addition, capacity expansion operations must also be considered if a high TPS request volume is observed according to business indicators.

    "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#scaling-kubernetes","title":"Scaling Kubernetes","text":"

    Kubernetes manages and allocates essential hardware resources in the distributed MatrixOne cluster. Kubernetes can expand or contract the hardware nodes in the cluster using the kuboard spray graphical management page. For more information on tutorials, see kuboard spray official documents.

    You need to add a working node to the cluster, and the overall hardware configuration resources are shown in the following table:

    Host Internal IP External IP mem CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker node1 10.206.134.16 129.211.211.29 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#scaling-matrixone-services","title":"Scaling MatrixOne Services","text":"

    Scaling of services refers to expanding or contracting the core component services within the MatrixOne cluster, such as Log Service, TN, and CN. Based on the architectural characteristics of MatrixOne, the following conditions apply to these service nodes:

    • Log Service has only 3 nodes.
    • TN has only 1 node.
    • The number of CN nodes is flexible.

    Therefore, scaling of Log Service and TN nodes is possible only through vertical scaling. However, CN nodes can be scaled both vertically and horizontally.

    "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#horizontal-scaling","title":"Horizontal scaling","text":"

    Horizontal scaling refers to the increase or decrease in the number of copies of a service. You can change the number of service replicas by modifying the value of the .spec.[component].replicas field in the MatrixOne Operator startup yaml file.

    1. Use the following command to activate the value of the .spec.[component].replicas field in the yaml file:

      kubectl edit matrixonecluster ${mo_cluster_name} -n ${mo_ns}\n
    2. Enter edit mode:

      tp:\n    replicas: 2 #Changed from 1 CN to 2 CNs\n#Other content is ignored\n

      Note

      You can also refer to the above steps to change the field value of replicas for scaling down.

    3. After editing the number of replicas, saving, and exiting, MatrixOne Operator will automatically start a new CN. You can observe the new CN status with the following command:

      [root@master0 ~]# kubectl get pods -n mo-hn      \nNAME                                  READY   STATUS    RESTARTS     AGE\nmatrixone-operator-6c9c49fbd7-lw2h2   1/1     Running   2 (8h ago)   9h\nmo-tn-0                               1/1     Running   0            11m\nmo-log-0                              1/1     Running   0            12m\nmo-log-1                              1/1     Running   0            12m\nmo-log-2                              1/1     Running   0            12m\nmo-tp-cn-0                            1/1     Running   0            11m\nmo-tp-cn-1                            1/1     Running   0            63s\n

    In addition, Kubernetes' SVC will automatically ensure CN load balancing and user connections will be evenly distributed to different CNs. You can view the number of connections on each CN through the built-in system_metrics.server_connections table of MatrixOne.

    "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#vertical-scaling","title":"Vertical scaling","text":"

    Vertical scaling refers to the resources required to serve a copy of a single component, such as adjusting CPU or memory.

    1. Use the following command to modify the configuration of requests and limits in the corresponding component's .spec.[component].resources. The example is as follows:

      kubectl edit matrixonecluster ${mo_cluster_name} -n ${mo_ns}\n
    2. Enter edit mode:

      metadata:\n  name: mo\n  # content omitted\nspec:\n  tp:\n        resources:\n      requests:\n        cpu: 1\n        memory: 2Gi\n      limits:\n        cpu: 1\n        memory: 2Gi\n...\n# content omitted\n
    "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#node-scheduling","title":"Node Scheduling","text":"

    By default, Matrixone-operator does not configure topology rules for each component's Pod but uses Kubernetes' default scheduler to schedule according to each Pod's resource request. If you need to set specific scheduling rules, such as scheduling the cn component to two specific nodes, node0, and node1, you can follow the steps below:

    1. Set labels for node0 and node1.

    2. Set nodeSelector in the MatrixOne cluster so the service can be scheduled to the corresponding node.

    3. (Optional) Set the TopologySpread field in the MatrixOne cluster to achieve an even distribution of services across nodes.

    4. Set the number of replicas replicas in the MatrixOne cluster.

    "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#set-node-label","title":"Set node label","text":"
    1. Execute the following command to view the status of the cluster nodes:

      [root@master0 ~]# kubectl get node\nNAME      STATUS   ROLES                  AGE   VERSION\nmaster0   Ready    control-plane,master   47h   v1.23.17\nnode0     Ready    <none>                 47h   v1.23.17\nnode1     Ready    <none>                 65s   v1.23.17\n
    2. According to the above-returned results and actual needs, you can label the nodes; see the following code example:

      NODE=\"[node to be labeled]\" # According to the above results, it may be IP, hostname, or alias, such as 10.0.0.1, host-10-0-0-1, node01, then set NODE = \"node0\"\nLABEL_K=\"mo-role\" # The key of the label, which can be defined on demand, or can be directly used as an example\nLABEL_V=\"mo-cn\" # The value of the label, which can be defined as needed, or can be directly used as an example\n\nkubectl label node ${NODE} ${LABEL_K}=${LABEL_V}\n
    3. In this case, you can also write the following two statements:

      kubectl label node node0 \"mo-role\"=\"mo-cn\"\nkubectl label node node1 \"mo-role\"=\"mo-cn\"\n
    4. Use the following command to confirm that the node label is printed:

      [root@master0 ~]# kubectl get node node0 --show-labels | grep mo_role     \nnode0   Ready    <none>   47h   v1.23.17   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node0,kubernetes.io/os=linux,mo_role=mo_cn\n[root@master0 ~]# kubectl get node node1 --show-labels | grep mo_role\nnode1   Ready    <none>   7m25s   v1.23.17   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node1,kubernetes.io/os=linux,mo_role=mo_cn\n
    5. Execute the following command to delete tags as needed:

      kubectl label node ${NODE} ${LABEL_K}-\n
    "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#set-service-scheduling-rules-uniform-distribution-and-number-of-copies","title":"Set service scheduling rules, uniform distribution, and number of copies","text":"
    1. Execute the following command to view the current distribution of Pods on multiple nodes:

      [root@master0 mo]# kubectl get pod -nmo-hn -owide\nNAME         READY   STATUS    RESTARTS   AGE   IP              NODE    NOMINATED NODE   READINESS GATES\nmo-tn-0      1/1     Running   0          34m   10.234.60.120   node0   <none>           2/2\nmo-log-0     1/1     Running   0          34m   10.234.168.72   node1   <none>           2/2\nmo-log-1     1/1     Running   0          34m   10.234.60.118   node0   <none>           2/2\nmo-log-2     1/1     Running   0          34m   10.234.168.73   node1   <none>           2/2\nmo-tp-cn-0   1/1     Running   0          33m   10.234.168.75   node1   <none>           2/2\n
    2. According to the above output and actual requirements, it can be seen that there is only one CN at present, and we need to set the scheduling rules for the CN component. We will modify it in the properties of the MatrixOne cluster object. The new CN will be scheduled to node0 under the rule of uniform distribution within the scheduling scope. Execute the following command to enter edit mode:

      mo_ns=\"mo-hn\"\nmo_cluster_name=\"mo\" # The general name is mo, specified by the name in the yaml file of the matrixonecluster object during deployment, or confirmed by kubectl get matrixonecluster -n${mo_ns}\nkubectl edit matrixonecluster ${mo_cluster_name} -n ${mo_ns}\n
    3. In edit mode, according to the above scenario, we will set the number of copies of CN to 2 and schedule on nodes labeled mo-role:mo-cn to achieve uniform distribution within the scheduling range. We will use spec.[component].nodeSelector to specify the tag selector for a specific component. Here is the edited content of the example:

      metadata:\n  name: mo\n# Intermediate content omitted\nspec:\n# Intermediate content omitted\n  tp:\n    # Set the number of replicas\n    replicas: 2\n    # Set scheduling rules\n    nodeSelector:\n      mo-role: mo-cn\n    # Set the uniform distribution within the scheduling range\n    topologySpread:\n      - topology.kubernetes.io/zone\n      - kubernetes.io/hostname\n#Other content omitted\n
    4. After the change takes effect, execute the following command to check that the two CNs are already on the two nodes:

      [root@master0 ~]# kubectl get pod -nmo-hn -owide      \nNAME         READY   STATUS    RESTARTS        AGE     IP              NODE    NOMINATED NODE   READINESS GATES\nmo-tn-0      1/1     Running   1 (2m53s ago)   3m6s    10.234.168.80   node1   <none>           2/2\nmo-log-0     1/1     Running   0               3m40s   10.234.168.78   node1   <none>           2/2\nmo-log-1     1/1     Running   0               3m40s   10.234.60.122   node0   <none>           2/2\nmo-log-2     1/1     Running   0               3m40s   10.234.168.77   node1   <none>           2/2\nmo-tp-cn-0   1/1     Running   0               84s     10.234.60.125   node0   <none>           2/2\nmo-tp-cn-1   1/1     Running   0               86s     10.234.168.82   node1   <none>           2/2\n

    It should be noted that the configuration in the above example will make the Pods in the cluster evenly distributed on the two dimensions topology.kubernetes.io/zone and kubernetes.io/hostname. The tag keys specified in topologySpread are ordered. In the example above, Pods is first distributed evenly across the Availability Zones dimension, and then Pods within each Availability Zone are evenly distributed across the nodes within that zone.

    Using the topologySpread function can increase the availability of the cluster and reduce the possibility of destroying the majority of replicas in the cluster due to a single point or regional failure. But this also increases the scheduling requirements and the need to ensure that the cluster has enough resources available in each region.

    "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/","title":"Starting and stopping MatrixOne distributed Cluster","text":"

    This document will introduce how to start and stop the MatrixOne distributed cluster.

    The upgraded environment introduced in this document will be based on the environment of MatrixOne Distributed Cluster Deployment.

    "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#cluster-shutdown","title":"Cluster Shutdown","text":"

    To shut down a MatrixOne cluster, stop the read-write operations and then shut down the servers directly. The shutdown sequence is as follows: first, shut down the node0 node, then shut down the master0 node, and finally, shut down the Kuboard-Spray node.

    "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#cluster-restart","title":"Cluster Restart","text":"

    To restart a MatrixOne cluster, following the following hardware startup sequence is recommended: start the Kuboard-Spray node, then start the master0 node, and finally start the node0 node.

    After the hardware startup is complete, k8s will automatically recover. At the same time, MatrixOne and MinIO-related services will be automatically restored without manual intervention. However, it should be noted that the Docker of the Kuboard-Spray node will not be automatically restored, and the Kuboard-Spray service needs to be manually started.

    "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-k8s-status","title":"Check K8s Status","text":"

    On the master0 node that operates k8s, you can check the status of the k8s cluster nodes.

    In normal circumstances, the status of all nodes should be Ready. If the status of some nodes is abnormal, further investigation is required to determine the reason.

    kubectl get node\n# If the status is not \"Ready\", further investigation into the node's situation is necessary.\n# kubectl describe node ${NODE_NAME}\n

    Here is an example of a diagram for codes:

    "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-minio-status","title":"Check MinIO status","text":"

    On the master0 node operating k8s, you can check the status of MinIO.

    After the hardware starts, MinIO will automatically resume. You can use the following command to check the status of MinIO.

    NS=\"mostorage\"\nkubectl get pod -n${NS}\n

    Here is an example of a diagram for codes:

    "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-the-status-of-the-matrixone-cluster-and-components","title":"Check the status of the MatrixOne cluster and components","text":""},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-matrixonecluster-status","title":"Check MatrixOneCluster status","text":"

    First, check whether the MatrixOne cluster is standard. The MatrixOne cluster corresponds to the custom resource type MatrixOneCluster.You can use the following command to check the status of MatrixOneCluster:

    MO_NAME=\"mo\"\nNS=\"mo-hn\"\nkubectl get matrixonecluster -n${NS} ${MO_NAME}\n

    Under normal circumstances, the status should be Ready. If the status is NotReady, further troubleshooting is required.

    Here is an example of a diagram for codes:

    "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#view-matrixone-cluster-status-details","title":"View MatrixOne cluster status details","text":"

    If the MatrixOne cluster status is not normal, you can use the following command to view the details:

    kubectl describe matrixonecluster -n${NS} ${MO_NAME}\n

    "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-the-status-of-tnsetcnsetlogset","title":"Check the status of TNSet/CNSet/LogSet","text":"

    The main components of the current MatrixOne cluster are TN, CN, Log Service, and corresponding custom resource types TNSet, CNSet, and LogSet.These objects are generated by the MatrixOneCluster controller.

    You can use the following command to check the status of each component; take TN as an example:

    SET_TYPE=\"tnset\"\nNS=\"mo-hn\"\nkubectl get ${SET_TYPE} -n${NS}\n

    Here is an example of a diagram for codes:

    "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-pod-status","title":"Check Pod status","text":"

    You can directly check the native k8s objects generated in the MO cluster to confirm the cluster's health.Under normal circumstances, you can confirm the status of the pod:

    NS=\"mo-hn\"\nkubectl get pod -n${NS}\n

    Here is an example of a diagram for codes:

    Generally speaking, the running state is the normal state. However, there are a few exceptions, such as the status is running, but the MO cluster is abnormal, such as the inability to connect to the MO cluster through the MySQL Client. At this time, you can further check whether the Pod's log has abnormal information output:

    NS=\"mo-hn\"\nPOD_NAME=\"[The name of the pod returned above]\" # For example, mo-tp-cn-3\nkubectl logs ${POD_NAME} -n${NS}\n

    If the status is non-running, such as Pending, you can confirm the cause of the exception by looking at the event in the Pod status. For example, because the cluster resources cannot meet the application of mo-tp-cn-3, this pod cannot be scheduled and is pending. In this example, it can be solved by expanding the node's resources.

    kubectl describe pod ${POD_NAME} -n${NS}\n

    Here is an example of a diagram for codes:

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/","title":"MatrixOne Distributed Cluster Deployment","text":"

    This document will mainly describe how to deploy MatrixOne distributed database, based on a private Kubernetes cluster that separates computing and storage resources in a cloud-native manner, starting from scratch.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#main-steps","title":"Main Steps","text":"
    1. Deploy Kubernetes cluster
    2. Deploy object storage MinIO
    3. Create and connect MatrixOne cluster
    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#key-concepts","title":"Key Concepts","text":"

    As this document involves many Kubernetes-related terms, to help everyone understand the deployment process, we will provide brief explanations of important terms related to Kubernetes. If you need to know more about Kubernetes-related content, see Kubernetes Documentation

    • Pod

    Pod is the smallest resource management component in Kubernetes and the smallest resource object for running containerized applications. A Pod represents a process running in the cluster. In simple terms, we can consider a group of applications that provide specific functions as a pod containing one or more container objects that work together to provide services to the outside world.

    • Storage Class

    Storage Class, abbreviated as SC, marks the characteristics and performance of storage resources. According to the description of SC, we can intuitively understand the aspects of various storage resources and then apply storage resources according to the application's requirements. Administrators can define storage resources as a specific category, just as storage devices describe their configuration profiles.

    • CSI

    Kubernetes provides the CSI interface (Container Storage Interface, Container Storage Interface). Based on this set of CSI interfaces, custom CSI plug-ins can be developed to support specific storage and achieve the purpose of decoupling.

    • PersistentVolume

    PersistentVolume, abbreviated as PV, mainly includes setting key information such as storage capacity, access mode, storage type, recycling strategy, and backend storage type as a storage resource.

    • PersistentVolumeClaim

    PersistentVolumeClaim, or PVC, is used as a user's request for storage resources, mainly including the setting of information such as storage space request, access mode, PV selection conditions, and storage category.

    • Service

    Also called SVC, it matches a group of Pods to external access services through label selection. Each svc can be understood as a microservice.

    • Operator

    Kubernetes Operator is a way to package, deploy and manage Kubernetes applications. We use the Kubernetes API (Application Programming Interface) and the Kubectl tool to deploy and manage Kubernetes applications on Kubernetes.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#deployment-architecture","title":"Deployment Architecture","text":""},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#dependent-components","title":"Dependent components","text":"

    MatrixOne distributed system depends on the following components:

    • Kubernetes: As a resource management platform for the entire MatrixOne cluster, components such as Logservice, CN, and TN all run in Pods managed by Kubernetes. In the event of a failure, Kubernetes will cull the failed Pod and start a new one to replace it.

    • Minio: Provides object storage services for the entire MatrixOne cluster, and all MatrixOne data is stored in the object storage provided by Minio.

    Additionally, for container management and orchestration on Kubernetes, we need the following plugins:

    • Helm: Helm is a package management tool for managing Kubernetes applications, similar to APT for Ubuntu and YUM for CentOS. It is used to manage pre-configured installation package resources called Charts.

    • local-path-provisioner: As a plug-in that implements the CSI (Container Storage Interface) interface in Kubernetes, local-path-provisioner is responsible for creating persistent volumes (PVs) for Pods and Minios of MatrixOne components to achieve data persistence storage.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#overall-structure","title":"Overall structure","text":"

    The overall deployment architecture is shown in the following figure:

    The overall architecture consists of the following components:

    • The bottom layer is three server nodes: the first host1 is the springboard machine for installing Kubernetes, the second is the master node (master) of Kubernetes, and the third is Kubernetes' working node (node).

    • The installed Kubernetes and Docker environment is the upper layer, which constitutes the cloud-native platform layer.

    • A Kubernetes plugin layer for management based on Helm, including the local-path-storage plugin implementing the CSI interface, Minio, and the MatrixOne Operator.

    • The topmost layer is several Pods and Services generated by these component configurations.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#pod-and-storage-architecture-of-matrixone","title":"Pod and storage architecture of MatrixOne","text":"

    MatrixOne creates a series of Kubernetes objects according to the rules of the Operator, and these objects are classified according to components and classified into resource groups, namely CNSet, TNSet, and LogSet.

    • Service: The services in each resource group must be provided externally through the Service. Service hosts the external connection function to ensure the service can still be provided when the Pod crashes or is replaced. External applications connect through the Service's exposed ports, and the Service forwards connections to the corresponding Pods through internal forwarding rules.

    • Pod: A containerized instance of MatrixOne components in which MatrixOne's core kernel code runs.

    • PVC: Each Pod declares the storage resources it needs through PVC (Persistent Volume Claim). In our architecture, CN and TN must apply for a storage resource as a cache, and LogService requires corresponding S3 resources. These requirements are declared through PVCs.

    • PV: PV (Persistent Volume) is an abstract representation of storage media, which can be regarded as a storage unit. After applying for a PVC, create a PV through software that implements the CSI interface and binds it to the PVC used for resources.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#1-deploying-a-kubernetes-cluster","title":"1. Deploying a Kubernetes Cluster","text":"

    As MatrixOne's distributed deployment relies on a Kubernetes cluster, we need to have one in place. This article will guide you through setting up a Kubernetes cluster using Kuboard-Spray.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#preparing-the-cluster-environment","title":"Preparing the Cluster Environment","text":"

    To prepare the cluster environment, you need to do the following:

    • Have three virtual machines

    • Use CentOS 7.9 as the operating system (by default, it does allow root account remote login). Two machines will be used for deploying Kubernetes and other dependencies for MatrixOne, while the third will act as a jump host to set up the Kubernetes cluster.

    • External network access conditions. The three servers all need to pull the external network image.

    The specific distribution of the machines is shown below:

    Host Intranet IP Extranet IP mem CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#deploying-kuboard-spray-on-a-jump-server","title":"Deploying Kuboard Spray on a Jump Server","text":"

    Kuboard Spray is a tool used for visualizing the deployment of Kubernetes clusters. It uses Docker to quickly launch a web application that can visualize the deployment of a Kubernetes cluster. Once the Kubernetes cluster environment has been deployed, the Docker application can be stopped.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#preparing-the-jump-server-environment","title":"Preparing the Jump Server Environment","text":"
    1. Install Docker: A Docker environment is required. Install and start Docker on the springboard machine with the following commands:

      curl -sSL https://get.docker.io/ | sh\n#If you are in a domestic network restricted environment, you can change the following domestic mirror address\ncurl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun\n
    2. Start Docker:

      [root@VM-0-6-centos ~]# systemctl start docker\n[root@VM-0-6-centos ~]# systemctl status docker\n\u25cf docker.service - Docker Application Container Engine\n   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)\n   Active: active (running) since Sun 2023-05-07 11:48:06 CST; 15s ago\n     Docs: https://docs.docker.com\n Main PID: 5845 (dockerd)\n    Tasks: 8\n   Memory: 27.8M\n   CGroup: /system.slice/docker.service\n           \u2514\u25005845 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock\n\nMay 07 11:48:06 VM-0-6-centos systemd[1]: Starting Docker Application Container Engine...\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.391166236+08:00\" level=info msg=\"Starting up\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.421736631+08:00\" level=info msg=\"Loading containers: start.\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.531022702+08:00\" level=info msg=\"Loading containers: done.\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.544715135+08:00\" level=info msg=\"Docker daemon\" commit=94d3ad6 graphdriver= overlay2 version=23.0.5\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.544798391+08:00\" level=info msg=\"Daemon has completed initialization\"\nMay 07 11:48:06 VM-0-6-centos systemd[1]: Started Docker Application Container Engine.\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.569274215+08:00\" level=info msg=\"API listen on /run/docker. sock\"\n

    Once the environment is prepared, Kuboard Spray can be deployed.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#deploying-kuboard-spray","title":"Deploying Kuboard Spray","text":"

    Execute the following command to install Kuboard Spray:

    docker run -d \\\n  --privileged \\\n  --restart=unless-stopped \\\n  --name=kuboard-spray \\\n  -p 80:80/tcp \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -v ~/kuboard-spray-data:/data \\\n  eipwork/kuboard-spray:latest-amd64\n

    If the image pull fails due to network issues, use the backup address below:

    docker run -d \\\n  --privileged \\\n  --restart=unless-stopped \\\n  --name=kuboard-spray \\\n  -p 80:80/tcp \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -v ~/kuboard-spray-data:/data \\\n  swr.cn-east-2.myhuaweicloud.com/kuboard/kuboard-spray:latest-amd64\n

    After executing the command, open the Kuboard Spray web interface by entering http://1.13.2.100 (jump server IP address) in a web browser, then log in to the Kuboard Spray interface using the username admin and the default password Kuboard123, as shown below:

    After logging in, the Kubernetes cluster deployment can be started.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#visual-deployment-of-kubernetes-cluster","title":"Visual Deployment of Kubernetes Cluster","text":"

    After logging into the Kuboard-Spray interface, you can begin visually deploying a Kubernetes cluster.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#importing-kubernetes-related-resource-packages","title":"Importing Kubernetes-related Resource Packages","text":"

    The installation interface will download the Kubernetes cluster's corresponding resource package via online downloading to achieve offline installation of the Kubernetes cluster.

    1. Click Resource Package Management and select the appropriate version of the Kubernetes resource package to download:

      Download spray-v2.18.0b-2_k8s-v1.23.17_v1.24-amd64 \u7248\u672c

    2. Click Import > Load Resource Package, select the appropriate download source, and wait for the resource package to finish downloading.

      Note

      We recommend choosing Docker as the container engine for your K8s cluster. Once Docker is selected as the container engine for K8s, Kuboard-Spray will automatically utilize Docker to run various components of the K8s cluster, including containers on both Master and Worker nodes.

    3. This will pull the related image dependencies:

    4. After the image resource package is successfully pulled, return to the Kuboard-Spray web interface. You can see that the corresponding version of the resource package has been imported.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#installing-a-kubernetes-cluster","title":"Installing a Kubernetes Cluster","text":"

    This chapter will guide you through the installation of a Kubernetes cluster.

    1. Select Cluster Management and choose Add Cluster Installation Plan:

    2. In the pop-up dialog box, define the name of the cluster, select the version of the resource package that was just imported, and click OK, as shown in the following figure:

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#cluster-planning","title":"Cluster Planning","text":"

    Based on the predefined roles, the Kubernetes cluster is deployed with a pattern of 1 master + 1 worker + 1 etcd.

    After defining the cluster name and selecting the resource package version, click OK, and then proceed to the cluster planning stage.

    1. Select the corresponding node roles and names:

      • Master node: Select the etcd and control node and name it master0. (If you want the master node to participate in the work, you can select the worker node simultaneously. This method can improve resource utilization but will reduce the high availability of Kubernetes.)
      • Worker node: Select only the worker node and name it node0.
    2. After filling in the roles and node names for each node, please fill in the corresponding connection information on the right, as shown in the following figure:

    3. After filling in all the roles, click Save. You can now prepare to install the Kubernetes cluster.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#installing-kubernetes-cluster","title":"Installing Kubernetes Cluster","text":"

    After completing all roles and saving in the previous step, click Execute to start installing the Kubernetes cluster.

    1. Click OK as shown in the figure below to start installing the Kubernetes cluster:

    2. When installing the Kubernetes cluster, the ansible script will be executed on the corresponding node to install the Kubernetes cluster. The overall installation time will vary depending on the machine configuration and network. Generally, it takes 5 to 10 minutes.

      Note: If an error occurs, you can check the log to confirm whether the version of Kuboard-Spray is mismatched. If the version is mismatched, please replace it with a suitable version.

    3. After the installation is complete, execute kubectl get node on the master node of the Kubernetes cluster:

      [root@master0 ~]# kubectl get node\nNAME      STATUS   ROLES                  AGE   VERSION\nmaster0   Ready    control-plane,master   52m   v1.23.17\nnode0     Ready    <none>                 52m   v1.23.17\n
    4. The command result shown in the figure above indicates that the Kubernetes cluster has been successfully installed.

    5. Adjust the DNS routing table on each node in Kubernetes. Please execute the following command on each machine to find the nameserver containing 169.254.25.10 and delete the record. (This record may affect the communication efficiency between Pods, if this record does not exist, there is no need to change it)

      vim /etc/resolve.conf\n

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#2-deploying-helm","title":"2. Deploying Helm","text":"

    Helm is a package management tool for managing Kubernetes applications. Similar to APT for Ubuntu and YUM for CentOS, Helm provides a convenient way to install, upgrade, and manage Kubernetes applications. It simplifies the application deployment and management process using charts (preconfigured installation package resources).

    Before installing Minio, we need to install Helm first because the installation process of Minio depends on Helm. Here are the steps to install Helm:

    Note: All operations in this section are performed on the master0 node.

    1. Download the Helm installation package:

      wget https://get.helm.sh/helm-v3.10.2-linux-amd64.tar.gz\n#You can use the following domestic mirror address if the trained network is limited.\nwget https://mirrors.huaweicloud.com/helm/v3.10.2/helm-v3.10.2-linux-amd64.tar.gz\n
    2. Extract and install:

      tar -zxf helm-v3.10.2-linux-amd64.tar.gz\nmv linux-amd64/helm /usr/local/bin/helm\n
    3. Verify the version to check if it is installed:

      [root@k8s01 home]# helm version\nversion.BuildInfo{Version:\"v3.10.2\", GitCommit:\"50f003e5ee8704ec937a756c646870227d7c8b58\", GitTreeState:\"clean\", GoVersion:\"go1.18.8\"}\n

      The version information shown above indicates that the installation is complete.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#3-csi-deployment","title":"3. CSI Deployment","text":"

    CSI is a storage plugin for Kubernetes that provides storage services for MinIO and MatrixOne. This section will guide you through the use of the local-path-provisioner plugin.

    Note: All the commands in this section should be executed on the master0 node.

    1. Install CSI using the following command line:

      wget https://github.com/rancher/local-path-provisioner/archive/refs/tags/v0.0.23.zip\nunzip v0.0.23.zip\ncd local-path-provisioner-0.0.23/deploy/chart/local-path-provisioner\nhelm install --set nodePathMap[0].paths[0]=\"/opt/local-path-provisioner\",nodePathMap[0].node=DEFAULT_PATH_FOR_NON_LISTED_NODES  --create-namespace --namespace local-path-storage local-path-storage ./\n
    2. After a successful installation, the command line should display as follows:

      root@master0:~# kubectl get pod -n local-path-storage\nNAME                                                        READY   STATUS    RESTARTS   AGE\nlocal-path-storage-local-path-provisioner-57bf67f7c-lcb88   1/1     Running   0          89s\n

      Note: After installation, this storageClass will provide storage services in the \"/opt/local-path-provisioner\" directory on the worker node. You can modify it to another path.

    3. Set the default storageClass:

      kubectl patch storageclass local-path -p '{\"metadata\": {\"annotations\":{\"storageclass.kubernetes.io/is-default-class\":\"true\"}}}'\n
    4. After setting the default, the command line should display as follows:

      root@master0:~# kubectl get storageclass\nNAME                   PROVISIONER                                               RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE\nlocal-path (default)   cluster.local/local-path-storage-local-path-provisioner   Delete          WaitForFirstConsumer   true                   115s\n
    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#4-minio-deployment","title":"4. MinIO Deployment","text":"

    MinIO is used to provide object storage for MatrixOne. This section will guide you through the deployment of a single-node MinIO.

    Note: All the commands in this section should be executed on the master0 node.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#installation-and-startup","title":"Installation and Startup","text":"
    1. The command line for installing and starting MinIO is as follows:

      helm repo add minio https://charts.min.io/\nmkdir minio_ins && cd minio_ins\nhelm fetch minio/minio\nls -lth\ntar -zxvf minio-5.0.9.tgz # This version may change; the actual download shall prevail\ncd ./minio/\n\nkubectl create ns mostorage\n\nhelm install minio \\\n--namespace mostorage \\\n--set resources.requests.memory=512Mi \\\n--set replicas=1 \\\n--set persistence.size=10G \\\n--set mode=standalone \\\n--set rootUser=rootuser,rootPassword=rootpass123 \\\n--set consoleService.type=NodePort \\\n--set image.repository=minio/minio \\\n--set image.tag=latest \\\n--set mcImage.repository=minio/mc \\\n--set mcImage.tag=latest \\\n-f values.yaml minio/minio\n

      Note

      • --set resources.requests.memory=512Mi sets the minimum memory consumption of MinIO

        • --set persistence.size=1G sets the storage size of MinIO to 1G
        • --set rootUser=rootuser,rootPassword=rootpass123 the parameters set for rootUser and rootPassword are required for creating the secrets file for the Kubernetes cluster later, so use something that you can remember.
      • If it is repeatedly executed due to network or other reasons, it needs to be uninstalled first:

        helm uninstall minio --namespace most storage\n
    2. After a successful installation and start, the command line should display as follows:

      NAME: minio\nLAST DEPLOYED: Sun May 7 14:17:18 2023\nNAMESPACE: most storage\nSTATUS: deployed\nREVISION: 1\nTEST SUITE: None\nNOTES:\nMinIO can be accessed via port 9000 on the following DNS name from within your cluster:\nminio.mostorage.svc.cluster.local\n\nTo access MinIO from localhost, run the following commands:\n\n  1. export POD_NAME=$(kubectl get pods --namespace moststorage -l \"release=minio\" -o jsonpath=\"{.items[0].metadata.name}\")\n\n  2. kubectl port-forward $POD_NAME 9000 --namespace most storage\n\nRead more about port forwarding here: http://kubernetes.io/docs/user-guide/kubectl/kubectl_port-forward/\n\nYou can now access MinIO server on http://localhost:9000. Follow the below steps to connect to MinIO server with mc client:\n\n  1. Download the MinIO mc client - https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart\n\n  2. export MC_HOST_minio-local=http://$(kubectl get secret --namespace most storage minio -o jsonpath=\"{.data.rootUser}\" | base64 --decode):$(kubectl get secret --namespace most storage minio -o jsonpath=\"{.data.rootPassword}\" | base64 --decode)@localhost:9000\n\n  3. mc ls minio-local\n

      So far, Minio has been successfully installed. During the subsequent installation of MatrixOne, MatrixOne will communicate with Minio directly through the Kubernetes Service (SVC) without additional configuration.

      However, if you want to connect to Minio from localhost, you can execute the following command line to set the POD_NAME variable and connect mostorage to port 9000:

      export POD_NAME=$(kubectl get pods --namespace mostorage -l \"release=minio\" -o jsonpath=\"{.items[0].metadata.name}\")\nnohup kubectl port-forward --address 0.0.0.0 $POD_NAME -n mostorage 9000:9000 &\n
    3. After startup, use http://118.195.255.252:32001/ to log in to the MinIO page and create object storage information. As shown in the figure below, the account password is the rootUser and rootPassword set by --set rootUser=rootuser,rootPassword=rootpass123 in the above steps:

    4. After logging in, you need to create object storage related information:

      Fill in the Bucket Name with minio-mo under Bucket > Create Bucket. After filling it in, click the Create Bucket button at the bottom right.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#5-deploying-a-matrixone-cluster","title":"5. Deploying a MatrixOne Cluster","text":"

    This section will guide you through the process of deploying a MatrixOne cluster.

    Note: All steps in this section are performed on the master0 node.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#installing-the-matrixone-operator","title":"Installing the MatrixOne-Operator","text":"

    MatrixOne Operator is a standalone software tool for deploying and managing MatrixOne clusters on Kubernetes. You can install the latest Operator Release installation package from the project's Release List.

    Follow the steps below to install MatrixOne Operator on master0. We will create a separate namespace, matrixone-operator for the Operator.

    1. Download the latest MatrixOne Operator installation package:

      wget https://github.com/matrixorigin/matrixone-operator/releases/download/chart-0.8.0-alpha.7/matrixone-operator-0.8.0-alpha.7.tgz\n
    2. Unzip the installation package:

      tar -xvf matrixone-operator-0.8.0-alpha.7.tgz\ncd /root/matrixone-operator/\n
    3. Define the namespace variable:

      NS=\"matrixone-operator\"\n
    4. Use Helm to install MatrixOne Operator and create a namespace:

      helm install --create-namespace --namespace ${NS} matrixone-operator ./ --dependency-update\n
    5. After the installation is successful, use the following command to confirm the installation status:

      kubectl get pod -n matrixone-operator\n

      Ensure all pods have a running status in the above command output.

      [root@master0 matrixone-operator]# kubectl get pod -n matrixone-operator\nNAME                                 READY   STATUS    RESTARTS   AGE\nmatrixone-operator-f8496ff5c-fp6zm   1/1     Running   0          3m26s\n

    As shown in the above line of code, the status of the corresponding Pods is normal.

    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#create-a-matrixone-cluster","title":"Create a MatrixOne cluster","text":"
    1. First, create the namespace of MatrixOne:

      NS=\"mo-hn\"\nkubectl create ns ${NS}\n
    2. Customize the yaml file of the MatrixOne cluster, and write the following mo.yaml file:

      apiVersion: core.matrixorigin.io/v1alpha1\nkind: MatrixOneCluster\nmetadata:\n  name: mo\n  namespace: mo-hn\nspec:\n  # 1. Configuration for tn\n  Tn:\n    cacheVolume: # Disk cache for tn\n      size: 5Gi # Modify according to actual disk size and requirements\n      storageClassName: local-path # If not specified, the default storage class of the system will be used\n    resources:\n      requests:\n        cpu: 100m #1000m=1c\n        memory: 500Mi # 1024Mi\n      limits: # Note that limits should not be lower than requests and should not exceed the capacity of a single node. Generally allocate based on actual circumstances, usually set limits and requests to be consistent.\n        cpu: 200m\n        memory: 1Gi\n    config: |  # Configuration for tn\n      [dn.Txn.Storage]\n      backend = \"TAE\"\n      log-backend = \"logservice\"\n      [dn.Ckp]\n      flush-interval = \"60s\"\n      min-count = 100\n      scan-interval = \"5s\"\n      incremental-interval = \"60s\"\n      global-interval = \"100000s\"\n      [log]\n      level = \"error\"\n      format = \"json\"\n      max-size = 512\n    replicas: 1 # The number of copies of TN, which cannot be modified. The current version only supports a setting of 1.\n  # 2. Configuration for logservice\n  logService:\n    replicas: 3 # Number of logservice replicas\n    resources:\n      requests:\n        cpu: 100m #1000m=1c\n        memory: 500Mi # 1024Mi\n      limits: # Note that limits should not be lower than requests and should not exceed the capacity of a single node. Generally allocate based on actual circumstances, usually set limits and requests to be consistent.\n        cpu: 200m\n        memory: 1Gi\n    sharedStorage: # Configuration for logservice to connect to s3 storage\n      s3:\n        type: minio # Type of s3 storage to connect to is minio\n        path: minio-mo # Path to the minio bucket used by mo, previously created through the console or mc command\n        endpoint: http://minio.mostorage:9000 # The svc address and port of the minio service\n        secretRef: # Configuration for accessing minio, the secret name is minio\n          name: minio\n    pvcRetentionPolicy: Retain # Configuration for the lifecycle policy of the pvc bucket after the cluster is destroyed, Retain means to keep, Delete means to delete\n    volume:\n      size: 1Gi # Configuration for the size of S3 object storage, modify according to actual disk size and requirements\n    config: | # Configuration for logservice\n      [log]\n      level = \"error\"\n      format = \"json\"\n      max-size = 512\n  # 3. Configuration for cn\n  tp:\n    cacheVolume: # Disk cache for cn\n      size: 5Gi # Modify according to actual disk size and requirements\n      storageClassName: local-path # If not specified, the default storage class of the system will be used\n    resources:\n      requests:\n        cpu: 100m #1000m=1c\n        memory: 500Mi # 1024Mi\n      limits: # Note that limits should not be lower than requests and should not exceed the capacity of a single node. Generally allocate based on actual circumstances, usually set limits and requests to be consistent.\n        cpu: 200m\n        memory: 2Gi\n    serviceType: NodePort # cn needs to provide access entry to the outside, so its svc is set to NodePort\n    nodePort: 31429 # NodePort port setting\n    config: | # Configuration for cn\n      [cn.Engine]\n      type = \"distributed-tae\"\n      [log]\n      level = \"debug\"\n      format = \"json\"\n      max-size = 512\n    replicas: 1\n  version: nightly-54b5e8c # The version of the MO image. You can check it on Docker Hub. Generally, cn, TN, and logservice are packaged in the same image, so the same field can be used to specify it. It also supports specifying separately in each section, but unless there are special circumstances, use a unified image version.\n  # https://hub.docker.com/r/matrixorigin/matrixone/tags\n  imageRepository: matrixorigin/matrixone # Image repository address. If it is pulled locally and the tag has been modified, you can adjust this configuration item.\n  imagePullPolicy: IfNotPresent # Image pull policy, consistent with the configurable values of k8s official.\n
    3. Execute the following command to create a Secret service for accessing MinIO in the namespace mo-hn:

      kubectl -n mo-hn create secret generic minio --from-literal=AWS_ACCESS_KEY_ID=rootuser --from-literal=AWS_SECRET_ACCESS_KEY=rootpass123\n

      The username and password use the rootUser and rootPassword set when creating the MinIO cluster.

    4. Execute the following command to deploy the MatrixOne cluster:

      kubectl apply -f mo.yaml\n
    5. Please wait patiently for about 10 minutes. If the Pod restarts, please continue to wait. Until you see the following information, the deployment is successful:

      [root@master0 mo]# kubectl get pods -n mo-hn      \nNAME                                 READY   STATUS    RESTARTS      AGE\nmo-tn-0                              1/1     Running   0             74s\nmo-log-0                             1/1     Running   1 (25s ago)   2m2s\nmo-log-1                             1/1     Running   1 (24s ago)   2m2s\nmo-log-2                             1/1     Running   1 (22s ago)   2m2s\nmo-tp-cn-0                           1/1     Running   0             50s\n
    "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#6-connect-to-matrixone-cluster","title":"6. Connect to MatrixOne cluster","text":"

    To connect to the MatrixOne cluster, you need to map the port of the corresponding service to the MatrixOne node. Here are the instructions for connecting to a MatrixOne cluster using kubectl port-forward:

    • Only allow local access:
    nohup kubectl port-forward -nmo-hn svc/mo-tp-cn 6001:6001 &\n
    • Specify a specific machine or all machines to access:
    nohup kubectl port-forward -nmo-hn --address 0.0.0.0 svc/mo-tp-cn 6001:6001 &\n

    After specifying Allow local access or Specify a specific machine or all machines to access, you can use the MySQL client to connect to MatrixOne:

    # Connect to the MySQL server using the 'mysql' command line tool\n# Use 'kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}' ' to get the cluster IP address of the service in the Kubernetes cluster\n# The '-h' parameter specifies the hostname or IP address of the MySQL service\n# The '-P' parameter specifies the port number of the MySQL service, here is 6001\n# '-uroot' means log in with root user\n# '-p111' means the initial password is 111\nmysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 163\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

    After explicit mysql>, the distributed MatrixOne cluster is established and connected.

    Info

    The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

    "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/","title":"Health check and resource monitoring","text":"

    In the MatrixOne distributed cluster, there are multiple components and objects. To ensure its regular operation and troubleshooting, we must perform a series of health checks and resource monitoring.

    The health check and resource monitoring environment introduced in this document will be based on the MatrixOne Distributed Cluster Deployment environment.

    The upgraded environment introduced in this document will be based on the environment of MatrixOne Distributed Cluster Deployment.

    "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#objects-to-check","title":"Objects to check","text":"
    • Physical resource layer: including the three virtual machines' CPU, memory, and disk resources. For a mature solution to monitor these resources, see Monitoring Solution.

    • Logical resource layer: including the capacity usage of MinIO, the CPU and memory resource usage of each node and Pod of Kubernetes, the overall status of MatrixOne, and the status of each component (such as LogService, CN, TN).

    "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#resource-monitoring","title":"Resource monitoring","text":""},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#minio-capacity-usage-monitoring","title":"MinIO capacity usage monitoring","text":"

    MinIO has a management interface through which we can visually monitor its capacity usage, including the remaining space. For more information, see official documentation.

    "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#nodepod-resource-monitoring","title":"Node/Pod resource monitoring","text":"

    To determine whether the MatrixOne service needs to be scaled up or down, users often need to monitor the resources used by the Node where the MatrixOne cluster resides and the pods corresponding to the components.

    You can use the kubectl top command to complete it. For more information, see Kubernetes official website document of

    "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#node-monitoring","title":"Node Monitoring","text":"
    1. Use the following command to view the details of MatrixOne cluster nodes:

      kubectl get node\n
      [root@master0 ~]# kubectl get node\nNAME      STATUS   ROLES                  AGE   VERSION\nmaster0   Ready    control-plane,master   22h   v1.23.17\nnode0     Ready    <none>                 22h   v1.23.17\n
    2. According to the above-returned results, use the following command to view the resource usage of a specific node. According to the previous deployment scheme, it can be seen that the MatrixOne cluster is located on the node named node0:

      NODE=\"[node to be monitored]\" # According to the above results, it may be IP, hostname, or alias, such as 10.0.0.1, host-10-0-0-1, node01\nkubectl top node ${NODE}\n
      [root@master0 ~]# kubectl top node\nNAME      CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   \nmaster0   179m         9%     4632Mi          66%       \nnode0     292m         15%    4115Mi          56%  \n[root@master0 ~]# kubectl top node node0\nNAME    CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   \nnode0   299m         15%    4079Mi          56%  \n
    3. You can also view the node's resource allocation and upper limit. Note that allocated resources are not equal to used resources.

    [root@master0 ~]# kubectl describe node node0\nName:               master0\nRoles:              control-plane,master\nLabels:             beta.kubernetes.io/arch=amd64\n                    beta.kubernetes.io/os=linux\n                    kubernetes.io/arch=amd64\n                    kubernetes.io/hostname=master0\n                    kubernetes.io/os=linux\n                    node-role.kubernetes.io/control-plane=\n                    node-role.kubernetes.io/master=\n                    node.kubernetes.io/exclude-from-external-load-balancers=\nAnnotations:        kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock\n                    node.alpha.kubernetes.io/ttl: 0\n                    projectcalico.org/IPv4Address: 10.206.134.8/24\n                    projectcalico.org/IPv4VXLANTunnelAddr: 10.234.166.0\n                    volumes.kubernetes.io/controller-managed-attach-detach: true\nCreationTimestamp:  Sun, 07 May 2023 12:28:57 +0800\nTaints:             node-role.kubernetes.io/master:NoSchedule\nUnschedulable:      false\nLease:\n  HolderIdentity:  master0\n  AcquireTime:     <unset>\n  RenewTime:       Mon, 08 May 2023 10:56:08 +0800\nConditions:\n  Type                 Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message\n  ----                 ------  -----------------                 ------------------                ------                       -------\n  NetworkUnavailable   False   Sun, 07 May 2023 12:30:08 +0800   Sun, 07 May 2023 12:30:08 +0800   CalicoIsUp                   Calico is running on this node\n  MemoryPressure       False   Mon, 08 May 2023 10:56:07 +0800   Sun, 07 May 2023 12:28:55 +0800   KubeletHasSufficientMemory   kubelet has sufficient memory available\n  DiskPressure         False   Mon, 08 May 2023 10:56:07 +0800   Sun, 07 May 2023 12:28:55 +0800   KubeletHasNoDiskPressure     kubelet has no disk pressure\n  PIDPressure          False   Mon, 08 May 2023 10:56:07 +0800   Sun, 07 May 2023 12:28:55 +0800   KubeletHasSufficientPID      kubelet has sufficient PID available\n  Ready                True    Mon, 08 May 2023 10:56:07 +0800   Sun, 07 May 2023 20:47:39 +0800   KubeletReady                 kubelet is posting ready status\nAddresses:\n  InternalIP:  10.206.134.8\n  Hostname:    master0\nCapacity:\n  cpu:                2\n  ephemeral-storage:  51473868Ki\n  hugepages-1Gi:      0\n  hugepages-2Mi:      0\n  memory:             7782436Ki\n  pods:               110\nAllocatable:\n  cpu:                1800m\n  ephemeral-storage:  47438316671\n  hugepages-1Gi:      0\n  hugepages-2Mi:      0\n  memory:             7155748Ki\n  pods:               110\nSystem Info:\n  Machine ID:                 fb436be013b5415799d27abf653585d3\n  System UUID:                FB436BE0-13B5-4157-99D2-7ABF653585D3\n  Boot ID:                    552bd576-56c8-4d22-9549-d950069a5a77\n  Kernel Version:             3.10.0-1160.88.1.el7.x86_64\n  OS Image:                   CentOS Linux 7 (Core)\n  Operating System:           linux\n  Architecture:               amd64\n  Container Runtime Version:  docker://20.10.23\n  Kubelet Version:            v1.23.17\n  Kube-Proxy Version:         v1.23.17\nPodCIDR:                      10.234.0.0/23\nPodCIDRs:                     10.234.0.0/23\nNon-terminated Pods:          (12 in total)\n  Namespace                   Name                               CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age\n  ---------                   ----                               ------------  ----------  ---------------  -------------  ---\n  default                     netchecker-agent-7xnwb             15m (0%)      30m (1%)    64M (0%)         100M (1%)      22h\n  default                     netchecker-agent-hostnet-bw85f     15m (0%)      30m (1%)    64M (0%)         100M (1%)      22h\n  kruise-system               kruise-daemon-xvl8t                0 (0%)        50m (2%)    0 (0%)           128Mi (1%)     20h\n  kube-system                 calico-node-sbzfc                  150m (8%)     300m (16%)  64M (0%)         500M (6%)      22h\n  kube-system                 dns-autoscaler-7874cf6bcf-l55q4    20m (1%)      0 (0%)      10Mi (0%)        0 (0%)         22h\n  kube-system                 kube-apiserver-master0             250m (13%)    0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 kube-controller-manager-master0    200m (11%)    0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 kube-proxy-lfkhk                   0 (0%)        0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 kube-scheduler-master0             100m (5%)     0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 metrics-server-7bd47f88c4-knh9b    100m (5%)     100m (5%)   200Mi (2%)       200Mi (2%)     22h\n  kube-system                 nodelocaldns-dcffl                 100m (5%)     0 (0%)      70Mi (1%)        170Mi (2%)     14h\n  kuboard                     kuboard-v3-master0                 0 (0%)        0 (0%)      0 (0%)           0 (0%)         22h\nAllocated resources:\n  (Total limits may be over 100 percent, i.e., overcommitted.)\n  Resource           Requests        Limits\n  --------           --------        ------\n  cpu                950m (52%)      510m (28%)\n  memory             485601280 (6%)  1222190848 (16%)\n  ephemeral-storage  0 (0%)          0 (0%)\n  hugepages-1Gi      0 (0%)          0 (0%)\n  hugepages-2Mi      0 (0%)          0 (0%)\nEvents:              <none>\n\n\nName:               node0\nRoles:              <none>\nLabels:             beta.kubernetes.io/arch=amd64\n                    beta.kubernetes.io/os=linux\n                    kubernetes.io/arch=amd64\n                    kubernetes.io/hostname=node0\n                    kubernetes.io/os=linux\nAnnotations:        kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock\n                    node.alpha.kubernetes.io/ttl: 0\n                    projectcalico.org/IPv4Address: 10.206.134.14/24\n                    projectcalico.org/IPv4VXLANTunnelAddr: 10.234.60.0\n                    volumes.kubernetes.io/controller-managed-attach-detach: true\nCreationTimestamp:  Sun, 07 May 2023 12:29:46 +0800\nTaints:             <none>\nUnschedulable:      false\nLease:\n  HolderIdentity:  node0\n  AcquireTime:     <unset>\n  RenewTime:       Mon, 08 May 2023 10:56:06 +0800\nConditions:\n  Type                 Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message\n  ----                 ------  -----------------                 ------------------                ------                       -------\n  NetworkUnavailable   False   Sun, 07 May 2023 12:30:08 +0800   Sun, 07 May 2023 12:30:08 +0800   CalicoIsUp                   Calico is running on this node\n  MemoryPressure       False   Mon, 08 May 2023 10:56:12 +0800   Sun, 07 May 2023 12:29:46 +0800   KubeletHasSufficientMemory   kubelet has sufficient memory available\n  DiskPressure         False   Mon, 08 May 2023 10:56:12 +0800   Sun, 07 May 2023 12:29:46 +0800   KubeletHasNoDiskPressure     kubelet has no disk pressure\n  PIDPressure          False   Mon, 08 May 2023 10:56:12 +0800   Sun, 07 May 2023 12:29:46 +0800   KubeletHasSufficientPID      kubelet has sufficient PID available\n  Ready                True    Mon, 08 May 2023 10:56:12 +0800   Sun, 07 May 2023 20:48:36 +0800   KubeletReady                 kubelet is posting ready status\nAddresses:\n  InternalIP:  10.206.134.14\n  Hostname:    node0\nCapacity:\n  cpu:                2\n  ephemeral-storage:  51473868Ki\n  hugepages-1Gi:      0\n  hugepages-2Mi:      0\n  memory:             7782444Ki\n  pods:               110\nAllocatable:\n  cpu:                1900m\n  ephemeral-storage:  47438316671\n  hugepages-1Gi:      0\n  hugepages-2Mi:      0\n  memory:             7417900Ki\n  pods:               110\nSystem Info:\n  Machine ID:                 a6600151884b44fb9f0bc9af490e44b7\n  System UUID:                A6600151-884B-44FB-9F0B-C9AF490E44B7\n  Boot ID:                    b7f3357f-44e6-425e-8c90-6ada14e92703\n  Kernel Version:             3.10.0-1160.88.1.el7.x86_64\n  OS Image:                   CentOS Linux 7 (Core)\n  Operating System:           linux\n  Architecture:               amd64\n  Container Runtime Version:  docker://20.10.23\n  Kubelet Version:            v1.23.17\n  Kube-Proxy Version:         v1.23.17\nPodCIDR:                      10.234.2.0/23\nPodCIDRs:                     10.234.2.0/23\nNon-terminated Pods:          (20 in total)\n  Namespace                   Name                                                         CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age\n  ---------                   ----                                                         ------------  ----------  ---------------  -------------  ---\n  default                     netchecker-agent-6v8rl                                       15m (0%)      30m (1%)    64M (0%)         100M (1%)      22h\n  default                     netchecker-agent-hostnet-fb2jn                               15m (0%)      30m (1%)    64M (0%)         100M (1%)      22h\n  default                     netchecker-server-645d759b79-v4bqm                           150m (7%)     300m (15%)  192M (2%)        512M (6%)      22h\n  kruise-system               kruise-controller-manager-74847d59cf-295rk                   100m (5%)     200m (10%)  256Mi (3%)       512Mi (7%)     20h\n  kruise-system               kruise-controller-manager-74847d59cf-854sq                   100m (5%)     200m (10%)  256Mi (3%)       512Mi (7%)     20h\n  kruise-system               kruise-daemon-rz9pj                                          0 (0%)        50m (2%)    0 (0%)           128Mi (1%)     20h\n  kube-system                 calico-kube-controllers-74df5cd99c-n9qsn                     30m (1%)      1 (52%)     64M (0%)         256M (3%)      22h\n  kube-system                 calico-node-brqrk                                            150m (7%)     300m (15%)  64M (0%)         500M (6%)      22h\n  kube-system                 coredns-76b4fb4578-9cqc7                                     100m (5%)     0 (0%)      70Mi (0%)        170Mi (2%)     14h\n  kube-system                 kube-proxy-rpxb5                                             0 (0%)        0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 nginx-proxy-node0                                            25m (1%)      0 (0%)      32M (0%)         0 (0%)         22h\n  kube-system                 nodelocaldns-qkxhv                                           100m (5%)     0 (0%)      70Mi (0%)        170Mi (2%)     14h\n  local-path-storage          local-path-storage-local-path-provisioner-d5bb7f8c9-qfp8h    0 (0%)        0 (0%)      0 (0%)           0 (0%)         21h\n  mo-hn                       matrixone-operator-f8496ff5c-fp6zm                           0 (0%)        0 (0%)      0 (0%)           0 (0%)         20h\n  mo-hn                       mo-tn-0                                                      0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mo-hn                       mo-log-0                                                     0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mo-hn                       mo-log-1                                                     0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mo-hn                       mo-log-2                                                     0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mo-hn                       mo-tp-cn-0                                                   0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mostorage                   minio-674ccf54f7-tdglh                                       0 (0%)        0 (0%)      512Mi (7%)       0 (0%)         20h\nAllocated resources:\n  (Total limits may be over 100 percent, i.e., overcommitted.)\n  Resource           Requests          Limits\n  --------           --------          ------\n  cpu                785m (41%)        2110m (111%)\n  memory             1700542464 (22%)  3032475392 (39%)\n  ephemeral-storage  0 (0%)            0 (0%)\n  hugepages-1Gi      0 (0%)            0 (0%)\n  hugepages-2Mi      0 (0%)            0 (0%)\nEvents:              <none>\n
    "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#pod-monitoring","title":"Pod Monitoring","text":"
    1. Use the following command to view the Pods of the MatrixOne cluster:

      NS=\"mo-hn\"\nkubectl get pod -n ${NS}\n
    2. According to the above-returned results, use the following command to view the resource usage of a specific Pod:

      POD=\"[pod name to be monitored]\" # According to the above results, for example: TN is mo-tn-0, cn is mo-tp-cn-0, mo-tp-cn-1, ..., logservice is mo -log-0, mo-log-1, ...\nkubectl top pod ${POD} -n ${NS}\n

      The command will display the CPU and memory usage for the specified Pod, similar to the following output:

      [root@master0 ~]# kubectl top pod mo-tp-cn-0 -nmo-hn\nNAME         CPU(cores)   MEMORY(bytes)   \nmo-tp-cn-0   20m          214Mi\n[root@master0 ~]# kubectl top pod mo-tn-0 -nmo-hn     \nNAME      CPU(cores)   MEMORY(bytes)   \nmo-tn-0   36m          161Mi  \n
    3. you can also view the resource declaration of a specific Pod to compare it with the actual resource usage.

    kubectl describe pod ${POD_NAME} -n${NS}\nkubectl get pod ${POD_NAME} -n${NS} -oyaml\n
    [root@master0 ~]# kubectl describe pod mo-tp-cn-0 -nmo-hn\nName:         mo-tp-cn-0\nNamespace:    mo-hn\nPriority:     0\nNode:         node0/10.206.134.14\nStart Time:   Sun, 07 May 2023 21:01:50 +0800\nLabels:       controller-revision-hash=mo-tp-cn-8666cdfb56\n              lifecycle.apps.kruise.io/state=Normal\n              matrixorigin.io/cluster=mo\n              matrixorigin.io/component=CNSet\n              matrixorigin.io/instance=mo-tp\n              matrixorigin.io/namespace=mo-hn\n              statefulset.kubernetes.io/pod-name=mo-tp-cn-0\nAnnotations:  apps.kruise.io/runtime-containers-meta:\n                {\"containers\":[{\"name\":\"main\",\"containerID\":\"docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\",\"restartCount\":0,\"...\n              cni.projectcalico.org/containerID: 80b286789a2d6fa9e615c3edee79b57edb452eaeafddb9b7b82ec5fb2e339409\n              cni.projectcalico.org/podIP: 10.234.60.53/32\n              cni.projectcalico.org/podIPs: 10.234.60.53/32\n              kruise.io/related-pub: mo\n              lifecycle.apps.kruise.io/timestamp: 2023-05-07T13:01:50Z\n              matrixone.cloud/cn-label: null\n              matrixone.cloud/dns-based-identity: False\nStatus:       Running\nIP:           10.234.60.53\nIPs:\n  IP:           10.234.60.53\nControlled By:  StatefulSet/mo-tp-cn\nContainers:\n  main:\n    Container ID:  docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\n    Image:         matrixorigin/matrixone:nightly-144f3be4\n    Image ID:      docker-pullable://matrixorigin/matrixone@sha256:288fe3d626c6aa564684099e4686a9d4b28e16fdd16512bd968a67bb41d5aaa3\n    Port:          <none>\n    Host Port:     <none>\n    Command:\n      /bin/sh\n      /etc/matrixone/config/start.sh\n    Args:\n      -debug-http=:6060\n    State:          Running\n      Started:      Sun, 07 May 2023 21:01:54 +0800\n    Ready:          True\n    Restart Count:  0\n    Environment:\n      POD_NAME:               mo-tp-cn-0 (v1:metadata.name)\n      NAMESPACE:              mo-hn (v1:metadata.namespace)\n      HEADLESS_SERVICE_NAME:  mo-tp-cn-headless\n      AWS_ACCESS_KEY_ID:      <set to the key 'AWS_ACCESS_KEY_ID' in secret 'minio'>      Optional: false\n      AWS_SECRET_ACCESS_KEY:  <set to the key 'AWS_SECRET_ACCESS_KEY' in secret 'minio'>  Optional: false\n      AWS_REGION:             us-west-2\n    Mounts:\n      /etc/matrixone/config from config (ro)\n      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-ngpcs (ro)\nReadiness Gates:\n  Type                 Status\n  InPlaceUpdateReady   True\n  KruisePodReady       True\nConditions:\n  Type                 Status\n  KruisePodReady       True\n  InPlaceUpdateReady   True\n  Initialized          True\n  Ready                True\n  ContainersReady      True\n  PodScheduled         True\nVolumes:\n  config:\n    Type:      ConfigMap (a volume populated by a ConfigMap)\n    Name:      mo-tp-cn-config-5abf454\n    Optional:  false\n  kube-api-access-ngpcs:\n    Type:                    Projected (a volume that contains injected data from multiple sources)\n    TokenExpirationSeconds:  3607\n    ConfigMapName:           kube-root-ca.crt\n    ConfigMapOptional:       <nil>\n    DownwardAPI:             true\nQoS Class:                   BestEffort\nNode-Selectors:              <none>\nTolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s\n                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s\nEvents:                      <none>\n[root@master0 ~]# kubectl get pod  mo-tp-cn-0 -nmo-hn -oyaml\napiVersion: v1\nkind: Pod\nmetadata:\n  annotations:\n    apps.kruise.io/runtime-containers-meta: '{\"containers\":[{\"name\":\"main\",\"containerID\":\"docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\",\"restartCount\":0,\"hashes\":{\"plainHash\":1670287891}}]}'\n    cni.projectcalico.org/containerID: 80b286789a2d6fa9e615c3edee79b57edb452eaeafddb9b7b82ec5fb2e339409\n    cni.projectcalico.org/podIP: 10.234.60.53/32\n    cni.projectcalico.org/podIPs: 10.234.60.53/32\n    kruise.io/related-pub: mo\n    lifecycle.apps.kruise.io/timestamp: \"2023-05-07T13:01:50Z\"\n    matrixone.cloud/cn-label: \"null\"\n    matrixone.cloud/dns-based-identity: \"False\"\n  creationTimestamp: \"2023-05-07T13:01:50Z\"\n  generateName: mo-tp-cn-\n  labels:\n    controller-revision-hash: mo-tp-cn-8666cdfb56\n    lifecycle.apps.kruise.io/state: Normal\n    matrixorigin.io/cluster: mo\n    matrixorigin.io/component: CNSet\n    matrixorigin.io/instance: mo-tp\n    matrixorigin.io/namespace: mo-hn\n    statefulset.kubernetes.io/pod-name: mo-tp-cn-0\n  name: mo-tp-cn-0\n  namespace: mo-hn\n  ownerReferences:\n  - apiVersion: apps.kruise.io/v1beta1\n    blockOwnerDeletion: true\n    controller: true\n    kind: StatefulSet\n    name: mo-tp-cn\n    uid: 891e0453-89a5-45d5-ad12-16ef048c804f\n  resourceVersion: \"72625\"\n  uid: 1e3e2df3-f1c2-4444-8694-8d23e7125d35\nspec:\n  containers:\n  - args:\n    - -debug-http=:6060\n    command:\n    - /bin/sh\n    - /etc/matrixone/config/start.sh\n    env:\n    - name: POD_NAME\n      valueFrom:\n        fieldRef:\n          apiVersion: v1\n          fieldPath: metadata.name\n    - name: NAMESPACE\n      valueFrom:\n        fieldRef:\n          apiVersion: v1\n          fieldPath: metadata.namespace\n    - name: HEADLESS_SERVICE_NAME\n      value: mo-tp-cn-headless\n    - name: AWS_ACCESS_KEY_ID\n      valueFrom:\n        secretKeyRef:\n          key: AWS_ACCESS_KEY_ID\n          name: minio\n    - name: AWS_SECRET_ACCESS_KEY\n      valueFrom:\n        secretKeyRef:\n          key: AWS_SECRET_ACCESS_KEY\n          name: minio\n    - name: AWS_REGION\n      value: us-west-2\n    image: matrixorigin/matrixone:nightly-144f3be4\n    imagePullPolicy: Always\n    name: main\n    resources: {}\n    terminationMessagePath: /dev/termination-log\n    terminationMessagePolicy: File\n    volumeMounts:\n    - mountPath: /etc/matrixone/config\n      name: config\n      readOnly: true\n    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount\n      name: kube-api-access-ngpcs\n      readOnly: true\n  dnsPolicy: ClusterFirst\n  enableServiceLinks: true\n  hostname: mo-tp-cn-0\n  nodeName: node0\n  preemptionPolicy: PreemptLowerPriority\n  priority: 0\n  readinessGates:\n  - conditionType: InPlaceUpdateReady\n  - conditionType: KruisePodReady\n  restartPolicy: Always\n  schedulerName: default-scheduler\n  securityContext: {}\n  serviceAccount: default\n  serviceAccountName: default\n  subdomain: mo-tp-cn-headless\n  terminationGracePeriodSeconds: 30\n  tolerations:\n  - effect: NoExecute\n    key: node.kubernetes.io/not-ready\n    operator: Exists\n    tolerationSeconds: 300\n  - effect: NoExecute\n    key: node.kubernetes.io/unreachable\n    operator: Exists\n    tolerationSeconds: 300\n  volumes:\n  - configMap:\n      defaultMode: 420\n      name: mo-tp-cn-config-5abf454\n    name: config\n  - name: kube-api-access-ngpcs\n    projected:\n      defaultMode: 420\n      sources:\n      - serviceAccountToken:\n          expirationSeconds: 3607\n          path: token\n      - configMap:\n          items:\n          - key: ca.crt\n            path: ca.crt\n          name: kube-root-ca.crt\n      - downwardAPI:\n          items:\n          - fieldRef:\n              apiVersion: v1\n              fieldPath: metadata.namespace\n            path: namespace\nstatus:\n  conditions:\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:50Z\"\n    status: \"True\"\n    type: KruisePodReady\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:50Z\"\n    status: \"True\"\n    type: InPlaceUpdateReady\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:50Z\"\n    status: \"True\"\n    type: Initialized\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:54Z\"\n    status: \"True\"\n    type: Ready\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:54Z\"\n    status: \"True\"\n    type: ContainersReady\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:50Z\"\n    status: \"True\"\n    type: PodScheduled\n  containerStatuses:\n  - containerID: docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\n    image: matrixorigin/matrixone:nightly-144f3be4\n    imageID: docker-pullable://matrixorigin/matrixone@sha256:288fe3d626c6aa564684099e4686a9d4b28e16fdd16512bd968a67bb41d5aaa3\n    lastState: {}\n    name: main\n    ready: true\n    restartCount: 0\n    started: true\n    state:\n      running:\n        startedAt: \"2023-05-07T13:01:54Z\"\n  hostIP: 10.206.134.14\n  phase: Running\n  podIP: 10.234.60.53\n  podIPs:\n  - ip: 10.234.60.53\n  qosClass: BestEffort\n  startTime: \"2023-05-07T13:01:50Z\"\n
    "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#matrixone-monitoring","title":"MatrixOne Monitoring","text":""},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#view-cluster-status","title":"View cluster status","text":"

    During Operator deployment, we defined matrixOnecluster as the custom resource name for the entire cluster. By checking MatrixOneCluster, we can tell if the cluster is functioning correctly. You can check with the following command:

    MO_NAME=\"mo\"\nNS=\"mo-hn\"\nkubectl get matrixonecluster -n ${NS} ${MO_NAME}\n

    If the status is \"Ready\", the cluster is healthy. If the status is \"NotReady\", further troubleshooting is required.

    [root@master0 ~]# MO_NAME=\"mo\"\n[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get matrixonecluster -n${NS} ${MO_NAME}\nNAME   LOG   TN    TP    AP    VERSION            PHASE   AGE\nmo     3     1     1           nightly-144f3be4   Ready   13h\n

    To view details of the MatrixOne cluster status, you can run the following command:

    kubectl describe matrixonecluster -n${NS} ${MO_NAME}\n
    [root@master0 ~]# kubectl describe matrixonecluster -n${NS} ${MO_NAME}\nName:         mo\nNamespace:    mo-hn\nLabels:       <none>\nAnnotations:  <none>\nAPI Version:  core.matrixorigin.io/v1alpha1\nKind:         MatrixOneCluster\nMetadata:\n  Creation Timestamp:  2023-05-07T12:54:17Z\n  Finalizers:\n    matrixorigin.io/matrixonecluster\n  Generation:  2\n  Managed Fields:\n    API Version:  core.matrixorigin.io/v1alpha1\n    Fields Type:  FieldsV1\n    fieldsV1:\n      f:metadata:\n        f:annotations:\n          .:\n          f:kubectl.kubernetes.io/last-applied-configuration:\n      f:spec:\n        .:\n        f:Tn:\n          .:\n          f:config:\n          f:replicas:\n        f:imagePullPolicy:\n        f:imageRepository:\n        f:logService:\n          .:\n          f:config:\n          f:pvcRetentionPolicy:\n          f:replicas:\n          f:sharedStorage:\n            .:\n            f:s3:\n              .:\n              f:endpoint:\n              f:secretRef:\n              f:type:\n          f:volume:\n            .:\n            f:size:\n        f:tp:\n          .:\n          f:config:\n          f:nodePort:\n          f:replicas:\n          f:serviceType:\n        f:version:\n    Manager:      kubectl-client-side-apply\n    Operation:    Update\n    Time:         2023-05-07T12:54:17Z\n    API Version:  core.matrixorigin.io/v1alpha1\n    Fields Type:  FieldsV1\n    fieldsV1:\n      f:metadata:\n        f:finalizers:\n          .:\n          v:\"matrixorigin.io/matrixonecluster\":\n    Manager:      manager\n    Operation:    Update\n    Time:         2023-05-07T12:54:17Z\n    API Version:  core.matrixorigin.io/v1alpha1\n    Fields Type:  FieldsV1\n    fieldsV1:\n      f:spec:\n        f:logService:\n          f:sharedStorage:\n            f:s3:\n              f:path:\n    Manager:      kubectl-edit\n    Operation:    Update\n    Time:         2023-05-07T13:00:53Z\n    API Version:  core.matrixorigin.io/v1alpha1\n    Fields Type:  FieldsV1\n    fieldsV1:\n      f:status:\n        .:\n        f:cnGroups:\n          .:\n          f:desiredGroups:\n          f:readyGroups:\n          f:syncedGroups:\n        f:conditions:\n        f:credentialRef:\n        f:Tn:\n          .:\n          f:availableStores:\n          f:conditions:\n        f:logService:\n          .:\n          f:availableStores:\n          f:conditions:\n          f:discovery:\n            .:\n            f:address:\n            f:port:\n        f:phase:\n    Manager:         manager\n    Operation:       Update\n    Subresource:     status\n    Time:            2023-05-07T13:02:12Z\n  Resource Version:  72671\n  UID:               be2355c0-0c69-4f0f-95bb-9310224200b6\nSpec:\n  Tn:\n    Config:  \n[dn]\n\n[dn.Ckp]\nflush-interval = \"60s\"\nglobal-interval = \"100000s\"\nincremental-interval = \"60s\"\nmin-count = 100\nscan-interval = \"5s\"\n\n[dn.Txn]\n\n[dn.Txn.Storage]\nbackend = \"TAE\"\nlog-backend = \"logservice\"\n\n[log]\nformat = \"json\"\nlevel = \"error\"\nmax-size = 512\n\n    Replicas:  1\n    Resources:\n    Service Args:\n      -debug-http=:6060\n    Shared Storage Cache:\n      Memory Cache Size:  0\n  Image Pull Policy:      Always\n  Image Repository:       matrixorigin/matrixone\n  Log Service:\n    Config:  \n[log]\nformat = \"json\"\nlevel = \"error\"\nmax-size = 512\n\n    Initial Config:\n      TN Shards:           1\n      Log Shard Replicas:  3\n      Log Shards:          1\n    Pvc Retention Policy:  Retain\n    Replicas:              3\n    Resources:\n    Service Args:\n      -debug-http=:6060\n    Shared Storage:\n      s3:\n        Endpoint:           http://minio.mostorage:9000\n        Path:               minio-mo\n        s3RetentionPolicy:  Retain\n        Secret Ref:\n          Name:             minio\n        Type:               minio\n    Store Failure Timeout:  10m0s\n    Volume:\n      Size:  1Gi\n  Tp:\n    Config:  \n[cn]\n\n[cn.Engine]\ntype = \"distributed-tae\"\n\n[log]\nformat = \"json\"\nlevel = \"debug\"\nmax-size = 512\n\n    Node Port:  31474\n    Replicas:   1\n    Resources:\n    Service Args:\n      -debug-http=:6060\n    Service Type:  NodePort\n    Shared Storage Cache:\n      Memory Cache Size:  0\n  Version:                nightly-144f3be4\nStatus:\n  Cn Groups:\n    Desired Groups:  1\n    Ready Groups:    1\n    Synced Groups:   1\n  Conditions:\n    Last Transition Time:  2023-05-07T13:02:14Z\n    Message:               the object is synced\n    Reason:                empty\n    Status:                True\n    Type:                  Synced\n    Last Transition Time:  2023-05-07T13:02:14Z\n    Message:               \n    Reason:                AllSetsReady\n    Status:                True\n    Type:                  Ready\n  Credential Ref:\n    Name:  mo-credential\n  Tn:\n    Available Stores:\n      Last Transition:  2023-05-07T13:01:48Z\n      Phase:            Up\n      Pod Name:         mo-tn-0\n    Conditions:\n      Last Transition Time:  2023-05-07T13:01:48Z\n      Message:               the object is synced\n      Reason:                empty\n      Status:                True\n      Type:                  Synced\n      Last Transition Time:  2023-05-07T13:01:48Z\n      Message:               \n      Reason:                empty\n      Status:                True\n      Type:                  Ready\n  Log Service:\n    Available Stores:\n      Last Transition:  2023-05-07T13:01:25Z\n      Phase:            Up\n      Pod Name:         mo-log-0\n      Last Transition:  2023-05-07T13:01:25Z\n      Phase:            Up\n      Pod Name:         mo-log-1\n      Last Transition:  2023-05-07T13:01:25Z\n      Phase:            Up\n      Pod Name:         mo-log-2\n    Conditions:\n      Last Transition Time:  2023-05-07T13:01:25Z\n      Message:               the object is synced\n      Reason:                empty\n      Status:                True\n      Type:                  Synced\n      Last Transition Time:  2023-05-07T13:01:25Z\n      Message:               \n      Reason:                empty\n      Status:                True\n      Type:                  Ready\n    Discovery:\n      Address:  mo-log-discovery.mo-hn.svc\n      Port:     32001\n  Phase:        Ready\nEvents:\n  Type    Reason            Age                From              Message\n  ----    ------            ----               ----              -------\n  Normal  ReconcileSuccess  29m (x2 over 13h)  matrixonecluster  object is synced\n
    "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#view-component-status","title":"View component status","text":"

    The current MatrixOne cluster includes the following components: TN, CN, and Log Service, which correspond to the custom resource types TNSet, CNSet, and LogSet, respectively, and these objects are generated by the MatrixOneCluster controller.

    To check whether each component is standard, take TN as an example; you can run the following command:

    SET_TYPE=\"tnset\"\nNS=\"mo-hn\"\nkubectl get ${SET_TYPE} -n ${NS}\n

    This will display status information for the TN component as follows:

    [root@master0 ~]# SET_TYPE=\"tnset\"\n[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME   IMAGE                                     REPLICAS   AGE\nmo     matrixorigin/matrixone:nightly-144f3be4   1          13h\n[root@master0 ~]# SET_TYPE=\"cnset\"\n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME    IMAGE                                     REPLICAS   AGE\nmo-tp   matrixorigin/matrixone:nightly-144f3be4   1          13h\n[root@master0 ~]# SET_TYPE=\"logset\"                 \n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME   IMAGE                                     REPLICAS   AGE\nmo     matrixorigin/matrixone:nightly-144f3be4   3          13h\n
    "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#view-pod-status","title":"View Pod Status","text":"

    In addition, you can directly check the native k8s objects generated in the MO cluster to confirm the cluster's health, usually by querying the pod.

    NS=\"mo-hn\"\nkubectl get pod -n ${NS}\n

    This will display status information for the Pod.

    [root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get pod -n${NS}\nNAME                                 READY   STATUS    RESTARTS   AGE\nmatrixone-operator-f8496ff5c-fp6zm   1/1     Running   0          19h\nmo-tn-0                              1/1     Running   0          13h\nmo-log-0                             1/1     Running   0          13h\nmo-log-1                             1/1     Running   0          13h\nmo-log-2                             1/1     Running   0          13h\nmo-tp-cn-0                           1/1     Running   0          13h\n

    Typically, the Running state indicates that the Pod is functioning normally. But there are also some special cases where the Pod status may be Running, but the MatrixOne cluster is abnormal. For example, connecting to a MatrixOne cluster through a MySQL client is impossible. In this case, you can look further into the Pod's logs to check for unusual output.

    NS=\"mo-hn\"\nPOD_NAME=\"[the name of the pod returned above]\" # For example, mo-tp-cn-0\nkubectl logs ${POD_NAME} -n ${NS}\n

    If the Pod status is not Running, such as Pending, you can check the Pod events (Events) to confirm the cause of the exception. Taking the previous example, because the cluster resources cannot satisfy the request of mo-tp-cn-3, the Pod cannot be scheduled and is Pending. In this case, you can solve it by expanding node resources.

    kubectl describe pod ${POD_NAME} -n${NS}\n

    "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/","title":"Import data from local Minio to MatrixOne","text":"

    In a distributed MatrixOne cluster, in addition to importing data locally and from public cloud object storage to MatrixOne, data can be imported through the local Minio component. This method is also feasible to import data to MatrixOne if there is no public network access or the imported file is too large to exceed the local disk space.

    This article will guide you on importing CSV files using local Minio. And the environment introduced in this document will be based on MatrixOne Distributed Cluster Deployment; ensure the entire MatrixOne has been installed.

    "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#steps","title":"steps","text":""},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#import-data","title":"Import Data","text":"

    You can log in to the Minio GUI by visiting http://192.168.56.10:32001. For the account and password, refer the rootUser and rootPassword created during the installation and deployment of Minio in MatrixOne Distributed Cluster Deployment. After logging in, you need to create a dedicated bucket load-from-minio, and upload the corresponding CSV file into the bucket.

    The example we use here is a simple addresses.csv example containing only 6 rows of data.

    "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#get-minios-endpoint","title":"Get Minio's Endpoint","text":"

    The principle of loading data from local Minio to MatrixOne cluster is the same as Import the data from S3 Compatible object storage are precisely the same, and their grammatical structure is the same. However, the public cloud vendor will give the parameters in the public cloud method, while the parameters in the local Minio need to be set by yourself.

    LOAD DATA\n    | URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"role_arn\"='xxxx', \"external_id\"='yyy', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>', \"provider\"='<string>'}\n    INTO TABLE tbl_name\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY 'string']\n        [[OPTIONALLY] ENCLOSED BY 'char']\n        [ESCAPED BY 'char']\n    ]\n    [IGNORE number {LINES | ROWS}]\n    [PARALLEL {'TRUE' | 'FALSE'}]\n

    To load data from the local Minio, you first need to find the Minio endpoint. Before the actual operation, let's understand the architecture of the entire call link.

    "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#minio-access-architecture","title":"Minio Access Architecture","text":"

    Logically speaking, MatrixOne communicates with Minio through Minio's access port endpoint and obtains data from it, as shown in the following figure:

    Minio is managed in Kubernetes (K8s), and external services must be accessed through the Service (SVC) of K8s. The actual execution of tasks is done in K8s Pods. SVC can ensure that the same port is always maintained for external applications no matter how the Pod changes. The association between SVC and Pod needs to establish rules through the Endpoint (EP) in K8s. Therefore, MatrixOne is connected to the Minio service through SVC and the specific architecture is shown in the following figure:

    "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#actual-command","title":"Actual command","text":"

    When we installed Minio, we created a namespace named mostorage. We can find this endpoint through the following K8s commands.

    • kubectl get svc -n ${ns}: List all SVCs under this namespace.
    • kubectl get pod -n${ns}: List all Pods under this namespace.
    • kubectl get ep -n ${ns}: List all forwarding rule relationships under this namespace.

    Examples are as follows:

    root@VM-32-16-debian:~# ns=\"mostorage\"\nroot@VM-32-16-debian:~# kubectl get svc -n${ns}\nNAME             TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE\nminio            ClusterIP   10.96.1.65   <none>        80/TCP           127d\nminio1-console   NodePort    10.96.3.53   <none>        9090:30869/TCP   127d\nminio1-hl        ClusterIP   None         <none>        9000/TCP         127d\nroot@VM-32-16-debian:~# kubectl get pod -n${ns}\nkubectl get ep -n${ns}NAME            READY   STATUS    RESTARTS   AGE\nminio1-ss-0-0   1/1     Running   0          106d\nminio1-ss-0-1   1/1     Running   0          106d\nminio1-ss-0-2   1/1     Running   0          106d\nminio1-ss-0-3   1/1     Running   0          106d\nroot@VM-32-16-debian:~# kubectl get ep -n${ns}\nNAME             ENDPOINTS                                                                 AGE\nminio            100.92.250.195:9000,100.92.250.200:9000,100.92.250.201:9000 + 1 more...   127d\nminio1-console   100.92.250.195:9090,100.92.250.200:9090,100.92.250.201:9090 + 1 more...   127d\nminio1-hl        100.92.250.195:9000,100.92.250.200:9000,100.92.250.201:9000 + 1 more...   127d\n

    The access address of SVC is the terminal address that needs to be added to the Load statement. To construct the SVC address, you can use ${service_name}.{namespace}.svc.cluster.local (the last three digits can be omitted). The results of the following commands show that the SVC of minio1-hl uses 9000 as the external forwarding port, and the SVC of minio uses 80 as the external forwarding port. Therefore, the final endpoint of Minio connected to Mostorage is: http://minio1-hl.mostorage:9000 or http://minio.mostorage:80.

    "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#build-and-execute-the-load-statement","title":"Build and execute the Load statement","text":"
    1. Build the corresponding table according to the data structure of addresses.csv:

      create table address (firstname varchar(50), lastname varchar(50), address varchar(500), city varchar(20), state varchar(10), postcode varchar(20));\n
    2. Referring to the syntax structure of Load S3, fill in the parameter information in the Load statement:

      • endpoint, access_key_id: the login account of minio
      • secret_access_key: the login password of minio)
      • bucket: the name of the bucket
      • filepath: the path to the imported file

      It should be noted that from the local Minio, a \"provider\"=\"minio\" needs to be added to the parameter string to indicate that the underlying storage source is the local Minio, and finally form the following SQL statement.

      MySQL [stock]> load data url s3option{\"endpoint\"='http://minio.mostorage:80',\"access_key_id\"='rootuser', \"secret_access_key\"='rootpass123',\"bucket\"='load-from-minio', \"filepath\"='/addresses.csv', \"compression\"='none', \"provider\"=\"minio\"} INTO TABLE address FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n' PARALLEL 'TRUE';\nQuery OK, 6 rows affected (2.302 sec)\n

    Note

    \"provider\"=\"minio\" is only valid in the local Minio environment. If you import data from the object storage of the public cloud, you don't need to add this parameter.

    "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/","title":"Managing CN Groups with Proxy","text":"

    Proxy is a new system component introduced in MatrixOne's 0.8 version. It can achieve account and load isolation, among other functionalities, through traffic proxying and forwarding. For the technical design of the Proxy, refer to Detailed Proxy Architecture.

    This document primarily explains using Proxy to establish different CN groups for independent resource management of accounts and loads.

    "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#system-architecture","title":"System Architecture","text":"

    As illustrated below, users first connect to the Proxy module. Based on the identity and label information in the user connection string, the Proxy component distributes the user's database connection to the corresponding CN group. Other CN groups will not receive this user connection nor participate in the computation process related to this connection.

    A CN group is a logical CN group composed of CN nodes with the same attributes and size. It is a unit in the MatrixOne cluster used to isolate different resource groups. Each CN group can contain from 1 to infinite CN nodes and can use a series of labels to define its attributes. For example, determining the Account label corresponding to an account and forwarding the connection to a CN group with corresponding labels can realize account resource and business load isolation. With the feature that CN nodes in a CN group can scale horizontally indefinitely, an independent expansion for accounts or specified loads can be achieved.

    To ensure the high availability of Proxy, at least 2 replicas should be set up in the cluster.

    When performing CN (Compute Node) downsizing, Proxy behaves as follows in the YAML file:

    • Session Migration with the Same Label: When the number of CN replicas decreases, sessions with the same label will be migrated to other downsized CN nodes. This ensures the continuity and availability of sessions associated with specific labels.

    • Session Migration with Different Labels: If a CN replica with a particular label is set to 0 or removed, based on label matching rules, sessions associated with that label will be migrated to idle labels in future sessions.

    • Label Cancellation without Matching Labels: If a label is cancelled and no matching label exists, related sessions will be closed because there are no target CNs to receive these sessions.

    Proxy manages session migration and closure during CN downsizing to ensure the isolation between workloads and tenants, as well as the continuity of business operations.

    "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#steps","title":"Steps","text":"

    The environment discussed in this document for managing CN groups using Proxy is based on the environment of MatrixOne Distributed Cluster Deployment.

    To help you understand resource isolation and allocation, you can refer to the table below, which illustrates the distribution of each hardware node in the environment of MatrixOne Distributed Cluster Deployment, as follows:

    Host Internal IP External IP Memory CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G Jump server master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#step-one-enable-proxy","title":"Step One: Enable Proxy","text":"

    To enable the Proxy component in the MatrixOne distributed cluster, you need to specify the required Proxy topology when creating the cluster, or after adding the Proxy topology to the existing cluster, execute kubectl apply to enable the Proxy component. The detailed steps are as follows:

    1. Modify the mo.yaml file of the MatrixOne cluster:

      metadata:\n  name: mo\n  namespace: mo-hn\nspec:\n+ proxy:\n+   replicas: 2 # For high availability, at least 2 replicas are required for the Proxy\n
    2. After the modifications, run the mo.yaml file using the command below:

      kubectl apply -f mo.yaml\n
    3. Run kubectl get pod -nmo-hn to check if the Proxy has started properly:

      root@HOST-10-206-134-16:~# kubectl get pod -nmo-hn\nNAME             READY   STATUS    RESTARTS   AGE\nmo-tn-0          1/1     Running   0          2m51s\nmo-log-0         1/1     Running   0          3m25s\nmo-log-1         1/1     Running   0          3m25s\nmo-log-2         1/1     Running   0          3m25s\nmo-proxy-69zjf   1/1     Running   0          2m51s\nmo-proxy-fpn2g   1/1     Running   0          2m51s\nmo-tp-cn-0       1/1     Running   0          2m25s\n
    4. The code example for a successful start is shown above. This completes the start of the minimized Proxy component. You can use kubectl get svc -nmo-hn to connect to the cluster via the Proxy's SVC address.

      root@HOST-10-206-134-16:~# kubectl get svc -nmo-hn\nNAME                TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE\nmo-tn-headless      ClusterIP   None          <none>        <none>           70m\nmo-log-discovery    ClusterIP   10.96.3.186   <none>        32001/TCP        71m\nmo-log-headless     ClusterIP   None          <none>        <none>           71m\nmo-proxy            NodePort    10.96.1.153   <none>        6001:31429/TCP   70m\nmo-tp-cn            ClusterIP   10.96.1.43    <none>        6001/TCP         70m\nmo-tp-cn-headless   ClusterIP   None          <none>        <none>           70m\nroot@HOST-10-206-134-16:~# mysql -h 10.96.1.153 -P6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 2064\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective owners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

    If multiple CNs exist in the entire cluster, Proxy will automatically implement connection-level load balancing and evenly distribute the user's connections to different CNs. You can query the system table system_metrics.server_connections to view the number of user connections on each CN.

    "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#step-two-set-up-cn-groups","title":"Step Two: Set Up CN Groups","text":"

    In the mo.yaml file of the MatrixOne cluster, you need to configure CN groups by setting the cnGroups field and configure the cnLabels field in each cnGroups to set the labels of all CNs in the CN group. The Proxy will route and forward according to the connection labels. For example, you have set up two CN groups named cn-set1 and cn-set2 in the following example. Each CN group can have an independent number of replicas, log levels, CN parameter configurations, and CN labels.

    The labels of CN groups adopt one-to-many groups of Key/value formats, in which there is a one-to-many relationship between each group of Key and value, i.e., each Key can have multiple values.

    The detailed steps are as follows:

    1. Refer to the configuration parameter example below to configure the labels of the CN group:

      metadata:\n  name: mo\n  namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+   replicas: 1\n+   cnLabels:\n+   - key: \"cn-set1\"\n+     values: [\"1\", \"high\"]\n+   - key: \"account\"\n+     values: [\"acc1\"]\n+\n+ - name: cn-set2\n+   replicas: 1\n+   cnLabels:\n+   - key: \"cn-set2\"\n+           values: [\"2\", \"medium\"]\n+   - key: \"account\"\n+     values: [\"acc2\"]  \n
    2. After the modifications, run the mo.yaml file using the command below:

      kubectl apply -f mo.yaml\n
    3. Run kubectl get pod -nmo-hn to check if the Proxy has adequately started:

    root@HOST-10-206-134-16:~# kubectl get pod -nmo-hn\nNAME              READY   STATUS    RESTARTS   AGE\nmo-cn-set1-cn-0   1/1     Running   0          6s\nmo-cn-set2-cn-0   1/1     Running   0          6s\nmo-tn-0           1/1     Running   0          97m\nmo-log-0          1/1     Running   0          97m\nmo-log-1          1/1     Running   0          97m\nmo-log-2          1/1     Running   0          97m\nmo-proxy-69zjf    1/1     Running   0          97m\nmo-proxy-fpn2g    1/1     Running   0          97m\n

    The code example for a successful start is shown above.

    The label setting of CN groups is very flexible, but it is most commonly used for account and load isolation.

    For how to achieve account isolation and load isolation, continue to the following sections.

    "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#implementing-account-isolation","title":"Implementing account Isolation","text":"

    MatrixOne 0.7 version supports About MatrixOne Privilege Management data isolation. If account load isolation is to be implemented, it must be done by configuring Proxy and CN groups.

    "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#ordinary-accounts","title":"Ordinary accounts","text":"

    In the label setting of CN groups, the account label is a reserved field used to match accounts.

    In this chapter, assuming that account load isolation needs to be implemented for acc1 and acc2, you can refer to the detailed steps below:

    Note

    Only users with system account permissions can configure load isolation for ordinary accounts.

    1. Log into the MatrixOne cluster using the system account. For the username and password, please look at your company's Database Administrator. After logging into the MatrixOne cluster, create two new accounts, acc1 and acc2:

      -- Create a new account acc1 with a password of 123456 (a simple password is set here, which is only used as an example)\nmysql> create account acc1 admin_name 'admin' identified by '123456';\n-- Create a new account acc2 with a password of 123456 (a simple password is set here, which is only used as an example)\nmysql> create account acc2 admin_name 'admin' identified by '123456';\n
    2. Modify the mo.yaml file of the MatrixOne cluster, and label the two CN groups with account:acc1 and account:acc2 respectively, corresponding to tenants named acc1 and acc2 respectively:

      metadata:\n  name: mo\n  namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+   replicas: 1\n+   cnLabels:\n+   - key: \"account\"\n+     values: [\"acc1\"]\n+\n+ - name: cn-set2\n+   replicas: 1\n+   cnLabels:\n+   - key: \"account\"\n+     values: [\"acc2\"]  \n
    3. Modify the mo.yaml file of the MatrixOne cluster, and label the two CN groups with account:acc1 and account:acc2 respectively, corresponding to the accounts named acc1 and acc2 respectively:

    -- acc1 account login MatrixOne\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc1:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 32309\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n-- acc1 checks which CN groups are used for login\nmysql> show backend servers;\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n| UUID                                 | Address                                               | Work State | Labels                       |\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n| 32333337-3966-3137-3032-613035306561 | mo-cn-set1-cn-0.mo-cn-set1-cn-headless.mo-hn.svc:6001 | Working    | account:acc1;cn-set1:1,high; |\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n1 row in set (0.00 sec)\n
    -- acc2 account login MatrixOne\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc2:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 32640\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n-- acc2 checks which CN groups are used for login\nmysql> show backend servers;\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n| UUID                                 | Address                                               | Work State | Labels                         |\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n| 33663265-3234-3365-3737-333030613535 | mo-cn-set2-cn-0.mo-cn-set2-cn-headless.mo-hn.svc:6001 | Working    | account:acc2;cn-set2:2,medium; |\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n1 row in set (0.00 sec)\n

    If an ordinary account does not have a corresponding CN group, then the account cannot log in successfully. For example, if you create a account acc3 that does not correspond to a CN group label and try to log in, you will get a no available CN server error.

    mysql> create account acc3 admin_name 'admin' identified by '123456';\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc3:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nERROR 1045 (28000): internal error: no available CN server\n
    "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#system-account","title":"System account","text":"

    For system accounts, MatrixOne will automatically select an appropriate CN group to connect in the following order:

    • Highest priority: Select the CN group configuring the account label as sys.
    • Second highest priority: Select the CN group configuring other labels but not the account label.
    • Medium priority: Select the CN group that has not configured labels.
    • Low priority: If none of the above CN groups exist, then choose randomly from the existing CN groups.

    Based on this principle, system accounts will prioritize the CN groups specifically reserved for themselves or not for other accounts. However, suppose the above conditions are not met. In that case, the system account might share a CN group with other accounts and thus cannot ensure load isolation between the system account and ordinary accounts.

    "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#implementing-load-isolation","title":"Implementing Load Isolation","text":"

    The use case for the Proxy agent is load isolation. In many standard business environments, such as high-concurrency writes, report generation, backup, and significant data export, traditional database solutions often require the deployment of specific instances to achieve load isolation. This approach also results in an additional burden of data synchronization.

    MatrixOne uses a Proxy to implement resource group division, which can flexibly combine CN groups with user-specified load labels. In the event of load changes, MatrixOne can adjust the scale of the resource group through software configuration, thus better adapting to changes.

    Using the above example, you can set the load labels of two CNs to olap and oltp, respectively. Then, use SSB to simulate the OLTP load and TPCH to simulate the OLAP load.

    Note

    When performing performance testing, you must first scale out the entire cluster.

    metadata:\n  name: mo\n  namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+   replicas: 1\n+   cnLabels:\n+   - key: \"workload\"\n+     # The load label is set to olap\n+     values: [\"olap\"]\n+\n+ - name: cn-set2\n+   replicas: 1\n+   cnLabels:\n+   - key: \"workload\"\n+     # The load label is set to oltp\n+           values: [\"oltp\"]\n

    After configuring the load of the cluster, you can connect to the cluster for load testing:

    1. Connect via JDBC:

      Specify connection attributes in the JDBC connection string, and set the corresponding key and value. A colon separates the key and value :, and a comma separates multiple key-values ,. Examples are as follows:

      jdbc:mysql://localhost:6001/test_db1?serverTimezone=UTC&connectionAttributes=workload:olap,another_key:test_value\n
    2. Connect via MySQL client:

      Use the MySQL client to connect by extending the username field. Add ? after the username (username), and the subsequent writing method follows the connectionAttributes format in JDBC. The difference from the connectionAttributes format in JDBC is that the key and value are separated by =, and between multiple key-values, Use commas , to separate them; examples are as follows:

      mysql -h127.0.0.1 -uuser1?workload=olap,another_key=test_value -P6001 -pxxx\n
    "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/","title":"MatrixOne Distributed Cluster Upgrade","text":"

    This document will introduce how to Rolling upgrade or Reinstall upgrade MatrixOne clusters.

    The upgraded environment introduced in this document will be based on the environment of MatrixOne Distributed Cluster Deployment.

    "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#rolling-upgrade","title":"Rolling upgrade","text":"

    Rolling upgrade is an online upgrade method; the MatrixOne cluster completes the software upgrade while ensuring that some or all services are available.

    According to the introduction in MatrixOne Distributed Cluster Deployment, the overall installation of MatrixOne is based on Kubernetes and MatrixOne Operator. Therefore, the rolling upgrade process is to realize automatic version updates by dynamically modifying the MatrixOne image version number in MatrixOne Operator.

    "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#steps","title":"Steps","text":"
    1. Execute the following command on the terminal on the master0 node to enter the interface for dynamically modifying the yaml configuration file the operator uses.

      mo_ns=\"mo-hn\" #the namespace of matrixone cluster\nmo_cluster_name=\"mo\" # The cluster name of matrixone, generally mo, is specified according to the name in the YAML file of the matrixonecluster object during deployment or can be confirmed by kubectl get matrixonecluster -n${mo_ns}\n# mo-hn and mo have been set in the mo.yaml file of the installation and deployment\nkubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
    2. After entering edit mode, modify the value of spec.version; the parameters are as below:

      • ${TAG}: corresponds to the image tag of Matrixone on dockerhub, for example: nightly-f0d52530

      • ${REPO_URL}: public mirror repository for Matrixone, the default is matrixorigin/matrixone. If the target version does not exist in the public mirror warehouse of MatrixOne, you also need to modify the URL of the mirror warehouse to the existing warehouse:

    3. After completing the modification, press :wq to save. MatrixOne Operator will automatically pull the new version of the image and restart the component services, including Log Service, TN, and CN. You can also observe its running status through the following commands.

      watch -e \"kubectl get pod -n${mo_ns}\"\n
      NAME                                 READY   STATUS    RESTARTS      AGE\nmatrixone-operator-f8496ff5c-fp6zm   1/1     Running   0             24h\nmo-tn-0                              1/1     Running   1 (51s ago)   18h\nmo-log-0                             1/1     Running   0             18h\nmo-log-1                             1/1     Running   1 (5s ago)    18h\nmo-log-2                             1/1     Running   1 (53s ago)   18h\nmo-tp-cn-0                           1/1     Running   1 (53s ago)   18h\n

      If an error, crashbackoff, etc., occurs, you can further troubleshoot the problem by viewing the component log.

      #pod_name is the name of the pod, such as mo-tn-0, mo-tp-cn-0\npod_name=mo-tn-0\nkubectl logs ${pod_name} -nmo-hn > /tmp/tn.log\nvim /tmp/tn.log\n
    4. After the Restart of the components in the MatrixOne cluster is completed, you can use the MySQL Client to connect to the cluster. The upgrade is successful if the connection is successful and the user data is complete.

      # Connect to the MySQL server using the 'mysql' command line tool\n# Use 'kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}' ' to get the cluster IP address of the service in the Kubernetes cluster\n# The '-h' parameter specifies the hostname or IP address of the MySQL service\n# The '-P' parameter specifies the port number of the MySQL service, here is 6001\n# '-uroot' means log in with root user\n# '-p111' means the initial password is 111\nmysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nroot@master0 ~]# mysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 1005\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\nMySQL [(none)]> show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| mo_task            |\n| information_schema |\n| mysql              |\n| system_metrics     |\n| system             |\n| test               |\n| mo_catalog         |\n+--------------------+\n7 rows in set (0.01 sec)\n

      Info

      The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

    5. The rolling update may be suspended due to incorrect configuration (such as specifying a non-existing version when upgrading). At this point, you can re-modify the dynamic configuration of the operator, reset the version number, roll back the changes, and the failed Pods will be re-updated.

    6. You can check the version number of the current MatrixOne deployment with the following command:

      [root@master0 matrixone-operator]# kubectl get matrixoneclusters -n mo-hn -o yaml | grep version\n        {\"apiVersion\":\"core.matrixorigin.io/v1alpha1\",\"kind\":\"MatrixOneCluster\",\"metadata\":{\"annotations\":{},\"name\":\"mo\",\"namespace\":\"mo-hn\"},\"spec\":{\"tn\":{\"cacheVolume\":{\"size\":\"5Gi\",\"storageClassName\":\"local-path\"},\"config\":\"[dn.Txn.Storage]\\nbackend = \\\"TAE\\\"\\nlog-backend = \\\"logservice\\\"\\n[dn.Ckp]\\nflush-interval = \\\"60s\\\"\\nmin-count = 100\\nscan-interval = \\\"5s\\\"\\nincremental-interval = \\\"60s\\\"\\nglobal-interval = \\\"100000s\\\"\\n[log]\\nlevel = \\\"error\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"replicas\":1,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"1Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}}},\"imagePullPolicy\":\"IfNotPresent\",\"imageRepository\":\"matrixorigin/matrixone\",\"logService\":{\"config\":\"[log]\\nlevel = \\\"error\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"pvcRetentionPolicy\":\"Retain\",\"replicas\":3,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"1Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}},\"sharedStorage\":{\"s3\":{\"endpoint\":\"http://minio.mostorage:9000\",\"path\":\"minio-mo\",\"secretRef\":{\"name\":\"minio\"},\"type\":\"minio\"}},\"volume\":{\"size\":\"1Gi\"}},\"tp\":{\"cacheVolume\":{\"size\":\"5Gi\",\"storageClassName\":\"local-path\"},\"config\":\"[cn.Engine]\\ntype = \\\"distributed-tae\\\"\\n[log]\\nlevel = \\\"debug\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"nodePort\":31429,\"replicas\":1,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"2Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}},\"serviceType\":\"NodePort\"},\"version\":\"nightly-54b5e8c\"}}\n    version: nightly-54b5e8c\n
    "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#reinstall-and-upgrade","title":"Reinstall and upgrade","text":"

    Reinstalling and upgrading mean all MatrixOne clusters will be deleted and the data discarded and reinstalled.

    Applicable scene:

    • no need for old data
    • The versions before and after the upgrade are not compatible with each other due to special reasons

    Note

    Before the operation, please ensure the data has been backed up (see modump backup tool) and the business knows that the database has stopped.

    "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#steps_1","title":"Steps","text":""},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#1-delete-the-old-version-cluster","title":"1. Delete the old version cluster","text":"

    In master0, the old version cluster can be deleted in any of the following ways:

    # Method 1: Delete through the YAML file of the mo cluster during deployment, for example:\nkubectl delete -f /root/deploy/mo.yaml\n# Method 2: By deleting the matrixonecluster object, where mo is the name\nkubectl delete matrixonecluster.core.matrixorigin.io mo -nmo-hn\n

    Confirm that mo-related resources have been deleted by checking the pod status:

    kubectl get pod -nmo-hn\n

    In addition, if the PVC used by mo has not been deleted, use the following command to delete it manually:

    kubectl get pvc -nmo-hn\n# For example, the PVC used by the log service has not been deleted, delete it manually\nkubectl delete pvc mo-data-mo-log-0 -nmo-hn\nkubectl delete pvc mo-data-mo-log-1 -nmo-hn\nkubectl delete pvc mo-data-mo-log-2 -nmo-hn\n
    "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#2-empty-bucket-data","title":"2. Empty bucket data","text":"

    On the MinIO control page, delete the data in the bucket used by MinIO used by MO, including subdirectories such as mo-data, etc.

    Or operate through the MinIO client mc:

    mc rb --force minio/minio-mo/data/\nmc rb --force minio/minio-mo/etl\n

    In addition, if you do not want to delete old data, you can create a new MinIO bucket and specify a unique bucket name in the YAML file for deploying the MatrixOne cluster.

    "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#3-deploy-the-new-version-cluster","title":"3. Deploy the new version cluster","text":"

    Edit the yaml file that defines the MO cluster, refer to the Rolling Upgrade chapter, modify the .spec.version field to the latest version, and redeploy the MatrixOne cluster:

    vi mo.yaml\n# content omitted\n...\nkubectl apply -f mo.yaml\n
    "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#4-check-if-the-upgrade-is-successful","title":"4. Check if the upgrade is successful","text":"

    Please check if MatrixOne has started successfully with the following command.

    As shown in the following code example, when the Log Service, TN, and CN are all running normally, the MatrixOne cluster starts successfully. Connecting through the MySQL Client can also check if the database functions correctly.

    [root@master0 ~]# kubectl get pods -n mo-hn      \nNAME                                  READY   STATUS    RESTARTS     AGE\nmatrixone-operator-6c9c49fbd7-lw2h2   1/1     Running   2 (8h ago)   9h\nmo-tn-0                               1/1     Running   0            2m13s\nmo-log-0                              1/1     Running   0            2m47s\nmo-log-1                              1/1     Running   0            2m47s\nmo-log-2                              1/1     Running   0            2m47s\nmo-tp-cn-0                            1/1     Running   0            111s\n
    "},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/","title":"Experience Environment Deployment Plan","text":"

    This document introduces the deployment plan for the MatrixOne experience environment, which can be used to experience the basic distributed capabilities of MatrixOne. You can simply experience the database's essential development, operation, and maintenance functions. Still, it is unsuitable for deploying production environments, performing performance stress tests, conducting high availability tests, etc.

    "},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#hardware-configuration","title":"Hardware Configuration","text":"

    The hardware configuration requirements for the deployment plan of the experience environment are as follows:

    Hardware Environment Requirements Physical/Virtual Machine Number of Devices 3 CPU Configuration 2 cores or more Memory Configuration 8GB or more Disk Configuration 200GB or more Network Card Configuration Not limited"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#software-configuration","title":"Software Configuration","text":"

    The software configuration requirements for the deployment plan of the experience environment include operating system and platform requirements and deployment software module requirements:

    "},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#operating-system-and-platform-requirements","title":"Operating System and Platform Requirements","text":"Operating System Supported CPU Architecture CentOS 7.3 or above 7.x version X86_64"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#deployment-software-module-requirements","title":"Deployment Software Module Requirements","text":"Software Module Number of Deployments Function Description Kubernetes 3 Provides container management for the entire cluster Minio 1 Provides storage services for the MatrixOne cluster MatrixOne 1 Core of the database

    The deployment guide for the MatrixOne distributed environment experience environment can refer to MatrixOne Distributed Cluster Deployment.

    "},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/","title":"Minimum Production Environment Deployment Plan","text":"

    The MatrixOne distributed cluster's minimum production configuration introduced in this article can be used for production environments. It can support tens of millions of data and hundreds of concurrent OLTP or OLAP businesses with tens of GB of data volume. At the same time, it provides a certain level of high availability guarantee. Even if one of the 3 nodes goes offline, it works normally.

    "},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#hardware-configuration","title":"Hardware Configuration","text":"

    The hardware configuration requirements for the minimum production environment deployment plan are as follows:

    Hardware Environment Requirements Both Physical and Virtual Machines are acceptable Number of Devices 3 CPU Configuration 8 cores or more Memory Configuration 32GB or more Disk Configuration Each node has 1 system disk of 100G and 4-7 data disks of 100G, all requiring PCIe NVME SSD 3.0 Network Card Configuration Dual 10GbE ports, 10GbE network card and switch"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#software-configuration","title":"Software Configuration","text":"

    The software configuration requirements for the minimum production environment deployment plan include operating system and platform requirements and deployment software module requirements:

    "},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#operating-system-and-platform-requirements","title":"Operating System and Platform Requirements","text":"Operating System Supported CPU Architecture Debian 11 or higher version (Kernel required 5.0 or higher) X86_64"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#deployment-software-module-requirements","title":"Deployment Software Module Requirements","text":"Node Name Resource Node Role Deployment Modules Disk Deployment node0 8c32g Control/Storage/Compute Deployment and O&M tool mo-ctl, Kubernetes master/node, Minio, MatrixOne Proxy, Logservice, TN, Load Balancer Kubernetes requires 1 data disk, Minio requires 1 to 4 data disks (physical partitioning recommended, logical partitioning is also possible), Logservice requires 1 data disk, TN requires 1 data disk node1 8c32g Control/Storage/Compute Deployment and O&M tool mo-ctl, Kubernetes master/node, Minio, MatrixOne Proxy, Logservice, CN, Load Balancer Kubernetes requires 1 data disk, Minio requires 1 to 4 data disks (physical partitioning recommended, logical partitioning is also possible), Logservice requires 1 data disk, CN requires 1 data disk node2 8c32g Control/Storage/Compute Deployment and O&M tool mo-ctl, Kubernetes master/node, Minio, MatrixOne Proxy, Logservice, CN, Load Balancer Kubernetes requires 1 data disk, Minio requires 1 to 4 data disks (physical partitioning recommended, logical partitioning is also possible), Logservice requires 1 data disk, CN requires 1 data disk"},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/","title":"Recommended Production Environment Deployment Plan","text":"

    The recommended configuration of the MatrixOne distributed cluster described in this document is suitable for production environments and possesses robust performance and reliability. This configuration can support billions of data with thousands of concurrent OLTP operations or handle OLAP operations with tens of TB data volume.

    This configuration provides a high degree of availability guarantee. Whether it is Kubernetes, Minio, or MatrixOne, the system can operate normally when a node goes offline. This means the system has strong fault tolerance and can maintain business continuity in node failure.

    Below are the details for the recommended production environment deployment plan:

    "},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/#software-and-hardware-configuration-requirements","title":"Software and Hardware Configuration Requirements","text":"Module Kubernetes master Minio LogService TN (mixed proxy and load balancing) CN (mixed proxy and load balancing) Number of machines (both physical machines and virtual machines) 3 machines 4 machines 3 machines 1 machine y machines Node Role Kubernetes Management Storage Service MatrixOne Work Node MatrixOne Work Node MatrixOne Work Node CPU configuration 4 cores or above 4 cores or above 4 cores or above 16 cores or above 16 cores or above Memory configuration 8GB or more 8GB or more 8GB or more 64GB or more 32GB or more Network Card Dual 10 Gigabit Ethernet ports, 10 Gigabit Ethernet Ditto Ditto Ditto Ditto System disk configuration Each node PCIe NVME SSD 3.0 \u00d7 1 block 100GB, it is recommended to do Raid 1 Same as above Same as above Same as above Same as above Kubernetes disk configuration PCIe NVME SSD 3.0 \u00d7 1 piece of 100GB per node, Raid 1 is recommended Same as above Same as above Same as above Same as above Disk Configuration N/A PCIe NVME SSD 3.0 \u00d7 4 x a G/block per node, no requirement for raid, physical partitioning is recommended, logical partitioning is recommended. Each node NVME SSD 3.0/4.0 (read rate above 1G/s) \u00d7 1 block \u00d7 b G/block. NVME SSD 3.0/4.0 \u00d7 2 blocks \u00d7 c G/block NVME SSD 3.0/4.0 \u00d7 2 blocks \u00d7 d G/block per node. Remarks a is related to the volume of business data, a = volume of business data \u00d7 2/16. b is related to the amount of business data; the closer, the better. c is related to the amount of business data; the closer, the better. One of them is reserved for TN/CN failure recovery. d is related to the amount of business data; the closer, the better. One of them is reserved for TN/CN failure recovery. y is related to the business load."},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/#other-configuration","title":"Other configuration","text":"Operating System Supported CPU Architectures Debian 11 or above (Kernel 5.0 or above) X86_64

    Since each privatized production environment's deployment scenarios are different, please contact MatrixOne's customer support team for specific deployment solutions and deployment details.

    "},{"location":"MatrixOne/Deploy/deployment-topology/topology-overview/","title":"Cluster Topology Planning Overview","text":"

    MatrixOne database cluster is an architecture for distributed deployment of database systems on multiple physical or virtual servers, aiming to provide high availability and scalability. By distributing the database to multiple servers, the cluster can realize data redundancy backup, load balancing, and fault recovery, thereby providing higher performance and reliability.

    The database cluster topology can choose a suitable architecture for business and performance requirements. Understanding the advantages and disadvantages of different topologies and applicable scenarios will help you design a stable and efficient database cluster architecture.

    "},{"location":"MatrixOne/Deploy/deployment-topology/topology-overview/#topology-deployment-document","title":"Topology deployment document","text":"

    We recommend deployment documents for three environments, refer to:

    • Experience Environment Deployment Plan
    • Minimum Production Environment Deployment Plan
    • Recommended Production Environment Deployment Plan
    "},{"location":"MatrixOne/Develop/develop-overview/","title":"Overview","text":"

    This article and subsequent sections mainly aim to introduce how to perform application development using MatrixOne. We will show how to connect to MatrixOne, create databases and tables, and build applications based on standard programming languages such as Java, Python, and Golang.

    "},{"location":"MatrixOne/Develop/develop-overview/#interaction-between-matrixone-and-applications","title":"Interaction between MatrixOne and Applications","text":"

    MatrixOne is generally highly compatible with MySQL 8.0 regarding communication protocol, SQL syntax, connection tools, or development modes. If this manual does not explicitly explain specific usage, you can refer to the MySQL 8.0 manual. Most application frameworks or programming languages can use MySQL's client library.

    For significant differences between MatrixOne and MySQL, see MySQL Compatibility section.

    "},{"location":"MatrixOne/Develop/develop-overview/#matrixone-transaction-mechanism","title":"MatrixOne Transaction Mechanism","text":"

    MatrixOne supports both Optimistic Transaction and Pessimistic Transaction. In the current version of MatrixOne, the default is the Pessimistic Transaction mode. You can switch to Optimistic Transaction mode by modifying the startup configuration file.

    You can start a transaction with BEGIN, commit the transaction with COMMIT, or roll back the transaction with ROLLBACK. MatrixOne ensures the atomicity of all statements from the beginning of BEGIN to the end of COMMIT or ROLLBACK. All statements during this period are either entirely successful or entirely failed, thereby ensuring the data consistency required in application development.

    If you choose to use optimistic transactions, please add error handling and retry mechanisms in the application, as MatrixOne does not guarantee the success of each transaction. If you use pessimistic transactions, you don't need to consider this. Optimistic transactions will have superior concurrent performance compared to pessimistic transactions.

    "},{"location":"MatrixOne/Develop/develop-overview/#reference","title":"Reference","text":"
    • Connect to MatrixOne
    • Schema Design
    • Import Data
    • Read Data
    • Transactions
    • Application Developing Tutorials
    "},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/","title":"Multi-Account Overview","text":"

    Unlike MySQL, MatrixOne is a database with built-in multi-tenancy capability. In a MatrixOne cluster, accounts can be created using the CREATE ACCOUNT command. Conceptually, each tenant represents a completely independent data space, with all data and operations being isolated from other accounts. When users log in with the tenant's username and password, they enter a MySQL instance where they can perform various operations such as creating databases and tables without affecting the data of other accounts.

    "},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/#introduction-to-accounts","title":"Introduction to accounts","text":"

    The Account in MatrixOne is part of the permission management system. For more information on the permission management system, see Privilege Management Overview section.

    Multi-tenancy has various use cases, including multi-tenancy design in SaaS applications, isolating accounts for subsidiaries of a corporation, and database usage for services in a microservices architecture. For more information on application scenarios, see Multi-Account section in the MatrixOne Feature Overview.

    "},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/#creating-and-using-accounts","title":"Creating and Using Accounts","text":"
    1. For developers, creating and using accounts in MatrixOne can be done through SQL statements. For more examples, see Create accounts, Verify Resource Isolation section.
    2. For operations personnel working with distributed versions of MatrixOne, it is necessary to configure resource isolation and scaling for accounts, for more information on practical guidelines, see Managing CN Groups with Proxy and Scaling MatrixOne Cluster.
    "},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/#account-to-account-publishsubscribe","title":"Account-to-Account Publish/Subscribe","text":"

    In addition to ensuring data and load isolation between accounts, MatrixOne provides a publish/subscribe capability that allows data exchange between accounts. This capability can be used to address data synchronization and large-scale data distribution scenarios. For more information, see Publish-subscribe section.

    "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/","title":"Publish-subscribe","text":"

    Publish-Subscribe (Pub/Sub for short) of a database is a messaging model in which Publisher sends messages to one or more Subscribers, and Subscribers The message is received and processed. In this mode, publishers and subscribers are loosely coupled, and no direct communication is required between them, thus improving the scalability and flexibility of the application.

    In databases, the publish-subscribe function is usually used in scenarios such as real-time data updates, cache synchronization, and business event notification. For example, when the data of a particular table in the database changes, the subscribers can be notified in real-time through the publish and subscribe function, to realize real-time data synchronization and processing. In addition, the notification of business events can also be recognized through the publish and subscribe function, such as an order being canceled, a certain inventory quantity is insufficient, and so on.

    There can be a many-to-many relationship between publishers and subscribers; one publisher can publish messages to multiple subscribers, and one subscriber can also subscribe to various messages/data. Usually, the publish-subscribe function of the database consists of two parts: Publisher and Subscriber. Publisher is responsible for publishing messages, while Subscriber subscribes to corresponding messages to achieve data synchronization.

    "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#application-scenarios","title":"Application scenarios","text":"

    The publish-subscribe function has many typical application scenarios:

    • Data Synchronization: When a database needs to be kept in sync with another database, the publish-subscribe feature can send data changes to the subscriber database. For example, when a website needs to transfer data from one geographic location to another, publish-subscribe functionality can ensure data synchronization between the two databases.

    • Business data distribution: The publish and subscribe function can distribute business data to different systems or processes. For example, when a bank needs to distribute customer account information to multiple business systems, the publish-subscribe function can distribute data to corresponding systems to ensure data consistency between various business processes.

    • Data backup: The publish-subscribe function can back up data. For example, when one database needs to be backed up to another database, the publish-subscribe part can be used to back up the data to the subscriber database so that the data can be recovered in the event of failure of the primary database.

    • Real-time data processing: The publish-subscribe function can be used to realize real-time data processing. For example, when a website needs to process data from different users, the publish-subscribe part can be used to transmit data to a processing program for processing, to realize real-time data analysis and decision-making.

    "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#concepts","title":"Concepts","text":"
    • Publication: In a database, a publication often refers to the process of setting a database object to be accessible by other accounts. It is a crucial step in data sharing and replication, where the published objects can be subscribed to by other accounts, and their data can be accessed.

    • Subscription: A subscription refers to a database choosing to receive and replicate the data of a published database object.

    • Publisher (Pub): The Publisher is the database that performs the publishing operation. The Publisher is responsible for creating and managing the published objects, as well as managing the access permissions of databases subscribing to these published objects.

    • Subscriber (Sub): The Subscriber is the account that subscribes to the published objects.

    • Published Object: A published object is a database created by the Publisher and made available for publication, namely a database. The data of these objects can be accessed and replicated by the Subscriber.

    • Subscribed Object: A subscribed object is a published object replicated and stored on the Subscriber. The data of the subscribed object is updated according to the data on the Publisher.

    "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publicationsubscription-scope-explanation","title":"Publication/Subscription Scope Explanation","text":""},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publishsubscribe-application-scope","title":"Publish/Subscribe Application Scope","text":"

    Both Publisher and Subscriber are accounts of MatrixOne.

    "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publishablesubscribable-permissions","title":"Publishable/Subscribable Permissions","text":"
    • Only ACCOUNTADMIN or MOADMIN role can create publications and subscriptions on the Publisher.
    • Subscribers are controlled by ACCOUNTADMIN or MOADMIN roles to access subscription data permissions.
    "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publicationsubscription-data-scope","title":"Publication/Subscription Data Scope","text":"
    • A single Publication can only be associated with one database.
    • Publications and subscriptions are only implemented at the database level, with no current support for direct publication and subscription at the table level.
    • The Subscriber only has read access to the Subscribed database.
    • If the Publisher adjusts the sharing scope of the publication, those accounts that are no longer within the new scope and have already created a subscribed database will find that their access to the Subscribed database is invalid.
    • If the Publisher attempts to delete a database that has been published, the deletion will fail.
    • If the Publisher deletes a Publication, but the corresponding object still exists in the subscribed database, an error will be triggered when the Subscriber attempts to access this object. The Subscriber will need to delete the corresponding Subscription.
    • If the Publisher deletes a Published object, but the corresponding object still exists in the subscribed database, an error will be triggered when the Subscriber attempts to access this object. The Subscriber must delete the corresponding Subscribed object.
    "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#examples","title":"Examples","text":"

    This chapter will give an example to introduce that there are currently three accounts in the MatrixOne cluster, sys, acc1, and acc2, and operate on the three accounts according to the order of operations:

    1. Publisher: sys account creates database sub1 and table t1, and publishes pub1:

      create database sub1;\ncreate table sub1.t1(a int,b int);\ncreate publication pub1 database sub;\n
    2. Subscriber: both acc1 and acc2 create a subscription database syssub1, and thus get the shared table t1:

      -- The SQL statements for acc1 and acc2 to create the subscription library are the same, so there will not repeat them\ncreate database syssub1 from sys publication pub1;\nuse syssub1;\nshow tables;\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub1  |\n+--------------------+\n| t1                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
    3. Publisher: sys account creates table t2:

      create table sub1.t2(a text);\n
    4. Subscribers: acc1 and acc2 get shared tables t1 and t2:

      show tables;\n+--------------------+\n| Tables_in_syssub1  |\n+--------------------+\n| t1                 |\n+--------------------+\n| t2                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
    5. Publisher: sys account creates database sub2 and table t2, and publishes pub2 to accounts acc1 and acc3:

      create database sub2;\ncreate table sub2.t1(a float);\ncreate publication pub2 database sub2 account acc1,acc3;\n
    6. Subscriber: both acc1 and acc2 create the subscription database syssub2, and acc1 gets the shared data table t1; acc2 fails to create the subscription database syssub2:

      • acc1
      create database syssub2 from sys publication pub2;\nuse syssub2;\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub2  |\n+--------------------+\n| t1                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
      • acc2
      create database syssub2 from sys publication pub2;\n> ERROR 20101 (HY000): internal error: the account acc3 is not allowed to subscribe the publication pub2\n
    7. Publisher: The sys account modifies and publishes pub2 to all accounts:

      alter publication pub2 account all;\n
    8. Subscriber: acc2 successfully created the subscription database syssub2, and got the shared data table t1:

      create database syssub2 from sys publication pub2;\nuse syssub2;\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub2  |\n+--------------------+\n| t1                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
    9. Publisher: sys account deletes publication pub1:

      drop publication pub1;\n
    10. Subscriber: acc1 failed to connect to syspub1:

      use syssub1;\nERROR 20101 (HY000): internal error: there is no publication pub1\n
    11. Subscriber: acc2 delete syspub1:

      drop database syssub1;\n
    12. Publisher: sys account recreates pub1:

      create publication pub1 database sub;\n
    13. Subscriber: acc1 connects to syspub1 successfully:

      create database syssub1 from sys publication pub1;\nuse syssub1;\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub1  |\n+--------------------+\n| t1                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
    "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#reference","title":"Reference","text":""},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publisher-reference","title":"Publisher Reference","text":"
    • CREATE PUBLICATION
    • ALTER PUBLICATION
    • DROP PUBLICATION
    • SHOW PUBLICATIONS
    • SHOW CREATE PUBLICATION
    "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#subscriber-reference","title":"Subscriber Reference","text":"
    • CREATE...FROM...PUBLICATION...
    • SHOW SUBSCRIPTIONS
    "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/","title":"General Transaction Overview","text":""},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#why-do-you-need-transactions","title":"Why do you need transactions?","text":"

    In many large, critical applications, computers perform many tasks every second. More often than not, these tasks are themselves, but these tasks are combined to complete a business requirement called a transaction. What happens if one task is executed successfully and an error occurs in a second or third related task? This error is likely to leave system data in an inconsistent state. At this time, the transaction becomes very important; it can make the system data out of this inconsistent state.

    How to understand transaction? For example, in the banking system, if there is no transaction to control and manage the data, A likely withdraws a sum of money from the corporate account, and B and C also withdraw money from the same corporate account. Each transfer involves at least two changes in account information (for example, A's money arrives, and the company's account goes out; B's money arrives, and the company's account goes out; C's money comes, and the company's account goes out), If there are no transactions, then the exact value of the booking amount cannot be determined. After introducing the business requirement of the transaction, the essential characteristics of the transaction (ACID) ensure that the fund operation of the bank book is atomic (indivisible) and the amount seen by others is isolated. Each process is Consistent, and all operations are persistent, ensuring that the data in and out of the banking system remains consistent.

    "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#what-is-transaction","title":"What is Transaction?","text":"

    The transaction is a logical unit in the execution process of the database management system, consisting of a limited sequence of database operations. A transaction is a series of SQL statements submitted or rolled back as a logical unit.

    "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#characteristics-of-transactions","title":"Characteristics of transactions","text":"

    Usually, transactions need to have four characteristics of ACID:

    • Atomicity: The atomicity of a transaction means that a transaction is an indivisible unit, and the operations in a transaction either all or none of them occur.

    For example:

    start transaction;\ninsert into t1 values(1,2,3),(4,5,6);\nupdate t2 set c1='b' where c1='B';\ncommit;\n

    Suppose an error occurs in inserting data into t1 or modifying any data in t2. In that case, the entire transaction will be rolled back, and only when two statements succeed at the same time will the submission be successful, and one operation will not succeed while the other fails.

    • Consistency: Transactional consistency means that data must remain correct and obey all data-related constraints before and after the transaction.

    For example, create a new table in database first:

    create table t1(a int primary key,b varchar(5) not null);\n

    To ensure data consistency here, when inserting data, to ensure the data type and range of columns a and b, the primary key constraint of column a and the non-null constraint of column b must be satisfied at the same time:

    insert into t1 values(1,'abcde'),(2,'bcdef');\n
    • Isolation: The isolation of a transaction is that when multiple users access concurrently, the specified isolation level must be observed between transactions. Within the determined isolation level range, one transaction cannot be interfered with by another transaction.

    For example, in the following transaction example, the session isolation level is read committed, and the data that can be seen in session 1 is as follows:

    select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 | a    |\n|    2 | b    |\n|    3 | c    |\n+------+------+\n

    At this point in session 2, you can do the following:

    begin;\ndelete from t1 where a=3;\n

    In session 1, you can still see the data unchanged:

    select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 | a    |\n|    2 | b    |\n|    3 | c    |\n+------+------+\n

    Until the current transaction is committed in session 2:

    commit;\n

    The result of the committed transaction will only be seen in session 1:

    select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 | a    |\n|    2 | b    |\n+------+------+\n
    • Durability: Transaction durability means that when a transaction is committed in the database, its changes to the data are permanent, regardless of whether the database software is restarted.
    "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#transaction-types","title":"Transaction Types","text":"

    In a database, transactions are divided into the following categories:

    • According to whether there is a clear start and end, it is divided into explicit transaction and implicit transaction.
    • According to the use stage of the resource lock, it is divided into optimistic transaction and pessimistic transaction.

    These two types of transactions is not limited by each other. An explicit transaction can be an optimistic or pessimistic transaction, and a pessimistic transaction can be either an explicit or an implicit transaction.

    "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#explicit-transaction-and-implicit-transaction","title":"Explicit Transaction and Implicit Transaction","text":"
    • Explicit transaction: In general, you can explicitly start a transaction by executing a BEGIN statement. A transaction can be ended explicitly by executing a COMMIT or ROLLBACK. MatrixOne's displayed transaction startup and execution methods are slightly different; see Explicit Transaction.

    • Implicit transaction: The transaction can start and end implicitly, without using BEGIN TRANSACTION, COMMIT, or ROLLBACK statements to start and end. Implicit transactions behave in the same way as explicit transactions. However, the rules for determining when an implicit transaction begins differ from those for determining when an explicit transaction begins. MatrixOne's implicit transaction startup and execution methods are slightly different; see Implicit Transaction.

    "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#optimistic-transaction-and-pessimistic-transaction","title":"Optimistic Transaction and Pessimistic Transaction","text":"

    Regardless of whether it is an optimistic or pessimistic transaction, the execution results of the transaction are the same; that is, the operations in a transaction have exactly the exact requirements for the ACID level, whether it is atomicity, consistency, isolation, or persistence, there is no situation where optimistic transactions are more relaxed and pessimistic transactions are stricter.

    The difference between an optimistic transaction and a pessimistic transaction is that it is just a two-phase commit based on a different execution strategy based on the state of the business to be processed. Its choice is based on the executor's judgment, and its efficiency is based on the actual state of the business being processed (the frequency of write conflicts of concurrent transactions). That is, different assumptions are made about the state of transaction-related resources so that write locks are placed in different stages.

    At the beginning of an optimistic transaction, it is assumed that the transaction-related tables are in a state where no write conflicts will occur. The insertion, modification, or deletion of data is cached in memory. At this stage, the data will not be locked, but in the data Lock the corresponding data table or data row when submitting, and unlock it after submitting.

    At the beginning of a pessimistic transaction, it is assumed that there will be written conflicts in the tables related to the transaction, and the related tables or rows are locked in advance. Then in memory, insert, modify or delete relevant data and commit. Data is only unlocked after a commit or rollback completes.

    Optimistic transactions and pessimistic transactions have the following advantages and disadvantages during use:

    • Optimistic transactions are more friendly to systems with fewer write operations and more read operations, avoiding deadlocks.
    • Optimistic transactions may fail after repeated retries due to conflicts when larger transactions are committed.
    • Pessimistic transactions are more friendly to systems with more write operations and avoid write-write conflicts from the database level.
    • Pessimistic transactions In a scenario with large concurrency, if a transaction with a long execution time appears, the system may be blocked, and the throughput will be affected.

    For more information on optimistic transactions in MatrixOne, see Optimistic Transaction.

    For more information on optimistic transactions in MatrixOne, see Pessimistic Transaction.

    "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#transaction-isolation","title":"Transaction Isolation","text":"

    One of the characteristics of transactions is isolation, which we usually call transaction isolation.

    Isolation is the most restrictive of the four ACID properties of database transactions. The database system usually uses a locking mechanism or a multi-version concurrency control mechanism to obtain a higher isolation level. Application software also requires additional logic to make it work properly.

    Many database management systems (DBMS) define different \"transaction isolation levels\" to control the degree of locking. In many database systems, most transactions avoid high-level isolation levels (such as serializability) to reduce locking overhead. Programmers must carefully analyze the database access part of the code to ensure that lowering the isolation level does not cause hard-to-find code bugs. On the contrary, a higher isolation level will increase the chance of deadlock, which must be avoided during programming.

    The DBMS is allowed to use a higher isolation level than the one requested because there are no operations in a higher isolation level that are prohibited by a lower isolation level.

    ANSI/ISO SQL defines four standard isolation levels:

    Isolation Level Dirty Write Dirty Read Fuzzy Read Phantom READ UNCOMMITTED Not Possible Possible Possible Possible READ COMMITTED Not Possible Not Possible Possible Possible REPEATABLE READ Not Possible Not Possible Not Possible Possible SERIALIZABLE Not Possible Not Possible Not Possible Not Possible
    • READ UNCOMMITTED: READ UNCOMMITTED is the lowest isolation level. \"Dirty reads\" are allowed, and transactions can see the \"not committed\" modifications of other transactions.

    • READ COMMITTED: At the READ COMMITTED level, the DBMS based on lock mechanism concurrency control needs to keep the write lock on the selected object until the end of the transaction, but the read lock is released immediately after the SELECT operation is completed. Like the previous isolation level, \"scope locks\" are not required.

    • REPEATABLE READS: At the REPEATABLE READS isolation level, the DBMS based on the lock mechanism concurrency control needs to keep the read locks (read locks) and write locks (write locks) of the selected objects until the transaction end but does not require a \"range lock\", so a \"phantom read\" may occur. MatrixOne has implemented Snapshot Isolation and it is also known as REPEATABLE READS to maintain consistency with the isolation level in MySQL.

    • SERIALIZABLE: SERIALIZABLE is the highest isolation level. On lock-based concurrency control DBMSs, serializability requires that read and write locks on selected objects be released at the end of the transaction. Using a \"WHERE\" clause in a SELECT query to describe a range should acquire a \"range-locks\".

    Higher levels provide stronger isolation by requiring more restrictions than lower isolation levels. The standard allows transactions to run at a stronger transaction isolation level.

    Note

    MatrixOne's transaction isolation is slightly different from the general isolation definition and isolation level division; see Isolation level in MatrixOne.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/","title":"Explicit Transactions in MatrixOne","text":"

    In MatrixOne's explicit transactions also obey the following rules:

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#explicit-transaction-rules","title":"Explicit transaction rules","text":"
    • An explicit transaction starts and ends with BEGIN...END or START TRANSACTION...COMMIT or ROLLBACK.
    • In explicit transactions, DML (Data Manipulation Language) and DDL (Data Definition Language) can exist at the same time. All DDLs are supported.
    • In an explicit transaction, other explicit transactions cannot be nested. For example, if START TANSACTIONS is encountered after START TANSACTIONS, all statements between two START TANSACTIONS will be forced to commit, regardless of the value of AUTOCOMMIT 1 or 0.
    • In an explicit transaction, only DML and DDL can be included and cannot contain modification parameter configuration or management commands, such as set [parameter] = [value], create user, and so on.
    • In an explicit transaction, if a write-write conflict occurs when a new transaction is started without an explicit commit or rollback, the previously uncommitted transaction will be rolled back, and an error will be reported.
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#differences-from-mysql-explicit-transactions","title":"Differences from MySQL explicit transactions","text":"Transaction type Turn on autocommit Turn off autocommit Explicit Transactions vs. Autocommit When AUTOCOMMIT=1, MySQL will not change the transaction, and each statement will be executed in a new auto-commit transaction. When AUTOCOMMIT=0, each statement will be executed in an explicitly opened transaction until the transaction is explicitly committed or rolled back. Explicit transactions and non-autocommit When AUTOCOMMIT=1, MySQL will automatically commit uncommitted transactions after each statement execution. When AUTOCOMMIT=0, each statement will be executed in an explicitly opened transaction until the transaction is explicitly committed or rolled back.

    MySQL and MatrixOne Explicit Transaction Behavior Example

    mysql> CREATE TABLE Accounts (account_number INT PRIMARY KEY, balance DECIMAL(10, 2));\nQuery OK, 0 rows affected (0.07 sec)\n\nmysql> INSERT INTO Accounts (account_number, balance) VALUES (1, 1000.00), (2, 500.00);\nQuery OK, 2 rows affected (0.00 sec)\n\nmysql> BEGIN;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> UPDATE Accounts SET balance = balance - 100.00 WHERE account_number = 1;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> UPDATE Accounts SET balance = balance + 100.00 WHERE account_number = 2;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> COMMIT;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> BEGIN;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> UPDATE Accounts SET balance = balance - 100.00 WHERE account_number = 1;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> UPDATE Accounts SET invalid_column = 0 WHERE account_number = 2;\nERROR 20101 (HY000): internal error: column 'invalid_column' not found in table\nPrevious DML conflicts with existing constraints or data format. This transaction has to be aborted\nmysql> ROLLBACK;\nQuery OK, 0 rows affected (0.00 sec)\nmysql> SELECT * FROM Accounts;\n+----------------+---------+\n| account_number | balance |\n+----------------+---------+\n|              1 |  900.00 |\n|              2 |  600.00 |\n+----------------+---------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#cross-database-transaction-behavior-example","title":"Cross-Database Transaction Behavior Example","text":"

    MatrixOne supports cross-database transaction behavior; here, we'll illustrate it with a simple example.

    First, let's create two databases (db1 and db2) along with their respective tables (table1 and table2):

    -- Create the db1 database\nCREATE DATABASE db1;\nUSE db1;\n\n-- Create table1 within db1\nCREATE TABLE table1 (\nid INT AUTO_INCREMENT PRIMARY KEY,\nfield1 INT\n);\n\n-- Create the db2 database\nCREATE DATABASE db2;\nUSE db2;\n\n-- Create table2 within db2\nCREATE TABLE table2 (\nid INT AUTO_INCREMENT PRIMARY KEY,\nfield2 INT\n);\n

    Now, we have created two databases and their tables. Next, let's insert some data:

    -- Insert data into table1 in db1\nINSERT INTO db1.table1 (field1) VALUES (100), (200), (300);\n\n-- Insert data into table2 in db2\nINSERT INTO db2.table2 (field2) VALUES (500), (600), (700);\n

    We now have data in both databases. Moving on, let's execute a cross-database transaction to modify data in these two databases simultaneously:

    -- Start the cross-database transaction\nSTART TRANSACTION;\n\n-- Update data in table1 within db1\nUPDATE db1.table1 SET field1 = field1 + 10;\n\n-- Update data in table2 within db2\nUPDATE db2.table2 SET field2 = field2 - 50;\n\n-- Commit the cross-database transaction\nCOMMIT;\n

    In the above cross-database transaction, we begin with START TRANSACTION;, then proceed to update data in table1 within db1 and table2 within db2. Finally, we use COMMIT; to commit the transaction. If any step fails during the transaction, the entire transaction is rolled back to ensure data consistency.

    This example demonstrates a complete cross-database transaction. Cross-database transactions can be more complex in real-world applications, but this simple example helps us understand the fundamental concepts and operations involved.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/","title":"How to use MatrixOne Transaction?","text":"

    This document will teach you how to simply start, commit, rollback a transaction, and how to automatically commit a transaction.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#start-transaction","title":"Start transaction","text":"

    To start a transaction, you can start a transaction with START TRANSACTION, or you can use the dialect command BEGIN.

    The code example is as follows:

    START TRANSACTION;\ninsert into t1 values(123,'123');\n

    Or:

    BEGIN;\ninsert into t1 values(123,'123');\n
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#commit-transaction","title":"Commit transaction","text":"

    When committing a transaction, MatrixOne accepts the COMMIT command as a commit command. The code example is as follows:

    START TRANSACTION;\ninsert into t1 values(123,'123');\ncommit;\n
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#rollback-transaction","title":"Rollback transaction","text":"

    When rolling back a transaction, MatrixOne accepts the ROLLBACK command as a commit command. The code example is as follows:

    START TRANSACTION;\ninsert into t1 values(123,'123');\nrollback;\n
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#autocommit","title":"Autocommit","text":"

    In MatrixOne, there is a parameter AUTOCOMMIT, which determines whether there is a single SQL statement to be automatically committed as an independent transaction without START TRANSACTION or BEGIN. The syntax is as follows:

    -- Set the value of this parameter\nSET AUTOCOMMIT={on|off|0|1}  SHOW VARIABLES LIKE 'AUTOCOMMIT';\n

    When this parameter is set to ON or 1, it means automatic submission. All single SQL statements not in START TRANSACTION or BEGIN will be automatically submitted when executed.

    -- Autocommit\ninsert into t1 values(1,2,3);   

    When this parameter is set to OFF or 0, it is not automatically committed. All SQL statements not in START TRANSACTION or BEGIN need to use COMMIT or ROLLBACK to perform commit or rollback.

    insert into t1 values(1,2,3);\n-- Manual submission is required here\nCOMMIT;  
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#switch-transaction-mode","title":"Switch Transaction Mode","text":"

    MatrixOne adopts pessimistic transaction and RC isolation level by default. But if you need to switch to optimistic transaction mode, the corresponding isolation level will be changed to snapshot isolation.

    Add the following configuration parameters to the configuration file cn.toml under the matrixone/etc/launch-with-proxy/ directory to switch the transaction mode:

    [cn.Txn]\nmode = \"optimistic\"\nisolation = \"SI\"\n

    Note: If you only add the transaction mode parameter mode = \"optimistic\", but do not add isolation = \"SI\", the system will default to SI isolation in the optimistic transaction mode.

    Restart MatrixOne to make the switched transaction mode take effect.

    For more information on the configuration parameters, see Distributed Common Parameters Configuration.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/","title":"Implicit Transactions in MatrixOne","text":"

    In MatrixOne's Implicit transactions also obey the following rules:

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#implicit-transaction-rules","title":"Implicit transaction rules","text":"
    • When AUTOCOMMIT changes, if the implicit transaction is not committed, MatrixOne will report an error and prompt the user to submit the change.

    • AUTOCOMMIT=0, and when there are no active transactions, DDL (Data Definition Language) and parameter configuration files can be executed.

    • In the case of AUTOCOMMIT=1, each DML (Data Manipulation Language, Data Manipulation Language) statement is a separate transaction and is committed immediately after execution.

    • In the case of AUTOCOMMIT=0, each DML statement will not be submitted immediately after execution, and COMMIT or ROLLBACK needs to be performed manually. If the client exits without committing or rolling back, then Rollback by default.

    • In the case of AUTOCOMMIT=0, DML and DDL can exist at the same time.

    • If a CREATE/DROP DATABASE or CREATE/DROP SEQUENCE operation occurs in the state of AUTOCOMMIT=0, all previously uncommitted content will be forced to be committed. Also, the CREATE/DROP DATABASE functions will be committed immediately as a separate transaction.

    • When there is uncommitted content in the implicit transaction, opening an explicit transaction will force the submission of the previously uncommitted content.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#the-difference-between-matrixone-and-mysql-implicit-transactions","title":"The difference between MatrixOne and MySQL implicit transactions","text":"

    In MatrixOne, if the implicit transaction is enabled (SET AUTOCOMMIT=0), all operations must manually execute COMMIT or ROLLBACK to end the transaction. In contrast, MySQL automatically commits when encountering a DDL or similar SET statement.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#mysql-implicit-transaction-behavior","title":"MySQL Implicit Transaction Behavior","text":"Transaction type Turn on autocommit Turn off autocommit Implicit transactions and autocommit When AUTOCOMMIT=1, MySQL will not change the transaction; each statement is a separate auto-commit transaction. When AUTOCOMMIT=0, MySQL also does not change the transaction, but subsequent statements continue to execute within the current transaction until the transaction is explicitly committed or rolled back. Implicit transactions and non-autocommit When AUTOCOMMIT=1, MySQL will automatically commit uncommitted transactions after each statement execution. When AUTOCOMMIT=0, MySQL continues to execute subsequent statements in the current transaction until the transaction is explicitly committed or rolled back.

    MySQL Implicit Transaction Behavior Example

    mysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT   |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = 1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n|                  1 |\n+--------------------+\n1 row in set (0.01 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n|                  1 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = default;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT   |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.00 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT   |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.00 sec)\n

    MatrixOne Implicit Transaction Behavior Example

    mysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT   |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = 1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1                  |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1                  |\n+--------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nERROR 20101 (HY000): internal error: Uncommitted transaction exists. Please commit or rollback first.\n
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#implicit-transactions-example","title":"Implicit Transactions Example","text":"

    For example, insert data (4,5,6) to t1, which becomes an implicit transaction. Whether the implicit transaction is committed immediately depends on the value of the AUTOCOMMIT parameter:

    CREATE TABLE t1(a bigint, b varchar(10), c varchar(10));\nSTART TRANSACTION;\nINSERT INTO t1 values(1,2,3);\nCOMMIT;\n\n-- Check the AUTOCOMMIT parameters\nmysql> SHOW VARIABLES LIKE 'AUTOCOMMIT';\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| autocommit    | 1     |\n+---------------+-------+\n1 row in set (0.00 sec)\n-- Here an implicit transaction begins, with each DML committed immediately after execution with AUTOCOMMIT=.1\ninsert into t1 values(4,5,6);\n\n-- Implicit transaction is committed automatically, and the table structure is shown below\nmysql> select * from t1;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 | 2    | 3    |\n|    4 | 5    | 6    |\n+------+------+------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/","title":"Isolation level in MatrixOne","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#read-committed","title":"Read Committed","text":"

    MatrixOne defaults to the Read Committed isolation level and its characteristics are as follows:

    • Between different transactions, only the data submitted by other transactions can be read, and the uncommitted data cannot be viewed.
    • The read-committed isolation level can effectively prevent dirty writes and dirty reads but cannot avoid non-repeatable reads and phantom reads.
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#read-committed-principles","title":"Read Committed Principles","text":"
    • When a transaction starts, the database generates a unique transaction ID.
    • When generating the timestamp of the transaction ID, TAE (Transactional Analytic Engine) automatically detects whether there is an updated timestamp in the corresponding table every time the data is added, deleted, modified, or checked. If so, the updated timestamp is the latest.
    • When operating on data, TAE caches the user data in memory. When committing a transaction, TAE writes the data in memory to the disk (the S3 path where the data is stored or the local disk path).
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#read-committed-examples","title":"Read Committed Examples","text":"

    You can participate in the following example to understand the read committed isolation level.

    First in MatrixOne, we create a database test and table t1:

    create database test;\nuse test;\nCREATE TABLE t1\n(\ntid INT NOT NULL primary key,\ntname VARCHAR(50) NOT NULL\n);\nINSERT INTO t1 VALUES(1,'version1');\nINSERT INTO t1 VALUES(2,'version2');\n

    In session 1, start a transaction:

    use test;\nbegin;\nUPDATE t1 SET tname='version3' WHERE tid=2;\nSELECT * FROM t1;\n

    In session 1, the results are as follows:

    +------+----------+\n| tid  | tname    |\n+------+----------+\n|    2 | version3 |\n|    1 | version1 |\n+------+----------+\n

    At this time, open session 2 to query t1:

    use test;\nbegin;\nSELECT * FROM t1;\n

    The result is still the original data:

    +------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version1 |\n|    2 | version2 |\n+------+----------+\n

    In session 2, modify the line for tid=1:

    UPDATE t1 SET tname='version0' WHERE tid=1;\n

    At this point, the content of query t1 in session 1 is still the modified data:

    SELECT * FROM t1;\n+------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version1 |\n|    2 | version3 |\n+------+----------+\n

    After session 2 submits its data, then query session 1, you will find that the content of session 1 has become the data after session two submits:

    • Session 2:
    -- Submit data in session 2:\nCOMMIT;\n
    • Session 1:
    -- Query whether the content of session 1 has become the data submitted by session 2:\nSELECT * FROM t1;\n+------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version0 |\n|    2 | version3 |\n+------+----------+\n
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#snapshot-isolation","title":"Snapshot isolation","text":"

    In MatrixOne, the supported isolation level is Snapshot Isolation, which is also known as REPEATABLE READS to maintain consistency with the isolation level in MySQL. The isolation implementation principle of this level is as follows:

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#snapshot-isolation-principle","title":"Snapshot isolation principle","text":"
    • When a transaction starts, the database generates a transaction ID for the transaction, which is a unique ID.
    • At the timestamp when the transaction ID is generated, a snapshot of the corresponding data is generated, and all transaction operations are performed based on the snapshot.
    • After the transaction commits to modify the data, release the transaction ID and data snapshot.
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#snapshot-isolation-example","title":"Snapshot Isolation Example","text":"

    See the example below to help you understand snapshot isolation.

    First in MatrixOne, we create a database test and table t1:

    create database test;\nuse test;\nCREATE TABLE t1\n(\ntid INT NOT NULL primary key,\ntname VARCHAR(50) NOT NULL\n);\nINSERT INTO t1 VALUES(1,'version1');\nINSERT INTO t1 VALUES(2,'version2');\n

    In session 1, start a transaction:

    use test;\nbegin;\nUPDATE t1 SET tname='version3' WHERE tid=2;\nSELECT * FROM t1;\n

    In session 1, the results are as follows, the modification results based on the snapshot data:

    +------+----------+\n| tid  | tname    |\n+------+----------+\n|    2 | version3 |\n|    1 | version1 |\n+------+----------+\n

    At this time, open session 2 to query t1:

    use test;\nSELECT * FROM t1;\n

    The result is still the original data:

    +------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version1 |\n|    2 | version2 |\n+------+----------+\n

    Commit the transaction in session 1:

    COMMIT;\n

    At this point, the result of t1 in session 2 becomes the submitted data:

    +------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version1 |\n|    2 | version3 |\n+------+----------+\n
    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/mvcc/","title":"MVCC","text":"

    MVCC (Multiversion Concurrency Control) is applied to MatrixOne to ensure transaction snapshot and achieve transaction isolation.

    Create a Latch Free linked list based on the pointer field of the data tuple (Tuple, that is, each row in the table), called the version chain. This version chain allows the database to locate the desired version of a Tuple. Therefore, the storage mechanism of these versions of data is an essential consideration in the design of the database storage engine.

    One solution is the Append Only mechanism, where all tuple versions of a table are stored in the same storage space. This method is used in Postgre SQL. To update an existing Tuple, the database first fetches an empty slot from the table for the new version; then, it copies the current version's contents to the latest version. Finally, it applies the modifications to the Tuple in the newly allocated Slot. The critical decision of the Append Only mechanism is how to order the version chain of Tuple. Since it is impossible to maintain a lock-free doubly linked list, the version chain only points in one direction, either from Old to New (O2N) or New to Old (N2O).

    Another similar scheme is called Time Travel, which stores the information of the version chain separately, while the main table maintains the main version data.

    The third option is to maintain the main version of the tuple in the main table, and maintain a series of delta versions in a separate database comparison tool (delta) store. This storage is called a rollback segment in MySQL and Oracle. To update an existing tuple, the database fetches a contiguous space from the delta store to create a new delta version. This delta version contains the original value of the modified property, not the entire tuple. Then the database directly updates the main version in the main table (In Place Update).

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/","title":"Optimistic Transactions in MatrixOne","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#optimistic-transaction-principle","title":"Optimistic Transaction principle","text":"

    When the transaction starts, no conflict detection or lock will be performed, and the relevant data will be cached in the corresponding memory area. The data will be added, deleted, or modified.

    After completing the modification, when entering the submission stage, it will be submitted in two steps:

    Step 1: Use a column in the data to be written as the primary key column, lock the column and create a timestamp. Writes to related rows after this timestamp are judged as write conflicts.

    Step 2: Write data, record the timestamp at this time, and unlock it.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#optimistic-transaction-model","title":"Optimistic Transaction model","text":"

    MatrixOne supports an optimistic transaction model. You don't lock a row while reading it using optimistic concurrency. When you want to update a row, the application must determine whether another user has updated the row since it was read. Optimistic concurrent transactions are typically used in environments with low data contention.

    In an optimistic concurrency model, an error occurs if you receive a value from the database and another user modifies it before you attempt to modify it.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#example","title":"Example","text":"

    The following is an example of optimistic concurrency, showing how MatrixOne resolves concurrency conflicts.

    1. At 1:00 PM, User 1 reads a row from the database with the following value:

      CustID LastName FirstName\n101 Smith Bob\n
      Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Bob Bob
    2. At 1:01 PM, User 2 reads the same row from the database.

    3. At 1:03 PM, User 2 changes the FirstName row from \"Bob\" to \"Robert\" and updates the database.

      Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Robert Bob
    4. As shown in the above table, the value in the database at the time of the update matches the original value of User 2, indicating that the update was successful.

    5. At 1:05 PM, User 1 changes the FirstName row from \"Bob\" to \"James\" and attempts to update it.

      Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob James Robert
    6. At this point, user 1 encounters an optimistic concurrency violation because the value \"Robert\" in the database no longer matches the original value \"Bob\" that user 1 expected. The concurrency violation indicates that the update failed. The next step is to overwrite User 2's changes with User 1's changes or cancel User 1's changes.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/","title":"Transaction overview of MatrixOne","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#what-is-a-transaction-in-matrixone","title":"What is a transaction in MatrixOne?","text":"

    MatrixOne transactions follow the Standard Definition and Basic Characteristics (ACID) of database transactions. It aims to help users in a distributed database environment to ensure that every database data operation behavior can ensure the consistency and integrity of the results and isolate each other without interference under concurrent requests.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#transaction-type-of-matrixone","title":"Transaction type of MatrixOne","text":"

    In MatrixOne, transactions, like general transactions, are also divided into the following two categories:

    • According to whether there is a clear start and end, it is divided into explicit and implicit transactions.
    • Divided into optimistic and pessimistic transactions according to the use stage of resource locks.

    The classification of these two types of transactions is not limited by each other. An explicit transaction can be an optimistic or pessimistic transaction, and a pessimistic transaction can be either an explicit or an implicit transaction.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#explicit-transaction","title":"Explicit Transaction","text":"

    In MatrixOne, a transaction explicitly declared with START TRANSACTION becomes explicit.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#implicit-transaction","title":"Implicit Transaction","text":"

    In MatrixOne, if a transaction is not explicitly declared by START TRANSACTION or BEGIN, it is an implicit transaction.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#optimistic-transaction","title":"Optimistic Transaction","text":"

    At the beginning of an optimistic transaction, it is assumed that the transaction-related tables are in a state where no write conflicts will occur. The insertion, modification, or deletion of data is cached in memory. At this stage, the data will not be locked, but in the data Lock the corresponding data table or data row when submitting, and unlock it after submitting.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#pessimistic-transaction","title":"Pessimistic Transaction","text":"

    MatrixOne defaults to pessimistic transactions. At the beginning of a pessimistic transaction, it is assumed that the transaction-related table is in a state where write conflicts may occur, and the corresponding data table or data row is locked in advance. After the locking action is completed, the data's insertion, modification, or deletion is cached in In memory; after committing or rolling back, the data is completed, and the lock is released.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#matrixone-supports-cross-database-transactions","title":"MatrixOne Supports Cross-Database Transactions","text":"

    MatrixOne supports cross-database transactions, allowing a single transaction to access and modify multiple databases simultaneously.

    In real-world applications, specific business requirements may necessitate operations involving multiple databases. The introduction of cross-database transactions serves to address these needs. This functionality ensures that operations across different databases maintain consistency and isolation as executed within a single database. This means that when you need to perform a series of operations across multiple databases, you can wrap them within a single transaction, facilitating the completion of these operations while preserving data integrity and consistency.

    Cross-database transactions typically play a pivotal role in complex enterprise application scenarios. Different business functions or departments may use separate databases in these scenarios, yet they need to collaborate to fulfill intricate business requirements. MatrixOne's support for cross-database transactions enhances system flexibility and scalability. However, preserving data integrity and consistency also requires careful design and management.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#transaction-isolation-level-of-matrixone","title":"Transaction isolation level of MatrixOne","text":"

    MatrixOne supports two isolation levels: Read Committed and Snapshot Isolation. The default isolation level is Read Committed.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#read-committed","title":"Read Committed","text":"

    Read Committed is the default isolation level of MatrixOne after version 0.8, and it is also one of the four isolation levels in the SQL standard. Its most notable features are:

    • Between different transactions, only the data submitted by other transactions can be read, and the uncommitted data cannot be viewed.
    • The read-committed isolation level can effectively prevent dirty writes and dirty reads but cannot avoid non-repeatable reads and phantom reads.
    Isolation Level P0 Dirty Write P1 Dirty Read P4C Cursor Lost Update P4 Lost Update READ COMMITTED Not Possible Not Possible Possible Possible"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#snapshot-isolation","title":"Snapshot Isolation","text":"

    Different from the four isolation levels defined by the SQL standard, in MatrixOne, the supported isolation level is snapshot isolation (Snapshot Isolation), which is isolated in the REPEATABLE READ and SERIALIZABLE of the SQL-92 standard between. Different from other isolation levels, snapshot isolation has the following characteristics:

    • Snapshot isolation does not reflect changes made to data by other synchronized transactions for data read within a specified transaction. Specifies that the transaction uses the data rows read at the beginning of this transaction.

    • Data is not locked while being read, so snapshot transactions do not prevent other transactions from writing data.

    • Transactions that write data also do not block snapshot transactions from reading data.

    Compared with other isolation levels, snapshot isolation is also suitable for scenarios such as dirty reads (read uncommitted data), dirty writes (write uncommitted records after modification), phantom reads (multiple reads before and after, and the total amount of data is inconsistent) and other scenarios. Effective avoidance is achieved:

    Isolation Level P0 Dirty Write P1 Dirty Read P4C Cursor Lost Update P4 Lost Update P2 Fuzzy Read P3 Phantom A5A Read Skew A5B Write Skew MatrixOne's Snapshot Isolation Not Possible Not Possible Not Possible Not Possible Not Possible Not Possible Not Possible Possible"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/","title":"Pessimistic Transactions in MatrixOne","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#pessimistic-transactions-principle","title":"Pessimistic Transactions principle","text":"

    When a transaction starts, conflict detection or lock operation must be performed. When no conflict or lock is detected, a column in the data to be written will be regarded as the primary key column, the column will be locked, and a timestamp will be created. Writes to related rows after this timestamp are judged as write conflicts.

    Cache the current relevant data to the corresponding memory area, and add, delete, and modify the data. If there is a lock on the current table, it will enter the waiting state. When the waiting timeout occurs, the waiting transaction will be canceled.

    After the modification is completed, enter the commit phase, write data, record the timestamp at this time, and unlock the lock.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#pessimistic-transaction-model","title":"Pessimistic transaction model","text":"

    MatrixOne defaults to a pessimistic transaction.

    Pessimistic concurrent transactions are typically used in environments with high data contention. When you read a row using pessimistic concurrency, the row is not locked. When you want to update a row, the application must determine whether another user has locked the row.

    In the pessimistic concurrency model, if you receive a value from the database, another user will encounter a lock and enter a waiting state before you try to modify the value. After exceeding the transaction waiting time (5 minutes) set by MatrixOne, Waiting transactions will be forcibly canceled.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#deadlock","title":"Deadlock","text":"

    In a pessimistic transaction, there may be a situation where two or more transactions lock the resources needed by each other, making it impossible for each transaction to proceed. This situation is called dead. Only through human intervention in one of the transactions, for example, by manually Kill the session, can the deadlock be ended immediately; otherwise, the transaction can only wait for the maximum waiting time.

    An example of a deadlock is shown in the following figure:

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#example","title":"Example","text":"

    The following is an example of pessimistic concurrency, showing how MatrixOne resolves concurrency conflicts.

    1. At 1:00 PM, User 1 reads a row from the database with the following value:
    CustID LastName FirstName\n101 Smith Bob\n
    Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Bob Bob
    1. At 1:01 PM, User 2 reads the same row from the database.

    2. At 1:03 PM, User 2 changes the FirstName row from \"Bob\" to \"Robert\" and updates the database and the uncommitted state at this time.

      Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Robert Bob
    3. At 1:05 PM, User 1 changes the FirstName column from \"Bob\" to \"James\" and attempts to update it.

      Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob James Bob
    4. At this point, user 1 encounters a pessimistic concurrency conflict because the row where the value \"Robert\" in the database has been locked and needs to wait for user 2's next operation.

    5. At 1:06 PM, User 1 commits to the transaction. At this time, user 2 releases the waiting state and starts the transaction, but because the corresponding FirstName cannot be matched, the transaction update of user 2 fails.

    "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/scenario/","title":"Transaction ascenarios in MatrixOne","text":"

    In a financial system, transfers between different users are prevalent scenarios. The actual operation of transfers in the database is usually two steps; first, after deducting the book value of one user and then to another, The user's account amount is increased. Only by using the atomicity of the transaction can we ensure that the total book funds have not changed. At the same time, the accounts between the two users have completed their deductions and increases. For example, user A transfers 50 to user B at this time:

    start transaction;\nupdate accounts set balance=balance-50 where name='A';\nupdate accounts set balance=balance+50 where name='B';\ncommit;\n

    When the two update are successful and finally submitted, the entire transfer is truly completed. The entire transaction must be rolled back if any step fails to ensure atomicity.

    In addition, during the transfer process of the two accounts, before committing, whether it is A or B, you see the book balance that has not been transferred, which is the transaction's isolation.

    During the transfer process, the database will check whether A's book funds are greater than 50 and whether A and B are indeed in the system. Only when these constraints are satisfied can the consistency of the transaction be guaranteed.

    After the transfer is completed, whether the system is restarted or not, the data has persisted, reflecting the persistence of the transaction.

    "},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/","title":"How to configure MatrixOne SSL connection","text":""},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#overview","title":"Overview","text":"

    This document describes how to configure your MatrixOne server to use SSL for database connections. After you secure your MatrixOne connections, malicious users cannot intercept your traffic.

    "},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#configure-matrixone-ssl-connections","title":"Configure MatrixOne SSL connections","text":""},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#create-the-directory-to-store-the-ssl-keys","title":"Create the directory to store the SSL keys","text":"

    To create the directory that will contain the SSL keys, perform the following steps:

    1. Log into your server via SSH. Check if you have the mysql_ssl_rsa_setup tool in place. Usually if you have installed MySQL, the mysql_ssl_rsa_setup binary will also be installed.

      If you try to execute this command mysql_ssl_rsa_setup and you see this following message, it means you have installed it. If not, please install MySQL first, and this mysql_ssl_rsa_setup will be installed along. You can also check the path of mysql_ssl_rsa_setup binary file with whereis mysql_ssl_rsa_setup.

      [pcusername@VM-0-12-centos matrixone]$ mysql_ssl_rsa_setup\n2022-10-19 10:57:30 [ERROR]   Failed to access directory pointed by --datadir. Please make sure that directory exists and is accessible by mysql_ssl_rsa_setup. Supplied value : /var/lib/mysql\n[pcusername@VM-0-12-centos matrixone]$ whereis mysql_ssl_rsa_setup\nmysql_ssl_rsa_setup: /usr/bin/mysql_ssl_rsa_setup /usr/share/man/man1/mysql_ssl_rsa_setup.1.gz\n
    2. Create an SSL key storage directory that MatrixOne can access. For example, run the mkdir /home/user/mo_keys command to create a mo_keys directory.

    "},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#create-the-ssl-keys","title":"Create the SSL keys","text":"

    To create the SSL keys, perform the following steps:

    1. Run the following commands to create the Certificate Authority (CA) keys:

      mysql_ssl_rsa_setup --datadir=/home/user/mo_keys\n

      You'll see in this folder a list of .pem files.

      /mo_keys \u251c\u2500\u2500 ca-key.pem \u251c\u2500\u2500 ca.pem \u251c\u2500\u2500 client-cert.pem \u251c\u2500\u2500 client-key.pem \u251c\u2500\u2500 private_key.pem \u251c\u2500\u2500 public_key.pem \u251c\u2500\u2500 server-cert.pem \u2514\u2500\u2500 server-key.pem

    2. Insert the following lines in the [cn.frontend] section of the etc /launch-with-proxy/cn.toml file in MatrixOne folder:

      [cn.frontend]\nenableTls = true\ntlsCertFile = \"/home/user/mo_keys/server-cert.pem\"\ntlsKeyFile = \"/home/user/mo_keys/server-key.pem\"\ntlsCaFile = \"/home/user/mo_keys/ca.pem\"\n

      If [cn.frontend] section doesn't exist in the MatrixOne system setting file, you can just create one with the above settings.

    "},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#test-the-ssl-configuration","title":"Test the SSL configuration","text":"

    To test the SSL configuration, perform the following steps:

    1. Launch MatrixOne service. Please refer to Deploy standalone MatrixOne.

    2. Connect to MatrixOne service by MySQL client:

      mysql -h IP_ADDRESS -P 6001 -uroot -p111\n
    3. After you connect, run the status command. The output will resemble the following example:

      mysql> status\n--------------\nmysql  Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)\n\nConnection id:      1001\nCurrent database:\nCurrent user:       root@0.0.0.0\nSSL:            Cipher in use is TLS_AES_128_GCM_SHA256\nCurrent pager:      stdout\nUsing outfile:      ''\nUsing delimiter:    ;\nServer version:     8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\nProtocol version:   10\nConnection:     127.0.0.1 via TCP/IP\nClient characterset:    utf8mb4\nServer characterset:    utf8mb4\nTCP port:       6002\nBinary data as:     Hexadecimal\n--------------\n
    "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/","title":"Connecting to MatrixOne with Golang","text":"

    MatrixOne supports Golang application connection, Go-MySQL-Driver is supported. This tutorial will walk you through how to connect MatrixOne with Golang.

    "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#before-you-start","title":"Before you start","text":"
    1. Make sure you have already installed and launched MatrixOne.
    2. Make sure you have already installed Golang 1.18 and plus.

      #To check with Golang installation and its version\ngo version\n
    3. Make sure you have already installed MySQL client.

    "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#using-golang-to-connect-to-matrixone","title":"Using Golang to connect to MatrixOne","text":"

    Go-MySQL-Driver is a MySQL driver for Go's (golang) database/sql package.

    1. Install go-mysql-driver tool. Simple install the package to your $GOPATH with the go tool from shell. Make sure Git is installed on your machine and in your system's PATH.

      > go get -u github.com/go-sql-driver/mysql\n
    2. Connect to MatrixOne by MySQL client. Create a new database named test.

      mysql> create database test;\n
    3. Create a plain text file golang_connect_matrixone.go and put the code below.

      package main\n\nimport (\n    \"database/sql\"\n    \"fmt\"\n    _ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc main() {\n    //\"username:password@[protocol](address:port)/database\"\n    db, _ := sql.Open(\"mysql\", \"root:111@tcp(127.0.0.1:6001)/test\") // Set database connection\n    defer db.Close()                                            //Close DB\n    err := db.Ping()                                            //Connect to DB\n    if err != nil {\n        fmt.Println(\"Database Connection Failed\")               //Connection failed\n        return\n    } else {\n        fmt.Println(\"Database Connection Succeed\")              //Connection succeed\n    }\n}\n
    4. Execute this golang file in the command line terminal.

      > go run golang_connect_matrixone.go\nDatabase Connection Succeed\n
    "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#using-gorm-to-connect-to-matrixone","title":"Using Gorm to connect to MatrixOne","text":"

    Gorm is the fantastic ORM library for Golang and aims to be developer-friendly. gorm.io/gorm and gorm.io/driver/mysql will make Go connect to MYSQL.

    1. Use command go get to install gorm.io/gorm and gorm.io/driver/mysql.

      go get -u gorm.io/gorm\ngo get -u gorm.io/driver/mysql\n
    2. Connect to MatrixOne by MySQL client. Create a new database named test.

      mysql> create database test;\n
    3. Create a go file golang_gorm_connect_matrixone.go and put the code below.

      package main\nimport (\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"fmt\"\n)\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO \ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ })\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\nfunc main() {\ngetDBConn()\n}\n
    4. Execute this go file in the command line terminal.

      > go run golang_gorm_connect_matrixone.go\nDatabase Connection Succeed\n
    "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#reference","title":"Reference","text":"

    For the example about using Golang to build a simple CRUD with MatrixOne, see Build a simple Golang CRUD demo with MatrixOne.

    For the example about using Gorm to build a simple CRUD with MatrixOne, see Build a simple Gorm CRUD demo with MatrixOne.

    "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/","title":"Connecting to MatrixOne with Database Client Tool","text":"

    MatrixOne now supports the following Database client tools:

    • MySQL Client
    • Navicat
    • DBeaver
    "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#before-you-start","title":"Before you start","text":"

    Make sure you have already installed and launched MatrixOne.

    "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#connect-to-the-matrixone-server-through-mysql-client","title":"Connect to the MatrixOne Server through MySQL Client","text":"
    1. Download and install MySQL Client.

    2. Connect to the MatrixOne server.

      You can use the MySQL command-line client to connect to MatrixOne server:

      mysql -h IP -P PORT -uUsername -p\n

      The connection string is the same format as MySQL accepts. You need to provide a user name and a password.

      Use the built-in test account for example:

      • user: root
      • password: 111
      mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password:\n

      Info

      The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

      The successful result is as below:

      Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 1031\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\nCopyright (c) 2000, 2022, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n

    For more information on deployment, see Deployment FAQs.

    Note

    MatrixOne and the client use non-encrypted transmission by default. Refer to Data Transmission Encryption to enable encrypted transmission.

    "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#connect-to-the-matrixone-server-through-navicat","title":"Connect to the MatrixOne Server through Navicat","text":"
    1. Open a new terminal and enter into the following command:

      #Launch MatrixOne (Source code method)\n./mo-service -launch ./etc/launch/launch.toml\n
    2. Download and install Navicat.

    3. Open Navicat, click Connection > MySQL, and fill in the following parameters in the pop-up window:

      • Connction Name: MatrixOne
      • Host: 127.0.0.1
      • Port: 6001
      • User Name: root
      • Password: 111
      • Save password:Yes
    4. Click Save, save the configuration.

    5. To connect to the MatrixOne server, double-click MatrixOne in the database directory on the left.

    6. Once you connect to MatrixOne, you will see 6 default system databases.

      And on the right you will see the information about this connection.

    "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#connect-to-the-matrixone-server-through-dbeaver","title":"Connect to the MatrixOne Server through DBeaver","text":"
    1. Download and install DBeaver.

    2. Open DBeaver, click Connection, select MySQL, then click Next.

      Fill in the following parameters in the pop-up window. Click Finish, save the configuration.

      • Host: 127.0.0.1
      • Port: 6001
      • Database: MatrixOne
      • User Name: root
      • Password: 111
      • Save password locally: Yes

    3. To connect to the MatrixOne server, double-click MatrixOne in the database navigation on the left. You will see the four default system databases.

    4. By default, views are not appearing in DBeaver. To show complete system databases, you need to right click on the MatrxiOne, select on Connection view and toggle on the Show system objects.

      Then you can see full 6 system databases.

    "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/","title":"Connecting to MatrixOne with Python","text":"

    MatrixOne supports Python connection, pymysql and sqlalchemy drivers are supported. This tutorial will walk you through how to connect MatrixOne by these two python drivers.

    "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#before-you-start","title":"Before you start","text":"
    1. Make sure you have already installed and launched MatrixOne.
    2. Make sure you have already installed Python 3.8(or plus) version.
    #To check with Python installation and its version\npython3 -V\n
    1. Make sure you have already installed MySQL.
    "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#using-python-pymysql-connect-to-matrixone","title":"Using Python pymysql connect to MatrixOne","text":"

    The PyMySQL is a pure-Python MySQL client library.

    1. Download and install pymysql and cryptography tool:

      pip3 install pymysql\npip3 install cryptography\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\n
    2. Connect to MatrixOne by MySQL client. Create a new database named test.

      mysql> create database test;\n
    3. Create a plain text file pymysql_connect_matrixone.py and put the code below.

      #!/usr/bin/python3\n\nimport pymysql\n\n# Open database connection\ndb = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        )\n# prepare a cursor object using cursor() method\ncursor = db.cursor()\n\n# execute SQL query using execute() method.\ncursor.execute(\"SELECT VERSION()\")\n\n# Fetch a single row using fetchone() method.\ndata = cursor.fetchone()\nprint (\"Database version : %s \" % data)\n\n# disconnect from server\ndb.close()\n
    4. Execute this python file in the command line terminal.

      > python3 pymysql_connect_matrixone.py\nDatabase version : 8.0.30-MatrixOne-v1.0.0-rc1\n
    "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#using-sqlalchemy-connect-to-matrixone","title":"Using sqlalchemy connect to MatrixOne","text":"

    SQLAlchemy is the Python SQL toolkit and Object Relational Mapper(ORM) that gives application developers the full power and flexibility of SQL.

    1. Download and install sqlalchemy tool:

      pip3 install sqlalchemy\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install sqlalchemy -i https://pypi.tuna.tsinghua.edu.cn/simple\n
    2. Connect to MatrixOne by MySQL client. Create a new database named test, a new table named student and insert two records.

      mysql> create database test;\nmysql> use test;\nmysql> create table student (name varchar(20), age int);\nmysql> insert into student values (\"tom\", 11), (\"alice\", \"10\");\n
    3. Create a plain text file sqlalchemy_connect_matrixone.py and put the code below,

      #!/usr/bin/python3\nfrom sqlalchemy import create_engine, text\n\n# Open database connection\nmy_conn = create_engine(\"mysql+mysqldb://root:111@127.0.0.1:6001/test\")\n\n# execute SQL query using execute() method.\nquery=text(\"SELECT * FROM student LIMIT 0,10\")\nmy_data=my_conn.execute(query)\n\n# print SQL result\nfor row in my_data:\n        print(\"name:\", row[\"name\"])\n        print(\"age:\", row[\"age\"])\n
    4. Execute this python file in the command line terminal.

      python3 sqlalchemy_connect_matrixone.py\nname: tom\nage: 11\nname: alice\nage: 10\n
    "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#reference","title":"Reference","text":"

    For the example about using Python to build a simple CRUD with MatrixOne, see Build a simple Python+SQLAlchemy CRUD demo with MatrixOne and Build a simple Python CRUD demo with MatrixOne

    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/","title":"Connect MatrixOne with JDBC","text":"

    In Java, we can connect to MatrixOne with JDBC(Java Database Connectivity) through the Java code. JDBC is one of the standard APIs for database connectivity, using it we can easily run our query, statement, and also fetch data from the database.

    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/#before-you-start","title":"Before you start","text":"

    Prerequisite to understand Java Database Connectivity with MatrixOne, make sure you have installed these items as below:

    1. Make sure you have already installed and launched MatrixOne.
    2. Make sure you have already installed JDK 8+ version.
    3. Make sure you have already installed MySQL client.
    4. Make sure you have already installed JAVA IDE, this document uses IntelliJ IDEA as an example, you can also download other IDE.
    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/#steps","title":"Steps","text":"
    1. Connect to MatrixOne by MySQL client. Create a new database named test or other names you want in MatrixOne and create a new table named t1:

      create database test;\nuse test;\ncreate table t1\n(\ncode int primary key,\ntitle char(35)\n);\n
    2. Create a new Java project testJDBC in IDEA and select Maven as build system, then click on Create.

    3. Click on the File > Project Structure, enter into *Project Setting*, select and click Library, then click + button, add new project library From Maven**.

    4. Search library with mysql-connector-java, select mysql:mysql-connector-java:8.0.30, apply it to this project.

    5. Modify the default Java source code at src/main/java/org/example/Main.java. In general, the code below create a connection with the connection address and credentials, after connecting to MatrixOne, you can operate on MatrixOne database and tables by Java language.

      For a full example about how to develop a CRUD(Create, Read, Update, Delete) application in MatrixOne with JDBC, please refer to this JDBC CRUD tutorial.

      package org.example;\n\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.SQLException;\n\n\n\npublic class Main {\n\n\n    private static String jdbcURL = \"jdbc:mysql://127.0.0.1:6001/test\";\n    private static String jdbcUsername = \"root\";\n    private static String jdbcPassword = \"111\";\n\n    public static void main(String[] args) {\n\n\n        try {\n            Connection connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);\n            // Do something with the Connection\n\n        } catch (SQLException ex) {\n            // handle any errors\n            System.out.println(\"SQLException: \" + ex.getMessage());\n            System.out.println(\"SQLState: \" + ex.getSQLState());\n            System.out.println(\"VendorError: \" + ex.getErrorCode());\n        }\n    }\n}\n
    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/#reference","title":"Reference","text":"

    For a full list about MatrixOne's support for JDBC features, see JDBC supported features list in MatrixOne.

    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/","title":"Connect MatrixOne with Java ORMs","text":"

    Apart from connecting with JDBC, more typically, we'll connect to our MySQL database using an Object Relational Mapping (ORM) Framework. We will introduce how to connect to MatrixOne with Spring Data JPA and MyBatis in this article.

    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#mybatis","title":"MyBatis","text":"

    MyBatis was introduced in 2010 and is a SQL mapper framework with simplicity as its strength. We provide a full building CRUD application tutorial with MyBatis and Spring Boot. Here, we'll focus on how to configure MyBatis with MatrixOne connection.

    The below example is a typical setting with Maven build system.

    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#1-add-mybatis-spring-boot-starter-in-pomxml","title":"1. Add MyBatis-Spring-Boot-Starter in Pom.xml","text":"

    MyBatis applications are built on top of the Spring Boot. For that, you need to add this module to pom.xml which is created when you choose a Maven project.

    <dependency>\n    <groupId>org.mybatis.spring.boot</groupId>\n    <artifactId>mybatis-spring-boot-starter</artifactId>\n    <version>2.1.4</version>\n</dependency>\n
    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#2-add-configuration","title":"2. Add Configuration","text":"

    You need to store some of the given parameters inside the application.properties. Five properties usually need to be modified:

    • spring.datasource.driver-class-name : Driver name for MySQL connector.
    • spring.datasource.url: JDBC connection URL with its parameters.
    • spring.datasource.username: Database username.
    • spring.datasource.password: Database password.
    • mybatis.mapper-locations : Locations of Mapper XML config file.

    MatrixOne's recommended configuration is as below:

    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\nspring.datasource.username=root\nspring.datasource.password=111\nmybatis.mapper-locations=classpath:mapping/*xml\n

    Note

    JDBC connection URL with recommended configuration is necessary, otherwise the connection will fail.

    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#spring-data-jpa","title":"Spring Data JPA","text":"

    Spring Data JPA is a robust framework that helps reduce boilerplate code and provides a mechanism for implementing basic CRUD operations via one of several predefined repository interfaces. We provide a full building CRUD application tutorial with Spring Data JPA and Spring Boot. We'll focus on how to configure Spring JPA with MatrixOne connection.

    The below example is a typical setting with Maven build system.

    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#1-add-spring-boot-starter-data-jpa-in-pomxml","title":"1. Add spring-boot-starter-data-jpa in Pom.xml","text":"

    Spring Data JPA applications are built on top of the Spring Boot. For that, you need to add this module to pom.xml which is created when you choose a Maven project.

    <dependency>\n    <groupId>org.springframework.boot</groupId>\n    <artifactId>spring-boot-starter-data-jpa</artifactId>\n</dependency>\n
    "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#2-add-configuration_1","title":"2. Add Configuration","text":"

    You need to store some of the given parameters inside the application.properties. Five properties usually need to be modified:

    • spring.datasource.driver-class-name : Driver name for MySQL connector.
    • spring.datasource.url: JDBC connection URL with its parameters.
    • spring.datasource.username: Database username.
    • spring.datasource.password: Database password.
    • spring.jpa.properties.hibernate.dialect : The SQL dialect makes Hibernate generate better SQL for the chosen database. MatrixOne only supports org.hibernate.dialect.MySQLDialect.

    • spring.jpa.hibernate.ddl-auto:This property takes an enum that controls the schema generation in a more controlled way. The possible options and effects are in the following table. MatrixOne only supports none and validate.

    Option Effect none No database Schema initialization create Drops and creates the schema at the application startup. With this option, all your data will be gone on each startup. create-drop Creates schema at the startup and destroys the schema on context closure. Useful for unit tests. validate Only checks if the Schema matches the Entities. If the schema doesn't match, then the application startup will fail. Makes no changes to the database. update Updates the schema only if necessary. For example, If a new field was added in an entity, then it will simply alter the table for a new column without destroying the data.

    MatrixOne's recommended configuration is as below:

    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\nspring.datasource.username=root\nspring.datasource.password=111\nspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect\nspring.jpa.hibernate.ddl-auto = validate\n
    "},{"location":"MatrixOne/Develop/export-data/modump/","title":"Export data by MODUMP","text":"

    There are two methods to export data with MatrixOne:

    • SELECT INTO...OUTFILE
    • mo-dump

    This document will introduce about how to export data with mo-dump.

    "},{"location":"MatrixOne/Develop/export-data/modump/#what-is-mo-dump","title":"What is mo-dump","text":"

    Like mysqldump, MatrixOne has a client utility tool called mo-dump that can perform backups of a MatrixOne database by exporting a \".sql\" file type that contains SQL statements can be executed to recreate the original database.

    To use the mo-dump tool, you must have access to a server running an instance of MatrixOne. You must also have user credentials with the required privileges for the database you want to export.

    "},{"location":"MatrixOne/Develop/export-data/modump/#syntax","title":"Syntax","text":"
    ./mo-dump -u ${user} -p ${password} -h ${host} -P ${port} -db ${database} [--local-infile=true] [-csv] [-tbl ${table}...] -net-buffer-length ${net-buffer-length} > {dumpfilename.sql}\n

    The parameters are as following:

    • -u [user]: It is a username to connect to the MatrixOne server. Only the users with database and table read privileges can use mo-dump utility. Default value: dump

    • -p [password]: The valid password of the MatrixOne user. Default value: 111

    • -h [host]: The host ip address of MatrixOne server. Default value: 127.0.0.1

    • -P [port]: The port of MatrixOne server. Default value: 6001

    • -db [database name]: Required parameter. Name of the database that you want to take backup.

    • -net-buffer-length [packet size]: Packet size, the total size of the characters in the SQL statement. The data packet is the basic unit of SQL exported data. If no parameter is set, the default is 1048576 Byte (1M), and the maximum can be set to 16777216 Byte (16M). If the parameter here is set to 16777216 Byte (16M), then when the data larger than 16M is to be exported, the data will be split into multiple 16M data packets, except for the last data packet, the size of other data packets is 16M.

    • -csv: The default value is false. The exported data is in CSV format when set to true.

    • --local-infile: The default value is true and only takes effect when the parameter -csv is set to true. Indicates support for native export of CSV files.

    • -tbl [table name]: Optional parameter. If the parameter is empty, the whole database will be exported. If you want to take the backup specific tables, then you can specify multiple -tbl and table names in the command.

    "},{"location":"MatrixOne/Develop/export-data/modump/#build-the-mo-dump-binary","title":"Build the mo-dump binary","text":"

    To use mo-dump utility, we need to build the tool first. mo-dump is embedded in the MatrixOne source code. You can build the binary from the source code.

    Tips: Same as MatrixOne mo-dump is written by Golang, building it will require a Golang installation and environment setting.

    1. Execute the following code to build the mo-dump binary from the MatrixOne source code:

      git clone https://github.com/matrixorigin/matrixone.git\ncd matrixone\nmake build modump\n
    2. Then you can find the mo-dump executable file in the MatrixOne folder.

    Note

    This built mo-dump file can also work in a same hardware platform. But a binary built in a x86 platform will not work correctly in a darwin ARM platform. The best practice is to build and use the binary file within the same operating system and hardware platform. mo-dump only supports Linux and macOS for now.

    "},{"location":"MatrixOne/Develop/export-data/modump/#steps-to-export-your-matrixone-database-using-mo-dump","title":"Steps to Export your MatrixOne Database using mo-dump","text":"

    mo-dump is easy to use with the command line. Here are the steps to take to export a complete database in the form of SQL commands:

    Open up a command line or terminal window on your computer, then verify that from this terminal you can connect to your MatrixOne instance, enter this command to export the database:

    ./mo-dump -u username -p password -h host_ip_address -P port -db database > exporteddb.sql\n

    For example, if you are launching the terminal in the same server as the MatrixOne instance, and you want to generate the backup of the single database, run the following command. The command will generate the backup of the \"t\" database with structure and data in the t.sql file. The t.sql file will be located in the same directory as your mo-dump executable.

    ./mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db t > t.sql\n

    If you want to export the tables in the database t to CSV format, refer to the following command:

    ./mo-dump -u root -p 111 -db t -csv --local-infile=false > ttt.csv\n

    If you want to generate the backup of a single table in a database, run the following command. The command will generate the backup of the t1 table of t database with structure and data in the t.sql file.

    ./mo-dump -u root -p 111 -db t -tbl t1 > t1.sql\n
    "},{"location":"MatrixOne/Develop/export-data/modump/#constraints","title":"Constraints","text":"
    • mo-dump only supports exporting the backup of a single database, if you have several databases to backup, you need to manually run mo-dump for several times.

    • mo-dump doesn't support exporting only the structure or data of databases. If you want to generate the backup of the data without the database structure or vise versa, you need to manually split the .sql file.

    "},{"location":"MatrixOne/Develop/export-data/select-into-outfile/","title":"Export data by SELECT INTO","text":"

    There are two methods to export data with MatrixOne:

    • SELECT INTO...OUTFILE
    • modump

    This document will introduce about how to export data with SELECT INTO...OUTFILE.

    SELECT...INTO OUTFILE statement exports a table data into a text file on the server host.

    "},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#syntax","title":"Syntax","text":"

    The syntax for this statement combines a regular SELECT command with INTO OUTFILE filename at the end. The default output format is the same as it is for the LOAD DATA command. So, the following statement exports the test table into /root/test as a tab-delimited, linefeed-terminated file.

    mysql> SELECT * FROM TEST\n    -> INTO OUTFILE '/root/test.csv';\n

    You can change the output format using various options to indicate how to quote and delimit columns and records. Using the following code to export the TEST table in a CSV format with CRLF-terminated lines:

    mysql> SELECT * FROM TEST INTO OUTFILE '/root/test.csv'\n   -> FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n   -> LINES TERMINATED BY '\\r\\n';\n

    The SELECT ... INTO OUTFILE has the following properties \u2212

    • The output file is created directly by the MatrixOne server, so the filename should indicate where you want the file to be written on the server host. MatrixOne doesn't support export the file to a client-side file system.
    • You must have the privilege to execute the SELECT ... INTO statement.
    • The output file must not already exist. This prevents MatrixOne from clobbering files that may be important.
    • You should have a login account on the server host or some way to retrieve the file from that host. Otherwise, the SELECT ... INTO OUTFILE command will most likely be of no value to you.
    "},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#example","title":"Example","text":""},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#before-you-start","title":"Before you start","text":"

    Make sure you have already Deployed standalone MatrixOne.

    Note

    If you install MatrixOne by docker, the directory is inside the docker image by default. To work with local directory, you need to bind a local directory to the container. In the following example, the local file system path ${local_data_path}/mo-data is binded to the MatrixOne docker image, with a mapping to the /mo-data path. For more information, see Docker Mount Volume tutorial.

    sudo docker run --name <name> --privileged -d -p 6001:6001 -v ${local_data_path}/mo-data:/mo-data:rw matrixorigin/matrixone:1.0.0-rc1\n
    "},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#steps","title":"Steps","text":"
    1. Create tables in MatrixOne:

      create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\ninsert into user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\nselect * from user;\n+------+-----------+------+\n| id   | user_name | sex  |\n+------+-----------+------+\n|    1 | weder     | man  |\n|    2 | tom       | man  |\n|    3 | wederTom  | man  |\n+------+-----------+------+\n
    2. For installation with source code or binary file, export the table to your local directory, for example, ~/tmp/export_demo/export_datatable.txt.

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

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

      select * from user into outfile 'mo-data/export_datatable.txt';\n
    3. Check the table in your directory export_datatable.txt, the result is as below:

      id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\n3,\"wederTom\",\"man\"\n
    "},{"location":"MatrixOne/Develop/import-data/delete-data/","title":"Delete Data","text":"

    This document describes how to delete data in MatrixOne using SQL statements.

    "},{"location":"MatrixOne/Develop/import-data/delete-data/#prerequisites","title":"Prerequisites","text":"

    Complete the Deploy standalone MatrixOne.

    "},{"location":"MatrixOne/Develop/import-data/delete-data/#sql-statements-for-deleting-data","title":"SQL Statements for Deleting Data","text":"

    You can delete data in three ways: DROP TABLE, TRUNCATE TABLE, and DELETE FROM.

    Here are the differences between them:

    • DELETE FROM: Use DELETE FROM to delete specific records.
    • TRUNCATE TABLE: Use TRUNCATE TABLE when you want to keep the table structure, indexes, and constraints intact, but delete all records.
    • DROP TABLE: Use DROP TABLE when you no longer need the table.
    "},{"location":"MatrixOne/Develop/import-data/delete-data/#delete","title":"DELETE","text":"
    DELETE FROM tbl_name [[AS] tbl_alias]\n    [WHERE where_condition]\n    [ORDER BY ...]\n    [LIMIT row_count]\n
    1. DELETE FROM tbl_name: Specifies the target table from which data will be deleted. tbl_name is the table name.

    2. [AS] tbl_alias (optional): You can use the AS keyword to assign a table alias (tbl_alias) to the target table. The alias is optional and used to simplify the query and reference the table in the statement.

    3. [WHERE where_condition] (optional): The WHERE clause specifies the conditions for deleting data. Only rows that satisfy the specified conditions will be deleted. where_condition is a logical expression that can use various comparisons and logical operators to define the conditions.

    4. [ORDER BY ...] (optional): The ORDER BY clause is used to sort the rows to be deleted based on specified columns. You can use one or more columns and specify ascending (ASC) or descending (DESC) order. The sorting affects the order of the deleted rows.

    5. [LIMIT row_count] (optional): The LIMIT clause limits the number of rows deleted from the table. It specifies the maximum number of rows (row_count) to be deleted. If the LIMIT clause is not specified, all rows satisfying the WHERE condition will be deleted.

    "},{"location":"MatrixOne/Develop/import-data/delete-data/#truncate","title":"TRUNCATE","text":"
    TRUNCATE [TABLE] table_name;\n

    The TRUNCATE statement deletes all data in a table while preserving the table structure. It quickly clears the table without deleting rows one by one.

    • [TABLE] (optional) is a keyword that provides more explicit syntax but can be omitted in most database systems.
    • table_name is the name of the target table.
    "},{"location":"MatrixOne/Develop/import-data/delete-data/#drop","title":"DROP","text":"
    DROP TABLE [IF EXISTS] [db.]name\n

    The DROP TABLE statement completely removes a table, including its structure and data, from the database.

    • [IF EXISTS] (optional) is a keyword that performs the deletion only if the table exists. An error will occur if omitted, and the table to be dropped does not exist.
    • [db.] (optional) specifies the database name where the table resides. If no database name is provided, the current database is assumed.
    • name is the name of the table to be dropped.
    "},{"location":"MatrixOne/Develop/import-data/delete-data/#garbage-collection","title":"Garbage Collection","text":"

    By default, MatrixOne does not immediately delete data from the disk after running DELETE, DROP, or TRUNCATE statements. Instead, it marks the data as deletable. Then, the GC (Garbage Collection) mechanism periodically scans and cleans up the no longer-needed old data.

    By default, the garbage collection mechanism scans every 30 minutes. During each scan, it identifies data deleted through SQL statements for over 1 hour and starts the cleanup process to release disk space. The most extended cycle to complete all deletions is 90 minutes. Therefore, it is essential to note that executing DELETE, DROP, or TRUNCATE statements do not immediately reduce disk usage. Only data marked as deletable during the garbage collection will be cleaned up, and disk space will be freed.

    "},{"location":"MatrixOne/Develop/import-data/delete-data/#examples","title":"Examples","text":"
    • Example 1
    -- Create table\nCREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ndepartment VARCHAR(50)\n);\n\n-- Insert data\nINSERT INTO employees (id, name, department)\nVALUES (1, 'John Doe', 'HR'),\n(2, 'Jane Smith', 'Marketing'),\n(3, 'Mike Johnson', 'IT'),\n(4, 'Emily Brown', 'Finance');\n\n-- View initial data\nmysql> SELECT * FROM employees;\n+------+--------------+------------+\n| id   | name         | department |\n+------+--------------+------------+\n|    1 | John Doe     | HR         |\n|    2 | Jane Smith   | Marketing  |\n|    3 | Mike Johnson | IT         |\n|    4 | Emily Brown  | Finance    |\n+------+--------------+------------+\n4 rows in set (0.01 sec)\n\n-- Delete partial data\nmysql> DELETE FROM employees WHERE department = 'IT';\nQuery OK, 1 row affected (0.01 sec)\n\n-- View data after the deletion\nmysql> SELECT * FROM employees;\n+------+-------------+------------+\n| id   | name        | department |\n+------+-------------+------------+\n|    1 | John Doe    | HR         |\n|    2 | Jane Smith  | Marketing  |\n|    4 | Emily Brown | Finance    |\n+------+-------------+------------+\n3 rows in set (0.00 sec)\n
    • Example 2
    -- Create table\nCREATE TABLE orders (\norder_id INT PRIMARY KEY,\ncustomer_name VARCHAR(50),\norder_date DATE\n);\n\n-- Insert data\nINSERT INTO orders (order_id, customer_name, order_date)\nVALUES (1, 'John Doe', '2022-01-01'),\n(2, 'Jane Smith', '2022-02-01'),\n(3, 'Mike Johnson', '2022-03-01'),\n(4, 'Emily Brown', '2022-04-01'),\n(5, 'David Wilson', '2022-05-01');\n\n-- View initial data\nmysql> SELECT * FROM orders;\n+----------+---------------+------------+\n| order_id | customer_name | order_date |\n+----------+---------------+------------+\n|        1 | John Doe      | 2022-01-01 |\n|        2 | Jane Smith    | 2022-02-01 |\n|        3 | Mike Johnson  | 2022-03-01 |\n|        4 | Emily Brown   | 2022-04-01 |\n|        5 | David Wilson  | 2022-05-01 |\n+----------+---------------+------------+\n5 rows in set (0.01 sec)\n\n-- Delete the earliest two orders\nmysql> DELETE FROM orders\nWHERE order_id IN (\nSELECT order_id\nFROM orders\nORDER BY order_date\nLIMIT 2);\nQuery OK, 2 rows affected (0.01 sec)\n\n-- View data after the deletion\nmysql> SELECT * FROM orders;\n+----------+---------------+------------+\n| order_id | customer_name | order_date |\n+----------+---------------+------------+\n|        3 | Mike Johnson  | 2022-03-01 |\n|        4 | Emily Brown   | 2022-04-01 |\n|        5 | David Wilson  | 2022-05-01 |\n+----------+---------------+------------+\n3 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Develop/import-data/insert-data/","title":"Insert Data","text":"

    This document describes how to insert data into MatrixOne by using the SQL language.

    "},{"location":"MatrixOne/Develop/import-data/insert-data/#before-you-start","title":"Before you start","text":"

    Make sure you have already Deployed standalone MatrixOne.

    "},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into-statement","title":"INSERT INTO Statement","text":"

    It is possible to write the INSERT INTO statement in several ways:

    1. Specify both the column names and the values to be inserted:

      INSERT INTO tbl_name (a,b,c) VALUES (1,2,3);\n
    2. If you add values for all the table columns, you do not need to specify the column names in the SQL query. However, make sure the values' order is in the same order as the columns in the table. Here, the INSERT INTO syntax would be as follows:

      INSERT INTO tbl_name VALUES (1,2,3);\n
    3. INSERTstatements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of comma-separated column values, with lists enclosed within parentheses and separated by commas. Example:

      INSERT INTO tbl_name (a,b,c) VALUES(1,2,3), (4,5,6), (7,8,9);\n
    "},{"location":"MatrixOne/Develop/import-data/insert-data/#demo-database","title":"Demo Database","text":"

    Below is a selection from the \"Customers\" table in the Northwind sample database:

    CREATE TABLE Customers (\n  CustomerID INT AUTO_INCREMENT NOT NULL,\n  CustomerName VARCHAR(40) NOT NULL,\n  ContactName VARCHAR(30) NULL,\n  Address VARCHAR(60) NULL,\n  City VARCHAR(15) NULL,\n  PostalCode VARCHAR(10) NULL,\n  Country VARCHAR(15) NULL,\n  PRIMARY KEY (CustomerID)\n  );\n
    CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into-example","title":"INSERT INTO Example","text":"

    The following SQL statement inserts a new record in the \"Customers\" table:

    "},{"location":"MatrixOne/Develop/import-data/insert-data/#example","title":"Example","text":"
    INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)\nVALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');\n

    The selection from the \"Customers\" table will now look like this:

    CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland 92 Cardinal Tom B. Erichsen Skagen 21 Stavanger 4006 Norway"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-data-only-in-specified-columns","title":"Insert Data Only in Specified Columns","text":"

    It is also possible to only insert data in specific columns.

    "},{"location":"MatrixOne/Develop/import-data/insert-data/#example_1","title":"Example","text":"

    The following SQL statement will insert a new record, but only insert data in the \"CustomerName\", \"City\", and \"Country\" columns (CustomerID will be updated automatically):

    INSERT INTO Customers (CustomerName, City, Country)\nVALUES ('Cardinal', 'Stavanger', 'Norway');\n

    The selection from the \"Customers\" table will now look like this:

    CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland 92 Cardinal null null Stavanger null Norway"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-intoselect","title":"INSERT INTO...SELECT","text":"

    With INSERT INTO SELECT, you can quickly insert many rows into a table from the result of a SELECT statement, which can select from one or many tables. The INSERT INTO SELECT statement requires that the data types in source and target tables match.

    "},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into-select-syntax","title":"INSERT INTO SELECT Syntax","text":"

    Copy all columns from one table to another table:

    INSERT INTO *table2*\nSELECT * FROM *table1\n*WHERE *condition*;\n

    Copy only some columns from one table into another table:

    INSERT INTO *table2* (*column1*, *column2*, *column3*, ...)\nSELECT *column1*, *column2*, *column3*, ...\nFROM *table1*\nWHERE *condition*;\n
    "},{"location":"MatrixOne/Develop/import-data/insert-data/#northwind-sample-database","title":"Northwind sample database","text":"

    In this tutorial we will use the Northwind sample database.

    CREATE TABLE Customers (\n  CustomerID INT AUTO_INCREMENT NOT NULL,\n  CustomerName VARCHAR(40) NOT NULL,\n  ContactName VARCHAR(30) NULL,\n  Address VARCHAR(60) NULL,\n  City VARCHAR(15) NULL,\n  PostalCode VARCHAR(10) NULL,\n  Country VARCHAR(15) NULL,\n  PRIMARY KEY (CustomerID)\n  );\nCREATE TABLE Suppliers (\n  SupplierID INT AUTO_INCREMENT NOT NULL,\n  SupplierName VARCHAR(40) NOT NULL,\n  ContactName VARCHAR(30) NULL,\n  Address VARCHAR(60) NULL,\n  City VARCHAR(15) NULL,\n  PostalCode VARCHAR(10) NULL,\n  Country VARCHAR(15) NULL,\n  PRIMARY KEY (SupplierID)\n  );\n

    Below is a selection from the \"Customers\" table:

    CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constituci\u00f3n 2222 M\u00e9xico D.F. 05021 Mexico 3 Antonio Moreno Taquer\u00eda Antonio Moreno Mataderos 2312 M\u00e9xico D.F. 05023 Mexico

    And a selection from the \"Suppliers\" table:

    SupplierID SupplierName ContactName Address City PostalCode Country 1 Exotic Liquid Charlotte Cooper 49 Gilbert St. Londona EC1 4SD UK 2 New Orleans Cajun Delights Shelley Burke P.O. Box 78934 New Orleans 70117 USA 3 Grandma Kelly's Homestead Regina Murphy 707 Oxford Rd. Ann Arbor 48104 USA"},{"location":"MatrixOne/Develop/import-data/insert-data/#example_2","title":"Example","text":"

    The following SQL statement copies \"Suppliers\" into \"Customers\" (the columns that are not filled with data, will contain NULL):

    INSERT INTO Customers (CustomerName, City, Country)\nSELECT SupplierName, City, Country FROM Suppliers;\n

    The selection from the \"Customers\" table will now look like this:

    CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constituci\u00f3n 2222 M\u00e9xico D.F. 05021 Mexico 3 Antonio Moreno Taquer\u00eda Antonio Moreno Mataderos 2312 M\u00e9xico D.F. 05023 Mexico 4 Exotic Liquid null null Londona null UK 5 New Orleans Cajun Delights null null New Orleans null USA 6 Grandma Kelly's Homestead null null Ann Arbor null USA"},{"location":"MatrixOne/Develop/import-data/prepared/","title":"Prepared","text":"

    MatrixOne provides support for server-side prepared statements. This support takes advantage of the efficient client/server binary protocol. Using prepared statements with placeholders for parameter values has the following benefits:

    Less overhead for parsing the statement each time it is executed. Typically, database applications process large volumes of almost-identical statements, with only changes to literal or variable values in clauses such as WHERE for queries and deletes, SET for updates, and VALUES for inserts.

    Protection against SQL injection attacks. The parameter values can contain unescaped SQL quote and delimiter characters.

    "},{"location":"MatrixOne/Develop/import-data/prepared/#prepare-execute-and-deallocate-prepare-statements","title":"PREPARE, EXECUTE, and DEALLOCATE PREPARE Statements","text":"

    SQL syntax for prepared statements is based on three SQL statements:

    • PREPARE prepares a statement for execution.

    • EXECUTE executes a prepared statement.

    • DEALLOCATE PREPARE releases a prepared statement.

    "},{"location":"MatrixOne/Develop/import-data/prepared/#create-a-prepared-statement","title":"Create a prepared statement","text":"
    PREPARE stmt_name FROM preparable_stmt\n
    Arguments Description stmt_name The name of the prepared statement. preparable_stmt a string literal or a user variable that contains the text of the SQL statement. The text must represent a single statement, not multiple statements."},{"location":"MatrixOne/Develop/import-data/prepared/#executes-a-prepared-statement","title":"Executes a prepared statement","text":"
    EXECUTE stmt_name [USING @var_name [, @var_name] ...]\n
    Arguments Description stmt_name The name of the prepared statement."},{"location":"MatrixOne/Develop/import-data/prepared/#delete-a-prepared-statement","title":"Delete a prepared statement","text":"
    {DEALLOCATE | DROP} PREPARE stmt_name\n
    Arguments Description stmt_name The name of the prepared statement."},{"location":"MatrixOne/Develop/import-data/prepared/#example","title":"Example","text":"
    -- Create table\nCREATE TABLE customers (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nemail VARCHAR(50)\n);\n\n-- Insert data\nINSERT INTO customers (id, name, email)\nVALUES (1, 'John Doe', 'john@example.com'),\n(2, 'Jane Smith', 'jane@example.com'),\n(3, 'Mike Johnson', 'mike@example.com');\n\n-- Prepare statement\nmysql> PREPARE stmt FROM 'SELECT * FROM customers WHERE id = ?';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Execute prepared statement\nmysql> SET @id = 2;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> EXECUTE stmt USING @id;\n+------+------------+------------------+\n| id   | name       | email            |\n+------+------------+------------------+\n|    2 | Jane Smith | jane@example.com |\n+------+------------+------------------+\n1 row in set (0.01 sec)\n\n-- Deallocate statement\nmysql> DEALLOCATE PREPARE stmt;\nQuery OK, 0 rows affected (0.00 sec)\n

    The above example begins by creating a table named customers with three columns: id, name, and email. Next, three rows of data are inserted into the table.

    Then, the PREPARE statement is used to prepare a statement, and the SELECT * FROM customers WHERE id = ? query is stored in the stmt variable.

    When executing the prepared statement, the @id variable is set to 2, and the EXECUTE statement is used to execute the prepared statement with the @id parameter.

    Finally, the DEALLOCATE PREPARE statement is used to deallocate the prepared statement and free up the associated resources.

    "},{"location":"MatrixOne/Develop/import-data/update-data/","title":"Update Data","text":"

    This document describes how to update data in MatrixOne using SQL statements.

    "},{"location":"MatrixOne/Develop/import-data/update-data/#prerequisites","title":"Prerequisites","text":"

    Single-node deployment of MatrixOne has been completed.

    "},{"location":"MatrixOne/Develop/import-data/update-data/#sql-statements-for-updating-data","title":"SQL Statements for Updating Data","text":"

    There are two ways to update data: UPDATE and INSERT ON DUPLICATE KEY UPDATE.

    The differences between the two are as follows:

    • UPDATE:

      • The UPDATE statement is used to update existing rows of data directly.
      • You need to specify the target table, columns to be updated, their corresponding new values, and the update conditions.
      • If the update conditions are met, the data of the existing rows will be modified.
      • No changes will be made if the update conditions are not met.
    • INSERT ON DUPLICATE KEY UPDATE:

      • INSERT ON DUPLICATE KEY UPDATE is an extension of the INSERT statement, used to handle duplicate keys when inserting new rows.
      • When there are duplicate keys in the inserted data, i.e., when the values of specific column(s) or combination of columns are the same as existing rows' key values, an UPDATE operation will be performed instead of inserting a new row.
      • You can specify the data to be inserted and the update operations to be performed when duplicate key conflicts occur in a single statement.
      • The specified update operations will update the corresponding columns for rows with duplicate keys.

    Key Differences:

    • The UPDATE statement is used to directly update existing rows, while the INSERT ON DUPLICATE KEY UPDATE statement is used to handle duplicate keys when inserting data.
    • The UPDATE statement requires you to specify the target table, columns to be updated, their corresponding new values, and the update conditions. The INSERT ON DUPLICATE KEY UPDATE statement allows you to specify the data to be inserted and the update operations in a single statement.
    "},{"location":"MatrixOne/Develop/import-data/update-data/#update","title":"UPDATE","text":"
    UPDATE table_reference\n    SET assignment_list\n    [WHERE where_condition]\n    [ORDER BY ...]\n    [LIMIT row_count]\n
    1. UPDATE table_reference: Specifies the target table for updating data. The table_reference can be a single table or multiple tables joined together.

    2. SET assignment_list: Specifies the columns and values to be updated. The assignment_list lists column names and their corresponding values, separated by commas. Each column name is followed by an equal sign (=) to associate it with the new value to be updated.

    3. [WHERE where_condition] (optional): The WHERE clause is used to specify the conditions for updating data. Only rows that satisfy the specified conditions will be updated. where_condition is a logical expression that can define conditions using various comparisons and logical operators.

    4. [ORDER BY ...] (optional): The ORDER BY clause is used to sort the rows to be updated based on the specified columns. You can use one or more columns and specify ascending (ASC) or descending (DESC) order. The sorting will affect the order of the updated rows.

    5. [LIMIT row_count] (optional): The LIMIT clause limits the number of rows to be updated. It specifies the maximum number of rows (row_count) to be updated. If the LIMIT clause is not specified, all rows that satisfy the WHERE condition will be updated.

    During the data update process, specify the target table, the columns and values to be updated, the update conditions, and optionally, the sorting and limiting parameters to perform flexible data updates according to your requirements.

    "},{"location":"MatrixOne/Develop/import-data/update-data/#insert-on-duplicate-key-update","title":"INSERT ON DUPLICATE KEY UPDATE","text":"
    > INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n  [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...];\n
    1. INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...
    2. The INSERT INTO statement inserts new rows into a table.
    3. [db.] (optional) specifies the database name where the table is located. If not provided, the default is the current database.
    4. table is the name of the target table where the data will be inserted.
    5. [(c1, c2, c3)] (optional) specifies the columns to be inserted, enclosed in parentheses and separated by commas. If column names are not specified, it is assumed that all available columns in the table will be inserted.
    6. The VALUES clause specifies the values to be inserted. Each value corresponds to its respective column and is separated by commas and enclosed in parentheses. Multiple rows of data can be inserted, with each row separated by commas.

    7. [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...]

    8. The ON DUPLICATE KEY UPDATE clause handles duplicate keys when inserting data.
    9. When there are duplicate keys in the inserted data, i.e., when the values of specific column(s) or combination of columns are the same as existing rows' key values, an UPDATE operation will be performed instead of inserting a new row.
    10. column1, column2, column3 represent the column names to be updated, and value1, value2, value3 represent the corresponding values to be updated.

    This syntax allows you to insert one or multiple rows of data into the specified table.

    . If a duplicate key situation occurs, i.e., a row with the same key value already exists, an UPDATE operation is executed to update that row's data.

    When using the INSERT INTO statement, provide the corresponding column names and values based on the table structure and requirements. If duplicate keys are encountered, and the ON DUPLICATE KEY UPDATE clause is used, specify the columns to be updated and their corresponding values.

    "},{"location":"MatrixOne/Develop/import-data/update-data/#examples","title":"Examples","text":"
    • Example 1: UPDATE
    -- Create table\nCREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ndepartment VARCHAR(50),\nsalary DECIMAL(10, 2)\n);\n\n-- Insert data\nINSERT INTO employees (id, name, department, salary)\nVALUES (1, 'John Doe', 'HR', 5000),\n(2, 'Jane Smith', 'Marketing', 6000),\n(3, 'Mike Johnson', 'IT', 7000),\n(4, 'Emily Brown', 'Finance', 8000),\n(5, 'David Wilson', 'HR', 5500);\n\n-- View initial data\nmysql> SELECT * FROM employees;\n+------+--------------+------------+---------+\n| id   | name         | department | salary  |\n+------+--------------+------------+---------+\n|    1 | John Doe     | HR         | 5000.00 |\n|    2 | Jane Smith   | Marketing  | 6000.00 |\n|    3 | Mike Johnson | IT         | 7000.00 |\n|    4 | Emily Brown  | Finance    | 8000.00 |\n|    5 | David Wilson | HR         | 5500.00 |\n+------+--------------+------------+---------+\n5 rows in set (0.01 sec)\n\n-- Update data using the UPDATE statement. The salary of the first two employees in the 'HR' department is increased by 10%. The WHERE clause specifies the condition for updating the data; only rows with the department 'HR' will be updated. The ORDER BY clause sorts the rows by the id column in ascending order, and the LIMIT clause limits the update to only two rows.\nmysql> UPDATE employees\nSET salary = salary * 1.1\nWHERE department = 'HR'\nORDER BY id\nLIMIT 2;\nQuery OK, 2 rows affected (0.02 sec)\n\n-- View updated data\nmysql> SELECT * FROM employees;\n+------+--------------+------------+---------+\n| id   | name         | department | salary  |\n+------+--------------+------------+---------+\n|    2 | Jane Smith   | Marketing  | 6000.00 |\n|    3 | Mike Johnson | IT         | 7000.00 |\n|    4 | Emily Brown  | Finance    | 8000.00 |\n|    1 | John Doe     | HR         | 5500.00 |\n|    5 | David Wilson | HR         | 6050.00 |\n+------+--------------+------------+---------+\n5 rows in set (0.00 sec)\n
    • Example 2: INSERT ... ON DUPLICATE KEY UPDATE
    -- Create table\nCREATE TABLE students (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nage INT,\ngrade VARCHAR(10)\n);\n\n-- Insert data\nINSERT INTO students (id, name, age, grade)\nVALUES (1, 'John Doe', 18, 'A'),\n(2, 'Jane Smith', 17, 'B'),\n(3, 'Mike Johnson', 19, 'A'),\n(4, 'Emily Brown', 18, 'A');\n\n-- View initial data\nmysql> SELECT * FROM students;\n+------+--------------+------+-------+\n| id   | name         | age  | grade |\n+------+--------------+------+-------+\n|    1 | John Doe     |   18 | A     |\n|    2 | Jane Smith   |   17 | B     |\n|    3 | Mike Johnson |   19 | A     |\n|    4 | Emily Brown  |   18 | A     |\n+------+--------------+------+-------+\n4 rows in set (0.01 sec)\n\n-- Update data\nmysql> INSERT INTO students (id, name, age, grade)\nVALUES (2, 'Jane Smith', 18, 'A')\nON DUPLICATE KEY UPDATE age = VALUES(age), grade = VALUES(grade);\nQuery OK, 1 row affected (0.01 sec)\n\n-- View updated data\nmysql> SELECT * FROM students;\n+------+--------------+------+-------+\n| id   | name         | age  | grade |\n+------+--------------+------+-------+\n|    1 | John Doe     |   18 | A     |\n|    3 | Mike Johnson |   19 | A     |\n|    4 | Emily Brown  |   18 | A     |\n|    2 | Jane Smith   |   18 | A     |\n+------+--------------+------+-------+\n4 rows in set (0.00 sec)\n

    In the above examples, a table named students is first created with four columns: id, name, age, and grade. Then, four rows of student data are inserted using the INSERT INTO statement.

    Next, the initial data is viewed using a SELECT statement. Then, an INSERT INTO statement is used to insert a new row of student data where the student with id 2 already exists, causing a duplicate key situation. In this case, the ON DUPLICATE KEY UPDATE clause is used to update that row's data. The columns to be updated, and their corresponding values are specified using the VALUES function.

    Finally, the updated data is viewed again using a SELECT statement, showing that the age and grade of the student with id 2 have been updated.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/","title":"Bulk Load Overview","text":"

    MatrixOne supports using the LOAD DATA command to insert many rows into MatrixOne tables and the SOURCE command to import table structures and data into the entire database.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#load-data","title":"LOAD DATA","text":"

    MatrixOne supports the LOAD DATA command for importing csv and jsonline files from either the local file system or S3-compatible object storage.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#import-the-different-file-types","title":"Import the different file types","text":"

    According to the different file types, MatrixOne currently mainly supports importing .csv or jsonlines:

    • For how to import .csv format, see Load csv format data.
    • For how to import .jl format, see Load jsonlines format data.
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#import-data-from-different-data-storage-locations","title":"Import data from different data storage locations","text":"

    According to the different data storage locations, MatrixOne supports importing data from local and importing data from S3(Simple Storage Service).

    • For how to import data from local host, see Load csv format data or Load jsonlines format data.
    • For how to import data from S3, see Load data from S3.
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#source","title":"SOURCE","text":"

    MatrixOne supports using the SOURCE command to import the entire database structure (including table structures and data) by executing SQL statements from an external SQL script file. The SOURCE command may not perform as well as the LOAD DATA command when processing large amounts of data because it needs to parse and execute each SQL statement.

    • Load data by using the source
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#more-import-capabilities","title":"More import capabilities","text":"
    • MatrixOne supports the parallel loading of data files: when the data file is large, to improve the loading speed, MatrixOne also supports parallel loading, see the LOAD DATA parameter description for importing data.
    • In a MatrixOne distributed cluster, in addition to importing data locally and from the public cloud object storage S3 to MatrixOne, you can also import data through the local Minio component. For details, see Import data from local Minio to MatrixOne
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/","title":"Load csv format data","text":"

    This document will guide you on how to import large amounts of .csv format data to MatrixOne.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#syntax","title":"Syntax","text":"
    • Scenario 1: The data file is in the same machine with the MatrixOne server.
    LOAD DATA\nINFILE 'file_name'\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[LINES\n[STARTING BY 'string']\n[TERMINATED BY 'string']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
    • Scenario 2: The data file is in separate machines with the MatrixOne server.
    LOAD DATA LOCAL\nINFILE 'file_name'\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[LINES\n[STARTING BY 'string']\n[TERMINATED BY 'string']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#before-you-start","title":"Before you start","text":"

    Make sure you have already Deployed and Launched standalone MatrixOne.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#using-the-load-data-command-in-mysql-client","title":"Using the Load data command in MySQL Client","text":"

    You can use Load Data to import data from big data files.

    This section will describe how to import a .csv file.

    Note: A csv(comma-separated values) file is a delimited text file that uses a comma to separate values.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#steps","title":"Steps","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#the-data-file-is-in-the-same-machine-with-the-matrixone-server","title":"The data file is in the same machine with the MatrixOne server","text":"
    1. Before executing Load Data in MatrixOne, the table needs to be created in advance. For now, the data file is required to be at the same machine with MatrixOne server, a file transfer is necessary if they are in separate machines.

    2. Launch the MySQL Client in the MatrixOne local server for accessing the local file system.

      mysql -h 127.0.0.1 -P 6001 -uroot -p111\n

      Info

      The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

    3. Execute LOAD DATA with the corresponding file path in MySQL client.

      mysql> LOAD DATA INFILE '/tmp/xxx.csv'\nINTO TABLE xxxxxx\nFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#the-data-file-is-in-separate-machines-with-the-matrixone-server","title":"The data file is in separate machines with the MatrixOne server","text":"
    1. Before executing LOAD DATA LOCAL in MatrixOne, the table needs to be created in advance.

    2. Launch the MySQL Client in the MatrixOne local server for accessing the local file system.

      mysql -h <mo-host-ip> -P 6001 -uroot -p111 --local-infile\n
    3. Execute LOAD DATA LOCAL with the corresponding file path in MySQL client.

      mysql> LOAD DATA LOCAL INFILE '/tmp/xxx.csv'\nINTO TABLE table_name\nFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#example-using-load-data-with-docker-version","title":"Example using Load data with docker version","text":"

    If you install MatrixOne by docker, the file system is inside the docker image by default. To work with local directory, you need to bind a local directory to the container. In the following example, the local file system path ~/tmp/docker_loaddata_demo/ is binded to the MatrixOne docker image, with a mapping to the /ssb-dbgen-path path inside the docker. We will walk you through the whole process of loading data with MatrixOne 1.0.0-rc1 docker version in this example.

    1. Download the dataset file and store the data in ~/tmp/docker_loaddata_demo/:

      cd ~/tmp/docker_loaddata_demo/\nwget https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/lineorder_flat.tar.bz2\n
    2. Unzip the dataset:

      tar -jxvf lineorder_flat.tar.bz2\n
    3. Use Docker to launch MatrixOne, and mount the directory ~/tmp/docker_loaddata_demo/ that stores data files to a directory in the container. The container directory is /sb-dbgen-path as an example:

      sudo docker run --name matrixone --privileged -d -p 6001:6001 -v ~/tmp/docker_loaddata_demo/:/ssb-dbgen-path:rw matrixorigin/matrixone:1.0.0-rc1\n
    4. Connect to MatrixOne server:

      mysql -h 127.0.0.1 -P 6001 -uroot -p111\n

      Note: If your data file is on a different machine from the MatrixOne server, that is, the data file is on the client machine you are using, then you need to use the command line to connect to the MatrixOne service host: mysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile; and the imported command line needs to use LOAD DATA LOCAL INFILE syntax.

    5. Create lineorder_flat tables in MatrixOne, and import the dataset into MatriOne:

      mysql> create database if not exists ssb;\nmysql> use ssb;\nmysql> drop table if exists lineorder_flat;\nmysql> CREATE TABLE lineorder_flat(\n  LO_ORDERKEY bigint key,\n  LO_LINENUMBER int,\n  LO_CUSTKEY int,\n  LO_PARTKEY int,\n  LO_SUPPKEY int,\n  LO_ORDERDATE date,\n  LO_ORDERPRIORITY char(15),\n  LO_SHIPPRIORITY tinyint,\n  LO_QUANTITY double,\n  LO_EXTENDEDPRICE double,\n  LO_ORDTOTALPRICE double,\n  LO_DISCOUNT double,\n  LO_REVENUE int unsigned,\n  LO_SUPPLYCOST int unsigned,\n  LO_TAX double,\n  LO_COMMITDATE date,\n  LO_SHIPMODE char(10),\n  C_NAME varchar(25),\n  C_ADDRESS varchar(25),\n  C_CITY char(10),\n  C_NATION char(15),\n  C_REGION char(12),\n  C_PHONE char(15),\n  C_MKTSEGMENT char(10),\n  S_NAME char(25),\n  S_ADDRESS varchar(25),\n  S_CITY char(10),\n  S_NATION char(15),\n  S_REGION char(12),\n  S_PHONE char(15),\n  P_NAME varchar(22),\n  P_MFGR char(6),\n  P_CATEGORY char(7),\n  P_BRAND char(9),\n  P_COLOR varchar(11),\n  P_TYPE varchar(25),\n  P_SIZE int,\n  P_CONTAINER char(10)\n);\nmysql> load data infile '/ssb-dbgen-path/lineorder_flat.tbl' into table lineorder_flat FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
    6. After the import is successful, you can run SQL statements to check the rows of imported data:

      select count(*) from lineorder_flat;\n/*\n    expected results:\n */\n+----------+\n| count(*) |\n+----------+\n| 10272594 |\n+----------+\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#constraints","title":"Constraints","text":"

    The loaded csv file format supports JSON. However, you need to ensure that the JSON does not contain field termination symbols. If the JSON does contain field termination symbols, wrap the JSON with double quotation marks. For example:

    • Right csv file example: \"{\"a\":1, \"b\":2}\", 2
    • Wrong csv file example: {\"a\":1, \"b\":2}, 2
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/","title":"Load jsonlines format data","text":"

    This document will guide you on how to import JSONLines (that is .jl or .jsonl file) data to MatrixOne.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#about-jsonlines-format","title":"About JSONLines format","text":"

    JSON(JavaScript Object Notation) is a popular file format for about two decades, nowadays became de-facto of data exchange format standard, replacing XML, that was a huge buzzword in the early 2000's. If you are not familiar with JSON format, please help yourself to know about it with this official documentation.

    JSONLines text format, also called newline-delimited JSON, is a convenient format for storing structured data that may be processed one record at a time. Basically, JSONL is a file format that allows one JSON object per line with lines delimited by a newline character \\n. Each line of the file is independent, so commas are not required at the beginning or ending of lines. Nor does the entire contents of the file need to be enclosed in square or curly braces.

    JSONLines is appealing format for data streaming. Since every new line means a separate entry makes the JSON Lines formatted file streamable. It doesn't require custom parsers. Just read a line, parse as JSON, read a line, parse as JSON\u2026 and so on.

    The JSON Lines format has three requirements:

    • UTF-8 Encoding: JSON allows encoding Unicode strings with only ASCII escape sequences, however those escapes will be hard to read when viewed in a text editor. The author of the JSON Lines file may choose to escape characters to work with plain ASCII files.

    • Each Line is a Valid JSON Value: The most common values will be objects or arrays, but any JSON value is permitted.

    • Line Separator is '\\n': This means '\\r\\n' is also supported because surrounding white space is implicitly ignored when parsing JSON values.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#valid-jsonlines-format-for-matrixone","title":"Valid JSONLines format for MatrixOne","text":"

    JSONLines format only requires a valid JSON value for each line. But MatrixOne requires a more structured JSONLines format, only an JSON object or an JSON array with the same type of values and a plain structure are allowed in MatrixOne. If your JSONLines file has nested structures, MatrixOne doesn't support loading it for now.

    A valid object JSONLines example:

    {\"id\":1,\"father\":\"Mark\",\"mother\":\"Charlotte\"}\n{\"id\":2,\"father\":\"John\",\"mother\":\"Ann\"}\n{\"id\":3,\"father\":\"Bob\",\"mother\":\"Monika\"}\n

    Invalid object JSONLines example (with nested structure):

    {\"id\":1,\"father\":\"Mark\",\"mother\":\"Charlotte\",\"children\":[\"Tom\"]}\n{\"id\":2,\"father\":\"John\",\"mother\":\"Ann\",\"children\":[\"Jessika\",\"Antony\",\"Jack\"]}\n{\"id\":3,\"father\":\"Bob\",\"mother\":\"Monika\",\"children\":[\"Jerry\",\"Karol\"]}\n

    A valid array JSONLines example, it needs to look like a CSV format.

    [\"Name\", \"Session\", \"Score\", \"Completed\"]\n[\"Gilbert\", \"2013\", 24, true]\n[\"Alexa\", \"2013\", 29, true]\n[\"May\", \"2012B\", 14, false]\n[\"Deloise\", \"2012A\", 19, true]\n

    Invalid array JSONLines example (Data type and column numbers don't match): [\"Gilbert\", \"2013\", 24, true, 100] [\"Alexa\", \"2013\", \"twenty nine\", true] [\"May\", \"2012B\", 14, \"no\"] [\"Deloise\", \"2012A\", 19, true, 40]

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#syntax","title":"Syntax","text":"
    • Scenario 1: The data file is in the same machine with the MatrixOne server.
    LOAD DATA INFILE\n    {'filepath'='FILEPATH', 'compression'='COMPRESSION_FORMAT', 'format'='FILE_FORMAT', 'jsondata'='object'/'array'} INTO TABLE table_name [IGNORE x LINES/ROWS] [PARALLEL {'TRUE' | 'FALSE'}];\n
    • Scenario 2: The data file is in separate machines with the MatrixOne server.
    LOAD DATA LOCAL INFILE\n    {'filepath'='FILEPATH', 'compression'='COMPRESSION_FORMAT', 'format'='FILE_FORMAT', 'jsondata'='object'/'array'} INTO TABLE table_name [IGNORE x LINES/ROWS] [PARALLEL {'TRUE' | 'FALSE'}];\n

    Parameter Description

    Parameter Value Required/Optional Description filepath String Required The file path. compression auto/none/bz2/gzip/lz4 Optional Compression algorithm format. format csv/jsonline Optional the loading file format. default is csv. jsondata object/array Optional jsonline format. If format is jsonline, must specify jsondata. table_name String Required table name to load into x Number Optional lines to be ignored while loading

    DDL guidelines for JSONLines format data

    Before load JSONLines data into MatrixOne, we need to firstly create a table. As JSON data type is not the same as MatrixOne data type, we need a guideline for DDL.

    JSON Type MatrixOne Type String VARCHAR (with a certain length limit) String TEXT (without knowing the limit of this string) String DATETIME or TIMESTAMP (with format as \"YYYY-MM-DD HH:MM:SS.XXXXXX\") String DATE (with format as \"YYYY-MM-DD\") String TIME (with format as \"HH-MM-SS.XXXXXX\") Number INT (with interger numbers) Number FLOAT or DOUBLE (with floating numbers) Boolean BOOL(true/false) Object JSON type Array JSON type Null All types have been supported.

    For example, We can create a MatrixOne table with such a DDL for a JSONLines format file as below.

    mysql> create table t1 (name varchar(100), session varchar(100), score int, completed bool);\n
    [\"Name\", \"Session\", \"Score\", \"Completed\"]\n[\"Gilbert\", \"2013\", 24, true]\n[\"Alexa\", \"2013\", 29, true]\n[\"May\", \"2012B\", 14, false]\n[\"Deloise\", \"2012A\", 19, true]\n

    Some examples

    These are some full SQL examples to load a JSONLines file to MatrixOne.

    #Load a BZIP2 compressed jsonline object file\nload data infile {'filepath'='data.bzip2', 'compression'='bz2','format'='jsonline','jsondata'='object'} into table db.a\n\n#Load a plain jsonline array file\nload data infile {'filepath'='data.jl', 'format'='jsonline','jsondata'='array'} into table db.a\n\n#Load a gzip compressed jsonline array file and ignore the first line\nload data infile {'filepath'='data.jl.gz', 'compression'='gzip','format'='jsonline','jsondata'='array'} into table db.a ignore 1 lines;\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#tutorial","title":"Tutorial","text":"

    In this tutorial, we will guide you through loading two jsonline files with object and array jsonformat.

    1. Prepare the data files. You can also download and use the .jl file we prepared. The data directory needs to be with in the same machine as MatrixOne server. The following steps are illustrated with sample data.

      • Example data file 1:jsonline_object.jl
      • Example data file 2:jsonline_array.jl
    2. Open your terminal, enter into the directory where the .jl file resides, and run the following command line to display the contents of the file:

      > cd /$filepath\n> head jsonline_object.jl\n{\"col1\":true,\"col2\":1,\"col3\":\"var\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":121.11}\n{\"col1\":\"true\",\"col2\":\"1\",\"col3\":\"var\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":\"121.11\"}\n{\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":\"121.11\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col1\":\"true\",\"col2\":\"1\",\"col3\":\"var\"}\n{\"col2\":1,\"col3\":\"var\",\"col1\":true,\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col8\":121.11}\n> head jsonline_array.jl\n[true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\"]\n
    3. Install and Launch MatrixOne in the same machine, launch MySQL Client to connect to MatrixOne.

      mysql -h 127.0.0.1 -P 6001 -uroot -p111\n

      Note: If your data file is on a different machine from the MatrixOne server, that is, the data file is on the client machine you are using, then you need to use the command line to connect to the MatrixOne service host: mysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile; and the imported command line needs to use LOAD DATA LOCAL INFILE syntax.

      Info

      The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

    4. Create tables in MatrixOne:

      create database db1;\nuse db1;\ndrop table if exists t1;\ncreate table t1(col1 bool,col2 int,col3 varchar, col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float);\ndrop table if exists t2;\ncreate table t2(col1 bool,col2 int,col3 varchar, col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float);\n
    5. Execute LOAD DATA with the corresponding file path in MySQL client, import the jsonline_object.jl and the file jsonline_array.jl into MatrixOne:

      load data infile {'filepath'='$filepath/jsonline_object.jl','format'='jsonline','jsondata'='object'} into table t1;\nload data infile {'filepath'='$filepath/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t2;\n
    6. After the import is successful, you can run SQL statements to check the results of imported data:

      select * from t1;\ncol1    col2    col3    col4    col5    col6    col7    col8\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\nselect * from t2;\ncol1    col2    col3    col4    col5    col6    col7    col8\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\n

    Note

    If you use Docker to launch MatrixOne, when you try to import the jsonline file, please make sure that you have a data directory mounted to the container. You can check on the load csv tutorial about the loading with docker installation.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/","title":"Load data from S3","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#overview","title":"Overview","text":"

    S3 (Simple Storage Service) object storage refers to Amazon's Simple Storage Service. You can also store almost any type and size of data with S3-compatible object storage, including data lakes, cloud-native applications, and mobile apps. If you are unfamiliar with S3 object service, you may look up some basic introductions in AWS.

    AWS S3 has been remarkably successful for over a decade, so it became the de facto standard for object storage. Thus almost every mainstream public cloud vendors provide an S3-compatible object storage service.

    MatrixOne supports loading files from S3-compatible object storage services into databases. MatrixOne supports AWS and mainstream cloud vendors in China (Alibaba Cloud, Tencent Cloud).

    In MatrixOne, there are two methods to import the data from S3-compatible object storage:

    • Use Load data with an s3option to load the file into MatrixOne. This method will load the data into MatrixOne, and all next queries will happen inside MatrixOne.
    • Create an external table with an s3option mapping to an S3 file, and query this external table directly. This method allows data access through an S3-compatible object storage service; each query's networking latency will be counted.
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#method-1-load-data","title":"Method 1: LOAD DATA","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#syntax","title":"Syntax","text":"
    LOAD DATA\n| URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n

    Parameter Description

    Parameter Description endpoint A endpoint is a URL that can conncect to object storage service. For example: s3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 Bucket to access filepath relative file path. regex expression is supported as /files/*.csv. region object storage service region compression Compressed format of S3 files. If empty or \"none\", it indicates uncompressed files. Supported fields or Compressed format are \"auto\", \"none\", \"gzip\", \"bz2\", and \"lz4\".

    The other paramaters are identical to a ordinary LOAD DATA, see LOAD DATA for more details.

    Statement Examples:

    # LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-mo', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-data', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD a csv file from Tencent Cloud COS Shanghai region, test-1252279971 bucket, without bz2 compression\nLOAD DATA URL s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n

    Note

    MatrixOne provides security assurance for S3 authentication information, such as access_key_id and secret_access_key sensitive information will be hidden in the system table (statement_info) records to ensure your account security.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#tutorial-load-a-file-from-aws-s3","title":"Tutorial: Load a file from AWS S3","text":"

    In this tutorial, we will walk you through the process of loading a .csv file from AWS S3; we assume that you already have an AWS account and already have your data file ready in your S3 service. If you do not already have that, please sign up and upload your data file first; you may check on the AWS S3 official tutorial. The process for Alibaba Cloud OSS and Tencent Cloud COS is similar to AWS S3.

    Note

    This code example does not show account information such as access_key_id and secret_access_key because of account privacy. You can read this document to understand the main steps; specific data and account information will not be shown.

    1. Download the data file. Enter into AWS S3 > buckets, create a bucket test-loading with a public access and upload the file char_varchar_1.csv.

    2. Get or create your AWS api key. Enter into Your Account Name > Security Credentials, get your existing Access Key or create a new one.

      You can get the access key id and secret access key from the downloaded credentials or this webpage.

    3. Launch the MySQL Client, create tables in MatrixOne, for example:

      create database db;\nuse db;\ndrop table if exists t1;\ncreate table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
    4. Import the file into MatrixOne:

      LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
    5. After the import is successful, you can run SQL statements to check the result of imported data:

      mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa,aa     | bb,bb     | cc,cc     | dd,dd     |\n| aa,       | bb,       | cc,       | dd,       |\n| aa,,,aa   | bb,,,bb   | cc,,,cc   | dd,,,dd   |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\",aa    | bb\",bb    | cc\",cc    | dd\",dd    |\n| aa\"\",aa   | bb\"\",bb   | cc\"\",cc   | dd\"\",dd   |\n|           |           |           |           |\n|           |           |           |           |\n| NULL      | NULL      | NULL      | NULL      |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n21 rows in set (0.03 sec)\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#method-2-specify-s3-file-to-an-external-table","title":"Method 2: Specify S3 file to an external table","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#syntax_1","title":"Syntax","text":"
    create external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}     [{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[IGNORE number {LINES | ROWS}];\n

    Note

    MatrixOne only supports select on external tables. Delete, insert, and update are not supported.

    Parameter Description

    Parameter Description endpoint A endpoint is a URL that can conncect to object storage service. For example: s3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 Bucket to access filepath relative file path. regex expression is supported as /files/*.csv. region object storage service region compression Compressed format of S3 files. If empty or \"none\", it indicates uncompressed files. Supported fields or Compressed format are \"auto\", \"none\", \"gzip\", \"bz2\", and \"lz4\".

    The other paramaters are identical to a ordinary LOAD DATA, see LOAD DATA for more details.

    For more information about External Table, see CREATE EXTERNAL TABLE.

    Statement Examples:

    ## Create a external table for a .csv file from AWS S3\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n\n## Create a external table for a .csv file compressed with BZIP2 from Tencent Cloud\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n' ignore 1 lines;\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#tutorial-create-an-external-table-with-s3-file","title":"Tutorial: Create an external table with S3 file","text":"

    This tutorial will walk you through the whole process of creating an external table with a .csv file from AWS S3.

    Note

    This code example does not show account information such as access_key_id and secret_access_key because of account privacy. You can read this document to understand the main steps; specific data and account information will not be shown.

    1. Download the data file. Enter into AWS S3 > buckets, create a bucket test-loading with a public access and upload the file char_varchar_1.csv.

    2. Get or create your AWS api key. Enter into Your Account Name > Security Credentials, get your existing Access Key or create a new one.

      You can get the access key id and secret access key from the downloaded credentials or this webpage.

    3. Launch the MySQL Client, and specify the S3 file to an external table:

      create database db;\nuse db;\ndrop table if exists t1;\ncreate external table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n
    4. After the import is successful, you can run SQL statements to check the result of the imported data. You can see that the query speed is significantly slower than querying from a local table.

      select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa,aa     | bb,bb     | cc,cc     | dd,dd     |\n| aa,       | bb,       | cc,       | dd,       |\n| aa,,,aa   | bb,,,bb   | cc,,,cc   | dd,,,dd   |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\",aa    | bb\",bb    | cc\",cc    | dd\",dd    |\n| aa\"\",aa   | bb\"\",bb   | cc\"\",cc   | dd\"\",dd   |\n|           |           |           |           |\n|           |           |           |           |\n| NULL      | NULL      | NULL      | NULL      |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n21 rows in set (1.32 sec)\n
    5. (Optional)If you need to import external table data into a data table in MatrixOne, you can use the following SQL statement:

      Create a new table t2 in MatrixOne:

      create table t2(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n

      Import the external table t1 to t2:

      insert into t2 select * from t1;\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/","title":"Load data by using the source","text":"

    This document will guide you to use the source command to import data into MatrixOne in batches.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#syntax","title":"Syntax","text":"
    SOURCE /path/to/your/sql_script.sql;\n

    /path/to/your/sql_script.sql is the absolute path to the SQL script file. When executing this command, the client will read the specified SQL script file and execute all its SQL statements.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#tutorial","title":"Tutorial","text":"

    This tutorial will guide you on migrating data from MySQL to MatrixOne using the source command.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#before-you-start","title":"Before you start","text":"

    Make sure you have already Deployed and Launched standalone MatrixOne.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#steps","title":"Steps","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#1-dump-mysql-data","title":"1. Dump MySQL data","text":"

    We suppose you have full access to your MySQL instances.

    Firstly, we use mysqldump to dump MySQL table structures and data to a single file with the following command. You can take a look at this wonderful tutorial if you are not familiar with mysqldump. The syntax is as below:

    mysqldump -h IP_ADDRESS -uUSERNAME -pPASSWORD -d DB_NAME1 DB_NAME2 ... OUTPUT_FILE_NAME.SQL\n

    For example, this following command dumps all table structures and data of the database test to a single file named a.sql.

    mysqldump -h 127.0.0.1 -uroot -proot -d test > a.sql\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#2-import-into-matrixone","title":"2. Import into MatrixOne","text":"

    Import the whole table structures and data into MatrixOne.

    1. Open a MySQL terminal and connect to MatrixOne.
    2. Import the SQL file into MatrixOne by the source command.
    mysql> source '/YOUR_PATH/a.sql'\n

    If your SQL file is big, you can use the following command to run the import task in the background. For example:

    nohup mysql -h 127.0.0.1 -P 6001 -uroot -p111 -e 'source /YOUR_PATH/a.sql' &\n

    Info

    The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

    "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#3-check-data","title":"3. Check data","text":"

    After the import is successful, you can run the following SQL statement to check the import results:

    select * from tool;\n
    "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#constraints","title":"Constraints","text":"

    MatrixOne 1.0.0-rc1 version already supports MySQL table creation statements, so you can smoothly migrate MySQL tables to MatrixOne. However, it should be noted that during the migration process, some keywords incompatible with MySQL, such as engine=, will be automatically ignored in MatrixOne and will not affect the migration of the table structure.

    However, it should be noted that although MatrixOne supports MySQL table creation statements, manual modification is still required if the migrated table contains incompatible data types, triggers, functions, or stored procedures. For more detailed compatibility information, see MySQL Compatibility.

    "},{"location":"MatrixOne/Develop/read-data/cte/","title":"Common Table Expression","text":"

    A CTE (Common table expression) is a named temporary result set that exists only within the execution scope of a single SQL statement (such as SELECT, INSERT, UPDATE, or DELETE).

    Like derived tables, CTEs are not stored as objects and persist only for the duration of query execution; Unlike derived tables, CTEs can be self-referenced or referenced multiple times in the same query. In addition, CTEs provide better readability and performance than derived tables.

    Use Cases:

    • CTEs can reuse the same subquery in multiple places, avoiding redundant logic.
    • They can simplify recursive queries, such as querying tree-structured data.
    • Complex queries can be broken down into smaller parts using CTEs, making the query logic clearer and more understandable.

    Common Table Expressions are divided into two types: non-recursive and recursive:

    • Non-recursive CTE refers to an expression in which the CTE does not reference itself. It is used to build a one-time temporary result set and does not involve recursion. Non-recursive CTE Statement:
    WITH <query_name> AS (\n<query_definition>\n)\nSELECT ... FROM <query_name>;\n
    • Recursive CTE refers to an expression in which the CTE references itself. It handles data with recursive structures, such as trees or graphs. A recursive CTE includes a base query (initial condition) in its definition, then performs recursive operations on the result of that base query until a stop condition is met. Recursive CTE Statement:
    WITH RECURSIVE <query_name> AS (\n<query_definition>\n)\nSELECT ... FROM <query_name>;\n
    "},{"location":"MatrixOne/Develop/read-data/cte/#before-you-start","title":"Before you start","text":"

    Make sure you have already Deployed standalone MatrixOne.

    "},{"location":"MatrixOne/Develop/read-data/cte/#examples-of-using-cte-statements","title":"Examples of Using CTE Statements","text":"

    Suppose we want to create a table named EMPLOYEES that includes a hierarchical relationship among employees. We will then use non-recursive and recursive Common Table Expressions (CTEs) to query the employee hierarchy.

    First, let's create the EMPLOYEES table and insert some sample data:

    CREATE TABLE EMPLOYEES (\nEMPLOYEE_ID INT PRIMARY KEY,\nNAME VARCHAR(50),\nMANAGER_ID INT\n);\n\nINSERT INTO EMPLOYEES (EMPLOYEE_ID, NAME, MANAGER_ID) VALUES\n(1, 'Alice', NULL),\n(2, 'Bob', 1),\n(3, 'Carol', 1),\n(4, 'David', 2),\n(5, 'Eve', 2),\n(6, 'Frank', 3),\n(7, 'Grace', 3),\n(8, 'Hannah', 4),\n(9, 'Ian', 4);\n

    Next, we'll use a recursive CTE to query the employee hierarchy:

    WITH RECURSIVE EmployeeHierarchy AS (\nSELECT EMPLOYEE_ID, NAME, MANAGER_ID, 0 AS LEVEL\nFROM EMPLOYEES\nWHERE MANAGER_ID IS NULL\n\nUNION ALL\n\nSELECT e.EMPLOYEE_ID, e.NAME, e.MANAGER_ID, eh.LEVEL + 1\nFROM EMPLOYEES e\nINNER JOIN EmployeeHierarchy eh ON e.MANAGER_ID = eh.EMPLOYEE_ID\n)\nSELECT * FROM EmployeeHierarchy;\n+-------------+--------+------------+-------+\n| employee_id | name   | manager_id | level |\n+-------------+--------+------------+-------+\n|           1 | Alice  |       NULL |     0 |\n|           2 | Bob    |          1 |     1 |\n|           3 | Carol  |          1 |     1 |\n|           4 | David  |          2 |     2 |\n|           5 | Eve    |          2 |     2 |\n|           6 | Frank  |          3 |     2 |\n|           7 | Grace  |          3 |     2 |\n|           8 | Hannah |          4 |     3 |\n|           9 | Ian    |          4 |     3 |\n+-------------+--------+------------+-------+\n9 rows in set (0.01 sec)\n

    Then, we'll use a non-recursive CTE to query employee information:

    WITH EmployeeInfo AS (\nSELECT EMPLOYEE_ID, NAME, MANAGER_ID\nFROM EMPLOYEES\n)\nSELECT * FROM EmployeeInfo;\n+-------------+--------+------------+\n| employee_id | name   | manager_id |\n+-------------+--------+------------+\n|           1 | Alice  |       NULL |\n|           2 | Bob    |          1 |\n|           3 | Carol  |          1 |\n|           4 | David  |          2 |\n|           5 | Eve    |          2 |\n|           6 | Frank  |          3 |\n|           7 | Grace  |          3 |\n|           8 | Hannah |          4 |\n|           9 | Ian    |          4 |\n+-------------+--------+------------+\n9 rows in set (0.00 sec)\n

    We used a recursive CTE named EmployeeHierarchy, which first selects top-level managers (MANAGER_ID IS NULL), and then recursively joins to find each employee's direct subordinates while keeping track of the hierarchy level. This allows us to query the detailed information of the employee hierarchy using the CTE.

    The non-recursive CTE example selects basic information of all employees from the EMPLOYEES table, including EMPLOYEE_ID, NAME, and MANAGER_ID.

    The RECURSIVE keyword is needed to declare a recursive CTE.

    For more information on using CTEs, see WITH (Common Table Expressions).

    "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/","title":"Multi-table Join Queries","text":"

    In many scenarios, you need to use one query to get data from multiple tables. You can use the JOIN statement to combine the data from two or more tables.

    "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#before-you-start","title":"Before you start","text":"

    Make sure you have already Deployed standalone MatrixOne.

    "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#preparation","title":"Preparation","text":"
    1. Download the dataset:

      https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
    2. Create the database and tables:

      create database d1;\nuse d1;\nCREATE TABLE NATION  ( N_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY));\n\nCREATE TABLE REGION  ( R_REGIONKEY  INTEGER NOT NULL,\nR_NAME       CHAR(25) NOT NULL,\nR_COMMENT    VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY));\n\nCREATE TABLE PART  ( P_PARTKEY     INTEGER NOT NULL,\nP_NAME        VARCHAR(55) NOT NULL,\nP_MFGR        CHAR(25) NOT NULL,\nP_BRAND       CHAR(10) NOT NULL,\nP_TYPE        VARCHAR(25) NOT NULL,\nP_SIZE        INTEGER NOT NULL,\nP_CONTAINER   CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT     VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY));\n\nCREATE TABLE SUPPLIER ( S_SUPPKEY     INTEGER NOT NULL,\nS_NAME        CHAR(25) NOT NULL,\nS_ADDRESS     VARCHAR(40) NOT NULL,\nS_NATIONKEY   INTEGER NOT NULL,\nS_PHONE       CHAR(15) NOT NULL,\nS_ACCTBAL     DECIMAL(15,2) NOT NULL,\nS_COMMENT     VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY));\n\nCREATE TABLE PARTSUPP ( PS_PARTKEY     INTEGER NOT NULL,\nPS_SUPPKEY     INTEGER NOT NULL,\nPS_AVAILQTY    INTEGER NOT NULL,\nPS_SUPPLYCOST  DECIMAL(15,2)  NOT NULL,\nPS_COMMENT     VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY));\n\nCREATE TABLE CUSTOMER ( C_CUSTKEY     INTEGER NOT NULL,\nC_NAME        VARCHAR(25) NOT NULL,\nC_ADDRESS     VARCHAR(40) NOT NULL,\nC_NATIONKEY   INTEGER NOT NULL,\nC_PHONE       CHAR(15) NOT NULL,\nC_ACCTBAL     DECIMAL(15,2)   NOT NULL,\nC_MKTSEGMENT  CHAR(10) NOT NULL,\nC_COMMENT     VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY));\n\nCREATE TABLE ORDERS  ( O_ORDERKEY       BIGINT NOT NULL,\nO_CUSTKEY        INTEGER NOT NULL,\nO_ORDERSTATUS    CHAR(1) NOT NULL,\nO_TOTALPRICE     DECIMAL(15,2) NOT NULL,\nO_ORDERDATE      DATE NOT NULL,\nO_ORDERPRIORITY  CHAR(15) NOT NULL,\nO_CLERK          CHAR(15) NOT NULL,\nO_SHIPPRIORITY   INTEGER NOT NULL,\nO_COMMENT        VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY));\n\nCREATE TABLE LINEITEM ( L_ORDERKEY    BIGINT NOT NULL,\nL_PARTKEY     INTEGER NOT NULL,\nL_SUPPKEY     INTEGER NOT NULL,\nL_LINENUMBER  INTEGER NOT NULL,\nL_QUANTITY    DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE  DECIMAL(15,2) NOT NULL,\nL_DISCOUNT    DECIMAL(15,2) NOT NULL,\nL_TAX         DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG  CHAR(1) NOT NULL,\nL_LINESTATUS  CHAR(1) NOT NULL,\nL_SHIPDATE    DATE NOT NULL,\nL_COMMITDATE  DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE     CHAR(10) NOT NULL,\nL_COMMENT      VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER));\n
    3. Load data into the created tables:

      load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n

    Then you can query data in MatrixOne with the created table.

    "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#join-types","title":"Join Types","text":""},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#inner-join","title":"INNER JOIN","text":"

    The join result of an inner join returns only rows that match the join condition.

    Statement Image SELECT FROM TableA A INNER JOIN TableB B ON A.Key=B.Key

    There are two ways of writing an inner join that are completely equivalent in results:

    mysql> SELECT   l_orderkey,\nSUM(l_extendedprice * (1 - l_discount)) AS revenue,\no_orderdate,\no_shippriority\nFROM\nCUSTOMER,\nORDERS,\nLINEITEM\nWHERE\nc_mktsegment = 'BUILDING'\nAND c_custkey = o_custkey\nAND l_orderkey = o_orderkey\nAND o_orderdate < DATE '1995-03-15'\nAND l_shipdate > DATE '1995-03-15'\nGROUP BY l_orderkey , o_orderdate , o_shippriority\nORDER BY revenue DESC , o_orderdate\nLIMIT 10;\n+------------+---------------------+-------------+----------------+\n| l_orderkey | revenue             | o_orderdate | o_shippriority |\n+------------+---------------------+-------------+----------------+\n|    2456423 | 406181.011100000000 | 1995-03-05  |              0 |\n|    3459808 | 405838.698900000000 | 1995-03-04  |              0 |\n|     492164 | 390324.061000000000 | 1995-02-19  |              0 |\n|    1188320 | 384537.935900000000 | 1995-03-09  |              0 |\n|    2435712 | 378673.055800000000 | 1995-02-26  |              0 |\n|    4878020 | 378376.795200000000 | 1995-03-12  |              0 |\n|    5521732 | 375153.921500000000 | 1995-03-13  |              0 |\n|    2628192 | 373133.309400000000 | 1995-02-22  |              0 |\n|     993600 | 371407.459500000000 | 1995-03-05  |              0 |\n|    2300070 | 367371.145200000000 | 1995-03-13  |              0 |\n+------------+---------------------+-------------+----------------+\n10 rows in set (0.20 sec)\n

    Write as Join, the syntax is as follows:

    mysql> SELECT   l_orderkey,\nSUM(l_extendedprice * (1 - l_discount)) AS revenue,\no_orderdate,\no_shippriority\nFROM\nCUSTOMER\njoin ORDERS on c_custkey = o_custkey\njoin LINEITEM on l_orderkey = o_orderkey\nWHERE\nc_mktsegment = 'BUILDING'\nAND o_orderdate < DATE '1995-03-15'\nAND l_shipdate > DATE '1995-03-15'\nGROUP BY l_orderkey , o_orderdate , o_shippriority\nORDER BY revenue DESC , o_orderdate\nLIMIT 10;\n+------------+---------------------+-------------+----------------+\n| l_orderkey | revenue             | o_orderdate | o_shippriority |\n+------------+---------------------+-------------+----------------+\n|    2456423 | 406181.011100000000 | 1995-03-05  |              0 |\n|    3459808 | 405838.698900000000 | 1995-03-04  |              0 |\n|     492164 | 390324.061000000000 | 1995-02-19  |              0 |\n|    1188320 | 384537.935900000000 | 1995-03-09  |              0 |\n|    2435712 | 378673.055800000000 | 1995-02-26  |              0 |\n|    4878020 | 378376.795200000000 | 1995-03-12  |              0 |\n|    5521732 | 375153.921500000000 | 1995-03-13  |              0 |\n|    2628192 | 373133.309400000000 | 1995-02-22  |              0 |\n|     993600 | 371407.459500000000 | 1995-03-05  |              0 |\n|    2300070 | 367371.145200000000 | 1995-03-13  |              0 |\n+------------+---------------------+-------------+----------------+\n10 rows in set (0.20 sec)\n
    "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#left-join-and-right-join","title":"LEFT JOIN and RIGHT JOIN","text":"

    Outer joins are further divided into left join and right join, and equivalent semantics can be achieved between the two:

    • LEFT JOIN

    The LEFT JOIN returns all the rows in the left table and the values \u200b\u200bin the right table that match the join condition. If no rows are matched in the right table, it will be filled with NULL.

    Statement Image SELECT FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key SELECT FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL
    • RIGHT JOIN

    A RIGHT JOIN returns all the records in the right table and the values \u200b\u200bin the left table that match the join condition. If there is no matching value, it is filled with NULL.

    Statement Image SELECT FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key SELECT FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL

    The example is as below:

    SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n|    147457 |      16 |\n|    147458 |       7 |\n|    147459 |       0 |\n|    147460 |      16 |\n|    147461 |       7 |\n|    147462 |       0 |\n|    147463 |      14 |\n|    147464 |      11 |\n|    147465 |       0 |\n|    147466 |      17 |\n+-----------+---------+\n10 rows in set (0.93 sec)\n

    Or:

    SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nORDERS\nRIGHT OUTER JOIN CUSTOMER ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n|    147457 |      16 |\n|    147458 |       7 |\n|    147459 |       0 |\n|    147460 |      16 |\n|    147461 |       7 |\n|    147462 |       0 |\n|    147463 |      14 |\n|    147464 |      11 |\n|    147465 |       0 |\n|    147466 |      17 |\n+-----------+---------+\n10 rows in set (0.93 sec)\n
    "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#full-join","title":"FULL JOIN","text":"

    A full join is the union of left and right outer joins. The join table contains all records from the joined tables or is filled with NULL if a matching record is missing.

    SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nFULL JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n|         1 |       6 |\n|         2 |       7 |\n|         4 |      20 |\n|         5 |       4 |\n|         7 |      16 |\n|         8 |      13 |\n|        10 |      20 |\n|        11 |      13 |\n|        13 |      18 |\n|        14 |       9 |\n+-----------+---------+\n10 rows in set (0.77 sec)\n

    The full join can also be rewritten to obtain the same semantics:

    SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey\nUNION\nSELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nWHERE c_custkey IS NULL\nGROUP BY c_custkey\nlimit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n|    147457 |      16 |\n|    147458 |       7 |\n|    147459 |       0 |\n|    147460 |      16 |\n|    147461 |       7 |\n|    147462 |       0 |\n|    147463 |      14 |\n|    147464 |      11 |\n|    147465 |       0 |\n|    147466 |      17 |\n+-----------+---------+\n10 rows in set (1.09 sec)\n
    "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#implicit-join","title":"Implicit join","text":"

    Before the JOIN statement that explicitly declared a join was added to the SQL standard, it was possible to join two or more tables in a SQL statement using the FROM t1, t2 clause, and specify the conditions for the join using the WHERE t1.id = t2.id clause. You can understand it as an implicit join, which uses the inner join to join tables.

    "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/","title":"Query Data from a Single Table","text":"

    This document describes how to use SQL to query data from a single table in a database.

    "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#before-you-start","title":"Before you start","text":"

    Make sure you have already Deployed standalone MatrixOne.

    "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#preparation","title":"Preparation","text":"

    Create a database named token_demo firstly:

    CREATE DATABASE token_demo;\nUSE token_demo;\n

    Create a table named token_count to prepare for querying:

    CREATE TABLE token_count (\nid int,\ntoken varchar(100) DEFAULT '' NOT NULL,\ncount int DEFAULT 0 NOT NULL,\nqty int,\nphone char(1) DEFAULT '' NOT NULL,\ntimes datetime DEFAULT '2000-01-01 00:00:00' NOT NULL\n);\nINSERT INTO token_count VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');\nINSERT INTO token_count VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21');\nINSERT INTO token_count VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04');\nINSERT INTO token_count VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53');\nINSERT INTO token_count VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53');\nINSERT INTO token_count VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24');\nINSERT INTO token_count VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12');\nINSERT INTO token_count VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12');\nINSERT INTO token_count VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24');\nINSERT INTO token_count VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36');\nINSERT INTO token_count VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05');\n
    "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#simple-query","title":"Simple query","text":"

    Execute the following SQL statement in a MySQL client:

    mysql> SELECT id, token FROM token_count;\n

    Result is as below:

    +------+----------------------------------+\n| id   | token                            |\n+------+----------------------------------+\n|   21 | e45703b64de71482360de8fec94c3ade |\n|   22 | e45703b64de71482360de8fec94c3ade |\n|   18 | 346d1cb63c89285b2351f0ca4de40eda |\n|   17 | ca6ddeb689e1b48a04146b1b5b6f936a |\n|   16 | ca6ddeb689e1b48a04146b1b5b6f936a |\n|   26 | a71250b7ed780f6ef3185bfffe027983 |\n|   24 | 4d75906f3c37ecff478a1eb56637aa09 |\n|   25 | 4d75906f3c37ecff478a1eb56637aa09 |\n|   27 | a71250b7ed780f6ef3185bfffe027983 |\n|   28 | a71250b7ed780f6ef3185bfffe027983 |\n|   29 | a71250b7ed780f6ef3185bfffe027983 |\n+------+----------------------------------+\n
    "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#filter-results","title":"Filter results","text":"

    To filter query results, you can use the WHERE statement.

    mysql> SELECT * FROM token_count WHERE id = 25;\n

    Result is as below:

    +------+----------------------------------+-------+------+-------+---------------------+\n| id   | token                            | count | qty  | phone | times               |\n+------+----------------------------------+-------+------+-------+---------------------+\n|   25 | 4d75906f3c37ecff478a1eb56637aa09 |     4 | 6500 | y     | 1999-12-23 17:29:12 |\n+------+----------------------------------+-------+------+-------+---------------------+\n
    "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#sort-results","title":"Sort results","text":"

    To sort query results, you can use the ORDER BY statement.

    For example, the following SQL statement can be used to sort the data in the token_count table in descending order (DESC) by times column.

    mysql> SELECT id, token, times FROM token_count ORDER BY times DESC;\n

    Result is as below:

    +------+----------------------------------+---------------------+\n| id   | token                            | times               |\n+------+----------------------------------+---------------------+\n|   29 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:45:05 |\n|   28 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:36 |\n|   26 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n|   27 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n|   24 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n|   25 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n|   21 | e45703b64de71482360de8fec94c3ade | 1999-12-23 17:22:21 |\n|   22 | e45703b64de71482360de8fec94c3ade | 1999-12-23 17:22:21 |\n|   18 | 346d1cb63c89285b2351f0ca4de40eda | 1999-12-23 11:58:04 |\n|   17 | ca6ddeb689e1b48a04146b1b5b6f936a | 1999-12-23 11:36:53 |\n|   16 | ca6ddeb689e1b48a04146b1b5b6f936a | 1999-12-23 11:36:53 |\n+------+----------------------------------+---------------------+\n
    "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#limit-the-number-of-query-results","title":"Limit the number of query results","text":"

    To limit the number of query results, you can use the LIMIT statement.

    mysql> SELECT id, token, times FROM token_count ORDER BY times DESC LIMIT 5;\n

    Result is as below:

    +------+----------------------------------+---------------------+\n| id   | token                            | times               |\n+------+----------------------------------+---------------------+\n|   29 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:45:05 |\n|   28 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:36 |\n|   26 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n|   27 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n|   24 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n+------+----------------------------------+---------------------+\n
    "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#aggregate-queries","title":"Aggregate queries","text":"

    To have a better understanding of the overall data situation, you can use the GROUP BY statement to aggregate query results.

    For example, you can group basic information by id, count, and times columns and count them separately:

    mysql> SELECT id, count, times FROM token_count GROUP BY id, count, times ORDER BY times DESC LIMIT 5;\n

    Result is as below:

    +------+-------+---------------------+\n| id   | count | times               |\n+------+-------+---------------------+\n|   29 |     4 | 1999-12-27 09:45:05 |\n|   28 |     3 | 1999-12-27 09:44:36 |\n|   26 |     5 | 1999-12-27 09:44:24 |\n|   27 |     3 | 1999-12-27 09:44:24 |\n|   24 |     3 | 1999-12-23 17:29:12 |\n+------+-------+---------------------+\n
    "},{"location":"MatrixOne/Develop/read-data/subquery/","title":"Subquery","text":"

    This document describes how to use subquery statements in MatrixOne.

    "},{"location":"MatrixOne/Develop/read-data/subquery/#overview","title":"Overview","text":"

    An subquery is a query within another SQL query. With subquery, the query result can be used in another query.

    In most cases, there are five types of subqueries:

    • Scalar Subquery, such as SELECT (SELECT s1 FROM t2) FROM t1.
    • Derived Tables, such as SELECT t1.s1 FROM (SELECT s1 FROM t2) t1.
    • Existential Test, such as WHERE NOT EXISTS(SELECT ... FROM t2), WHERE t1.a IN (SELECT ... FROM t2).
    • Quantified Comparison, such as WHERE t1.a = ANY(SELECT ... FROM t2), WHERE t1.a = ANY(SELECT ... FROM t2).
    • Subquery as a comparison operator operand, such as WHERE t1.a > (SELECT ... FROM t2).

    For more information on SQL statement, see SUBQUERY.

    In addition, from the execution of SQL statements, subquery generally has the following two types:

    • Correlated Subquery: In Correlated Subquery nested in databases, the inner and outer queries would not be independent, and the inner queries would depend on the outer queries.The execution sequence is as follows:

      • Queries a record from the outer query.

      • Put the queried records into the inner query, then put the records that meet the conditions into the outer query.

      • Repeat the above steps

      For example: select * from tableA where tableA.cloumn &lt; (select column from tableB where tableA.id = tableB.id))

    • Self-contained Subquery: In a database nested query, the inner query is entirely independent of the outer query. The execution sequence is as follows:

      • Execute the inner query first.

      • The result of the inner query is carried into the outer layer, and then the outer query is executed.

      For example: select * from tableA where tableA.column = (select tableB.column from tableB)

    Key Feature:

    • Subqueries allow structured queries so that each part of a query statement can be separated.

    • Subqueries provides another way to perform operations that require complex JOIN and UNION.

    "},{"location":"MatrixOne/Develop/read-data/subquery/#example","title":"Example","text":""},{"location":"MatrixOne/Develop/read-data/subquery/#before-you-start","title":"Before you start","text":"

    Make sure you have already Deployed standalone MatrixOne.

    "},{"location":"MatrixOne/Develop/read-data/subquery/#preparation","title":"Preparation","text":"
    1. Download the dataset:

      https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
    2. Create the database and tables:

      create database d1;\nuse d1;\nCREATE TABLE NATION  ( N_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY));\n\nCREATE TABLE REGION  ( R_REGIONKEY  INTEGER NOT NULL,\nR_NAME       CHAR(25) NOT NULL,\nR_COMMENT    VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY));\n\nCREATE TABLE PART  ( P_PARTKEY     INTEGER NOT NULL,\nP_NAME        VARCHAR(55) NOT NULL,\nP_MFGR        CHAR(25) NOT NULL,\nP_BRAND       CHAR(10) NOT NULL,\nP_TYPE        VARCHAR(25) NOT NULL,\nP_SIZE        INTEGER NOT NULL,\nP_CONTAINER   CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT     VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY));\n\nCREATE TABLE SUPPLIER ( S_SUPPKEY     INTEGER NOT NULL,\nS_NAME        CHAR(25) NOT NULL,\nS_ADDRESS     VARCHAR(40) NOT NULL,\nS_NATIONKEY   INTEGER NOT NULL,\nS_PHONE       CHAR(15) NOT NULL,\nS_ACCTBAL     DECIMAL(15,2) NOT NULL,\nS_COMMENT     VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY));\n\nCREATE TABLE PARTSUPP ( PS_PARTKEY     INTEGER NOT NULL,\nPS_SUPPKEY     INTEGER NOT NULL,\nPS_AVAILQTY    INTEGER NOT NULL,\nPS_SUPPLYCOST  DECIMAL(15,2)  NOT NULL,\nPS_COMMENT     VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY));\n\nCREATE TABLE CUSTOMER ( C_CUSTKEY     INTEGER NOT NULL,\nC_NAME        VARCHAR(25) NOT NULL,\nC_ADDRESS     VARCHAR(40) NOT NULL,\nC_NATIONKEY   INTEGER NOT NULL,\nC_PHONE       CHAR(15) NOT NULL,\nC_ACCTBAL     DECIMAL(15,2)   NOT NULL,\nC_MKTSEGMENT  CHAR(10) NOT NULL,\nC_COMMENT     VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY));\n\nCREATE TABLE ORDERS  ( O_ORDERKEY       BIGINT NOT NULL,\nO_CUSTKEY        INTEGER NOT NULL,\nO_ORDERSTATUS    CHAR(1) NOT NULL,\nO_TOTALPRICE     DECIMAL(15,2) NOT NULL,\nO_ORDERDATE      DATE NOT NULL,\nO_ORDERPRIORITY  CHAR(15) NOT NULL,\nO_CLERK          CHAR(15) NOT NULL,\nO_SHIPPRIORITY   INTEGER NOT NULL,\nO_COMMENT        VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY));\n\nCREATE TABLE LINEITEM ( L_ORDERKEY    BIGINT NOT NULL,\nL_PARTKEY     INTEGER NOT NULL,\nL_SUPPKEY     INTEGER NOT NULL,\nL_LINENUMBER  INTEGER NOT NULL,\nL_QUANTITY    DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE  DECIMAL(15,2) NOT NULL,\nL_DISCOUNT    DECIMAL(15,2) NOT NULL,\nL_TAX         DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG  CHAR(1) NOT NULL,\nL_LINESTATUS  CHAR(1) NOT NULL,\nL_SHIPDATE    DATE NOT NULL,\nL_COMMITDATE  DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE     CHAR(10) NOT NULL,\nL_COMMENT      VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER));\n
    3. Load data into the created tables:

      load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n

    Then you can query data in MatrixOne with the created table.

    "},{"location":"MatrixOne/Develop/read-data/subquery/#self-contained-subquery","title":"Self-contained subquery","text":"

    For a self-contained subquery that uses subquery as operand of comparison operators (>, >=, <, <=, = , or ! =), the inner subquery queries only once, and MatrixOne rewrites it as a constant during the execution plan phase.

    mysql> select p.p_name from (select * from part where p_brand='Brand#21' and p_retailprice between 1100 and 1200)  p, partsupp ps where p.p_partkey=ps.ps_partkey and p.p_name like '%pink%' limit 10;\n

    The inner subquery is executed before MatrixOne executes the above query:

    mysql> select * from part where p_brand='Brand#21' and p_retailprice between 1100 and 1200\n

    Result is as below:

    +-----------------------------------+\n| p_name                            |\n+-----------------------------------+\n| olive chartreuse smoke pink tan   |\n| olive chartreuse smoke pink tan   |\n| olive chartreuse smoke pink tan   |\n| olive chartreuse smoke pink tan   |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| honeydew orchid cyan magenta pink |\n| honeydew orchid cyan magenta pink |\n+-----------------------------------+\n10 rows in set (0.06 sec)\n

    For self-contained subqueries such as Existential Test and Quantified Comparison, MatrixOne rewrites and replaces them with equivalent queries for better performance.

    "},{"location":"MatrixOne/Develop/read-data/subquery/#correlated-subquery","title":"Correlated subquery","text":"

    For correlated subquery, because the inner subquery references the columns from the outer query, each subquery is executed once for each row of the outer query. That is, assuming that the outer query gets 10 million results, the subquery will also be executed 10 million times, which will consume more time and resources.

    Therefore, in the process of processing, MatrixOne will try to Decorrelate of Correlated Subquery to improve the query efficiency at the execution plan level.

    mysql> select p_name from part where P_PARTKEY in (select PS_PARTKEY from PARTSUPP where PS_SUPPLYCOST>=500) and p_name like '%pink%' limit 10;\n

    Rewrites it to an equivalent join query:

    select p_name from part join partsupp on P_PARTKEY=PS_PARTKEY where PS_SUPPLYCOST>=500 and p_name like '%pink%' limit 10;\n

    Result is as below:

    +------------------------------------+\n| p_name                             |\n+------------------------------------+\n| papaya red almond hot pink         |\n| turquoise hot smoke green pink     |\n| purple cornsilk red pink floral    |\n| pink cyan purple white burnished   |\n| sandy dark pink indian cream       |\n| powder cornsilk chiffon slate pink |\n| rosy light black pink orange       |\n| pink white goldenrod ivory steel   |\n| cornsilk dim pink tan sienna       |\n| lavender navajo steel sandy pink   |\n+------------------------------------+\n10 rows in set (0.23 sec)\n

    As a best practice, in actual development, it is recommended to avoid querying through a correlated subquery if you can write another equivalent query with better performance.

    "},{"location":"MatrixOne/Develop/read-data/views/","title":"Views","text":"

    This document describes how to use views in MatrixOne.

    "},{"location":"MatrixOne/Develop/read-data/views/#overview","title":"Overview","text":"

    A view acts as a virtual table, whose schema is defined by the SELECT statement that creates the view.

    Key Feature:

    • Simplified user action: The view mechanism allows users to focus on the data they care about. If the data is not directly from the base table, you can define views to make the database look simple and simplify the user's data query operation.

    • Multiple perspectives on the same data: The view mechanism enables different users to view the same data differently, which is necessary when many users share the same database.

    • Provides a degree of logical independence for refactoring the database: Physical data independence means that the user's application does not depend on the physical structure of the database. The logical independence of the data indicates that when the database is restructured, such as adding new relationships or adding new fields to existing relationships, the user's application is not affected. Hierarchical databases and mesh databases can support the physical independence of data but can not fully support logical independence.

    "},{"location":"MatrixOne/Develop/read-data/views/#before-you-start","title":"Before you start","text":"

    Make sure you have already Deployed standalone MatrixOne.

    "},{"location":"MatrixOne/Develop/read-data/views/#preparation","title":"Preparation","text":"

    Create two tables to prepare for using the VIEW:

    CREATE TABLE t00(a INTEGER);\nINSERT INTO t00 VALUES (1),(2);\nCREATE TABLE t01(a INTEGER);\nINSERT INTO t01 VALUES (1);\n

    Query the table t00:

    mysql> select * from t00;\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n+------+\n

    Query the table t01:

    mysql> select * from t01;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n
    "},{"location":"MatrixOne/Develop/read-data/views/#create-a-view","title":"Create a view","text":"

    A complex query can be defined as a view with the CREATE VIEW statement. The syntax is as follows:

    CREATE VIEW view_name AS query;\n

    you cannot create a view with the same name as an existing view or table.

    Example:

    CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\nQuery OK, 0 rows affected (0.02 sec)\n
    "},{"location":"MatrixOne/Develop/read-data/views/#query-views","title":"Query views","text":"

    Once a view is created, you can use the SELECT statement to query the view just like a normal table.

    mysql> SELECT * FROM v0;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    1 |\n|    2 | NULL |\n+------+------+\n
    "},{"location":"MatrixOne/Develop/read-data/views/#get-view-related-information","title":"Get view related information","text":"

    Use the SHOW CREATE TABLE|VIEW view_name statement:

    mysql> SHOW CREATE VIEW v0;\n+------+----------------------------------------------------------------------------+\n| View | Create View                                                                |\n+------+----------------------------------------------------------------------------+\n| v0   | CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a) |\n+------+----------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Develop/read-data/views/#drop-view","title":"Drop view","text":"

    Use the DROP VIEW view_name; statement to drop a view.

    mysql> DROP VIEW v0;\n
    "},{"location":"MatrixOne/Develop/read-data/window-function/","title":"Window Function","text":"

    Window Function (Window Function) is a unique function that can perform calculation operations on a specific window (Window) of the query result set. Window functions can be used to group, sort, and aggregate the result set and calculate the relevant value of each row of data within each window without changing the number of rows in the result set. That is, the result set can be flexibly analyzed and processed through the window function without introducing additional subqueries or join operations.

    SQL window functions have a wide range of applications in various business scenarios:

    1. Intra-row comparison: Compare a specific value of each row with other rows in the same group, such as calculating the difference between each employee's salary and the department's average salary. At this time, you can use window functions.

    2. Data ranking: The window function can quickly generate data ranking information. For example, you can use the RANK() or ROW_NUMBER() function to check the sales ranking.

    3. Rolling Calculation: Calculate the moving average. You can define the window range of the window function and then perform rolling calculations.

    "},{"location":"MatrixOne/Develop/read-data/window-function/#list-of-window-functions","title":"List of window functions","text":"
    • Most aggregate functions can also be used as window functions, for example, SUM(), AVG(), and COUNT(). These aggregate functions can be used with window functions to calculate the value of a column within a window Sum, average, or count. For aggregate functions and reference documents supported by MatrixOne that can be used as window functions, see:

      • AVG
      • COUNT
      • MAX
      • SUM
      • MIN
    • See the table below for other window functions:

    Function name description DENSE_RANK() Used to assign ranks to rows in a dataset, always assigning consecutive ranks to the next value, even if previous values \u200b\u200bhave the same rank. RANK() Assigns a rank value to each row in the query result set, rows with the same value will have the same rank, and the next rank value will skip the same number of rows. ROW_NUMBER() Assigns a unique integer value to each row in the query result set, ordered according to the specified collation."},{"location":"MatrixOne/Develop/read-data/window-function/#how-to-use-window-functions","title":"How to use window functions","text":"

    Using window functions usually requires the following steps:

    1. Define the window (Window): By using the OVER clause to define the scope of the window, you can specify the sorting rules, partition method and row range of the window, etc.

    2. Write the window function: In the SELECT statement, list the window function together with other columns, and specify the columns and operations that need to be calculated within the window.

    Here is an example of how to use window functions to calculate the total sales for each department and the sales rank for each employee within the department:

    CREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\nSELECT\nDepartment,\nEmployee,\nSales,\nSUM(Sales) OVER(PARTITION BY Department) AS DepartmentSales,\nRANK() OVER(PARTITION BY Department ORDER BY Sales DESC) AS SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------------+-----------+\n| department | employee | sales | DepartmentSales | SalesRank |\n+------------+----------+-------+-----------------+-----------+\n| HR         | Charlie  |   850 |            1650 |         1 |\n| HR         | Alice    |   800 |            1650 |         2 |\n| Marketing  | Jane     |  1200 |            2200 |         1 |\n| Marketing  | John     |  1000 |            2200 |         2 |\n| Sales      | Bob      |  1100 |            2000 |         1 |\n| Sales      | Alex     |   900 |            2000 |         2 |\n+------------+----------+-------+-----------------+-----------+\n6 rows in set (0.01 sec)\n

    In the above example, the PARTITION BY clause is used to partition the result set by the department, and then the SUM() function calculates the total sales for each department. Also, the ORDER BY clause specifies sorting in descending order by sales, and the RANK() function assigns ranks to employees within each department based on sales.

    "},{"location":"MatrixOne/Develop/schema-design/create-database/","title":"Create a Database","text":"

    This document describes how to create a database using SQL and various programming languages and lists the rules of database creation. In this document, the modatabase application is taken as an example to walk you through the steps of database creation.

    "},{"location":"MatrixOne/Develop/schema-design/create-database/#before-you-start","title":"Before you start","text":"

    Before creating a database, do the following:

    • Build a MatrixOne Cluster in MatrixOne.
    • Read the Database Schema Design Overview.
    "},{"location":"MatrixOne/Develop/schema-design/create-database/#what-is-database","title":"What is database","text":"

    Database objects in MatrixOne contain tables, views and other objects.

    "},{"location":"MatrixOne/Develop/schema-design/create-database/#create-databases","title":"Create databases","text":"

    To create a database, you can use the CREATE DATABASE statement.

    CREATE DATABASE IF NOT EXISTS `modatabase`;\n

    For more information on CREATE DATABASE statement, see CREATE DATABASE.

    "},{"location":"MatrixOne/Develop/schema-design/create-database/#view-databases","title":"View databases","text":"

    To view the databases in a cluster, use the SHOW DATABASES statement.

    SHOW DATABASES;\n

    The following is an example output:

    +--------------------+\n| Database           |\n+--------------------+\n| mo_catalog         |\n| system             |\n| system_metrics     |\n| mysql              |\n| information_schema |\n| modatabase         |\n+--------------------+\n
    "},{"location":"MatrixOne/Develop/schema-design/create-database/#rules-in-database-creation","title":"Rules in database creation","text":"
    • Follow the Database Naming Conventions and name your database meaningfully.

    • You can create your own database using the CREATE DATABASE statement and change the current database using the USE {databasename}; statement in a SQL session.

    • Use the account user or user to create objects such as database, roles, and new users. Grant only the necessary privileges to roles and users. For more information, see Access control in MatrixOne.

    "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/","title":"Create a secondary index","text":""},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#what-is-a-secondary-index","title":"What is a secondary index","text":"

    Indexes identified on non-primary keys and secondary indexes are also called non-clustered indexes, which are used to improve query performance and speed up data retrieval. The secondary index does not directly store table data. Still, it indexes a part of the data (such as a column), allowing the database system to locate the table rows containing specific values quickly.

    Secondary indexes can help speed up query operations, especially when querying large tables. Secondary indexes can also support sorting, grouping, and join operations, which usually require sorting or matching a portion of the data in the table.

    "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#before-you-start","title":"Before you start","text":"

    Before reading this document, make sure that the following tasks are completed:

    • Build a MatrixOne Cluster in MatrixOne.
    • Read the Database Schema Design Overview.
    • The database has been created.
    "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#use-secondary-index","title":"Use secondary index","text":"

    Create a secondary index. You can create a secondary index through theCREATE INDEX statement, specify the column for which the index is aimed, and other indexing options.

    The syntax structure is'CREATE INDEX index_name on table_name (column_name);

    index_name is the name of the index, table_name is the name of the table on which the index is to be created, and column_name is the name of the column used to create the index.

    For example, if you want to create a secondary index on the last_name column of a table named employees, you can use the following SQL statement:

    CREATE INDEX idx_lastname ON employees (last_name);\n

    Use a secondary index: You can use a secondary index in a query statement to locate data rows. The SQL query optimizer will automatically select the appropriate index to perform the query operation for the best performance. Such as:

    SELECT * FROM employees WHERE last_name = 'Smith';\n

    In this example, the query optimizer will use the idx_lastname index to locate the data row whose last_name is smith.

    It should be noted that creating an index will increase the storage and maintenance costs of the database, and it may also affect performance when inserting, updating, and deleting data. Therefore, when creating a secondary index, it is necessary to carefully consider its impact on database performance and make the necessary optimizations and adjustments.

    "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#examples","title":"Examples","text":"
    CREATE TABLE users (id INT PRIMARY KEY,\nname VARCHAR(50),\nage INT,\nemail VARCHAR(50)\n);\n-- create a secondary index on the table to speed up the speed of querying users by name\nCREATE INDEX idx_users_name ON users(name);\n-- Insert data\nINSERT INTO users VALUES ('1', 'John', '30', 'john@gmail.com');\nINSERT INTO users VALUES ('2', 'Tommy', '50', 'tom@gmail.com');\nINSERT INTO users VALUES ('3', 'Ann', '33', 'ann@gmail.com');\n-- Perform the following query, the database can use the secondary index to quickly find all users with the name 'John' without having to scan the entire table\nmysql> SELECT * FROM users WHERE name = 'John';\n+------+------+------+----------------+\n| id   | name | age  | email          |\n+------+------+------+----------------+\n|    1 | John |   30 | john@gmail.com |\n+------+------+------+----------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#constraints","title":"Constraints","text":"

    Currently MatrixOne only implements secondary indexes syntactically, and does not achieve performance improvements.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/","title":"Create a Table","text":"

    This document introduces how to create tables using the SQL statement and the related best practices. In the previous document, you created a database named modatabase. In this document, you will create a table in the database.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/#before-you-start","title":"Before you start","text":"

    Before reading this document, make sure that the following tasks are completed:

    • Build a MatrixOne Cluster in MatrixOne.
    • Read the Database Schema Design Overview.
    • The database has been created.
    "},{"location":"MatrixOne/Develop/schema-design/create-table/#what-is-a-table","title":"What is a table","text":"

    A table is a logical object in MatrixOne cluster that is subordinate to the database. It is used to store the data.

    Tables save data records in the form of rows and columns. A table has at least one column. If you have defined n columns, each row of data has exactly the same fields as the n columns.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/#name-a-table","title":"Name a table","text":"

    The first step for creating a table is to give your table a name. Do not use meaningless names that will cause great distress to yourself or your colleagues in the future. It is recommended that you follow your company or organization's table naming convention.

    The CREATE TABLE statement usually takes the following form:

    CREATE TABLE {table_name} ({elements});\n

    For more information on CREATE TABLE statement, see CREATE TABLE.

    Parameter description

    • {table_name}: The name of the table to be created.

    • {elements}: A comma-separated list of table elements, such as column definitions and primary key definitions.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/#define-columns","title":"Define columns","text":"

    A column is subordinate to a table. Each table has at least one column. Columns provide a structure to a table by dividing the values in each row into small cells of a single data type.

    Column definitions typically take the following form.

    {column_name} {data_type} {column_qualification}\n

    Parameter description

    • {column_name}: The column name.
    • {data_type}: The column data type.
    • {column_qualification}: Column qualifications.

    Suppose you need to create a table to store the NATION information in the modatabase database.

    CREATE TABLE NATION(\nN_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\n);\n

    Explanations

    The following table explains the fields in the above example:

    Field name Data type Function Explanation N_NATIONKEY INTEGER The unique identifier of the nation All identifiers should be of type INTEGER N_NAME CHAR Ethnic name Ethnic name is char type, and no more than 25 characters N_REGIONKEY INTEGER Region code, unique identifier All identifiers should be of type INTEGER N_COMMENT VARCHAR comment information varchar type, and no more than 152 characters

    MatrixOne supports many other column data types, including the integer types, floating-point types, date and time types. For more information, see Data Types.

    Create a complex table

    Create a new table named ORDERS.

    CREATE TABLE ORDERS(\nO_ORDERKEY       BIGINT NOT NULL,\nO_CUSTKEY        INTEGER NOT NULL,\nO_ORDERSTATUS    CHAR(1) NOT NULL,\nO_TOTALPRICE     DECIMAL(15,2) NOT NULL,\nO_ORDERDATE      DATE NOT NULL,\nO_ORDERPRIORITY  CHAR(15) NOT NULL,\nO_CLERK          CHAR(15) NOT NULL,\nO_SHIPPRIORITY   INTEGER NOT NULL,\nO_COMMENT        VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY)\n);\n

    This table contains more data types than the NATION table:

    Field name Data type Function Explanation O_TOTALPRICE DECIMAL O_TOTALPRICE is used to mark the price The precision is 15, and the scale is 2; that is, the accuracy represents the total number of digits in the field value, and the scale means how many digits there are after the decimal point, for example decimal(5,2), that is, the precision is 5 when the ratio is 2, its value ranges from -999.99 to 999.99. decimal(6,1), when the accuracy is 6, and the scale is 1, its value range is from -99999.9 to 99999.9. O_ORDERDATE DATE Date value Date of the order"},{"location":"MatrixOne/Develop/schema-design/create-table/#select-primary-key","title":"Select primary key","text":"

    A primary key is a column or a set of columns in a table whose values uniquely identify a row in the table.

    The primary key is defined in the CREATE TABLE statement. The primary key constraint requires that all constrained columns contain only non-NULL values.

    A table can be created without a primary key or with a non-integer primary key.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/#set-default-value","title":"Set default value","text":"

    To set a default value on a column, use the DEFAULT constraint. The default value allows you to insert data without specifying a value for each column.

    You can use DEFAULT together with supported SQL functions to move the calculation of defaults out of the application layer, thus saving resources of the application layer. The resources consumed by the calculation do not disappear and are moved to the MatrixOne cluster. The following exemplifies setting the default value in the t1 table:

    create table t1(a int default (1), b int);\ninsert into t1(b) values(1), (1);\n> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    1 |\n|    1 |    1 |\n+------+------+\n2 rows in set (0.01 sec)\n

    The default value of a is 1.

    You can also set the default value to the time when the value was inserted; see the simple example below:

    -- Create the table and set the default value to the current time\nCREATE TABLE t2 (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ncreated_at DATETIME DEFAULT NOW()\n);\n\nINSERT INTO t2 (id, name) VALUES\n(1, 'John'),\n(2, 'Jane'),\n(3, 'Mike');\n\n> SELECT * FROM t2;\n+------+------+---------------------+\n| id | name | created_at |\n+------+------+---------------------+\n| 1 | John | 2023-07-10 11:57:27 |\n| 2 | Jane | 2023-07-10 11:57:27 |\n| 3 | Mike | 2023-07-10 11:57:27 |\n+------+------+---------------------+\n3 rows in set (0.00 sec)\n

    After executing the above insert statement, each row's created_at column will be automatically set to the current time.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/#prevent-duplicate-values","title":"Prevent duplicate values","text":"

    If you need to prevent duplicate values in a column, you can use the UNIQUE constraint.

    For example, to make sure that N_NATIONKEY are unique, you can rewrite the table creation SQL statement for the NATION table like this:

    CREATE TABLE NATION(\nN_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nUNIQUE KEY (N_NATIONKEY)\n);\n

    If you try to insert the same value ofN_NATIONKEY in the NATION table, an error is returned.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/#prevent-null-values","title":"Prevent null values","text":"

    If you need to prevent null values in a column, you can use the NOT NULL constraint.

    Use the nation's name as an example. In addition to the unique value of the national, it is also hoped that the name of the nation cannot be empty, so here you can write the creation SQL of the NATION table as follows:

    CREATE TABLE NATION(\nN_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY)\n);\n
    "},{"location":"MatrixOne/Develop/schema-design/create-table/#execute-the-show-tables-statement","title":"Execute the SHOW TABLES statement","text":"

    To view all tables under the modatabase database, use the SHOW TABLES statement.

    SHOW TABLES IN `modatabase`;\n

    Running results:

    +----------------------+\n| tables_in_modatabase |\n+----------------------+\n| nation               |\n| orders               |\n+----------------------+\n
    "},{"location":"MatrixOne/Develop/schema-design/create-table/#guidelines-to-follow-when-creating-a-table","title":"Guidelines to follow when creating a table","text":"

    This section provides guidelines you need to follow when creating a table.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/#guidelines-to-follow-when-naming-a-table","title":"Guidelines to follow when naming a table","text":"
    • Use a fully-qualified table name (for example, CREATE TABLE {database_name}. {table_name}). If you do not specify the database name, MatrixOne uses the current database in your SQL session. If you do not use USE {databasename}; to specify the database in your SQL session, MatrixOne returns an error.

    • Use meaningful table names. For example, if you need to create a NATION table, you can use names: NATION, t_user,users, or follow your company or organization's naming convention.

    • Multiple words are separated by an underscore, and it is recommended that the name is no more than 32 characters.

    • Create a separate DATABASE for tables of different business modules and add comments accordingly.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/#guidelines-to-follow-when-defining-columns","title":"Guidelines to follow when defining columns","text":"
    • Check the data types supported.

    • Check the guidelines to follow for selecting primary keys and decide whether to use primary key columns.

    • Check adding column constraints and decide whether to add constraints to the columns.

    • Use meaningful column names. It is recommended that you follow your company or organization's table naming convention. If your company or organization does not have a corresponding naming convention, refer to the column naming convention.

    "},{"location":"MatrixOne/Develop/schema-design/create-table/#guidelines-to-follow-when-selecting-primary-key","title":"Guidelines to follow when selecting primary key","text":"
    • Define a primary key or unique index within the table.
    • Try to select meaningful columns as primary keys.
    • For performance reasons, try to avoid storing extra-wide tables. It is not recommended that the number of table fields is over 60 and that the total data size of a single row is over 64K. It is recommended to split fields with too much data length to another table.
    • It is not recommended to use complex data types.
    • For the fields to be joined, ensure that the data types are consistent and avoid implicit conversion.
    • Avoid defining primary keys on a single monotonic data column. If you use a single monotonic data column (for example, a column with the AUTO_INCREMENT attribute) to define the primary key, it might impact the write performance.
    "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/","title":"Create Temporary Table","text":""},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#what-is-a-temporary-table","title":"What is a temporary table","text":"

    A temporary table is a unique one that is only visible in the current session after creation. At the end of the current session, the database automatically drops the temporary table and frees all space; you can also use the DROP TABLE to drop the temporary table.

    You can use temporary tables to hold some intermediate results in a session; for example, you may need to query these results multiple times, or these results are a subset of other queries.

    "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#advantages-of-temporary-tables","title":"Advantages of temporary tables","text":"

    Temporary tables have several uses and advantages in database design:

    • Data Isolation: Temporary tables are independent in each session or transaction. This means that two temporary tables with the same name can exist in two different sessions without affecting each other.

    • Simplify complex queries: If a query is very complex and involves multiple joins and subqueries, you can save the query results to a temporary table and then perform operations on this temporary table, thereby simplifying the query and improving performance.

    • Improve performance: Saving data in temporary tables can significantly improve query performance for complex queries with large data sets. The access speed is fast because the temporary table is stored in memory.

    • Protect data: Use temporary tables to avoid modification of original data. When you need to perform operations that may change the original data, you can store the data in a temporary table and then perform functions on the temporary table to avoid changing the original data by mistake.

    • Save storage space: Temporary tables are automatically deleted when no longer needed, saving storage space.

    • Helpful for debugging: In complex nested queries, temporary tables can store intermediate results to help debug and verify the output of each step.

    Note that temporary tables are not omnipotent, they also have some limitations, such as being only accessible within the current session, and once the session ends, the temporary table disappears.

    "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#before-you-start","title":"Before you start","text":"

    Before reading this document, make sure that the following tasks are completed:

    • Build a MatrixOne Cluster in MatrixOne.
    • Read the Database Schema Design Overview.
    • The database has been created.
    "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#how-to-use-temporary-tables","title":"How to use temporary tables","text":"

    The syntax for using a temporary table is the same as for a regular table, except that the TEMPORARY keyword is added before the statement that creates the table:

    CREATE TEMPORARY TABLE temp_table_name (column_list);\n

    You can use the same table name for temporary and regular tables without conflicts because they are in different namespaces. However, two temporary tables cannot share the same name in the session.

    Note

    1. Even though temporary tables can have the same name as permanent tables, it is not recommended as this may result in unexpected data loss. For example, if the connection to the database server is lost and you automatically reconnect to the server, you cannot distinguish between temporary and permanent tables. Then, you issue a DROP TABLE statement. This time, the permanent table may be deleted instead of the temporary table. This result is unpredictable.
    2. When you use the 'SHOW TABLES' command to display a list of data tables, you cannot see a list of temporary tables either.
    "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#example","title":"Example","text":"
    -- Create a temporary table 'temp_employees'\nCREATE TEMPORARY TABLE temp_employees (\nemployee_id INT AUTO_INCREMENT, -- auto-increment employee ID\nfirst_name VARCHAR(50), -- employee name\nlast_name VARCHAR(50), -- employee last name\nemail VARCHAR(100), -- employee email address\nPRIMARY KEY (employee_id) -- set 'employee_id' as the primary key\n);\n\n-- Insert some data into the 'temp_employees' table\nINSERT INTO temp_employees (first_name, last_name, email)\nVALUES ('John', 'Doe', 'john.doe@example.com'),\n('Jane', 'Doe', 'jane.doe@example.com'),\n('Jim', 'Smith', 'jim.smith@example.com'),\n('Jack', 'Johnson', 'jack.johnson@example.com'),\n('Jill', 'Jackson', 'jill.jackson@example.com');\n\n-- Query the temporary table to view all employee information\nSELECT * FROM temp_employees;\n+-------------+------------+-----------+--------------------------+\n| employee_id | first_name | last_name | email                    |\n+-------------+------------+-----------+--------------------------+\n|           1 | John       | Doe       | john.doe@example.com     |\n|           2 | Jane       | Doe       | jane.doe@example.com     |\n|           3 | Jim        | Smith     | jim.smith@example.com    |\n|           4 | Jack       | Johnson   | jack.johnson@example.com |\n|           5 | Jill       | Jackson   | jill.jackson@example.com |\n+-------------+------------+-----------+--------------------------+\n5 rows in set (0.01 sec)\n\n-- At the end of this session, the temporary table 'temp_employees' will be dropped automatically\n
    "},{"location":"MatrixOne/Develop/schema-design/create-view/","title":"Create View","text":""},{"location":"MatrixOne/Develop/schema-design/create-view/#what-is-view","title":"What is View","text":"

    View is a visual, read-only virtual table based on the result set of an SQL statement, whose content is defined by the query. Unlike ordinary tables (tables that store data), views do not contain data but are only formatted displays of query results based on the base table (the table being queried). You can think of a view as a window on a table; the data in this window is reflected on other tables. When a view is queried, the database applies its SQL query to its underlying tables.

    "},{"location":"MatrixOne/Develop/schema-design/create-view/#advantages-of-views","title":"Advantages of Views","text":"
    • Simplify queries: For complex queries, you can create views to hide the complexity of the query, and you only need to select data from the view without remembering complex query statements.

    • Add an extra layer of security: Views can restrict user's access to specific database fields and only display the fields they need to see, which can protect the security of the data.

    • Maintain data consistency: Creating a view can maintain data consistency if multiple queries need to use the same query clause.

    • Logical abstraction: Views can represent functional parts of base table data, summaries, and information from several tables.

    But Views also have disadvantages:

    • Performance: Querying data from a database view can be slow, especially if the view is created based on other views.

    • Depends on other tables: A view will be created based on the underlying tables of the database. Not all views support updating data, depending on the definition of the view and its underlying tables.

    "},{"location":"MatrixOne/Develop/schema-design/create-view/#before-you-start","title":"Before you start","text":"

    Before reading this document, make sure that the following tasks are completed:

    • Build a MatrixOne Cluster in MatrixOne.
    • Read the Database Schema Design Overview.
    • The database has been created.
    "},{"location":"MatrixOne/Develop/schema-design/create-view/#how-to-use-views","title":"How to use views","text":"

    The syntax for creating a view is as follows:

    CREATE VIEW view_name AS\nSELECT column1, column2, ...\nFROM table_name\nWHERE condition;\n

    After creating a view, you can query it like any other table:

    SELECT column1, column2, ...\nFROM view_name;\n
    "},{"location":"MatrixOne/Develop/schema-design/create-view/#example","title":"Example","text":"
    -- Create a table called 'orders'\nCREATE TABLE orders (\norder_id INT AUTO_INCREMENT,\ncustomer_id INT,\norder_date DATE,\norder_amount DOUBLE,\nPRIMARY KEY (order_id)\n);\n\n-- Insert some data into the 'orders' table\nINSERT INTO orders (customer_id, order_date, order_amount)\nVALUES (1, '2023-01-01', 99.99),\n(1, '2023-01-03', 29.99),\n(2, '2023-01-03', 49.99),\n(3, '2023-01-05', 89.99),\n(1, '2023-01-07', 59.99),\n(2, '2023-01-07', 19.99);\n\n-- Create a view called 'order_summary' that shows the total order quantity and total order amount for each customer\nCREATE VIEW order_summary AS\nSELECT customer_id, COUNT(*) as order_count, SUM(order_amount) as total_amount\nFROM orders\nGROUP BY customer_id;\n\n--  Query view\nmysql> SELECT *\nFROM order_summary;\n+-------------+-------------+--------------+\n| customer_id | order_count | total_amount |\n+-------------+-------------+--------------+\n|           1 |           3 |       189.97 |\n|           2 |           2 |        69.98 |\n|           3 |           1 |        89.99 |\n+-------------+-------------+--------------+\n3 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Develop/schema-design/overview/","title":"Database Schema Design Overview","text":"

    This document provides the basics of MatrixOne database schema design. This document introduces terminology related to MatrixOne databases and subsequent data read and write examples.

    "},{"location":"MatrixOne/Develop/schema-design/overview/#key-concept-in-matrixone","title":"Key concept in MatrixOne","text":"

    Database Schema: The database schema mentioned in this article is the same as the logical object database. It is the same as MySQL.

    "},{"location":"MatrixOne/Develop/schema-design/overview/#database","title":"Database","text":"

    A database in MatrixOne is a collection of objects such as tables.

    To view the default database contained by MatrixOne, ues SHOW DATABASES; statment.

    To create a new database, ues CREATE DATABASE database_name; statement.

    "},{"location":"MatrixOne/Develop/schema-design/overview/#table","title":"Table","text":"

    A table is a collection of related data in a database.

    Each table consists of rows and columns. Each value in a row belongs to a specific column. Each column allows only a single data type. To further qualify columns, you can add some constraints.

    "},{"location":"MatrixOne/Develop/schema-design/overview/#index","title":"Index","text":"

    An index is a data structure used to find data in database tables quickly. It can be seen as a 'table of contents' that contains pointers to the data of each row in the table, making it possible for queries to locate data that meets specific conditions more quickly.

    The indexes commonly used in databases include primary key indexes, secondary indexes, etc. Among them, unique indexes are used to ensure the uniqueness of specific columns or combinations of columns, ordinary indexes are used to improve query performance, and full-text indexes are used for full-text search in text data.

    There are two common types of indexes, namely:

    • Primary Key: Primary key index, that is, the index that identifies the primary key column. The primary key index uniquely identifies each row of data in the table.
    • Secondary index: Secondary index is the index identified on the non-primary key. The secondary index, also called a non-clustered index, is used to improve query performance and speed up data retrieval.
    "},{"location":"MatrixOne/Develop/schema-design/overview/#other-supported-logical-objects","title":"Other supported logical objects","text":"

    MatrixOne supports the following logical objects at the same level as table:

    • View: a view acts as a virtual table, whose schema is defined by the SELECT statement that creates the view.

    • Temporary table: a table whose data is not persistent.

    "},{"location":"MatrixOne/Develop/schema-design/overview/#access-control","title":"Access Control","text":"

    MatrixOne supports both user-based and role-based access control. To allow users to view, modify, or delete data, for more information, see Access control in MatrixOne.

    "},{"location":"MatrixOne/Develop/schema-design/overview/#object-limitations","title":"Object limitations","text":""},{"location":"MatrixOne/Develop/schema-design/overview/#limitations-on-identifier-length","title":"Limitations on identifier length","text":"Identifier type Maximum length (number of characters allowed) Database 64 Table 64 Column 64 Sequence 64"},{"location":"MatrixOne/Develop/schema-design/overview/#limitations-on-a-single-table","title":"Limitations on a single table","text":"Type Upper limit (default value) Columns Defaults to 1017 and can be adjusted up to 4096 Partitions 8192 Size of a single line 6 MB by default Size of a single column 6 MB"},{"location":"MatrixOne/Develop/schema-design/overview/#limitations-on-data-types","title":"Limitations on data types","text":"

    For more information on data types, see Data Types.

    "},{"location":"MatrixOne/Develop/schema-design/overview/#number-of-rows","title":"Number of rows","text":"

    MatrixOne supports an unlimited number of rows by adding nodes to the cluster.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/","title":"AUTO INCREMENT Constraint","text":"

    The Auto-Increment Constraint is a feature in MatrixOne that automatically generates a unique identifier value for a column in a table. When inserting new rows, it allows you to automatically generate an incrementing unique value for the specified auto-increment column. This feature is handy in many cases, such as for primary keys or identifiers.

    Auto-Increment Constraint Features

    The Auto-Increment Constraint simplifies the generation and management of identifiers. When using an auto-increment column, there are a few things to keep in mind:

    • Auto-increment columns are usually used as primary keys, so their uniqueness should be ensured.
    • The data type of the auto-increment column should be chosen appropriately based on the requirements, typically an integer type.
    • The values of the auto-increment column are automatically generated when inserting new rows and cannot be manually specified.
    • The auto-increment values are unique within the table and automatically increment with subsequent insert operations.
    • The auto-increment value's starting value and increment step can be customized by modifying the table definition.

    Please use the auto-increment constraint to simplify the generation and management of identifiers based on the specific table structure and requirements, ensuring data integrity and uniqueness.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#syntax","title":"Syntax","text":"

    When creating a table, you can define an auto-increment constraint for a column. Typically, the data type of the auto-increment column is an integer type such as INT or BIGINT. To add an auto-increment constraint to a column, use the AUTO_INCREMENT keyword when creating the table.

    CREATE TABLE table_name (\ncolumn_name data_type AUTO_INCREMENT,\n...\nPRIMARY KEY (primary_key_column)\n);\n
    • table_name: The name of the table.
    • column_name: The column's name to be defined as auto-increment.
    • data_type: The data type of the column, usually an integer type such as INT or BIGINT.
    • primary_key_column: The primary key column of the table.
    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#example","title":"Example","text":"

    Here is an example of creating a table with an auto-increment column:

    -- Create an employees' table with an 'id' column defined as an auto-increment column. The 'id' column has a data type of 'INT' and the auto-increment constraint is specified using the 'AUTO_INCREMENT' keyword. The 'id' column is set as the table's primary key.\nCREATE TABLE employees (\nid INT AUTO_INCREMENT,\nname VARCHAR(50),\ndepartment VARCHAR(50),\nPRIMARY KEY (id)\n);\n\n-- Insert data into the table and let the auto-increment column generate unique identifier values. No values are specified for the 'id' column, and an incrementing unique value is automatically generated for the 'id' column when inserting new rows. The value of the 'id' column will automatically increment with each new row inserted.\nINSERT INTO employees (name, department)\nVALUES ('John Doe', 'HR'),\n('Jane Smith', 'Marketing'),\n('Mike Johnson', 'IT');\n\n-- The 'id' column values will be auto-incremented, generating a unique identifier value for each new row inserted.\nmysql> SELECT * FROM employees;\n+------+--------------+------------+\n| id   | name         | department |\n+------+--------------+------------+\n|    1 | John Doe     | HR         |\n|    2 | Jane Smith   | Marketing  |\n|    3 | Mike Johnson | IT         |\n+------+--------------+------------+\n3 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#constraints","title":"Constraints","text":"
    1. MatrixOne currently does not support modifying auto-increment values' starting and increment steps using the ALTER TABLE statement.
    2. In MatrixOne, only syntax supports using the system variable set @@auto_increment_increment=n to set the incremental step size, and only syntax supports using the system variable set @@auto_increment_offset=n to set the default auto-increment column initial value, but it does not take effect; currently supports setting the initial value AUTO_INCREMENT=n of the auto-increment column, but the step size is still 1 by default.
    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/","title":"FOREIGN KEY integrity constraints","text":"

    FOREIGN KEY constraints can keep related data consistent when cross-referencing associated data across tables.

    Rules

    When defining FOREIGN KEY, the following rules need to be followed:

    • The parent table must already exist in the database or be a table currently being created. In the latter case, the parent table and the slave table are the same table, such a table is called a self-referential table, and this structure is called self-referential integrity.

    • A primary key must be defined for the parent table.

    • Primary keys cannot contain null values, but null values are allowed in foreign keys. In other words, as long as every non-null value in the foreign key appears in the specified primary key, the content of the foreign key is correct.

    • Specify the column name or combination of column names after the table name of the parent table. This column or combination of columns must be the primary or candidate key of the primary table.

    • The number of columns in the foreign key must be the same as the number of columns in the primary key of the parent table.

    • The data type of the column in the foreign key must be the same as the data type of the corresponding column in the primary key of the parent table.

    • The foreign key's value must be consistent with the primary key's value in the main table.

    Foreign Key Characteristics

    • Multi-column foreign key: This type of foreign key is when two or more columns in a table jointly reference another table's primary key. In other words, these columns together define the reference to another table. They must exist in the form of a group and need to meet the foreign key constraint simultaneously.

    • Multi-level foreign key: This situation usually involves three or more tables, and they have a dependency relationship. A table's foreign key can be another table's primary key, and this table's foreign key can be the primary key of a third table, forming a multi-level foreign key situation.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#syntax","title":"Syntax","text":"

    Foreign keys are defined in the child table, and the primary foreign key constraint syntax is as follows:

    > CREATE TABLE child_table (\n    ...,\n    foreign_key_column data_type,\n    FOREIGN KEY (foreign_key_column) REFERENCES parent_table (parent_key_column)\n    [ON DELETE reference_option]\n    [ON UPDATE reference_option]\n);\n\nreference_option:\n    RESTRICT | CASCADE | SET NULL | NO ACTION\n

    Explanation

    In the above syntax structure of a foreign key constraint, the following are explanations for each parameter:

    • child_table: The name of the child table, which contains the foreign key.
    • foreign_key_column: The column's name in the child table references the parent table.
    • data_type: The data type of the foreign key column.
    • parent_table: The name of the referenced parent table.
    • parent_key_column: The name of the primary key column in the parent table establishing the relationship.
    • [ON DELETE reference_option]: An optional parameter used to specify actions to be taken when records in the parent table are deleted.
      • RESTRICT: If related foreign key data exists in the referenced table, deletion of data in the table is not allowed. This prevents accidental deletion of related data, ensuring data consistency.
      • CASCADE: When data in the referenced table is deleted, associated foreign key data is also deleted. This is used for cascading deletion of related data to maintain data integrity.
      • SET NULL: When data in the referenced table is deleted, the value of the foreign key column is set to NULL. This is used to retain foreign key data while disconnecting it from the referenced data upon deletion.
      • NO ACTION: Indicates no action is taken; it only checks for the existence of associated data. This is similar to RESTRICT but may have minor differences in some databases.
    • [ON UPDATE reference_option]: An optional parameter used to specify actions to be taken when records in the parent table are updated. Possible values are the same as [ON DELETE reference_option].

    These parameters collectively define a foreign key constraint, ensuring the data integrity relationship between the child and parent tables.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#examples","title":"Examples","text":""},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#example-1","title":"Example 1","text":"
    -- Create a table named t1, containing two columns: a and b. The column a is of type int and is set as the primary key, while the column b is of type varchar with a length of 5.\ncreate table t1(a int primary key, b varchar(5));\n\n-- Create a table named t2, containing three columns: a, b, and c. The column a is of type int, the column b is of type varchar with a length of 5. The column c is of type int, and is set as a foreign key, establishing a relationship with the column a in table t1.\ncreate table t2(a int ,b varchar(5), c int, foreign key(c) references t1(a));\n\n-- Insert two rows of data into table t1: (101, 'abc') and (102, 'def').\nmysql> insert into t1 values(101,'abc'),(102,'def');\nQuery OK, 2 rows affected (0.01 sec)\n\n-- Insert two rows of data into table t2: (1, 'zs1', 101) and (2, 'zs2', 102), where 101 and 102 are the primary keys in table t1.\nmysql> insert into t2 values(1,'zs1',101),(2,'zs2',102);\nQuery OK, 2 rows affected (0.01 sec)\n\n-- Insert a row of data into table t2: (3, 'xyz', null), where null means that this row of data has no associated primary key in column c (the foreign key column).\nmysql> insert into t2 values(3,'xyz',null);\nQuery OK, 1 row affected (0.01 sec)\n\n-- Attempt to insert a row of data into table t2: (3, 'xxa', 103). However, 103 does not exist in the primary keys of table t1, so the insertion fails due to violation of the foreign key constraint.\nmysql> insert into t2 values(3,'xxa',103);\nERROR 20101 (HY000): internal error: Cannot add or update a child row: a foreign key constraint fails\n

    Example Explanation: In the above example, column c of t2 can only refer to the value or null value of column a in t1, so the operation of inserting row 1 and row 2 of t1 can be successfully inserted, but row 3 103 in the row is not a value in column a of t1, which violates the foreign key constraint, so the insert fails.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#example-2-multi-column-foreign-key","title":"Example 2 - Multi-column foreign key","text":"
    -- Creating a \"Student\" table to store student information\nCREATE TABLE Student (\nStudentID INT, -- Student ID field, integer\nName VARCHAR(100), -- Student name field, string with a maximum length of 100\nPRIMARY KEY (StudentID) -- Setting the StudentID as the primary key of this table\n);\n\n-- Creating a \"Course\" table to store course information\nCREATE TABLE Course (\nCourseID INT, -- Course ID field, integer\nCourseName VARCHAR(100), -- Course name field, string with a maximum length of 100\nPRIMARY KEY (CourseID) -- Setting the CourseID as the primary key of this table\n);\n\n-- Creating a \"StudentCourse\" table to store student course selection information\nCREATE TABLE StudentCourse (\nStudentID INT, -- Student ID field, integer, corresponds to the StudentID field in the Student table.\nCourseID INT, -- Course ID field, integer, corresponds to the CourseID field in the Course table.\nPRIMARY KEY (StudentID, CourseID), -- Setting the combination of StudentID and CourseID as the primary key of this table\nFOREIGN KEY (StudentID) REFERENCES Student(StudentID), -- Setting the StudentID field as the foreign key, referencing the StudentID field in the Student table\nFOREIGN KEY (CourseID) REFERENCES Course(CourseID) -- Setting the CourseID field as the foreign key, referencing the CourseID field in the Course table\n);\n

    Example Explanation: In the above example, there are three tables: the Student table, the Course table, and the StudentCourse table for recording which students have chosen which courses. In this case, the Student ID and Course ID in the course selection table can serve as foreign keys, jointly referencing the primary keys of the student table and the course table.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#example-3-multi-level-foreign-key","title":"Example 3 - Multi-level foreign key","text":"
    -- Creating a \"Country\" table to store country information\nCREATE TABLE Country (\nCountryID INT, -- Country ID field, integer\nCountryName VARCHAR(100), -- Country name field, string with a maximum length of 100\nPRIMARY KEY (CountryID) -- Setting the CountryID as the primary key of this table\n);\n\n-- Creating a \"State\" table to store state/province information\nCREATE TABLE State (\nStateID INT, -- State/province ID field, integer\nStateName VARCHAR(100), -- State/province name field, string with a maximum length of 100\nCountryID INT, -- Country ID field, integer, corresponds to the CountryID field in the Country table.\nPRIMARY KEY (StateID), -- Setting the StateID as the primary key of this table\nFOREIGN KEY (CountryID) REFERENCES Country(CountryID) -- Setting the CountryID field as the foreign key, referencing the CountryID field in the Country table\n);\n\n-- Creating a \"City\" table to store city information\nCREATE TABLE City (\nCityID INT, -- City ID field, integer\nCityName VARCHAR(100), -- City name field, string with a maximum length of 100\nStateID INT, -- State/province ID field, integer, corresponds to the StateID field in the State table\nPRIMARY KEY (CityID), -- Setting the CityID as the primary key of this table\nFOREIGN KEY (StateID) REFERENCES State(StateID) -- Setting the StateID field as the foreign key, referencing the StateID field in the State table\n);\n

    Example Explanation: In the above example, there are three tables: the Country table, the State table, and the City table. The State table has a field, CountryID, which is the primary key of the Country table and is also the foreign key of the State table. The City table has a field, StateID, which is the State table's primary key and the City table's foreign key. This forms a multi-level foreign key situation.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/","title":"NOT NULL integrity constraints","text":"

    The NOT NULL constraint can restrict a column from containing NULL values.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/#syntax","title":"Syntax","text":"
    > column_name data_type NOT NULL;\n

    You cannot insert a NULL value into a column that contains a NOT NULL constraint or update an old value to NULL.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/#examples","title":"Examples","text":"
    create table t1(a int not null,b int);\nmysql> insert into t1 values(null,1);\nERROR 3819 (HY000): constraint violation: Column 'a' cannot be null\nmysql> insert into t1 values(1,null);\nQuery OK, 1 row affected (0.01 sec)\nmysql> update t1 set a=null where a=1;\nERROR 3819 (HY000): constraint violation: Column 'a' cannot be null\n

    Example Explanation: In the above example, because there is a non-null constraint in column a, the execution of the first insert statement will fail, the second statement satisfies the non-null constraint in column a, and there is no non-null constraint in column b so that it can be inserted successfully. The update statement fails because it triggers the non-null constraint of column a.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/","title":"Data Integrity Constraints Overview","text":"

    In MatrixOne, to ensure the data's correctness, integrity, and validity, restrictions are added to specific columns in the table creation statement to ensure that the information stored in the database complies with specific rules. These restrictions are called constraints. For example, if the execution result of a DML statement violates the integrity constraint, the statement will be rolled back, and an error message will be returned.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/#integrity-constraints-types","title":"Integrity Constraints Types","text":"

    There are various constraints in MatrixOne, and different constraints have different restrictions on database behavior. Currently, supported constraints are table-level constraints:

    • NOT NULL integrity constraints:

    The non-null constraint means that the data in a specific column cannot have a null value (NULL), and the data that violates the constraint cannot be inserted or updated in the corresponding column. In MatrixOne, a table can have zero, one, or more not-null constraints.

    • UNIQUE KEY integrity constraints

    The unique key constraint means that in a specific column or a combination of multiple columns stored in a table, the value of this column (or column set) in the inserted or updated data row is unique. In MatrixOne, zero, one, or more unique key constraints are allowed in a table, but unlike other relational databases, the unique key constraints of MatrixOne must also be non-empty.

    • PRIMARY KEY integrity constraints

      The primary key constraint means that in a specific column or a combination of multiple columns stored in a table, each data row can be uniquely determined by a specific key value and is not empty. There can only be, at most, one primary key constraint in a table.

    • FOREIGN KEY integrity constraints

    A foreign key constraint means that a column or columns in another table reference a column or a combination of columns stored in one table. The referenced table is usually called the parent table, and the referenced table is called the child table. The child table refers to the data of the corresponding column of the parent table, which can only be the data or null value of the parent table. This kind of constraint is called a foreign key constraint.

    • AUTO INCREMENT constraint

    An auto-increment constraint is a feature that automatically generates a unique identifying value for a column in a table. It allows you to automatically generate an incremental unique value for a specified auto-increment column when a new row is inserted.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/","title":"PRIMARY KEY integrity constraints","text":"

    PRIMARY KEY constraints can be used to ensure that a key value uniquely identifies each data row in a table. And at most, one PRIMARY KEY constraint can be defined on each database table.

    Rules

    When defining PRIMARY KEY, the following rules need to be followed:

    • Uniqueness: The value of the primary key column must be unique; each row in the table must have a different primary key value.

    • Non-nullness: The values \u200b\u200bof the primary key columns cannot be null, i.e., they cannot contain NULL values.

    • Immutability: The value of the primary key column cannot be changed or updated after insertion. This is to keep the primary key unique. If you need to change the primary key value, you usually need to delete the original row first and then insert a new one with the new primary key value.

    • Minimality: The primary key can be composed of a single column or a combination of multiple columns. Composite primary keys can uniquely identify rows, but their composite values \u200b\u200bmust be unique and cannot have repeated combinations.

    • Referential integrity: The primary key is usually used as a reference for the foreign key (Foreign Key).

    • Automatically create indexes: Primary key columns will automatically create indexes to improve retrieval performance.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#syntax","title":"Syntax","text":"
    > column_name data_type PRIMARY KEY;\n
    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#examples","title":"Examples","text":"
    mysql> create table t1(a int primary key, b int, c int, primary key(b,c));\nERROR 20301 (HY000): invalid input: more than one primary key defined\nmysql> create table t2(a int, b int, c int, primary key(b,c));\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t3(a int, b int, c int, primary key(a));\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t2 values(1,1,1);\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> insert into t2 values(1,1,2);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert into t3 values(1,1,1);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert into t3 values(2,1,1);\nQuery OK, 1 row affected (0.01 sec)\n

    Example Explanation: In the above example, t1 contains two sets of primary keys, so the creation fails. t2 and t3 have only one set of primary keys so they can be created. None of the four insert statements violated the constraints, and all were executed successfully.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#constraints","title":"Constraints","text":"

    MatrixOne does not currently support deleting PRIMARY KEY constraints.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/","title":"UNIQUE KEY integrity constraints","text":"

    The UNIQUE KEY constraint can be used to ensure that the values \u200b\u200bof the columns or column groups of the data rows to be inserted or updated are unique and that the values \u200b\u200bof a column or a column set in any two rows of the table are not repeated. The unique key must also be non-Null.

    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/#syntax","title":"Syntax","text":"
    > column_name data_type UNIQUE KEY;\n
    "},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/#examples","title":"Examples","text":"
    create table t1(a int unique key, b int, c int, unique key(b,c));\nmysql> insert into t1 values(1,1,1);\nQuery OK, 1 row affected (0.01 sec)\nmysql> insert into t1 values(2,1,1);\nERROR 20307 (HY000): Duplicate entry '3a15013a1501' for key '__mo_index_idx_col'\nmysql> insert into t1 values(1,1,2);\nERROR 20307 (HY000): Duplicate entry '1' for key '__mo_index_idx_col'\n

    Example Explanation: In the above example, there are two unique key constraints in column a and columns (b,c). When inserting data, the second insert statement violates the unique constraint of (b,c) and duplicates the value of the first insert, so the insert fails. The third insert statement violates the constraint on column a, so the insert fails.

    "},{"location":"MatrixOne/FAQs/deployment-faqs/","title":"Deployment FAQs","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#operating-system-requirements","title":"Operating system requirements","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#what-are-the-required-operating-system-versions-for-deploying-matrixone","title":"What are the required operating system versions for deploying MatrixOne?","text":"

    MatrixOne supports the following operating system:

    Linux OS Version Debian 11.0 or later Ubuntu LTS 20.04 or later Red Hat Enterprise Linux 9.0 or later releases Oracle Enterprise Linux 9.0 or later releases

    MatrixOne also supports macOS operating system, but it's only recommended to run as a test and development environment.

    macOS Version macOS Monterey 12.3 or later"},{"location":"MatrixOne/FAQs/deployment-faqs/#hardware-requirements","title":"Hardware requirements","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#what-are-the-required-hardware-for-deploying-matrixone","title":"What are the required hardware for deploying MatrixOne?","text":"

    For standalone installation, MatrixOne can be running on the 64-bit generic hardware server platform in the Intel x86-64 and ARM architecture. The requirements and recommendations about server hardware configuration for development, testing and production environments are as follows:

    • Development and testing environments
    CPU Memory Local Storage 4 core+ 16 GB+ SSD/HDD 200 GB+

    The Macbook M1/M2 with ARM architecture is also a good fit for a development environment.

    • Production environment
    CPU Memory Local Storage 16 core+ 64 GB+ SSD/HDD 500 GB+

    For comprehensive details on deploying MatrixOne in a distributed setting, see Cluster Topology Planning Overview. This guide includes specific server hardware configuration requirements and recommendations tailored for development, testing, and production environments.

    "},{"location":"MatrixOne/FAQs/deployment-faqs/#installation-and-deployment","title":"Installation and deployment","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#what-settings-do-i-need-to-change-for-installation","title":"What settings do I need to change for installation?","text":"

    Normally you don't need to change anything for installation. A default setting of launch.toml is enough to run MatrixOne directly. But if you want to customize your listening port, ip address, stored data files path, you may modify the corresponding records of cn.toml, tn.toml or log.toml, for more details about parameter configuration in these files, see Boot Parameters for standalone installation.

    "},{"location":"MatrixOne/FAQs/deployment-faqs/#after-the-mysql-client-is-installed-i-open-the-terminal-and-run-mysql-i-got-an-error-of-command-not-found-mysql","title":"After the MySQL client is installed, I open the terminal and run mysql, I got an error of command not found: mysql.","text":"

    To solve the error, you need to set the environment variable. Open a new terminal window, run the following command:

    Linux EnvironmentMacOS Environment
    echo 'export PATH=\"/path/to/mysql/bin:$PATH\"' >> ~/.bash_profile\nsource ~/.bash_profile\n

    Replace /path/to/mysql/bin in the above code with the MySQL installation path in your system. Usually, it is /usr/local/mysql/bin; if you are not sure about the installation path of MySQL, you can use the following command to find it:

    whereis mysql\n

    After macOS 10, zsh is used as the default shell. Here, zsh is used as an example. If you use other shells, you can convert it yourself.

    echo export PATH=/path/to/mysql/bin:$PATH >> ~/.zshrc\nsource ~/.zshrc\n

    Replace /path/to/mysql/bin in the above code with the MySQL installation path in your system. Usually, it is /usr/local/mysql/bin; if you are not sure about the installation path of MySQL, you can use the following command to find it:

    whereis mysql\n
    "},{"location":"MatrixOne/FAQs/deployment-faqs/#when-i-install-matrixone-by-building-from-source-i-got-an-error-of-the-following-and-the-build-failed-how-can-i-proceed","title":"When I install MatrixOne by building from source, I got an error of the following and the build failed, how can I proceed?","text":"

    Error: Get \"https://proxy.golang.org/........\": dial tcp 142.251.43.17:443: i/o timeout

    As MatrixOne needs many go libraries as dependency, it downloads them at the time of building it. This is an error of downloading timeout, it's mostly a networking issue. If you are using a Chinese mainland network, you need to set your go environment to a Chinese image site to accelerate the go library downloading. If you check your go environment by go env, you may see GOPROXY=\"https://proxy.golang.org,direct\", you need to set it by

    go env -w GOPROXY=https://goproxy.cn,direct\n

    Then the make build should be fast enough to finish.

    "},{"location":"MatrixOne/FAQs/deployment-faqs/#when-i-want-to-save-the-matrixone-data-directory-to-my-specified-file-directory-how-should-i-do-it","title":"When I want to save the MatrixOne data directory to my specified file directory, how should I do it?","text":"
    • When you use Docker to start MatrixOne, you can mount the data directory you specify to the Docker container, see Mount directory to Docker container.

    • When you use the source code or binary package to compile and start MatrixOne, you can modify the default data directory path in the configuration file: open the MatrixOne source file directory matrixone/etc /launch-with-proxy, modify the configuration parameter data-dir = \"./mo-data\" in the three files of cn.toml, tn.toml and log.toml is data-dir = \"your_local_path\", save and restart MatrixOne It will take effect.

    "},{"location":"MatrixOne/FAQs/deployment-faqs/#when-i-was-testing-matrixone-with-mo-tester-i-got-an-error-of-too-many-open-files","title":"When I was testing MatrixOne with MO-tester, I got an error of too many open files?","text":"

    MO-tester will open and close many SQL files in a high speed to test MatrixOne, this kind of usage will easily reach the maximum open file limit of Linux and macOS, which is the reason for the too many open files error.

    • For MacOS, you can just set the open file limit by a simple command:
    ulimit -n 65536\n
    • For Linux, please refer to this detailed guide to set the ulimit to 100000.

    After setting this value, there will be no more too many open files error.

    "},{"location":"MatrixOne/FAQs/deployment-faqs/#ssb-dbgen-cannot-be-compiled-on-a-pc-with-m1-chip","title":"Ssb-dbgen cannot be compiled on a PC with M1 chip","text":"

    To complete the following configuration, then compiling 'SSB-DBgen' for a PC with M1 chip:

    1. Download and install GCC11.

    2. To ensure the gcc-11 is successful installed, run the following command:

      gcc-11 -v\n

      The successful result is as below:

      Using built-in specs.\nCOLLECT_GCC=gcc-11\nCOLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc@11/11.3.0/bin/../libexec/gcc/aarch64-apple-darwin21/11/lto-wrapper\nTarget: aarch64-apple-darwin21\nConfigured with: ../configure --prefix=/opt/homebrew/opt/gcc@11 --libdir=/opt/homebrew/opt/gcc@11/lib/gcc/11 --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-11 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 11.3.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --build=aarch64-apple-darwin21 --with-system-zlib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk\nThread model: posix\nSupported LTO compression algorithms: zlib zstd\ngcc version 11.3.0 (Homebrew GCC 11.3.0)\n
    3. Modify the bm_utils.c file in the ssb-dbgen directory:

      • Change the #include <malloc.h> in line 41 to #include <sys/malloc.h>

      • Change the open(fullpath, ((*mode == 'r')?O_RDONLY:O_WRONLY)|O_CREAT|O_LARGEFILE,0644); in line 398 to open(fullpath, ((*mode == 'r')?O_RDONLY:O_WRONLY)|O_CREAT,0644);

    4. Modify the varsub.c file in the ssb-dbgen directory:

      • Change the #include <malloc.h> in line 5 to #include <sys/malloc.h>
    5. Modify the makefile file in the ssb-dbgen directory:

      • Change the CC = gcc in line 5 to CC = gcc-11
    6. Enter into ssb-dbgen directory again and compile:

      cd ssb-dbgen\nmake\n
    7. Check the ssb-dbgen directory, when the the dbgen file is generated, indicating that the compilation is successful.

    "},{"location":"MatrixOne/FAQs/deployment-faqs/#i-built-matrixone-in-the-main-branch-initially-but-encountered-panic-when-switching-to-other-versions-for-building","title":"I built MatrixOne in the main branch initially but encountered panic when switching to other versions for building","text":"

    The storage formats between MatrixOne version 0.8.0 and its earlier versions are not compatible with each other. This means that when executing make build, the system will automatically generate a data directory file named mo-data to store data.

    In the future, if you need to switch to another branch and re-execute make build to build MatrixOne, it may cause a panic situation to occur. In this case, you need first to clean the mo-data data directory (that is, execute the rm -rf mo-data command), and then rebuild MatrixOne.

    Reference code example:

    [root ~]# cd matrixone  // Go to the matrixone directory\n[root ~]# git branch // Check the current branch\n* 0.8.0\n[root ~]# make build // Build matrixone\n...    // The build process code is omitted here. If you want to switch to another version, such as version 0.7.0,\n[root ~]# git checkout 0.7.0 // Switch to version 0.7.0\n[root ~]# rm -rf mo-data // Clean up the data directory\n[root ~]# make build // Build matrixone again\n...    // The build process code is omitted here\n[root ~]# ./mo-service --daemon --launch ./etc/launch/launch.toml &> test.log &   // Start MatrixOne service in the terminal backend\n

    Note

    The MatrixOne version 0.8.0 is compatible with the storage format of older versions. If you use version 0.8.0 or a higher version, there is no need to clean the data file directory when switching to other branches and buildings.

    "},{"location":"MatrixOne/FAQs/deployment-faqs/#password-authentication-error-when-connecting-to-the-matrixone-cluster-via-proxy-with-cn-label","title":"Password authentication error when connecting to the MatrixOne cluster via proxy with CN label","text":"
    • Issue Reason: Incorrect connection string formatting. Support for extending the username field is available when connecting to the MatrixOne cluster through the MySQL client. You can add a ? after the username and follow it with CN group labels. CN group labels consist of key-value pairs separated by = and multiple key-value pairs are separated by commas ,.

    • Solution: Please refer to the following example.

    Assuming the configuration for the CN group in your MatrixOne's mo.yaml configuration file is as shown below:

    ## Displaying partial code only\n...\n- cacheVolume:\nsize: 100Gi\ncnLabels:\n- key: workload\nvalues:\n- bk\n...\n

    When connecting to the MatrixOne cluster through the MySQL client, you can use the following command example: mysql -u root?workload=bk -p111 -h 10.206.16.10 -P 31429. In this command, workload=bk is the CN label, connected using =.

    Similarly, when using the mo-dump tool to export data, refer to the following command example: mo-dump -u \"dump?workload=bk\" -h 10.206.16.10 -P 31429 -db tpch_10g > /tmp/mo/tpch_10g.sql.

    "},{"location":"MatrixOne/FAQs/product-faqs/","title":"Product FAQs","text":"
    • What is MatrixOne?

    MatrixOne is a future-oriented hyperconverged cloud & edge native DBMS that supports transactional, analytical, and streaming workload with a simplified and distributed database engine, across multiple data centers, clouds, edges, and other heterogenous infrastructures. The all-in-one architecture of MatrixOne will significantly simplify database management and maintenance, creating a single database that can serve multiple data applications. For information about MatrixOne, you can see MatrixOne Introduction.

    • Where can I apply MatrxOne?

    MatrixOne provides users with HTAP services to support hybrid workloads. It can be used to build data warehouse or data platforms.

    • Is MatrixOne based on MySQL or some other database?

    MatrixOne is a completely redesigned database. It's compatible with part of MySQL syntax and semantics. We are currently working to support more database semantics such as PostgreSQL, Hive, Clickhouse, since we intend to develop MatrixOne as a hyperconverged database. To learn more about the compatibility with MySQL, you can visit MySQL-Compatibility.

    • Which programming language is MatrixOne developed with?

    Currently, the primary programming language used for our programming in Golang.

    • What operating system does MatrixOne support?

    MatrixOne supports Linux and macOS. Please refer to deployment FAQ for more details.

    • Which MatrixOne data types are supported?

    You can see data types in MatrixOne to learn more about the data types we support.

    • Where can I deploy MatrixOne?

    MatrixOne can be deployed on-premise, public cloud, private cloud, or Kubernetes.

    • Can I contribute to MatrixOne?

    Yes, MatrixOne is an open-source project developed on GitHub. Contribution instructions are published in Contribution Guide. We welcome developers to contribute to the MatrixOne community.

    • In addition to the MatrixOne documentation, are there any other ways to acquire MatrixOne knowledge?

    Currently, MatrixOne documentation is the most important and timely way to get MatrixOne related knowledge. In addition, we also have some technical communication groups in Slack and WeChat. If you have any needs, contact opensource@matrixorigin.io.

    "},{"location":"MatrixOne/FAQs/sql-faqs/","title":"SQL FAQs","text":"
    • Are functions and other keywords case sensitive?

    No, they are not case sensitive. Only in one case case is sensitive in MatrixOne, if user creates table and attributes with ``, the name in`` is case sensitive. To find this table name or attribute name in your query, it needs to be in `` as well.

    • How do I export data from MatrixOne to a file?

    You can use SELECT INTO OUTFILE command to export data from MatrixOne to a csv file (only to the server host, not to the remote client). For this command, you can see SELECT Reference.

    • What is the size limit of a transaction in MatrixOne?

    The transaction size is limited to the memory size you have for hardware environment.

    • What kind of character set does MatrixOne support?

    MatrixOne supports the UTF-8 character set by default and currently only supports UTF-8.

    • What is the sql_mode in MatrixOne?

    MatrixOne doesn't support modifying the sql_mode for now, the default sql_mode is as the only_full_group_by in MySQL.

    • How do I bulk load data into MatrixOne?

    MatrixOne provides two methods of bulk load data: 1. Using source filename command from shell, user can load the SQL file with all DDL and insert data statements. 2. Using load data infile...into table... command from shell, user can load an existing .csv file to MatrixOne.

    • How do I know how my query is executed?

    To see how MatrixOne executes for a given query, you can use the EXPLAIN statement, which will print out the query plan.

    EXPLAIN SELECT col1 FROM tbl1;\n
    "},{"location":"MatrixOne/Get-Started/basic-sql/","title":"Explore SQL with MatrixOne","text":"

    MatrixOne is compatible with MySQL, you can use MySQL statements directly in most of the cases. For unsupported features, see MySQL Compatibility, and for more information on connecting to MatriOne, see Using client connect to the MatrixOne server.

    "},{"location":"MatrixOne/Get-Started/basic-sql/#what-is-sql","title":"What is SQL?","text":"

    The Structured Query Language (SQL) is used to manage a relational database management system (RDBMS). The scope of SQL includes data insertion, query, update, and delete, database schema creation and modification, and data access control.

    "},{"location":"MatrixOne/Get-Started/basic-sql/#how-many-types-sql-does-matrixone-have","title":"How many types SQL does MatrixOne have?","text":"

    SQL is divided into the following 6 types according to their functions in MatrixOne:

    • DDL (Data Definition Language): It is used to define database objects, including databases, tables, and views. Such as CREATE, ALTER, and DROP.

    • DML (Data Manipulation Language): It is used to manipulate application related records. Such as SELECT, DELETE, and INSERT.

    • DQL (Data Query Language): It is used to query the records after conditional filtering. Such as SELECT...FROM...[WHERE].

    • TCL (Transaction Control Language): It is used to manage transactions. Such as COMMIT,ROLLBACK, or SET TRANSACTION.

    • DCL (Data Control Language): It is used to define access privileges and security levels. Such as CREATET ACCOUNT, DROP ACCOUNT, and GRANT.

    • Other: Other types of management languages \u200b\u200bin MatrixOne are not directly related to data and are a general term for the acquisition and modification of database parameters and resource allocation. Such as SHOW, SET variable, and KILL.

    "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-show-create-and-drop-a-database","title":"Basic SQL about SHOW, CREATE and DROP a database","text":"

    A database in MatrixOne can be considered as a collection of objects such as tables.

    • To show the list of databases, use the SHOW DATABASES statement:
    SHOW DATABASES;\n
    • To create the database named dbdemo, use the CREATE DATABASE db_name [options]; statement, for example:
    CREATE DATABASE dbdemo;\n

    or:

    CREATE DATABASE IF NOT EXISTS dbdemo;\n

    Add IF NOT EXISTS to prevent an error if the database exists.

    • To use the database named dbdemo, use the following statement:
    USE dbdemo;\n
    • To show all the tables in a database, use the SHOW TABLES statement:
    SHOW TABLES FROM dbdemo;\n
    • To delete a database, use the DROP DATABASE statement:
    DROP DATABASE dbdemo;\n
    "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-create-show-and-drop-a-table","title":"Basic SQL about CREATE, SHOW, and DROP a table","text":"
    • To create a table, use the CREATE TABLE statement:
    CREATE TABLE table_name column_name data_type constraint;\n

    For example, to create a table named person which includes fields such as number, name, and birthday, use the following statement:

    CREATE TABLE person (\nid INT(11),\nname VARCHAR(255),\nbirthday DATE\n);\n
    • To view the statement that creates the table (DDL), use the SHOW CREATE statement:
    SHOW CREATE table person;\n

    Expected result:

    +--------+-----------------------------------------------------------------------------------------------------------------+\n| Table  | Create Table                                                                                                    |\n+--------+-----------------------------------------------------------------------------------------------------------------+\n| person | CREATE TABLE `person` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`birthday` DATE DEFAULT NULL\n) |\n+--------+-----------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
    • To delete a table, use the DROP TABLE statement:
    DROP TABLE person;\n
    "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-insert-update-and-delete-data","title":"Basic SQL about INSERT, UPDATE, and DELETE data","text":"

    Common DML features are adding, modifying, and deleting table records. The corresponding commands are INSERT, UPDATE, REPLACE and DELETE.

    • To insert data into a table, use the INSERT statement:
    INSERT INTO person VALUES(1,'tom','20170912');\n
    • To insert a record containing data of some fields into a table, use the INSERT statement:
    INSERT INTO person(id,name) VALUES('2','bob');\n
    • To update some fields of a record in a table, use the UPDATE statement:
    UPDATE person SET birthday='20180808' WHERE id=2;\n
    • To replace some field data of table records in the table, use the UPDATE statement:
    REPLACE INTO person SET birthday='20180809' WHERE id=2;\n
    • To delete the data in a table, use the DELETE statement:
    DELETE FROM person WHERE id=2;\n

    Note

    The UPDATE and DELETE statements without the WHERE clause as a filter operate on the entire table.

    "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-query-data","title":"Basic SQL about Query data","text":"

    DQL is used to retrieve the desired data rows from a table or multiple tables.

    • To view the data in a table, use the SELECT statement:
    SELECT * FROM person;\n

    Expected result:

    +------+------+------------+\n| id   | name | birthday   |\n+------+------+------------+\n|    1 | tom  | 2017-09-12 |\n+------+------+------------+\n1 row in set (0.00 sec)\n
    • To query a specific column, add the column name after the SELECT keyword:
    SELECT name FROM person;\n+------+\n| name |\n+------+\n| tom  |\n+------+\n1 rows in set (0.00 sec)\n

    Use the WHERE clause to filter all records that match the conditions and then return the result:

    SELECT * FROM person where id<5;\n

    Expected result:

    +------+------+------------+\n| id   | name | birthday   |\n+------+------+------------+\n|    1 | tom  | 2017-09-12 |\n+------+------+------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-create-grant-and-drop-a-user","title":"Basic SQL about CREATE, GRANT, and DROP a user","text":"

    CREATE, GRANT, and DROP are usually used to create or delete users, and manage user privileges.

    • To create a user, use the CREATE USER statement. The following example creates a user named mouser with the password 111:
    > CREATE USER mouser IDENTIFIED BY '111';\nQuery OK, 0 rows affected (0.10 sec)\n
    • To create a role for the user:
    > CREATE ROLE role_r1;\nQuery OK, 0 rows affected (0.05 sec)\n
    • To grant mouser the role_r1:
    > GRANT role_r1 to mouser;\nQuery OK, 0 rows affected (0.04 sec)\n
    • To grant mouser the privilege to create table in the dbdemo database:
    GRANT create table on database * to role_r1;\n
    • To check the privileges of mouser:
    > SHOW GRANTS for mouser@localhost;\n+-------------------------------------------------------+\n| Grants for mouser@localhost                           |\n+-------------------------------------------------------+\n| GRANT create table ON database * `mouser`@`localhost` |\n| GRANT connect ON account  `mouser`@`localhost`        |\n+-------------------------------------------------------+\n2 rows in set (0.02 sec)\n

    You have successfully granted the permission of create table in the database to mouser.

    • To delete mouser:
    DROP USER mouser;\n

    Privilege management is a huge but very useful function. For more information, see Privilege Management.

    "},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/","title":"Deploy standalone MatrixOne","text":"

    The applicable scenario of the standalone version of MatrixOne is to use a single development machine to deploy MatrixOne and experience the essential functions of MatrixOne, which is the same as using MySQL for the standalone version.

    Recommended operating system

    MatrixOne supports Linux and MacOS. For quick start, we recommend the following hardware specifications:

    Operating System Operating System Version CPU Memory Debian 11 and later x86 / ARM CPU; 4 Cores 16 GB Ubuntu 20.04 and later x86 / ARM CPU; 4 Cores 16 GB macOS Monterey 12.3 and later x86 / ARM CPU; 4 Cores 16 GB

    For more information on the required operating system versions for deploying MatrixOne, see Hardware and Operating system requirements.

    "},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#deploy-on-macos","title":"Deploy on macOS","text":"

    You can install and connect to MatrixOne on macOS in one of three ways that work best for you:

    • Building from source code
    • Using binary package
    • Using Docker
    "},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#deploy-on-linux","title":"Deploy on Linux","text":"

    You can install and connect to MatrixOne on Linux in one of three ways that work best for you:

    • Building from source code
    • Using binary package
    • Using Docker
    "},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#reference","title":"Reference","text":"
    • For more information on the method of connecting to MatrixOne, see:

      • Connecting to MatrixOne with Database Client Tool
      • Connecting to MatrixOne with JDBC
      • Connecting to MatrixOne with Python.
    • For more information on the questions of deployment,see Deployment FAQs.

    • For more information on distributed installation, see MatrixOne Distributed Cluster Deployment.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/","title":"Building from source code in Linux","text":"

    This document will guide you to deploy a standalone MatrixOne in a Linux environment using source code. You can use the mo_ctl tool to help you deploy and manage MatrixOne.

    MatrixOne supports x86 and ARM Linux systems. This article uses the Debian11.1 x86 architecture as an example to to show the entire deployment process. If you use the Ubuntu system, it should be noted that there is no root authority by default. It is recommended to add sudo to all the commands in the process.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#pre-dependency-reference","title":"Pre-dependency Reference","text":"

    To install and use the stand-alone MatrixOne through source code, you need to depend on the following software packages.

    Dependent software Version golang 1.20 or later gcc gcc8.5 or later git 2.20 or later MySQL Client 8.0 or later"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-1-install-dependency","title":"Step 1: Install Dependency","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1-install-go","title":"1. Install Go","text":"
    1. Click Go Download and install to enter its official documentation, and follow the installation steps to complete the Go installation.

    2. To verify whether Go is installed, please execute the code go version. When Go is installed successfully, the example code line is as follows:

      go version go1.20.4 linux/amd64\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#2-install-gcc","title":"2. Install GCC","text":"
    1. Debian 11.1 generally comes with GCC version 9.0 or above. To verify whether the GCC is installed:

      gcc -v\nbash: gcc: command not found\n

      As shown in the code, the version of GCC is not displayed, the GCC environment needs to be installed.

    2. Click GCC Download and install to enter its official documentation, and follow the installation steps to complete the GCC installation.

    3. To verify whether GCC is installed, execute the code gcc -v. When GCC is installed successfully, the example code line is as follows (only part of the code is displayed):

      Using built-in specs.\nCOLLECT_GCC=gcc\n...\nThread model: posix\ngcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#3-install-git","title":"3. Install Git","text":"
    1. To verify whether Git is installed, execute the code git version. As shown in the code, if the version of git is not displayed, it means that Git needs to be installed.

      git version\n-bash: git: command not found\n
    2. Install Git with the following command:

      sudo apt install git\n
    3. To verify whether Git is installed, please execute the code git version, the code line example of a successful installation is as follows:

      git version\ngit version 2.40.0\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#4-install-mysql-client","title":"4. Install MySQL Client","text":"

    The Debian11.1 version does not have MySQL Client installed by default, so it needs to be downloaded and installed manually.

    1. To install MySQL Client, you need to use the wget download tool, wget is used to download files from the specified URL. Execute the following commands in sequence to install wget:

      ## Update the software source list cache\nsudo apt udpate\n## install wget\nsudo apt install wget\n

      After the installation is complete, please enter the following command to verify:

      wget -V\n

      The result of a successful installation (only a part of the code is displayed) is as follows:

      GNU Wget 1.21.3 built on linux-gnu.\n...\nCopyright (C) 2015 Free Software Foundation, Inc.\n...\n
    2. Execute the following commands in sequence to install MySQL Client:

      wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
    3. Execute the command mysql --version to test whether MySQL is available. The result of the successful installation is as follows:

      mysql --version\nmysql  Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-2-install-the-mo_ctl-tool","title":"Step 2: Install the mo_ctl tool","text":"

    mo_ctl is a command-line tool for deploying, installing, and managing MatrixOne. It is very convenient to perform various operations on MatrixOne. See mo_ctl Tool for complete usage details.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1-install-the-mo_ctl-tool","title":"1. Install the mo_ctl tool","text":"

    The mo_ctl tool can be installed through the following command:

    wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && bash +x ./install.sh\n

    After the installation is complete, verify whether the installation is successful through the mo_ctl command:

    root@VM-16-2-debian:~# mo_ctl\nUsage             : mo_ctl [option_1] [option_2]\n\n[option_1]      : available: connect | ddl_connect | deploy | get_branch | get_cid | get_conf | help | pprof | precheck | restart | set_conf | sql | start | status | stop | uninstall | upgrade | watchdog\n  1) connect      : connect to mo via mysql client using connection info configured\n  2) ddl_convert  : convert ddl file to mo format from other types of database\n  3) deploy       : deploy mo onto the path configured\n  4) get_branch   : upgrade or downgrade mo from current version to a target commit id or stable version\n  5) get_cid      : print mo git commit id from the path configured\n  6) get_conf     : get configurations\n  7) help         : print help information\n  8) pprof        : collect pprof information\n  9) precheck     : check pre-requisites for mo_ctl\n  10) restart     : a combination operation of stop and start\n  11) set_conf    : set configurations\n  12) sql         : execute sql from string, or a file or a path containg multiple files\n  13) start       : start mo-service from the path configured\n  14) status      : check if there's any mo process running on this machine\n  15) stop        : stop all mo-service processes found on this machine\n  16) uninstall   : uninstall mo from path MO_PATH=/data/mo//matrixone\n  17) upgrade     : upgrade or downgrade mo from current version to a target commit id or stable version\n  18) watchdog    : setup a watchdog crontab task for mo-service to keep it alive  \n  e.g.            : mo_ctl status\n\n  [option_2]        : Use \" mo_ctl [option_1] help \" to get more info\n  e.g.            : mo_ctl deploy help\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#2-set-mo_ctl-parameters-optional","title":"2. Set mo_ctl parameters (Optional)","text":"

    Some parameters in the mo_ctl tool need to be set and you can view all current parameters through mo_ctl get_conf.

    root@VM-16-2-debian:~# mo_ctl get_conf\n2023-08-23 18:23:35.444 UTC+0800    [INFO]    Below are all configurations set in conf file /root/mo_ctl/conf/env.sh\nMO_PATH=\"/data/mo/\"\nMO_LOG_PATH=\"${MO_PATH}/matrixone/logs\"\nMO_HOST=\"127.0.0.1\"\nMO_PORT=\"6001\"\nMO_USER=\"root\"\nMO_PW=\"111\"\nMO_DEPLOY_MODE=\"host\"\nMO_REPO=\"matrixorigin/matrixone\"\nMO_IMAGE_PREFIX=\"nightly\"\nMO_IMAGE_FULL=\"\"\nMO_CONTAINER_NAME=\"mo\"\nMO_CONTAINER_PORT=\"6001\"\nMO_CONTAINER_DEBUG_PORT=\"12345\"\nCHECK_LIST=(\"go\" \"gcc\" \"git\" \"mysql\" \"docker\")\nGCC_VERSION=\"8.5.0\"\nCLANG_VERSION=\"13.0\"\nGO_VERSION=\"1.20\"\nMO_GIT_URL=\"https://github.com/matrixorigin/matrixone.git\"\nMO_DEFAULT_VERSION=\"1.0.0-rc1\"\nGOPROXY=\"https://goproxy.cn,direct\"\nSTOP_INTERVAL=\"5\"\nSTART_INTERVAL=\"2\"\nMO_DEBUG_PORT=\"9876\"\nMO_CONF_FILE=\"${MO_PATH}/matrixone/etc/launch/launch.toml\"\nRESTART_INTERVAL=\"2\"\nPPROF_OUT_PATH=\"/tmp/pprof-test/\"\nPPROF_PROFILE_DURATION=\"30\"\n

    Generally, the parameters that may need to be adjusted are as follows:

    mo_ctl set_conf MO_PATH=\"/data/mo/matrixone\" # Set custom MatrixOne download path\nmo_ctl set_conf MO_GIT_URL=\"https://ghproxy.com/https://github.com/matrixorigin/matrixone.git\" # For the problem of slow downloading from the original GitHub address, set the proxy download address\nmo_ctl set_conf MO_DEFAULT_VERSION=\"1.0.0-rc1\" # Set the version of MatrixOne downloaded\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-3-get-matrixone-code","title":"Step 3: Get MatrixOne code","text":"

    Depending on your needs, choose whether you want to keep your code up to date, or if you want to get the latest stable version of the code.

    Get the MatrixOne(Develop Version) code to buildGet the MatrixOne(Stable Version) code to build

    The main branch is the default branch, the code on the main branch is always up-to-date but not stable enough.

    mo_ctl deploy main\n
    mo_ctl deploy 1.0.0-rc1\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-4-launch-matrixone-server","title":"Step 4: Launch MatrixOne server","text":"

    Launch the MatrixOne service through the mo_ctl start command.

    If the operation is regular, the following log will appear. The relevant operation logs of MatrixOne will be in /data/mo/logs/.

    root@VM-16-2-debian:~# mo_ctl start\n2023-07-07_09:55:01    [INFO]    No mo-service is running\n2023-07-07_09:55:01    [INFO]    Starting mo-service: cd /data/mo//matrixone/ && /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml >/data/mo//logs/stdout-20230707_095501.log 2>/data/mo//logs/stderr-20230707_095501.log\n2023-07-07_09:55:01    [INFO]    Wait for 2 seconds\n2023-07-07_09:55:03    [INFO]    At least one mo-service is running. Process info:\n2023-07-07_09:55:03    [INFO]    root      748128       1  2 09:55 ?        00:00:00 /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml\n2023-07-07_09:55:03    [INFO]    Pids:\n2023-07-07_09:55:03    [INFO]    748128\n2023-07-07_09:55:03    [INFO]    Start succeeded\n

    Note

    The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-5-connect-to-matrixone","title":"Step 5: Connect to MatrixOne","text":"

    One-click connection to MatrixOne service through mo_ctl connect command.

    This command will invoke the MySQL Client tool to connect to the MatrixOne service automatically.

    root@VM-16-2-debian:~# mo_ctl connect\n2023-07-07_10:30:20    [INFO]    Checking connectivity\n2023-07-07_10:30:20    [INFO]    Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

    Note

    The above connection and login account is the initial accounts root and the password 111; please change the initial password after logging in to MatrixOne; see MatrixOne Password Management. After changing the login username or password, you must set a new username and password through mo_ctl set_conf. For details, please refer to mo_ctl Tool.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/","title":"Using binary package in Linux","text":"

    This document will guide you to deploy a stand-alone version of MatrixOne in a Linux environment using binary packages. This installation solution does not need to install pre-dependencies and compile source packages. You can use the mo_ctl tool to help you deploy and manage MatrixOne.

    MatrixOne supports x86 and ARM Linux systems. This article uses the Debian11.1 x86 architecture as an example to to show the entire deployment process. If you use the Ubuntu system, it should be noted that there is no root authority by default. It is recommended to add sudo to all the commands in the process.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#pre-dependency-reference","title":"Pre-dependency Reference","text":"

    Only the MySQL Client tool must be installed to deploy and install MatrixOne through the binary package.

    Dependent software Version MySQL Client 8.0 or later"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-1-install-dependency","title":"Step 1: Install Dependency","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#1-install-wget-or-curl","title":"1. Install wget or curl","text":"

    We'll provide a method of Using binary package to install MatrixOne. If you prefer to use the command line, you can pre-install wget or curl.

    Tips: It is recommended that you download and install one of these two tools to facilitate future operations.

    Install wgetInstall curl

    The wget tool is used to download files from the specified URL. wget is a unique file download tool; it is very stable and has a download speed.

    Execute the following commands in sequence to install wget:

    ## Update the software source list cache\nsudo apt udpate\n## install wget\nsudo apt install wget\n

    After the installation is complete, please enter the following command to verify:

    wget -V\n

    The result of a successful installation (only a part of the code is displayed) is as follows:

    GNU Wget 1.21.3 built on linux-gnu.\n...\nCopyright (C) 2015 Free Software Foundation, Inc.\n...\n

    curl is a file transfer tool that works from the command line using URL rules. curl is a comprehensive transfer tool that supports file upload and download.

    Go to the Curl website according to the official installation guide to install curl. To verify that curl is installed successfully, use the following command line:

    curl --version\n

    The successful installation results (only part of the code is displayed) are as follows:

    curl 7.84.0 (x86_64-pc-linux-gnu) libcurl/7.84.0 OpenSSL/1.1.1k-fips zlib/1.2.11\nRelease-Date: 2022-06-27\n...\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#2-install-mysql-client","title":"2. Install MySQL Client","text":"

    The Debian11.1 version does not have MySQL Client installed by default, so it needs to be downloaded and installed manually.

    1. Execute the following commands in sequence to install MySQL Client:

      wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
    2. Execute the command mysql --version to test whether MySQL is available. The result of the successful installation is as follows:

      mysql --version\nmysql  Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-2-download-binary-packages-and-decompress","title":"Step 2: Download binary packages and decompress","text":"

    Download Method 1 and Download Method 2 need to install the download tools wget or curl first.

    Downloading method 1: Using wget to install binary packagesDownloading method 2: Using curl to install binary packagesDownloading method 3: Go to the page and download

    Binary for x86 architecture system:

    mkdir -p /root/matrixone & cd /root/\nwget https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-linux-x86_64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-linux-x86_64.zip\n

    Binary for ARM architecture system:

    mkdir -p /root/matrixone & cd /root/\nwget https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-linux-arm64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-linux-arm64.zip\n

    Binary for x86 architecture system:

    mkdir -p /root/matrixone & cd /root/\ncurl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-linux-x86_64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-linux-x86_64.zip\n

    Binary for ARM architecture system:

    mkdir -p /root/matrixone & cd /root/\ncurl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-linux-arm64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-linux-arm64.zip\n

    If you want a more intuitive way to download the page, go to the version 1.0.0-rc1, pull down to find the Assets column, and click the installation package mo-v1.0.0-rc1-linux-x86_64.zip or mo-v1.0.0-rc1-linux-arm64.zip can be downloaded.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-3-install-the-mo_ctl-tool","title":"Step 3: Install the mo_ctl tool","text":"

    mo_ctl is a command-line tool for deploying, installing, and managing MatrixOne. It is very convenient to perform various operations on MatrixOne. See mo_ctl Tool for complete usage details.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#1-install-the-mo_ctl-tool","title":"1. Install the mo_ctl tool","text":"

    The mo_ctl tool can be installed through the following command:

    wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && bash +x ./install.sh\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#2-set-mo_ctl-parameters","title":"2. Set mo_ctl parameters","text":"

    Using the following command sets the MatrixOne binary decompression file directory to the MO_PATH parameter of mo_ctl. mo_ctl will automatically look for the matrixone folder in MO_PATH.

    mo_ctl set_conf MO_PATH=\"/root\"\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-4-launch-matrixone-server","title":"Step 4: Launch MatrixOne server","text":"

    Launch the MatrixOne service through the mo_ctl start command.

    If the operation is regular, the following log will appear. The relevant operation logs of MatrixOne will be in /data/mo/logs/.

    root@VM-16-2-debian:~# mo_ctl start\n2023-07-07_09:55:01    [INFO]    No mo-service is running\n2023-07-07_09:55:01    [INFO]    Starting mo-service: cd /data/mo//matrixone/ && /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml >/data/mo//logs/stdout-20230707_095501.log 2>/data/mo//logs/stderr-20230707_095501.log\n2023-07-07_09:55:01    [INFO]    Wait for 2 seconds\n2023-07-07_09:55:03    [INFO]    At least one mo-service is running. Process info:\n2023-07-07_09:55:03    [INFO]    root      748128       1  2 09:55 ?        00:00:00 /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml\n2023-07-07_09:55:03    [INFO]    Pids:\n2023-07-07_09:55:03    [INFO]    748128\n2023-07-07_09:55:03    [INFO]    Start succeeded\n

    Note

    The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-5-connect-to-matrixone","title":"Step 5: Connect to MatrixOne","text":"

    One-click connection to MatrixOne service through mo_ctl connect command.

    This command will invoke the MySQL Client tool to connect to the MatrixOne service automatically.

    root@VM-16-2-debian:~# mo_ctl connect\n2023-07-07_10:30:20    [INFO]    Checking connectivity\n2023-07-07_10:30:20    [INFO]    Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

    Note

    The above connection and login account is the initial accounts root and the password 111; please change the initial password after logging in to MatrixOne; see MatrixOne Password Management. After changing the login username or password, you must set a new username and password through mo_ctl set_conf. For details, please refer to mo_ctl Tool.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/","title":"Using Docker","text":"

    This document will guide you build standalone MatrixOne using Docker.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#step-1-download-and-install-docker","title":"Step 1: Download and install Docker","text":"
    1. Click Get Docker, enter into the Docker's official document page, depending on your operating system, download and install the corresponding Docker. It is recommended to choose Docker version 20.10.18 or later and strive to maintain consistency between the Docker client and Docker server versions.

    2. After the installation, you can verify the Docker version by using the following lines:

      docker --version\n

      The successful installation results are as follows:

      Docker version 20.10.18, build 100c701\n
    3. Execute the following command in your terminal, start Docker and check whether the running status is successfully:

      systemctl start docker\nsystemctl status docker\n

      The following code example indicates that Docker is running. Active: active (running) shows that Docker is running.

      docker.service - Docker Application Container Engine\n   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)\n   Active: active (running) since Sat 2022-11-26 17:48:32 CST; 6s ago\n     Docs: https://docs.docker.com\n Main PID: 234496 (dockerd)\n    Tasks: 8\n   Memory: 23.6M\n
    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#step-2-create-and-run-the-container-of-matrixone","title":"Step 2: Create and run the container of MatrixOne","text":"

    It will pull the image from Docker Hub if not exists. You can choose to pull the stable version image or the develop version image.

    Stable Version Image(1.0.0-rc1 version)Develop Version Image
    docker pull matrixorigin/matrixone:1.0.0-rc1\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.0.0-rc1\n

    If you are using the network in mainland China, you can pull the MatrixOne stable version image on Alibaba Cloud:

    docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.0.0-rc1\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.0.0-rc1\n

    If you want to pull the develop version image, see Docker Hub, get the image tag. An example as below:

    docker pull matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:nightly-commitnumber\n

    If you are using the network in mainland China, you can pull the MatrixOne develop version image on Alibaba Cloud:

    docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\n

    Note: The nightly version is updated once a day.

    Note

    If your Docker version is lower than 20.10.18 or the Docker client and server versions are inconsistent, upgrading to the latest stable version before attempting is recommended. If you choose to proceed with the current versions, you need to add the parameter --privileged=true to the docker run command, as shown below:

    docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.0.0-rc1\n

    Note

    The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

    If you need to mount data directories or customize configure files, see Mount the directory to Docker container.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#step-3-connect-to-standalone-matrixone","title":"Step 3: Connect to standalone MatrixOne","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#install-and-configure-mysql-client","title":"Install and configure MySQL Client","text":"

    The Debian11.1 version does not have MySQL Client installed by default, so it needs to be downloaded and installed manually.

    1. Execute the following commands in sequence:

      wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
    2. Execute the command mysql --version to test whether MySQL is available. The result of the successful installation is as follows:

      mysql --version\nmysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n

    Tips: Currently, MatrixOne is only compatible with the Oracle MySQL client. This means some features might not work with the MariaDB or Percona clients.

    "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#connect-to-matrixone","title":"Connect to MatrixOne","text":"

    You can use the MySQL command-line client to connect to MatrixOne server. Open a new terminal window and enter the following command:

    ```\nmysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password:  # The default initial password is 111\n```\n

    Currently, MatrixOne only supports the TCP listener.

    Info

    The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/","title":"Building from source code in macOS","text":"

    This document will guide you to deploy a standalone version of MatrixOne in a macOS environment using source code. You can use the mo_ctl tool to help you deploy and manage MatrixOne.

    MatrixOne supports x86 and ARM macOS systems. This article uses the Macbook M1 ARM version as an example to show the entire deployment process.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#pre-dependency-reference","title":"Pre-dependency Reference","text":"

    To install and use the stand-alone MatrixOne through source code, you need to depend on the following software packages.

    Dependent software Version golang 1.20 or later gcc/clang gcc8.5 or later, clang13.0 or later git 2.20 or later MySQL Client 8.0 or later"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-1-install-dependency","title":"Step 1: Install Dependency","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#1-install-go","title":"1. Install Go","text":"
    1. Click Go Download and install to enter its official documentation, and follow the installation steps to complete the Go installation.

    2. To verify whether Go is installed, please execute the code go version. When Go is installed successfully, the example code line is as follows:

      > go version\ngo version go1.20.5 darwin/arm64\n
    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#2-install-gccclang","title":"2. Install GCC/Clang","text":"
    1. macOS generally has its own Clang compiler, which plays the same role as GCC. To verify whether the GCC is installed:

      gcc -v\nbash: gcc: command not found\n

      As shown in the code, the version of GCC is not displayed, the GCC/Clang environment needs to be installed.

    2. Click GCC Download and install to enter its official documentation, and follow the installation steps to complete the GCC installation. Or you can install Clang through Apple's official Xcode.

    3. To verify whether GCC/Clang is installed, please execute the code gcc -v. When GCC is installed successfully, the example code line is as follows:

      Apple clang version 14.0.3 (clang-1403.0.22.14.1)\nTarget: arm64-apple-darwin22.5.0\nThread model: posix\nInstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin\n
    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#3-install-git","title":"3. Install Git","text":"

    Install Git via the Official Documentation.

    Use the command git version to check whether the installation is successful. The code example of a successful installation is as follows:

    > git version\ngit version 2.40.0\n
    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#4-install-and-configure-mysql-client","title":"4. Install and configure MySQL Client","text":"
    1. Click MySQL Community Downloads to enter into the MySQL client download and installation page. According to your operating system and hardware environment, drop down to select Select Operating System > macOS, then drop down to select Select OS Version, and select the download installation package to install as needed.

    2. Configure the MySQL client environment variables:

      1. Open a new terminal window and enter the following command:

        cd ~\nsudo vim .bash_profile\n
      2. After pressing Enter on the keyboard to execute the above command, you need to enter the root user password, which is the root password you set in the installation window when you installed the MySQL client. If no password has been set, press Enter to skip the password.

      3. After entering/skiping the root password, you will enter .bash_profile, click i on the keyboard to enter the insert state, and you can enter the following command at the bottom of the file:

        export PATH=${PATH}:/usr/local/mysql/bin\n
    3. After the input is completed, click esc on the keyboard to exit the insert state, and enter :wq at the bottom to save and exit.

    4. Enter the command source .bash_profile, press Enter to execute, and run the environment variable.

    5. To test whether MySQL is available:

      Run the command mysql --version, if MySQL client is installed successfully, the example code line is as follows: mysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-2-install-the-mo_ctl-tool","title":"Step 2: Install the mo_ctl tool","text":"

    mo_ctl is a command-line tool for deploying, installing, and managing MatrixOne. It is very convenient to perform various operations on MatrixOne. See mo_ctl Tool for complete usage details.

    1. First, install the wget download tool: Go to the Homebrew page and follow the steps to install Homebrew first, then install wget. To verify whether wget is installed successfully, you can use the following command line:

      wget -V\n

      The successful installation results (only part of the code is displayed) are as follows:

      GNU Wget 1.21.3 \u5728 darwin21.3.0 \u4e0a\u7f16\u8bd1\n...\nCopyright \u00a9 2015 Free Software Foundation, Inc.\n...\n
    2. The mo_ctl tool can be installed through the following command:

      wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
    3. After the installation is complete, verify whether the installation is successful through the mo_ctl command:

      > mo_ctl\nUsage             : mo_ctl [option_1] [option_2]\n\n[option_1]      : available: connect | ddl_connect | deploy | get_branch | get_cid | get_conf | help | pprof | precheck | restart | set_conf | sql | start | status | stop | uninstall | upgrade | watchdog\n1) connect      : connect to mo via mysql client using connection info configured\n2) ddl_convert  : convert ddl file to mo format from other types of database\n3) deploy       : deploy mo onto the path configured\n4) get_branch   : upgrade or downgrade mo from current version to a target commit id or stable version\n5) get_cid      : print mo git commit id from the path configured\n6) get_conf     : get configurations\n7) help         : print help information\n8) pprof        : collect pprof information\n9) precheck     : check pre-requisites for mo_ctl\n10) restart     : a combination operation of stop and start\n11) set_conf    : set configurations\n12) sql         : execute sql from string, or a file or a path containg multiple files\n13) start       : start mo-service from the path configured\n14) status      : check if there's any mo process running on this machine\n15) stop        : stop all mo-service processes found on this machine\n16) uninstall   : uninstall mo from path MO_PATH=/data/mo//matrixone\n17) upgrade     : upgrade or downgrade mo from current version to a target commit id or stable version\n18) watchdog    : setup a watchdog crontab task for mo-service to keep it alive\ne.g.            : mo_ctl status\n[option_2]      : Use \" mo_ctl [option_1] help \" to get more info\ne.g.            : mo_ctl deploy help\n
    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#set-mo_ctl-parameters-optional","title":"Set mo_ctl parameters (Optional)","text":"

    Some parameters in the mo_ctl tool need to be set and you can view all current parameters through mo_ctl get_conf.

    > mo_ctl get_conf\n2023-07-07_15:31:24    [INFO]    Below are all configurations set in conf file /Users/username/mo_ctl/conf/env.sh\nMO_PATH=\"/Users/username/mo/matrixone\"\nMO_LOG_PATH=\"${MO_PATH}/matrixone/logs\"\nMO_HOST=\"127.0.0.1\"\nMO_PORT=\"6001\"\nMO_USER=\"root\"\nMO_PW=\"111\"\nMO_DEPLOY_MODE=\"host\"\nMO_REPO=\"matrixorigin/matrixone\"\nMO_IMAGE_PREFIX=\"nightly\"\nMO_IMAGE_FULL=\"\"\nMO_CONTAINER_NAME=\"mo\"\nMO_CONTAINER_PORT=\"6001\"\nMO_CONTAINER_DEBUG_PORT=\"12345\"\nCHECK_LIST=(\"go\" \"gcc\" \"git\" \"mysql\" \"docker\")\nGCC_VERSION=\"8.5.0\"\nCLANG_VERSION=\"13.0\"\nGO_VERSION=\"1.20\"\nMO_GIT_URL=\"https://github.com/matrixorigin/matrixone.git\"\nMO_DEFAULT_VERSION=\"1.0.0-rc1\"\nGOPROXY=\"https://goproxy.cn,direct\"\nSTOP_INTERVAL=\"5\"\nSTART_INTERVAL=\"2\"\nMO_DEBUG_PORT=\"9876\"\nMO_CONF_FILE=\"${MO_PATH}/matrixone/etc/launch/launch.toml\"\nRESTART_INTERVAL=\"2\"\nPPROF_OUT_PATH=\"/tmp/pprof-test/\"\nPPROF_PROFILE_DURATION=\"30\"\n

    Generally, the parameters that may need to be adjusted are as follows:

    mo_ctl set_conf MO_PATH=\"/Users/username/mo/matrixone\" # Set custom MatrixOne download path\nmo_ctl set_conf MO_GIT_URL=\"https://ghproxy.com/https://github.com/matrixorigin/matrixone.git\" ## For the problem of slow downloading from the original GitHub address, set the proxy download address\nmo_ctl set_conf MO_DEFAULT_VERSION=\"1.0.0-rc1\" # Set the version of MatrixOne downloaded\n
    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-3-get-matrixone-code","title":"Step 3: Get MatrixOne code","text":"

    Depending on your needs, choose whether you want to keep your code up to date, or if you want to get the latest stable version of the code.

    Get the MatrixOne(Develop Version) code to buildGet the MatrixOne(Stable Version) code to build

    The main branch is the default branch, the code on the main branch is always up-to-date but not stable enough.

    mo_ctl deploy main\n
    mo_ctl deploy 1.0.0-rc1\n
    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-4-launch-matrixone-server","title":"Step 4: Launch MatrixOne server","text":"

    Launch the MatrixOne service through the mo_ctl start command.

    If the operation is regular, the following log will appear. The relevant operation logs of MatrixOne will be in /data/mo/logs/.

    > mo_ctl start\n2023-07-07_15:33:45    [INFO]    No mo-service is running\n2023-07-07_15:33:45    [INFO]    Starting mo-service: cd /Users/username/mo/matrixone/matrixone/ && /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml >/Users/username/mo/matrixone/matrixone/logs/stdout-20230707_153345.log 2>/Users/username/mo/matrixone/matrixone/logs/stderr-20230707_153345.log\n2023-07-07_15:33:45    [INFO]    Wait for 2 seconds\n2023-07-07_15:33:48    [INFO]    At least one mo-service is running. Process info:\n2023-07-07_15:33:48    [INFO]      501 66932     1   0  3:33PM ??         0:00.27 /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml\n2023-07-07_15:33:48    [INFO]    Pids:\n2023-07-07_15:33:48    [INFO]    66932\n2023-07-07_15:33:48    [INFO]    Start succeeded\n

    Note

    The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-5-connect-to-matrixone","title":"Step 5: Connect to MatrixOne","text":"

    One-click connection to MatrixOne service through mo_ctl connect command.

    This command will invoke the MySQL Client tool to connect to the MatrixOne service automatically.

    > mo_ctl connect\n2023-07-07_10:30:20    [INFO]    Checking connectivity\n2023-07-07_10:30:20    [INFO]    Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

    Note

    The above connection and login account is the initial accounts root and the password 111; please change the initial password after logging in to MatrixOne; see MatrixOne Password Management. After changing the login username or password, you must set a new username and password through mo_ctl set_conf. For details, please refer to mo_ctl Tool.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/","title":"Using binary package in macOS","text":"

    This document will guide you to deploy a stand-alone version of MatrixOne in a macOS environment using binary packages. This installation solution does not need to install pre-dependencies and compile source packages. You can use the mo_ctl tool to help you deploy and manage MatrixOne.

    MatrixOne supports x86 and ARM macOS systems. This article uses the Macbook M1 ARM version as an example to show the entire deployment process.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#pre-dependency-reference","title":"Pre-dependency Reference","text":"

    Only the MySQL Client tool must be installed to deploy and install MatrixOne through the binary package.

    Dependent software Version MySQL Client 8.0 or later"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-1-install-dependency","title":"Step 1: Install Dependency","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#install-and-configure-mysql-client","title":"Install and configure MySQL Client","text":"
    1. Click MySQL Community Downloads to enter into the MySQL client download and installation page. According to your operating system and hardware environment, drop down to select Select Operating System > macOS, then drop down to select Select OS Version, and select the download installation package to install as needed.

    2. Configure the MySQL client environment variables:

      1. Open a new terminal window and enter the following command:

        cd ~\nsudo vim .bash_profile\n
      2. After pressing Enter on the keyboard to execute the above command, you need to enter the root user password, which is the root password you set in the installation window when you installed the MySQL client. If no password has been set, press Enter to skip the password.

      3. After entering/skiping the root password, you will enter .bash_profile, click i on the keyboard to enter the insert state, and you can enter the following command at the bottom of the file:

        export PATH=${PATH}:/usr/local/mysql/bin\n
    3. After the input is completed, click esc on the keyboard to exit the insert state, and enter :wq at the bottom to save and exit.

    4. Enter the command source .bash_profile, press Enter to execute, and run the environment variable.

    5. To test whether MySQL is available:

      Run the command mysql --version, if MySQL client is installed successfully, the example code line is as follows: mysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-2-download-binary-packages-and-decompress","title":"Step 2: Download binary packages and decompress","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#1-install-wget-or-curl","title":"1. Install wget or curl","text":"

    We'll provide a method of Using binary package to install MatrixOne. If you prefer to use the command line, you can pre-install wget or curl.

    Tips: It is recommended that you download and install one of these two tools to facilitate future operations.

    Install wgetInstall curl

    The wget tool is used to download files from the specified URL. wget is a unique file download tool; it is very stable and has a download speed.

    Go to the Homebrew page and follow the instructions to install Homebrew first and then install wget. To verify that wget is installed successfully, use the following command line:

    wget -V\n

    The successful installation results (only part of the code is displayed) are as follows:

    GNU Wget 1.21.3 \u5728 darwin21.3.0 \u4e0a\u7f16\u8bd1.\n...\nCopyright \u00a9 2015 Free Software Foundation, Inc.\n...\n

    curl is a file transfer tool that works from the command line using URL rules. curl is a comprehensive transfer tool that supports file upload and download.

    Go to the Curl website according to the official installation guide to install curl. To verify that curl is installed successfully, use the following command line:

    curl --version\n

    The successful installation results (only part of the code is displayed) are as follows:

    curl 7.84.0 (x86_64-apple-darwin22.0) libcurl/7.84.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.47.0\nRelease-Date: 2022-06-27\n...\n
    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#2-download-binary-packages-and-decompress","title":"2. Download binary packages and decompress","text":"

    Download Method 1 and Download Method 2 need to install the download tools wget or curl first.

    Downloading method 1: Using wget to install binary packagesDownloading method 2: Using curl to install binary packagesDownloading method 3: Go to the page and download

    Binary for x86 architecture system:

    mkdir -p /User/username/mo/matrixone & cd /User/username/mo\nwget https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-darwin-x86_64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-darwin-x86_64.zip\n

    Binary for ARM architecture system:

    mkdir -p /User/username/mo/matrixone & cd /User/username/mo\nwget https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-darwin-arm64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-darwin-arm64.zip\n

    Binary for x86 architecture system:

    mkdir -p /User/username/mo/matrixone & cd /User/username/mo\ncurl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-darwin-x86_64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-darwin-x86_64.zip\n

    Binary for ARM architecture system:

    mkdir -p /User/username/mo/matrixone & cd /User/username/mo\ncurl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-darwin-arm64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-darwin-arm64.zip\n

    If you want a more intuitive way to download the page, go to the version 1.0.0-rc1, pull down to find the Assets column, and click the installation package mo-v1.0.0-rc1-darwin-x86_64.zip or mo-v1.0.0-rc1-darwin-arm64.zip can be downloaded.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-3-install-the-mo_ctl-tool","title":"Step 3: Install the mo_ctl tool","text":"

    mo_ctl is a command-line tool for deploying, installing, and managing MatrixOne. It is very convenient to perform various operations on MatrixOne. See mo_ctl Tool for complete usage details.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#1-install-the-mo_ctl-tool","title":"1. Install the mo_ctl tool","text":"

    The mo_ctl tool can be installed through the following command:

    wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#2-set-mo_ctl-parameters","title":"2. Set mo_ctl parameters","text":"

    Using the following command sets the MatrixOne binary decompression file directory to the MO_PATH parameter of mo_ctl. mo_ctl will automatically look for the matrixone folder in MO_PATH.

    mo_ctl set_conf MO_PATH=\"/User/username/mo\"\n
    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-4-launch-matrixone-server","title":"Step 4: Launch MatrixOne server","text":"

    Launch the MatrixOne service through the mo_ctl start command.

    If the operation is regular, the following log will appear. The relevant operation logs of MatrixOne will be in /data/mo/logs/.

    > mo_ctl start\n2023-07-07_15:33:45    [INFO]    No mo-service is running\n2023-07-07_15:33:45    [INFO]    Starting mo-service: cd /Users/username/mo/matrixone/matrixone/ && /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml >/Users/username/mo/matrixone/matrixone/logs/stdout-20230707_153345.log 2>/Users/username/mo/matrixone/matrixone/logs/stderr-20230707_153345.log\n2023-07-07_15:33:45    [INFO]    Wait for 2 seconds\n2023-07-07_15:33:48    [INFO]    At least one mo-service is running. Process info:\n2023-07-07_15:33:48    [INFO]      501 66932     1   0  3:33PM ??         0:00.27 /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml\n2023-07-07_15:33:48    [INFO]    Pids:\n2023-07-07_15:33:48    [INFO]    66932\n2023-07-07_15:33:48    [INFO]    Start succeeded\n

    Note

    The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-5-connect-to-matrixone","title":"Step 5: Connect to MatrixOne","text":"

    One-click connection to MatrixOne service through mo_ctl connect command.

    This command will invoke the MySQL Client tool to connect to the MatrixOne service automatically.

    > mo_ctl connect\n2023-07-07_10:30:20    [INFO]    Checking connectivity\n2023-07-07_10:30:20    [INFO]    Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

    Note

    The above connection and login account is the initial accounts root and the password 111; please change the initial password after logging in to MatrixOne; see MatrixOne Password Management. After changing the login username or password, you must set a new username and password through mo_ctl set_conf. For details, please refer to mo_ctl Tool.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/","title":"Using Docker","text":"

    This document will guide you build standalone MatrixOne using Docker.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#step-1-download-and-install-docker","title":"Step 1: Download and install Docker","text":"
    1. Click Get Docker, enter into the Docker's official document page, depending on your operating system, download and install the corresponding Docker. It is recommended to choose Docker version 20.10.18 or later and strive to maintain consistency between the Docker client and Docker server versions.

    2. After the installation, you can verify the Docker version by using the following lines:

      docker --version\n

      The successful installation results are as follows:

      Docker version 20.10.17, build 100c701\n
    3. Open your local Docker client and launch Docker.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#step-2-create-and-run-the-container-of-matrixone","title":"Step 2: Create and run the container of MatrixOne","text":"

    It will pull the image from Docker Hub if not exists. You can choose to pull the stable version image or the develop version image.

    Stable Version Image(1.0.0-rc1 version)Develop Version Image
    docker pull matrixorigin/matrixone:1.0.0-rc1\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.0.0-rc1\n

    If you are using the network in mainland China, you can pull the MatrixOne stable version image on Alibaba Cloud:

    docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.0.0-rc1\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.0.0-rc1\n

    If you want to pull the develop version image, see Docker Hub, get the image tag. An example as below:

    docker pull matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:nightly-commitnumber\n

    If you are using the network in mainland China, you can pull the MatrixOne develop version image on Alibaba Cloud:

    docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\n

    Note: The nightly version is updated once a day.

    Note

    If your Docker version is lower than 20.10.18 or the Docker client and server versions are inconsistent, upgrading to the latest stable version before attempting is recommended. If you choose to proceed with the current versions, you need to add the parameter --privileged=true to the docker run command, as shown below:

    docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.0.0-rc1\n

    Note

    The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

    If you need to mount data directories or customize configure files, see Mount the directory to Docker container.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#step-3-connect-to-standalone-matrixone","title":"Step 3: Connect to standalone MatrixOne","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#install-and-configure-mysql-client","title":"Install and configure MySQL Client","text":"
    1. Click MySQL Community Downloads to enter into the MySQL client download and installation page. According to your operating system and hardware environment, drop down to select Select Operating System > macOS, then drop down to select Select OS Version, and select the download installation package to install as needed.

      Note: MySQL client version 8.0.30 or later is recommended.

    2. Configure the MySQL client environment variables:

      1. Open a new terminal window and enter the following command:

        cd ~\nsudo vim .bash_profile\n
      2. After pressing Enter on the keyboard to execute the above command, you need to enter the root user password, which is the root password you set in the installation window when you installed the MySQL client. If no password has been set, press Enter to skip the password.

      3. After entering/skiping the root password, you will enter .bash_profile, click i on the keyboard to enter the insert state, and you can enter the following command at the bottom of the file:

        export PATH=${PATH}:/usr/local/mysql/bin\n
      4. After the input is completed, click esc on the keyboard to exit the insert state, and enter :wq at the bottom to save and exit.

      5. Enter the command source .bash_profile, press Enter to execute, and run the environment variable.

      6. To test whether MySQL is available:

        • Method 1: Enter mysql -u root -p, press Enter to execute, the root user password is required, if mysql> is displayed, it means that the MySQL client is enabled.

        • Method 2: Run the command mysql --version, if MySQL client is installed successfully, the example code line is as follows: mysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)

      7. If MySQL is available, close the current terminal and browse the next chapter Connect to MatrixOne Server.

    Tips: Currently, MatrixOne is only compatible with the Oracle MySQL client. This means that some features might not work with the MariaDB client or Percona client.

    "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#connect-to-matrixone","title":"Connect to MatrixOne","text":"

    You can use the MySQL command-line client to connect to MatrixOne server. Open a new terminal window and enter the following command:

    mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: # The default initial password is 111\n

    Currently, MatrixOne only supports the TCP listener.

    Info

    The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

    "},{"location":"MatrixOne/Maintain/mo-directory-structure/","title":"MatrixOne Directory Structure","text":"

    After MatrixOne has been installed and connected, the MatrixOne automatically generates the following directories for storing data files or metadata information.

    Enter into the matrixone directory and execute ls to view the directory structure. The related directory structure and uses are as follows:

    matrixone \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//MatrixOne main directory |-- etc \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//configuration file directory \u2502\u00a0\u00a0\u00a0\u00a0 |-- quickstart \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//configration file directory |-- mo-data \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//data file directory \u2502\u00a0\u00a0\u00a0\u00a0 |-- local \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//local fileservice directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- cnservice\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//cn node information directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- dnservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//TN node information directory \u2502\u00a0\u00a0\u00a0\u00a0 |-- etl \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//external table directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- sys \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//Which account does the external table information belong to \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- logs \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//type of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 2022 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//the year of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 10 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//month of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 27 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//the number of days of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- metric \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//system indicators storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- rawlog \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//log storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- statement_info \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//information storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0 \u00a0\u00a0|-- merged \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//Merge records of past external table information \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 2022 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//the year of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 10 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//month of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 27 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//the number of days of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- metric \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//system indicators storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- rawlog \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//log storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- statement_info \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//information storage directory \u2502\u00a0\u00a0\u00a0\u00a0 |-- logservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//logservice directory | \u00a0\u00a0 \u00a0|-- 7c4dccb4-4d3c-41f8-b482-5251dc7a41bf \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//logservice node directory (randomly generated uuid) \u2502\u00a0\u00a0\u00a0\u00a0 |--hostname \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//MatrixOne server domain name \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 00000000000000000001 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//snapshot directory \u2502\u00a0\u00a0\u00a0\u00a0 | \u00a0\u00a0\u00a0|-- exported-snapshot \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//exporting snapshot Directory |\u00a0 \u00a0\u00a0\u00a0\u2502\u00a0\u00a0\u00a0\u00a0 |-- snapshot-part-n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//snapshot partial directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- tandb \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//bootstrap directory |-- s3 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//data storage directory

    "},{"location":"MatrixOne/Maintain/mo_ctl/","title":"mo_ctl Tool","text":"

    mo_ctl is a command-line tool that helps you deploy and install MatrixOne, start and stop control, and connect to the database.

    "},{"location":"MatrixOne/Maintain/mo_ctl/#feature-overview","title":"Feature Overview","text":"

    The operating systems that mo_ctl has adapted so far are shown in the table below:

    OS Version Debian 11 and above Ubuntu 20.04 and above macOS Monterey 12.3 and above

    The current function list of mo_ctl is shown in the table below.

    Command Function mo_ctl help See a list of statements and functions for the mo_ctl tool itself mo_ctl precheck Check dependencies required for MatrixOne source code installation, namely golang, gcc, git, MySQL Client mo_ctl deploy Download and install and compile the corresponding version of MatrixOne; the default is to install the latest stable version mo_ctl start Start MatrixOne service mo_ctl status Check if the MatrixOne service is running mo_ctl stop Stop all MatrixOne service processes mo_ctl restart Restart MatrixOne service mo_ctl connect Call MySQL Client to connect to MatrixOne service mo_ctl upgrade Upgrade/downgrade MatrixOne from the current version to a release version or commit id version mo_ctl set_conf Set various usage parameters mo_ctl get_conf View current parameters mo_ctl uninstall Uninstall MatrixOne from MO_PATH path mo_ctl watchdog Set a scheduled task to ensure the availability of MatrixOne service, check the status of MatrixOne every minute, and automatically pull up the service if the service is found to be suspended mo_ctl sql Execute SQL directly through commands or a text file composed of SQL mo_ctl ddl_convert A tool to convert MySQL DDL statements into MatrixOne statements mo_ctl get_cid View the source version of the current MatrixOne download repository mo_ctl get_branch View the branch version of the current MatrixOne download repository mo_ctl pprof Used to collect MatrixOne profiling data"},{"location":"MatrixOne/Maintain/mo_ctl/#install-mo_ctl","title":"Install mo_ctl","text":"

    Depending on whether you have internet access, you can choose to install the mo_ctl tool online or offline; you need to be careful to consistently execute commands as root or with sudo privileges (and add sudo before each command). Meanwhile, install.sh will use the unzip command to decompress the mo_ctl package; please ensure the unzip command is installed.

    "},{"location":"MatrixOne/Maintain/mo_ctl/#install-online","title":"Install Online","text":"
    wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo bash +x ./install.sh\n\n# alternate address\nwget https://ghproxy.com/https://github.com/matrixorigin/mo_ctl_standalone/blob/main/install.sh && sudo bash +x install.sh\n

    For users running this command in a macOS environment, if you are a non-root user, run install.sh with the following statement:

    sudo -u $(whoami) bash +x ./install.sh\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#install-offline","title":"Install Offline","text":"
    # 1. First, download the installation script to the local computer, and then upload it to the installation machine\nwget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh\nwget https://github.com/matrixorigin/mo_ctl_standalone/archive/refs/heads/main.zip -O mo_ctl.zip\n\n# alternate address\nwget https://ghproxy.com/https://github.com/matrixorigin/mo_ctl_standalone/blob/main/install.sh\nwget https://ghproxy.com/https://github.com/matrixorigin/mo_ctl_standalone/archive/refs/heads/main.zip -O mo_ctl.zip\n\n# 2. Install from offline package\nbash +x ./install.sh mo_ctl.zip\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#quick-start","title":"Quick Start","text":"

    You can quickly install and deploy the stand-alone version of MatrixOne through the following steps. For more information, see Deploy standalone MatrixOne.

    1. Use the mo_ctl help command to view the tool guide.

    2. Use the mo_ctl precheck command to check whether the pre-dependency conditions are met.

    3. Use the mo_ctl get_conf command to set relevant parameters, and the possible parameter configurations are as follows:

      # check default parameter values\nmo_ctl set_conf MO_PATH=\"/data/mo/matrixone\" # set your own mo path\nmo_ctl set_conf MO_GIT_URL=\"https://ghproxy.com/https://github.com/matrixorigin/matrixone.git\" # in case have network issues, you can set this conf by overwriting default value MO_GIT_URL=\"https:// github.com/matrixorigin/matrixone.git\"\n
    4. Use the mo_ctl deploycommand to install and deploy the latest stable version of MatrixOne.

    5. Use the mo_ctl start command to launch the MatrixOne service with the command .

    6. Use the mo_ctl connect command to connect to the MatrixOne service.

    "},{"location":"MatrixOne/Maintain/mo_ctl/#reference-command-guide","title":"Reference command guide","text":""},{"location":"MatrixOne/Maintain/mo_ctl/#help-print-reference-guide","title":"help - print reference guide","text":"
    mo_ctl help\nUsage             : mo_ctl [option_1] [option_2]\n\n[option_1]      : available: connect | ddl_connect | deploy | get_branch | get_cid | get_conf | help | pprof | precheck | query | restart | set_conf | sql | start | status | stop | uninstall | upgrade | watchdog\n  1) connect      : connect to mo via mysql client using connection info configured\n  2) ddl_convert  : convert ddl file to mo format from other types of database\n  3) deploy       : deploy mo onto the path configured\n  4) get_branch   : upgrade or downgrade mo from current version to a target commit id or stable version\n  5) get_cid      : print mo git commit id from the path configured\n  6) get_conf     : get configurations\n  7) help         : print help information\n  8) pprof        : collect pprof information\n  9) precheck     : check pre-requisites for mo_ctl\n  10) restart     : a combination operation of stop and start\n  11) set_conf    : set configurations\n  12) sql         : execute sql from string, or a file or a path containg multiple files\n  13) start       : start mo-service from the path configured\n  14) status      : check if there's any mo process running on this machine\n  15) stop        : stop all mo-service processes found on this machine\n  16) uninstall   : uninstall mo from path MO_PATH=/data/mo/20230712_1228//matrixone\n  17) upgrade     : upgrade or downgrade mo from current version to a target commit id or stable version\n  18) watchdog    : setup a watchdog crontab task for mo-service to keep it alive\n  e.g.            : mo_ctl status\n\n  [option_2]      : Use \" mo_ctl [option_1] help \" to get more info\n  e.g.            : mo_ctl deploy help\n

    Use mo_ctl [option_1] help for instructions on using the next-level mo_ctl [option_1] functionality.

    "},{"location":"MatrixOne/Maintain/mo_ctl/#precheck-check-pre-dependency","title":"precheck - check pre-dependency","text":"

    Before installing MatrixOne from the source code, use mo_ctl precheck to check the pre-dependency conditions. The pre-dependence depends on go/gcc/git/mysql(client).

    mo_ctl precheck help\nUsage         : mo_ctl precheck # check pre-requisites for mo_ctl\n   Check list : go gcc git mysql\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#deploy-install-matrixone","title":"deploy - install MatrixOne","text":"

    Use mo_ctl deploy [mo_version] [force] to install and deploy a stable version of MatrixOne, or a specified version. The force option can delete the existing version of MatrixOne in the same directory and force a new version to be reinstalled.

    mo_ctl deploy help\nUsage         : mo_ctl deploy [mo_version] [force] # deploy mo onto the path configured\n  [mo_version]: optional, specify an mo version to deploy\n  [force]     : optional, if specified will delete all content under MO_PATH and deploy from beginning\n  e.g.        : mo_ctl deploy             # default, same as mo_ctl deploy 1.0.0-rc1\n              : mo_ctl deploy main        # deploy development latest version\n              : mo_ctl deploy d29764a     # deploy development version d29764a\n              : mo_ctl deploy 1.0.0-rc1       # deploy stable verson 1.0.0-rc1\n              : mo_ctl deploy force       # delete all under MO_PATH and deploy verson 1.0.0-rc1\n              : mo_ctl deploy 1.0.0-rc1 force # delete all under MO_PATH and deploy stable verson 1.0.0-rc1 from beginning\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#start-launch-matrixone","title":"start - launch MatrixOne","text":"

    Use mo_ctl start to start MatrixOne service; the startup file path is located under MO_PATH.

    mo_ctl start help\nUsage         : mo_ctl start # start mo-service from the path configured\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#stop-stop-matrixone","title":"stop - stop MatrixOne","text":"

    Use mo_ctl stop [force] to stop all MatrixOne services on local machine, and if multiple MatrixOne services are running, they will also be stopped.

     mo_ctl stop help\nUsage : mo_ctl stop [force] # stop all mo-service processes found on this machine\n [force] : optional, if specified, will try to kill mo-services with -9 option, so be very carefully\n  e.g.: mo_ctl stop # default, stop all mo-service processes found on this machine\n              : mo_ctl stop force # stop all mo-services with kill -9 command\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#restart-restart-matrixone","title":"restart - restart MatrixOne","text":"

    Use mo_ctl restart [force] to stop all MatrixOne services on this machine and restart the MatrixOne services located in the path of MO_PATH.

    mo_ctl restart help\nUsage         : mo_ctl restart [force] # a combination operation of stop and start\n [force]      : optional, if specified, will try to kill mo-services with -9 option, so be very carefully\n  e.g.        : mo_ctl restart         # default, stop all mo-service processes found on this machine and start mo-serivce under path of conf MO_PATH\n              : mo_ctl restart force   # stop all mo-services with kill -9 command and start mo-serivce under path of conf MO_PATH\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#connect-using-mysql-client-to-connect-matrixone","title":"connect - using mysql-client to connect MatrixOne","text":"

    Use mo_ctl connect to connect to MatrixOne service, the connection parameters are set by mo_ctl tool.

    mo_ctl connect help\nUsage         : mo_ctl connect # connect to mo via mysql client using connection info configured\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#status-check-the-status-of-matrixone","title":"status - Check the status of MatrixOne","text":"

    Use mo_ctl status to check whether MatrixOne is running or not.

    mo_ctl status help\nUsage         : mo_ctl status # check if there's any mo process running on this machine\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#get_cid-print-matrixone-code-commit-id","title":"get_cid - print MatrixOne code commit id","text":"

    Use mo_ctl get_cid to print the MatrixOne repository commit id under the current MO_PATH path.

    mo_ctl get_cid help\nUsage : mo_ctl get_cid # print mo commit id from the path configured\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#get_branch-print-matrixone-code-commit-id","title":"get_branch - print MatrixOne code commit id","text":"

    Use mo_ctl get_branch to print the MatrixOne codebase branch under the current MO_PATH path.

    mo_ctl get_branch help\nUsage           : mo_ctl get_branch        # print which git branch mo is currently on\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#pprof-collect-performance-information","title":"pprof - Collect performance information","text":"

    Use mo_ctl pprof [item] [duration] to collect related performance information of MatrixOne, mainly for developers to debug.

    mo_ctl pprof help\nUsage         : mo_ctl pprof [item] [duration] # collect pprof information\n  [item]      : optional, specify what pprof to collect, available: profile | heap | allocs\n  1) profile  : default, collect profile pprof for 30 seconds\n  2) heap     : collect heap pprof at current moment\n  3) allocs   : collect allocs pprof at current moment\n  [duration]  : optional, only valid when [item]=profile, specifiy duration to collect profile\n  e.g.        : mo_ctl pprof\n              : mo_ctl pprof profile    # collect duration will use conf value PPROF_PROFILE_DURATION from conf file or 30 if it's not set\n              : mo_ctl pprof profile 30\n              : mo_ctl pprof heap\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#set_conf-configuration-parameters","title":"set_conf - configuration parameters","text":"

    Use mo_ctl set_conf [conf_list] to configure 1 or more usage parameters.

    mo_ctl set_conf help\nUsage         : mo_ctl setconf [conf_list] # set configurations\n [conf_list]  : configuration list in key=value format, seperated by comma\n  e.g.        : mo_ctl setconf MO_PATH=/data/mo/matrixone,MO_PW=M@trix0riginR0cks,MO_PORT=6101  # set multiple configurations\n              : mo_ctl setconf MO_PATH=/data/mo/matrixone                                       # set single configuration\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#get_conf-get-parameter-list","title":"get_conf - get parameter list","text":"

    Use mo_ctl get_conf [conf_list] to get one or more current configuration items.

    mo_ctl get_conf help\nUsage         : mo_ctl getconf [conf_list] # get configurations\n [conf_list]  : optional, configuration list in key, seperated by comma.\n              : use 'all' or leave it as blank to print all configurations\n  e.g.        : mo_ctl getconf MO_PATH,MO_PW,MO_PORT  # get multiple configurations\n              : mo_ctl getconf MO_PATH                # get single configuration\n              : mo_ctl getconf all                    # get all configurations\n              : mo_ctl getconf                        # get all configurations\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#mo_ctl-get_conf-detailed-parameter-list","title":"mo_ctl get_conf - Detailed Parameter List","text":"

    Using mo_ctl get_conf will print a list of all the parameters used by the current tool. Their meanings and value ranges are shown in the table below.

    Parameter Name Function Value Specification MO_PATH Location of MatrixOne's code repository and executables Folder path MO_LOG_PATH Location of MatrixOne's logs Folder path, default: ${MO_PATH}/matrixone/logs MO_HOST IP address for connecting to MatrixOne service IP address, default: 127.0.0.1 MO_PORT Port number for connecting to MatrixOne service Port number, default: 6001 MO_USER Username for connecting to MatrixOne service Username, default: root MO_PW Password for connecting to MatrixOne service Password, default: 111 CHECK_LIST Dependencies required for precheck Default: (\"go\" \"gcc\" \"git\" \"mysql\") GCC_VERSION gcc version to be checked in precheck Default: 8.5.0 GO_VERSION go version to be checked in precheck Default: 1.20 MO_GIT_URL Repository URL for fetching MatrixOne source code Default: https://github.com/matrixorigin/matrixone.git MO_DEFAULT_VERSION Default version of MatrixOne to be fetched Default: 1.0.0-rc1 GOPROXY Address of GOPROXY used for faster dependency retrieval in China Default: https://goproxy.cn, direct STOP_INTERVAL Interval to wait for service status check after stopping the service Default: 5 seconds START_INTERVAL Interval to wait for service status check after starting the service Default: 2 seconds MO_DEBUG_PORT Debug port for MatrixOne, usually used by developers Default: 9876 MO_CONF_FILE Launch configuration file for MatrixOne Default: ${MO_PATH}/matrixone/etc/launch/launch.toml RESTART_INTERVAL Interval to wait for service status check after restarting the service Default: 2 seconds PPROF_OUT_PATH Output path for collecting golang performance data Default: /tmp/pprof-test/ PPROF_PROFILE_DURATION Duration for collecting golang performance data Default: 30 seconds"},{"location":"MatrixOne/Maintain/mo_ctl/#ddl_convert-ddl-format-conversion","title":"ddl_convert - DDL format conversion","text":"

    Use mo_ctl ddl_convert [options] [src_file] [tgt_file] to convert a DDL file from other database syntax formats to MatrixOne's DDL format, currently only supported by mysql_to_mo mode.

    mo_ctl ddl_convert help\nUsage           : mo_ctl ddl_convert [options] [src_file] [tgt_file] # convert a ddl file to mo format from other types of database\n [options]      : available: mysql_to_mo\n [src_file]     : source file to be converted, will use env DDL_SRC_FILE from conf file by default\n [tgt_file]     : target file of converted output, will use env DDL_TGT_FILE from conf file by default\n  e.g.          : mo_ctl ddl_convert mysql_to_mo /tmp/mysql.sql /tmp/mo.sql\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#sql-execute-sql","title":"sql - Execute SQL","text":"

    Use mo_ctl sql [sql] to execute SQL text or SQL files.

    mo_ctl sql help\nUsage           : mo_ctl sql [sql]                 # execute sql from string, or a file or a path containg multiple files\n  [sql]         : a string quote by \"\", or a file, or a path\n  e.g.          : mo_ctl sql \"use test;select 1;\"  # execute sql \"use test;select 1\"\n                : mo_ctl sql /data/q1.sql          # execute sql in file /data/q1.sql\n                : mo_ctl sql /data/                # execute all sql files with .sql postfix in /data/\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#uninstall-uninstall-matrixone","title":"uninstall - Uninstall MatrixOne","text":"

    Use mo_ctl uninstall to uninstall MatrixOne from MO_PATH.

    mo_ctl uninstall help\nUsage           : mo_ctl uninstall        # uninstall mo from path MO_PATH=/data/mo//matrixone\n                                          # note: you will need to input 'Yes/No' to confirm before uninstalling\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#upgrade-upgradedowngrade-matrixone-version","title":"upgrade - upgrade/downgrade MatrixOne version","text":"

    Use mo_ctl upgrade version or mo_ctl upgrade commitid to upgrade or downgrade MatrixOne from the current version to a stable version or a commit id version.

    mo_ctl upgrade help\nUsage           : mo_ctl upgrade [version_commitid]   # upgrade or downgrade mo from current version to a target commit id or stable version\n [commitid]     : a commit id such as '38888f7', or a stable version such as '1.0.0-rc1'\n                : use 'latest' to upgrade to latest commit on main branch if you don't know the id\n  e.g.          : mo_ctl upgrade 38888f7              # upgrade/downgrade to commit id 38888f7 on main branch\n                : mo_ctl upgrade latest               # upgrade/downgrade to latest commit on main branch\n                : mo_ctl upgrade 1.0.0-rc1                # upgrade/downgrade to stable version 1.0.0-rc1\n
    "},{"location":"MatrixOne/Maintain/mo_ctl/#watchdog-keep-alive-matrixone","title":"watchdog - Keep Alive MatrixOne","text":"

    Use mo_ctl watchdog [options] to set a scheduled task to ensure the availability of MatrixOne service, check the status of MatrixOne every minute, and automatically pull up the service if it finds that the service is suspended.

    mo_ctl watchdog help\nUsage           : mo_ctl watchdog [options]   # setup a watchdog crontab task for mo-service to keep it alive\n [options]      : available: enable | disable | status\n  e.g.          : mo_ctl watchdog enable      # enable watchdog service for mo, by default it will check if mo-servie is alive and pull it up if it's dead every one minute\n                : mo_ctl watchdog disable     # disable watchdog\n                : mo_ctl watchdog status      # check if watchdog is enabled or disabled\n                : mo_ctl watchdog             # same as mo_ctl watchdog status\n
    "},{"location":"MatrixOne/Maintain/mount-data-by-docker/","title":"Mount directory to Docker container","text":"

    This document will teach you how to mount the data directory or your customized configuration file to the Docker container when you launch MatrixOne by using Docker.

    "},{"location":"MatrixOne/Maintain/mount-data-by-docker/#mount-the-data-directory","title":"Mount the data directory","text":"

    To ensure the safety of the data directory, mount the local data directory to the Docker container by the following steps:

    1. To check if MatrixOne has been running in Docker, execute the following command:

      docker ps -a\n
    2. To stop the running container if MatrixOne has been running in Docker, execute the following command:

      docker stop <containerID>\ndocker rm <containerID>\n

      Skip this step if MatrixOne is not running in Docker.

    3. Mount the local empty directory to the Docker container directory /mo-data, execute the following command:

      sudo docker run --name <name> --privileged -d -p 6001:6001 -v ${local_data_path}/mo-data:/mo-data:rw matrixorigin/matrixone:1.0.0-rc1\n
      Parameters Description ${local_data_path}/mo-data:/mo-data mount the local disk directory ${local_data_path}/mo-data to the container directory /mo-data Tips: The local data directory to be mounted must be an empty directory.
    "},{"location":"MatrixOne/Maintain/mount-data-by-docker/#mount-the-customized-configuration-file","title":"Mount the customized configuration file","text":"

    If you need to modify the configuration file. In that case, it would be best to copy the configuration file in Docker to your local directory and then mount the local directory where the configuration file is stored to the Docker container directory. Refer to the following steps to mount the configuration file to the Docker container:

    1. To check if MatrixOne has been running in Docker, execute the following command:

      docker ps -a\n
    2. To launch MatrixOne MatrixOne has not been running in Docker, execute the following command:

      docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.0.0-rc1\n
    3. Check the containerID that MatrixOne has been running in Docker, and copy the configuration file directory to the local directory:

      docker ps -a\ndocker cp <containerID>:/etc .\n
    4. To stop the MatrixOne when the copy is completed, execute the following command:

      docker stop <containerID>\ndocker rm <containerID>\n
    5. (Optional) Modify the configuration file and save it.

    6. Mount the configuration file to the Docker container directory and launch MatrixOne. Execute the following command:

      sudo docker run --name <name> --privileged -d -p 6001:6001 -v ${local_config_path}/etc:/etc:rw  --entrypoint \"/mo-service\" matrixorigin/matrixone:1.0.0-rc1 -launch /etc/launch/launch.toml\n
      Parameters Description ${local_config_path}/etc:/etc mount the local customize configration directory ${local_config_path}/etc to the container directory /etc --entrypoint \"/mo-service\" Specifies that the container starts the MatrixOne service -launch /etc/launch/launch.toml launch mode in /etc/

    For more information on the description of Docker run, run the commands docker run --help.

    "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/","title":"MatrixOne Backup and Recovery Overview","text":"

    Database backup and recovery are core operations for any database management system and are crucial for ensuring data security and availability. MatrixOne provides flexible and powerful database backup and recovery capabilities to ensure the integrity and continuity of user data. This article provides an overview of the importance of MatrixOne database backup and recovery, backup strategies, and backup methods.

    "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#backup-and-recovery-strategies","title":"Backup and Recovery Strategies","text":"

    Database backup and recovery can restore operational status in various disaster recovery scenarios.

    Here are backup and recovery methods for different situations:

    1. Operating System Crash:

      • With Physical Backup: Restore the entire database state using physical backup after a crash. Restore the backup to normal hardware conditions and apply redo logs to ensure data consistency.
      • With Logical Backup: Rebuild the database architecture and data on a new server using logical backup. First, install the database software, execute SQL statements from the logical backup to create tables, indexes, and more, and then import the data.
    2. Power (Detection) Failure:

      • With Physical Backup: Recover the database using physical backup after a failure. Restore the backup to normal hardware conditions and apply redo logs for data consistency.
      • With Logical Backup: Similarly, rebuild the database on a new server using logical backup.
    3. File System Crash:

      • With Physical Backup: Use a physical backup to recover the database, restore the backup to normal hardware conditions, and apply redo logs for data consistency.
      • With Logical Backup: After a crash, rebuild the database architecture and data on a new server.
    4. Hardware Issues (e.g., Hard Drive, Motherboard):

      • With Physical Backup: Recover the database using physical backup, restoring the backup to new hardware conditions and applying redo logs for data consistency.
      • With Logical Backup: Rebuild the database on new hardware using logical backup.

    For backup and recovery, consider the following strategies:

    1. Backup Frequency: Determine the frequency of backups, typically divided into full and incremental backups. Full backups consume more storage space and time but offer faster recovery, while incremental backups are more economical.

    2. Backup Storage: Choose a secure backup storage location to ensure backup data is not easily compromised or lost. Typically, use offline storage media or cloud storage for backups.

    3. Backup Retention Period: Determine the retention period for backup data to facilitate historical data retrieval and recovery when needed. Establish data retention policies based on regulations and business requirements.

    Regardless of the recovery scenario, follow these principles:

    1. Consider stopping database operations to prevent data changes.
    2. Choose an appropriate backup for recovery based on backup type.
    3. Restore backup files.
    4. Consider applying corresponding redo logs to ensure data consistency.
    5. Start the database and perform the necessary testing.
    "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#database-backup-methods","title":"Database Backup Methods","text":"

    MatrixOne provides multiple backup methods, considering database requirements, performance, resources, and recovery time.

    MatrixOne databases offer various backup tools to meet different scenarios and needs:

    1. modump: Used for exporting data and schemas from the database. It generates recoverable SQL scripts for logical backups.

    2. mo-backup: Used for physical backup and recovery. mo-backup is a tool for physical backup and recovery of MatrixOne enterprise services, helping protect your MatrixOne database and perform reliable recovery operations when needed.

      Note

      mo-backup is a physical backup and recovery tool for enterprise-level services. Contact your MatrixOne account manager for the tool download path and user guide.

    "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#logical-backup-and-recovery","title":"Logical Backup and Recovery","text":""},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#using-select-into-outfile-for-backup","title":"Using SELECT INTO OUTFILE for Backup","text":"

    Use the SELECT ... INTO OUTFILE command to export retrieved data in a specific format to a file. The exported file is created by the MatrixOne service and is only available on the MatrixOne server host. Exporting to the client file system is not supported. Ensure that the export directory does not have files with the same name to avoid overwriting new files.

    For more information on operational steps and examples, see Export data by SELECT INTO.

    "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#using-modump-for-backup","title":"Using modump for Backup","text":"

    MatrixOne supports logical backup using the modump tool, which generates SQL statements that can be used to recreate database objects and data.

    For more information on operational steps and examples, see Export data by MODUMP.

    "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#using-command-line-batch-import-for-recovery","title":"Using Command-Line Batch Import for Recovery","text":"

    MatrixOne supports inserting many rows into database tables using the LOAD DATA command. It also supports importing table structures and data into the entire database using the' SOURCE' command.

    For more information, see Bulk Load Overview.

    "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/","title":"Backup and Recovery Concepts","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#physical-backup-vs-logical-backup","title":"Physical Backup vs. Logical Backup","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#physical-backup","title":"Physical Backup","text":"

    Physical backup directly copies database files to a backup medium, such as tape or disk. This method involves copying all physical data blocks of the database, including data files, control files, and redo log files. The backed-up data is the binary data stored on disk, making recovery operations typically faster.

    "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#logical-backup","title":"Logical Backup","text":"

    Logical backup involves backing up logical objects (e.g., tables, indexes, stored procedures) in the database using SQL statements. This backup method exports the definitions and data of logical objects to a backup file but does not include the binary data of database files. Although recovery may be slower, backup data is usually more readable and modifiable.

    "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#differences-between-physical-and-logical-backup","title":"Differences Between Physical and Logical Backup","text":"

    The primary difference between physical and logical backup lies in the form of the backed-up data. Physical backup copies the binary data on disk, while logical backup backs up the definitions and data of analytical objects. The two methods have differences in backup speed, data size, and backup flexibility.

    "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#full-backup-incremental-backup-and-differential-backup","title":"Full Backup, Incremental Backup, and Differential Backup","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#full-backup","title":"Full Backup","text":"

    Full backup involves backing up the entire dataset to storage devices, including all files and folders. While it is typically time-consuming and requires substantial storage space, it can restore data without relying on other backup files.

    "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#incremental-backup","title":"Incremental Backup","text":"

    Incremental backup only backs up recently changed or added files or data blocks. It backs up changes made since the last backup, typically consuming less backup time and storage space. Incremental backups are often performed between regular full backups to ensure the backup data stays up-to-date. You need all incremental backups and the latest full backup to restore data.

    "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#differential-backup","title":"Differential Backup","text":"

    Differential backup backs up data that has changed since the last full backup, resulting in more extensive backup data and longer backup times than incremental backups. When restoring data, you only need to restore the latest full and differential backups. As it does not depend on previous backup data, the recovery process is relatively simpler, and backup and restoration times are shorter.

    "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#differences-between-full-incremental-and-differential-backup","title":"Differences Between Full, Incremental, and Differential Backup","text":"
    • Full backup provides a complete data backup but requires more time and storage space.
    • Incremental backup is suitable for environments with minimal data changes, saving backup storage space and time but requiring reliance on previous backup data.
    • Differential backup suits environments with significant data changes, resulting in more extensive backup data, shorter recovery times, and a relatively straightforward backup and recovery process.
    "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#recovery","title":"Recovery","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#physical-recovery","title":"Physical Recovery","text":"

    Physical recovery involves database recovery using physical backups. It is typically used in severe failures such as disk failures, operating system failures, or file system failures. In physical recovery, specialized recovery tools or software read backup files or storage media's actual data blocks and attempt to repair damaged blocks.

    Physical recovery can quickly restore the database without executing SQL statements or other high-level operations. Additionally, physical recovery can restore all database objects, including tables, indexes, stored procedures, and more.

    "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#complete-recovery-vs-incomplete-recovery","title":"Complete Recovery vs. Incomplete Recovery","text":"
    • Complete Recovery: Applies all redo logs from the backup set, restoring data to a point where all logs are committed.
    • Incomplete Recovery: Applies some redo logs or incremental backups, restoring data to a specific time defined by the backup redo logs.
    "},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/","title":"Backup and Restore by using mo-dump","text":"

    It is essential to back up your databases to recover your data and be up and running again in case problems occur, such as system crashes, hardware failures, or users deleting data by mistake. Backups are also essential as a safeguard before upgrading a MatrixOne installation, and they can be used to transfer a MatrixOne building to another system.

    MatrixOne currently only supports logical backup through the modump utility. modump is a command-line utility used to generate the logical backup of the MatrixOne database. It produces SQL Statements that can be used to recreate the database objects and data. You can look up the syntax and usage guide in the modump chapter.

    We will take a simple example to walk you through the backup and restore process with the modump utility.

    "},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/#steps","title":"Steps","text":""},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/#1-build-the-modump-binary","title":"1. Build the modump binary","text":"

    For more information on how to build the modump binary, see Build the modump binary.

    If the modump binary has been built, you can continue to browse the next chapter Generate the backup of a single database.

    "},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/#2-generate-the-backup-of-a-single-database","title":"2. Generate the backup of a single database","text":"

    We have a database t which is created by the following SQL.

    DROP DATABASE IF EXISTS `t`;\nCREATE DATABASE `t`;\nUSE `t`;\ncreate table t1\n(\n    c1  int primary key auto_increment,\n    c2  tinyint not null default 4,\n    c3  smallint,\n    c4  bigint,\n    c5  tinyint unsigned,\n    c6  smallint unsigned,\n    c7  int unsigned,\n    c8  bigint unsigned,\n    c9  float,\n    c10 double,\n    c11 date,\n    c12 datetime,\n    c13 timestamp on update current_timestamp,\n    c14 char,\n    c15 varchar,\n    c16 json,\n    c17 decimal,\n    c18 text,\n    c19 blob,\n    c20 uuid\n);\ninsert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2019-01-01', '2019-01-01 00:00:00', '2019-01-01 00:00:00', 'a', 'a', '{\"a\":1}','1212.1212', 'a', 'aza', '00000000-0000-0000-0000-000000000000');\n

    If you want to generate the backup of the single database, run the following command. The command will generate the backup of the t database with structure and data in the t.sql file.

    ./modump -u root -p 111 -h 127.0.0.1 -P 6001 -db t > t.sql\n

    If you want to generate the backup of a single table in a database, run the following command. The command will generate the backup of the t1 table of t database with structure and data in the t.sql file.

    ./modump -u root -p 111 -db t -tbl t1 > t1.sql\n

    Note

    If you have multiple databases, you need to run modump multiple times to generate SQLs one by one.

    "},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/#3-restore-the-backup-to-matrixone-server","title":"3. Restore the backup to MatrixOne server","text":"

    Restoring a MatrixOne database using the exported 'sql' file is very simple. To restore the database, you must create an empty database and use mysql client to restore.

    Connect to MatrixOne with MySQL client in the same server, and make sure the exported sql file is also in the same machine as the MySQL client.

    mysql> create database t if not exists;\nmysql> source /YOUR_SQL_FILE_PATH/t.sql\n

    Once command executes successfully, execute the following command to verify that all objects have been created on the t database.

    mysql> use t;\nmysql> show tables;\nmysql> select count(*) from t1;\n
    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/","title":"Migrate data from MySQL to MatrixOne","text":"

    This document will guide you on how to migrate data from MySQL to MatrixOne.

    MatrixOne maintains a high degree of compatibility with MySQL syntax, so no other operations are required during the migration process to achieve seamless migration.

    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#data-type-difference","title":"Data type difference","text":"

    In MatrixOne, while maintaining the same name as MySQL, there are slight differences in accuracy and range between data types and MySQL. For more information, see Data Types.

    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#online-migration","title":"Online Migration","text":"

    This chapter will guide you to use third-party tools - DBeaver to migrate data from MySQL to MatrixOne.

    • Applicable scenarios: scenarios where the amount of data is small (recommended less than 1GB), and the migration speed is not sensitive.
    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#preparation","title":"Preparation","text":"
    • Springboard machine with a graphical interface: it can connect to the source of MySQL and the target of MatrixOne.
    • Data Migration Tool: Download DBeaver on the springboard machine.
    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-1-migrate-table-structure","title":"Step 1: Migrate table structure","text":"

    Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from MySQL to MatrixOne.

    1. Open DBeaver, select the table to be migrated from MySQL, right-click and select Generate SQL > DDL Click Copy, first copy this SQL to a text editor for text editing Name the filer as tpch_ddl.sql and save it locally on the springboard machine.

    2. Connect to MatrixOne and create a new database and table in MatrixOne:

      create database tpch;\nuse tpch;\nsource '/YOUR_PATH/tpch_ddl.sql'\n
    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-2-migrate-data","title":"Step 2: Migrate data","text":"
    1. Open DBeaver, select the table to be migrated from MySQL, right-click and select Export Data:

    2. In the Conversion Target > Export Target window, select Database, click Next; in the Table Mapping window, select Target Container, and select the MatrixOne database for the target container tpch:

    3. In the Extraction Settings and Data Loading Settings windows, set the number of selected extractions and inserts. To trigger MatrixOne's direct write S3 strategy, it is recommended to fill in 5000:

    4. After completing the settings, DBeaver starts to migrate the data, and after completion, DBeaver will prompt that the migration is successful.

    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-3-check-the-data","title":"Step 3: Check the data","text":"

    After the migration is complete, the data can be inspected as follows:

    • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

    • Compare the results through related queries; you can also refer to the Complete TPCH testing query example to compare the results.

    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#offline-migration","title":"Offline Migration","text":"

    This chapter will guide you through importing to MatrixOne through offline files.

    • Applicable scenarios: scenarios with a large amount of data (more significant than 1GB) and sensitive to migration speed.
    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#preparation_1","title":"Preparation","text":"
    • Springboard machine with a graphical interface: it can be connected to the source end of MySQL and the target end of MatrixOne.
    • Data Migration Tool: Download DBeaver to the springboard machine.
    • Install mysqldump in MySQL server. If you are not familiar with how to use mysqldump, see mysqldump tutorial
    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-1-migrate-table-structure_1","title":"Step 1: Migrate table structure","text":"

    Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from MySQL to MatrixOne.

    1. Open DBeaver, select the table to be migrated from MySQL, right-click and select Generate SQL > DDL > Copy, first copy this SQL to a text editor, and name the text editor tpch_ddl.sql, saved locally on the springboard machine.

    2. Connect to MatrixOne and create a new database and table in MatrixOne:

      create database tpch;\nuse tpch;\nsource '/YOUR_PATH/tpch_ddl.sql'\n
    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-2-migrate-data_1","title":"Step 2: Migrate data","text":"

    MatrixOne has two data migration methods to choose from: INSERT and LOAD DATA. When the amount of data is greater than 1GB, it is recommended to use LOAD DATA first, followed by INSERT.

    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#load-data","title":"LOAD DATA","text":"
    1. Use mysqldump to export the MySQL data table as a CSV format file. Make sure you have write access to the file path and check the secure_file_priv configuration:

      mysqldump -u root -p -t -T /{filepath} tpch --fields-terminated-by='|'\n
    2. Connect to MatrixOne and import the exported CSV data into MatrixOne:

      mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n

    For more operation examples of LOAD DATA, see Bulk Load Overview.

    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#insert","title":"INSERT","text":"

    The INSERT statement needs to use mysqldump to export the logical statement first and then import it into MatrixOne:

    1. Use mysqldump to export data. To ensure that MatrixOne directly writes to S3 when inserting, inserting as large a batch as possible is recommended. The net_buffer_length parameter should start at 10MB:

      mysqldump -t tpch -uroot -p --net_buffer_length=10m > tpch_data.sql\n
    2. On the MatrixOne side, execute the SQL file, there will be an error message during the process, but it will not affect the data insertion:

      source '/YOUR_PATH/tpch_data.sql'\n

    For more examples of INSERT operations, see Insert Data.

    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-3-check-the-data_1","title":"Step 3: Check the data","text":"

    After the migration is complete, the data can be inspected as follows:

    • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

    • Compare the results through related queries; you can also refer to the Complete a TPCH Test with MatrixOne query example to compare the results.

    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#reference-example","title":"Reference example","text":"

    If you are a novice and want to migrate a small amount of data, see Import data by using the source command.

    "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#constraints","title":"Constraints","text":"

    MatrixOne 1.0.0-rc1 version already supports MySQL table creation statements, so you can smoothly migrate MySQL tables to MatrixOne. However, it should be noted that during the migration process, some keywords incompatible with MySQL, such as engine=, will be automatically ignored in MatrixOne and will not affect the migration of the table structure.

    However, it should be noted that although MatrixOne supports MySQL table creation statements, manual modification is still required if the migrated table contains incompatible data types, triggers, functions, or stored procedures. For more detailed compatibility information, see MySQL Compatibility.

    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/","title":"Migrate data from SQL Server to MatrixOne","text":"

    This document will guide you on how to migrate data from Oracle to MatrixOne.

    Oracle is currently the most widely used commercial database in the world. Its usage scenarios and popularity rank first in DBEngine all year round. MatrixOne can also support the scenario of migrating data from Oracle. According to the size of Oracle data, this article still recommends using online and offline modes for migration.

    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#data-type-difference","title":"Data type difference","text":"

    There are many differences between MatrixOne and Oracle's built-in data types. Other types can replace some differences, and some cannot be supported temporarily. The specific list is as follows:

    Oracle MatrixOne varchar2 replace with text nchar/nvarcahr replace with char/varchar NUMBER(3,0), NUMBER(5,0) replace with smallint NUMBER(10,0) replace with int NUMBER(38,0) replace with bitint NUMBER(n,p) (p>0) replace with decimal(n,p) binary_float/binary_double replace with float/double long replace with text long raw replace with blob raw replace with varbinary clob/nclob replace with text bfile Not supported yet rowid/urowid Not Supported user-defined types Not supported yet any Not supported yet xml Not supported yet spatial Not supported yet"},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#online-migration","title":"Online Migration","text":"

    This chapter will guide you to use third-party tools - DBeaver to migrate data from Oracle to MatrixOne.

    Through DBeaver, the source data is obtained in batches, and then the data is inserted into the target database as INSERT. If an error is reported during the migration process that the heap space is insufficient, please try to adjust the size of each batch of fetched and inserted data.

    • Applicable scenarios: scenarios where the amount of data is small (recommended less than 1GB), and the migration speed is not sensitive.

    • The recommended configuration of the springboard machine where DBeaver is installed: RAM 16GB or more.

    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#preparation","title":"Preparation","text":"
    • Springboard machine with a graphical interface: it can connect to the source of Oracle and the target of MatrixOne.
    • Data Migration Tool: Download DBeaver on the springboard machine.
    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-1-migrate-table-structure","title":"Step 1: Migrate table structure","text":"

    Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from Oracle to MatrixOne.

    1. Open DBeaver, select the table to be migrated from Oracle, right-click and select Generate SQL > DDL Click Copy, first copy this SQL to a text editor for text editing Name the filer as oracle_ddl.sql and save it locally on the springboard machine.

    2. Use the following command to replace keywords not supported by MatrixOne in the oracle_ddl.sql file:

      # The commands executed by the Linux system are as follows:\nsed -i '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n\n# The commands executed by the MacOS system are as follows:\nsed -i '' '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '' '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n
    3. Connect to MatrixOne and create a new database and table in MatrixOne:

      create database tpch;\nuse tpch;\nsource '/YOUR_PATH/oracle_ddl.sql'\n
    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-2-migrate-data","title":"Step 2: Migrate data","text":"
    1. Open DBeaver, select the table to be migrated from Oracle, right-click and select Export Data:

    2. In the Conversion Target > Export Target window, select Database, click Next; in the Table Mapping window, select Target Container, and select the MatrixOne database for the target container tpch:

    3. In the Extraction Settings and Data Loading Settings windows, set the number of selected extractions and inserts. To trigger MatrixOne's direct write S3 strategy, it is recommended to fill in 5000:

    4. After completing the settings, DBeaver starts to migrate the data, and after completion, DBeaver will prompt that the migration is successful.

    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-3-check-the-data","title":"Step 3: Check the data","text":"

    After the migration is complete, the data can be inspected as follows:

    • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

    • Compare the results through related queries; you can also refer to the Complete TPCH testing query example to compare the results.

    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#offline-migration","title":"Offline Migration","text":"

    This chapter will guide you through importing to MatrixOne through offline files.

    • Applicable scenarios: scenarios with a large amount of data (more significant than 1GB) and sensitive to migration speed.
    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#preparation_1","title":"Preparation","text":"
    • Springboard machine with a graphical interface: it can be connected to the source end of Oracle and the target end of MatrixOne.
    • Data Migration Tool: Download DBeaver to the springboard machine.
    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-1-migrate-table-structure_1","title":"Step 1: Migrate table structure","text":"

    Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from Oracle to MatrixOne.

    1. Open DBeaver, select the table to be migrated from Oracle, right-click and select Generate SQL > DDL > Copy, first copy this SQL to a text editor, and name the text editor oracle_ddl.sql, saved locally on the springboard machine.

    2. Use the following command to replace keywords that MatrixOne does not support in the oracle_ddl.sql file:

      # The commands executed by the Linux system are as follows:\nsed -i '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n\n# The commands executed by the MacOS system are as follows:\nsed -i '' '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '' '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n
    3. Connect to MatrixOne and create a new database and table in MatrixOne:

      create database tpch;\nuse tpch;\nsource '/YOUR_PATH/oracle_ddl.sql'\n
    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-2-migrate-data_1","title":"Step 2: Migrate data","text":"

    MatrixOne has two data migration methods to choose from: INSERT and LOAD DATA. When the amount of data is greater than 1GB, it is recommended to use LOAD DATA first, followed by INSERT.

    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#load-data","title":"LOAD DATA","text":"

    Use DBeaver to export the Oracle data table to CSV format first, and use MatrixOne's parallel loading function to migrate the data to MatrixOne:

    1. Open DBeaver, select the table to be migrated, right-click and select Export Data to export the Oracle data table as a CSV format file:

    2. In the Conversion Goals > Export Goals window, select CSV and click Next:

    3. Connect to MatrixOne and import the exported CSV data into MatrixOne:

      mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n

    For more operation examples of LOAD DATA, see Bulk Load Overview.

    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#insert","title":"INSERT","text":"

    The INSERT statement needs to use DBeaver to export the logical statement first and then import it into MatrixOne:

    1. Use DBeaver to export data: Open DBeaver, select the table to be migrated from Oracle, right-click, and select Export Data > SQL. To ensure that MatrixOne directly writes to S3 when inserting, it is recommended to insert parameters in batches The number of data rows per statement is set to 5000:

    2. On the MatrixOne side, execute the SQL file:

      source '/YOUR_PATH/oracle_data.sql'\n

    For more examples of INSERT operations, see Insert Data.

    "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-3-check-the-data_1","title":"Step 3: Check the data","text":"

    After the migration is complete, the data can be inspected as follows:

    • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

    • Compare the results through related queries; you can also refer to the Complete a TPCH Test with MatrixOne query example to compare the results.

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/","title":"Migrate data from PostgreSQL to MatrixOne","text":"

    This document will guide you in migrating data from PostgreSQL to MatrixOne.

    PostgreSQL is currently one of the world's most advanced open-source relational databases, with an extensive range of data types, object types, SQL models, and other features. It holds a significant position in various fields, such as enterprise, education, and research. Depending on the size of your PostgreSQL data, this document recommends utilizing online and offline migration methods.

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#data-type-difference","title":"Data type difference","text":"

    There are several differences in data types between MatrixOne and the ones provided by PostgreSQL. Some differences can be replaced using alternative types, while others might not be supported temporarily. Additionally, PostgreSQL supports a three-tier logical structure: Database - Schema - Table. This means you can create multiple schemas within a single database containing multiple tables. This hierarchical structure allows for better organization and data management. On the other hand, MatrixOne follows a two-tier logical structure: Database - Table. In MatrixOne, tables are directly created within the database, resulting in some differences during the migration process.

    The specific list is as follows:

    PostgreSQL MatrixOne serial replaced by auto-incrementing columns money replace with decimal bytea replace with binary or varbinary geometric Not supported yet network adress replace with char or varchar bit string Not supported yet text search Not supported yet xml Not supported yet array Not supported yet composite Not supported yet range Not supported yet domain Not supported yet object identifier Not supported yet pg_lsn Not supported yet pseudo Not supported yet"},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#online-migration","title":"Online Migration","text":"

    This chapter will guide you to use third-party tools - DBeaver to migrate data from PostgreSQL to MatrixOne.

    Through DBeaver, the source data is obtained in batches, and then the data is inserted into the target database as INSERT. If an error is reported during the migration process that the heap space is insufficient, please try to adjust the size of each batch of fetched and inserted data.

    • Applicable scenarios: scenarios where the amount of data is small (recommended less than 1GB), and the migration speed is not sensitive.

    • The recommended configuration of the springboard machine where DBeaver is installed: RAM 16GB or more.

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#preparation","title":"Preparation","text":"
    • Springboard machine with a graphical interface: it can connect to the source of Oracle and the target of MatrixOne.
    • Data Migration Tool: Download DBeaver on the springboard machine.
    • DDL translation tool: download pg2mysql on the springboard machine, and note that the springboard machine needs to have a Python environment.
    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-1-migrate-table-structure","title":"Step 1: Migrate table structure","text":"

    Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from PostgreSQL to MatrixOne.

    1. Open DBeaver, select the table to be migrated from Oracle, right-click and select Generate SQL > DDL Click Copy, first copy this SQL to a text editor for text editing Name the filer as pg_ddl.sql and save it locally on the springboard machine.

    2. Use pg2mysql translation tool to convert pg_ddl.sql file to MySQL format DDL:**

      a. First, run the following command to replace bpchar in the pg_ddl.sql file with char:

      ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/bpchar/char/g' pg_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/bpchar/char/g' pg_ddl.sql\n```\n

      b. Next, use the pg2mysql translation tool to convert the pg_ddl.sql file to MySQL format and save the output to the mysql_ddl.sql file:

      ```\n# The commands executed by both Linux and MacOS systems are as follows:\n./pg2mysql.pl < pg_ddl.sql > mysql_ddl.sql\n```\n

      c. The converted DDL retains the original Postgresql schema name. If necessary, you can execute the following command, replacing the schema name with the database name in MySQL:

      ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n```\n

      d. Finally, you may need to uniformly replace numeric in the mysql_ddl.sql file with decimal, which can be achieved by the following command:

      ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/numeric/decimal/g' mysql_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/numeric/decimal/g' mysql_ddl.sql\n```\n
    3. Connect to MatrixOne and create a new database and table in MatrixOne:

      create database tpch;\nuse tpch;\nsource '/YOUR_PATH/mysql_ddl.sql'\n
    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-2-migrate-data","title":"Step 2: Migrate data","text":"
    1. Open DBeaver, select the table to be migrated from PostgreSQL, right-click and select Export Data:

    2. In the Conversion Target > Export Target window, select Database, click Next; in the Table Mapping window, select Target Container, and select the MatrixOne database for the target container tpch:

    3. In the Extraction Settings and Data Loading Settings windows, set the number of selected extractions and inserts. To trigger MatrixOne's direct write S3 strategy, it is recommended to fill in 5000:

    4. After completing the settings, DBeaver starts to migrate the data, and after completion, DBeaver will prompt that the migration is successful.

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-3-check-the-data","title":"Step 3: Check the data","text":"

    After the migration is complete, the data can be inspected as follows:

    • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

    • Compare the results through related queries; you can also refer to the Complete TPCH testing query example to compare the results.

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#offline-migration","title":"Offline Migration","text":"

    This chapter will guide you through importing to MatrixOne through offline files.

    • Applicable scenarios: scenarios with a large amount of data (more significant than 1GB) and sensitive to migration speed.
    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#preparation_1","title":"Preparation","text":"
    • Springboard machine with a graphical interface: it can be connected to the source end of PostgreSQL and the target end of MatrixOne.
    • Data Migration Tool: Download DBeaver to the springboard machine.

    • Install pgdump in PostgreSQL server. If you are not familiar with how to use pgdump, see pgdump tutorial

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-1-migrate-table-structure_1","title":"Step 1: Migrate table structure","text":"

    Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from MySQL to MatrixOne.

    1. Open DBeaver, select the table to be migrated from PostgreSQL, right-click and select Generate SQL > DDL > Copy, first copy this SQL to a text editor, and name the text editor pg_ddl.sql, saved locally on the springboard machine.

    2. Use pg2mysql translation tool to convert pg_ddl.sql file to MySQL format DDL:**

      a. First, run the following command to replace bpchar in the pg_ddl.sql file with char:

      ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/bpchar/char/g' pg_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/bpchar/char/g' pg_ddl.sql\n```\n

      b. Next, use the pg2mysql translation tool to convert the pg_ddl.sql file to MySQL format and save the output to the mysql_ddl.sql file:

      ```\n# The commands executed by both Linux and MacOS systems are as follows:\n./pg2mysql.pl < pg_ddl.sql > mysql_ddl.sql\n```\n

      c. The converted DDL retains the original Postgresql schema name. If necessary, you can execute the following command, replacing the schema name with the database name in MySQL:

      ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n```\n

      d. Finally, you may need to uniformly replace numeric in the mysql_ddl.sql file with decimal, which can be achieved by the following command:

      ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/numeric/decimal/g' mysql_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/numeric/decimal/g' mysql_ddl.sql\n```\n
    3. Connect to MatrixOne and create a new database and table in MatrixOne:

      create database tpch;\nuse tpch;\nsource '/YOUR_PATH/mysql_ddl.sql'\n
    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-2-migrate-data_1","title":"Step 2: Migrate data","text":"

    MatrixOne has two data migration methods to choose from: INSERT and LOAD DATA. When the amount of data is greater than 1GB, it is recommended to use LOAD DATA first, followed by INSERT.

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#load-data","title":"LOAD DATA","text":"
    1. Export the PostgreSQL data table to CSV format in the PostgreSQL database command line environment:

      postgres=# \\c tpch;\npostgres=# COPY tpch.nation TO '/{filepath}/nation.tbl' DELIMITER '|';\npostgres=# COPY tpch.region TO '/{filepath}/region.tbl' DELIMITER '|';\npostgres=# COPY tpch.customer TO '/{filepath}/customer.tbl' DELIMITER '|';\npostgres=# COPY tpch.part TO '/{filepath}/part.tbl' DELIMITER '|';\npostgres=# COPY tpch.supplier TO '/{filepath}/supplier.tbl' DELIMITER '|';\npostgres=# COPY tpch.partsupp TO '/{filepath}/partsupp.tbl' DELIMITER '|';\npostgres=# COPY tpch.lineitem TO '/{filepath}/lineitem.tbl' DELIMITER '|';\npostgres=# COPY tpch.orders TO '/{filepath}/orders.tbl' DELIMITER '|';\n
    2. Connect to MatrixOne and import the exported CSV data into MatrixOne:

      mysql> load data infile '/{filepath}/lineitem.tbl' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.tbl' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.tbl' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.tbl' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.tbl' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.tbl' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.tbl' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.tbl' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n

    For more operation examples of LOAD DATA, see Bulk Load Overview.

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#insert","title":"INSERT","text":"

    The INSERT statement needs to use pgdump to export the logical statement first and then import it into MatrixOne:

    1. Use pgdump to export data. To ensure that MatrixOne directly writes to S3 when inserting, inserting as large a batch as possible is recommended. The net_buffer_length parameter should start at 10MB:

      $ pg_dump -U postgres --no-acl --no-owner --inserts --rows-per-insert 5000  --format p --data-only --schema=tpch tpch -f pg_data.sql\n
    2. On the MatrixOne side, execute the SQL file, there will be an error message during the process, but it will not affect the data insertion:

      source '/YOUR_PATH/pg_data.sql'\n

    For more examples of INSERT operations, see Insert Data.

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-3-check-the-data_1","title":"Step 3: Check the data","text":"

    After the migration is complete, the data can be inspected as follows:

    • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

    • Compare the results through related queries; you can also refer to the Complete a TPCH Test with MatrixOne query example to compare the results.

    "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#reference-example","title":"Reference example","text":"

    If you are a novice and want to migrate a small amount of data, see Import data by using the source command.

    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/","title":"Migrate data from SQL Server to MatrixOne","text":"

    This document will guide you on how to migrate data from SQL Server to MatrixOne.

    SQLServer is widely used in various industries as a mature commercial database, and its functions and performance are outstanding. As a relational database, MatrixOne also supports multiple database migration modes from SQLServer.

    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#data-type-difference","title":"Data type difference","text":"

    There are many differences between MatrixOne and SQL Server's built-in data types. Other types can replace some differences, and some cannot be supported temporarily. The specific list is as follows:

    SQLServer MatrixOne real replace with double money, smallmoney replace with decimal datetimeoffset use timestampmap with timezone substitution nchar/nvarchar/ntext replace with char/varchar/text image replace with blob uniqueidentifier replace with uuid bit Not supported yet rowversion Not supported yet hierarchyid Not supported yet sql_variant Not supported yet xml Not supported yet geometry Not supported yet geography Not supported yet"},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#online-migration","title":"Online Migration","text":"

    This chapter will guide you to use third-party tools - DBeaver to migrate data from SQL Server to MatrixOne.

    Through DBeaver, the source data is obtained in batches, and then the data is inserted into the target database as INSERT. If an error is reported during the migration process that the heap space is insufficient, please try to adjust the size of each batch of fetched and inserted data.

    • Applicable scenarios: scenarios where the amount of data is small (recommended less than 1GB), and the migration speed is not sensitive.

    • The recommended configuration of the springboard machine where DBeaver is installed: RAM 16GB or more.

    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#preparation","title":"Preparation","text":"
    • Springboard machine with a graphical interface: it can connect to the source of SQL Server and the target of MatrixOne.
    • Data Migration Tool: Download DBeaver on the springboard machine.
    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-1-migrate-table-structure-and-data","title":"Step 1: Migrate table structure and data","text":"

    Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from SQL Server to MatrixOne.

    1. Open DBeaver, select the table to be migrated from SQL Server, right-click and select Export Data:

    2. In the Conversion Target > Export Target window, select Database, click Next; in the Table Mapping window, select Target Container, and select the MatrixOne database for the target container tpch:

    3. In the Extraction Settings and Data Loading Settings windows, set the number of selected extractions and inserts. To trigger MatrixOne's direct write S3 strategy, it is recommended to fill in 5000:

    4. After completing the settings, DBeaver starts to migrate the data, and after completion, DBeaver will prompt that the migration is successful.

    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-3-check-the-data","title":"Step 3: Check the data","text":"

    After the migration is complete, the data can be inspected as follows:

    • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

    • Compare the results through related queries; you can also refer to the Complete TPCH testing query example to compare the results.

    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#offline-migration","title":"Offline Migration","text":"

    This chapter will guide you through importing to MatrixOne through offline files.

    • Applicable scenarios: scenarios with a large amount of data (more significant than 1GB) and sensitive to migration speed.
    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#preparation_1","title":"Preparation","text":"
    • Springboard machine with a graphical interface: it can be connected to the source end of SQL Server and the target end of MatrixOne.
    • Data Migration Tool: Download DBeaver to the springboard machine.
    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-1-migrate-table-structure","title":"Step 1: Migrate table structure","text":"

    Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from SQL Server to MatrixOne.

    1. Open DBeaver, select the table to be migrated from SQL Server, right-click and select Generate SQL > DDL > Copy, first copy this SQL to a text editor, and name the text editor sqlserver_ddl.sql, saved locally on the springboard machine.

    2. Connect to MatrixOne and create a new database and table in MatrixOne:

      create database tpch;\nuse tpch;\nsource '/YOUR_PATH/sqlserver_ddl.sql'\n
    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-2-migrate-data","title":"Step 2: Migrate data","text":"

    MatrixOne has two data migration methods to choose from: INSERT and LOAD DATA. When the amount of data is greater than 1GB, it is recommended to use LOAD DATA first, followed by INSERT.

    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#load-data","title":"LOAD DATA","text":"

    Use DBeaver to export the SQL Server data table to CSV format first, and use MatrixOne's parallel loading function to migrate the data to MatrixOne:

    1. Open DBeaver, select the table to be migrated, right-click and select Export Data to export the SQL Server data table as a CSV format file:

    2. In the Conversion Goals > Export Goals window, select CSV and click Next:

    3. Connect to MatrixOne and import the exported CSV data into MatrixOne:

      mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n

    For more operation examples of LOAD DATA, see Bulk Load Overview.

    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#insert","title":"INSERT","text":"

    The INSERT statement needs to use DBeaver to export the logical statement first and then import it into MatrixOne:

    1. Use DBeaver to export data: Open DBeaver, select the table to be migrated from SQL Server, right-click, and select Export Data > SQL. To ensure that MatrixOne directly writes to S3 when inserting, it is recommended to insert parameters in batches The number of data rows per statement is set to 5000:

    2. Use the following command to replace keywords that MatrixOne does not support in the sqlserver_ddl.sql file:

      # The commands executed by the Linux system are as follows:\nsed -i 's/,N/,/g' mssql_data.sql\n\n# The commands executed by the MacOS system are as follows:\nsed -i '' 's/,N/,/g' mssql_data.sql\n
    3. On the MatrixOne side, execute the SQL file:

      ues tpch;\nsource '/YOUR_PATH/sqlserver_ddl.sql'\n

    For more examples of INSERT operations, see Insert Data.

    "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-3-check-the-data_1","title":"Step 3: Check the data","text":"

    After the migration is complete, the data can be inspected as follows:

    • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

    • Compare the results through related queries; you can also refer to the Complete a TPCH Test with MatrixOne query example to compare the results.

    "},{"location":"MatrixOne/Migrate/migrate-overview/","title":"migrating data to MatrixOne Overview","text":""},{"location":"MatrixOne/Migrate/migrate-overview/#matrixone-tools-and-functions-for-migrating-data","title":"MatrixOne tools and functions for migrating data","text":"

    When using MatrixOne, it is sometimes necessary to migrate data from other databases to MatrixOne. Due to differences between different databases, data migration requires some extra work. To facilitate users to import external data quickly, MatrixOne provides a variety of tools and functions.

    Here are some of the standard tools and functions:

    "},{"location":"MatrixOne/Migrate/migrate-overview/#load-data","title":"LOAD DATA","text":"

    Like MySQL, MatrixOne provides the LOAD DATA function, allowing users to quickly and parallelly import external CSV files or JSON files into tables that match the table structure.

    "},{"location":"MatrixOne/Migrate/migrate-overview/#source","title":"SOURCE","text":"

    In MatrixOne, you can also use the SOURCE command to migrate data and table structures to the target database.

    For more information on bulk import using LOAD DATA or SOURCE, see Bulk Load Overview.

    "},{"location":"MatrixOne/Migrate/migrate-overview/#reference","title":"Reference","text":"

    MatrixOne provides the following documents to help you quickly understand how to migrate data from other databases to MatrixOne:

    • Migrate data from MySQL to MatrixOne
    • Migrate data from Oracle to MatrixOne
    • Migrate data from SQL Server to MatrixOne
    • Migrate data from PostgreSQL to MatrixOne
    "},{"location":"MatrixOne/Overview/matrixone-feature-list/","title":"MatrixOne Features","text":"

    This document lists the features supported by the latest version of MatrixOne and features that are common and in MatrixOne's roadmap but not currently supported.

    "},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-definition-language-ddl","title":"Data definition language (DDL)","text":"Data definition Language(DDL) Supported(Y)/Not supported (N) /Experimental (E) CREATE DATABASE Y DROP DATABASE Y ALTER DATABASE N CREATE TABLE Y ALTER TABLE E, The clauses: CHANGE [COLUMN], MODIFY [COLUMN], RENAME COLUMN, ADD [CONSTRAINT [symbol]] PRIMARY KEY, DROP PRIMARY KEY, and ALTER COLUMN ORDER BY can be used in ALTER It can be freely combined in the TABLE statement. Still, it is not supported to be used with other clauses for the time being. RENAME TABLE N, Can be replaced by ALTER TABLE tbl RENAME TO new_tbl DROP TABLE Y CREATE INDEX Y, Secondary indexes have no speedup DROP INDEX Y MODIFY COLUMN N PRIMARY KEY Y CREATE VIEW Y ALTER VIEW Y DROP VIEW Y TRUNCATE TABLE Y AUTO_INCREMENT Y SEQUENCE Y TEMPORARY TABLE Y CREATE STREAM E, Only some types are supported PARTITION BY E, Only some types are supported CHARSET, COLLATION N, Only UTF8 is supported by default"},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-manipulationquery-language-dmldql","title":"Data manipulation/query language (DML/DQL)","text":"SQL Statement Supported(Y)/Not supported (N) /Experimental (E) SELECT Y INSERT Y UPDATE Y DELETE Y REPLACE Y INSERT ON DUPLICATE KEY UPDATE Y LOAD DATA Y SELECT INTO Y INNER/LEFT/RIGHT/OUTER JOIN Y UNION, UNION ALL Y EXCEPT, INTERSECT Y GROUP BY, ORDER BY Y CLUSTER BY Y SUBQUERY Y (Common Table Expressions, CTE) Y BEGIN/START TRANSACTION, COMMIT, ROLLBACK Y EXPLAIN Y EXPLAIN ANALYZE Y LOCK/UNLOCK TABLE N User-defined Variables Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#advanced-sql-features","title":"Advanced SQL Features","text":"Advanced SQL Features Supported(Y)/Not supported (N) /Experimental (E) PREPARE Y STORED PROCEDURE N TRIGGER N EVENT SCHEDULER N UDF N Materialized VIEW N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-types","title":"Data types","text":"Data type categories Data types Supported(Y)/Not supported (N) /Experimental (E) Integer Numbers TINYINT/SMALLINT/INT/BIGINT (UNSIGNED) Y BIT N Real Numbers FLOAT Y DOUBLE Y String Types CHAR Y VARCHAR Y BINARY Y VARBINARY Y TINYTEXT/TEXT/MEDIUMTEXT/LONGTEXT Y ENUM Y, Not support Filtering ENUM values and Sorting ENUM values SET N Binary Types TINYBLOB/BLOB/MEDIUMBLOB/LONGBLOB Y Time and Date Types DATE Y TIME Y DATETIME Y TIMESTAMP Y YEAR Y Boolean BOOL Y Decimal Types DECIMAL Y, up to 38 digits JSON Types JSON Y vector type VECTOR N Spatial Type SPATIAL N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#indexing-and-constraints","title":"Indexing and constraints","text":"Indexing and constraints Supported(Y)/Not supported (N) /Experimental (E) PRIMARY KEY Y Composite PRIMARY KEY Y UNIQUE KEY Y Secondary KEY Y, Syntax only implementation FOREIGN KEY Y Enforced Constraints on Invalid Data Y ENUM and SET Constraints N NOT NULL Constraint Y AUTO INCREMENT Constraint Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#transactions","title":"Transactions","text":"Transactions Supported(Y)/Not supported (N) /Experimental (E) Pessimistic transactions Y Optimistic transactions Y Distributed Transaction Y Snapshot Isolation Y READ COMMITTED Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#functions-and-operators","title":"Functions and Operators","text":"Functions and Operators Categories Supported(Y)/Not supported (N) /Experimental (E) Aggregate Functions Y Mathematical Y Datetime Y String Y CAST Y Flow Control Functions E Window Functions Y JSON Functions Y System Functions Y Other Functions Y Operators Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#partition","title":"PARTITION","text":"PARTITION Supported(Y)/Not supported (N) /Experimental (E) KEY(column_list) E HASH(expr) E RANGE(expr) N RANGE COLUMNS N LIST N LIST COLUMNS N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#import-and-export","title":"Import and Export","text":"Import and Export Supported(Y)/Not supported (N) /Experimental (E) LOAD DATA Y SOURCE Y Load data from S3 Y modump Y mysqldump N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#security-and-access-control","title":"Security and Access Control","text":"Security Supported(Y)/Not supported (N) /Experimental (E) Transport Layer Encryption TLS Y Encryption at rest Y Import from Object Storage Y Role-Based Access Control (RBAC) Y Multi-Account Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#backup-and-restore","title":"Backup and Restore","text":"Backup and Restore Supported(Y)/Not supported (N) /Experimental (E) Logical Backup and Restore Y, Only the modump tool is supported Physical Backup and Restore Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#management-tool","title":"Management Tool","text":"Management Tool Supported(Y)/Not supported (N) /Experimental (E) Stand-alone mo_ctl deployment management Y Distributed mo_ctl deployment management E, Enterprise Edition only Visual management platform E, Public cloud version only System Logging Y System indicator monitoring Y Slow query log Y SQL record Y Kubernetes operator Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#deployment-method","title":"Deployment Method","text":"Deployment Method Supported(Y)/Not supported (N) /Experimental (E) Stand-alone environment privatization deployment Y Distributed environment privatization deployment Y, self-built Kubernetes and minIO object storage Alibaba Cloud distributed self-built deployment Y, ACK+OSS Tencent Cloud Distributed Self-built Deployment Y, TKE+COS AWS distributed self-built deployment Y, EKS+S3 Public Cloud Serverless Y, MatrixOne Cloud, Support AWS, Alibaba Cloud"},{"location":"MatrixOne/Overview/matrixone-introduction/","title":"MatrixOne Introduction","text":"

    MatrixOne is a hyper-converged cloud & edge native distributed database with a structure that separates storage, computation, and transactions to form a consolidated HSTAP data engine. This engine enables a single database system to accommodate diverse business loads such as OLTP, OLAP, and stream computing. It also supports deployment and utilization across public, private, and edge clouds, ensuring compatibility with diverse infrastructures.

    MatrixOne touts significant features, including real-time HTAP, multi-tenancy, stream computation, extreme scalability, cost-effectiveness, enterprise-grade availability, and extensive MySQL compatibility. MatrixOne unifies tasks traditionally performed by multiple databases into one system by offering a comprehensive ultra-hybrid data solution. This consolidation simplifies development and operations, minimizes data fragmentation, and boosts development agility.

    MatrixOne is optimally suited for scenarios requiring real-time data input, large data scales, frequent load fluctuations, and a mix of procedural and analytical business operations. It caters to use cases such as mobile internet apps, IoT data applications, real-time data warehouses, SaaS platforms, and more.

    "},{"location":"MatrixOne/Overview/matrixone-introduction/#key-features","title":"Key Features","text":""},{"location":"MatrixOne/Overview/matrixone-introduction/#hyper-converged-engine","title":"Hyper-converged Engine","text":"
    • Monolithic Engine

      HTAP data engine that supports a mix of workloads such as TP, AP, time series, and machine learning within a single database.

    • Built-in Streaming Engine

      Built-in stream computing engine that enables real-time data inflow, transformation, and querying.

    "},{"location":"MatrixOne/Overview/matrixone-introduction/#cloud-edge-native","title":"Cloud & Edge Native","text":"
    • Storage-Computation Separation Structure

      Separates the storage, computation, and transaction layers, leveraging a containerized design for ultimate scalability.

    • Multi-Infrastructure Compatibility

      MatrixOne provides industry-leading latency control with optimized consistency protocol.

    "},{"location":"MatrixOne/Overview/matrixone-introduction/#extreme-performance","title":"Extreme Performance","text":"
    • High-Performance Execution Engine

      The flexible combination of Compute Node and Transaction node accommodates point queries and batch processing, delivering peak performance for OLTP and OLAP.

    • Enterprise-Grade High Availability

      Establishes a consistently shared log under a leading Multi-Raft replication state machine model. It ensures high cluster availability while preventing data duplication, thus achieving RTO=0.

    "},{"location":"MatrixOne/Overview/matrixone-introduction/#ease-of-use","title":"Ease of Use","text":"
    • Built-in Multi-Tenancy Capability

      Offers inherent multi-tenancy, where tenants are isolated from each other, independently scalable yet uniformly manageable. This feature simplifies the complexity of multi-tenancy design in upper-level applications.

    • High Compatibility with MySQL

      MatrixOne exhibits high compatibility with MySQL 8.0, including transmission protocol, SQL syntax, and ecosystem tools, lowering usage and migration barriers.

    "},{"location":"MatrixOne/Overview/matrixone-introduction/#cost-effective","title":"Cost-Effective","text":"
    • Efficient Storage Design

      Employs cost-effective object storage as primary storage. High availability can be achieved through erasure coding technology with only about 150% data redundancy. It also provides high-speed caching capabilities, balancing cost and performance via a multi-tiered storage strategy that separates hot and cold data.

    • Flexible Resource Allocation

      Users can adjust the resource allocation ratio for OLTP and OLAP according to business conditions, maximizing resource utilization.

    "},{"location":"MatrixOne/Overview/matrixone-introduction/#enterprise-level-security-and-compliance","title":"Enterprise-Level Security and Compliance","text":"
      MatrixOne employs Role-Based Access Control (RBAC), TLS connections, and data encryption to establish a multi-tiered security defense system, safeguarding enterprise-level data security and compliance.\n
    "},{"location":"MatrixOne/Overview/matrixone-introduction/#user-values","title":"User Values","text":"
    • Simplify Database Management and Maintenance

      With business evolution, the number of data engines and middleware enterprises employ increases. Each data engine relies on 5+ essential components and stores 3+ data replicas. Each engine must be independently installed, monitored, patched, and upgraded. This results in high and uncontrollable data engine selection, development, and operations costs. Under MatrixOne's unified architecture, users can employ a single database to serve multiple data applications, reducing the number of introduced data components and technology stacks by 80% and significantly simplifying database management and maintenance costs.

    • Reduce Data Fragmentation and Inconsistency

      Data flow and copy between databases make data sync and consistency increasingly tricky. The unified and incrementally materialized view of MatrixOne allows the downstream to support real-time upstream updates and achieve end-to-end data processing without redundant ETL processes.

    • Decoupling Data Architecture From Infrastructure

      Currently, the architecture design across different infrastructures is complicated, causing new data silos between cloud and edge, cloud and on-premise. MatrixOne is designed with a unified architecture to support simplified data management and operations across different infrastructures.

    • Extremely Fast Complex Query Performance

      Poor business agility results from slow, complex queries and redundant intermediate tables in current data warehousing solutions. MatrixOne supports blazing-fast experience even for star and snowflake schema queries, improving business agility with real-time analytics.

    • An Solid OLTP-like OLAP Experience

      Current data warehousing solutions have the following problems: high latency and absence of immediate visibility for data updates. MatrixOne brings OLTP (Online Transactional Processing) level consistency and high availability to CRUD operations in OLAP (Online Analytical Processing).

    • Seamless and Non-disruptive Scaling

      It is challenging to balance performance and scalability to achieve an optimum price-performance ratio in current data warehousing solutions. MatrixOne's disaggregated storage and compute architecture makes it fully automated and efficient to scale in/out and up/down without disrupting applications.

    "},{"location":"MatrixOne/Overview/matrixone-introduction/#scenarios","title":"Scenarios","text":"
    • Traditional Application System Scenarios Requiring Scalability and Analytical Reporting Capabilities

      With the expansion of businesses, the performance needs of traditional single-machine databases cannot meet enterprises' usual systems such as OA, ERP, CRM, etc., especially during special periods requiring business analysis. Many enterprises equip a separate analytical database system to meet statistical report needs at essential points like month-end, quarter-end, etc. Using MatrixOne; these needs can be met with a single database system, providing strong scalability that seamlessly scales with business growth.

    • Dashboard/BI Report Scenarios Requiring Real-Time Analytical Capabilities

      For typical OLAP-type applications in enterprises, such as dashboards, BI reports, etc., analyzing massive amounts of data often leads to a performance bottleneck when the data volume is significantly large, resulting in poor timeliness. MatrixOne's robust analysis performance and scalability enable the acceleration of various complex and large-scale SQL queries, providing a near-instant experience and enhancing enterprise decision-making analysis's agility.

    • Data Platform Scenarios for Real-Time Influx and Processing of Massive Heterogeneous Data Applications

      With the extensive use of sensor and network technology, numerous IoT devices generate substantial data, such as manufacturing factory production lines, new energy vehicles, city security surveillance cameras, etc. Their scale can easily reach hundreds of TB or even PB levels. The demand for digitization also requires enterprises to store and use these data increasingly. Traditional database solutions cannot meet the requirements of such massive and large-scale real-time data writing and processing applications. MatrixOne's powerful streaming data writing and processing capabilities and robust scalability can adapt to any load and data volume scale, fully meeting these requirements.

    • Data Middle-End Scenarios Where Various Internal Enterprise Data Converges

      Medium and large enterprises often have multiple business systems. To fully understand the enterprise's overall status, many enterprises build a data middle-end that connects data sources from various systems. Traditional solutions to carry the data middle-end are based on the Hadoop system, which is complex, posing high development and operation thresholds for many enterprises. MatrixOne's one-stop HTAP architecture makes using a data middle-end as convenient as using MySQL, significantly reducing costs.

    • Business Scenarios with Dramatic and Frequent Internet Business Fluctuations

      Internet applications such as games, e-commerce, entertainment, social networking, news, etc., have a massive user base, and the business fluctuates dramatically and frequently. During hot events, these applications often need many computing resources to support business needs. MatrixOne's fully cloud-native architecture has superior scalability, enabling automatic and rapid scaling with business changes, significantly reducing user operation and maintenance difficulties.

    • Enterprise SaaS Service Business Scenarios

      Enterprise SaaS applications have seen explosive growth in recent years. In developing SaaS applications, they all need to consider their multi-tenant model. Traditional schemes offer two modes of multi-tenant shared database instances and single-tenant exclusive database instances, but they face the dilemma of management cost and isolation. MatrixOne comes with multi-tenant capabilities; tenants are naturally load-isolated and can be independently scaled. At the same time, it provides unified management capabilities, balancing the enterprise's needs for cost, management simplicity, and isolation, making it an optimal choice for SaaS applications.

    "},{"location":"MatrixOne/Overview/matrixone-introduction/#learn-more","title":"Learn More","text":"

    This section describes the basic introduction of MatrixOne. If you want to learn more detailed information about MatrixOne, see the following content:

    • MatrixOne Architecture
    • Deploy standalone MatrixOne
    "},{"location":"MatrixOne/Overview/whats-new/","title":"What's New","text":"

    The lastest version of MatrixOne is 1.0.0-rc1, releases on 24th Aug, 2023. See the following:

    • v1.0.0-rc1 Release Notes
    "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/","title":"Detailed Caching and Hot-Cold Data Separation Architecture","text":"

    Data caching and hot-cold data separation are key features of MatrixOne, where data is classified into hot and cold based on the frequency of use and managed differently. This design allows MatrixOne to maintain excellent performance while keeping operating costs low.

    "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#technical-architecture","title":"Technical Architecture","text":"

    In the overall architecture of MatrixOne, two parts are responsible for persistent data storage. One is the object storage shared by the entire MatrixOne distributed cluster, which is the primary storage device of the cluster. The other is the local storage on each compute node (CN), mainly used for data caching. The primary storage contains all data of the entire cluster, while the cache only saves data extracted from the primary storage during recent queries. In addition, the memory of CN nodes is also used as part of the data cache.

    When a user initiates a query, the system first checks whether the cache of the CN to which the user is connected already contains the required data. If it exists, the system directly returns the result to the user, prioritizing memory over disk. Suppose the required data is not found in the cache of the currently connected CN. In that case, the system queries the global metadata information to see if the required data exists in the cache of other available CNs for this user, checking memory first and then disk. If it exists, the system redirects the request to the CN containing this data, processes it, and returns the result to the user. If the data searched for is not in the cache of any available CN, the system initiates a read request to the object storage and returns the result to the user.

    When a user queries data from object storage, the queried data block will be filled into the corresponding position according to the cache query order. For example, if a user queries 100M of data from object storage, this 100M of data will first be written into the memory of the CN node to which the user is connected and then written into the disk cache of this CN node. Each time a new query is generated, the data in the cache will be updated according to this rule. Whether in memory or disk, data replacement in the CN cache follows the LRU (Least Recently Used) principle. With this mechanism, the most recent data is always in the easiest-to-get position, while relatively unpopular data will gradually be removed from the cache.

    "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#product-features","title":"Product Features","text":"

    The features of data caching and hot-cold data separation bring unique advantages to the product. To show more specifically, we will show a simple example.

    "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#environment-configuration","title":"Environment Configuration","text":"

    The environment introduced in this chapter will be based on the environment of MatrixOne Distributed Cluster Deployment. Please ensure that the entire MatrixOne is installed.

    1. Prepare a table named pe and the corresponding CSV data. This CSV data table is 35.8MB, with 1,048,575 rows of data. We will use the following SQL statement to create two databases and load the same data table into the pe table in both databases.

      create database stock;\ndrop table if exists stock.pe;\ncreate table stock.pe (\nts_code VARCHAR(255) DEFAULT null,\ntrade_date VARCHAR(255) DEFAULT null,\npe FLOAT DEFAULT null,\npb FLOAT DEFAULT null\n);\nload data local infile '/XXX/pe.csv' into table stock.pe fields TERMINATED BY '\\t';\n\ncreate database stock2;\ndrop table if exists stock2.pe;\ncreate table stock2.pe (\nts_code VARCHAR(255) DEFAULT null,\ntrade_date VARCHAR(255) DEFAULT null,\npe FLOAT DEFAULT null,\npb FLOAT DEFAULT null\n);\nload data local infile '/XXX/pe.csv' into table stock.pe fields TERMINATED BY '\\t';\n
    2. Next, perform the corresponding cache configuration. In the cluster yaml settings of MatrixOne, TN, Log Service, and CN all have cache-related settings. However, you only need to focus on the CN cache directly related to the query, and the primary cache size is managed by memoryCacheSize and diskCacheSize.

      metadata:\nname: mo\nnamespace: mo-hn\nspec:\ncnGroups:\n- name: cn-set1\n# Intermediate configuration omitted\nsharedStorageCache: # Core parameters for configuring CN cache\nmemoryCacheSize: 250Mi # CN's memory cache, Mi stands for MB\ndiskCacheSize: 1Gi # CN's disk cache, Gi stands for GB\n

    When both parameters are set to \"1\", the cache is turned off, and all query requests from MatrixOne will interact directly with the underlying object storage, significantly reducing the efficiency of queries.

    To simplify the display, you can first turn off the memory cache here and only set a specific size of the disk cache. Since the original data will be compressed to a particular ratio according to the data type after being stored, you need to set the disk cache to 20MB first, which is enough to store the compressed 35.8MB data file.

    metadata:\nname: mo\nnamespace: mo-hn\nspec:\ncnGroups:\n- name: cn-set1\n## Omitted intermediate configuration\nsharedStorageCache: # Core parameters for configuring CN cache\nmemoryCacheSize: \"1\" # CN's memory cache, Mi stands for MB\ndiskCacheSize: 20Mi # CN's disk cache, Gi stands for GB\n
    "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#query-acceleration","title":"Query Acceleration","text":"

    After completing the above settings and starting the MatrixOne cluster, you can experience the effect of cache acceleration through the results of multiple queries. Here, you can run a full table scan of stock.pe multiple times in a row.

    mysql> select * from stock.pe into outfile \"test01.txt\";\nEmpty set (6.53 sec)\n\nmysql> select * from stock.pe into outfile \"test02.txt\";\nEmpty set (4.01 sec)\n\nmysql> select * from stock.pe into outfile \"test03.txt\";\nEmpty set (3.84 sec)\n\nmysql> select * from stock.pe into outfile \"test04.txt\";\nEmpty set (3.96 sec)\n

    The above results show that the first query is noticeably slower because it needs to fetch data from object storage. However, since the data has been cached to the disk in the subsequent three queries, the query speed has significantly improved.

    "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#cache-replacement","title":"Cache Replacement","text":"

    Next, you can alternate and run a full table scan of stock.pe and stock2.pe multiple times.

    mysql> select * from stock2.pe into outfile \"test05.txt\";\nEmpty set (5.84 sec)\n\nmysql> select * from stock2.pe into outfile \"test06.txt\";\nEmpty set (4.27 sec)\n\nmysql> select * from stock2.pe into outfile \"test07.txt\";\nEmpty set (4.15 sec)\n\nmysql> select * from stock.pe into outfile \"test08.txt\";\nEmpty set (6.37 sec)\n\nmysql> select * from stock.pe into outfile \"test09.txt\";\nEmpty set (4.14 sec)\n\nmysql> select * from stock.pe into outfile \"test10.txt\";\nEmpty set (3.81 sec)\n

    You might notice that each time the data table for the query is switched, the query efficiency significantly decreases. This is due to the cache replacement mechanism. You only set a small cache, which is just enough to store the complete data of a table. Therefore, when you alternate queries, the old cache data is replaced. The new query needs to fetch data from the object storage, and when queried again, since the data has been cached, the query speed is improved.

    "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#query-preheating","title":"Query Preheating","text":"

    In many business scenarios, we often need to accelerate the queries due to a large amount of data or complex queries. The cache mechanism of MatrixOne can accelerate queries by preheating the data.

    For example, the following SQL query:

    SELECT pe1.ts_code, pe1.pe, pe1.pb\nFROM stock2.pe as pe1\nWHERE pe1.pe = (SELECT min(pe2.pe)\nFROM stock2.pe as pe2\nWHERE pe1.ts_code = pe2.ts_code)\nORDER BY trade_date\nDESC LIMIT 1;\n

    If not optimized, the execution speed is as follows:

    SELECT pe1.ts_code, pe1.pe, pe1.pb\nFROM stock2.pe as pe1\nWHERE pe1.pe = (SELECT min(pe2.pe)\nFROM stock2.pe as pe2\nWHERE pe1.ts_code = pe2.ts_code)\nORDER BY trade_date\nDESC LIMIT\n\n1;\n+-----------+------+--------+\n| ts_code   | pe   | pb     |\n+-----------+------+--------+\n| 000038.SZ |    0 | 1.2322 |\n+-----------+------+--------+\n1 row in set (5.21 sec)\n

    This SQL query only involves the query of the stock2.pe table. We can preheat the table data to the cache by pre-scanning the complete table data, so the query can significantly improve the speed of this SQL query.

    mysql> select * from stock2.pe into outfile \"test11.txt\";\nEmpty set (6.48 sec)\n\nmysql> SELECT pe1.ts_code, pe1.pe, pe1.pb FROM stock2.pe as pe1 WHERE pe1.pe = (SELECT min(pe2.pe) FROM stock2.pe as pe2 WHERE pe1.ts_code = pe2.ts_code) ORDER BY trade_date DESC LIMIT 1;\n+-----------+------+---------+\n| ts_code   | pe   | pb      |\n+-----------+------+---------+\n| 000068.SZ |    0 | 14.6959 |\n+-----------+------+---------+\n1 row in set (2.21 sec)\n

    This feature is particularly suitable for some fixed report calculation scenarios. Users can preheat the data involved in the query and then perform the query, which can significantly improve the query effect.

    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/","title":"Detailed Logservice Architecture","text":"

    Logservice plays a vital role in MatrixOne. It is an independent service used by external components through RPC for log management.

    Logservice uses the dragonboat library based on the Raft protocol (a multi-raft group's Go language open source implementation) and usually uses local disks to store logs in multiple copies, similar to the management of WAL (Write-Ahead Log). The transaction commits must only be written to the Logservice without writing the data to S3. Additional components write batches of data to S3 asynchronously. Such a design ensures low latency when the transaction commits, and multiple copies provide high data reliability.

    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#logservice-architecture","title":"Logservice Architecture","text":"

    The architecture of Logservice consists of two parts: client and server. The server includes modules such as handler, dragonboat, and RSM (Replicated State Machine), while the client includes several key interfaces. The collaborative relationship between them is shown in the figure below:

    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#client","title":"Client","text":"

    Logservice client is mainly invoked by TN (Transaction node) and provides the following key interfaces:

    • Close(): Close the client connection.
    • Config(): Get client-related configuration.
    • GetLogRecord(): returns a pb.LogRecord variable containing an 8-byte LSN (log sequence number), a 4-byte record type, and a data field of type []byte. The data field consists of 4 bytes for pb.UserEntryUpdate, 8 for the replica TN ID, and payload []byte.
    • Append(): Append pb.LogRecord to Logservice and return LSN. The parameter pb.LogRecord can be reused on the calling side.
    • Read(): Read logs starting from the specified firstLsn from the Logservice until maxSize is reached. The returned LSN is used as the starting point for the next read.
    • Truncate(): Delete the logs before the specified LSN to free up disk space.
    • GetTruncatedLsn(): Returns the LSN of the most recently deleted log.
    • GetTSOTimestamp(): Request the specified timestamps from TSO (Timestamp Oracle). The caller occupies the scope of [returned value, returned value + count]. This method currently needs to be used.

    The Logservice client sends a request to the Logservice server through MO-RPC, and the server interacts with Raft/dragonboat and returns the result.

    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#server","title":"Server","text":""},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#server-handler","title":"Server Handler","text":"

    The server side of Logservice receives requests from clients and handles them. The entry function is (*Service).handle(), and different requests are processed by calling other methods:

    • Append: Appends logs to Logservice, ultimately invoking the (*NodeHost) SyncPropose() method of Dragonboat for synchronous proposal. It waits for the log to be committed and applied before returning, and the return value is the LSN (Log Sequence Number) after a successful log write.
    • Read: Reads log entries from the log database. It first calls the (*NodeHost) SyncRead() method to perform a linear read from the state machine up to the current LSN and then calls the (*NodeHost) QueryRaftLog() method to read log entries from the log database based on the LSN.
    • Truncate: Truncates logs in the log database to free up disk space. It's important to note that here, only the latest truncatable LSN in the state machine is updated, and the actual truncation operation still needs to be performed.
    • Connect: Establishes a connection with the Logservice server and attempts to read and write the state machine for state checking.
    • Heartbeat: Includes heartbeats to Logservice, CN, and TN. This request updates the status information of each entity in the HAKeeper's state machine and synchronizes the tick of HAKeeper. When the HAKeeper performs checks, it compares the offline time based on the tick, and if it's offline, it triggers removal or shutdown operations.
    • Get XXX: Retrieves relevant information from the state machine.
    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#bootstrap","title":"Bootstrap","text":"

    Bootstrap is the process that occurs when the logservice server starts, and it is carried out through HAKeeper's shard ID 0. The entry function is (*Service) BootstrapHAKeeper. Regardless of how many replicas are configured, each logservice process starts a replica of HAKeeper during startup. Each replica sets up members (replicas) upon startup, and the HAKeeper shard starts Raft with these members as the default replica count. After completing the leader election in Raft, it executes setting the initial cluster information (set initial cluster info), sets the shard to count for logs and TNs, and sets the replica count for logs. Once the replica count is set, any excess HAKeeper replicas will be stopped.

    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#heartbeat","title":"Heartbeat","text":"

    This heartbeat is sent from Logservice, CN, and TN to HAKeeper, rather than being a heartbeat between Raft replicas. It serves two primary purposes:

    1. Sending the status information of each replica to HAKeeper through heartbeats, allowing HAKeeper's state machine to update replica information.
    2. Retrieving commands that replicas need to execute from HAKeeper upon heartbeat response.

    The heartbeat process in Logservice is illustrated in the following diagram, and the process is similar for CN and TN.

    By default, the heartbeat is executed once per second, and its mechanism is as follows:

    1. Generate heartbeat information for all shard replicas on the storage level, including shard ID, node information, term, leader, etc.
    2. Send the request to the server side of Logservice.
    3. Upon receiving the request, the server invokes the (*Service) handleLogHeartbeat() method to process it and uses propose to send the heartbeat to Raft.
    4. Upon receiving the heartbeat, the state machine of HAKeeper calls the (*stateMachine) handleLogHeartbeat() method to process it, primarily performing the following tasks:
      • Updating the LogState in the state machine: Invoking the (*LogState) Update() method to update storage and shard information.
      • Retrieving commands from the ScheduleCommands of the state machine and returning them to the initiating end for execution.

    The principles of CN and TN sending heartbeats to HAKeeper are also similar.

    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#replicated-state-machine-rsm","title":"Replicated State Machine (RSM)","text":"

    Logservice and HAKeeper have an in-memory replicated state machine model where all data is stored in memory. They both implement the IStateMachine interface, and the key methods are as follows:

    • Update(): After completing a propose and commit (i.e., when a majority of replicas have finished writing), the Update() method is called to update the data in the state machine. The user implements the Update() method and must be side-effect free, meaning that the same input must yield the same output. Otherwise, it can lead to an unstable state machine. The results of the Update() method are returned through the Result structure, and if an error occurs, the error field is not empty.
    • Lookup(): Used to retrieve data from the state machine. The data type to be retrieved is specified through the interface{} parameter, and the result is also of type interface{}. Therefore, users need to define the data in the state machine, pass the corresponding data type, and then perform type assertion. Lookup() is a read-only method and should not modify the data in the state machine.
    • SaveSnapshot(): Creates a snapshot by writing the data from the state machine to an io.Writer interface, typically a file handle. Thus, the snapshot is ultimately saved to a local disk file. ISnapshotFileCollection represents a list of files outside the state machine's file system (if any), which will also be stored in the snapshot. The third parameter is to notify the snapshot process that the Raft replica has stopped, terminating the snapshot operation.
    • RecoverFromSnapshot(): Recovers the state machine data by reading the latest snapshot data from an io.Reader. []SnapshotFile represents an additional list of files directly copied to the state machine's data directory. The third parameter controls the snapshot operation's recovery, stopping it when Raft replica operations are being performed.
    • Close(): Closes the state machine and performs any necessary cleanup tasks.
    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#read-write-process","title":"Read-Write Process","text":"

    In Logservice, the general process for a read-write request is as follows:

    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#write-process","title":"Write Process","text":"
    1. The request is forwarded to the leader node if the connected node is not the leader. Upon receiving the request, the leader node writes the log entry to its local disk.
    2. Simultaneously, the request is asynchronously sent to follower nodes. Upon receiving the request, each follower node writes the log entry to its local disk.
    3. Once most nodes have completed the write, the commit index is updated, and other follower nodes are notified through heartbeat messages.
    4. The leader node executes the state machine operations (apply) after the write is committed.
    5. The result is returned to the client after the state machine operations are completed.
    6. Each follower node independently executes its state machine operations upon receiving the commit index from the leader.
    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#read-process","title":"Read Process","text":"

    Reading data can be divided into two scenarios:

    • Reading data from the state machine.

      • The client initiates a read request, and when the request reaches the leader node, the current commit index is recorded.
      • The leader node sends heartbeat requests to all nodes to confirm its leader status. Once most nodes respond and confirm it as the leader, it can respond to the read request.
      • Wait for the apply index to be greater than or equal to the commit index.
      • Once the condition is met, the data can be read from the state machine and returned to the client.

    • Reading log entries from the log database (log db).

      • This process typically occurs during cluster restart.
      • During restart, replicas first need to recover the state machine data from the snapshot, then start reading log entries from the log database based on the index position recorded in the snapshot and apply them to the state machine.
      • After this operation is completed, replicas can participate in leader elections.
      • When a leader is elected in the cluster, the Transaction nodes (TN) connect to the Logservice cluster and start reading log entries from the last checkpoint position of a replica's log database. These log entries are replayed into the Transaction node's in-memory data.

    "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#truncation","title":"Truncation","text":"

    As the log entries in Logservice's log database continue to grow, it can lead to insufficient disk space. Therefore, regular disk space release is needed, achieved through truncation.

    Logservice uses an in-memory-based state machine that only stores some metadata and status information, such as tick, state, and LSN (Log Sequence Number), without recording user data. User data is recorded by the Transaction nodes (TN) themselves. You can think of it as a master-slave architecture, where the state machines are separate, and the TN and Logservice maintain their respective state machines.

    In this design with separate state machines, a simple snapshot mechanism can cause issues:

    1. When a TN sends a truncation request and sets the truncation index to 100, the applied index of the Logservice's state machine is 200. This means that logs before index 200 will be deleted, and a snapshot will be generated at that position. Note: The truncation index is not equal to the applied index.
    2. The cluster restarts.
    3. The Logservice's state machine applies the snapshot with index 200, sets the first index to 200 (deleting logs before index 200), and replays logs before providing the service.
    4. When the TN reads log entries from Logservice, starting from index 100, it fails to read because the logs before index 200 have been deleted, resulting in an error.

    To address the above problem, the current truncation workflow is as follows:

    1. The TN sends a truncation request and updates the truncation LSN (truncateLsn) in the Logservice's state machine. Only the value is updated, and no snapshot/truncation operation is executed.
    2. Each Logservice server internally starts a truncation worker that periodically sends truncation requests (Truncate Request). It's important to note that the Exported parameter in this request is true, indicating that the snapshot is not visible to the system and is only exported to a specified directory.
    3. The truncation worker also checks the list of currently exported snapshots to see if there are any snapshots with an index greater than the truncation LSN in the Logservice's state machine. If there are, the snapshot closest to the truncation LSN is imported into the system to make it effective and visible to the system.
    4. All replicas perform the same operations to ensure that the snapshot LSN of both state machines is consistent. This allows reading the corresponding log entries when the cluster restarts.
    "},{"location":"MatrixOne/Overview/architecture/architecture-proxy/","title":"Detailed Proxy Architecture","text":"

    Proxy, the sole component in MatrixOne responsible for load balancing and SQL request distribution, adapts to various scenarios by implementing session-level SQL routing through CN grouping and Proxy's SQL distribution.

    The architecture diagram of its SQL request distribution is as follows:

    • The Kubernetes Library layer utilizes built-in Kubernetes features to ensure high availability and load balancing of the Proxy layer.
    • SQL Proxy implements long connections, allowlists, and SQL request distribution, achieving load balancing and request forwarding for CNs.
    • CN does not have the concept of read-only replicas and is divided only by manual grouping.
    "},{"location":"MatrixOne/Overview/architecture/architecture-proxy/#technical-implementation","title":"Technical Implementation","text":"

    Based on the multi-CN architecture of MatrixOne's storage-compute separation and the responsibilities of Proxy, the concept of CN label groups is introduced in HAKeeper and Proxy, that is, CN collections with fixed names and quantities.

    As shown in the figure above, the technical implementation process is explained as follows:

    1. Create different CN labels through configuration options in the yaml file (including configuration, replica count, and tenant).
    2. When the MatrixOne cluster starts, MatrixOne will launch the same number of Pods according to the replica count of each CN label, and HAKeeper will uniformly apply the corresponding labels.
    3. MatrixOne Operator (i.e., MatrixOne cluster resource manager in Kubernetes) is responsible for dynamically maintaining the CN quantity within the CN label group. After a CN node goes down, it launches the same number of CNs.
    4. The Proxy component determines the connection session parameters and forwards a specific session to the corresponding CN group, implementing SQL routing.

    5. If a session request does not have a matching CN label, it will search for CNs with empty labels. If found, it will connect to the CN group with blank labels; otherwise, the connection will fail.

    6. During expansion, Proxy migrates existing connections based on the session count of existing CN nodes, moving existing sessions to new CN nodes. The session count of the migrated nodes is close to being balanced, achieving load balancing.
    7. During contraction, the Proxy migrates existing sessions of CN nodes that are about to go offline to other nodes. The session count of the migrated nodes is close to being balanced, thus achieving load balancing.

    8. Proxy is responsible for intra-group load balancing within the same CN label group.

    The Proxy analyzes the parameters in the session request to determine whether the request matches the CN label. In implementing SQL routing, session parameters are used to find the CN label group matching the request. Specifically, the Proxy may examine specific fields in the CN label, such as tenant information, replica count, etc., to route the request to the appropriate CN label group. This way, the Proxy can match session requests with CN labels and ensure that requests are routed to the correct CN node.

    "},{"location":"MatrixOne/Overview/architecture/architecture-proxy/#reference","title":"Reference","text":"

    To learn more about implementing load balancing through Proxy, see Using Proxy for Tenant and Load Independent Resource Management.

    "},{"location":"MatrixOne/Overview/architecture/architecture-tae/","title":"Transactional Analytical Engine Architecture","text":"

    MatrixOne's storage engine is called the Transactional Analytical Engine (TAE).

    "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#storage-engine-architecture","title":"Storage Engine Architecture","text":"

    The Transactional Analytical Engine (TAE) organizes data into column blocks, the minor IO units. Currently, these blocks are organized with a fixed number of rows. For columns of the Blob type, special handling is performed.

    TAE organizes data in the form of tables, and the data of each table is structured as a Log-structured Merge-tree (LSM) tree. The current implementation of TAE is a three-level LSM tree, including L0, L1, and L2. L0 is relatively tiny and stored entirely in memory, while L1 and L2 are persisted on disk.

    In TAE, L0 consists of transient blocks, where data is unsorted. On the other hand, L1 consists of sorted blocks that contain sorted data. New data is permanently inserted into the latest transient block. When the number of rows in a transient block exceeds a limit due to inserted data, the block is sorted by the primary key and then flushed into L1 as a sorted block. If the number of sorted blocks exceeds the maximum limit for a segment, a merge sort method is used to sort and write them into L2.

    Both L1 and L2 store data sorted by the primary key. The main difference between the two is that L1 ensures data is sorted within a block, while L2 ensures data is sorted within each segment. A segment is a logical concept equivalent to row groups or sets in other implementations. A segment can be compressed based on the number of updates (delete) operations, resulting in a new segment. Additionally, multiple segments can be merged into a new segment. These operations are performed by background asynchronous tasks, with scheduling strategies that balance write amplification and read amplification.

    "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#key-features","title":"Key Features","text":"
    • Suitable for AP scenarios: TAE offers efficient data compression, high query efficiency, fast aggregate operations, and concurrent solid processing capabilities. Therefore, TAE performs better and is more suitable for analytics processing and data warehousing scenarios, especially with large-scale data.
    • Flexible workload adaptation: By introducing the concept of Column Families, TAE allows flexible workload adaptation. For example, if all columns belong to the same Column Family (i.e., all column data is stored together), it behaves similarly to row storage. If each column is an independent Column Family (i.e., each column is stored independently), it behaves like a column storage. Users can easily switch between row and column storage by specifying it in the DDL table definition.
    "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#indexing-and-metadata-management","title":"Indexing and Metadata Management","text":"

    Like traditional column storage engines, TAE introduces Zonemap (min/max data) information at the block and segment levels. As a transactional storage engine, TAE implements complete primary key constraint functionality, including support for multi-column primary keys and global auto-increment IDs. A primary key index is automatically created for each table to ensure data deduplication during data insertion to satisfy the primary key constraint and enable filtering based on the primary key.

    Primary key deduplication is a critical step in data insertion. TAE achieves a balance in the following aspects:

    • Query performance
    • Memory usage
    • Data layout matching

    From an indexing granularity perspective, TAE can be divided into table-level indexing and segment-level indexing. For example, there can be one table-level index or one index per segment. Since TAE's table data consists of multiple segments, each undergoing compression/merging processes from L1 to L3, transitioning from unordered to ordered, table-level indexing is unfavorable. Therefore, TAE's indexing is built at the segment level.

    In segment-level indexing, there are two segments: append-only and non-dependable. For non-appendable segments, the segment-level index is a two-tier structure consisting of a Bloom filter and a Zone map. Dependable segments are composed of at least one dependable block and multiple non-appendable blocks. The index of the dependable block is an ART-tree (Adaptive Radix Tree) structure and a Zonemap, which reside in memory. The non-appendable blocks contain a Bloom filter and a Zone map.

    "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#buffer-management","title":"Buffer Management","text":"

    In a stable storage engine, efficient memory management is crucial for buffer management. Although buffer management is theoretically just the concept of a least-recently-used (LRU) cache, databases do not directly use the operating system's page cache to replace the cache manager, especially for transactional (TP) databases.

    In MatrixOne, a cache manager is used to manage memory buffer areas. Each buffer node has a fixed size and is allocated to four areas:

    1. Mutable: A fixed-size buffer area used to store transient column blocks from L0.
    2. SST: A buffer area used to store blocks from L1 and L2.
    3. Index
    An area for storing index information. 4. Redo log: Stores uncommitted transaction data, with at least one buffer needed per transaction.

    Each buffer node can be in either the Loaded or Unloaded state. When a user requests a pin operation on a buffer node from the cache manager, the reference count of the node is increased if it is in the Loaded state. If the node is in the Unloaded state, it is read from disk or remote storage, increasing the reference count. When there is insufficient memory, the system removes some nodes from memory based on the LRU strategy to free up space. When a user unpins a node, they close the node handle. If the reference count is 0, the node becomes a candidate for removal, while it remains in memory if the reference count is greater than 0.

    "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#write-ahead-log-and-log-replay","title":"Write-Ahead Log and Log Replay","text":"

    In TAE, the handling of redo logs is optimized to make the column storage engine's Write-Ahead Log (WAL) design more efficient. Unlike a row storage engine, TAE only records redo logs during transaction commits instead of recording them for each write operation. Utilizing the cache manager reduces the usage of input/output (IO), especially for short-lived transactions that may require rollbacks, thereby avoiding IO events. Additionally, TAE can support large or long-running transactions.

    The format of the log entry header in TAE's redo log follows the structure below:

    Item Byte Size GroupID 4 LSN 8 Length 8 Type 1

    The transaction log entries include the following types:

    Type Data Type Value Description AC int8 0x10 Full write operations of a committed transaction PC int8 0x11 Partial write operations of a committed transaction UC int8 0x12 Partial write operations of an uncommitted transaction RB int8 0x13 Transaction rollback CKP int8 0x40 Checkpoint

    Most transactions have only one log entry, but larger or longer transactions may require multiple entries. Therefore, a transaction's log may contain one or more UC-type log entries, one PC-type log entry, or just one AC-type log entry. UC-type log entries are allocated to a dedicated group.

    In TAE, the payload of a transaction log entry contains multiple transaction nodes. Transaction nodes include data manipulation language (DML) operations such as delete, add, update, and data definition language (DDL) operations such as create/delete table, create/delete database, etc. Each transaction node is a sub-item of a committed log entry and can be understood as part of the transaction log. Active transaction nodes share a fixed-size memory space and are managed by the cache manager. When there is insufficient space, some transaction nodes are unloaded, and their corresponding log entries are saved in the redo log. These log entries are replayed and applied to their respective transaction nodes during loading.

    A checkpoint is a safe point where the state machine can apply log entries during a system restart. Log entries before the checkpoint are no longer needed and will be physically destroyed at the appropriate time. TAE records information about the last checkpoint through groups, allowing log replay to start from the last checkpoint during system restart.

    TAE's WAL and log replay components have been independently abstracted into a code module called log store. It provides an abstraction for low-level log storage and access operations, which can be adapted to different implementations ranging from single-node to distributed systems. At the physical level, the behavior of a store is similar to that of a message queue. Starting from version 0.6 of MatrixOne, we have evolved towards a cloud-native version, using a separate shared log service as the log service. Therefore, in future versions, TAE's log store will be appropriately modified to access the external shared log service directly, eliminating the dependency on local storage.

    "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#transaction-processing","title":"Transaction Processing","text":"

    TAE ensures transaction isolation by employing the Multi-Version Concurrency Control (MVCC) mechanism. Each transaction is equipped with a consistent read view determined by the transaction's start time, ensuring that the data read within the transaction never reflects modifications made by other concurrent transactions. TAE provides fine-grained optimistic concurrency control, and conflicts occur only when updates are made to the same row and column. Transactions use value versions that existed at the start of the transaction and do not lock them during read operations. When two transactions attempt to update the same value, the second fails due to a write-write conflict.

    In TAE's architecture, a table consists of multiple segments, each resulting from multiple transactions. Therefore, a segment can be represented as $[T{start}, T{end}]$ (\u00b7 is the commit time of the earliest transaction, \u00b7 is the commit time of the latest transaction). To compress and merge segments, an additional dimension is added to the representation of a segment: $([T{start} T{end}]$, [T{create}, T{drop}])$ where $T{create}$ is the creation time of the segment and $T{drop}$ is the deletion time of the segment. When $T{drop} = 0$, it indicates that the segment has not been dropped. The representation of blocks is the same as that of segments: $([T{start}, T{end}]$, [T{create}, T{drop}])$. When a transaction is committed, its read view is determined by the commit time: $(Txn{commit} \\geqslant T{create}) \\bigcap ((T{drop} = 0) \\bigcup (T{drop} > Txn{commit}))$.

    Background asynchronous tasks handle the generation and transformation of segments. To ensure data consistency during data reading, TAE incorporates these asynchronous tasks into the transaction processing framework, as shown in the example below:

    Block $Block1 {L0}$ in layer L0 is created at time $t1$ and contains data from $Txn1$, $Txn2$, $Txn3$, and $Txn4$. Block $Block1 {L0}$ starts sorting at $t11$; its read view is the baseline plus one uncommitted update node. Sorting and persisting blocks may take a long time. Before the committed sorted block $Block2 {L1}$ is flushed, there are two committed transactions $Txn5$, $Txn6$, and one uncommitted transaction $Txn7$. When $Txn7$ is committed at $t16$, it fails because $Block1 {L0}$ has already been terminated. The update nodes $Txn5$ and $Txn6$ committed during the period $(t11, t16)$ will be merged into a new update node, which will be committed together with $Block2 {L1}$ at `$t16

    $`.

    The compaction process terminates a series of blocks or segments and atomically creates a new block or segment (or builds an index). Unlike regular transactions, this process often takes longer, and we do not want to block, update, or delete transactions involving the blocks or segments in question. Therefore, we extend the read view to include the metadata of blocks and segments. During the execution of a transaction, each write operation checks for write-write conflicts. If a conflict occurs, the transaction is terminated prematurely.

    "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#mvcc-multi-version-concurrency-control","title":"MVCC (Multi-Version Concurrency Control)","text":"

    The version storage mechanism of a database determines how the system stores different versions of tuples and the information contained in each version. TAE creates a lock-free linked list called the version chain based on the pointer fields of data tuples. The version chain allows the database to locate the desired version of a tuple accurately. Therefore, the storage mechanism for version data is an essential consideration in the design of a database storage engine.

    One solution is to use an append-only mechanism to store all tuple versions of a table in the same storage space. Due to the inability to maintain a lock-free bidirectional linked list, the version chain can only point in one direction: from old to new (O2N) or from new to old (N2O).

    Another similar solution is time travel, which keeps the information of the version chain separate while maintaining the primary version of tuples in the main table.

    The third solution is to maintain the primary version of tuples in the main table and a series of incremental versions in separate storage. When updating existing tuples, the database acquires a continuous space from the incremental storage to create a new incremental version that only contains the original values of the modified attributes rather than the entire tuple. The database then directly updates the primary version in the main table.

    Each of the above solutions has characteristics that impact its performance in OLTP workloads. For LSM trees, due to their inherent append-only structure, they are closer to the first solution. However, the linked list of the version chain may need to be made apparent.

    TAE currently chooses a variant of the third solution:

    In heavy updates, the old version data of LSM tree structures can lead to significant read amplification. The cache manager maintains the version chain in TAE, and when it needs to be replaced, it is merged with the primary table data to generate new blocks. Thus, it is semantically in-place updates but implemented as copy-on-write, which is necessary for cloud storage. The newly generated blocks have less read amplification, which is advantageous for frequent AP queries after updates.

    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/","title":"MatrixOne Architecture Design","text":""},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone-overview","title":"MatrixOne Overview","text":"

    MatrixOne is a future-oriented hyperconverged cloud & edge native DBMS that supports transactional, analytical, and streaming workload with a simplified and distributed database engine working across multiple datacenters, clouds, edges, and other heterogenous infrastructures. This combination of engines is called HSTAP.

    As a redefinition of the HTAP database, HSTAP aims to meet all the needs of Transactional Processing (TP) and Analytical Processing (AP) within a single database. Compared with the traditional HTAP, HSTAP emphasizes its built-in streaming capability used for connecting TP and AP tables. This provides users with an experience that a database can be used just like a Big Data platform, with which many users are already familiar thanks to the Big Data boom. With minimal integration efforts, MatrixOne frees users from the limitations of Big Data and provides one-stop coverage for all TP and AP scenarios for enterprises.

    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone-architecture-layers","title":"MatrixOne Architecture Layers","text":"

    MatrixOne implements three independent layers, each with its object units and responsibilities. Different nodes can freely scale, no longer constrained by other layers. These three layers are:

    • Compute Layer: Based on Compute Nodes (CNs), MatrixOne enables serverless computing and transaction processing with its cache, which is capable of random restarts and scaling.
    • Transaction Layer: Based on Transaction Nodes and Log Services, MatrixOne provides complete logging services and metadata information, with built-in Logtail for recent data storage.
    • Storage Layer: Full data is stored in object storage, represented by S3, implementing a low-cost, infinitely scalable storage method. A unified File Service enables seamless operations on underlying storage by different nodes.

    After deciding on TAE as the sole storage engine, multiple design adjustments were made to the fused TAE engine, resulting in the TAE storage engine. This engine has the following advantages:

    • Columnar Storage Management: Uniform columnar storage and compression methods provide inherent performance advantages for OLAP businesses.
    • Transaction Processing: Shared logs and TN nodes jointly support transaction processing for compute nodes.
    • Hot and Cold Separation: Using S3 object storage as the target for File Service, each compute node has its cache.

    The compute engine is based on the fundamental goal of being compatible with MySQL, with higher requirements for node scheduling, execution plans, and SQL capabilities. The high-performance compute engine has both MPP (massively parallel processing) and experimental architecture:

    • MySQL Compatible: Supports MySQL protocol and syntax. Fused Engine: Rebuilds execution plans based on DAG, capable of executing both TP and AP.
    • Node Scheduling: Future support for adaptive intra-node and inter-node scheduling, meeting both concurrency and parallelism requirements.
    • Comprehensive SQL Capability: Supports subqueries, window functions, CTE, and spill memory overflow processing.
    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone-architecture-design_1","title":"MatrixOne Architecture Design","text":"

    The MatrixOne architecture is as follows:

    The architecture of MatrixOne is divided into several layers:

    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#cluster-management-layer","title":"Cluster Management Layer","text":"

    Being responsible for cluster management, it interacts with Kubernetes to obtain resources dynamically when in the cloud-native environment, while in the on-premises deployment, it gets hold of resources based on the configuration. Cluster status is continuously monitored with the role of each node allocated based on resource information. Maintenance works are carried out to ensure that all system components are up and running despite occasional node and network failures. It rebalances the loads on nodes when necessary as well. Major components in this layer are:

    • Prophet Scheduler: take charge of load balancing and node keep-alive.
    • Resource Manager: being responsible for physical resources provision.
    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#serverless-layer","title":"Serverless Layer","text":"

    Serverless Layer is a general term for a series of stateless nodes, which, as a whole, contains three categories:

    • Background tasks: the most important one is called Offload Worker, which is responsible for offloading expensive compaction tasks and flushing data to S3 storage.
    • SQL compute nodes: responsible for executing SQL requests, here divided into write nodes and read nodes. The former also provides the ability to read the freshest data.
    • Stream task processing node: responsible for executing stream processing requests.
    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#logreliability-layer","title":"Log(Reliability) Layer","text":"

    As MatrixOne's Single Source of Truth, data is considered as persistently stored in MatrixOne once it is written into the Log Layer. It is built upon our world-class expertise in the Replicated State Machine model to guarantee state-of-the-art high throughput, high availability, and strong consistency for our data. Following a fully modular and disaggregated design by itself, it is also the central component that helps to decouple the storage and compute layers. This in turn earns our architecture much higher elasticity when compared with traditional NewSQL architecture.

    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#storage-layer","title":"Storage Layer","text":"

    The storage layer transforms the incoming data from the Log Layer into an efficient form for future processing and storage. This includes cache maintenance for fast accessing data that has already been written to S3.

    In MatrixOne, TAE (Transactional Analytic Engine) is the primary interface exposed by the Storage Layer, which can support both row and columnar storage together with transaction capabilities. Besides, the Storage Layer includes other internally used storage capabilities as well, e.g. the intermediate storage for streaming.

    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#storage-provision-layer","title":"Storage Provision Layer","text":"

    As an infrastructure agnostic DBMS, MatrixOne stores data in shared storage of S3 / HDFS, or local disks, on-premise servers, hybrid, and any cloud, or even smart devices. The Storage Provision Layer hides such complexity from upper layers by just presenting them with a unified interface for accessing such diversified storage resources.

    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone-system-components","title":"MatrixOne System Components","text":"

    In MatrixOne, to achieve the integration of distributed and multi-engine, a variety of different system components are built to complete the functions of the architecture-related layers:

    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#file-service","title":"File Service","text":"

    File Service is the component of MatrixOne responsible for reading and writing all storage media. Storage media include memory, disk, object storage, and so on., which provide the following features:

    • File Service provides a unified interface so that reading and writing of different media can use the same interface.
    • The design of the interface follows the concept of immutable data. After the file is written, no further updates are allowed. The update of the data is realized by generating a new file.
    • This design simplifies operations such as data caching, migration, and verification and is conducive to improving the concurrency of data operations.
    • Based on a unified read-write interface, File Service provides a hierarchical cache and a flexible cache strategy to balance read-write speed and capacity.
    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#log-service","title":"Log Service","text":"

    Log Service is a component specially used to process transaction logs in MatrixOne, and it has the following features:

    • The Raft protocol ensures consistency, and multiple copies are used to ensure availability.
    • Save and process all transaction logs in MatrixOne, ensure that Log Service logs are read and written typically before the transaction is committed, and check and replay the log content when the instance is restarted.
    • After the transaction is submitted and placed, truncate the content of the Log Service to control the size of the Log Service. The content that remains in the Log Service after truncation is called Logtail.
    • If multiple Log Service copies are down at the same time, the entire MatrixOne will be down.
    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#transaction-node","title":"Transaction Node","text":"

    The Transaction Node (TN) is the carrier used to run MatrixOne's distributed storage engine TAE, which provides the following features:

    • Manage metadata information in MatrixOne and transaction log content saved in Log Service.
    • Receive distributed transaction requests sent by Computing Node (CN), adjudicate the read and write requests of distributed transactions, push transaction adjudication results to CN, and push transaction content to Log Service to ensure the ACID characteristics of transactions.
    • Generate a snapshot according to the checkpoint in the transaction to ensure the snapshot isolation of the transaction, and release the snapshot information after the transaction ends.
    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#computing-node","title":"Computing Node","text":"

    The computing node (CN) is a component of Matrixone that accesses user requests and processes SQL. The toolkit includes the following modules:

    • Frontend, it handles the client SQL protocol, accepts the client's message, parses it to get the executable SQL of MatrixOne, calls other modules to execute the SQL, organizes the query results into a message, and returns it to the client.
    • Plan, parse the SQL processed by Frontend, generate a logical execution plan based on MatrixOne's calculation engine and send it to Pipeline.
    • Pipeline, which parses the logical plan, converts the logical plan into an actual execution plan and then runs the execution plan through Pipeline.
    • Disttae, responsible for specific read and write tasks, including synchronizing Logtail from TN and reading data from S3, and sending the written data to TN.
    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#stream-engine","title":"Stream Engine","text":"

    Stream Engine is a new component within MatrixOne, serving as an integrated stream engine designed for real-time querying, processing, and enriching data stored in a series of incoming data points, also known as data streams. With Stream Engine, you can employ SQL to define and create streaming processing pipelines, offering real-time data backend services. Additionally, you can utilize SQL to query data within streams and establish connections with non-streaming datasets, thereby further streamlining the data stack.

    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#proxy","title":"Proxy","text":"

    The Proxy component is a powerful tool mainly used for load balancing and SQL routing. It has the following functions:

    • Through SQL routing, resource isolation between different accounts is realized, ensuring that the CNs of different accounts will not affect each other.
    • Through SQL routing, users can do a second split in the resource group of the same account, improving resource utilization.
    • The load balancing between different CNs is realized in the second split resource group, making the system more stable and efficient.
    "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#learn-more","title":"Learn More","text":"

    This page outlines the overall architecture design of MatrixOne. For information on other options that are available when trying out MatrixOne, see the following:

    • Install MatrixOne
    • MySQL Compatibility
    • What's New
    "},{"location":"MatrixOne/Overview/architecture/streaming/","title":"Detailed Stream Engine Architecture","text":"

    MatrixOne incorporates a built-in stream engine designed for real-time querying, processing, and enriching data stored in a series of incoming data points, known as data streams. Developers can now use SQL to define and create stream processing pipelines as a real-time data backend service. Furthermore, developers can utilize SQL to query data within streams and establish connections with non-streaming datasets, thereby further simplifying the data stack.

    "},{"location":"MatrixOne/Overview/architecture/streaming/#technical-architecture","title":"Technical Architecture","text":"

    The technical architecture of the MatrixOne stream engine is illustrated as follows:

    MatrixOne introduced the ability to create streaming tables and implemented a Kafka connector to fulfill the streaming data ingestion requirements of numerous time-series scenarios.

    "},{"location":"MatrixOne/Overview/architecture/streaming/#connectors","title":"Connectors","text":"

    Connectors facilitate connecting with external data sources, such as the Kafka connector introduced in MatrixOne 1.0.

    MatrixOne supports the use of the following statement to establish a connection between connectors and external data sources:

    CREATE SOURCE | SINK CONNECTOR [IF NOT EXISTS] connector_name CONNECTOR_TYPE WITH (property_name = expression [, ...]);\n

    Here, the parameter CONNECTOR_TYPE is used to specify the target.

    "},{"location":"MatrixOne/Overview/architecture/streaming/#streams","title":"Streams","text":"

    A stream represents an append-only data flow akin to an unbounded table with infinite events. Each stream maps to an event group in the storage layer, such as Kafka topics or MatrixOne tables.

    • External stream: A stream using an external storage layer via connectors.
    • Internal stream: A stream that utilizes MatrixOne tables as the event storage.

    MatrixOne supports the use of the following statement to create streams:

    CREATE [OR REPLACE] [EXTERNAL] STREAM [IF NOT EXISTS] stream_name\n({ column_name data_type [KEY | HEADERS | HEADER(key)] } [, ...])\nWITH (property_name = expression [, ...]);\n

    For example, you can refer to the following examples:

    CREATE EXTERNAL STREAM STUDENTS (ID STRING KEY, SCORE INT)\nWITH (kafka_topic = 'students_topic', value_format = 'JSON', partitions = 4);\n

    Or:

    CREATE STREAM STUDENTS (ID STRING KEY, SCORE INT)\n

    You can also query streams and connect them with other tables and materialized views, as shown below:

    SELECT * FROM STUDENTS WHERE rank > 5;\n

    Additionally, you can insert new events, as demonstrated below:

    INSERT INTO foo (ROWTIME, KEY_COL, COL_A) VALUES (1510923225000, 'key', 'A');\n
    "},{"location":"MatrixOne/Overview/feature/cost-effective/","title":"Cost-Effective","text":"

    MatrixOne is a newly designed database, the architectural design philosophy emphasizing high-cost performance. The high cost-performance of MatrixOne is mainly reflected in the following aspects:

    "},{"location":"MatrixOne/Overview/feature/cost-effective/#single-cluster-supports-mixed-load-htap","title":"Single Cluster Supports Mixed Load HTAP","text":"

    With the rapid popularization and diversified development of big data applications, traditional data processing solutions are increasingly unable to meet the demand for real-time analysis of massive data. Modern data application requirements tend to consider both high-concurrent OLTP transactional business and large-scale data OLAP analytical business simultaneously.

    MatrixOne is specifically designed to solve the problem of mixed loads. MatrixOne can support OLTP and OLAP in the same cluster, achieving Hybrid Transaction and Analytical Processing (HTAP). Users no longer need to build two separate database systems for OLTP and OLAP, a single database can support mixed loads. This avoids the cost of building and maintaining two systems and the ETL process of synchronizing data from the OLTP system to the OLAP system. Users can easily handle business and analysis in the same cluster.

    "},{"location":"MatrixOne/Overview/feature/cost-effective/#single-storage-engine-achieves-htap","title":"Single Storage Engine Achieves HTAP","text":"

    In databases, achieving HTAP usually requires encapsulating an OLTP engine and an OLAP engine into a single database product. Although the conversion process between the two storage engines is hidden from the user, who only sees a unified SQL interface, the data is stored twice, once in each machine, and the cost of hardware and storage is not reduced.

    Different from the engine mentioned above encapsulation method, MatrixOne achieves HTAP using a single storage engine. As shown below, MatrixOne achieves single-engine HTAP by grouping other computing nodes (CN) and distinguishing between load-running links. When a user's application request enters the MatrixOne cluster, the Proxy module distributes OLAP-like requests to the CN group designed explicitly for OLAP. These requests usually need to read or write data on a large scale and interact directly with object storage via the CN nodes. For OLTP-like requests, such as small amounts of INSERT, UPDATE, and DELETE, these go through another group of CN designed explicitly for OLTP, and the TN nodes handle transaction information and write shared logs to LogService. TN also constantly compresses and merges small transactional data from LogService and writes them back to object storage.

    In summary, the data written into MatrixOne by users only exists once and is processed by a single storage engine, significantly reducing the cost of storage and computing hardware.

    "},{"location":"MatrixOne/Overview/feature/cost-effective/#flexible-resource-allocation-increases-utilization","title":"Flexible Resource Allocation Increases Utilization","text":"

    The system primarily serves transactional business based on CRUD in actual data application business scenarios. However, at specific points in time, such as at night, at the end of the month, or at the end of the year, it is necessary to analyze the overall data over a period of time. At this time, if the user only has one database system, they will need to temporarily reduce the business load or conduct OLAP analytical tasks when the business load is low. However, in such cases, there are often problems like long analysis time and cannot affect the long running time of business. If users deploy a separate database system for OLAP analytical business, the actual analytical business is often difficult to maximize, leading to a specific waste of resources.

    As introduced in the previous section, MatrixOne achieves HTAP by grouping stateless computing nodes and supporting OLTP and OLAP business at the underlying layer through different links. This architecture allows MatrixOne to adjust resources flexibly.

    Allocation according to actual business needs increases machine utilization and achieves true cost-effectiveness. When CRUD-type business requirements are high, you can allocate more CN nodes to OLTP. In addition, when analytical business requirements increase, you can give more CN nodes to OLAP. These adjustments are fully dynamic and configurable.

    Take the following diagram as an example; suppose that the user needs 3 computing nodes to handle OLTP business and 3 computing nodes to handle OLAP business. And these hardware resources are fully bound, i.e., nodes serving OLTP cannot provide services for OLAP and vice versa. Moreover, users' planning for machine resources often exceeds the upper limit of actual demand. However, the time to reach the total peak demand is quite limited in real business. If you plan to use the MatrixOne cluster to support these businesses, you can adjust to 4 computing nodes; typically, 3 nodes handle OLTP business, and 1 node takes OLAP business. Then, at the end of the month or other periods when the demand for analysis is high, you can adjust to 1 computing node to handle the OLTP business and 3 computing nodes to run the OLAP business; after the peak period, you can return to the original configuration, thereby improving machine resource utilization by 40%.

    "},{"location":"MatrixOne/Overview/feature/cost-effective/#efficient-and-low-cost-object-storage","title":"Efficient and Low-Cost Object Storage","text":"

    At the storage level, MatrixOne mainly uses object storage. This storage uses the principle of erasure coding and only needs a redundancy as low as 33% to ensure the high availability of data. Compared with the standard method of providing high availability through multiple copies, erasure coding has a higher space utilization rate under the same reliability.

    In the MatrixOne cluster, take the minimum configuration recommended by the official Minio for private deployment (4 nodes \u00d7 4 disks) as an example; MatrixOne can support at least 4 disks as erasure coding disks and 12 disks as data disk architecture, with redundancy of 1.33.

    In addition, object storage also supports low-cost storage media such as HDD disks. In usage scenarios where the demand for cluster computing performance is not high, and storage is the main focus, it can further reduce the usage cost.

    "},{"location":"MatrixOne/Overview/feature/cost-effective/#high-data-compression-ratio-brought-by-column-storage","title":"High data compression ratio brought by column storage","text":"

    When structured data is stored, the data structure of each column is the same. In the MatrixOne storage layer, data is stored in column format. This feature gives the data better compression characteristics:

    • Free compression algorithm: Each column is stored separately, and different columns can choose the most suitable compression algorithm for their data structure. These algorithms can use column data characteristics such as duplicate values, ordering, and data type-specific compression techniques to achieve better results. In contrast, the compression algorithms used by traditional row-store databases are often more general and fail to take full advantage of the characteristics of column data.
    • High redundancy of intra-column data: Column storage databases store data in the same column together so that similar values \u200b\u200bwill be clustered together, resulting in higher redundancy, allowing the compression algorithm to more effectively identify and compress the same or Similar data items, thus improving the compression ratio.

    The overall data compression rate of MatrixOne can be as low as 1%. The specific compression rate is affected by many factors, such as the data structure of the actual data and the degree of data redundancy.

    MatrixOne's columnar storage method will significantly compress your actual storage space and greatly reduce your storage costs.

    "},{"location":"MatrixOne/Overview/feature/cost-effective/#compatibility-with-mysql","title":"Compatibility with MySQL","text":"

    MatrixOne maintains compatibility with MySQL, the most popular open-source database on the market, regarding syntax, protocol, and ecological tools. This allows users familiar with MySQL or who have used MySQL to migrate and learn at a meager cost.

    For detailed information on MatrixOne's compatibility with MySQL, please look at the MySQL Compatibility Section.

    "},{"location":"MatrixOne/Overview/feature/feature-overview/","title":"MatrixOne Features Overview","text":""},{"location":"MatrixOne/Overview/feature/feature-overview/#features","title":"Features","text":"

    In MatrixOne, it has the following features to make you more efficient in the process of using MatrixOne:

    "},{"location":"MatrixOne/Overview/feature/feature-overview/#distributed-architecture","title":"Distributed Architecture","text":"

    In MatrixOne, the distributed storage and computing separation architecture is adopted. The separation of the storage, data, and computing layers enables MatrixOne to flexibly realize node expansion when encountering system resource bottlenecks. At the same time, resources can be allocated more efficiently under the multi-node architecture, avoiding hotspots and resource requisition to a certain extent.

    "},{"location":"MatrixOne/Overview/feature/feature-overview/#transactions-and-isolation","title":"Transactions and Isolation","text":"

    In MatrixOne, transactions are isolated using optimistic transactions and snapshots.

    Optimistic transactions can achieve better performance in a distributed architecture with fewer conflicts. At the same time, snapshot isolation with a higher isolation level can be achieved in terms of implementation. In order to ensure the ACID four elements of the transaction, MatrixOne currently supports and only supports one snapshot isolation level. Compared with the ordinary read-committed isolation level, this is stricter, which can effectively prevent dirty reads and better adapt to distributed optimistic transactions.

    "},{"location":"MatrixOne/Overview/feature/feature-overview/#cloud-native","title":"Cloud Native","text":"

    MatrixOne is a cloud-native database. From the storage layer, it adapts to various storage methods such as local disks, AWS S3, and NFS and realizes non-aware management of multiple types of storage through File service. MatrixOne clusters can run stably in a variety of infrastructure environments, can adapt to private enterprise clouds, and provide services in different public cloud vendor environments.

    "},{"location":"MatrixOne/Overview/feature/feature-overview/#load-balancing","title":"Load Balancing","text":"

    Under the distributed database architecture, load differences inevitably exist between different nodes, which may lead to performance bottlenecks in specific business scenarios or idle computing resources. Therefore, to ensure that other nodes are kept as close as possible in resource allocation, MatrixOne implements the load-balancing function of computing resources.

    "},{"location":"MatrixOne/Overview/feature/feature-overview/#sql-routing","title":"SQL Routing","text":"

    SQL routing is often used in early sub-database and sub-table database scenarios. It determines which instance/library/table to send the request to according to the data distribution after receiving an SQL request.

    In MatrixOne, although the capacity of the storage engine no longer limits the size of the database, under the multi-CN architecture, there are still scenarios for load balancing between multiple CNs and resource isolation between different accounts. Therefore, in MatrixOne, SQL routing is implemented to send SQL requests to other CN nodes for execution according to predefined rules. This solves the situation that a database instance cannot load many data access requirements.

    "},{"location":"MatrixOne/Overview/feature/feature-overview/#allowlist","title":"Allowlist","text":"

    Allowlist is a security policy that controls access to restricted resources, systems, or networks. It is based on a core idea that only authorized and trusted entities are allowed to access, while other unauthorized access attempts are denied. These authorized entities may include specific users, IP addresses, programs, or others. The opposite of an allowlist is a blocklist, a policy that specifies a list of prohibited entities that will be prevented from accessing a restricted resource, system, or network. Under the blocklist policy, entities outside the blocklist can access.

    The allowlist has the following characteristics:

    • Only users or systems on the pre-defined list are allowed to access; other users or systems not included in the allowlist are denied access.
    • Using an allowlist policy can improve security but may limit access for legitimate users. Therefore, a trade-off exists between security and user convenience when implementing an allowlist policy.
    • In the database system, the allowlist is mainly used to restrict user access, only allowing specific users to access the database of a particular server or network segment, thereby improving the security of the database.
    "},{"location":"MatrixOne/Overview/feature/feature-overview/#multi-account","title":"Multi-Account","text":"

    The multi-account mode of a single cluster can provide benefits such as resource sharing, simplified management, improved scalability, and security isolation. It is precious for scenarios needing database services for multiple accounts simultaneously.

    MatrixOne's multi-account mode can provide independent database instances for different accounts and adopts a logical isolation method to ensure the security and independence of each account's data, effectively preventing the risk of data leakage and tampering.

    "},{"location":"MatrixOne/Overview/feature/feature-overview/#matrixone-key-performance","title":"MatrixOne Key Performance","text":""},{"location":"MatrixOne/Overview/feature/feature-overview/#efficient-storage","title":"Efficient Storage","text":"

    MatrixOne chooses AWS S3 as an efficient storage solution, meeting the two core requirements of low cost and hot-cold data separation. Its reliable availability ensures low risk in public clouds and provides a compatible version for private deployment.

    • Low cost: Reducing redundancy to achieve lower costs with acceptable performance.
    • Hot-cold data separation: A necessary condition for fine-grained data management.
    "},{"location":"MatrixOne/Overview/feature/feature-overview/#clear-transaction-division-of-labor","title":"Clear Transaction Division of Labor","text":"
    • CN is responsible for all calculations and transaction logic, while TN is responsible for storing metadata, log information, and transaction adjudication.
    • The Logtail object is introduced in the logs to save associated data from recent logs. Logtail data is regularly written to S3. When CN scales out, Logtail data can be synchronized to the cache in real-time to achieve partial data sharing.
    • Set a threshold for transaction size. Transactions that exceed the threshold are directly written to S3 and logs only record write records. Transactions that do not exceed the threshold are still written by TN, significantly increasing throughput.
    "},{"location":"MatrixOne/Overview/feature/feature-overview/#htap-workload-isolation","title":"HTAP Workload Isolation","text":"

    As an HTAP database, it achieves isolation of different types of workloads:

    • Server-level isolation: When hardware resources are sufficient, each component runs on a different physical machine and accesses the same object storage.
    • Container-level isolation: When hardware resources are limited, the stateless nature of all nodes is utilized, and containers are used as isolation measures for each node.
    "},{"location":"MatrixOne/Overview/feature/feature-overview/#flexible-resource-allocation","title":"Flexible Resource Allocation","text":"

    As an HTAP database, the ratio of different business scenarios constantly changes, and there are higher requirements for resource allocation. The resource allocation pattern under the old architecture is doomed to be unable to achieve flexible adjustment, and more refined management of each node is needed, including but not limited to the following:

    • CN node division of labor: Users can divide CN for TP or AP business. When a business resource bottleneck occurs, CN is horizontally scaled out. Dynamically judge the workload of different business CN groups and automatically allocate idle resources to busy groups.
    • Complete isolation of analytical resources is achieved through the logical concept of accounts (accounts). Different accounts can use specified CN resources in a dedicated or shared manner.
    "},{"location":"MatrixOne/Overview/feature/high-availability/","title":"High Availability","text":"

    The high availability of a database is a critical enterprise demand, ensuring the continuous availability of the system, data security, and business continuity. MatrixOne is a highly available distributed database that can meet enterprise demands. This document aims to introduce the high availability features of MatrixOne, including critical functions such as fault recovery, data redundancy, load balancing, and so on.

    "},{"location":"MatrixOne/Overview/feature/high-availability/#business-requirements","title":"Business Requirements","text":"

    The business demands high database availability mainly reflect the following aspects:

    • Continuous Availability: Enterprises need to ensure the continuous operation of their critical business databases to prevent long-term system interruptions or unavailability of services, thus ensuring business continuity and user satisfaction.

    • Fault Recovery: When a database failure occurs, it should quickly and automatically perform fault detection and switch to reduce the system downtime, ensuring the continuity and reliability of the service.

    • Data Protection and Recovery: Data is a vital enterprise asset, so regular database backups are needed, and quick data recovery is required to cope with accidental data loss or damage.

    • Cross-Regional Disaster Recovery: For critical businesses, it may be necessary to set up data centers in different geographical regions, implementing cross-regional disaster recovery to cope with natural disasters, network interruptions, or regional faults.

    "},{"location":"MatrixOne/Overview/feature/high-availability/#advantages","title":"Advantages","text":"

    MatrixOne uses erasure coding for data redundancy checks and synchronizes transaction logs using the Raft protocol. Only when a majority of nodes write successfully can the transaction be committed, ensuring the strong consistency of data and availability even when a minority of replicas fail. MatrixOne's high availability meets the level 4 standard in the finance industry (RPO=0, RTO<30min).

    "},{"location":"MatrixOne/Overview/feature/high-availability/#architecture","title":"Architecture","text":"

    The overall technical architecture of MatrixOne is shown in the figure below. We will introduce their high availability according to different component modules.

    "},{"location":"MatrixOne/Overview/feature/high-availability/#resource-scheduling-layer","title":"Resource Scheduling Layer","text":"

    The technical architecture of MatrixOne is completely cloud-native. All technical components run on Kubernetes in a containerized form. The Kubernetes cluster can ensure continuous availability by adopting a multi-master and multi-slave deployment scheme. Specific deployment topology and system can refer to the Kubernetes official scheme.

    "},{"location":"MatrixOne/Overview/feature/high-availability/#storage-layer","title":"Storage Layer","text":"

    MatrixOne uses object storage in the storage layer and recommends deploying with Minio. MinIO, as a mature distributed object storage solution, needs to ensure the high availability of data services and the completeness and consistency of data files. The architecture of the MinIO cluster is distributed, storing data on multiple nodes, and providing high availability and fault tolerance. At the same time, the MinIO cluster uses Erasure Coding technology to ensure the reliability and availability of data. When a node fails, other nodes can use these coded replicas to recover lost data.

    "},{"location":"MatrixOne/Overview/feature/high-availability/#shared-logs","title":"Shared Logs","text":"

    The shared log component LogService is the only component in MatrixOne that holds distributed transaction status. This is a three-node architecture following the Raft protocol. Even if one node fails, it can still work typically. It is responsible for ensuring the final consistency of services for the entire MatrixOne cluster.

    "},{"location":"MatrixOne/Overview/feature/high-availability/#transaction-layer","title":"Transaction Layer","text":"

    The transaction layer component Transaction node is responsible for conflict detection and arbitration of transaction operations. It is a stateless node. If a failure occurs, Kubernetes can pull it up at any time, and it can generally recover in seconds, ensuring continuous availability. The current version of Transaction node only supports single-node operation, and subsequent versions will add multiple Transaction node schemes to improve availability further.

    "},{"location":"MatrixOne/Overview/feature/high-availability/#computation-layer","title":"Computation Layer","text":"

    The computation layer component Compute Node is responsible for parsing front-end Queries, generating, and executing execution plans. It is also a stateless node. If a failure occurs, Kubernetes can pull it up at any time and generally recover in seconds, ensuring continuous availability.

    "},{"location":"MatrixOne/Overview/feature/high-availability/#proxy","title":"Proxy","text":"

    The Proxy component in the resource scheduling layer is responsible for grouping computation nodes CN to achieve load isolation and implement user connection level load balancing within the CN group. Proxy also runs in the form of multiple replicas backing each other up to ensure high availability.

    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/","title":"HTAP","text":"

    MatrixOne is a database capable of supporting Hybrid Transaction Analytical Processing (HTAP), aiming to provide a solution that fulfills all the requirements for transaction processing (TP) and analytical processing (AP) within a single database. With its decoupled architecture for storage and transaction computations, MatrixOne can support online transactions and real-time statistical analysis in the same data engine while providing an efficient resource isolation mechanism. This design dramatically preserves data freshness, eliminating the need for building real-time data warehouses in many business scenarios, thus helping customers realize their business value.

    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#business-requirements","title":"Business Requirements","text":"

    With the expansion of business scale, the continuous growth of data volume, and the increasing complexity of business systems, traditional online databases have to face the issue of splitting. However, the architecture after splitting cannot meet some needs for associated statistics and real-time analysis. At this time, products like real-time data warehouses come into play. However, due to the complex architecture and high cost of real-time data warehouses, not all enterprises can build a complete ecological link. MatrixOne's HTAP mode was born in response to this situation. It can use one engine to support high concurrent online throughput while providing real-time online analysis capability for massive data. This provides momentum for enterprises to improve efficiency and continuous innovation.

    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#advantages","title":"Advantages","text":"
    • One-stop experience: Satisfy all the needs for transaction processing (TP) and analytical processing (AP) within a single database, and users can enjoy a one-stop experience covering all TP and AP scenarios.
    • Simplified integration work: Users using MatrixOne only need to do a small amount of integration work to achieve extensive use of TP and AP scenarios, especially significantly reducing the complex ETL work from TP database synchronization to AP database.
    • Cost-effective: MatrixOne uses a single storage engine to implement HTAP; compared with traditional multi-engine solutions, users only need to maintain a set of clusters and store one set of data, which can significantly reduce hardware investment.
    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#architecture","title":"Architecture","text":"

    MatrixOne implements HTAP through modular storage, calculation, transaction architecture, a multi-level storage system, and load processing link isolation mode.

    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#modular-separation-of-storage-computation-and-transaction","title":"Modular Separation of Storage, Computation, and Transaction","text":"

    The overall technical architecture of MatrixOne adopts a separate architecture of storage and computation. The modular design separates the database's computation, storage, and transaction processing into independent modules, thus forming a database system with independent scalability for each component. As shown in the following figure, MatrixOne is composed of three independent layers:

    • Computation layer, with Compute Node as the unit, realizes serverless computation and transaction processing. It has its Cache, supporting random restarts and scaling; multiple Compute Nodes can calculate parallel to improve query efficiency.
    • Transaction layer, composed of Transaction Node and Log Service, provides complete log service and metadata information, with built-in Logtail for storing recently written new data.
    • Storage layer, all data are saved in object storage represented by S3, which achieves low-cost, infinitely expandable storage method. Through a unified file operation service named File Service, it realizes the invisible operation of different nodes on the underlying storage.
    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#multi-level-storage-system","title":"Multi-level Storage System","text":"

    As illustrated in the previous section, the storage system of MatrixOne is composed of shared storage for all data, a small number of shared logs, and a stateless cache on the computing nodes.

    • All data are stored in object storage, the primary storage for the entire database and the only location for data persistence. Object storage has the characteristics of being low-cost and nearly infinitely scalable.
    • The LogService provides shared log services for saving state information of transactions such as writes/updates across the entire cluster. It is the only component in the entire cluster with a state. Therefore, LogService must ensure high availability through three nodes using the distributed Raft protocol. However, it only retains transaction logs for a certain period, which we call Longtail. After some time, there will be TN to help compress historical logs and store them in S3. Therefore, Logtail can maintain a very slim data size, generally a few GB.
    • Each computing node CN has a cache. When a user queries for the first time, it will read related data from object storage and put it into the cache as hot data. When the customer queries the same content again, if the cache is hit, the query result will be returned to the user quickly. The technical feature of cold and hot data separation brought by the cache can refer to Detailed Explanation of Data Caching and Cold-Hot Data Separation Architecture. In addition to reading data from object storage, CN nodes will also subscribe to Logtail data from LogService, and new updates in LogService will be pushed to CN immediately.
    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#load-processing-link-isolation","title":"Load Processing Link Isolation","text":""},{"location":"MatrixOne/Overview/feature/key-feature-htap/#custom-load-isolation","title":"Custom Load Isolation","text":"

    User requests first enter the MatrixOne cluster and go through the Proxy module. Proxy is a module used to implement the grouping and isolation of computing nodes. This module groups computing nodes CN into several groups through configuration and uses tags to distinguish various tenants or loads, allowing users to set different CN groups to handle other businesses according to different business needs.

    For specific operations of Proxy using CN groups, refer to Manage CN Groups Using Proxy.

    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#isolation-of-tpap-load-links","title":"Isolation of TP/AP Load Links","text":"

    At the execution level, MatrixOne will route it to different processing links according to the request type, thus realizing the isolation of OLTP and OLAP. Below we will explain how to implement load isolation based on the processing methods of read and write requests.

    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#write-request-processing","title":"Write Request Processing","text":"

    As shown in the figure, when processing write requests (INSERT/UPDATE/DELETE):

    1. CN node will start a transaction and check whether there are primary key conflicts or other transaction-related issues in the write request. If so, it will return an error to the user directly.

    2. Next, CN will decide on the operation link based on the data size of the write request. If the data size does not exceed the set threshold (usually 10MB), the CN node will send the data to the TN node. The TN node will perform operations like write conflict detection and transaction arbitration. After confirming no mistakes, these data will be written into LogService as logs to form Longtail.

    3. The updated Logtail will be immediately pushed to the CN nodes that have subscribed to Logtail data for queries. If the data size exceeds the threshold, the CN node will directly write the data into object storage and send the commit information to TN. The TN node will perform operations like write conflict detection and transaction arbitration. After confirming no errors, the transaction will be committed.

    From the figure above, it is known that small data volume OLTP-type write requests will go through the processing link from CN to TN and then to LogService, while large data volume write requests, such as Load, etc., will mainly go through CN to S3, and a small amount from CN to TN.

    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#read-request-processing","title":"Read Request Processing","text":"

    As shown in the figure, the CN node will first check the subscribed Logtail data when handling read requests. If the data directly hits Logtail, it is in the latest part of the written data and can be directly returned. If it does not hit Logtail, CN will check its cache and other visible CNs. If it hits the cache, it will directly return the result. If it does not hit the cache, CN will judge whether a large amount of data needs to be read through the execution plan. Multiple CN nodes will read in parallel from the object storage if it exceeds a certain threshold (such as 200 block sizes). A single CN node will read from object storage if it does not exceed the threshold.

    As shown above, OLTP and OLAP read requests will go through the processing link from CN to S3. Through the isolation of CN nodes by Proxy, further isolation of CN can be achieved.

    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#scenarios","title":"Scenarios","text":"

    Whether in finance, telecommunications, manufacturing, or emerging industries like the internet and technology, HTAP has many application scenarios.

    For example, in the financial field, HTAP databases can meet the needs of high-speed transaction processing and real-time risk management, support high throughput and low latency requirements of financial transactions, and provide real-time data analysis functions to support decision-making and risk monitoring.

    In the telecommunications industry, HTAP databases can be used for real-time billing and network optimization. They can handle much real-time data, track user communication and network activities, and support real-time analysis and intelligent decision-making to improve service quality, network performance, and user experience.

    In the Internet of Things field, HTAP databases can be used for device management and real-time monitoring. They can handle many sensor data and device status information and provide real-time device monitoring and management functions. This is significant for real-time decision-making, remote fault diagnosis, and predictive maintenance of IoT systems.

    "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#real-time-financial-risk-control-system","title":"Real-time Financial Risk Control System","text":"

    As a leading city commercial bank, a specific bank has a real-time risk control system for its credit card business. This system is mainly responsible for monitoring and evaluating credit card transactions, identifying transaction risks, and taking restrictive measures promptly.

    The following table shows the core business requirements of this system and how MatrixOne's HTAP can meet these needs:

    Core Business Requirements Business Type HTAP Capabilities of MatrixOne Real-time acquisition of transaction data Fast and low-latency data writing MatrixOne can efficiently write massive amounts of data concurrently, further enhancing performance by expanding multiple CN nodes and object storage. Offline calculation of a large amount of data indicators, analysis of user behavior and risk factors Complex analytical queries, needing to process data at the TB level MatrixOne can handle massive star and snowflake data analysis and parallel computation across multiple CN nodes can linearly enhance analytical capabilities. Real-time analysis of transaction data, computation of risk indicators Typical AP business, needing to calculate data results within a specified time MatrixOne's parallel computing capabilities of multiple CN nodes can meet the calculation needs of large-scale data reports while providing fast data reading performance. Facing frequent and drastic business fluctuations Need for a flexible, scalable architecture to cope with large load fluctuations MatrixOne's storage and calculation separation architecture has strong scalability. It can quickly scale up and down during business fluctuations to match business needs."},{"location":"MatrixOne/Overview/feature/key-feature-htap/#telecommunications-business-management-system","title":"Telecommunications Business Management System","text":"

    A specific company is a provincial telecommunications operator serving tens of millions of users, mainly providing telephone communication services, and needs to support the use and statistical analysis of many users.

    The following table shows the core business scenarios of this system and how MatrixOne's HTAP can meet these needs:

    Core Business Scenarios Business Type MatrixOne's HTAP Solution Query user call charge deposit status and real-time shutdown High-concurrent short transactions, requiring low latency MatrixOne has OLTP capabilities, and its distributed architecture across multiple CN nodes ensures stable performance under high concurrency while achieving load balancing. Real-time account balance update after user recharge High-concurrent short transactions, requiring low latency MatrixOne's TP capabilities can meet the high-concurrent and low-latency TP requirements, and the distributed architecture across multiple CN nodes provides load balancing features. Bulk adjustment of user packages and effect in the next month Super large transaction, requiring high performance MatrixOne can write directly to S3, avoiding contention in Logservice under high concurrency, thus achieving fast batch data writing. Perform daily, weekly, monthly, quarterly, and annual statistics on user data Typical AP business, needing to calculate data results within a specified time MatrixOne's parallel computing capabilities of multiple CN nodes can meet the calculation needs of large-scale data reports while providing fast data reading performance."},{"location":"MatrixOne/Overview/feature/key-feature-htap/#manufacturing-execution-system","title":"Manufacturing Execution System","text":"

    A specific company is an electronic product manufacturer with dozens of production lines for various consumer electronic products. Its Manufacturing Execution System (MES) must manage personnel, machines, materials, and processes on the production line and regularly analyze production efficiency and energy consumption issues.

    The following table shows the core business scenarios of this system and how MatrixOne's HTAP can meet these needs:

    Core Business Scenarios Business Type MatrixOne's HTAP Solution Manage production, warehousing, and quality High-concurrent short transactions, requiring low latency MatrixOne has OLTP capabilities, distributed across multiple CN nodes to ensure stable performance under high concurrency while achieving load balancing. Real-time collection of a large amount of machine production data High-concurrent multi-data type data writing MatrixOne can efficiently write massive amounts of data concurrently, further enhancing performance by expanding multiple CN nodes and object storage. Analysis of the origin of a large number of historical production records Need for multidimensional query analysis of massive"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/","title":"Multi-Account","text":"

    MatrixOne is designed in a single-cluster multi-account approach. In this design, account (Account) is a logical concept as a unit of resource allocation and database management. MatrixOne's multi-account mode can provide independent database instances for different accounts and adopts an analytical isolation method to ensure the security and independence of each account's data, effectively preventing the risk of data leakage and tampering.

    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#business-requirements","title":"Business Requirements","text":"

    As an enterprise's business scales up and data volume continues to grow, alongside the increase in business departments or project teams, the enterprise can perform flexible tenant management according to its individual business needs and scale. This satisfies the independence requirements of different business departments or project teams. Under the multi-tenant mode of MatrixOne, enterprises can easily manage the data resources of each tenant, making the business processes such as data analysis and reporting smoother and more accurate. At the same time, this approach also helps the enterprise improve business efficiency, reduce management costs, and maximize enterprise resource utilization.

    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#advantages","title":"Advantages","text":"
    • Reduce operating costs: Multiple users can share a database cluster, avoiding deploying and managing multiple sets of clusters, thereby reducing the investment cost of hardware and software.

    • Resource and load isolation: The multi-account mode improves data security and reliability, and the data and load of different users are isolated from each other. Even if a user's data has problems or the load is too high, it will not affect other users.

    • Dynamic Resource Allocation: multi-account can also improve the scalability of the database. Each account can expand or shrink its resources independently and maximize resource usage in the face of different load levels.

    • account Unified Management: Although each account is isolated and operates independently, administrators can still manage other accounts through the system account, such as quickly creating new accounts and deleting old accounts in batches.

    • account data sharing: Data sharing between accounts is required in specific federal statistical query scenarios. MatrixOne provides a complete account data sharing and subscription mechanism to meet the more flexible business analysis needs.

    • Cross-Regional Deployment: When some services span many regions, accounts must associate with areas to provide nearby services. MatrixOne supports different accounts under the same cluster to be distributed in other areas to serve the business nearby.

    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#architecture","title":"Architecture","text":"

    The MatrixOne system contains two accounts: system (sys) and common accounts. The system account is built into the MatrixOne cluster, and the system will log in to this account by default after the cluster starts. The primary responsibilities of this account include:

    • Store and manage system tables related to the cluster.
    • Manage cluster-level functions, such as creating/deleting accounts, modifying system configuration, etc.

    In contrast, common accounts are created by system accounts. A common account can be regarded as a database instance, and the account name needs to be specified to connect. Common accounts have the following characteristics:

    • Possibility to create your user.
    • Can create databases, tables, and all other objects.
    • Have independent information_schema and other system databases.
    • Has independent system variables.
    • Possess other characteristics that a database instance should have.
    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#multi-account-resource-isolation","title":"Multi-account resource isolation","text":"

    MatrixOne's distributed cluster adopts a Proxy module and CN resource group technology architecture to realize multi-account resource isolation.

    When a user connects, the connection will pass through the Proxy module. The Proxy will forward the connection to a CN in the corresponding CN resource group according to the account label information of the CN and select the CN with the lightest load according to the principle of load balancing. In the MatrixOne cluster architecture, CNs are deployed in containers, so CNs are isolated. A CN resource group a account, uses is a set of CNs tagged with the account. If resources are insufficient and need to be expanded, the CN resource group can be expanded horizontally to meet the demand without preempting the resources of other CN resource groups.

    The architecture diagram is as follows:

    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#scenarios","title":"Scenarios","text":"

    The multi-account capability of MatrixOne can show advantages in the following application scenarios.

    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#multi-account-saas","title":"Multi-account SaaS","text":"

    Multi-account model design is critical in a SaaS application that serves many enterprise customers.

    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#traditional-architecture","title":"Traditional architecture","text":"

    Traditional multi-account architectures store and manage data for each account at the database level. There are usually multiple design patterns, such as a shared database pattern (each account shares a database but has its data tables/columns) or an independent database pattern (each account has its database).

    Both traditional models have specific challenges:

    • The account-shared database mode relies on the application layer to distinguish account logic by SQL and application layer code, and the isolation degree of data and resources is low. It is straightforward to seize the resources of other accounts when the load of a account suddenly increases significantly, resulting in a decline in the entire system's performance. However, only one set of database clusters is used in the account-shared database mode. The resource cost and operation and maintenance management difficulty are relatively low, and the upgrade/expansion/application change only needs to be done once to complete the global change.
    • The account-independent database mode supports each account with an independent database instance. The isolation of resources and data is very high, but resource costs and O&M difficulties are increased. Unifying upgrades and other operation and maintenance actions will be very time-consuming when accounts exceed one hundred.
    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#matrixone-architecture","title":"MatrixOne Architecture","text":"

    The multi-account capability of MatrixOne brings a new architectural approach. accounts still share a MatrixOne cluster, and unified account O&M and management can be performed through system accounts. In addition, the isolation of data and resources is realized through the built-in multi-account capability. Each account can independently expand and contract resources, further reducing the difficulty of operation and maintenance. This approach meets not only the requirements for isolation but also the requirements for low resource and operation and maintenance costs.

    Multi-account mode Data isolation degree Resource cost Resource isolation Operation and maintenance complexity account Shared Database Mode Low Low Low Low account Independent Database Mode High High High High MatrixOne Mode High Low High Low"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#microservice-application-architecture","title":"Microservice Application Architecture","text":"

    Microservice application architecture is a software architectural pattern that implements an application by developing small services. Each small service typically runs in its process and communicates via a lightweight HTTP API. These services are usually bounded by business modules, which can be developed, deployed independently, and released using automated deployment tools. A microservices approach can help businesses launch new products and services faster, aligning development teams with business goals.

    Unlike SaaS applications, microservice applications also face the problem of database sharing or independence. It is usually recommended to prepare a separate database for each microservice; this pattern is more suitable for microservice architecture because each service is developed, deployed, and scaled independently. Other services will not be affected when there is a need to upgrade or change the data schema. When a service needs to be expanded, the service can also be partially developed. In addition, if some services require unique database capabilities, such as Elastic Search or vector search, etc., this mode provides more flexible possibilities.

    However, microservices ultimately serve the same business, and data must be shared between different services, so they will also encounter the same dilemma as SaaS application multi-account.

    The multi-account capability provided by MatrixOne can well balance these two contradictions, which can not only ensure the independence of data and resource expansion of each microservice but also maintain a certain degree of sharing.

    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#group-subsidiariesbusiness-units","title":"Group Subsidiaries/Business Units","text":"

    Many group companies separate operations with regional subsidiaries or business units, which often operate independently, with total production, sales, and technical support teams, and use their IT systems. However, the group company needs to fully grasp the business status of the subsidiaries, so the subsidiaries need to report a large amount of business data regularly.

    This IT architecture faces precisely the same problem in terms of database design as the previous two scenarios, namely the trade-off between sharing and isolation. In addition, geographical location also needs to be considered in this scenario. Subsidiaries usually have their regional attributes and need to provide services nearby. For example, manufacturing companies are generally located in big cities such as Beijing, Shanghai, Guangzhou, and Shenzhen, but various factories may be scattered in second-and third-tier cities. These factories need to cooperate closely with systems such as ERP and MES. Therefore, these systems often need to be deployed locally in the factory, and the headquarters needs to grasp the situation of each factory, so these systems need to report data to the group company. The traditional deployment architecture usually adopts the method of independently deploying databases, while the application layer implements data synchronization and reporting.

    The multi-account capability of MatrixOne can well solve the database sharing/isolation dilemma. Since the CN nodes required by the accounts can be deployed to the nearest location of the subsidiary company, a cluster can be naturally formed with other components of the group company under the condition of network connectivity, which is not only convenient for localized business use, but also meets the requirements of efficient data reporting and statistics need.

    "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#reference","title":"Reference","text":"

    For more information on multi-account, see:

    • Multi-Account Application Scenario
    • Quick Start: Create accounts, Verify Resource Isolation
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/","title":"MySQL Compatibility","text":"

    This documentation primarily introduces the compatibility comparison information between the MySQL mode of MatrixOne database and the native MySQL database.

    MatrixOne is highly compatible with the MySQL 8.0 protocol and commonly used features and syntax of MySQL 8.0. Additionally, MatrixOne provides support for commonly used MySQL-related tools, including Navicat, MySQL Workbench, JDBC, etc. However, due to the different technical architecture of MatrixOne and its ongoing development and improvement, some functionalities are not yet supported. This section will mainly discuss the differences between the MySQL mode of MatrixOne database and the native MySQL database from the following aspects:

    • DDL Statements
    • DCL Statements
    • DML Statements
    • Advanced SQL Features
    • Data Types
    • Indexes and Constraints
    • Partition
    • Functions and Operators
    • Storage Engine
    • Transaction
    • Security and Permissions
    • Backup and Restore
    • System Variables
    • Programming Language
    • Peripheral Tools
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#ddl-statements","title":"DDL statements","text":""},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-database","title":"About DATABASE","text":"
    • A database with a Chinese name is not supported.
    • ENCRYPTION are currently supported but do not work.
    • ALTER DATABASE is not supported.
    • Only the utf8mb4 character set and utf8mb4_bin collation are supported by default and cannot be changed.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-table","title":"About TABLE","text":"
    • The CREATE TABLE .. AS SELECT statement is not supported.
    • Support AUTO_INCREMENT in the column definition, but not the AUTO_INCREMENT custom start value in a table definition.
    • CHARACTER SET/CHARSET and COLLATE in column definitions are not supported.
    • ENGINE= in the table definition is not supported.
    • The clauses: CHANGE [COLUMN], MODIFY [COLUMN], RENAME COLUMN, ADD [CONSTRAINT [symbol]] PRIMARY KEY, DROP PRIMARY KEY, and ALTER COLUMN ORDER BY can be freely combined in ALTER TABLE, these are not supported to be used with other clauses for the time being.
    • Temporary tables currently do not support using ALTER TABLE to modify the table structure.
    • Tables created using CREATE TABLE ... CLUSTER BY... do not allow modifications to the table structure using ALTER TABLE.
    • ALTER TABLE does not support PARTITION related operations.
    • Support defining Cluster by column clauses to pre-sort a column to speed up queries.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-view","title":"About VIEW","text":"
    • CREATE OR REPLACE VIEW is not supported.
    • The with check option clause is not supported, but MatrixOne simply ignores' ENGINE= '.
    • The DEFINER and SQL SECURITY clauses are not supported.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-sequence","title":"About SEQUENCE","text":"
    • MySQL does not support SEQUENCE objects, but MatrixOne can create a sequence through CREATE SEQUENCE, and the syntax of MatrixOne is the same as PostgreSQL.
    • When using SEQUENCE in a table, you must pay attention to the auto_increment and sequence cannot be used together; otherwise, an error will be occured.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#dcl-statement","title":"DCL Statement","text":""},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-account","title":"About ACCOUNT","text":"
    • Multi Account is a unique function of MatrixOne, including related statements such as CREATE/ALTER/DROP ACCOUNT.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-permission","title":"About Permission","text":"
    • GRANT, authorization logic is different from MySQL.

    • REVOLE, the recovery logic is different from MySQL.

    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-show","title":"About SHOW","text":"
    • MatrixOne does not support performing SHOW operations on certain objects, including TRIGGER, FUNCTION, EVENT, PROCEDURE, ENGINE, and so on.
    • Due to architectural differences, MatrixOne has implemented some SHOW commands solely for syntactic compatibility; these commands will not produce any output, such as SHOW STATUS/PRIVILEGES, etc.
    • Although some commands have the same syntax as MySQL, their results differ significantly from MySQL due to different implementations. These commands include SHOW GRANTS, SHOW ERRORS, SHOW PROCESSLIST, SHOW VARIABLES.
    • For the purpose of its own management, MatrixOne offers several unique SHOW commands such as SHOW BACKEND SERVERS, SHOW ACCOUNTS, SHOW ROLES, SHOW NODE LIST, and others.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-set","title":"About SET","text":"
    • The system variables in MatrixOne differ significantly from MySQL, with most only providing syntactic compatibility. The parameters that can be set at present include: ROLE, SQL_MODE, and TIME_ZONE.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#dml-statements","title":"DML Statements","text":""},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-select","title":"About SELECT","text":"
    • SELECT...FOR UPDATE only supports single-table queries.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-insert","title":"About INSERT","text":"
    • MatrixOne does not support modifiers such as LOW_PRIORITY, DELAYED, HIGH_PRIORITY, IGNORE.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-update","title":"About UPDATE","text":"
    • MatrixOne does not support the use of LOW_PRIORITY and IGNORE modifiers.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-delete","title":"About DELETE","text":"
    • MatrixOne does not support modifiers such as LOW_PRIORITY, QUICK, or IGNORE.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-subqueries","title":"About Subqueries","text":"
    • MatrixOne does not support multi-level associated subqueries in IN.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-load","title":"About LOAD","text":"
    • MatrixOne supports SET, but only in the form of SET columns_name=nullif(expr1,expr2).
    • MatrixOne does not support ESCAPED BY.
    • MatrixOne supports LOAD DATA LOCAL on the client side, but the --local-infle parameter must be added when connecting.
    • MatrixOne supports the import of JSONlines files but requires some unique syntax.
    • MatrixOne supports importing files from object storage but requires some unique syntax.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-explain","title":"About EXPLAIN","text":"
    • MatrixOne's Explain and Explain Analyze printing formats refer to PostgreSQL, which differs from MySQL.
    • JSON-type output is not supported.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#other","title":"other","text":"
    • The REPLACE statement does not currently support rows of values \u200b\u200binserted using the VALUES row_constructor_list parameter.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#advanced-sql-features","title":"Advanced SQL Features","text":"
    • Triggers are not supported.
    • Stored procedures are not supported.
    • Event dispatchers are not supported.
    • Custom functions are not supported.
    • Materialized views are not supported.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#data-types","title":"Data Types","text":"
    • BOOL: Different from MySQL's Boolean value type, which is int, MatrixOne's Boolean value is a new type whose value can only be True or False.
    • DECIMAL: DECIMAL(P, D), the maximum precision of the effective number P and the number of digits after the decimal point D of MatrixOne is 38 digits, and MySQL is 65 and 30, respectively.
    • Float numbers: The usage of Float(M,D) and Double(M,D) is discarded after MySQL 8.0.17, but MatrixOne still retains this usage.
    • DATETIME: The maximum value range of MySQL is '1000-01-01 00:00:00' to '9999-12-31 23:59:59', and the maximum range of MatrixOne is '0001-01 -01 00:00:00' to '9999-12-31 23:59:59'.
    • TIMESTAMP: The maximum value range of MySQL is '1970-01-01 00:00:01.000000' UTC to '2038-01-19 03:14:07.999999' UTC, the maximum range of MatrixOne is '0001- 01-01 00:00:00' UTC to '9999-12-31 23:59:59' UTC.
    • MatrixOne supports UUID type.
    • Spatial types are not supported.
    • BIT and SET types are not supported.
    • MEDIUMINT type is not supported.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#indexes-and-constraints","title":"Indexes and Constraints","text":"
    • Secondary indexes only implement syntax and have no speedup effect.
    • Foreign keys do not support the ON CASCADE DELETE cascade delete.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#partition-support","title":"Partition Support","text":"
    • Only support KEY, HASH two partition types.
    • Subpartitions implement only syntax, not functionality.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#functions-and-operators","title":"Functions and Operators","text":""},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#aggregate-functions","title":"Aggregate Functions","text":"
    • Support MatrixOne-specific Median function.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#date-and-time-functions","title":"Date and Time Functions","text":"
    • MatrixOne's TO_DATE function is the same as MySQL's STR_TO_DATE function.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#cast-function","title":"CAST Function","text":"
    • The type conversion rules are pretty different from MySQL; see CAST.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#window-functions","title":"Window functions","text":"
    • Only RANK, DENSE_RANK, ROW_NUMBER are supported.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#json-functions","title":"JSON functions","text":"
    • Only JSON_UNQUOTE, JSON_QUOTE, JSON_EXTRACT are supported.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#system-management-functions","title":"System Management functions","text":"
    • CURRENT_ROLE_NAME(), CURRENT_ROLE(), CURRENT_USER_NAME(), CURRENT_USER(), PURGE_LOG() are supported.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#tae-storage-engine","title":"TAE Storage Engine","text":"
    • MatrixOne's TAE storage engine is independently developed and does not support MySQL's InnoDB, MyISAM, or other engines.
    • There is only a TAE storage engine in MatrixOne; there is no need to use ENGINE=XXX to change the engine.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#security-and-permissions","title":"Security and Permissions","text":"
    • Only using ALTER USER can change the password.
    • Does not support modifying the upper limit of user connections.
    • Connection IP whitelisting is not supported.
    • Does not support LOAD file authorization management.
    • Can support SELECT INTO file authorization management through the CREATE STAGE section.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#transaction","title":"Transaction","text":"
    • MatrixOne defaults to optimistic transactions.
    • different from MySQL, DDL statements in MatrixOne are transactional, and DDL operations can be rolled back within a transaction.
    • Table-level lock LOCK/UNLOCK TABLE is not supported.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#backup-and-restore","title":"Backup and Restore","text":"
    • The mysqldump backup tool is not supported; only the modump tool is supported.
    • Physical backups are supported.
    • Does not support binlog log backup.
    • Incremental backups are not supported.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#system-variables","title":"System variables","text":"
    • MatrixOne's lower_case_table_names has 5 modes; the default is 1.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#programming-language","title":"Programming language","text":"
    • Java, Python, Golang connectors, and ORM are basically supported, and connectors and ORMs in other languages \u200b\u200bmay encounter compatibility issues.
    "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#other-support-tools","title":"Other support tools","text":"
    • Navicat, DBeaver, MySQL Workbench, and HeidiSQL are basically supported, but the support for table design functions could be better due to the incomplete ability of ALTER TABLE.
    • The xtrabackup backup tool is not supported.
    "},{"location":"MatrixOne/Overview/feature/scalability/","title":"Scalability","text":"

    MatrixOne is a superior integration of heterogeneous cloud-native databases. Its structure is based on a storage, computing, and transaction separation architecture, which boasts impressive elastic scalability that quickly adapts to user workload changes. As data volumes and businesses expand, enterprises' demand for database scalability is ever-increasing.

    Generally, whether user data grows from 0 to 100TB or concurrent operations increase from several hundred to hundreds of thousands, MatrixOne can meet performance demands through its unparalleled scalability.

    "},{"location":"MatrixOne/Overview/feature/scalability/#business-requirements","title":"Business Requirements","text":"

    The demand for database scalability in enterprises primarily originates from the following pain points:

    • Growth in Data Volume: With business development, an enterprise's data volume will continue to grow. Suppose the scalability of the database could be better. In that case, it might not be able to effectively process a large amount of data, leading to a decline in query speed and affecting the regular operation of the business.
    • Increase in Concurrent Requests: As the number of users grows, the number of concurrent requests a database needs to handle also increases. Suppose the scalability of the database could be better. In that case, it might not effectively process many concurrent requests, leading to an extension in response time and affecting the user experience.
    • Change in Business Needs: The business needs of an enterprise may change over time. Suppose the scalability of the database could be better. In that case, it might be unable to flexibly adapt to these changes, causing the enterprise to invest more resources to adjust and optimize the database.
    • System Availability: If the scalability of the database could be better, it might not effectively handle hardware or network failures, resulting in lower system availability, which affects business continuity.

    If a database has good scalability, it can help enterprises improve data processing capabilities, thus effectively coping with the growth of data volume, handling the increase in concurrent requests, and ensuring system availability.

    "},{"location":"MatrixOne/Overview/feature/scalability/#architecture","title":"Architecture","text":"

    MatrixOne adopts a comprehensive cloud-native architecture. All components exist in the form of containers and are uniformly managed by Kubernetes. Kubernetes itself has strong container orchestration and management capabilities. In MatrixOne, the manual expansion only requires modifying the Kubernetes configuration.

    "},{"location":"MatrixOne/Overview/feature/scalability/#advantages","title":"Advantages","text":"

    From the technical architecture perspective, the unparalleled scalability of MatrixOne mainly manifests in the following aspects:

    • Flexible Expansion of Distributed Architecture: MatrixOne adopts a storage and computing-separated architecture. The separation of the storage, transaction, and computing layers allows MatrixOne to expand nodes when encountering system resource bottlenecks flexibly. The storage layer is mainly based on object storage and partly based on the cache on the computing nodes (CN). The transaction layer is based on stateless transaction nodes (TN). The computing layer is based on stateless computing nodes (CN). The multi-node architecture can more effectively distribute resources and avoid hot spots and resource contention.

    • Infinite Expansion Capability of S3 Object Storage: The core storage of MatrixOne is completely based on S3 object storage. S3 object storage has naturally high availability and infinite scalability, making MatrixOne highly scalable in data storage. No matter how the data scale grows, MatrixOne can meet the demand by expanding S3 storage. In a private deployment environment, MatrixOne builds S3 services based on the open-source MinIO component. MatrixOne can seamlessly utilize the object storage service provided by the public cloud in a public cloud environment.

    • Stateless Computing and Transaction Nodes: MatrixOne's computing nodes (CN) and transaction nodes (TN) are stateless, meaning they can be horizontally expanded anytime. Stateless design means that computing and transaction nodes do not need to store any persistent data

    They can be easily added or deleted to cope with different load requirements. This design makes MatrixOne extremely scalable and flexible when dealing with large-scale concurrent requests. (The current 1.0 version TN node does not yet have expansion capabilities, but the TN mainly handles transaction submission information, and the load is lower, so a single TN is enough to take a large-scale cluster, and subsequent versions will improve TN's scalability.)

    • Independent Scaling for Different Workloads and Accounts: MatrixOne utilizes the Proxy module to group multiple compute nodes (CN) into managed sets known as CN Sets, achieved through labeling. This enables the independent scaling of each CN Set. Users can assign different CN Sets to distinct tenants, ensuring load isolation and separate scaling between tenants. It's also possible to give various CN Sets to diverse workloads, such as read and write workloads, or transactional and analytical workloads, thereby achieving isolation and separate scaling between them.
    "},{"location":"MatrixOne/Performance-Tuning/performance-tuning-overview/","title":"SQL Performance Tuning Methods Overview","text":"

    SQL performance tuning optimizes database queries and operations to improve performance and response time. Several standard performance tuning methods include:

    • Index optimization: Indexes can speed up queries and improve database performance. By using the correct index type, selecting the right index columns, avoiding excessive indexing, and regularly rebuilding indexes, you can maximize the use of indexes to improve performance.

    • Query optimization: By optimizing the structure of queries, avoiding unnecessary subqueries, using more efficient JOIN statements, and avoiding using OR operators, you can reduce the time and resources required for queries.

    • Table structure optimization: Optimizing table structure, such as selecting the correct data types, avoiding NULL values, using appropriate constraints and default values, normalization, and denormalization, can reduce storage space and query time.

    • Data volume control: By limiting the amount of data returned, paging, caching, using stored procedures, and other methods, you can reduce the time and resources required for queries.

    • Server configuration optimization: By increasing server memory, adjusting database parameters, regularly cleaning logs and caches, and other methods, you can improve database performance and response time.

    • Monitoring and debugging: Using database performance monitoring tools, debugging SQL queries, viewing database logs and error messages, and other methods can help identify and resolve performance issues.

    It should be noted that SQL performance tuning is a complex process that requires comprehensive consideration of multiple factors such as database structure, data volume, and query patterns. Continuous testing and validation of optimization results are also necessary to ultimately improve database performance and response time.

    When executing SQL statements in MatrixOne, the system automatically plans and selects the optimal execution plan rather than simply querying according to the SQL statements. Currently, MatrixOne supports performance tuning through EXPLAIN interpretation of the execution plan and optimizing the physical arrangement of tables. To help you better tune SQL queries in MatrixOne, you can refer to the following documents on execution plans:

    • MatrixOne Query Execution Plan Overview: Describes the concepts of MatrixOne execution plans.
    • Using EXPLAIN to learn the execution plan: Describes how to use the EXPLAIN statement to understand how MatrixOne executes a query.
    • Performance Tuning Best Practices: Describes the best practices of using Cluster by in MatrixOne for performance tuning and learning how to improve query performance.
    "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/","title":"Optimizer Hints","text":"

    When you determine the problems in the execution plan, such as when the optimizer chooses a query plan that is not optimal, you can use Optimizer Hints to control the generation of the execution plan.

    The Hint hint command tells the query optimizer how to execute the query statement. By using hints, you can provide queries with information about how to access data to improve query performance. The Hint hint directive often tunes large or complex queries.

    Hints can be used to modify the execution plan of a query, including choosing a different index, using a different JOIN algorithm, changing the join order, etc.

    Hints in SQL use comment syntax, and specific comments can be added to query statements to specify hints.

    "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#syntax","title":"Syntax","text":"
    {DELETE|INSERT|SELECT|UPDATE} /*+ hint [text] [hint[text]]... */\n
    "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#explanations","title":"Explanations","text":"
    • DELETE, INSERT, SELECT, UPDATE are keywords of SQL statements.

    • /*+ */ is a comment symbol in the SQL statement.

    • hint is the specific instruction for hinting.

    • text is the argument to the prompt command.

    Here are some commonly used SQL hints:

    /*+ INDEX (table index) */: Specifies to use a specific index to execute the query.

    /*+ FULL (table) */: Specifies to perform a full table scan instead of using an index.

    "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#scenarios","title":"Scenarios","text":"
    • When the query optimizer chooses an inappropriate execution plan, you can use the hint hint to specify a better execution plan. For example, when a query involves multiple tables, the optimizer may choose the wrong join algorithm or join order, resulting in degraded query performance. In this case, hints can be used to specify a better join algorithm or join order.

    • When a query contains complex subqueries or aggregate functions, the hint hint can be used to optimize the execution plan of the query. Because the optimizer cannot analyze complex subqueries or aggregate functions, it may choose the wrong execution plan, resulting in degraded query performance.

    • When the amount of data accessed by the query is vast, the hint hint can be used to optimize the query execution plan. In this case, hints can be used to specify the use of a specific index or join algorithm to improve query performance.

    MatrixOne supports the use of hint hints to choose between full table scans or index scans and to optimize the order of multi-table joins.

    • Select full table scan or use index scan:

    An index scan can speed up queries, but in some cases, a full table scan might be faster than an index scan. For example, using indexes can become slow when query conditions are too broad. In this case, the following hint syntax can be used to choose to use a full table scan or an index scan:

    SELECT /*+ INDEX(table_name index_name) */ column_name FROM table_name WHERE ...\n

    Among them, table_name is the table name, index_name is the index name, and column_name is the column name. If an index name is specified, the query will scan that index. The query will use a full table scan if no index name is specified.

    • Optimize the order of multi-table joins:

    When a query involves multiple tables, the query optimizer will try to choose the optimal join order. However, in some cases, the optimizer may be unable to select the optimal join order, resulting in degraded query performance. In this case, the following hint syntax can be used to optimize the order of multi-table joins:

    SELECT /*+ ORDERED */ column_name FROM table1, table2 WHERE table1.column1 = table2.column2;\n

    Among them, ORDERED specifies that the query should be connected in the order of the tables, that is, connect table1 first and then join table2. This prevents the optimizer from choosing the wrong join order, improving query performance.

    "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#example","title":"Example","text":"
    -- Create a new table called orders\nCREATE TABLE order (\norder_id INT PRIMARY KEY,\ncustomer_id INT,\norder_date DATE,\norder_total DECIMAL(10, 2)\n);\n-- insert datas\nINSERT INTO order (order_id, customer_id, order_date, order_total)\nVALUES\n(1, 101, '2022-05-10', 100.00),\n(2, 102, '2022-05-09', 150.00),\n(3, 103, '2022-05-08', 200.00),\n(4, 104, '2022-05-07', 50.00);\n-- Query all orders of a customer and sort them in descending order by order date\nSELECT order_id, order_date, order_total\nFROM orders\nWHERE customer_id = 123\nORDER BY order_date DESC;\n

    To optimize this query, we can use the following hint hints:

    -- Execute the query using an index called idx_customer_id created on the customer_id field\nSELECT /*+ INDEX(orders idx_customer_id) */ order_id, order_date, order_total\nFROM orders\nWHERE customer_id = 123\nORDER BY order_date DESC;\n
    "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#constraints","title":"Constraints","text":"

    Currently /*+ HINT_NAME(t1, t2) */ only implements the syntax, and cannot control the execution plan for now.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/","title":"Explain Statements Using Aggregation","text":"

    The aggregation may be used in SQL, and the execution plan of the aggregate query can be interpreted through EXPLAIN statements.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/#example","title":"Example","text":"

    We have prepared a simple example to help you understand the execution plan for interpreting the Aggregation using EXPLAIN.

    > drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/#hash-aggregation","title":"Hash Aggregation","text":"

    The Hash Aggregation algorithm uses a hash table to store intermediate results while performing aggregation. It executes in parallel using multiple threads but consumes more memory than Stream Aggregation.

    The following is an example of the Hash Aggregation operator:

    > SELECT /*+ HASH_AGG() */ count(*) FROM t1;\n+----------+\n| count(*) |\n+----------+\n|        9 |\n+----------+\n1 row in set (0.01 sec)\n\nmysql> EXPLAIN SELECT /*+ HASH_AGG() */ count(*) FROM t1;\n+-------------------------------------------+\n| QUERY PLAN                                |\n+-------------------------------------------+\n| Project                                   |\n|   ->  Aggregate                           |\n|         Aggregate Functions: starcount(1) |\n|         ->  Table Scan on db1.t1          |\n+-------------------------------------------+\n4 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/","title":"Explain Statements Using JOIN","text":"

    The SQL Optimizer needs to decide in which order tables should be joined and what is the most efficient join algorithm for a particular SQL statement.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/#example","title":"Example","text":"

    We have prepared a simple example to help you understand the execution plan for interpreting the JOIN using EXPLAIN.

    > drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/#hash-join","title":"Hash Join","text":"

    In the Hash Join operation, MatrixOne first reads the smaller tables in t1 and t2 and uses a hash function for each value to be joined to obtain a hash table. Then each row of the other table is scanned, and the hash value is calculated and compared with the hash table generated in the previous step. A new join table is generated based on the joinif any values meet the join criteria.

    The hash join operator is multi-threaded in MatrixOne and executes in parallel.

    An example of hash join is as below:

    > SELECT /*+ HASH_JOIN(t1, t2) */ * FROM t1, t2 WHERE t1.id = t2.id;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  | id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    1 |    1 |    4 |    3 |  1113.32 |  111332 | 1113 | hello        | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |    1 |    1 |    4 |    3 |  1113.32 |  111332 | 1113 | hello        | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    2 |    2 |    5 |    2 |  2252.05 |  225205 | 2252 | bye          | sub query      | 2022-04-28 | 2022-04-28 22:40:11 |    2 |    2 |    5 |    2 |  2252.05 |  225205 | 2252 | bye          | sub query      | 2022-04-28 | 2022-04-28 22:40:11 |\n|    3 |    6 |    6 |    3 |  3663.21 |  366321 | 3663 | hi           | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |    3 |    6 |    6 |    3 |  3663.21 |  366321 | 3663 | hi           | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    4 |    7 |    1 |    5 |  4715.22 |  471522 | 4715 | good morning | my subquery    | 2022-04-28 | 2022-04-28 22:40:11 |    4 |    7 |    1 |    5 |  4715.22 |  471522 | 4715 | good morning | my subquery    | 2022-04-28 | 2022-04-28 22:40:11 |\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n9 rows in set (0.00 sec)\n\nmysql> EXPLAIN SELECT /*+ HASH_JOIN(t1, t2) */ * FROM t1, t2 WHERE t1.id = t2.id;\n+------------------------------------+\n| QUERY PLAN                         |\n+------------------------------------+\n| Project                            |\n|   ->  Join                         |\n|         Join Type: INNER           |\n|         Join Cond: (t1.id = t2.id) |\n|         ->  Table Scan on db1.t1   |\n|         ->  Table Scan on db1.t2   |\n+------------------------------------+\n6 rows in set (0.01 sec)\n

    MatrixOne executes the Hash Join operator in the following order:

    1. Scan table t2 and t1 in parallel.

    2. Execute the JOIN filter query: (t1.id = t2.id).

    3. Execute INNER JOIN.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/","title":"MatrixOne Query Execution Plan Overview","text":""},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/#what-is-query-execution-plan","title":"What is Query Execution Plan?","text":"

    Execution plan is the specific steps for the database to execute SQL statements, such as accessing data in the table through index or full table scan, connection query implementation method and connection sequence, etc.; the execution plan is based on The details of your tables, columns, indexes, and conditions in the WHERE clause can tell you how the query will be executed or how it has been executed, which can be performed without reading all rows. Huge Queries of tables; joins involving multiple tables can be performed without comparing every combination of rows. If the performance of a SQL statement is not satisfactory, the first thing you should look at is its execution plan. Like most mature database products, MatrixOne database also provides the function of analyzing query statement performance.

    The MatrixOne query optimizer selects the most efficient execution plan by \"calculating\" the input SQL statement, and this execution plan is the execution plan.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/#use-explain-to-query-the-execution-plan","title":"Use EXPLAIN to query the execution plan","text":"

    The EXPLAIN statement shows the MatrixOne query execution plan for the SQL statement.

    EXPLAIN works with SELECT, DELETE, INSERT, REPLACE, and UPDATE statements.

    When EXPLAIN is used with an explainable statement, MatrixOne displays information from the optimizer about the statement execution plan. That is, MatrixOne explains how it would process the statement, including information about how tables are joined and in which order.

    Note

    When you use the MatrixOne client to connect to MatrixOne, to read the output result in a clearer way without line wrapping, you can use the pager less -S command. Then, after the EXPLAIN result is output, you can press the right arrow \u2192 button on your keyboard to horizontally scroll through the output.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/#explain-example","title":"EXPLAIN Example","text":"

    You can see the EXPLAIN example to understand the query execution plan:

    Data preparation:

    CREATE TABLE t (id INT NOT NULL PRIMARY KEY auto_increment, a INT NOT NULL, pad1 VARCHAR(255), INDEX(a));\nINSERT INTO t VALUES (1, 1, 'aaa'),(2,2, 'bbb');\nEXPLAIN SELECT * FROM t WHERE a = 1;\n

    Return result:

    +------------------------------------------------+\n| QUERY PLAN                                     |\n+------------------------------------------------+\n| Project                                        |\n|   ->  Table Scan on aab.t                      |\n|         Filter Cond: (CAST(t.a AS BIGINT) = 1) |\n+------------------------------------------------+\n

    EXPLAIN does not execute the actual query. EXPLAIN ANALYZE can be used to execute the query and show EXPLAIN information. This can be useful in diagnosing cases where the execution plan selected is suboptimal.

    EXPLAIN output analysis

    • QUERY PLAN: the name of an operator.

      • Filter Cond:Filter conditions
      • Table Scan:scans the table
    • Project is the parent node of the executive order in the query process. The structure of the Project is tree-like, and the child node \"flows into\" the parent node after the calculation is completed. The parent, child, and sibling nodes may execute parts of the query in parallel.

    Range query

    In the WHERE/HAVING/ON conditions, the MatrixOne optimizer analyzes the result returned by the primary key query. For example, these conditions might include comparison operators of the numeric and date type, such as >, <, =, >=, <=, and the character type such as LIKE.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/","title":"Explain Statements Using Subqueries","text":"

    MatrixOne performs several optimizations to improve the performance of subqueries. This document describes some of these optimizations for common subqueries and how to interpret the output of EXPLAIN.

    From the execution of SQL statements, subquery generally has the following two types:

    • Self-contained Subquery: In a database nested query, the inner query is entirely independent of the outer query.

      For example: select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);, the execution sequence is as follows:

      • Execute the inner query first: (select t2.id from t2 where t2.id>=3).

      • The result of the inner query is carried into the outer layer, and then the outer query is executed.

    • Correlated Subquery: In Correlated Subquery nested in databases, the inner and outer queries would not be independent, and the inner queries would depend on the outer queries.

      For example: SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);, generally, the execution sequence is as follows:

      • Queries a record from the outer query: SELECT * FROM t1 WHERE id.

      • Put the queried records into the inner query, then put the records that meet the conditions into the outer query.

      • Repeat the above steps.

      However, MatrixOne will rewrite the SQL statement as an equivalent JOIN statement: select t1.* from t1 join t2 on t1.id=t2.id where t2.id>=4;

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/#example","title":"Example","text":"

    We have prepared a simple example to help you understand the execution plan for interpreting the SUBQUERY using EXPLAIN.

    > drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/#self-contained-subquery","title":"Self-contained Subquery","text":"
    > select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    3 |    6 |    6 |    3 |  3663.21 |  366321 | 3663 | hi           | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    4 |    7 |    1 |    5 |  4715.22 |  471522 | 4715 | good morning | my subquery    | 2022-04-28 | 2022-04-28 22:40:11 |\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n7 rows in set (0.02 sec)\n\n> explain select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);\n+---------------------------------------------------------------+\n| QUERY PLAN                                                    |\n+---------------------------------------------------------------+\n| Project                                                       |\n|   ->  Join                                                    |\n|         Join Type: SEMI                                       |\n|         Join Cond: (t1.id = t2.id)                            |\n|         ->  Table Scan on db1.t1                              |\n|         ->  Project                                           |\n|               ->  Table Scan on db1.t2                        |\n|                     Filter Cond: (CAST(t2.id AS BIGINT) >= 3) |\n+---------------------------------------------------------------+\n8 rows in set (0.00 sec)\n

    The execution sequence is as follows:

    1. Execute the inner query first: (select t2.id from t2 where t2.id>=3).

    2. The result of the inner query is carried into the outer layer, and then the outer query is executed.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/#correlated-subquery","title":"Correlated subquery","text":"
    > SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    4 |    7 |    1 |    5 |  4715.22 |  471522 | 4715 | good morning | my subquery    | 2022-04-28 | 2022-04-28 22:40:11 |\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n6 rows in set (0.01 sec)\n\nmysql> explain SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);\n+---------------------------------------------------------------+\n| QUERY PLAN                                                    |\n+---------------------------------------------------------------+\n| Project                                                       |\n|   ->  Join                                                    |\n|         Join Type: SEMI                                       |\n|         Join Cond: (t1.ti = t2.ti), (t1.id = t2.id)           |\n|         ->  Table Scan on db1.t1                              |\n|         ->  Project                                           |\n|               ->  Table Scan on db1.t2                        |\n|                     Filter Cond: (CAST(t2.id AS BIGINT) >= 4) |\n+---------------------------------------------------------------+\n8 rows in set (0.01 sec)\n

    MatrixOne will rewrite the SQL statement as an equivalent JOIN statement: select t1.* from t1 join t2 on t1.id=t2.id where t2.id>=4;, the execution sequence is as follows:

    1. Execute the filter query: where t2.id>=4;.

    2. Scan Table: Table Scan on db1.t2, and then the result \"flow into\" into the parent node.

    3. Scan table table scan on db1.t1.

    4. Execute JOIN.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-views/","title":"EXPLAIN Statements Using Views","text":"

    EXPLAIN displays the tables that a view references, not the name of the view itself. This is because views are only virtual tables and do not store any data themselves. The definition of the view and the rest of the statement are merged together during SQL optimization.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-views/#example","title":"Example","text":"

    We have prepared a simple example to help you understand the execution plan for interpreting the VIEW using EXPLAIN.

    > drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> create view v1 as select * from (select * from t1) sub where id > 4;\n> select * from v1;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.01 sec)\n

    As shown in the above example, a new VIEW named v1 is created, then query the result of v1. So let's learn the query plan in this VIEW:

    > explain select * from v1;\n+--------------------------------------------------------------+\n| QUERY PLAN                                                   |\n+--------------------------------------------------------------+\n| Project                                                      |\n|   ->  Project                                                |\n|         ->  Project                                          |\n|               ->  Table Scan on db1.t1                       |\n|                     Filter Cond: (CAST(t1.id AS BIGINT) > 4) |\n+--------------------------------------------------------------+\n5 rows in set (0.00 sec)\n

    You can see that Project is the parent node in the execution order of this query. It starts from the most indented child node, then \"flows into\" its upper parent node, and finally \"flow into\" the Project parent node.

    To execute firstly:

    • Filter Cond: the filter condition

    To execute secondly:

    • Table Scan: scans all tables

    The following query is executed similarly to the above:

    > explain select * from (select * from t1) sub where id > 4;\n+--------------------------------------------------------+\n| QUERY PLAN                                             |\n+--------------------------------------------------------+\n| Project                                                |\n|   ->  Project                                          |\n|         ->  Table Scan on db1.t1                       |\n|               Filter Cond: (CAST(t1.id AS BIGINT) > 4) |\n+--------------------------------------------------------+\n4 rows in set (0.03 sec)\n
    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/","title":"Using EXPLAIN to learn the execution plan","text":"

    Because SQL is a declarative language, you cannot automatically tell whether a query is executed efficiently. You must first use the EXPLAIN statement to learn the current execution plan.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#example","title":"Example","text":"

    We have prepared a simple example to help you understand how to interpret an execution plan using EXPLAIN.

    > drop table if exists a;\n> create table a(a int);\n> insert into a values(1),(2),(3),(4),(5),(6),(7),(8);\n> select count(*) from a where a>=2 and a<=8;\n+----------+\n| count(*) |\n+----------+\n|        7 |\n+----------+\n1 row in set (0.00 sec)\n\n> explain select count(*) from a where a>=2 and a<=8;\n+-----------------------------------------------------------------------------------+\n| QUERY PLAN                                                                        |\n+-----------------------------------------------------------------------------------+\n| Project                                                                           |\n|   ->  Aggregate                                                                   |\n|         Aggregate Functions: starcount(1)                                         |\n|         ->  Table Scan on aab.a                                                   |\n|               Filter Cond: (CAST(a.a AS BIGINT) >= 2), (CAST(a.a AS BIGINT) <= 8) |\n+-----------------------------------------------------------------------------------+\n5 rows in set (0.00 sec)\n

    Above are the execution plan results for this query. Starting from the Filter Cond operator, the execution process of the query is as follows:

    1. Execute the Filter condition Filter Cond first: the integer whose data type is BIGINT and is greater than or equal to 2 and less than or equal to 8 is filtered out. According to the calculation reasoning, it should be (2),(3),(4),(5),(6),(7),(8).

    2. Scan Table in database aab.

    3. The number of integers is 7.

    In the end, the query result is 7, which means count(*) = 7.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#assess-the-current-performance","title":"Assess the current performance","text":"

    EXPLAIN only returns the query execution plan but does not execute the query.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#what-is-explain-analyze","title":"What is EXPLAIN ANALYZE","text":"

    EXPLAIN ANALYZE is a profiling tool for your queries that will show you where SQL spends time on your query and why. It will plan the query, instrument it and execute it while counting rows and measuring time spent at various points in the execution plan. When execution finishes, EXPLAIN ANALYZE will print the plan and the measurements instead of the query result.

    n addition to the query plan and estimated costs, which a normal EXPLAIN will print, EXPLAIN ANALYZE also prints the actual costs of individual iterators in the execution plan.

    "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#how-to-use-explain-analyze","title":"How to use EXPLAIN ANALYZE?","text":"

    With the above example, to get the actual execution time, you can either execute the query or use EXPLAIN ANALYZE:

    > explain analyze select count(*) from a where a>=2 and a<=8;\n+-------------------------------------------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                                                    |\n+-------------------------------------------------------------------------------------------------------------------------------+\n| Project                                                                                                                       |\n|   Analyze: timeConsumed=0us inputRows=1 outputRows=1 inputSize=8bytes outputSize=8bytes memorySize=8bytes                     |\n|   ->  Aggregate                                                                                                               |\n|         Analyze: timeConsumed=3317us inputRows=2 outputRows=2 inputSize=8bytes outputSize=16bytes memorySize=16bytes          |\n|         Aggregate Functions: starcount(1)                                                                                     |\n|         ->  Table Scan on aab.a                                                                                               |\n|               Analyze: timeConsumed=6643us inputRows=31 outputRows=24 inputSize=96bytes outputSize=64bytes memorySize=64bytes |\n|               Filter Cond: (CAST(a.a AS BIGINT) >= 2), (CAST(a.a AS BIGINT) <= 8)                                             |\n+-------------------------------------------------------------------------------------------------------------------------------+\n8 rows in set (0.00 sec)\n

    Judging from the printed execution results, when performing aggregate calculations and scanning tables respectively, the following measurements are obtained, which can be used as reference items:

    • total time consumed: timeConsumed
    • inputRows/outputRows
    • inputSize/outputSize
    • memorySize

    With this information, you can analyze queries and understand why they behave the way they do, which can be explored in the following ways:

    • How long do these queries take to execute? You'll be able to view the timeConsumed.

    • Why execute the current query plan instead of other execution plans? You can look at the row counter. When there is a significant difference (i.e., several orders of magnitude or more) between the estimated and actual number of rows, it means that the optimizer chooses a plan based on the estimate, but looking at the actual execution can give you a good idea of \u200b\u200bwhich execution plan is better.

    So using EXPLAIN ANALYZE is analyzing query execution.

    The example query above takes 0.00 seconds to execute, which is an ideal performance. Also, because the query we executed in this example is simple, it meets the high execution performance.

    For more information, see EXPLAIN ANALYZE.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/","title":"Scaling CN for better performance","text":"

    MatrixOne is a distributed database; its most distinctive feature is that it can improve the system's overall performance through node expansion. In MatrixOne's storage-computing separation architecture, CN is a stateless computing node, and the rapid expansion of CN nodes is the core of the performance improvement of the entire cluster.

    Generally, we can extend CN in two ways:

    1. Vertically expand CN nodes: improve performance by adjusting the resources of a single CN node. This includes the improvement of the entire CN resource and cache.

    2. Horizontal expansion of CN nodes: Improve performance by increasing the number of CN nodes.

    One of the smallest MatrixOne distributed cluster architectures is shown in the following figure:

    CN mainly performs the user's query request. Therefore, the resource size of the CN node is proportional to the computing power. The most direct expansion method is to expand the resources of a single CN node vertically. At the same time, the queried data is stored in the CN cache as hot data. If the cache is hit, the query can be returned directly from the cache without obtaining cold data from the object store. After the upper capacity limit is exceeded, the cache will only replace the data with the LRU algorithm, so the cache size is also helpful for improving performance.

    In addition, we can also improve performance by horizontally expanding CN nodes. The horizontal expansion has two technical characteristics that can improve performance. First, multiple user connection requests can be dispersed to different CN nodes, spreading the load on each CN. Secondly, other CN nodes also have different caches. When the CN node that receives the query request finds that the request data is not in its cache, it will find the CN node containing the request data cache through the metadata and forward the request to it for processing to improve the cache hit rate.

    The expansion of the MatrixOne distributed cluster components can be done through the Operator. For the operation method, please look at the expansion and contraction chapter of the MatrixOne cluster. Please note that the vertical expansion of the CN node needs to be carried out on a single node, while the horizontal expansion of the CN node needs to be carried out on multiple nodes.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/#how-to-operate","title":"How to operate","text":"

    The expansion of MatrixOne distributed cluster components can be done through the Operator. For more information, see Scaling MatrixOne Cluster.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/","title":"Using Cluster by for performance tuning","text":"

    Cluster by is a commonly used performance-tuning technique that can help optimize the execution efficiency of queries. This article explains how to use Cluster by for performance tuning.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/#what-is-cluster-by","title":"What is Cluster by?","text":"

    Cluster by is a command used to optimize the physical arrangement of a table. When Cluster by is used during table creation, tables without primary keys can be physically sorted according to a specified column. The data rows will be rearranged in the same order as the values of that column. This physical sorting helps improve query performance.

    The following are some considerations when using Cluster by:

    Cluster by cannot coexist with a primary key because the primary key already specifies the sorting order. Otherwise, it will result in a syntax error.

    Cluster by can only be specified during table creation and does not support dynamic creation.

    The syntax for using Cluster by is as follows:

    • Single column syntax: create table() cluster by col;
    • Multi-column syntax: create table() cluster by (col1, col2);
    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/#how-to-use-cluster-by-for-performance-tuning","title":"How to use Cluster by for performance tuning?","text":"

    The steps for using Cluster by for performance tuning are as follows:

    1. Determine the column to be sorted.

      First, it is necessary to determine the column to be sorted. Generally, columns that are frequently used for filtering can be selected. For example, if there is an order table, the orders can be sorted by time. The time column is a commonly used sorting column for data with time series characteristics.

    2. Execute the Cluster by command.

      Once the sorting column is determined, the Cluster by command can be executed during table creation to perform the sorting.

      Here is an example:

      create table t1(a int, b int, c varchar(10)) cluster by(a,b,c);\ndesc t1;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type        | Null | Key  | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| a     | INT(32)     | YES  |      | NULL    |       |         |\n| b     | INT(32)     | YES  |      | NULL    |       |         |\n| c     | VARCHAR(10) | YES  |      | NULL    |       |         |\n+-------+-------------+------+------+---------+-------+---------+\n3 rows in set (0.02 sec)\n

      In this example, we first create a table named t1. Then, we use the Cluster by command to physically sort the table according to columns a, b, and c. This way, all data rows will be arranged in the order of values of columns a, b, and c.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/#how-to-make-the-best-use-of-cluster-by-for-performance-tuning","title":"How to Make the Best Use of Cluster by for Performance Tuning?","text":"

    There are two ways to make the best use of Cluster by for performance tuning:

    1. Put the most frequently queried columns at the front.

      In the case of Cluster by with multiple columns, the first column will get the best query acceleration effect because the data distribution of the first column is ultimately ordered. Only when the first column is the same the remaining data will be sorted according to the second column. Therefore, the query acceleration effect of the second column is weaker than that of the first column, and the subsequent columns will decrease. Consequently, it is generally not recommended to specify too many columns in Cluster by; usually, 3-4 columns are sufficient.

    2. Put low cardinality columns at the front.

      Cardinality refers to the number of different values in a column. For example, gender, with only two values, is a typical low cardinality column. For example, ID card numbers are usually not duplicated, which is a high cardinality column. If the tall cardinality column is placed in the first column of Cluster by, the data distribution of the whole table has been thoroughly sorted on the first column, which leads to the subsequent columns not being effective. In this case, it is recommended to use Cluster by for a single column or to build a separate index for the high cardinality column rather than including it in Cluster by.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/#to-consider-when-using-cluster-by","title":"To consider when using Cluster by","text":"
    • Cluster by may take a long time to complete on large tables

    It may take a long time to complete when using Cluster by on a large table. This is because the operation requires reorganizing, reordering, and storing the data in the table. Therefore, when executing the Cluster by command, the table size and hardware configuration need to be considered.

    • Cluster by may affect the performance of insert and update operations

    Using Cluster by to sort data in a table physically may affect the performance of insert and update operations. When specific columns sort the data in a table, insert and update procedures may need to move many rows. Therefore, this impact must be considered when using Cluster by.

    • Cluster by needs to be regularly executed to maintain performance

    As data grows and changes, the physical sorting of data in a table may lose its effectiveness. Therefore, the Cluster by command needs to be regularly executed to ensure that the physical sorting of data remains effective.

    It is important to note that using the Cluster by command needs to be carefully considered. It is recommended first to validate its effects in a testing environment to avoid negative impacts on the data in the table.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/","title":"Performance Tuning with Partitioned Tables","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#what-is-a-partitioned-table","title":"What is a Partitioned Table?","text":"

    A partitioned table organizes data in a database, which involves dividing the table data into multiple partitions. Each partition acts as an independent sub-table.

    In MatrixOne, table data is divided into different storage objects based on the key values of one or more table columns. These key values are referred to as data partitions or ranges.

    A data partition or range is a subset of table rows stored separately from other row sets. The table data is divided into multiple data partitions or ranges based on the specifications provided in the PARTITION BY clause of the CREATE TABLE statement.

    Partitioned tables can bring many benefits, such as faster query speed, optimized data maintenance, and increased availability. Partitioned tables simplify the reading and writing of table data. When SQL is executed on a partitioned table, the system first determines which partition the data belongs to and then reads or writes only that partition, avoiding operations on all the data in the table.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#scenarios-for-partitioned-tables","title":"Scenarios for Partitioned Tables","text":"
    • Improving query performance by scanning only a portion of the table.
    • Improving write performance by inserting, updating, or deleting only a portion of the table data.
    • Batch deleting data within a specific range rather than performing an entire table operation.
    • Fine-tuning and managing data.
    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#what-performance-tuning-can-be-done-with-partitioned-tables","title":"What Performance Tuning can be done with Partitioned Tables?","text":"
    • Query performance tuning: Using partitioned tables can make queries more efficient by targeting specific partitions, thus improving query efficiency. For example, if a table is partitioned by date, specific data within a certain date range can be queried without scanning the entire table.
    • Storage Space Usage Performance Tuning: Partitioned tables can better manage table data and reduce unnecessary storage space usage. For example, if a table is partitioned by time, old partitions can be quickly deleted or archived without affecting data in other partitions.
    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#impact-of-partitioned-tables-on-performance","title":"Impact of Partitioned Tables on Performance","text":"

    Typically, as data increases within a table, performance gradually decreases. However, if the same data is stored in partitioned tables, data access can be optimized by partitioning data into different storage objects based on different ranges.

    Compared to full table access, the optimized access method will prioritize accessing specific partitions, making it possible for requests for data addition, deletion, and modification to be more effectively distributed to different partitions, avoiding the occurrence of IO hotspots and ultimately achieving better performance improvements.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#how-to-use-partitioned-tables-for-tuning","title":"How to Use Partitioned Tables for Tuning","text":"

    When using partitioned tables, the following prerequisites need to be considered:

    • The table has a large amount of data distributed according to some rules, such as by year or month.
    • Improved query performance is desired by scanning only a portion of the table.
    • Frequent data reads, and writes are limited to a specific range, while other fields have a lower frequency of reads and write.
    • Frequent data reads and writes typically have certain fixed filtering conditions.
    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#choosing-the-partition-key","title":"Choosing the Partition Key","text":"

    The partition key is a key factor in physically dividing the table, and choosing the right partition key can significantly improve read and write performance.

    When selecting a partition key, the following factors need to be considered:

    • High cardinality: A partition key with high cardinality will result in better data distribution and scalability. For example, for a table with student gender and age attributes, age has a higher cardinality than gender and is more suitable as the partition key.
    • Uniqueness: The partition key should be as unique as possible to avoid a partition becoming a standalone hotspot. Using a composite key can achieve uniqueness. For example, in a company, if more than half of the employees in different departments are in the same city, partitioning the town as the partition key will result in that department becoming a hotspot. However, using a composite key such as department ID + city ID can significantly reduce the probability of a hot partition.
    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#establishing-partitioning-strategy","title":"Establishing Partitioning Strategy","text":"

    Even if a column with high cardinality and uniqueness is selected as the partitioning key, hotspot partitions may still occur if the partitioning range is inappropriate. Therefore, more sophisticated management is required in the partitioning strategy.

    • Data distribution should be as evenly as possible to avoid extreme distribution. For example, if student age is used as the partitioning key, the company's age distribution needs to be evaluated to prevent overly concentrated age ranges in a partition. For instance, a school may have many students aged 18-22 but relatively few under 18 or over 22, so each age can be partitioned.
    • Add a random number to disperse the partition. Combine the partitioning key with a random number sequence in high-concurrency write scenarios. For example, in an order system, the number of orders for a particular item is very high. A random number sequence can be added when designing the table, with a value range of 1-10, and used as the partitioning key with the item type. Each time an order is written, a number from 1 to 10 is randomly generated, and these orders are randomly written to 10 partitions, reducing the likelihood of hotspot partitions.
    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#matrixone-partitioned-table-types","title":"MatrixOne Partitioned Table Types","text":"

    In MatrixOne, multiple partitioning modes are supported for tables, each corresponding to a different partitioning method.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#range-partition","title":"Range Partition","text":"

    Range partitioning is a partitioning method based on continuous values. The partitioning key can be an integer type, DATE, or DATETIME in date type. Partitions must not overlap, and the partition definition uses the VALUES LESS THAN operator.

    Example

    The following two tables use an integer column and a date column as partitioning keys, respectively:

    CREATE TABLE members (\nfirstname VARCHAR(25) NOT NULL,\nlastname VARCHAR(25) NOT NULL,\nusername VARCHAR(16) NOT NULL,\nemail VARCHAR(35),\njoined DATE NOT NULL\n)\nPARTITION BY RANGE COLUMNS(joined) (\nPARTITION p0 VALUES LESS THAN ('1960-01-01'),\nPARTITION p1 VALUES LESS THAN ('1970-01-01'),\nPARTITION p2 VALUES LESS THAN ('1980-01-01'),\nPARTITION p3 VALUES LESS THAN ('1990-01-01'),\nPARTITION MySQL :: MySQL 8.0 Reference Manual :: 13.1.20 CREATE TABLE Statement\n)\nPARTITION BY RANGE COLUMNS(joined) (\nPARTITION p0 VALUES LESS THAN ('1960-01-01'),\nPARTITION p1 VALUES LESS THAN ('1970-01-01'),\nPARTITION p2 VALUES LESS THAN ('1980-01-01'),\nPARTITION p3 VALUES LESS THAN ('1990-01-01')\n);\n

    Note that if the value of the partition column in the data being inserted or updated does not correspond to a partition, the corresponding insert or update operation will fail. For example, if you insert a row with a \"joined\" date of 2000-01-01 but no corresponding partition, the process will fail because the partition cannot be located. So, when performing insert or update operations, you must ensure that the value of the partition column belongs to the corresponding partition.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#list-partition","title":"List Partition","text":"

    List partitioning requires each partition to be composed of a defined value list, and each partition member in the list cannot have duplicate values. List partitioning can only use an integer type as the partition key.

    Example

    CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY LIST(store_id) (\nPARTITION pNorth VALUES IN (3,5,6,9,17),\nPARTITION pEast VALUES IN (1,2,10,11,19,20),\nPARTITION pWest VALUES IN (4,12,13,14,18),\nPARTITION pCentral VALUES IN (7,8,15,16)\n);\n

    Please note that if the value of the partitioning column in the data being inserted or updated does not correspond to any partition, the insertion will fail.

    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#hash-partition","title":"Hash Partition","text":"

    Hash partitioning is commonly used to distribute data among different partitions evenly. Common types of hash partitioning include HASH function partitioning and KEY function partitioning.

    In HASH function partitioning, the column or expression used for partitioning must be explicitly specified, and its type must be an integer. It is also recommended to explicitly specify the number of partitions, which must be a positive integer.

    Example

    CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH( YEAR(hired) )\nPARTITIONS 4;\n

    Unlike HASH function partitioning, KEY function partitioning supports all types of partition keys except for large object types (TEXT/BLOB), and it is unnecessary to specify the number of partitions. When using KEY function partitioning, the database service provides its hashing method, so explicitly defining the number of partitions is unnecessary. For example, the following statement can be used to create a table with a partition key of s1:

    CREATE TABLE tm1 (\ns1 CHAR(32) PRIMARY KEY\n)\nPARTITION BY KEY(s1);\n

    It should be noted that if the partition key is the table's primary key column, the system will default to using the primary key column as the partition key if it is not explicitly specified. For example:

    CREATE TABLE tm1 (\ns1 CHAR(32) PRIMARY KEY\n)\nPARTITION BY KEY();\n
    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#composite-partition","title":"Composite Partition","text":"

    Composite partitioning is a variant of range partitioning and list partitioning that allows combinations of multiple columns in the partition key. Depending on the type of partition key, composite partitioning can be divided into range and list composite partitioning.

    The types that can be used in composite partitioning include:

    • All integer types, including [UNSIGNED] SMALLINT/INT/BIGINT
    • Data types, including DATE and DATETIME
    • Character types, including CHAR, VARCHAR, BINARY, and VARBINARY.

    Range composite partitioning allows multiple types of columns to be combined, such as:

    CREATE TABLE rcx (\na INT,\nb INT,\nc CHAR(3),\nd date\n)\nPARTITION BY RANGE COLUMNS(a,d,c) (\nPARTITION p0 VALUES LESS THAN (5,'2022-01-01','ggg'),\nPARTITION p1 VALUES LESS THAN (10,'2012-01-01','mmm'),\nPARTITION p2 VALUES LESS THAN (15,'2002-01-01','sss'),\nPARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE)\n);\n

    List composite partitions allow users to define partitions in the same way that multiple columns can be combined, such as:

    CREATE TABLE t1 (\na INT,\nb int,\nc date\n)\nPARTITION BY LIST COLUMNS(a,floor(b),c) (\nPARTITION p0 VALUES IN( (0,0,NULL), (NULL,NULL,NULL) ),\nPARTITION p1 VALUES IN( (0,1,'2000-01-01'), (0,2,'2000-01-01'), (0,3,'2000-01-01'), (1,1,'2000-01-01'), (1,2,'2000-01-01') ),\nPARTITION p2 VALUES IN( (1,0,'2000-01-01'), (2,0,'2000-01-01'), (2,1,'2000-01-01'), (3,0,'2000-01-01'), (3,1,'2000-01-01') ),\nPARTITION p3 VALUES IN( (1,3,'2000-01-01'), (2,2,'2000-01-01'), (2,3,'2000-01-01'), (3,2,'2000-01-01'), (3,3,'2000-01-01') )\n);\n
    "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#constraints","title":"Constraints","text":"
    1. The partition table does not support the following partitions for the time being:

      • Range partition: Only supports integer and date (date/datetime).
      • List partition: Only supports integers.
      • Hash partition: The HASH function only supports integers .
      • Composite partition: Only supports integers, dates, and strings.
    2. The partition table cannot be used for acceleration for now.

    "},{"location":"MatrixOne/Reference/System-tables/","title":"MatrixOne System Database and Tables","text":"

    MatrixOne system database and tables are where MatrixOne stores system information. We can access the system information through them. MatrixOne creates 6 system databases at initialization: mo_catalog, information_schema, system_metrcis, system, mysql, and mo_task. mo_task is under development and have no direct impact on users. The other system databases and table functions are described in this document.

    The system can only modify system databases and tables, and users can only read from them.

    "},{"location":"MatrixOne/Reference/System-tables/#mo_catalog-database","title":"mo_catalog database","text":"

    mo_catalog stores the metadata of MatrixOne objects: databases, tables, columns, system variables, accounts, users, and roles.

    Start with MatrixOne 0.6 has introduced the concept of multi-account, the default sys account and other accounts have slightly different behaviors. The system table mo_account, which serves the multi-tenancy management, is only visible for the sys account; the other accounts don't see this table.

    "},{"location":"MatrixOne/Reference/System-tables/#mo_database-table","title":"mo_database table","text":"column type comments dat_id bigint unsigned Primary key ID datname varchar(100) Database name dat_catalog_name varchar(100) Database catalog name, default as def dat_createsql varchar(100) Database creation SQL statement owner int unsigned Role id creator int unsigned User id created_time timestamp Create time account_id int unsigned Account id dat_type varchar(23) Database type, common library or subscription library"},{"location":"MatrixOne/Reference/System-tables/#mo_tables-table","title":"mo_tables table","text":"column type comments rel_id bigint unsigned Primary key, table ID relname varchar(100) Name of the table, index, view, and so on. reldatabase varchar(100) The database that contains this relation. reference mo_database.datname reldatabase_id bigint unsigned The database id that contains this relation. reference mo_database.datid relpersistence varchar(100) p = permanent table, t = temporary table relkind varchar(100) r = ordinary table, e = external table, i = index, S = sequence, v = view, m = materialized view rel_comment varchar(100) rel_createsql varchar(100) Table creation SQL statement created_time timestamp Create time creator int unsigned Creator ID owner int unsigned Creator's default role id account_id int unsigned Account id partitioned blob Partition by statement partition_info blob the information of partition viewdef blob View definition statement constraint varchar(5000) Table related constraints catalog_version INT UNSIGNED(0) Version number of the system table"},{"location":"MatrixOne/Reference/System-tables/#mo_columns-table","title":"mo_columns table","text":"column type comments att_uniq_name varchar(256) Primary Key. Hidden, composite primary key, format is like \"${att_relname_id}-${attname}\" account_id int unsigned accountID att_database_id bigint unsigned databaseID att_database varchar(256) database Name att_relname_id bigint unsigned table id att_relname varchar(256) The table this column belongs to.(references mo_tables.relname) attname varchar(256) The column name atttyp varchar(256) The data type of this column (zero for a dropped column). attnum int The number of the column. Ordinary columns are numbered from 1 up. att_length int bytes count for the type. attnotnull tinyint(1) This represents a not-null constraint. atthasdef tinyint(1) This column has a default expression or generation expression. att_default varchar(1024) default expression attisdropped tinyint(1) This column has been dropped and is no longer valid. A dropped column is still physically present in the table, but is ignored by the parser and so cannot be accessed via SQL. att_constraint_type char(1) p = primary key constraint, n=no constraint att_is_unsigned tinyint(1) unsigned or not att_is_auto_increment tinyint(1) auto increment or not att_comment varchar(1024) comment att_is_hidden tinyint(1) hidden or not attr_has_update tinyint(1) This columns has update expression attr_update varchar(1024) update expression attr_is_clusterby tinyint(1) Whether this column is used as the cluster by keyword to create the table"},{"location":"MatrixOne/Reference/System-tables/#mo_table_partitions-table","title":"mo_table_partitions table","text":"column type comments table_id BIGINT UNSIGNED(64) The ID of the current partitioned table. database_id BIGINT UNSIGNED(64) The ID of the database to which the current partitioned table belongs. number SMALLINT UNSIGNED(16) The current partition number. All partitions are indexed in the order they are defined, with 1 assigned to the first partition. name VARCHAR(64) The name of the partition. partition_type VARCHAR(50) Stores the partition type information for the table. For partitioned tables, the values can be \"KEY\", \"LINEAR_KEY\", \"HASH\", \"LINEAR_KEY_51\", \"RANGE\", \"RANGE_COLUMNS\", \"LIST\", \"LIST_COLUMNS\". For non-partitioned tables, the value is an empty string. Note: MatrixOne does not currently support RANGE and LIST partitioning. partition_expression VARCHAR(2048) The expression for the partitioning function used in the CREATE TABLE or ALTER TABLE statement that created the partitioned table's partitioning scheme. description_utf8 TEXT(0) This column is used for RANGE and LIST partitions. For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be an integer or MAXVALUE. For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a comma-separated list of integer values. For partitions with partition_type other than RANGE or LIST, this column is always NULL. Note: MatrixOne does not currently support RANGE and LIST partitioning, so this column is NULL. comment VARCHAR(2048) The text of the comment, if the partition has one. Otherwise, this value is empty. options TEXT(0) Partition options information, currently set to NULL. partition_table_name VARCHAR(1024) The name of the subtable corresponding to the current partition."},{"location":"MatrixOne/Reference/System-tables/#mo_account-table-only-visible-for-sys-account","title":"mo_account table (Only visible for sys account)","text":"column type comments account_id int unsigned account id, primary key account_name varchar(100) account name status varchar(100) open/suspend created_time timestamp create time comments varchar(256) comment suspended_time TIMESTAMP Time of the account's status is changed version bigint unsigned the version status of the current account"},{"location":"MatrixOne/Reference/System-tables/#mo_role-table","title":"mo_role table","text":"column type comments role_id int unsigned role id, primary key role_name varchar(100) role name creator int unsigned user_id owner int unsigned MOADMIN/ACCOUNTADMIN ownerid created_time timestamp create time comments text comment"},{"location":"MatrixOne/Reference/System-tables/#mo_user-table","title":"mo_user table","text":"column type comments user_id int user id, primary key user_host varchar(100) user host address user_name varchar(100) user name authentication_string varchar(100) authentication string encrypted with password status varchar(8) open,locked,expired created_time timestamp user created time expired_time timestamp user expired time login_type varchar(16) ssl/password/other creator int the creator id who created this user owner int the admin id for this user default_role int the default role id for this user"},{"location":"MatrixOne/Reference/System-tables/#mo_user_grant-table","title":"mo_user_grant table","text":"column type comments role_id int unsigned ID of the authorized role, associated primary key user_id int unsigned Obtain the user ID of the authorized role and associate the primary key granted_time timestamp granted time with_grant_option bool Whether to allow an authorized user to license to another user or role"},{"location":"MatrixOne/Reference/System-tables/#mo_role_grant-table","title":"mo_role_grant table","text":"column type comments granted_id int the role id being granted, associated primary key grantee_id int the role id to grant others, associated primary key operation_role_id int operation role id operation_user_id int operation user id granted_time timestamp granted time with_grant_option bool Whether to allow an authorized role to be authorized to another user or role"},{"location":"MatrixOne/Reference/System-tables/#mo_role_privs-table","title":"mo_role_privs table","text":"column type comments role_id int role id, associated primary key role_name varchar(100) role name: accountadmin/public obj_type varchar(16) object type: account/database/table, associated primary key obj_id bigint unsigned object id, associated primary key privilege_id int privilege id, associated primary key privilege_name varchar(100) privilege name: the list of privileges privilege_level varchar(100) level of privileges, associated primary key operation_user_id int unsigned operation user id granted_time timestamp granted time with_grant_option bool If permission granting is permitted"},{"location":"MatrixOne/Reference/System-tables/#mo_stages-table","title":"mo_stages table","text":"column type comments stage_id INT UNSIGNED(32) data stage ID stage_name VARCHAR(64) data stage name url TEXT(0) Path to object storage (without authentication), path to file system stage_credentials TEXT(0) Authentication information, encrypted and saved stage_status VARCHAR(64) ENABLED/DISABLED Default: DISABLED created_time TIMESTAMP(0) creation time comment TEXT(0) comment"},{"location":"MatrixOne/Reference/System-tables/#mo_user_defined_function-table","title":"mo_user_defined_function table","text":"column type comments function_id INT(32) ID of the function, primary key name VARCHAR(100) the name of the function owner INT UNSIGNED(32) ID of the role who created the function args TEXT(0) Argument list for the function rettype VARCHAR(20) return type of the function body TEXT(0) function body language VARCHAR(20) language used by the function db VARCHAR(100) database where the function is located definer VARCHAR(50) name of the user who defined the function modified_time TIMESTAMP(0) time when the function was last modified created_time TIMESTAMP(0) creation time of the function type VARCHAR(10) type of function, default FUNCTION security_type VARCHAR(10) security processing method, uniform value DEFINER comment VARCHAR(5000) Create a comment for the function character_set_client VARCHAR(64) Client character set: utf8mb4 collation_connection VARCHAR(64) Connection sort: utf8mb4_0900_ai_ci database_collation VARCHAR(64) Database connection collation: utf8mb4_0900_ai_ci"},{"location":"MatrixOne/Reference/System-tables/#mo_mysql_compatbility_mode-table","title":"mo_mysql_compatbility_mode table","text":"column type comments configuration_id INT(32) Configuration item id, an auto-increment column, used as a primary key to distinguish different configurations account_name VARCHAR(300) The name of the tenant where the configuration is located dat_name VARCHAR(5000) The name of the database where the configuration is located configuration JSON(0) Configuration content, saved in JSON format"},{"location":"MatrixOne/Reference/System-tables/#mo_pubs-table","title":"mo_pubs table","text":"column type comments pub_name VARCHAR(64) publication name database_name VARCHAR(5000) The name of the published data database_id BIGINT UNSIGNED(64) ID of the publishing database, corresponding to dat_id in the mo_database table all_table BOOL(0) Whether the publishing library contains all tables in the database corresponding to database_id all_account BOOL(0) Whether all accounts can subscribe to the library table_list TEXT(0) When it is not all table, publish the list of tables contained in the library, and the table name corresponds to the table under the database corresponding to database_id account_list TEXT(0) Account list that is allowed to subscribe to the publishing library when it is not all accounts created_time TIMESTAMP(0) Time when the release repository was created owner INT UNSIGNED(32) The role ID corresponding to the creation of the release library creator INT UNSIGNED(32) The ID of the user who created the release library comment TEXT(0) Remarks for creating a release library"},{"location":"MatrixOne/Reference/System-tables/#mo_indexes-table","title":"mo_indexes table","text":"column type comments id BIGINT UNSIGNED(64) index ID table_id BIGINT UNSIGNED(64) ID of the table where the index resides database_id BIGINT UNSIGNED(64) ID of the database where the index resides name VARCHAR(64) name of the index type VARCHAR(11) The type of index, including primary key index (PRIMARY), unique index (UNIQUE), secondary index (MULTIPLE) is_visible TINYINT(8) Whether the index is visible, 1 means visible, 0 means invisible (currently all MatrixOne indexes are visible indexes) hidden TINYINT(8) Whether the index is hidden, 1 is a hidden index, 0 is a non-hidden index comment VARCHAR(2048) Comment information for the index column_name VARCHAR(256) The column name of the constituent columns of the index ordinal_position INT UNSIGNED(32) Column ordinal in index, starting from 1 options TEXT(0) options option information for index index_table_name VARCHAR(5000) The table name of the index table corresponding to the index, currently only the unique index contains the index table"},{"location":"MatrixOne/Reference/System-tables/#system_metrics-database","title":"system_metrics database","text":"

    system_metrics collect the status and statistics of SQL statements, CPU & memory resource usage.

    system_metrics tables have more or less same column types, fields in these tables are described as follows:

    • collecttime:Collection time
    • value: the value of the collecting metric

    • node: the MatrixOne node uuid

    • role: the MatrixOne node role, can be CN, TN or LOG.
    • account: default as \"sys\", the account who fires the SQL request.
    • type:SQL type, can be select, insert, update, delete, other types.
    "},{"location":"MatrixOne/Reference/System-tables/#metric-table","title":"metric table","text":"Column Type Comment metric_name VARCHAR(128) metric name, like: sql_statement_total, server_connections, process_cpu_percent, sys_memory_used, .. collecttime DATETIME metric data collect time value DOUBLE metric value node VARCHAR(36) MatrixOne node uuid role VARCHAR(32) MatrixOne node role account VARCHAR(128) account name, default \"sys\" type VARCHAR(32) SQL type: like insert, select, update ...

    The other tables are all views of the metric table:

    • process_cpu_percent table: Process CPU busy percentage.
    • process_open_fs table: Number of open file descriptors.
    • process_resident_memory_bytes table: Resident memory size in bytes.
    • server_connection table: Server connection numbers.
    • sql_statement_errors table: Counter of sql statements executed with errors.
    • sql_statement_total table: Counter of executed sql statement.
    • sql_transaction_errors table: Counter of transactional statements executed with errors.
    • sql_statement_hotspot table: records the most extended SQL query executed by each tenant within each minute. Only those SQL queries whose execution time does not exceed a certain aggregation threshold will be included in the statistics.
    • sql_transaction_total table: Counter of transactional sql statement.
    • sys_cpu_combined_percent table: System CPU busy percentage, average among all logical cores.
    • sys_cpu_seconds_total table: System CPU time spent in seconds, normalized by number of cores
    • sys_disk_read_bytes table: System disk read in bytes.
    • sys_disk_write_bytes table: System disk write in bytes.
    • sys_memory_available table: System memory available in bytes.
    • sys_memory_used table: System memory used in bytes.
    • sys_net_recv_bytes table: System net received in bytes.
    • sys_net_sent_bytes table: System net sent in bytes.
    "},{"location":"MatrixOne/Reference/System-tables/#system-database","title":"system database","text":"

    System database stores MatrixOne historical SQL statements, system logs, error information.

    "},{"location":"MatrixOne/Reference/System-tables/#statement_info-table","title":"statement_info table","text":"

    It records user and system SQL statement with detailed information.

    Column Type Comments statement_id VARCHAR(36) statement unique id transaction_id VARCHAR(36) Transaction unique id session_id VARCHAR(36) session unique id account VARCHAR(1024) account name user VARCHAR(1024) user name host VARCHAR(1024) user client ip database VARCHAR(1024) what database current session stay in statement TEXT sql statement statement_tag TEXT note tag in statement(Reserved) statement_fingerprint TEXT note tag in statement(Reserved) node_uuid VARCHAR(36) node uuid, which node gen this data node_type VARCHAR(64) node type in MO, val in [TN, CN, LOG] request_at DATETIME request accept datetime response_at DATETIME response send datetime duration BIGINT exec time, unit: ns status VARCHAR(32) sql statement running status, enum: Running, Success, Failed err_code VARCHAR(1024) error code error TEXT error message exec_plan JSON statement execution plan rows_read BIGINT rows read total bytes_scan BIGINT bytes scan total stats JSON global stats info in exec_plan statement_type VARCHAR(1024) statement type, val in [Insert, Delete, Update, Drop Table, Drop User, ...] query_type VARCHAR(1024) query type, val in [DQL, DDL, DML, DCL, TCL] role_id BIGINT role id sql_source_type TEXT Type of SQL source internally generated by MatrixOne aggr_count BIGINT(64) the number of statements aggregated result_count BIGINT(64) the number of rows of sql execution results"},{"location":"MatrixOne/Reference/System-tables/#rawlog-table","title":"rawlog table","text":"

    It records very detailed system logs.

    Column Type Comments raw_item VARCHAR(1024) raw log item node_uuid VARCHAR(36) node uuid, which node gen this data. node_type VARCHAR(64) node type in MO, val in [TN, CN, LOG] span_id VARCHAR(16) span unique id statement_id VARCHAR(36) statement unique id logger_name VARCHAR(1024) logger name timestamp DATETIME timestamp of action level VARCHAR(1024) log level, enum: debug, info, warn, error, panic, fatal caller VARCHAR(1024) where it log, like: package/file.go:123 message TEXT log message extra JSON log dynamic fields err_code VARCHAR(1024) error log error TEXT error message stack VARCHAR(4096) span_name VARCHAR(1024) span name, for example: step name of execution plan, function name in code, ... parent_span_id VARCHAR(16) parent span unique id start_time DATETIME end_time DATETIME duration BIGINT exec time, unit: ns resource JSON static resource information

    The other 3 tables(log_info, span_info and error_info) are views of statement_info and rawlog table.

    "},{"location":"MatrixOne/Reference/System-tables/#information_schema-database","title":"information_schema database","text":"

    Information Schema provides an ANSI-standard way of viewing system metadata. MatrixOne also provides a number of custom information_schema tables, in addition to the tables included for MySQL compatibility.

    Many INFORMATION_SCHEMA tables have a corresponding SHOW command. The benefit of querying INFORMATION_SCHEMA is that it is possible to join between tables.

    "},{"location":"MatrixOne/Reference/System-tables/#tables-for-mysql-compatibility","title":"Tables for MySQL compatibility","text":"Table Name Description KEY_COLUMN_USAGE Describes the key constraints of the columns, such as the primary key constraint. COLUMNS Provides a list of columns for all tables. PROFILING Provides some profiling information during SQL statement execution. PROCESSLIST Provides similar information to the command SHOW PROCESSLIST. USER_PRIVILEGES Summarizes the privileges associated with the current user. SCHEMATA Provides similar information to SHOW DATABASES. CHARACTER_SETS Provides a list of character sets the server supports. TRIGGERS Provides similar information to SHOW TRIGGERS. TABLES Provides a list of tables that the current user has visibility of. Similar to SHOW TABLES. PARTITIONS Provides information about table partitions. VIEWS Provides information about views in the database. ENGINES Provides a list of supported storage engines. ROUTINES Provides some information about stored procedures. PARAMETERS Provides information about stored procedures' parameters and return values \u200b\u200b. KEYWORDS Provide information about keywords in the database; see Keywords for details."},{"location":"MatrixOne/Reference/System-tables/#character_sets-table","title":"CHARACTER_SETS table","text":"

    The description of columns in the CHARACTER_SETS table is as follows:

    • CHARACTER_SET_NAME: The name of the character set.
    • DEFAULT_COLLATE_NAME The default collation name of the character set.
    • DESCRIPTION The description of the character set.
    • MAXLEN The maximum length required to store a character in this character set.
    "},{"location":"MatrixOne/Reference/System-tables/#columns-table","title":"COLUMNS table","text":"

    The description of columns in the COLUMNS table is as follows:

    • TABLE_CATALOG: The name of the catalog to which the table with the column belongs. The value is always def.
    • TABLE_SCHEMA: The name of the schema in which the table with the column is located.
    • TABLE_NAME: The name of the table with the column.
    • COLUMN_NAME: The name of the column.
    • ORDINAL_POSITION: The position of the column in the table.
    • COLUMN_DEFAULT: The default value of the column. If the explicit default value is NULL, or if the column definition does not include the default clause, this value is NULL.
    • IS_NULLABLE: Whether the column is nullable. If the column can store null values, this value is YES; otherwise, it is NO.
    • DATA_TYPE: The type of data in the column.
    • CHARACTER_MAXIMUM_LENGTH: For string columns, the maximum length in characters.
    • CHARACTER_OCTET_LENGTH: For string columns, the maximum length in bytes.
    • NUMERIC_PRECISION: The numeric precision of a number-type column.
    • NUMERIC_SCALE: The numeric scale of a number-type column.
    • DATETIME_PRECISION: For time-type columns, the fractional seconds precision.
    • CHARACTER_SET_NAME: The name of the character set of a string column.
    • COLLATION_NAME: The name of the collation of a string column.
    • COLUMN_TYPE: The column type.
    • COLUMN_KEY: Whether this column is indexed. This field might have the following values:
      • Empty: This column is not indexed, or this column is indexed and is the second column in a multi-column non-unique index.
      • PRI: This column is the primary key or one of multiple primary keys.
      • UNI: This column is the first column of the unique index.
      • MUL: The column is the first column of a non-unique index, in which a given value is allowed to occur for multiple times.
    • EXTRA: Any additional information of the given column.
    • PRIVILEGES: The privilege that the current user has on this column.
    • COLUMN_COMMENT: Comments contained in the column definition.
    • GENERATION_EXPRESSION: For generated columns, this value displays the expression used to calculate the column value. For non-generated columns, the value is empty.
    • SRS_ID: This value applies to spatial columns. It contains the column SRID value that indicates the spatial reference system for values stored in the column.
    "},{"location":"MatrixOne/Reference/System-tables/#engines-table","title":"ENGINES table","text":"

    The description of columns in the ENGINES table is as follows:

    • ENGINES: The name of the storage engine.
    • SUPPORT: The level of support that the server has on the storage engine.
    • COMMENT: The brief comment on the storage engine.
    • TRANSACTIONS: Whether the storage engine supports transactions.
    • XA: Whether the storage engine supports XA transactions.
    • SAVEPOINTS: Whether the storage engine supports savepoints.
    "},{"location":"MatrixOne/Reference/System-tables/#partitions-table","title":"PARTITIONS table","text":"

    The description of columns in the PARTITIONS table is as follows:

    • TABLE_CATALOG: The name of the catalog to which the table belongs. This value is always def.
    • TABLE_SCHEMA: The name of the schema (database) to which the table belongs.
    • TABLE_NAME: The name of the table containing the partition.
    • PARTITION_NAME: The name of the partition.
    • SUBPARTITION_NAME: If the PARTITIONS table row represents a subpartition, the name of subpartition; otherwise NULL.
    • PARTITION_ORDINAL_POSITION: All partitions are indexed in the same order as they are defined, with 1 being the number assigned to the first partition. The indexing can change as partitions are added, dropped, and reorganized; the number shown is this column reflects the current order, taking into account any indexing changes.
    • SUBPARTITION_ORDINAL_POSITION: Subpartitions within a given partition are also indexed and reindexed in the same manner as partitions are indexed within a table.
    • PARTITION_METHOD: One of the values RANGE, LIST, HASH, LINEAR HASH, KEY, or LINEAR KEY. Note: MatrixOne does not currently support RANGE and LIST partitioning.
    • SUBPARTITION_METHOD: One of the values HASH, LINEAR HASH, KEY, or LINEAR KEY.
    • PARTITION_EXPRESSION: The expression for the partitioning function used in the CREATE TABLE or ALTER TABLE statement that created the table's current partitioning scheme.
    • SUBPARTITION_EXPRESSION: This works in the same fashion for the subpartitioning expression that defines the subpartitioning for a table as PARTITION_EXPRESSION does for the partitioning expression used to define a table's partitioning. If the table has no subpartitions, this column is NULL.
    • PARTITION_DESCRIPTION: This column is used for RANGE and LIST partitions. For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be either an integer or MAXVALUE. For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a list of comma-separated integer values. For partitions whose PARTITION_METHOD is other than RANGE or LIST, this column is always NULL. Note: MatrixOne does not currently support RANGE and LIST partitioning.
    • TABLE_ROWS: The number of table rows in the partition.
    • AVG_ROW_LENGTH: The average length of the rows stored in this partition or subpartition, in bytes. This is the same as DATA_LENGTH divided by TABLE_ROWS.
    • DATA_LENGTH: The total length of all rows stored in this partition or subpartition, in bytes; that is, the total number of bytes stored in the partition or subpartition.
    • INDEX_LENGTH: The length of the index file for this partition or subpartition, in bytes.
    • DATA_FREE: The number of bytes allocated to the partition or subpartition but not used.
    • CREATE_TIME: The time that the partition or subpartition was created.
    • UPDATE_TIME: The time that the partition or subpartition was last modified.
    • CHECK_TIME: The last time that the table to which this partition or subpartition belongs was checked.
    • CHECKSUM: The checksum value, if any; otherwise NULL.
    • PARTITION_COMMENT: The text of the comment, if the partition has one. If not, this value is empty. The maximum length for a partition comment is defined as 1024 characters, and the display width of the PARTITION_COMMENT column is also 1024, characters to match this limit.
    • NODEGROUP: This is the nodegroup to which the partition belongs.
    • TABLESPACE_NAME: The name of the tablespace to which the partition belongs. The value is always DEFAULT.
    "},{"location":"MatrixOne/Reference/System-tables/#processlist-table","title":"PROCESSLIST table","text":"

    Fields in the PROCESSLIST table are described as follows:

    • ID: The ID of the user connection.
    • USER: The name of the user who is executing PROCESS.
    • HOST: The address that the user is connecting to.
    • DB: The name of the currently connected default database.
    • COMMAND: The command type that PROCESS is executing.
    • TIME: The current execution duration of PROCESS, in seconds.
    • STATE: The current connection state.
    • INFO: The requested statement that is being processed.
    "},{"location":"MatrixOne/Reference/System-tables/#schemata-table","title":"SCHEMATA table","text":"

    The SCHEMATA table provides information about databases. The table data is equivalent to the result of the SHOW DATABASES statement. Fields in the SCHEMATA table are described as follows:

    • CATALOG_NAME: The catalog to which the database belongs.
    • SCHEMA_NAME: The database name.
    • DEFAULT_CHARACTER_SET_NAME: The default character set of the database.
    • DEFAULT_COLLATION_NAME: The default collation of the database.
    • SQL_PATH: The value of this item is always NULL.
    • DEFAULT_TABLE_ENCRYPTION: defines the default encryption setting for databases and general tablespaces.
    "},{"location":"MatrixOne/Reference/System-tables/#tables-table","title":"TABLES table","text":"

    The description of columns in the TABLES table is as follows:

    • TABLE_CATALOG: The name of the catalog which the table belongs to. The value is always def.
    • TABLE_SCHEMA: The name of the schema which the table belongs to.
    • TABLE_NAME: The name of the table.
    • TABLE_TYPE: The type of the table. The base table type is BASE TABLE, the view table type is VIEW, and the INFORMATION_SCHEMA table type is SYSTEM VIEW.
    • ENGINE: The type of the storage engine.
    • VERSION: Version. The value is 10 by default.
    • ROW_FORMAT: The row format. The value is Compact, Fixed, Dynamic, Compressed, Redundant.
    • TABLE_ROWS: The number of rows in the table in statistics. For INFORMATION_SCHEMA tables, TABLE_ROWS is NULL.
    • AVG_ROW_LENGTH: The average row length of the table. AVG_ROW_LENGTH = DATA_LENGTH / TABLE_ROWS.
    • DATA_LENGTH: Data length. DATA_LENGTH = TABLE_ROWS * the sum of storage lengths of the columns in the tuple.
    • MAX_DATA_LENGTH: The maximum data length. The value is currently 0, which means the data length has no upper limit.
    • INDEX_LENGTH: The index length. INDEX_LENGTH = TABLE_ROWS * the sum of lengths of the columns in the index tuple.
    • DATA_FREE: Data fragment. The value is currently 0.
    • AUTO_INCREMENT: The current step of the auto- increment primary key.
    • CREATE_TIME: The time at which the table is created.
    • UPDATE_TIME: The time at which the table is updated.
    • CHECK_TIME: The time at which the table is checked.
    • TABLE_COLLATION: The collation of strings in the table.
    • CHECKSUM: Checksum.
    • CREATE_OPTIONS: Creates options.
    • TABLE_COMMENT: The comments and notes of the table.
    "},{"location":"MatrixOne/Reference/System-tables/#user_privileges-table","title":"USER_PRIVILEGES table","text":"

    The USER_PRIVILEGES table provides information about global privileges.

    Fields in the USER_PRIVILEGES table are described as follows:

    • GRANTEE: The name of the granted user, which is in the format of 'user_name'@'host_name'.
    • TABLE_CATALOG: The name of the catalog to which the table belongs. This value is always def.
    • PRIVILEGE_TYPE: The privilege type to be granted. Only one privilege type is shown in each row.
    • IS_GRANTABLE: If you have the GRANT OPTION privilege, the value is YES; otherwise, the value is NO.
    "},{"location":"MatrixOne/Reference/System-tables/#view-table","title":"VIEW table","text":"
    • TABLE_CATALOG: The name of the catalog the view belongs to. The value is def.
    • TABLE_SCHEMA: The name of the database to which the view belongs.
    • TABLE_NAME: The name of the view.
    • VIEW_DEFINITION: The SELECT statement that provides the view definition. It contains most of what you see in the \"Create Table\" column generated by SHOW Create VIEW.
    • CHECK_OPTION: The value of the CHECK_OPTION property. Values are NONE, CASCADE, or LOCAL.
    • IS_UPDATABLE: Set a flag called the view updatable flag when CREATE VIEW; if UPDATE and DELETE (and similar operations) are legal for the view, the flag is set to YES(true). Otherwise, the flag is set to NO(false).
    • DEFINER: The account of the user who created the view, in the format username@hostname.
    • SECURITY_TYPE: View the SQL SECURITY attribute. Values \u200b\u200bare DEFINER or INVOKER.
    • CHARACTER_SET_CLIENT: The session value of the character_set_client system variable when the view was created.
    • COLLATION_CONNECTION: The session value of the collation_connection system variable when the view was created.
    "},{"location":"MatrixOne/Reference/System-tables/#statistics-table","title":"STATISTICS Table","text":"

    Obtain detailed information about database table indexes and statistics. For example, you can check whether an index is unique, understand the order of columns within an index, and estimate the number of unique values in an index.

    • TABLE_CATALOG: The catalog name of the table (always 'def').
    • TABLE_SCHEMA: The name of the database to which the table belongs.
    • TABLE_NAME: The name of the table.
    • NON_UNIQUE: Indicates whether the index allows duplicate values. If 0, the index is unique.
    • INDEX_SCHEMA: The database name to which the index belongs.
    • INDEX_NAME: The name of the index.
    • SEQ_IN_INDEX: The position of the column within the index.
    • COLUMN_NAME: The name of the column.
    • COLLATION: The collation of the column.
    • CARDINALITY: An estimated count of unique values in the index.
    • SUB_PART: The length of the index part. For the entire column, this value is NULL.
    • PACKED: Indicates whether compressed storage is used.
    • NULLABLE: Indicates whether the column allows NULL values.
    • INDEX_TYPE: The index type (e.g., BTREE, HASH, etc.).
    • COMMENT: Comment information about the index.
    "},{"location":"MatrixOne/Reference/System-tables/#mysql-database","title":"mysql database","text":""},{"location":"MatrixOne/Reference/System-tables/#grant-system-tables","title":"Grant system tables","text":"

    These system tables contain grant information about user accounts and their privileges:

    • user: user accounts, global privileges, and other non-privilege columns.
    • db: database-level privileges.
    • tables_priv: table-level privileges.
    • columns_priv: column-level privileges.
    • procs_priv: stored procedure and stored function privileges.
    "},{"location":"MatrixOne/Reference/access-control-type/","title":"Privilege Control Types","text":"

    The privilege control of a MatrixOne is classified into System Permission and Object Permission. You can refer to the permissions granted to roles.

    "},{"location":"MatrixOne/Reference/access-control-type/#system-permission","title":"System Permission","text":"

    System permissions are the permissions of the initial system account. The system account is the cluster system administrator root, also called the cluster administrator. The system root can create and delete other accounts, and manage accounts. A system root cannot manage other resources of other accounts.

    Permissions Description CREATE ACCOUNT Create an account. It belongs only to the SYS account. DROP ACCOUNT Delete an account. It belongs only to the SYS account. ALTER ACCOUNT Manage accounts. It belongs only to the SYS account."},{"location":"MatrixOne/Reference/access-control-type/#object-permission","title":"Object Permission","text":"

    Object permission can be classified into Account Permission, User Permission, Role Permission, Database Permission, and Table Permission.

    "},{"location":"MatrixOne/Reference/access-control-type/#account-permission","title":"Account Permission","text":"

    Objects with Account Permission can have the following permissions:

    Permissions Description CREATE USER Create a user DROP USER Delete a user ALTER USER Modify users CREATE ROLE Create a role DROP ROLE Delete a role CREATE DATABASE Create a database DROP DATABASE Delete a database SHOW DATABASES View all databases in the current account CONNECT Use use [database | role], execute SELECT which does not involve concrete object MANAGE GRANTS Permission management. You can authorize roles and inherit permission from roles ALL [PRIVILEGES] All permissions of the Account OWNERSHIP All permissions of the Account. The account can be set using WITH GRANT OPTION SHOW GRANT View the permission list of a role or user under the current account"},{"location":"MatrixOne/Reference/access-control-type/#user-permission","title":"User Permission","text":"

    Objects with User Permission can have the following permissions:

    Permissions Description Ownership You can manage all user permission, including modifying user information, passwords, and deleting users, and transfer these permissions to other roles."},{"location":"MatrixOne/Reference/access-control-type/#role-permission","title":"Role Permission","text":"

    Objects with Role Permission can have the following permissions:

    Permissions Description Ownership You can manage all rights of a role, including modifying the name, description, and deletion of a role, and transfer these rights to other roles."},{"location":"MatrixOne/Reference/access-control-type/#database-permission","title":"Database Permission","text":"

    Objects with Database Permission can have the following permissions:

    Permissions Description SHOW TABLES View all tables in the current database CREATE TABLE Create a table DROP TABLE Delete a table CREATE VIEW Create a view,A view created without the corresponding table permission cannot be queried DROP VIEW Delete a view ALTER TABLE Modify a table ALTER VIEW Modify a view. A view created without the corresponding table permission cannot be queried. ALL [PRIVILEGES] All permission of database OWNERSHIP All permission of database. The database can be set using WITH GRANT OPTION"},{"location":"MatrixOne/Reference/access-control-type/#table-permission","title":"Table Permission","text":"

    Objects with Table Permission can have the following permissions:

    Permissions Description SELECT Execute the SELECT statement INSERT Execute the INSERT statement UPDATE Execute the UPDATE statement TRUNCATE Execute the TRUNCATE TABLE statement DELETE Execute the DELETE statement REFERENCE Allows a table to be referenced as a unique/primary key table for external constraints. View the structure of the table with the DESCRIBE or SHOW command INDEX Create or drop INDEX ALL Specifies all permissions for the table OWNERSHIP Specifies all permissions for the table, append WITH GRANT OPTION"},{"location":"MatrixOne/Reference/access-control-type/#table-routine-level-permission","title":"Table Routine Level Permission","text":"

    Objects with Table Routine Level Permission can have the following permissions:

    Permissions Description EXECUTE Permission to execute a function or stored procedure"},{"location":"MatrixOne/Reference/access-control-type/#publish-and-subscribe-permission","title":"Publish and subscribe permission","text":"

    In MatrixOne, publish-subscribe is data-sharing access to the specified database.

    Note: Currently, only moadmin and accountadmin roles are supported in MatrixOne to perform publish and subscribe operations.

    • publisher

    The publisher is the party that publishes the data that needs to be shared and synchronized.

    Permissions Description CREATE PUBLICATION Create Publication ALTER PUBLICATION Modify Publication DROP PUBLICATION Delete a publication SHOW PUBLICATION View Publication SHOW CREATE PUBLICATION View create publication statement
    • Subscriber

    The subscriber is the party that obtains the shared and synchronized data.

    Permissions Description CREATE DATABASE db_name FROM account_name PUBLICATION CREATE SUBSCRIPTION SHOW SUBSCRIPTIONS View Subscriptions"},{"location":"MatrixOne/Reference/Data-Types/blob-text-type/","title":"The BLOB and TEXT Type","text":"

    BLOB

    • A BLOB is a binary large object that can hold a variable amount of data.

    • BLOB values are treated as binary strings (byte strings). They have the binary character set and collation, and comparison and sorting are based on the numeric values of the bytes in column values.

    TEXT

    • TEXT values are treated as nonbinary strings (character strings). They have a character set other than binary, and values are sorted and compared based on the collation of the character set.

    About BLOB and TEXT

    If you assign a value to a BLOB or TEXT type column that exceeds the maximum length for that column, the portion that exceeds the length will be truncated, and a warning will be generated. If a non-whitespace character is truncated, an error (rather than a warning) occurs, and insertion of the value is prohibited. For TEXT, always generate a warning when trimming excess trailing spaces in values \u200b\u200binserted into TEXT columns.

    "},{"location":"MatrixOne/Reference/Data-Types/data-type-conversion/","title":"Data Type Conversion","text":""},{"location":"MatrixOne/Reference/Data-Types/data-type-conversion/#data-type-conversion","title":"Data Type Conversion","text":"

    MatrixOne supports the conversion between different data types, the supported and unsupported conversions are listed in the following table.

    • Castable: explicit conversion with cast function.
    • Coercible: implicit conversion without cast function.
    Source Data Type Target Data Type Castable Coercible BOOLEAN INTEGER \u274c \u274c DECIMAL \u274c \u274c VARCHAR \u2714 \u2714 DATE TIMESTAMP \u2714 \u2714 DATETIME \u2714 \u2714 VARCHAR \u2714 \u2714 DATETIME TIMESTAMP \u2714 \u2714 DATE \u2714 \u2714 VARCHAR \u2714 \u2714 FLOAT(Floating-point number) INTEGER \u274c \u274c DECIMAL \u2714 \u2714 VARCHAR \u2714 \u2714 INTEGER BOOLEAN \u274c \u274c FLOAT \u2714 \u2714 TIMESTAMP \u2714 \u2714 VARCHAR \u2714 \u2714 DECIMAL \u2714 \u2714 TIMESTAMP DATE \u2714 \u2714 DATETIME \u2714 \u2714 VARCHAR \u2714 \u2714 VARCHAR BOOLEAN \u2714 \u2714 DATE \u2714 \u2714 FLOAT \u2714 \u2714 INTEGER \u2714 \u2714 DECIMAL \u2714 \u2714 TIMESTAMP \u2714 \u2714 DATETIME \u2714 \u2714"},{"location":"MatrixOne/Reference/Data-Types/data-types/","title":"Data Types Overview","text":"

    MatrixOne Data types conforms with MySQL Data types definition.

    Reference: https://dev.mysql.com/doc/refman/8.0/en/data-types.html

    "},{"location":"MatrixOne/Reference/Data-Types/data-types/#integer-numbers","title":"Integer Numbers","text":"Data Type Size Min Value Max Value TINYINT 1 byte -128 127 SMALLINT 2 bytes -32768 32767 INT 4 bytes -2147483648 2147483647 BIGINT 8 bytes -9223372036854775808 9223372036854775807 TINYINT UNSIGNED 1 byte 0 255 SMALLINT UNSIGNED 2 bytes 0 65535 INT UNSIGNED 4 bytes 0 4294967295 BIGINT UNSIGNED 8 bytes 0 18446744073709551615"},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples","title":"Examples","text":"
    • TINYINT and TINYINT UNSIGNED
    -- Create a table named \"inttable\" with 2 attributes of a \"tinyint\", a \"tinyint unsigned\",\ncreate table inttable ( a tinyint not null default 1, tinyint8 tinyint unsigned primary key);\ninsert into inttable (tinyint8) values (0),(255), (0xFE), (253);\n\nmysql> select * from inttable order by 2 asc;\n+------+----------+\n| a    | tinyint8 |\n+------+----------+\n|    1 |        0 |\n|    1 |      253 |\n|    1 |      254 |\n|    1 |      255 |\n+------+----------+\n4 rows in set (0.03 sec)\n
    • SMALLINT and SMALLINT UNSIGNED
    -- Create a table named \"inttable\" with 2 attributes of a \"smallint\", a \"smallint unsigned\",\ndrop table inttable;\ncreate table inttable ( a smallint not null default 1, smallint16 smallint unsigned);\ninsert into inttable (smallint16) values (0),(65535), (0xFFFE), (65534), (65533);\n\nmysql> select * from inttable;\n+------+------------+\n| a    | smallint16 |\n+------+------------+\n|    1 |          0 |\n|    1 |      65535 |\n|    1 |      65534 |\n|    1 |      65534 |\n|    1 |      65533 |\n+------+------------+\n5 rows in set (0.01 sec)\n
    • INT and INT UNSIGNED
    -- Create a table named \"inttable\" with 2 attributes of a \"int\", a \"int unsigned\",\ndrop table inttable;\ncreate table inttable ( a int not null default 1, int32 int unsigned primary key);\ninsert into inttable (int32) values (0),(4294967295), (0xFFFFFFFE), (4294967293), (4294967291);\n\nmysql> select * from inttable order by a desc, 2 asc;\n+------+------------+\n| a    | int32      |\n+------+------------+\n|    1 |          0 |\n|    1 | 4294967291 |\n|    1 | 4294967293 |\n|    1 | 4294967294 |\n|    1 | 4294967295 |\n+------+------------+\n5 rows in set (0.01 sec)\n
    • BIGINT and BIGINT UNSIGNED
    -- Create a table named \"inttable\" with 2 attributes of a \"bigint\", a \"bigint unsigned\",\ndrop table inttable;\ncreate table inttable ( a bigint, big bigint primary key );\ninsert into inttable values (122345515, 0xFFFFFFFFFFFFE), (1234567, 0xFFFFFFFFFFFF0);\n\nmysql> select * from inttable;\n+-----------+------------------+\n| a         | big              |\n+-----------+------------------+\n| 122345515 | 4503599627370494 |\n|   1234567 | 4503599627370480 |\n+-----------+------------------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Data-Types/data-types/#real-numbers","title":"Real Numbers","text":"Data Type Size Precision Min Value Max Value Syntax FLOAT32 4 bytes 23 bits -3.40282e+038 3.40282e+038 FLOAT(M, D) M represents the maximum length and D represents the number of decimal places displayed. The value range of M is (1=< M <=255). The value range of D is (1=< D <=30), and M >= D. Float numbers with precision show the number of bits with the required precision, and a trailing zero is added when the number of bits falls short. FLOAT64 8 bytes 53 bits -1.79769e+308 1.79769e+308 DOUBLE(M, D) M represents the maximum length and D represents the number of decimal places displayed. The value range of M is (1=< M <=255). The value range of D is (1=< D <=30), and M >= D. Float numbers with precision show the number of bits with the required precision, and a trailing zero is added when the number of bits falls short."},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_1","title":"Examples","text":"
    -- Create a table named \"floatt1\" with precision, a trailing zero is added when the number of bits falls short\ncreate table floatt1(a float(5, 2));\ninsert into floatt1 values(1), (2.5), (3.56), (4.678);\nmysql> select * from floatt1;\n+------+\n| a    |\n+------+\n| 1.00 |\n| 2.50 |\n| 3.56 |\n| 4.68 |\n+------+\n4 rows in set (0.00 sec)\n\n-- Create a table named \"floattable\" with 1 attributes of a \"float\"\ncreate table floattable ( a float not null default 1, big float(20,5) primary key);\ninsert into floattable (big) values (-1),(12345678.901234567),(92233720368547.75807);\n\nmysql> select * from floattable order by a desc, big asc;\n+------+----------------------+\n| a    | big                  |\n+------+----------------------+\n|    1 |             -1.00000 |\n|    1 |       12345679.00000 |\n|    1 | 92233718038528.00000 |\n+------+----------------------+\n3 rows in set (0.01 sec)\n\nmysql> select min(big),max(big),max(big)-1 from floattable;\n+----------+----------------------+----------------+\n| min(big) | max(big)             | max(big) - 1   |\n+----------+----------------------+----------------+\n| -1.00000 | 92233718038528.00000 | 92233718038527 |\n+----------+----------------------+----------------+\n1 row in set (0.05 sec)\n
    "},{"location":"MatrixOne/Reference/Data-Types/data-types/#string-types","title":"String Types","text":"Data Type Size Length Syntax Description char 24 bytes 0 ~ 4294967295 CHAR Fixed length string varchar 24 bytes 0 ~ 4294967295 VARCHAR Variable length string binary 255 bytes 0 ~ 65535 BINARY(M) Similar to CHAR, binary string varbinary 255 bytes 0 ~ 65535 VARBINARY(M) Similar to VARCHAR, binary string text 1 GB other types mapping TEXT Long text data, TINY TEXT, MEDIUM TEXT, and LONG TEXT are not distinguished blob 1 GB other types mapping BLOB Long text data in binary form, TINY BLOB, MEDIUM BLOB, and LONG BLOB are not distinguished enum 1 byte or 2 bytes 0 ~ 65535 enum An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special '' error value. ENUM values are represented internally as integers."},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_2","title":"Examples","text":"
    • CHAR and VARCHAR
    -- Create a table named \"names\" with 2 attributes of a \"varchar\" and a \"char\"\ncreate table names(name varchar(255),age char(255));\ninsert into names(name, age) values('Abby', '24');\ninsert into names(name, age) values(\"Bob\", '25');\ninsert into names(name, age) values('Carol', \"23\");\ninsert into names(name, age) values(\"Dora\", \"29\");\n\nmysql> select name,age from names;\n+-------+------+\n| name  | age  |\n+-------+------+\n| Abby  | 24   |\n| Bob   | 25   |\n| Carol | 23   |\n| Dora  | 29   |\n+-------+------+\n4 rows in set (0.00 sec)\n
    • BINARY and VARBINARY
    -- Create a table named \"names\" with 2 attributes of a \"varchar\" and a \"char\"\ncreate table names(name varbinary(255),age binary(255));\ninsert into names(name, age) values('Abby', '24');\ninsert into names(name, age) values(\"Bob\", '25');\ninsert into names(name, age) values('Carol', \"23\");\ninsert into names(name, age) values(\"Dora\", \"29\");\n\nmysql> select name,age from names;\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| name         | age                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| 0x41626279   | 0x323400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x426F62     | 0x323500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x4361726F6C | 0x323300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x446F7261   | 0x323900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n4 rows in set (0.01 sec)\n
    • TEXT
    -- Create a table named \"texttest\" with 1 attribute of a \"text\"\ncreate table texttest (a text);\ninsert into texttest values('abcdef');\ninsert into texttest values('_bcdef');\ninsert into texttest values('a_cdef');\ninsert into texttest values('ab_def');\ninsert into texttest values('abc_ef');\ninsert into texttest values('abcd_f');\ninsert into texttest values('abcde_');\n\nmysql> select * from texttest where a like 'ab\\_def' order by 1 asc;\n+--------+\n| a      |\n+--------+\n| ab_def |\n+--------+\n1 row in set (0.01 sec)\n
    • BLOB
    -- Create a table named \"blobtest\" with 1 attribute of a \"blob\"\ncreate table blobtest (a blob);\ninsert into blobtest values('abcdef');\ninsert into blobtest values('_bcdef');\ninsert into blobtest values('a_cdef');\ninsert into blobtest values('ab_def');\ninsert into blobtest values('abc_ef');\ninsert into blobtest values('abcd_f');\ninsert into blobtest values('abcde_');\n\nmysql> select * from blobtest where a like 'ab\\_def' order by 1 asc;\n+----------------+\n| a              |\n+----------------+\n| 0x61625F646566 |\n+----------------+\n1 row in set (0.01 sec)\n
    • ENUM
    -- Create a table named \"enumtest\" with 1 attribute of a \"enum\"\nCREATE TABLE enumtest (color ENUM('red', 'green', 'blue'));\nINSERT INTO enumtest (color) VALUES ('red');\nmysql> SELECT * FROM enumtest WHERE color = 'green';\n+-------+\n| color |\n+-------+\n| green |\n+-------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Data-Types/data-types/#json-types","title":"JSON Types","text":"JSON Data Type Syntax Object Object is enclosed by {}, separated by commas between key-value pairs, and separated by colons : between keys and values.The value/key can be String, Number, Bool, Time and date. Array Array is enclosed by [], separated by commas between key-value pairs, and separated by colons : between keys and values. The value can be String, Number, Bool, Time and date."},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_3","title":"Examples","text":"
    -- Create a table named \"jsontest\" with 1 attribute of a \"json\"\ncreate table jsontest (a json,b int);\ninsert into jsontest values ('{\"t1\":\"a\"}',1),('{\"t1\":\"b\"}',2);\n\nmysql> select * from jsontest;\n+-------------+------+\n| a           | b    |\n+-------------+------+\n| {\"t1\": \"a\"} |    1 |\n| {\"t1\": \"b\"} |    2 |\n+-------------+------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Data-Types/data-types/#time-and-date-types","title":"Time and Date Types","text":"Data Type Size Resolution Min Value Max Value Precision Time 8 bytes microsecond -2562047787:59:59.999999 2562047787:59:59.999999 hh:mm:ss.ssssss Date 4 bytes day 0001-01-01 9999-12-31 YYYY-MM-DD/YYYYMMDD DateTime 8 bytes microsecond 0001-01-01 00:00:00.000000 9999-12-31 23:59:59.999999 YYYY-MM-DD hh:mi:ssssss TIMESTAMP 8 bytes microsecond 0001-01-01 00:00:00.000000 9999-12-31 23:59:59.999999 YYYYMMDD hh:mi:ss.ssssss"},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_4","title":"Examples","text":"
    • TIME
    -- Create a table named \"timetest\" with 1 attributes of a \"time\"\ncreate table time_02(t1 time);\ninsert into time_02 values(200);\ninsert into time_02 values(\"\");\n\nmysql> select * from time_02;\n+----------+\n| t1       |\n+----------+\n| 00:02:00 |\n| NULL     |\n+----------+\n2 rows in set (0.00 sec)\n
    • DATE
    -- Create a table named \"datetest\" with 1 attributes of a \"date\"\ncreate table datetest (a date not null, primary key(a));\ninsert into datetest values ('2022-01-01'), ('20220102'),('2022-01-03'),('20220104');\n\nmysql> select * from datetest order by a asc;\n+------------+\n| a          |\n+------------+\n| 2022-01-01 |\n| 2022-01-02 |\n| 2022-01-03 |\n| 2022-01-04 |\n+------------+\n
    • DATETIME
    -- Create a table named \"datetimetest\" with 1 attributes of a \"datetime\"\ncreate table datetimetest (a datetime(0) not null, primary key(a));\ninsert into datetimetest values ('20200101000000'), ('2022-01-02'), ('2022-01-02 00:00:01'), ('2022-01-02 00:00:01.512345');\n\nmysql> select * from datetimetest order by a asc;\n+---------------------+\n| a                   |\n+---------------------+\n| 2020-01-01 00:00:00 |\n| 2022-01-02 00:00:00 |\n| 2022-01-02 00:00:01 |\n| 2022-01-02 00:00:02 |\n+---------------------+\n4 rows in set (0.02 sec)\n
    • TIMESTAMP
    -- Create a table named \"timestamptest\" with 1 attribute of a \"timestamp\"\ncreate table timestamptest (a timestamp(0) not null, primary key(a));\ninsert into timestamptest values ('20200101000000'), ('2022-01-02'), ('2022-01-02 00:00:01'), ('2022-01-02 00:00:01.512345');\n\nmysql> select * from timestamptest;\n+---------------------+\n| a                   |\n+---------------------+\n| 2020-01-01 00:00:00 |\n| 2022-01-02 00:00:00 |\n| 2022-01-02 00:00:01 |\n| 2022-01-02 00:00:02 |\n+---------------------+\n
    "},{"location":"MatrixOne/Reference/Data-Types/data-types/#bool","title":"Bool","text":"Data Type Size True 1 byte False 1 byte"},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_5","title":"Examples","text":"
    -- Create a table named \"booltest\" with 2 attribute of a \"boolean\" and b \"bool\"\ncreate table booltest (a boolean,b bool);\ninsert into booltest values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from booltest;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n| NULL  | NULL  |\n+-------+-------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Data-Types/data-types/#decimal-types","title":"Decimal Types","text":"Data Type Size Precision Syntax Decimal64 8 bytes 18 digits Decimal(N,S) N is the total number of digits, the range is(1 ~ 18). The decimal point and (for negative numbers) the - sign are not counted in N.If N is omitted, the default value of N should be the largest; that is, the value is 18. S is the number of digits after the decimal point (the scale), the range is(0 ~ N) If S is 0, values have no decimal point or fractional part. If S is omitted, the default is 0, for example, Decimal(10) is equivalent to Decimal(10, 0). For example, Decimal(10,8) represents a number with a total length of 10 and a decimal place of 8. Decimal128 16 bytes 38 digits Decimal(N,S) N is the total number of digits, the range is(18 ~ 38). The decimal point and (for negative numbers) the - sign are not counted in N.If N is omitted, the default value of N should be the largest; that is, the value is 38. S is the number of digits after the decimal point (the scale), the range is(0 ~ N) If S is 0, values have no decimal point or fractional part. If S is omitted, the default is 0, for example, Decimal(20) is equivalent to Decimal(20, 0).For example, Decimal(20,9) represents a number with a total length of 20 and a decimal place of 9."},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_6","title":"Examples","text":"
    -- Create a table named \"decimalTest\" with 2 attribute of a \"decimal\" and b \"decimal\"\ncreate table decimalTest(a decimal(6,3), b decimal(24,18));\ninsert into decimalTest values(123.4567, 123456.1234567891411241355);\n\nmysql> select * from decimalTest;\n+---------+---------------------------+\n| a       | b                         |\n+---------+---------------------------+\n| 123.457 | 123456.123456789141124136 |\n+---------+---------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Data-Types/data-types/#uuid-type","title":"UUID Type","text":"UUID type Explanation UUID A UUID value consists of 32 hexadecimal digits and 4 hyphens '-', in the form of 8-4-4-4-12, a standard UUID example: a0eebc99 -9c0b-4ef8-bb6d-6bb9bd380a11."},{"location":"MatrixOne/Reference/Data-Types/data-types/#example","title":"Example","text":"
    -- Create a new table named 't1' and set the 'a' column as UUID type, and set the 'a' column as the primary key\ncreate table t1(a uuid primary key);\n\n-- Insert a new UUID value into column 'a' of table 't1'\ninsert into t1 values \u200b\u200b(uuid());\n\n-- Query the length of the value of the 'a' column in the 't1' table converted to a string\nmysql> select length(cast(a as varchar)) from t1;\n+----------------------------+\n|length(cast(a as varchar))|\n+----------------------------+\n| 36 |\n+----------------------------+\n1 row in set (0.01 sec)\n\n-- Query all records in the t1 table, whose value is a UUID\nmysql> select * from t1;\n+----------------------------------------+\n| a |\n+----------------------------------------+\n| 948d8e4e-1b00-11ee-b656-5ad2460dea50 |\n+----------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Data-Types/enum-type/","title":"The ENUM Type","text":"

    \"ENUM\" is a list of strings used to store a set of predefined discrete values. It can define a type with discrete values, with each enumeration constant representing a specific value.

    The \"ENUM\" data type is suitable for storing data with limited fixed values, such as status and identification.

    The advantages of the \"ENUM\" data type are:

    Improved readability of column values. Compact data storage. When storing \"ENUM\" in MatrixOne, only the numerical index (1, 2, 3, ...) corresponding to the enumeration value is stored.

    "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#syntax","title":"Syntax","text":"
    ENUM ('value1', 'value2', ..., 'valuen')\n

    For example, to define an ENUM column, you can use the following syntax:

    CREATE TABLE table_name (\n...\ncol ENUM ('value1','value2','value3'),\n...\n);\n
    "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#explanations","title":"Explanations","text":"
    • ENUM is a keyword used to declare an enumeration type.
    • value1 to valuen is the optional list of choices for this ENUM type. The value of a column using the ENUM type can only be one of the values listed above.
    • Enumeration values can be of type string, int, or time.

    Note: You can have multiple enumeration values in the ENUM data type. However, it is recommended to keep the number of enumeration values below 20.

    "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#example-explanation","title":"Example Explanation","text":"

    The value of an ENUM type must be selected from a predefined list of values. The following example will help you understand:

    CREATE TABLE enumtable (\nid INT NOT NULL AUTO_INCREMENT,\ncolor ENUM('red', 'green', 'blue'),\nPRIMARY KEY (id)\n);\n

    The above statement will create a table named enumtable, which contains an enum type field named color. The value of the color field must be one of red, green, or blue. At the same time, according to the order of column definition, the indexes of red, green, and blue are 1, 2, and 3, respectively.

    "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#insert-enum-values","title":"Insert ENUM values","text":"

    When inserting data into a field of an enumeration type, only predefined enumeration values \u200b\u200bor NULL can be inserted. An error is raised if the inserted value is not in the predefined list. For example:

    INSERT INTO enumtable (id, color) VALUES ('01', 'red');\n-- 'red' is in the predefined list; the insertion was successful\nINSERT INTO enumtable (id, color) VALUES ('02', 'yellow');\n-- 'yellow' is not in the predefined list, an error will be generated\nINSERT INTO enumtable (id, color) VALUES ('03', NULL);\n-- The enumeration member does not define not null; the insertion is successful\n

    In addition to enumeration values, data can be inserted into ENUM columns using numeric indexes on enumeration members. For example:

    INSERT INTO enumtable (id, color) VALUES ('04', 2);\n-- Since the index of `green` is 2, this data is successfully inserted\n
    • NON-NULL CONSTRAINT FOR ENUM RESTRICTIONS

    If we defined the color column NOT NULL when creating the table:

    CREATE TABLE enumtable (\nid INT NOT NULL AUTO_INCREMENT,\ncolor ENUM('red', 'green', 'blue') NOT NULL,\nPRIMARY KEY (id)\n);\n

    When inserting a new row without specifying a value for the color column, MatrixOne will use the first enumeration member as the default value:

    INSERT INTO enumtable (id) VALUES ('05');\n-- Here, the first enumeration member `red` will be assigned as the default value for the column with id 05\n
    "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#features-that-are-different-from-mysql","title":"Features that are different from MySQL","text":"

    Unlike MySQL, MatrixOne's ENUM type can only be compared with the string type in the WHERE condition.

    You can see this example:

    update orders set status= 2 where status='Processing';`\n

    In this example, you must update the status to 2 for the row whose status is Processing. Due to the nature of the ENUM type, MatrixOne implicitly converts 2 to the string 2 in the WHERE condition, which is then compared with Processing.

    "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#constraints","title":"Constraints","text":"
    1. Modifying ENUM enumeration members requires rebuilding the table using the ALTER TABLE statement.
    2. MatrixOne does not support Filtering ENUM values and Sorting ENUM values.
    "},{"location":"MatrixOne/Reference/Data-Types/fixed-point-types/","title":"Fixed-Point Types (Exact Value) - DECIMAL","text":"

    The DECIMAL type store exact numeric data values. These types are used when it is important to preserve exact precision, for example with monetary data, or with scientific calculations.

    In a DECIMAL column declaration, the precision and scale can be (and usually is) specified. For example:

    salary DECIMAL(5,2)\n

    In this example, 5 is the precision and 2 is the scale. The precision represents the number of significant digits that are stored for values, and the scale represents the number of digits that can be stored following the decimal point.

    Standard SQL requires that DECIMAL(5,2) be able to store any value with five digits and two decimals, so values that can be stored in the salary column range from -999.99 to 999.99.

    In MatrixOne, the syntax DECIMAL(M) is equivalent to DECIMAL(M,0). Similarly, the syntax DECIMAL is equivalent to DECIMAL(M,0), where the implementation is permitted to decide the value of M. MatrixOne supports both of these variant forms of DECIMAL syntax. The default value of M is 10.

    If the scale is 0, DECIMAL values contain no decimal point or fractional part.

    In MatrixOne, the maximum number of digits for DECIMAL is 38, but the actual range for a given DECIMAL column can be constrained by the precision or scale for a given column. When such a column is assigned a value with more digits following the decimal point than are permitted by the specified scale, the value is converted to that scale.

    "},{"location":"MatrixOne/Reference/Data-Types/fixed-point-types/#decimal-data-type-characteristics","title":"DECIMAL Data Type Characteristics","text":"

    This section discusses the characteristics of the DECIMAL data type (and its synonyms), with particular regard to the following topics:

    • Maximum number of digits

    • Storage format

    The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments are as follows:

    M is the maximum number of digits (the precision). It has a range of 1 to 38.

    D is the number of digits to the right of the decimal point (the scale). It has a range of 1 to 38 and must be no larger than M.

    If D is omitted, the default is 0. If M is omitted, the default is 10.

    The maximum value of 38 for M means that calculations on DECIMAL values are accurate up to 38 digits.

    Values for DECIMAL columns are stored using a binary format that packs decimal digits into 8 bytes or 16 bytes. The storage required for remaining digits is given by the following table.

    Digits Number of Bytes 0-18 8 bytes 19-38 16 bytes

    For a full explanation of the internal implementation of DECIMAL values, see the Feature Design.

    "},{"location":"MatrixOne/Reference/Data-Types/json-type/","title":"The JSON Data Type","text":"

    MatrixOne supports a native JSON data type defined by RFC 7159 that enables efficient access to data in JSON (JavaScript Object Notation) documents. The JSON data type provides these advantages over storing JSON-format strings in a string column:

    Automatic validation of JSON documents stored in JSON columns. Invalid documents produce an error.

    Automatically optimize storage format. JSON documents stored in JSON columns are converted to an internal format that permits quick read access to document elements. When the server later must read a JSON value stored in this binary format, the value need not be parsed from a text representation. The binary format is structured to enable the server to look up subobjects or nested values directly by key or array index without reading all values before or after them in the document.

    The space required to store a JSON document is roughly the same as for BLOB or TEXT.

    "},{"location":"MatrixOne/Reference/Data-Types/json-type/#json-types","title":"JSON Types","text":"

    JSON types contain JSON array and JSON object.

    • A JSON array contains a list of values separated by commas and enclosed within [ and ] characters:
    [\"abc\", 10, null, true, false]\n
    • A JSON object contains a set of key-value pairs separated by commas and enclosed within { and } characters:
    {\"k1\": \"value\", \"k2\": 10}\n

    As the examples illustrate, JSON arrays and objects can contain scalar values that are strings or numbers, the JSON null literal, or the JSON boolean true or false literals. Keys in JSON objects must be strings. Temporal (date, datetime) scalar values are also permitted:

    [\"12:18:29.000000\", \"2015-07-29\", \"2015-07-29 12:18:29.000000\"]\n

    Nesting is permitted within JSON array elements and JSON object key values:

    [99, {\"id\": \"HK500\", \"cost\": 75.99}, [\"hot\", \"cold\"]]\n{\"k1\": \"value\", \"k2\": [10, 20]}\n
    "},{"location":"MatrixOne/Reference/Data-Types/json-type/#normalization-of-json-values","title":"Normalization of JSON Values","text":"

    When a string is parsed and found to be a valid JSON document, it is also normalized. This means that members with keys that duplicate a key found later in the document, reading from left to right, are discarded.

    Normalization is performed when values are inserted into JSON columns, as shown here:

    CREATE TABLE t1 (c1 JSON);\nINSERT INTO t1 VALUES\n('{\"x\": 17, \"x\": \"red\"}'),\n('{\"x\": 17, \"x\": \"red\", \"x\": [3, 5, 7]}');\n\nmysql> SELECT c1 FROM t1;\n+------------------+\n| c1               |\n+------------------+\n| {\"x\": \"red\"}     |\n| {\"x\": [3, 5, 7]} |\n+------------------+\n
    "},{"location":"MatrixOne/Reference/Data-Types/uuid-type/","title":"UUID Type","text":"

    A UUID is a universally unique identifier consisting of 32 hexadecimal digits followed by 4 hyphens. UUIDs are globally unique, not unique in the database, and even performing a UUID call on two unconnected, standalone devices is expected to generate two different values. UUID is often used to generate a random value for the corresponding row to ensure the uniqueness of each record. . UUIDs are suitable as unique identifiers in a cluster environment.

    Info

    Although UUID() values \u200b\u200bare unique, they are not guessable or unpredictable. If unpredictability is desired, UUID values \u200b\u200bshould be generated in other ways.

    UUID() returns a version 1 UUID value conforming to the RFC 4122 standard, which is a 128-bit number, which represents a utf8mb3 composed of five A string of hexadecimal numbers, that is, aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee, the format is explained as follows:

    • The first three numbers are generated from the low, middle, and high parts of a timestamp. The high part also includes the UUID version number.

    • The fourth number preserves temporal uniqueness in case the timestamp value loses monotonicity (for example, due to daylight saving time).

    • The fifth number is an IEEE 802 node number that provides spatial uniqueness. A random number is substituted if the latter is not available (for example, because the host device has no Ethernet card, or it is unknown how to find the hardware address of an interface on the host operating system). In this case, spatial uniqueness cannot be guaranteed. Nevertheless, a collision should have very low probability.

    SQL statement supported by UUID type:

    • DDL - CREATE statement: Can create a table with a field of type UUID.
    • DML - INSERT/UPDATE/DELETE statement: Allows insert, update and delete operations on UUID type data.
    • DQL - SELECT statement: UUID type fields can be queried, and the query results are displayed as strings on the client side.

    SQL statement clauses supported by UUID type:

    • ORDER BY clause: UUID type fields can be used as sorting criteria.
    • WHERE clause: UUID type fields can be used in the WHERE clause, and comparison operations are supported.
    • HAVING clause: UUID type fields can be used in the HAVING clause, and comparison operations are supported.
    • GROUP BY clause: UUID type fields can be used as grouping criteria for GROUP BY.

    Other supported UUID type functions:

    • UUID type field can be set as the table's primary key.
    • UUID type fields can be used as parameters of aggregation functions (such as max, min, and count).
    • UUID type data can be converted between string types.
    "},{"location":"MatrixOne/Reference/Data-Types/uuid-type/#examples","title":"Examples","text":"
    • Example 1:
    mysql> select uuid();\n+--------------------------------------+\n| uuid()                               |\n+--------------------------------------+\n| 4aa4f4de-1b00-11ee-b656-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
    • Example 2:
    drop table if exists t1;\n-- Create a new table 't1' with two columns 'a' and 'b', column 'a' is of type INT and column 'b' is of type float\ncreate table t1(a INT, b float);\n\n-- Insert two rows into table 't1'\ninsert into t1 values(12124, -4213.413), (12124, -42413.409);\n\n-- Query the number of rows in the 't1' table, and generate the length of the uuid() function of each row. Note that the uuid() function generates a new UUID here.\n-- does not depend on any data from the 't1' table, the returned length is 36 because the UUID is a 36 character string with 32 characters and 4 dashes\nmysql> SELECT length(uuid()) FROM t1;\n\n+----------------+\n|length(uuid())|\n+----------------+\n| 36 |\n| 36 |\n+----------------+\n2 rows in set (0.00 sec)\n
    • Example 3:
    -- Create a table named 't1' with a column named 'a' of data type VARCHAR with a maximum length of 20\ncreate table t1(a varchar(20));\n\n-- Insert a row of data in the 't1' table, the value of the 'a' column is '123123sdafsdf'\ninsert into t1 values('123123sdafsdf');\n\n-- Select all rows from table 't1' and return the value of column 'a' for each row, and a newly generated UUID value\nmysql> select uuid(), a from t1;\n+-------------------------------------+---------- -----+\n| uuid() | a |\n+-------------------------------------+---------- -----+\n| 664f1a96-1981-11ee-a041-5ad2460dea50 | 123123sdafsdf |\n+-------------------------------------+---------- -----+\n1 row in set (0.01 sec)\n
    • Example 4:
    -- Create a table named namelists with two fields, id and name\nCREATE TABLE namelists (\nid UUID DEFAULT uuid() PRIMARY KEY, -- the id field is of UUID type, and the default value is the UUID value generated by the uuid() function as the primary key\nname VARCHAR NOT NULL -- the name field is of type VARCHAR and cannot be empty\n);\nINSERT INTO namelists (name) VALUES ('Tom'), ('Jane'), ('Bob');\nmysql> select * from namelists;\n+--------------------------------------+--------+\n| id                                   | name   |\n+--------------------------------------+--------+\n| 61400e9c-1bbc-11ee-b512-5ad2460dea50 | Tom    |\n| 61400ea6-1bbc-11ee-b512-5ad2460dea50 | Jane   |\n| 61400ea6-1bbc-11ee-b513-5ad2460dea50 | Bob    |\n+--------------------------------------+--------+\n3 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/timestamp-initialization/","title":"Automatic Initialization and Updating for TIMESTAMP and DATETIME","text":"

    TIMESTAMP and DATETIME columns can be automatically initialized and updated to the current date and time (that is, the current timestamp).

    For any TIMESTAMP or DATETIME column in a table, you can assign the current timestamp as the default value, the auto-update value, or both:

    • An auto-initialized column is set to the current timestamp for inserted rows that specify no value for the column.

    • An auto-updated column is automatically updated to the current timestamp when the value of any other column in the row is changed from its current value. An auto-updated column remains unchanged if all other columns are set to their current values. To prevent an auto-updated column from updating when other columns change, explicitly set it to its current value. To update an auto-updated column even when other columns do not change, explicitly set it to the value it should have (for example, set it to CURRENT_TIMESTAMP).

    To specify automatic properties, use the DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP clauses in column definitions. The order of the clauses does not matter. If both are present in a column definition, either can occur first. Any of the synonyms for CURRENT_TIMESTAMP have the same meaning as CURRENT_TIMESTAMP. These are CURRENT_TIMESTAMP(), NOW().

    Use of DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP is specific to TIMESTAMP and DATETIME. The DEFAULT clause also can be used to specify a constant (nonautomatic) default value (for example, DEFAULT 0 or DEFAULT '2000-01-01 00:00:00').

    TIMESTAMP or DATETIME column definitions can specify the current timestamp for both the default and auto-update values, for one but not the other, or for neither. Different columns can have different combinations of automatic properties. The following rules describe the possibilities:

    • With both DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP, the column has the current timestamp for its default value and is automatically updated to the current timestamp.
    CREATE TABLE t1 (\n  ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n);\n
    • With a DEFAULT clause but no ON UPDATE CURRENT_TIMESTAMP clause, the column has the given default value and is not automatically updated to the current timestamp.

    The default depends on whether the DEFAULT clause specifies CURRENT_TIMESTAMP or a constant value. With CURRENT_TIMESTAMP, the default is the current timestamp.

    CREATE TABLE t1 (\n  ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  dt DATETIME DEFAULT CURRENT_TIMESTAMP\n);\n

    With a constant, the default is the given value. In this case, the column has no automatic properties at all.

    CREATE TABLE t1 (\n  ts TIMESTAMP DEFAULT 0,\n  dt DATETIME DEFAULT 0\n);\n
    • With an ON UPDATE CURRENT_TIMESTAMP clause and a constant DEFAULT clause, the column is automatically updated to the current timestamp and has the given constant default value.
    CREATE TABLE t1 (\n  ts TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP,\n  dt DATETIME DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP\n);\n
    • With an ON UPDATE CURRENT_TIMESTAMP clause but no DEFAULT clause, the column is automatically updated to the current timestamp but does not have the current timestamp for its default value.

    The default in this case is type dependent. TIMESTAMP has a default of 0 unless defined with the NULL attribute, in which case the default is NULL.

    CREATE TABLE t1 (\n  ts1 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,     -- default 0\n  ts2 TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP -- default NULL\n);\n

    DATETIME has a default of NULL unless defined with the NOT NULL attribute, in which case the default is 0.

    CREATE TABLE t1 (\n  dt1 DATETIME ON UPDATE CURRENT_TIMESTAMP,         -- default NULL\n  dt2 DATETIME NOT NULL ON UPDATE CURRENT_TIMESTAMP -- default 0\n);\n
    "},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/year-type/","title":"YEAR Type","text":"

    The YEAR type is a 1-byte data type used to represent year values. It can be declared as YEAR with an implicit display width of 4 characters or equivalently as YEAR(4) with an explicit display width of 4.

    MatrixOne displays YEAR values in the format YYYY, ranging from the year 0001 to 9999.

    YEAR accepts input values in various formats:

    • As 4-digit strings in the range '0001' to '9999'.
    • As 4-digit numbers in the range 0001 to 9999.
    • As 1- or 2-digit strings in the range '0' to '99'. For values in the range '0' to '00' and '00' to '99', MatrixOne automatically adds '00' as the prefix, resulting in values from '0000' to '0099'.
    • The result of functions that return a value acceptable in the context of YEAR, such as the NOW() function.
    "},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/year-type/#two-digit-years-in-dates","title":"Two-Digit Years in Dates","text":"

    Due to the lack of century information, two-digit years in dates need to be sufficiently clear. To ensure internal storage consistency, MatrixOne must interpret these date values as four-digit numbers.

    For DATETIME, DATE, and TIMESTAMP types, MatrixOne follows these rules to interpret dates with ambiguous year values:

    • Year values within the range 00-99 are converted to 0000-0099.

    Below are examples of dates involving two-digit years:

    1. Interpreting dates in DATETIME type:

    Let's assume we have a column named event_date with DATETIME type, containing the following date values:

    event_date 2023-07-12 08:30 99-01-15 13:45 23-05-06 09:00

    According to the rules, the two-digit year values in these dates are interpreted as:

    • 99-01-15 is interpreted as January 15th, 0099.
    • 23-05-06 is interpreted as May 6th, 0023.

    • Interpreting dates in DATE type:

    Let's assume we have a column named birth_date with DATE type containing the following date values:

    birth_date 95-08-21 04-11-30 88-03-17

    According to the rules, the two-digit year values in these dates are interpreted as:

    • 95-08-21 is interpreted as August 21st, 0095.
    • 04-11-30 is interpreted as November 30th, 0004.
    • 88-03-17 is interpreted as March 17th, 0088.

    • Interpreting dates in YEAR type:

    Let's assume we have a column named graduation_year with YEAR type containing the following year values:

    graduation_year 65 78 03

    According to the rules, the two-digit year values in these dates are interpreted as:

    • 65 is interpreted as the year 0065.
    • 78 is interpreted as the year 0078.
    • 03 is interpreted as the year 0003.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/","title":"ANY_VALUE","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#description","title":"Description","text":"

    The ANY_VALUE function is useful for GROUP BY queries.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#syntax","title":"Syntax","text":"
    > ANY_VALUE(arg)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#arguments","title":"Arguments","text":"Arguments Description arg Any type. When arg is NULL, the line does not participate in the calculation."},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#returned-value","title":"Returned Value","text":"

    The function return value and type are the same as the return value and type of its argument.

    note

    The execution result of ANY_VALUE is uncertain. The same input may produce different execution results.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#examples","title":"Examples","text":"
    > create table t1(\n-> a int,\n-> b int,\n-> c int\n-> );\n> create table t2(\n-> a int,\n-> b int,\n-> c int\n-> );\n> insert into t1 values(1,10,34),(2,20,14);\n> insert into t2 values(1,-10,-45);\n> select ANY_VALUE(t1.b) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a;\n+-----------------+\n| any_value(t1.b) |\n+-----------------+\n|              10 |\n|              20 |\n+-----------------+\n2 rows in set (0.01 sec)\n> select 3+(5*ANY_VALUE(t1.b)) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a;\n+---------------------------+\n| 3 + (5 * any_value(t1.b)) |\n+---------------------------+\n|                        53 |\n|                       103 |\n+---------------------------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/","title":"AVG","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#description","title":"Description","text":"

    Aggregate function.

    The AVG() function calculates the average value of the argument.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#syntax","title":"Syntax","text":"
    > AVG(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#arguments","title":"Arguments","text":"Arguments Description expr Any numerical expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#returned-value","title":"Returned Value","text":"

    The arithmetic mean, always as Double.

    NaN if the input parameter is empty.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#examples","title":"Examples","text":"
    > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select avg(col_1c) from tbl1;\n+-------------+\n| avg(col_1c) |\n+-------------+\n|      3.5000 |\n+-------------+\n\n> select sum(col_1d) as s1,avg(col_1d) as a3 from tbl1 group by col_1e order by s1 desc;\n+------+---------+\n| s1   | a3      |\n+------+---------+\n|   21 | 10.5000 |\n|   18 |  9.0000 |\n|   10 | 10.0000 |\n|    8 |  8.0000 |\n+------+---------+\n\n> select avg(col_1d) as a1 from tbl1 where col_1d < 13 group by col_1e order by a1;\n+---------+\n| a1      |\n+---------+\n|  8.0000 |\n|  9.0000 |\n| 10.0000 |\n| 10.5000 |\n+---------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/","title":"BIT_AND","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#description","title":"Description","text":"

    Aggregate function.

    The BIT_AND(expr) function returns the bitwise AND of all bits in expr.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#syntax","title":"Syntax","text":"
    > BIT_AND(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#arguments","title":"Arguments","text":"Arguments Description expr UINT data types"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_AND(number) FROM t1 GROUP BY id;\n+------+-----------------+\n| id   | bit_and(number) |\n+------+-----------------+\n| a    |               0 |\n| b    |               1 |\n+------+-----------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/","title":"BIT_OR","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#description","title":"Description","text":"

    Aggregate function.

    The BIT_OR(expr) function returns the bitwise OR of all bits in expr.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#syntax","title":"Syntax","text":"
    > BIT_OR(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#arguments","title":"Arguments","text":"Arguments Description expr UINT data types"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_OR(number) FROM t1 GROUP BY id;\n+------+----------------+\n| id   | bit_or(number) |\n+------+----------------+\n| a    |            111 |\n| b    |             11 |\n+------+----------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/","title":"BIT_XOR","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#description","title":"Description","text":"

    Aggregate function.

    The BIT_XOR(expr) function returns the bitwise XOR of all bits in expr.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#syntax","title":"Syntax","text":"
    > BIT_XOR(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#arguments","title":"Arguments","text":"Arguments Description expr UINT data types"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_XOR(number) FROM t1 GROUP BY id;\n+------+-----------------+\n| id   | bit_xor(number) |\n+------+-----------------+\n| a    |             101 |\n| b    |              10 |\n+------+-----------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/","title":"COUNT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#description","title":"Description","text":"

    Aggregate function.

    The COUNT() function calculates the number of records returned by a select query.

    note

    NULL values are not counted.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#syntax","title":"Syntax","text":"
    > COUNT(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#arguments","title":"Arguments","text":"Arguments Description expr Any expression.This may be a column name, the result of another function, or a math operation. * is also allowed, to indicate pure row counting."},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#returned-value","title":"Returned Value","text":"

    Returns a count of the number of non-NULL values of expr in the rows retrieved by a SELECT statement. The result is a BIGINT value.

    If there are no matching rows, COUNT() returns 0.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#examples","title":"Examples","text":"
    > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select count(col_1b) from tbl1;\n+---------------+\n| count(col_1b) |\n+---------------+\n|             6 |\n+---------------+\n\n> select count(*) from tbl1 where col_1d<10;\n+----------+\n| count(*) |\n+----------+\n|        3 |\n+----------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/","title":"GROUP_CONCAT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#description","title":"Description","text":"

    This function returns a string result with the concatenated non-NULL values from a group. It returns NULL if there are no non-NULL values.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#syntax","title":"Syntax","text":"
    > GROUP_CONCAT(expr)\n

    The full syntax is as follows:

    GROUP_CONCAT([DISTINCT] expr [,expr ...]\n             [ORDER BY {unsigned_integer | col_name | expr}\n                 [ASC | DESC] [,col_name ...]]\n             [SEPARATOR str_val])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#arguments","title":"Arguments","text":"Arguments Description expr Required. It specifies one or more columns or expressions to join. DISTINCT Optional. To eliminate duplicate values. ORDER BY Optional. To sort values in the result. To sort in reverse order, add the DESC (descending) keyword to the name of the column you are sorting by in the ORDER BY clause. The default is ascending order; this may be specified explicitly using the ASC keyword. SEPARATOR Optional. The default separator between values in a group is comma (,)."},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#returned-value","title":"Returned Value","text":"

    The return value is a nonbinary or binary string, depending on whether the arguments are nonbinary or binary strings.

    It returns NULL if there are no non-NULL values.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#examples","title":"Examples","text":"
    create table t1(a int,b text,c text);\ninsert into t1 values(1,\"a\",\"bc\"),(2,\"ab\",\"c\"),(3,\"aa\",\"bb\"),(3,\"aa\",\"bb\");\n\nmysql> select group_concat(distinct a,b,c separator '|') from t1;\n+-----------------------------------+\n| group_concat(distinct a, b, c, |) |\n+-----------------------------------+\n| 1abc|2abc|3aabb                   |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select group_concat(distinct b,c separator '|') from t1 group by a;\n+--------------------------------+\n| group_concat(distinct b, c, |) |\n+--------------------------------+\n| abc                            |\n| abc                            |\n| aabb                           |\n+--------------------------------+\n3 rows in set (0.01 sec)\n\nmysql> select group_concat(distinct b,c separator '|') from t1;\n+--------------------------------+\n| group_concat(distinct b, c, |) |\n+--------------------------------+\n| abc|abc|aabb                   |\n+--------------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/","title":"MAX","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#description","title":"Description","text":"

    Aggregate function.

    The MAX() function calculates the maximum value across a group of values.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#syntax","title":"Syntax","text":"
    > MAX(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#arguments","title":"Arguments","text":"Arguments Description expr Any expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#returned-value","title":"Returned Value","text":"

    Returns the maximum value of expr. MAX() may take a string argument, in such cases, it returns the maximum string value.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#examples","title":"Examples","text":"
    > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select max(col_1d) from tbl1;\n+-------------+\n| max(col_1d) |\n+-------------+\n|          12 |\n+-------------+\n\n> select max(col_1c) as m1 from tbl1 where col_1d<12 group by col_1e;\n+------+\n| m1   |\n+------+\n|    5 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/","title":"MEDIAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#description","title":"Description","text":"

    MEDIAN() returns the median value of a set of values, that is, returns the value in the middle after sorting a set of values. If the argument set contains an even number of values, the function returns the average of the two numbers in the middle. It can be used as an aggregate or analytical function.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#syntax","title":"Syntax","text":"
    > MEDIAN(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#arguments","title":"Arguments","text":"Arguments Description expr Required. Specify the name of the array whose median value is required, whose argument type is a numeric data type or can be implicitly converted to a numeric data type."},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#returned-value","title":"Returned Value","text":"

    The function return value and type are the same as the return value and type of its argument.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#examples","title":"Examples","text":"
    mysql> select median(null);\n+--------------+\n| median(null) |\n+--------------+\n|         NULL |\n+--------------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\ncreate table t1 (a int,b int);\ninsert into t1 values (1,null);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n|      NULL |\n+-----------+\n1 row in set (0.01 sec)\n\ninsert into t1 values (1,1);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n|         1 |\n+-----------+\n1 row in set (0.01 sec)\n\ninsert into t1 values (1,2);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n|       1.5 |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select median(b) from t1 group by a order by a;\n+-----------+\n| median(b) |\n+-----------+\n|       1.5 |\n+-----------+\n1 row in set (0.00 sec)\n\ninsert into t1 values (2,1),(2,2),(2,3),(2,4);\n\nmysql> select median(b) from t1 group by a order by a;\n+-----------+\n| median(b) |\n+-----------+\n|       1.5 |\n|       2.5 |\n+-----------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/","title":"MIN","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#description","title":"Description","text":"

    Aggregate function.

    The MAX() function calculates the maximum value across a group of values.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#syntax","title":"Syntax","text":"
    > MIN(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#arguments","title":"Arguments","text":"Arguments Description expr Any expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#returned-value","title":"Returned Value","text":"

    Returns the minimum value of expr. MIN() may take a string argument, in such cases, it returns the minimum string value.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#examples","title":"Examples","text":"
    > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select min(col_1d) from tbl1;\n+-------------+\n| min(col_1d) |\n+-------------+\n|           7 |\n+-------------+\n\n> select min(col_1c) as m1 from tbl1 where col_1d<12 group by col_1e;\n+------+\n| m1   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/","title":"STDDEV_POP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#description","title":"Description","text":"

    Aggregate function.

    The STDDEV_POP(expr) function returns the population standard deviation of expr.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#syntax","title":"Syntax","text":"
    > STDDEV_POP(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#arguments","title":"Arguments","text":"Arguments Description expr Any numerical expressions"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#examples","title":"Examples","text":"
    > CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\n> INSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ),  ('Mitchell Starc', 0, 3);\n> SELECT STDDEV_POP(RunScored) as Pop_Standard_Deviation FROM t1;\n> SELECT  STDDEV_POP(WicketsTaken) as Pop_Std_Dev_Wickets FROM t1;\n\n\n> SELECT STDDEV_POP(RunScored) as Pop_Standard_Deviation FROM t1;\n+------------------------+\n| Pop_Standard_Deviation |\n+------------------------+\n|                16.8762 |\n+------------------------+\n1 row in set (0.02 sec)\n\n> SELECT  STDDEV_POP(WicketsTaken) as Pop_Std_Dev_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Dev_Wickets |\n+---------------------+\n|              0.9574 |\n+---------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/","title":"SUM","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#description","title":"Description","text":"

    Aggregate function.

    The SUM() function calculates the sum of a set of values.

    note

    NULL values are not counted.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#syntax","title":"Syntax","text":"
    > SUM(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#arguments","title":"Arguments","text":"Arguments Description expr Any expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#returned-value","title":"Returned Value","text":"

    Returns the sum of expr. A double if the input type is double, otherwise integer.

    If there are no matching rows, SUM() returns NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#examples","title":"Examples","text":"
    • Example 1:
    > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select sum(col_1c) from tbl1;\n+-------------+\n| sum(col_1c) |\n+-------------+\n|          21 |\n+-------------+\n\n> select sum(col_1d) as c1 from tbl1 where col_1d < 13 group by col_1e order by c1;\n+------+\n| c1   |\n+------+\n|    8 |\n|   10 |\n|   18 |\n|   21 |\n+------+\n
    • Example 2:
    > CREATE TABLE t1(a varchar(255), b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL);\n> INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1);\n> INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2);\n> SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b;\n+-----------------+\n| sum(distinct b) |\n+-----------------+\n|               1 |\n|               2 |\n+-----------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/","title":"VARIANCE","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#description","title":"Description","text":"

    The VARIANCE(expr) function returns the population standard variance of expr. Variance is an essential concept in statistics, which is used to measure the degree of dispersion of a set of data values, that is, the difference between the data value and its mean value. If the variance value is large, the difference between the data values \u200b\u200bis large; conversely, if the variance value is small, the difference between the data values \u200b\u200bis slight.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#syntax","title":"Syntax","text":"
    > VARIANCE(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#arguments","title":"Arguments","text":"Arguments Description expr Any numerical expressions"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#examples","title":"Examples","text":"
    CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\nINSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ),  ('Mitchell Starc', 0, 3);\n\n-- Calculate the variance of the RunScored column\n> SELECT VARIANCE(RunScored) as Pop_Standard_Variance FROM t1;\n+-----------------------+\n| Pop_Standard_Variance |\n+-----------------------+\n|     284.8055555555555 |\n+-----------------------+\n1 row in set (0.01 sec)\n\n-- Calculate the variance of the WicketsTaken column\nmysql> SELECT VARIANCE(WicketsTaken) as Pop_Std_Var_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Var_Wickets |\n+---------------------+\n|  0.9166666666666665 |\n+---------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/","title":"CURDATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#description","title":"Description","text":"

    The CURDATE() function returns the current date as a value in YYYY-MM-DD format, depending on whether the function is used in string or numeric context.

    Note

    The difference from MySQL's behavior is: curdate()+int returns the number of days from 1970-01-01. For example, curdate()+1 means the current date minus 1970-01-01 plus 1 day.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#syntax","title":"Syntax","text":"
    > CURDATE()\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#examples","title":"Examples","text":"
    mysql> SELECT CURDATE();\n+------------+\n| curdate()  |\n+------------+\n| 2023-02-02 |\n+------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT CURDATE() + 0;\n+---------------+\n| curdate() + 0 |\n+---------------+\n|         19390 |\n+---------------+\n1 row in set (0.00 sec)\n\nmysql> select cast(now() as date)=curdate() q;\n+------+\n| q    |\n+------+\n| true |\n+------+\n1 row in set (0.01 sec)\n\ncreate table t1 (a int);\ninsert into t1 values (1),(2),(3);\n\nmysql> select cast(now() as date)=curdate() q from t1;\n+------+\n| q    |\n+------+\n| true |\n| true |\n| true |\n+------+\n3 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/","title":"CURRENT_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#description","title":"Description","text":"

    CURRENT_TIMESTAMP and CURRENT_TIMESTAMP() are synonyms for NOW().

    Returns the current date and time as a value in YYYY-MM-DD hh:mm:ss or YYYYMMDDhhmmss format, depending on whether the function is used in string or numeric context. The value is expressed in the session time zone.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#syntax","title":"Syntax","text":"
    > CURRENT_TIMESTAMP([fsp])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#arguments","title":"Arguments","text":"Arguments Description fsp Optional. If the fsp argument is given to specify a fractional seconds precision from 0 to 6, the return value includes a fractional seconds part of that many digits."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#examples","title":"Examples","text":"
    mysql> SELECT CURRENT_TIMESTAMP();\n+----------------------------+\n| current_timestamp()        |\n+----------------------------+\n| 2022-09-21 11:46:44.153777 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT NOW();\n+----------------------------+\n| now()                      |\n+----------------------------+\n| 2022-09-21 12:56:36.915961 |\n+----------------------------+\n1 row in set (0.01 sec)\n
    create table t1 (a int primary key, b int, c int, d timestamp default current_timestamp);\ninsert into t1 select 1,1,1,now();\ninsert into t1 select 2,0,0,null;\n\nmysql> select a,b,c,year(d) from t1;\n+------+------+------+---------+\n| a    | b    | c    | year(d) |\n+------+------+------+---------+\n|    1 |    1 |    1 |    2022 |\n|    2 |    0 |    0 |    NULL |\n+------+------+------+---------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#constraints","title":"Constraints","text":"

    Operator + or - is not supported for using with CURRENT_TIMESTAMP now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/","title":"DATE_ADD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#description","title":"Description","text":"

    The DATE_ADD() function adds a time/date interval to a date and then returns the date. If date is NULL, the function returns NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#syntax","title":"Syntax","text":"
    > DATE_ADD(date,INTERVAL expr unit)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the date from. expr Required. The expr is an expression specifying the interval value to be added or subtracted from the starting date. The expr is evaluated as a string; it may start with a - for negative intervals. unit Required. The unit is a keyword indicating the units in which the expression should be interpreted. The unit argument can have the following values:MICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#examples","title":"Examples","text":"
    create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT OrderId,DATE_ADD(OrderDate,INTERVAL 45 DAY) AS OrderPayDate FROM t2;\n+---------+---------------------+\n| orderid | orderpaydate        |\n+---------+---------------------+\n|       1 | 2008-12-26 13:23:45 |\n+---------+---------------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#constraints","title":"Constraints","text":"

    The date type supports only yyyy-mm-dd and yyyymmdd for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/","title":"DATE_FORMAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#description","title":"Description","text":"

    Formats the date value according to the format string. If either argument is NULL, the function returns NULL.

    DATE_FORMAT() returns a string with a character set and collation given by character_set_connection and collation_connection so that it can return month and weekday names containing non-ASCII characters.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#syntax","title":"Syntax","text":"
    > DATE_FORMAT(date,format)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#arguments","title":"Arguments","text":"Arguments Description date Required. The date to be formatted. format Required. The format to use. Can be one or a combination of the following values as the below table:"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#format-specifier","title":"Format Specifier","text":"

    Info

    The specifiers shown in the following table may be used in the format string. The % character is required before format specifier characters. The specifiers apply to other functions as well as UNIX_TIMESTAMP().

    Specifier Description %a Abbreviated weekday name (Sun..Sat) %b Abbreviated month name (Jan..Dec) %c Month, numeric (0..12) %D Day of the month with English suffix (0th, 1st, 2nd, 3rd, \u2026) %d Day of the month, numeric (00..31) %e Day of the month, numeric (0..31) %f Microseconds (000000..999999) %H Hour (00..23) %h Hour (01..12) %I Hour (01..12) %i Minutes, numeric (00..59) %j Day of year (001..366) %k Hour (0..23) %l Hour (1..12) %M Month name (January..December) %m Month, numeric (00..12) %p AM or PM %r Time, 12-hour (hh:mm:ss followed by AM or PM) %S Seconds (00..59) %s Seconds (00..59) %T Time, 24-hour (hh:mm:ss) %U Week (00..53), where Sunday is the first day of the week; WEEK() mode 0 %u Week (00..53), where Monday is the first day of the week; WEEK() mode 1 %V Week (01..53), where Sunday is the first day of the week; WEEK() mode 2; used with %X %v Week (01..53), where Monday is the first day of the week; WEEK() mode 3; used with %x %W Weekday name (Sunday..Saturday) %w Day of the week (0=Sunday..6=Saturday) %X Year for the week where Sunday is the first day of the week, numeric, four digits; used with %V %x Year for the week, where Monday is the first day of the week, numeric, four digits; used with %v %Y Year, numeric, four digits %y Year, numeric (two digits) %% A literal % character %x x, for any \"x\" not listed above"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#examples","title":"Examples","text":"
    mysql> SELECT DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y');\n+--------------------------------------------+\n| date_format(2009-10-04 22:23:00, %W %M %Y) |\n+--------------------------------------------+\n| Sunday October 2009                        |\n+--------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('2007-10-04 22:23:00', '%H:%i:%s');\n+--------------------------------------------+\n| date_format(2007-10-04 22:23:00, %H:%i:%s) |\n+--------------------------------------------+\n| 22:23:00                                   |\n+--------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT Date_format('1900-10-04 22:23:00', '%D %y %a %d %m %b %j');\n+--------------------------------------------------------+\n| date_format(1900-10-04 22:23:00, %D %y %a %d %m %b %j) |\n+--------------------------------------------------------+\n| 4th 00 Thu 04 10 Oct 277                               |\n+--------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('1997-10-04 22:23:00', '%H %k %I %r %T %S %w');\n+--------------------------------------------------------+\n| date_format(1997-10-04 22:23:00, %H %k %I %r %T %S %w) |\n+--------------------------------------------------------+\n| 22 22 10 10:23:00 PM 22:23:00 00 6                     |\n+--------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('1999-01-01', '%X %V');\n+--------------------------------+\n| date_format(1999-01-01, %X %V) |\n+--------------------------------+\n| 1998 52                        |\n+--------------------------------+\n1 row in set (0.00 sec)\n
    CREATE TABLE t2 (f1 DATETIME);\nINSERT INTO t2 (f1) VALUES ('2005-01-01');\nINSERT INTO t2 (f1) VALUES ('2005-02-01');\n\nmysql> SELECT Date_format(f1, \"%m\") AS d1,\nDate_format(f1, \"%m\") AS d2\nFROM   t2\nORDER  BY Date_format(f1, \"%m\");\n+------+------+\n| d1   | d2   |\n+------+------+\n| 01   | 01   |\n| 02   | 02   |\n+------+------+\n2 rows in set (0.00 sec)\n
    CREATE TABLE t5 (a int, b date);\nINSERT INTO t5\nVALUES    (1,\n'2000-02-05'),\n(2,\n'2000-10-08'),\n(3,\n'2005-01-03'),\n(4,\n'2007-09-01'),\n(5,\n'2022-01-01');\n\nmysql> SELECT * FROM   t5\nWHERE  b = Date_format('20000205', '%Y-%m-%d');\n+------+------------+\n| a    | b          |\n+------+------------+\n|    1 | 2000-02-05 |\n+------+------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT * FROM t5\nWHERE  b != Date_format('20000205', '%Y-%m-%d');\n+------+------------+\n| a    | b          |\n+------+------------+\n|    2 | 2000-10-08 |\n|    3 | 2005-01-03 |\n|    4 | 2007-09-01 |\n|    5 | 2022-01-01 |\n+------+------------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT(\"2009-01-01\",'%W %d %M %Y') as valid_date;\n+--------------------------+\n| valid_date               |\n+--------------------------+\n| Thursday 01 January 2009 |\n+--------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#constraints","title":"Constraints","text":"

    The date type supports only yyyy-mm-dd and yyyymmdd for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/","title":"DATE_SUB()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#description","title":"Description","text":"

    The DATE_SUB() function subtracts a time/date interval from a date and then returns the date. If date is NULL, the function returns NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#syntax","title":"Syntax","text":"
    DATE_SUB(date,INTERVAL expr unit)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the date from. expr Required. The expr is an expression specifying the interval value to be added or subtracted from the starting date. The expr is evaluated as a string; it may start with a - for negative intervals. unit Required. The unit is a keyword indicating the units in which the expression should be interpreted. The unit argument can have the following values:MICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#examples","title":"Examples","text":"
    create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT OrderId,DATE_SUB(OrderDate,INTERVAL 5 DAY) AS SubtractDate FROM t2;\n+---------+---------------------+\n| orderid | subtractdate        |\n+---------+---------------------+\n|       1 | 2008-11-06 13:23:45 |\n+---------+---------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#constraints","title":"Constraints","text":"

    The date type supports only yyyy-mm-dd and yyyymmdd for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/","title":"DATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#description","title":"Description","text":"

    Extracts the date part of the date or datetime expression expr.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#syntax","title":"Syntax","text":"
    > DATE(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#arguments","title":"Arguments","text":"Arguments Description expr Required. The date/datetime to extract the date from."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a date, b datetime);\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01');\ninsert into t1 values(20220101,'2022-01-01 01:01:01');\ninsert into t1 values('2022-01-02','2022-01-02 23:01:01');\ninsert into t1 values('2021-12-31','2021-12-30 23:59:59');\ninsert into t1 values('2022-06-30','2021-12-30 23:59:59');\n\nmysql> select date(a),date(b) from t1;\n+------------+------------+\n| date(a)    | date(b)    |\n+------------+------------+\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-02 | 2022-01-02 |\n| 2021-12-31 | 2021-12-30 |\n| 2022-06-30 | 2021-12-30 |\n+------------+------------+\n5 rows in set (0.01 sec)\n\nmysql> select date(a),date(date(a)) as dda from t1;\n+------------+------------+\n| date(a)    | dda        |\n+------------+------------+\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-02 | 2022-01-02 |\n| 2021-12-31 | 2021-12-31 |\n| 2022-06-30 | 2022-06-30 |\n+------------+------------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#constraints","title":"Constraints","text":"

    The date type supports only yyyy-mm-dd and yyyymmdd for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/","title":"DATEDIFF()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#description","title":"Description","text":"

    DATEDIFF() returns expr1 \u2212 expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#syntax","title":"Syntax","text":"
    > DATEDIFF(expr1,expr2)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#arguments","title":"Arguments","text":"Arguments Description expr1,expr2 Required. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#examples","title":"Examples","text":"
    mysql> SELECT DATEDIFF('2007-12-31 23:59:59','2007-12-30');\n+-------------------------------------------+\n| datediff(2007-12-31 23:59:59, 2007-12-30) |\n+-------------------------------------------+\n|                                         1 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATEDIFF('2010-11-30 23:59:59','2010-12-31');\n+-------------------------------------------+\n| datediff(2010-11-30 23:59:59, 2010-12-31) |\n+-------------------------------------------+\n|                                       -31 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n
    create table t1(a INT,  b date);\ninsert into t1 values(1, \"2012-10-11\");\ninsert into t1 values(2, \"2004-04-24\");\ninsert into t1 values(3, \"2008-12-04\");\ninsert into t1 values(4, \"2012-03-23\");\ninsert into t1 values(5, \"2000-03-23\");\ninsert into t1 values(6, \"2030-03-23\");\ninsert into t1 values(7, \"2040-03-23\");\n\nmysql> SELECT a, DATEDIFF('2022-10-9', b) from t1;\n+------+------------------------+\n| a    | datediff(2022-10-9, b) |\n+------+------------------------+\n|    1 |                   3650 |\n|    2 |                   6742 |\n|    3 |                   5057 |\n|    4 |                   3852 |\n|    5 |                   8235 |\n|    6 |                  -2722 |\n|    7 |                  -6375 |\n+------+------------------------+\n7 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/","title":"DAY()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#description","title":"Description","text":"

    Returns the day of the month for date, in the range 1 to 31, or 0 for dates such as 0000-00-00 or 2008-00-00 that have a zero day part. Returns NULL if date is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#syntax","title":"Syntax","text":"
    > DAY(date)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the date from."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#examples","title":"Examples","text":"
    mysql> SELECT day('2007-02-03');\n+-----------------+\n| day(2007-02-03) |\n+-----------------+\n|               3 |\n+-----------------+\n1 row in set (0.01 sec)\n
    CREATE TABLE t3(c1 TIMESTAMP NOT NULL);\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('1999-12-31');\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('2006-12-25');\nINSERT INTO t3 VALUES('2008-02-29');\n\nmysql> SELECT day(c1) from t3;\n+---------+\n| day(c1) |\n+---------+\n|       1 |\n|      31 |\n|       1 |\n|      25 |\n|      29 |\n+---------+\n5 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/","title":"DAYOFYEAR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#description","title":"Description","text":"

    Returns the day of the year for date, in the range 1 to 366.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#syntax","title":"Syntax","text":"
    > DAYOFYEAR(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#arguments","title":"Arguments","text":"Arguments Description expr Required. The date to get the day from. Must be date type."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a date, b datetime,c varchar(30));\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01','2022-01-01 01:01:01');\ninsert into t1 values(20220101,'2022-01-01 01:01:01','2022-13-13 01:01:01');\ninsert into t1 values('2022-01-02','2022-01-02 23:01:01','2022-01-01 23:01:01');\ninsert into t1 values('2021-12-31','2021-12-30 23:59:59','2021-12-30 23:59:59');\ninsert into t1 values('2022-06-30','2021-12-30 23:59:59','2021-12-30 23:59:59');\n\nmysql> select distinct dayofyear(a) as dya from t1;\n+------+\n| dya  |\n+------+\n|    1 |\n|    2 |\n|  365 |\n|  181 |\n+------+\n4 rows in set (0.00 sec)\n\nmysql> select * from t1 where dayofyear(a)>120;\n+------------+---------------------+---------------------+\n| a          | b                   | c                   |\n+------------+---------------------+---------------------+\n| 2021-12-31 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n| 2022-06-30 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n+------------+---------------------+---------------------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t1 where dayofyear(a) between 1 and 184;\n+------------+---------------------+---------------------+\n| a          | b                   | c                   |\n+------------+---------------------+---------------------+\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-01-01 01:01:01 |\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-01-01 01:01:01 |\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-13-13 01:01:01 |\n| 2022-01-02 | 2022-01-02 23:01:01 | 2022-01-01 23:01:01 |\n| 2022-06-30 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n+------------+---------------------+---------------------+\n4 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#constraints","title":"Constraints","text":"
    • DAYOFYEAR() only supports date type for now.
    • The date type supports only yyyy-mm-dd and yyyymmdd for now.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/","title":"EXTRACT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#description","title":"Description","text":"

    The EXTRACT() function uses the same kinds of unit specifiers as DATE_ADD() or DATE_SUB(), but extracts parts from the date rather than performing date arithmetic. Returns NULL if date is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#syntax","title":"Syntax","text":"
    > EXTRACT(unit FROM date)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the date from. unit Required. The unit argument can have the following values:MICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#examples","title":"Examples","text":"
    create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT EXTRACT(YEAR FROM OrderDate) AS OrderYear, EXTRACT(MONTH FROM OrderDate) AS OrderMonth   FROM t2 WHERE OrderId=1;\n+-----------+------------+\n| orderyear | ordermonth |\n+-----------+------------+\n| 2008      | 11         |\n+-----------+------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#constraints","title":"Constraints","text":"

    The date type supports only yyyy-mm-dd and yyyymmdd for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/","title":"FROM_UNIXTIME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#description","title":"Description","text":"

    The FROM_UNIXTIME() function returns a representation of unix_timestamp as a datetime or character string value. The value returned is expressed using the session time zone. For example, the return value is in 'YYYYY-MM-DD HH:MM:SS' format or YYYYMMDDHHMMSS. unix_timestamp is an internal timestamp value representing seconds since 1970-01-01 00:00:00 UTC, such as produced by the UNIX_TIMESTAMP() function.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#syntax","title":"Syntax","text":"
    > FROM_UNIXTIME(unix_timestamp[,format])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#arguments","title":"Arguments","text":"Arguments Description format Optional. A format string indicating the format of the return value. If the format is omitted, this function returns a DATETIME value. If the format is NULL, this function returns NULL.format is used to format the result in the same way as the format string used for the DATE_FORMAT() function. If format is supplied, the value returned is a VARCHAR. unix_timestamp Required. If the unix_timestamp is NULL, this function returns NULL. If the unix_timestamp is an integer, the fractional seconds precision of the DATETIME is zero. When unix_timestamp is a decimal value, the fractional seconds precision of the DATETIME is the same as the precision of the decimal value, up to a maximum of 6. When unix_timestamp is a floating point number, the fractional seconds precision of the datetime is 6."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#examples","title":"Examples","text":"
    mysql> SELECT FROM_UNIXTIME(1447430881);\n+---------------------------+\n| from_unixtime(1447430881) |\n+---------------------------+\n| 2015-11-14 00:08:01       |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FROM_UNIXTIME(1447430881,  '%Y %D %M %h:%i:%s %x');\n+-------------------------------------------------+\n| from_unixtime(1447430881, %Y %D %M %h:%i:%s %x) |\n+-------------------------------------------------+\n| 2015 14th November 12:08:01 2015                |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#constraints","title":"Constraints","text":"

    The date type supports only yyyy-mm-dd and yyyymmdd for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/","title":"HOUR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#description","title":"Description","text":"

    Returns the hour for time. The range of the return value is 0 to 23 for time-of-day values. However, the range of TIME values actually is much larger, so HOUR can return values greater than 23. Returns NULL if time is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#syntax","title":"Syntax","text":"
    > HOUR(time)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#arguments","title":"Arguments","text":"Arguments Description time Required. A value that represents time or timestamp."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select hour(a),hour(b) from t1;\n+---------+---------+\n| hour(a) | hour(b) |\n+---------+---------+\n|       0 |      12 |\n|      12 |       0 |\n|    NULL |      23 |\n|       0 |    NULL |\n|      14 |       0 |\n|       0 |      12 |\n|       0 |       0 |\n+---------+---------+\n7 rows in set (0.00 sec)\n\nmysql> select * from t1 where hour(a)>hour(b);\n+---------------------+---------------------+\n| a                   | b                   |\n+---------------------+---------------------+\n| 2011-01-31 12:32:11 | 1979-10-22 00:00:00 |\n| 2022-06-01 14:11:09 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/","title":"MINUTE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#description","title":"Description","text":"

    Returns the minute for time, in the range 0 to 59, or NULL if time is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#syntax","title":"Syntax","text":"
    > MINUTE(time)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#arguments","title":"Arguments","text":"Arguments Description time Required. A value that represents time or timestamp."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#examples","title":"Examples","text":"
    • Example 1:
    mysql> SELECT MINUTE('2008-02-03 10:05:03');\n+-----------------------------+\n| minute(2008-02-03 10:05:03) |\n+-----------------------------+\n|                           5 |\n+-----------------------------+\n1 row in set (0.00 sec)\n
    • Example 2:
    drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select minute(a),minute(b) from t1;\n+-----------+-----------+\n| minute(a) | minute(b) |\n+-----------+-----------+\n|         0 |         0 |\n|        32 |         0 |\n|      NULL |        10 |\n|         0 |      NULL |\n|        11 |         0 |\n|         0 |         0 |\n|         0 |         0 |\n+-----------+-----------+\n7 rows in set (0.00 sec)\n\nmysql> select * from t1 where minute(a)<=minute(b);\n+---------------------+---------------------+\n| a                   | b                   |\n+---------------------+---------------------+\n| 2022-07-01 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-12-31 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-06-12 00:00:00 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n3 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/","title":"MONTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#description","title":"Description","text":"

    Returns the month for date, in the range 1 to 12 for January to December, or 0 for dates such as '0000-00-00' or '2008-00-00' that have a zero month part. Returns NULL if date is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#syntax","title":"Syntax","text":"
    > MONTH(date)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#arguments","title":"Arguments","text":"Arguments Description date Required. The date to be formatted."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#examples","title":"Examples","text":"
    • Example 1:
    mysql> SELECT MONTH('2008-02-03');\n+-------------------+\n| month(2008-02-03) |\n+-------------------+\n|                 2 |\n+-------------------+\n1 row in set (0.02 sec)\n
    • Example 2:
    drop table if exists t1;\ncreate table t1 (id int,d date, dt datetime,c char(10),vc varchar(20));\ninsert into t1 values (1,\"2021-01-13\", \"2021-01-13 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (1,\"2021-01-31\", \"2021-01-31 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (2,\"2022-02-15\", \"2022-02-15 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (2,\"2022-02-28\", \"2022-02-28 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (3,\"2000-02-29\", \"2000-02-29 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (4,\"2023-03-17\", \"2021-02-17 23:54:59\", \"2021-03-17\", \"2021-03-17\");\ninsert into t1 values (5,\"1985-04-18\", \"1985-04-18 00:00:01\", \"1985-04-18\", \"1985-04-18\");\ninsert into t1 values (6,\"1987-05-20\", \"1987-05-20 22:59:59\", \"1987-05-20\", \"1987-05-20\");\ninsert into t1 values (7,\"1989-06-22\", \"1989-06-22 15:00:30\", \"1989-06-22\", \"1989-06-22\");\ninsert into t1 values (8,\"1993-07-25\", \"1987-07-25 03:04:59\", \"1993-07-25\", \"1993-07-25\");\ninsert into t1 values (9,\"1995-08-27\", \"1987-08-27 04:32:33\", \"1995-08-27\", \"1995-08-27\");\ninsert into t1 values (10,\"1999-09-30\", \"1999-09-30 10:11:12\", \"1999-09-30\", \"1999-09-30\");\ninsert into t1 values (11,\"2005-10-30\", \"2005-10-30 18:18:59\", \"2005-10-30\", \"2005-10-30\");\ninsert into t1 values (12,\"2008-11-30\", \"2008-11-30 22:59:59\", \"2008-11-30\", \"2008-11-30\");\ninsert into t1 values (13,\"2013-12-01\", \"2013-12-01 22:59:59\", \"2013-12-01\", \"2013-12-01\");\ninsert into t1 values (14,null, null, null, null);\n\nmysql> select month(d),month(dt) from t1;\n+----------+-----------+\n| month(d) | month(dt) |\n+----------+-----------+\n|        1 |         1 |\n|        1 |         1 |\n|        2 |         2 |\n|        2 |         2 |\n|        2 |         2 |\n|        3 |         2 |\n|        4 |         4 |\n|        5 |         5 |\n|        6 |         6 |\n|        7 |         7 |\n|        8 |         8 |\n|        9 |         9 |\n|       10 |        10 |\n|       11 |        11 |\n|       12 |        12 |\n|     NULL |      NULL |\n+----------+-----------+\n16 rows in set (0.01 sec)\n\nmysql> select month(c),month(vc) from t1;\n+----------+-----------+\n| month(c) | month(vc) |\n+----------+-----------+\n|       12 |        12 |\n|       12 |        12 |\n|        2 |         2 |\n|        2 |         2 |\n|        2 |         2 |\n|        3 |         3 |\n|        4 |         4 |\n|        5 |         5 |\n|        6 |         6 |\n|        7 |         7 |\n|        8 |         8 |\n|        9 |         9 |\n|       10 |        10 |\n|       11 |        11 |\n|       12 |        12 |\n|     NULL |      NULL |\n+----------+-----------+\n16 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/","title":"SECOND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#description","title":"Description","text":"

    Returns the second for time, in the range 0 to 59, or NULL if time is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#syntax","title":"Syntax","text":"
    > SECOND(time)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#arguments","title":"Arguments","text":"Arguments Description time Required. A value that represents time or timestamp."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select second(a),second(b) from t1;\n+-----------+-----------+\n| second(a) | second(b) |\n+-----------+-----------+\n|         0 |         0 |\n|        11 |         0 |\n|      NULL |        11 |\n|         0 |      NULL |\n|         9 |         0 |\n|         0 |         0 |\n|         0 |         0 |\n+-----------+-----------+\n7 rows in set (0.01 sec)\n\nmysql> select * from t1 where second(a)>=second(b);\n+---------------------+---------------------+\n| a                   | b                   |\n+---------------------+---------------------+\n| 2022-07-01 00:00:00 | 2011-01-31 12:00:00 |\n| 2011-01-31 12:32:11 | 1979-10-22 00:00:00 |\n| 2022-06-01 14:11:09 | 2022-07-01 00:00:00 |\n| 2022-12-31 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-06-12 00:00:00 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/","title":"TIME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#description","title":"Description","text":"

    Extracts the time part of the time or datetime expression expr and returns it as a string. Returns NULL if expr is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#syntax","title":"Syntax","text":"
    > TIME(expr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#arguments","title":"Arguments","text":"Arguments Description expr Required. The date/datetime to extract the time from."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#examples","title":"Examples","text":"
    mysql> SELECT TIME('2003-12-31 01:02:03');\n+---------------------------+\n| time(2003-12-31 01:02:03) |\n+---------------------------+\n| 01:02:03                  |\n+---------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/","title":"TIMEDIFF()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#description","title":"Description","text":"

    TIMEDIFF() returns expr1 \u2212 expr2 expressed as a time value.

    The result returned by TIMEDIFF() is limited to the range allowed for TIME values. Alternatively, you can use either of the functions TIMESTAMPDIFF() and UNIX_TIMESTAMP(), both of which return integers.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#syntax","title":"Syntax","text":"
    > TIMEDIFF(expr1,expr2)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#arguments","title":"Arguments","text":"Arguments Description expr1,expr2 Required. expr1 and expr2 are strings which are converted to TIME or DATETIME expressions; these must be of the same type following conversion. Returns NULL if expr1 or expr2 is NULL."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#examples","title":"Examples","text":"
    mysql> select timediff(\"22:22:22\", \"11:00:00\");\n+------------------------------+\n| timediff(22:22:22, 11:00:00) |\n+------------------------------+\n| 11:22:22.000000              |\n+------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select timediff(cast('22:22:22' as time), null);\n+--------------------------------------------+\n| timediff(cast(22:22:22 as time(26)), null) |\n+--------------------------------------------+\n| NULL                                       |\n+--------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select timediff(CAST('2017-08-08 22:22:22' as datetime), CAST('2000-01-02 11:00:00' as datetime));\n+------------------------------------------------------------------------------------------------+\n| timediff(cast(2017-08-08 22:22:22 as datetime(26)), cast(2000-01-02 11:00:00 as datetime(26))) |\n+------------------------------------------------------------------------------------------------+\n| 154283:22:22                                                                                   |\n+------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
    create table time_01(t1 time,t2 time,t3 time);\ninsert into time_01 values(\"-838:59:59.0000\",\"838:59:59.00\",\"22:00:00\");\ninsert into time_01 values(\"0:00:00.0000\",\"0\",\"0:00\");\ninsert into time_01 values(null,NULL,null);\ninsert into time_01 values(\"23\",\"1122\",\"-1122\");\ninsert into time_01 values(\"101412\",\"4\",\"-101219\");\ninsert into time_01 values(\"24:59:09.932823\",\"24:02:00.93282332424\",\"24:20:34.00000000\");\ninsert into time_01 values(\"2022-09-08 12:00:01\",\"019\",\"23403\");\n\nmysql> select * from time_01;\n+------------+-----------+-----------+\n| t1         | t2        | t3        |\n+------------+-----------+-----------+\n| -838:59:59 | 838:59:59 | 22:00:00  |\n| 00:00:00   | 00:00:00  | 00:00:00  |\n| NULL       | NULL      | NULL      |\n| 00:00:23   | 00:11:22  | -00:11:22 |\n| 10:14:12   | 00:00:04  | -10:12:19 |\n| 24:59:10   | 24:02:01  | 24:20:34  |\n| 12:00:01   | 00:00:19  | 02:34:03  |\n+------------+-----------+-----------+\n7 rows in set (0.00 sec)\n\nmysql> select timediff(t1,t2) from time_01;\n+------------------+\n| timediff(t1, t2) |\n+------------------+\n| -1677:59:58      |\n| 00:00:00         |\n| NULL             |\n| -00:10:59        |\n| 10:14:08         |\n| 00:57:09         |\n| 11:59:42         |\n+------------------+\n7 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/","title":"TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#description","title":"Description","text":"

    With a single argument, this function returns the date or datetime expression expr as a datetime value. With two arguments, it adds the time expression expr2 to the date or datetime expression expr1 and returns the result as a datetime value. Returns NULL if expr, expr1, or expr2 is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#syntax","title":"Syntax","text":"
    > TIMESTAMP(expr), TIMESTAMP(expr1,expr2)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#arguments","title":"Arguments","text":"Arguments Description expr Required. The expr is an expression specifying the interval value to be added or subtracted from the starting date. The expr is evaluated as a string; it may start with a - for negative intervals."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#examples","title":"Examples","text":"
    mysql> SELECT TIMESTAMP('2003-12-31');\n+----------------------------+\n| timestamp(2003-12-31)      |\n+----------------------------+\n| 2003-12-31 00:00:00.000000 |\n+----------------------------+\n1 row in set (0.00 sec)\n
    CREATE TABLE t1(c1 DATE NOT NULL);\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('1999-12-31');\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('2006-12-25');\nINSERT INTO t1 VALUES('2008-02-29');\n\nmysql> SELECT TIMESTAMP(c1) FROM t1;\n+----------------------------+\n| timestamp(c1)              |\n+----------------------------+\n| 2000-01-01 00:00:00.000000 |\n| 1999-12-31 00:00:00.000000 |\n| 2000-01-01 00:00:00.000000 |\n| 2006-12-25 00:00:00.000000 |\n| 2008-02-29 00:00:00.000000 |\n+----------------------------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#constraints","title":"Constraints","text":"

    TIMESTAMP() does not support double arguments for now, which means it doesn't support TIMESTAMP(expr1,expr2).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/","title":"TIMESTAMPDIFF()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#description","title":"Description","text":"

    Returns datetime_expr2 \u2212 datetime_expr1, where datetime_expr1 and datetime_expr2 are date or datetime expressions. One expression may be a date and the other a datetime; a date value is treated as a datetime having the time part '00:00:00' where necessary. The unit for the result (an integer) is given by the unit argument. The legal values for unit are the same as those listed in the description of the TIMESTAMPADD() function.

    This function returns NULL if datetime_expr1 or datetime_expr2 is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#syntax","title":"Syntax","text":"
    > TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#arguments","title":"Arguments","text":"Arguments Description unit is a string representing the unit of the time interval. This can be MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH or YEAR etc. datetime_expr1,datetime_expr2 Mandatory parameters. datetime_expr1 and datetime_expr2 expressions need to be of the same type. datetime_expr1 and datetime_expr2 are strings converted to TIME or DATETIME expressions. Returns NULL if datetime_expr1 or datetime_expr2 is NULL."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#examples","title":"Examples","text":"
    • Example 1:
    mysql> SELECT TIMESTAMPDIFF( MICROSECOND, '2017-12-01 12:15:12','2018-01-01 7:18:20');\n+---------------------------------------------------------------------+\n| timestampdiff(microsecond, 2017-12-01 12:15:12, 2018-01-01 7:18:20) |\n+---------------------------------------------------------------------+\n|                                                       2660588000000 |\n+---------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
    • Example 2:
    drop table if exists t1;\ncreate table t1(a date,  b date);\ninsert into t1 values('2019-11-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2019-10-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2020-10-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2021-11-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2022-01-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2018-01-01 12:15:12', '2019-11-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2019-10-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2020-10-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2021-11-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2022-01-01 12:15:12');\n\nmysql> SELECT a, b, TIMESTAMPDIFF(MICROSECOND, a, b) from t1;\n+------------+------------+----------------------------------+\n| a          | b          | timestampdiff(microsecond, a, b) |\n+------------+------------+----------------------------------+\n| 2019-11-01 | 2018-01-01 |                  -57801600000000 |\n| 2019-10-01 | 2018-01-01 |                  -55123200000000 |\n| 2020-10-01 | 2018-01-01 |                  -86745600000000 |\n| 2021-11-01 | 2018-01-01 |                 -120960000000000 |\n| 2022-01-01 | 2018-01-01 |                 -126230400000000 |\n| 2018-01-01 | 2019-11-01 |                   57801600000000 |\n| 2018-01-01 | 2019-10-01 |                   55123200000000 |\n| 2018-01-01 | 2020-10-01 |                   86745600000000 |\n| 2018-01-01 | 2021-11-01 |                  120960000000000 |\n| 2018-01-01 | 2022-01-01 |                  126230400000000 |\n+------------+------------+----------------------------------+\n10 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/","title":"TO_DATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#description","title":"Description","text":"

    TO_DATE() returns a DATETIME value if the format string contains both date and time parts, or a DATE or TIME value if the string contains only date or time parts.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#syntax","title":"Syntax","text":"
    > TO_DATE(str,format)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#arguments","title":"Arguments","text":"Arguments Description str Required. If the date, time, or datetime value extracted from str is illegal, STR_TO_DATE() returns NULL and produces a warning. If str is NULL, the function returns NULL. format Required. A format string indicating the format of the return value. If the format is omitted, this function returns a DATETIME value. If the format is NULL, this function returns NULL.If the format is supplied, the value returned is a VARCHAR.

    note

    The format string can contain literal characters and format specifiers beginning with %. Literal characters in format must match literally in str. Format specifiers in format must match a date or time part in str.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#examples","title":"Examples","text":"
    mysql> SELECT TO_DATE('2022-01-06 10:20:30','%Y-%m-%d %H:%i:%s') as result;\n+---------------------+\n| result              |\n+---------------------+\n| 2022-01-06 10:20:30 |\n+---------------------+\n1 row in set (0.00 sec)                 
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#constraints","title":"Constraints","text":"

    The date type supports only yyyy-mm-dd and yyyymmdd for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/","title":"TO_DAYS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#description","title":"Description","text":"

    TO_DAYS() is used to calculate the number of days between a given date and the start date of the Gregorian calendar (January 1, 0000). If the date is NULL, it returns NULL.

    Note

    The dates '0000-00-00' and '0000-01-01' are considered invalid. When querying 0000-00-00 and 0000-01-01, TO_DAYS() will return an error message:

    mysql> SELECT TO_DAYS('0000-00-00');\nERROR 20301 (HY000): invalid input: invalid datetime value 0000-00-00\nmysql> SELECT TO_DAYS('0000-01-01');\nERROR 20301 (HY000): invalid input: invalid datetime value 0000-01-01\n

    For dates with two-digit years, for example, when querying SELECT TO_DAYS('08-10-07');, MatrixOne automatically completes the year 08 to 0008, which is different from MySQL. For more information, see Two-Digit Years in Dates

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#syntax","title":"Syntax","text":"
    > TO_DAYS(date)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#examples","title":"Examples","text":"
    -- The query will return an integer representing the number of days between the date '2023-07-12' and the start date of the Gregorian calendar.\nmysql> SELECT TO_DAYS('2023-07-12');\n+---------------------+\n| to_days(2023-07-12) |\n+---------------------+\n|              739078 |\n+---------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_DAYS('2008-10-07'), TO_DAYS('08-10-07');\n+---------------------+-------------------+\n| to_days(2008-10-07) | to_days(08-10-07) |\n+---------------------+-------------------+\n|              733687 |              3202 |\n+---------------------+-------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/","title":"TO_SECONDS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/#description","title":"Description","text":"

    The TO_SECONDS(expr) function is used to calculate the number of seconds between a given date or datetime expr and the year 0, January 1, 00:00:00. If expr is NULL, it returns NULL.

    Note

    The dates 0000-00-00 and 0000-01-01 are considered invalid. MatrixOne year queries should start from 0001. When querying 0000-00-00 and 0000-01-01, TO_SECONDS() returns an error message:

    mysql> SELECT TO_SECONDS('0000-00-00');\nERROR 20301 (HY000): invalid input: invalid datetime value 0000-00-00\nmysql> SELECT TO_SECONDS('0000-01-01');\nERROR 20301 (HY000): invalid input: invalid datetime value 0000-01-01\n

    Similar to the TO_DAYS() function, for example, when querying SELECT TO_SECONDS('08-10-07');, MatrixOne automatically fills the year 08 to 0008, which is different from MySQL. For more information, see Two-Digit Years in Dates.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/#syntax","title":"Syntax","text":"
    > TO_SECONDS(expr)\n

    expr is a date or datetime value and can be of type DATETIME, DATE, or TIMESTAMP.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/#examples","title":"Examples","text":"
    mysql> SELECT TO_SECONDS('0001-01-01');\n+------------------------+\n| to_seconds(0001-01-01) |\n+------------------------+\n|               31622400 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('2023-07-12 08:30:00');\n+---------------------------------+\n| to_seconds(2023-07-12 08:30:00) |\n+---------------------------------+\n|                     63856369800 |\n+---------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('2007-10-07');\n+------------------------+\n| to_seconds(2007-10-07) |\n+------------------------+\n|            63358934400 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('97-10-07');\n+----------------------+\n| to_seconds(97-10-07) |\n+----------------------+\n|           3085257600 |\n+----------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/","title":"UNIX_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#description","title":"Description","text":"

    If UNIX_TIMESTAMP() is called with no date argument, it returns a Unix timestamp representing seconds since '1970-01-01 00:00:00' UTC.

    If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' UTC. The server interprets date as a value in the session time zone and converts it to an internal Unix timestamp value in UTC.

    If you pass an out-of-range date to UNIX_TIMESTAMP(), it returns 0. If date is NULL, it returns NULL.

    The return value is an integer if no argument is given or the argument does not include a fractional seconds part, or DECIMAL if an argument is given that includes a fractional seconds part.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#syntax","title":"Syntax","text":"
    > UNIX_TIMESTAMP([date])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#arguments","title":"Arguments","text":"Arguments Description date Optional. The date/datetime to extract the date from. The date argument may be a DATE, DATETIME, or TIMESTAMP string, or a number in YYMMDD, YYMMDDhhmmss, YYYYMMDD, or YYYYMMDDhhmmss format. If the argument includes a time part, it may optionally include a fractional seconds part. When the date argument is a TIMESTAMP column, UNIX_TIMESTAMP() returns the internal timestamp value directly, with no implicit string-to-Unix-timestamp conversion."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#convert-between-non-utc-time-zone-and-unix-timestamp-values","title":"Convert between non-UTC time zone and Unix timestamp values","text":"

    If you use UNIX_TIMESTAMP() and FROM_UNIXTIME() to convert between values in a non-UTC time zone and Unix timestamp values, the conversion is lossy because the mapping is not one-to-one in both directions. For example, due to conventions for local time zone changes such as Daylight Saving Time (DST), it is possible for UNIX_TIMESTAMP() to map two values that are distinct in a non-UTC time zone to the same Unix timestamp value. FROM_UNIXTIME() maps that value back to only one of the original values. Here is an example, using values that are distinct in the MET time zone:

    mysql> SET time_zone = 'MET';\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2005-03-27 03:00:00');\n+-------------------------------------+\n| unix_timestamp(2005-03-27 03:00:00) |\n+-------------------------------------+\n|                          1111885200 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2005-03-27 02:00:00');\n+-------------------------------------+\n| unix_timestamp(2005-03-27 02:00:00) |\n+-------------------------------------+\n|                          1111885200 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FROM_UNIXTIME(1111885200);\n+---------------------------+\n| from_unixtime(1111885200) |\n+---------------------------+\n| 2005-03-27 03:00:00       |\n+---------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#examples","title":"Examples","text":"
    mysql> SELECT UNIX_TIMESTAMP(\"2016-07-11\");\n+----------------------------+\n| unix_timestamp(2016-07-11) |\n+----------------------------+\n|                 1468188000 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2015-11-13 10:20:19');\n+-------------------------------------+\n| unix_timestamp(2015-11-13 10:20:19) |\n+-------------------------------------+\n|                          1447406419 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2015-11-13 10:20:19.012');\n+-----------------------------------------+\n| unix_timestamp(2015-11-13 10:20:19.012) |\n+-----------------------------------------+\n|                       1447406419.012000 |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#constraints","title":"Constraints","text":"

    The date type supports only yyyy-mm-dd and yyyymmdd for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/","title":"UTC_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#description","title":"Description","text":"

    Returns the current UTC date and time as a value in YYYY-MM-DD hh:mm:ss or YYYYMMDDhhmmss format, depending on whether the function is used in string or numeric context.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#syntax","title":"Syntax","text":"
    > UTC_TIMESTAMP, UTC_TIMESTAMP([fsp])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#arguments","title":"Arguments","text":"Arguments Description fsp Optional. If the fsp argument is given to specify a fractional seconds precision from 0 to 6, the return value includes a fractional seconds part of that many digits."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#examples","title":"Examples","text":"
    • Example 1:
    mysql> SELECT UTC_TIMESTAMP();\n+---------------------+\n| utc_timestamp()     |\n+---------------------+\n| 2022-09-16 03:37:40 |\n+---------------------+\n1 row in set (0.01 sec)\n\nmysql> select unix_timestamp(utc_timestamp());\n+---------------------------------+\n| unix_timestamp(utc_timestamp()) |\n+---------------------------------+\n|                      1663282842 |\n+---------------------------------+\n1 row in set (0.02 sec)\n
    • Example 2:
    create table t1 (ts timestamp);\nset time_zone='+00:00';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());\n+-------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(utc_timestamp()) |\n+-------------------------------------------------------------------+\n|                                                                 0 |\n+-------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\nset time_zone='+10:30';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());\n+-------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(utc_timestamp()) |\n+-------------------------------------------------------------------+\n|                                                                 0 |\n+-------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\nset time_zone='-10:00';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp());\n+-----------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(current_timestamp()) |\n+-----------------------------------------------------------------------+\n|                                                                 36000 |\n+-----------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\n\nmysql> select * from t1;\n+---------------------+\n| ts                  |\n+---------------------+\n| 2003-03-29 16:30:00 |\n| 2003-03-29 06:00:00 |\n| 2003-03-30 02:30:00 |\n+---------------------+\n3 rows in set (0.00 sec)\n
    • Example 3:
    DROP TABLE IF EXISTS t1;\nCREATE TABLE t1 (a TIMESTAMP);\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\n\nmysql> SELECT year(a) FROM t1 WHERE a > '2008-01-01';\n+---------+\n| year(a) |\n+---------+\n|    2022 |\n|    2022 |\n|    2022 |\n+---------+\n3 rows in set (0.04 sec)\n
    DROP TABLE if exists t1;\ncreate table t1 (a int primary key, b int, c int, d timestamp);\ninsert into t1 select 1,1,1,utc_timestamp();\ninsert into t1 select 2,0,0,null;\n\nmysql> select a,b,c,year(d) from t1;\n+------+------+------+---------+\n| a    | b    | c    | year(d) |\n+------+------+------+---------+\n|    1 |    1 |    1 |    2022 |\n|    2 |    0 |    0 |    NULL |\n+------+------+------+---------+\n2 rows in set (0.01 sec)\n
    DROP TABLE if exists t1;\nCREATE TABLE t1 (a TIMESTAMP);\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\n\nmysql> SELECT 1 FROM t1 ORDER BY 1;\n+------+\n| 1    |\n+------+\n|    1 |\n|    1 |\n+------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#constraints","title":"Constraints","text":"

    Operator + or - with parameters DATETIME BIGINT is not supported now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/","title":"WEEK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#description","title":"Description","text":"

    Used to calculate the week number for a given date. This function returns an integer representing the week number of the specified date. If date is NULL, return NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#syntax","title":"Syntax","text":"
    > WEEK(date)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#arguments","title":"Arguments","text":"Arguments Description date Required. date represents the date to calculate the week number. MatrixOne defaults the start day of the week to Monday, and the return value ranges from 0 to 53."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#examples","title":"Examples","text":"
    • Example 1:
    mysql> SELECT WEEK('2008-02-20');\n+------------------+\n| week(2008-02-20) |\n+------------------+\n|                8 |\n+------------------+\n1 row in set (0.01 sec)\n
    • Example 2:
    drop table if exists t1;\nCREATE TABLE t1(c1 DATETIME NOT NULL);\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('1999-12-31');\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('2006-12-25');\nINSERT INTO t1 VALUES('2008-02-29');\n\nmysql> SELECT WEEK(c1) FROM t1;\n+----------+\n| week(c1) |\n+----------+\n|       52 |\n|       52 |\n|       52 |\n|       52 |\n|        9 |\n+----------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#constraints","title":"Constraints","text":"

    The WEEK() function of MatrixOne only supports the date parameter, and does not support the optional parameter [, mode], which is different from MySQL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/","title":"WEEKDAY()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#description","title":"Description","text":"

    Returns the weekday index for date (0 = Monday, 1 = Tuesday, \u2026 6 = Sunday). Returns NULL if date is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#syntax","title":"Syntax","text":"
    > WEEKDAY(date)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#arguments","title":"Arguments","text":"Arguments Description date Required. The date to be formatted."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#examples","title":"Examples","text":"
    • Example 1:
    mysql> SELECT WEEKDAY('2008-02-03 22:23:00');\n+------------------------------+\n| weekday(2008-02-03 22:23:00) |\n+------------------------------+\n|                            6 |\n+------------------------------+\n1 row in set (0.03 sec)\n
    • Example 2:
    drop table if exists t1;\ncreate table t1 (id int,d date, dt datetime,c char(10),vc varchar(20));\ninsert into t1 values (1,\"2021-01-13\", \"2021-01-13 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (1,\"2021-01-31\", \"2021-01-31 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (2,\"2022-02-15\", \"2022-02-15 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (2,\"2022-02-28\", \"2022-02-28 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (3,\"2000-02-29\", \"2000-02-29 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (4,\"2023-03-17\", \"2021-02-17 23:54:59\", \"2021-03-17\", \"2021-03-17\");\ninsert into t1 values (5,\"1985-04-18\", \"1985-04-18 00:00:01\", \"1985-04-18\", \"1985-04-18\");\ninsert into t1 values (6,\"1987-05-20\", \"1987-05-20 22:59:59\", \"1987-05-20\", \"1987-05-20\");\ninsert into t1 values (7,\"1989-06-22\", \"1989-06-22 15:00:30\", \"1989-06-22\", \"1989-06-22\");\ninsert into t1 values (8,\"1993-07-25\", \"1987-07-25 03:04:59\", \"1993-07-25\", \"1993-07-25\");\ninsert into t1 values (9,\"1995-08-27\", \"1987-08-27 04:32:33\", \"1995-08-27\", \"1995-08-27\");\ninsert into t1 values (10,\"1999-09-30\", \"1999-09-30 10:11:12\", \"1999-09-30\", \"1999-09-30\");\ninsert into t1 values (11,\"2005-10-30\", \"2005-10-30 18:18:59\", \"2005-10-30\", \"2005-10-30\");\ninsert into t1 values (12,\"2008-11-30\", \"2008-11-30 22:59:59\", \"2008-11-30\", \"2008-11-30\");\ninsert into t1 values (13,\"2013-12-01\", \"2013-12-01 22:59:59\", \"2013-12-01\", \"2013-12-01\");\ninsert into t1 values (14,null, null, null, null);\n\nmysql> select weekday(d),weekday(dt) from t1;\n+------------+-------------+\n| weekday(d) | weekday(dt) |\n+------------+-------------+\n|          2 |           2 |\n|          6 |           6 |\n|          1 |           1 |\n|          0 |           0 |\n|          1 |           1 |\n|          4 |           2 |\n|          3 |           3 |\n|          2 |           2 |\n|          3 |           3 |\n|          6 |           5 |\n|          6 |           3 |\n|          3 |           3 |\n|          6 |           6 |\n|          6 |           6 |\n|          6 |           6 |\n|       NULL |        NULL |\n+------------+-------------+\n16 rows in set (0.01 sec)\n\nmysql> select weekday(c),weekday(vc) from t1;\n+------------+-------------+\n| weekday(c) | weekday(vc) |\n+------------+-------------+\n|          2 |           3 |\n|          2 |           3 |\n|          0 |           0 |\n|          0 |           0 |\n|          0 |           0 |\n|          2 |           2 |\n|          3 |           3 |\n|          2 |           2 |\n|          3 |           3 |\n|          6 |           6 |\n|          6 |           6 |\n|          3 |           3 |\n|          6 |           6 |\n|          6 |           6 |\n|          6 |           6 |\n|       NULL |        NULL |\n+------------+-------------+\n16 rows in set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/","title":"YEAR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#description","title":"Description","text":"

    The YEAR() or TOYEAR() function returns the year part for a given date (a number from 1000 to 9999).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#syntax","title":"Syntax","text":"
    > YEAR(date)\n> TOYEAR(date)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the year from"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a date, b datetime);\ninsert into t1 values('20211223','2021-10-22 09:23:23');\ninsert into t1 values('2021-12-23','2021-10-22 00:23:23');\n\nmysql> select year(a) from t1;\n+---------+\n| year(a) |\n+---------+\n|    2021 |\n|    2021 |\n+---------+\n2 rows in set (0.00 sec)\n
    DROP TABLE IF EXISTS t3;\nCREATE TABLE t3(c1 DATE NOT NULL);\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('1999-12-31');\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('2006-12-25');\nINSERT INTO t3 VALUES('2008-02-29');\nmysql> SELECT YEAR(c1) FROM t3;\n+----------+\n| year(c1) |\n+----------+\n|     2000 |\n|     1999 |\n|     2000 |\n|     2006 |\n|     2008 |\n+----------+\n5 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#constraints","title":"Constraints","text":"

    The date type supports only yyyy-mm-dd and yyyymmdd for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/","title":"JSON Functions","text":"

    MatrixOne supports the following JSON functions:

    Name Description JSON_EXTRACT() Return data from JSON document JSON_QUOTE() Quote JSON document JSON_UNQUOTE() Unquote JSON value"},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_extract","title":"JSON_EXTRACT()","text":"

    A JSON path expression selects a value within a JSON document.

    Path expressions are useful with functions that extract parts of or modify a JSON document, to specify where within that document to operate. For example, the following query extracts from a JSON document the value of the member with the name key:

    mysql> SELECT JSON_EXTRACT('{\"id\": 14, \"name\": \"Aztalan\"}', '$.name');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"id\": 14, \"name\": \"Aztalan\"}', '$.name') |\n+---------------------------------------------------------+\n| \"Aztalan\"                                               |\n+---------------------------------------------------------+\n

    Path syntax uses a leading $ character to represent the JSON document under consideration, optionally followed by selectors that indicate successively more specific parts of the document:

    • A period followed by a key name names the member in an object with the given key. The key name must be specified within double quotation marks if the name without quotes is not legal within path expressions (for example, if it contains a space).

    • [N] appended to a path that selects an array names the value at position N within the array. Array positions are integers beginning with zero. If the array is negative, an error is generated.

    • Paths can contain * or ** wildcards:

      • .[*] evaluates to the values of all members in a JSON object.

      • [*] evaluates to the values of all elements in a JSON array.

      • prefix**suffix evaluates to all paths that begin with the named prefix and end with the named suffix.

    • A path that does not exist in the document (evaluates to nonexistent data) evaluates to NULL.

    Example:

    [3, {\"a\": [5, 6], \"b\": 10}, [99, 100]]\n
    • $[0] evaluates to 3.

    • $[1] evaluates to {\"a\": [5, 6], \"b\": 10}.

    • $[2] evaluates to [99, 100].

    • $[3] evaluates to NULL (it refers to the fourth array element, which does not exist).

    Because $[1] and $[2] evaluate to nonscalar values, they can be used as the basis for more-specific path expressions that select nested values. Examples:

    • $[1].a evaluates to [5, 6].

    • $[1].a[1] evaluates to 6.

    • $[1].b evaluates to 10.

    • $[2][0] evaluates to 99.

    As mentioned previously, path components that name keys must be quoted if the unquoted key name is not legal in path expressions. Let $ refer to this value:

    {\"a fish\": \"shark\", \"a bird\": \"sparrow\"}\n

    The keys both contain a space and must be quoted:

    • $.\"a fish\" evaluates to shark.

    • $.\"a bird\" evaluates to sparrow.

    Paths that use wildcards evaluate to an array that can contain multiple values:

    mysql> SELECT JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.*');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.*') |\n+---------------------------------------------------------+\n| [1, 2, [3, 4, 5]]                                       |\n+---------------------------------------------------------+\n\nmysql> SELECT JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.c[*]');\n+------------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.c[*]') |\n+------------------------------------------------------------+\n| [3, 4, 5]                                                  |\n+------------------------------------------------------------+\n

    In the following example, the path $**.b evaluates to multiple paths ($.a.b and $.c.b) and produces an array of the matching path values:

    mysql> SELECT JSON_EXTRACT('{\"a\": {\"b\": 1}, \"c\": {\"b\": 2}}', '$**.b');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": {\"b\": 1}, \"c\": {\"b\": 2}}', '$**.b') |\n+---------------------------------------------------------+\n| [null, 1, 2]                                                  |\n+---------------------------------------------------------+\n

    In the following example, showes the querying JSON values from columns:

    CREATE table t1 (a json,b int);\nINSERT into t1(a,b) values ('{\"a\":1,\"b\":2,\"c\":3}',1);\n\nmysql> SELECT json_extract(t1.a,'$.a') from t1 where t1.b=1;\n+-------------------------+\n| json_extract(t1.a, $.a) |\n+-------------------------+\n| 1                       |\n+-------------------------+\n1 row in set (0.00 sec)\n\nINSERT into t1(a,b) values ('{\"a\":4,\"b\":5,\"c\":6}',2);\n\nmysql> SELECT json_extract(t1.a,'$.b') from t1 where t1.b=2;\n+-------------------------+\n| json_extract(t1.a, $.b) |\n+-------------------------+\n| 5                       |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT json_extract(t1.a,'$.a') from t1;\n+-------------------------+\n| json_extract(t1.a, $.a) |\n+-------------------------+\n| 1                       |\n| 4                       |\n+-------------------------+\n2 rows in set (0.00 sec)\n\nINSERT into t1(a,b) values ('{\"a\":{\"q\":[1,2,3]}}',3);\n\nmysql> SELECT json_extract(t1.a,'$.a.q[1]') from t1 where t1.b=3;\n+------------------------------+\n| json_extract(t1.a, $.a.q[1]) |\n+------------------------------+\n| 2                            |\n+------------------------------+\n1 row in set (0.01 sec)\n\nINSERT into t1(a,b) values ('[{\"a\":1,\"b\":2,\"c\":3},{\"a\":4,\"b\":5,\"c\":6}]',4);\n\nmysql> SELECT json_extract(t1.a,'$[1].a') from t1 where t1.b=4;\n+----------------------------+\n| json_extract(t1.a, $[1].a) |\n+----------------------------+\n| 4                          |\n+----------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_quote","title":"JSON_QUOTE()","text":"

    The JSON_QUOTE function converts a string value into a string in JSON format. It wraps the string with double quotes, escapes inner quotes and other characters, quotes the string as a JSON value, and then returns the result as a utf8mb4 string. If the parameter is NULL, it returns NULL.

    The JSON_QUOTE function is commonly used to generate valid JSON strings to include in JSON documents.

    The syntax structure is: select JSON_QUOTE(string_value);

    string_value is the string to be converted to a JSON string. The function returns a string in JSON format, where the original string is surrounded by quotes and properly escaped.

    Example:

    mysql> SELECT JSON_QUOTE('null'), JSON_QUOTE('\"null\"');\n+------------------+--------------------+\n| json_quote(null) | json_quote(\"null\") |\n+------------------+--------------------+\n| \"null\"           | \"\\\"null\\\"\"         |\n+------------------+--------------------+\n1 row in set (0.00 sec)\nmysql> SELECT JSON_QUOTE('[1, 2, 3]');\n+-----------------------+\n| json_quote([1, 2, 3]) |\n+-----------------------+\n| \"[1, 2, 3]\"           |\n+-----------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT JSON_QUOTE('hello world');\n+-------------------------+\n| json_quote(hello world) |\n+-------------------------+\n| \"hello world\"           |\n+-------------------------+\n1 row in set (0.00 sec)\n

    As we can see, the original string is surrounded by quotes, and the double quotes within the string are escaped. This allows it to be used in JSON format, such as as a property value in a JSON object.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_unquote","title":"JSON_UNQUOTE()","text":"

    The JSON_UNQUOTE() function extracts an unquoted JSON value from a JSON string and returns it as a string.

    Specifically, the JSON_UNQUOTE() function takes a JSON string as input, extracts a JSON value from it, and returns it as a string. If the input JSON string does not contain a valid JSON value or the parameter is NULL, the function returns NULL. An error occurs if the value begins and ends with double quotes but is not a valid JSON string literal.

    The syntax structure: select JSON_UNQUOTE(string_value);

    In the string, specific sequences have special meanings and start with a backslash (), known as escape characters, with the following rules. For example, \\b is interpreted as backspace, while \\B is interpreted as B. For all other escape sequences, the backslash is ignored. That is, the escape character is interpreted as unescaped. For example, \\x is just x. These sequences are case-sensitive.

    Escape Sequence Character Represented by Sequence \\\" A double quote (\") character \\b A backspace character \\f A formfeed character \\n A newline (linefeed) character \\r A carriage return character \\t A tab character \\ A backslash () character \\uXXXX UTF-8 bytes for Unicode value XXXX

    Example:

    mysql> SET @j = '\"abc\"';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT @j, JSON_UNQUOTE(@j);\n+-------+------------------+\n| @j    | json_unquote(@j) |\n+-------+------------------+\n| \"abc\" | abc              |\n+-------+------------------+\n1 row in set (0.00 sec)\n\nmysql> SET @j = '[1, 2, 3]';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT @j, JSON_UNQUOTE(@j);\n+-----------+------------------+\n| @j        | json_unquote(@j) |\n+-----------+------------------+\n| [1, 2, 3] | [1, 2, 3]        |\n+-----------+------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT JSON_UNQUOTE('\"\\\\t\\\\u0032\"');\n+----------------------------+\n| json_unquote(\"\\\\t\\\\u0032\") |\n+----------------------------+\n|       2                         |\n+----------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/","title":"ABS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#description","title":"Description","text":"

    ABS(X) Returns the absolute value of X, or NULL if X is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#syntax","title":"Syntax","text":"
    > ABS(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now.

    The result type is derived from the argument type.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,-3.1416);\ninsert into t1 values(-1,1.57);\n\nmysql> select abs(a),abs(b) from t1;\n+--------+--------------------+\n| abs(a) | abs(b)             |\n+--------+--------------------+\n|      1 | 3.1415998935699463 |\n|      1 | 1.5700000524520874 |\n+--------+--------------------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/","title":"ACOS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#description","title":"Description","text":"

    The ACOS() function returns the arccosine(given in radians) of the input number.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#syntax","title":"Syntax","text":"
    > ACOS(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a float,b int);\ninsert into t1 values(0.5,1);\ninsert into t1 values(-0.5,-1);\n\nmysql> select acos(a),acos(b) from t1;\n+--------------------+-------------------+\n| acos(a)            | acos(b)           |\n+--------------------+-------------------+\n| 1.0471975511965976 |                 0 |\n| 2.0943951023931957 | 3.141592653589793 |\n+--------------------+-------------------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/","title":"ATAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#description","title":"Description","text":"

    The ATAN() function returns the arctangent(given in radians) of the input number.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#syntax","title":"Syntax","text":"
    > ATAN(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(0,1);\n\nmysql> select atan(a),atan(tan(b)) from t1;\n+--------------------+--------------------------+\n| atan(a)            | atan(tan(b))             |\n+--------------------+--------------------------+\n| 0.7853981633974483 | -0.000002535181590113463 |\n|                  0 |                        1 |\n+--------------------+--------------------------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/","title":"CEIL()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#description","title":"Description","text":"

    The CEIL(X) function returns the smallest integer value not less than X.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#syntax","title":"Syntax","text":"
    > CEIL(X)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#arguments","title":"Arguments","text":"Arguments Description X Required. Any numeric data type supported now.

    For exact-value numeric arguments, the return value has an exact-value numeric type. For floating-point arguments, the return value has a floating-point type.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,ceil(b) from t1;\n+------+---------+\n| a    | ceil(b) |\n+------+---------+\n|    1 |       1 |\n|    2 |       1 |\n|    3 |       1 |\n|    4 |      21 |\n|    5 |      21 |\n|    6 |      14 |\n|    7 |      -0 |\n|    8 |      -0 |\n|    9 |      -0 |\n|   10 |     -20 |\n|   11 |     -20 |\n|   12 |     -13 |\n+------+---------+\n12 rows in set (0.01 sec)\n\nmysql> select sum(ceil(b)) from t1;\n+--------------+\n| sum(ceil(b)) |\n+--------------+\n|            6 |\n+--------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/","title":"COS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#description","title":"Description","text":"

    The COS() function returns the cosine of input number(given in radians).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#syntax","title":"Syntax","text":"
    > COS(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,1.57);\n\nmysql> select cos(a),cos(b) from t1;\n+--------------------+----------------------+\n| cos(a)             | cos(b)               |\n+--------------------+----------------------+\n| 0.5403023058681398 |  -0.9999999999967865 |\n| 0.5403023058681398 | 0.000796274258662553 |\n+--------------------+----------------------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/","title":"COT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#description","title":"Description","text":"

    The COT() function returns the cotangent of input number(given in radians).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#syntax","title":"Syntax","text":"
    > COT(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#examples","title":"Examples","text":"
    mysql> SELECT COT(12);\n+---------------------+\n| cot(12)             |\n+---------------------+\n| -1.5726734063976895 |\n+---------------------+\n1 row in set (0.00 sec)\n
    drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,12);\n\nmysql> select cot(a), cot(b) from t1;\n+---------------------+---------------------+\n| cot(a)              | cot(b)              |\n+---------------------+---------------------+\n|  0.6420926159343306 |  -394449.0619219334 |\n| -0.6420926159343308 | -1.5726734063976895 |\n+---------------------+---------------------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/","title":"EXP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#description","title":"Description","text":"

    The EXP() function returns the value of e (the base of natural logarithms) raised to the power of X.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#syntax","title":"Syntax","text":"
    > EXP(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(-4, 2.45);\ninsert into t1 values(6, -3.62);\n\nmysql> select exp(a), exp(b) from t1;\n+---------------------+----------------------+\n| exp(a)              | exp(b)               |\n+---------------------+----------------------+\n| 0.01831563888873418 |   11.588347271798835 |\n|   403.4287934927351 | 0.026782679557672436 |\n+---------------------+----------------------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/","title":"FLOOR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#description","title":"Description","text":"

    The FLOOR() function returns the largest round number that is less than or equal to the number.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#syntax","title":"Syntax","text":"
    > FLOOR(number, decimals)\n> FLOOR(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now. decimals Optional. An integer that represents the number of decimal places. By default it is zero, which means to round to an integer.decimals may also be negative."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,floor(b) from t1;\n+------+----------+\n| a    | floor(b) |\n+------+----------+\n|    1 |        0 |\n|    2 |        0 |\n|    3 |        0 |\n|    4 |       20 |\n|    5 |       20 |\n|    6 |       13 |\n|    7 |       -1 |\n|    8 |       -1 |\n|    9 |       -1 |\n|   10 |      -21 |\n|   11 |      -21 |\n|   12 |      -14 |\n+------+----------+\n12 rows in set (0.01 sec)\n\nmysql> select sum(floor(b)) from t1;\n+---------------+\n| sum(floor(b)) |\n+---------------+\n|            -6 |\n+---------------+\n1 row in set (0.00 sec)\n\nmysql> select a,sum(floor(b)) from t1 group by a order by a;\n+------+---------------+\n| a    | sum(floor(b)) |\n+------+---------------+\n|    1 |             0 |\n|    2 |             0 |\n|    3 |             0 |\n|    4 |            20 |\n|    5 |            20 |\n|    6 |            13 |\n|    7 |            -1 |\n|    8 |            -1 |\n|    9 |            -1 |\n|   10 |           -21 |\n|   11 |           -21 |\n|   12 |           -14 |\n+------+---------------+\n12 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/","title":"LN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/#description","title":"Description","text":"

    LN(X) returns the natural logarithm of X. This function is synonymous with LOG(X).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/#syntax","title":"Syntax","text":"
    > LN(X)\n

    Reference to LOG(X).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/","title":"LOG()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#description","title":"Description","text":"

    LOG(X) returns the natural logarithm of X.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#syntax","title":"Syntax","text":"
    > LOG(X)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#arguments","title":"Arguments","text":"Arguments Description X Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a float, b float);\ninsert into t1 values(2,8);\n\nmysql> select log(a), log(b) from t1;\n+--------------------+--------------------+\n| log(a)             | log(b)             |\n+--------------------+--------------------+\n| 0.6931471805599453 | 2.0794415416798357 |\n+--------------------+--------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#constraints","title":"Constraints","text":"

    LOG(X) only support one parameter input for now.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/","title":"PI()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#description","title":"Description","text":"

    PI() returns the value of \u03c0 (pi).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#syntax","title":"Syntax","text":"
    > PI()\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(0,0),(-15,-20),(-22,-12.5);\ninsert into t1 values(0,360),(30,390),(90,450),(180,270),(180,180);\n\nmysql> select acos(a*pi()/180) as acosa,acos(b*pi()/180) acosb from t1;\n+--------------------+--------------------+\n| acosa              | acosb              |\n+--------------------+--------------------+\n| 1.5707963267948966 | 1.5707963267948966 |\n| 1.8356824738191324 |  1.927370391646567 |\n| 1.9648910192076245 | 1.7907312931992256 |\n| 1.5707963267948966 |               NULL |\n| 1.0197267436954502 |               NULL |\n|               NULL |               NULL |\n|               NULL |               NULL |\n|               NULL |               NULL |\n+--------------------+--------------------+\n8 rows in set (0.01 sec)\n\nmysql> select acos(a*pi()/180)*acos(b*pi()/180) as acosab,acos(acos(a*pi()/180)) as c from t1;\n+--------------------+------+\n| acosab             | c    |\n+--------------------+------+\n| 2.4674011002723395 | NULL |\n| 3.5380400485035204 | NULL |\n|  3.518591835821214 | NULL |\n|               NULL | NULL |\n|               NULL | NULL |\n|               NULL | NULL |\n|               NULL | NULL |\n|               NULL | NULL |\n+--------------------+------+\n8 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/","title":"POWER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#description","title":"Description","text":"

    POWER(X, Y) returns the value of X raised to the power of Y.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#syntax","title":"Syntax","text":"
    > POWER(X, Y)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#arguments","title":"Arguments","text":"Arguments Description X Required. Any numeric data type supported now. Y Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int,b int);\ninsert into t1 values(5,-2),(10,3),(100,0),(4,3),(6,-3);\n\nmysql> select power(a,b) from t1;\n+----------------------+\n| power(a, b)          |\n+----------------------+\n|                 0.04 |\n|                 1000 |\n|                    1 |\n|                   64 |\n| 0.004629629629629629 |\n+----------------------+\n5 rows in set (0.01 sec)\n\nmysql> select power(a,2) as a1, power(b,2) as b1 from t1 where power(a,2) > power(b,2) order by a1 asc;\n+-------+------+\n| a1    | b1   |\n+-------+------+\n|    16 |    9 |\n|    25 |    4 |\n|    36 |    9 |\n|   100 |    9 |\n| 10000 |    0 |\n+-------+------+\n5 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/","title":"RAND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#description","title":"Description","text":"

    The RAND() function is used to generate a Float64 type random number between 0 and 1. It does not accept any arguments and generates a random number that is unpredictable and non-repeating each time it is called.

    If you need to randomly select data from a table, you can use the RAND() function to generate a random number, and then use ORDER BY to sort the data in the table according to this random number. For example:

    -- Randomly retrieve all data from the table and sort it in a random order, the order of the query results may differ each time.\nSELECT * FROM table ORDER BY RAND();\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#syntax","title":"Syntax","text":"
    > RAND([seed])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#arguments","title":"Arguments","text":"Arguments Description seed Optional argument. It is an integer value used to specify the seed when generating random numbers. If the seed parameter is not specified, the current time is used as the seed value by default. The return value type is consistent with the input type.MatrixOne does not currently support specifying seed."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#examples","title":"Examples","text":"
    • Example 1
    mysql> SELECT RAND();\n+---------------------+\n| rand()              |\n+---------------------+\n| 0.25193285156620004 |\n+---------------------+\n1 row in set (0.00 sec)\n
    • Example 2
    CREATE TABLE Users (\nID INT PRIMARY KEY AUTO_INCREMENT,\nUserName VARCHAR(255) NOT NULL,\nEmail VARCHAR(255));\n\nINSERT INTO Users (UserName, Email) VALUES\n('John', 'john@example.com'),\n('Jane', 'jane@example.com'),\n('Alice', 'alice@example.com'),\n('Bob', 'bob@example.com');\n\n-- Select a user's information randomly from the Users table.\nmysql> SELECT * FROM Users ORDER BY RAND() LIMIT 1;\n+------+----------+-----------------+\n| id   | username | email           |\n+------+----------+-----------------+\n|    4 | Bob      | bob@example.com | -- Bob's information is randomly selected.\n+------+----------+-----------------+\n1 row in set (0.01 sec)\n\n-- Execute the above query again, and another user may be selected.\nmysql> SELECT * FROM Users  ORDER BY RAND() LIMIT 1;\n+------+----------+-------------------+\n| id   | username | email             |\n+------+----------+-------------------+\n|    3 | Alice    | alice@example.com | -- Alice's information is randomly selected.\n+------+----------+-------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#constraints","title":"Constraints","text":"

    MatrixOne does not currently support specifying the seed value for the RAND(seed) function (i.e., the seed parameter).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/","title":"ROUND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#description","title":"Description","text":"

    The ROUND() function rounds a number to a specified number of decimal places. The function returns the nearest number of the specified order. In case when given number has equal distance to surrounding numbers, the function uses banker's rounding for float number types and rounds away from zero for the other number types (Decimal).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#syntax","title":"Syntax","text":"
    > ROUND(number, decimals)\n> ROUND(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#arguments","title":"Arguments","text":"Arguments Description number Required. The number to round, including any numeric data type supported now. decimals Optional. An integer that represents the number of decimal places you want to round to. Default value is 0. decimals>0 then the function rounds the value to the right of the decimal point. decimals<0 then the function rounds the value to the left of the decimal point. decimals=0 then the function rounds the value to integer."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,round(b) from t1;\n+------+----------+\n| a    | round(b) |\n+------+----------+\n|    1 |        0 |\n|    2 |        0 |\n|    3 |        1 |\n|    4 |       20 |\n|    5 |       20 |\n|    6 |       14 |\n|    7 |       -0 |\n|    8 |       -0 |\n|    9 |       -1 |\n|   10 |      -20 |\n|   11 |      -20 |\n|   12 |      -14 |\n+------+----------+\n12 rows in set (0.00 sec)\n\nmysql> select a,round(b,-1) from t1;\n+------+--------------+\n| a    | round(b, -1) |\n+------+--------------+\n|    1 |            0 |\n|    2 |            0 |\n|    3 |            0 |\n|    4 |           20 |\n|    5 |           20 |\n|    6 |           10 |\n|    7 |           -0 |\n|    8 |           -0 |\n|    9 |           -0 |\n|   10 |          -20 |\n|   11 |          -20 |\n|   12 |          -10 |\n+------+--------------+\n12 rows in set (0.01 sec)\n\nmysql> select round(a*b) from t1;\n+--------------+\n| round(a * b) |\n+--------------+\n|            0 |\n|            1 |\n|            2 |\n|           82 |\n|          102 |\n|           81 |\n|           -4 |\n|           -4 |\n|           -5 |\n|         -205 |\n|         -226 |\n|         -162 |\n+--------------+\n12 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/","title":"SIN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#description","title":"Description","text":"

    The SIN() function returns the sine of input number(given in radians).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#syntax","title":"Syntax","text":"
    > SIN(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,1.57);\n\nmysql> select sin(a),sin(b) from t1;\n+---------------------+--------------------------+\n| sin(a)              | sin(b)                   |\n+---------------------+--------------------------+\n|  0.8414709848078965 | 0.0000025351815901107472 |\n| -0.8414709848078965 |       0.9999996829736023 |\n+---------------------+--------------------------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/","title":"SINH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#description","title":"Description","text":"

    The SINH() function returns the hyperbolic sine of the input number(given in radians).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#syntax","title":"Syntax","text":"
    > SINH(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159), (-1,-3.14159);\n\nmysql> select sinh(a), sinh(b) from t1;\n+---------------------+---------------------+\n| sinh(a)             | sinh(b)             |\n+---------------------+---------------------+\n|  1.1752011936438014 |  11.548709969588323 |\n| -1.1752011936438014 | -11.548709969588323 |\n+---------------------+---------------------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/","title":"TAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#description","title":"Description","text":"

    The TAN() function returns the tangent of input number(given in radians).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#syntax","title":"Syntax","text":"
    > TAN(number)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,-3.14159);\n\nmysql> select tan(a),tan(b) from t1;\n+--------------------+--------------------------+\n| tan(a)             | tan(b)                   |\n+--------------------+--------------------------+\n|  1.557407724654902 | -0.000002535181590118894 |\n| -1.557407724654902 |  0.000002535181590118894 |\n+--------------------+--------------------------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/","title":"SLEEP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#description","title":"Description","text":"

    Sleeps (pauses) for the number of seconds given by the duration argument, then returns 0.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#syntax","title":"Syntax","text":"
    >\nSLEEP(duration)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#arguments","title":"Arguments","text":"Arguments Description duration Required. The number of seconds. The duration may have a fractional part. The duration is not allowed NULL or negative."},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#returned-value","title":"Returned Value","text":"
    • When sleep returns normally (without interruption), it returns 0.

    • When SLEEP() returns 1 (with interruption or time out), the query returns no error.

      For example:

      1. In session 1, execute the following command to query the current connection_id and execute the SLEEP() function:

        mysql> select connection_id();\n+-----------------+\n| connection_id() |\n+-----------------+\n|            1476 |\n+-----------------+\n1 row in set (0.03 sec)\nmysql> select sleep(200);\n
      2. At this point, open a new session, interrupt session 1, and run the following command.

        mysql> kill 1463;\nQuery OK, 0 rows affected (0.00 sec)\n
      3. Check the query result of session 1:

        mysql> select sleep(200);\n+------------+\n| sleep(200) |\n+------------+\n|          1 |\n+------------+\n1 row in set (26.50 sec)\n
    • When SLEEP() returns an error (part of a query is uninterrupted). For example:

      mysql> SELECT 1 FROM t1 WHERE SLEEP(1000);\nERROR 20101 (HY000): internal error: pipeline closed unexpectedly\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#examples","title":"Examples","text":"
    -- without interruption\nmysql> SELECT SLEEP(1);\n+----------+\n| sleep(1) |\n+----------+\n|        0 |\n+----------+\n1 row in set (1.01 sec)\n\n-- without interruption\nmysql> SELECT SLEEP(1000);\n+-------------+\n| sleep(1000) |\n+-------------+\n|           0 |\n+-------------+\n1 row in set (18 min 20.87 sec)\n\ncreate table t1 (a int,b int);\ninsert into t1 values (1,1),(1,null);\nmysql> select sleep(a) from t1;\n+----------+\n| sleep(a) |\n+----------+\n|        0 |\n|        0 |\n+----------+\n2 rows in set (2.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/","title":"UUID()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#description","title":"Description","text":"

    Returns a Universal Unique Identifier (UUID) generated according to RFC 4122, \"A Universally Unique IDentifier (UUID) URN Namespace\".

    A UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate devices not connected to each other.

    Info

    Although UUID() values are intended to be unique, they are not necessarily unguessable or unpredictable. If unpredictability is required, UUID values should be generated some other way.

    UUID() returns a value that conforms to UUID version 1 as described in RFC 4122. The value is a 128-bit number represented as a utf8mb3 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format:

    • The first three numbers are generated from the low, middle, and high parts of a timestamp. The high part also includes the UUID version number.

    • The fourth number preserves temporal uniqueness in case the timestamp value loses monotonicity (for example, due to daylight saving time).

    • The fifth number is an IEEE 802 node number that provides spatial uniqueness. A random number is substituted if the latter is not available (for example, because the host device has no Ethernet card, or it is unknown how to find the hardware address of an interface on the host operating system). In this case, spatial uniqueness cannot be guaranteed. Nevertheless, a collision should have very low probability.

    UUID is both a data type and a function. For more information on UUID data types, see UUID Type.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#syntax","title":"Syntax","text":"
    > UUID()\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a INT,  b float);\ninsert into t1 values(12124, -4213.413), (12124, -42413.409);\n\nmysql> SELECT length(uuid()) FROM t1;\n+----------------+\n| length(uuid()) |\n+----------------+\n|             36 |\n|             36 |\n+----------------+\n2 rows in set (0.00 sec)\n\nmysql> SELECT UUID();\n+--------------------------------------+\n| uuid()                               |\n+--------------------------------------+\n| b293b688-70a7-11ed-a25a-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#constraints","title":"Constraints","text":"

    UUID() does not support optional argument for now, which means it doesn't support UUID([number]).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/","title":"BIN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#description","title":"Description","text":"

    This function BIN() returns a string representation of the binary value of N, where N is a longlong (BIGINT) number. Returns NULL if N is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#syntax","title":"Syntax","text":"
    > BIN(N)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#arguments","title":"Arguments","text":"Arguments Description N Required. UINT Type"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#examples","title":"Examples","text":"
    > SELECT bin(1314);\n+-------------+\n| bin(1314)   |\n+-------------+\n| 10100100010 |\n+-------------+\n1 row in set (0.01 sec)\n\n> select bin(2e5);\n+--------------------+\n| bin(2e5)           |\n+--------------------+\n| 110000110101000000 |\n+--------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/","title":"BIT_LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#description","title":"Description","text":"

    Returns the length of the string str in bits. Returns NULL if str is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#syntax","title":"Syntax","text":"
    > BIT_LENGTH(str)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#arguments","title":"Arguments","text":"Arguments Description str Required. String you want to calculate."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#examples","title":"Examples","text":"
    > SELECT BIT_LENGTH('text');\n+------------------+\n| bit_length(text) |\n+------------------+\n|               32 |\n+------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/","title":"CHAR_LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#description","title":"Description","text":"

    The CHAR_LENGTH function returns the length of the string str, measured in code points. A multibyte character counts as a single code point. This means that, for a string containing two 3-byte characters, CHAR_LENGTH returns 6, whereas CHAR_LENGTH returns 2.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#syntax","title":"Syntax","text":"
    > CHAR_LENGTH(str)\n

    note

    The alias for CHAR_LENGTH can also be lengthUTF8()

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#arguments","title":"Arguments","text":"Arguments Description str Required. String you want to calculate."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> create table t1(a varchar(255),b varchar(255));\n> insert into t1 values('nihao','\u4f60\u597d');\n> select char_length(a), char_length(b) from t1;\n+---------------+---------------+\n| lengthutf8(a) | lengthutf8(b) |\n+---------------+---------------+\n|             5 |             2 |\n+---------------+---------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/","title":"CONCAT_WS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#description","title":"Description","text":"

    This function CONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments. If the separator is NULL, the result is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#syntax","title":"Syntax","text":"
    • Syntax 1
    > CONCAT_WS(separator,str1,str2,...)\n
    • Syntax 2
    > CONCAT_WS(separator,str1,NULL,str1,...);\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#arguments","title":"Arguments","text":"Arguments Description str Required. both CHAR and VARCHAR are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#examples","title":"Examples","text":"
    SELECT CONCAT_WS(',','First name','Second name','Last Name');\n+--------------------------------------------------+\n| concat_ws(,, First name, Second name, Last Name) |\n+--------------------------------------------------+\n| First name,Second name,Last Name                 |\n+--------------------------------------------------+\n1 row in set (0.01 sec)\n> SELECT CONCAT_WS(',','First name',NULL,'Last Name');\n+-------------------------------------------+\n| concat_ws(,, First name, null, Last Name) |\n+-------------------------------------------+\n| First name,Last Name                      |\n+-------------------------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/","title":"CONCAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#description","title":"Description","text":"

    This function CONCAT() returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string.

    CONCAT() returns NULL if any argument is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#syntax","title":"Syntax","text":"
    >\nCONCAT(str1,str2,...)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#arguments","title":"Arguments","text":"Arguments Description str1,str2,... Required. The str to add together. Note: If any of the strs is a NULL value, it returns NULL."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#examples","title":"Examples","text":"
    mysql> SELECT CONCAT('My', 'S', 'QL');\n+-------------------+\n| concat(My, S, QL) |\n+-------------------+\n| MySQL             |\n+-------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CONCAT('My', NULL, 'QL');\n+----------------------+\n| concat(My, null, QL) |\n+----------------------+\n| NULL                 |\n+----------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#constraints","title":"Constraints","text":"

    Currently, CONCAT() doesn't support quoted strings and numeric argument.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/","title":"EMPTY()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#description","title":"Description","text":"

    Checks whether the input string is empty. A string is considered non-empty if it contains at least one byte, even if this is a space or a null byte.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#syntax","title":"Syntax","text":"
    > EMPTY(str)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#arguments","title":"Arguments","text":"Arguments Description str Required. both CHAR and VARCHAR are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#returned-values","title":"Returned Values","text":"

    Returns 1 for an empty string or 0 for a non-empty string.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> create table t1(a varchar(255),b varchar(255));\n> insert into t1 values('', 'abcd');\n> insert into t1 values('1111', '');\n> select empty(a),empty(b) from t1;\n+----------+----------+\n| empty(a) | empty(b) |\n+----------+----------+\n|        1 |        0 |\n|        0 |        1 |\n+----------+----------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/","title":"ENDSWITH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#description","title":"Description","text":"

    Returns whether to end with the specified suffix. Returns 1 if the string ends with the specified suffix, otherwise it returns 0. This function is case sensitive.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#syntax","title":"Syntax","text":"
    > ENDSWITH(str,suffix)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR both are supported. suffix Required. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#returned-values","title":"Returned Values","text":"
    • 1, if the string ends with the specified suffix.
    • 0, if the string does not end with the specified suffix.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> create table t1(a int,b varchar(100),c char(20));\n> insert into t1 values\n(1,'Ananya Majumdar', 'XI'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'XI');\n> select a,endsWith(b,'a') from t1;\n+------+----------------+\n| a    | endswith(b, a) |\n+------+----------------+\n|    1 |              0 |\n|    2 |              1 |\n|    3 |              1 |\n|    4 |              0 |\n|    5 |              0 |\n|    6 |              1 |\n+------+----------------+\n> select a,b,c from t1 where endswith(b,'a')=1 and endswith(c,'I')=1;\n+------+---------------+------+\n| a    | b             | c    |\n+------+---------------+------+\n|    3 | Aniket Sharma | XI   |\n|    6 | Tapan Samanta | XI   |\n+------+---------------+------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/","title":"FIELD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#description","title":"Description","text":"

    FIELD() returns the index (position) of str in the str1, str2, str3, ... list.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#syntax","title":"Syntax","text":"
    > FIELD(str,str1,str2,str3,...)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#arguments","title":"Arguments","text":"Arguments Description str Required. The value to search for in the list, case insensitive. str1,str2,str3,... Required. A list of values to search for, case insensitive."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#returned-value","title":"Returned Value","text":"

    If all arguments to FIELD() are strings, all arguments are compared as strings. If all arguments are numbers, they are compared as numbers. Otherwise, the arguments are compared as double.

    • The FIELD() function returns the corresponding position index if the specified value is found in the list. Indexes returned by the FIELD() function start at 1.

    • If more than one specified value is found in the list, the FIELD() function returns only the index of the first one.

    • Returns 0 if str is not found.

    • If str is NULL, the return value is 0 because NULL fails equality comparison with any value.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#examples","title":"Examples","text":"
    • Example 1:
    mysql> SELECT FIELD('Bb', 'Aa', 'Bb', 'Cc', 'Dd', 'Ff');\n+-------------------------------+\n| field(Bb, Aa, Bb, Cc, Dd, Ff) |\n+-------------------------------+\n|                             2 |\n+-------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FIELD('Gg', 'Aa', 'Bb', 'Cc', 'Dd', 'Ff');\n+-------------------------------+\n| field(Gg, Aa, Bb, Cc, Dd, Ff) |\n+-------------------------------+\n|                             0 |\n+-------------------------------+\n1 row in set (0.00 sec)\n
    • Example 2:
    drop table if exists t;\ncreate table t(\ni int,\nf float,\nd double\n);\ninsert into t() values (1, 1.1, 2.2), (2, 3.3, 4.4), (0, 0, 0), (0, null, 0);\n\nmysql> select * from t;\n+------+------+------+\n| i    | f    | d    |\n+------+------+------+\n|    1 |  1.1 |  2.2 |\n|    2 |  3.3 |  4.4 |\n|    0 |    0 |    0 |\n|    0 | NULL |    0 |\n+------+------+------+\n4 rows in set (0.01 sec)\n\nmysql> select field(1, i, f, d) from t;\n+-------------------+\n| field(1, i, f, d) |\n+-------------------+\n|                 1 |\n|                 0 |\n|                 0 |\n|                 0 |\n+-------------------+\n4 rows in set (0.01 sec)\n\nmysql> select field(i, f, d, 0, 1, 2) from t;\n+-------------------------+\n| field(i, f, d, 0, 1, 2) |\n+-------------------------+\n|                       4 |\n|                       5 |\n|                       1 |\n|                       2 |\n+-------------------------+\n4 rows in set (0.01 sec)\n\nmysql> select field('1', f, d, 0, 1, 2) from t;\n+-------------------------+\n| field(1, f, d, 0, 1, 2) |\n+-------------------------+\n|                       4 |\n|                       4 |\n|                       4 |\n|                       4 |\n+-------------------------+\n4 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/","title":"FIND_IN_SET()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#description","title":"Description","text":"

    This function FIND_IN_SET() returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings. A string list is a string composed of substrings separated by , characters. If the first argument is a constant string and the second is a column of type SET, the FIND_IN_SET() function is optimized to use bit arithmetic. Returns 0 if str is not in strlist or if strlist is the empty string. Returns NULL if either argument is NULL. This function does not work properly if the first argument contains a comma (,) character.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#syntax","title":"Syntax","text":"
    > FIND_IN_SET(str,strlist)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#arguments","title":"Arguments","text":"Arguments Description str Required. both CHAR and VARCHAR are supported. strlist Required."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#examples","title":"Examples","text":"
    select find_in_set('b','a,b,c,d');\n+-------------------------+\n| find_in_set(b, a,b,c,d) |\n+-------------------------+\n|                       2 |\n+-------------------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/","title":"FORMAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#description","title":"Description","text":"

    Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#syntax","title":"Syntax","text":"
    > FORMAT(X,D[,locale])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#arguments","title":"Arguments","text":"Arguments Description X Required. X is the number need to format. If X is NULL, the function returns NULL. D Required. D is the number of decimal places to round. If D is 0, the result has no decimal point or fractional part. If D is NULL, the function returns NULL. [,locale] Optional. The optional parameter enables a locale to be specified to be used for the result number's decimal point, thousands separator, and grouping between separators. If the locale is NULL or not specified, the default locale is 'en_US'. [,locale] supports locale parameters consistent with MySQL; see MySQL Server Locale Support."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#examples","title":"Examples","text":"
    mysql> SELECT FORMAT(12332.123456, 4);\n+-------------------------+\n| format(12332.123456, 4) |\n+-------------------------+\n| 12,332.1235             |\n+-------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT FORMAT(12332.1,4);\n+--------------------+\n| format(12332.1, 4) |\n+--------------------+\n| 12,332.1000        |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(12332.2,0);\n+--------------------+\n| format(12332.2, 0) |\n+--------------------+\n| 12,332             |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(12332.2,2,'de_DE');\n+---------------------------+\n| format(12332.2, 2, de_DE) |\n+---------------------------+\n| 12.332,20                 |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(19999999.999999999,4);\n+-------------------------------+\n| format(19999999.999999999, 4) |\n+-------------------------------+\n| 20,000,000.0000               |\n+-------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT FORMAT(\"-.12334.2\",\"2\", \"en_US\");\n+-----------------------------+\n| format(-.12334.2, 2, en_US) |\n+-----------------------------+\n| -0.12                       |\n+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(\"-.12334.2\",\"2\", \"de_CH\");\n+-----------------------------+\n| format(-.12334.2, 2, de_CH) |\n+-----------------------------+\n| -0.12                       |\n+-----------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/","title":"HEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#description","title":"Description","text":"

    For a string argument str, HEX() returns a hexadecimal string representation of str where each byte of each character in str is converted to two hexadecimal digits. (Multibyte characters therefore become more than two digits.)

    For a numeric argument N, HEX() returns a hexadecimal string representation of the value of N treated as an integer number. This is equivalent to CONV(N,10,16). The inverse of this operation is performed by CONV(HEX(N),16,10).

    For a NULL argument, this function returns NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#syntax","title":"Syntax","text":"
    > HEX(str), HEX(N)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#arguments","title":"Arguments","text":"Arguments Description N Required. A number which is to be converted to hexadecimal. str Required. A string whose each character is to be converted to two hexadecimal digits."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#examples","title":"Examples","text":"
    > SELECT HEX('abc');\n+----------+\n| hex(abc) |\n+----------+\n| 616263   |\n+----------+\n1 row in set (0.00 sec)\n\n> SELECT HEX(255);\n+----------+\n| hex(255) |\n+----------+\n| FF       |\n+----------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/","title":"INSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#description","title":"Description","text":"

    INSTR() function is used to return the position of the first occurrence of a substring in a given string. This function is multibyte safe, which means it is compatible with various character encodings and can correctly handle multibyte characters (such as characters encoded in UTF-8).

    The INSTR() function primarily uses data cleaning and transformation, such as when you need to search for a specific substring within a text field or split a text field based on a specific character. This can be particularly useful when dealing with data that follows a specific pattern or format, like email addresses, phone numbers, etc.

    Regarding case sensitivity, INSTR() function is case-sensitive only if at least one argument is a binary string. For non-binary strings, INSTR() is case-insensitive. However, to make a case-sensitive comparison, you can use the BINARY keyword to cast the string into a binary format.

    For example:

    SELECT INSTR(BINARY 'abc', 'A') AS Match;\n

    The above query will return 0 because, in binary format, 'A' and 'a' are considered different characters.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#syntax","title":"Syntax","text":"
    > INSTR(str,substr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#arguments","title":"Arguments","text":"Arguments Description str Required. The string is the string to search in. substr Required. The substring is the string you are looking for."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#examples","title":"Examples","text":"
    • Example 1
    mysql> SELECT INSTR('foobarbar', 'bar');\n+-----------------------+\n| instr(foobarbar, bar) |\n+-----------------------+\n|                     4 |\n+-----------------------+\n1 row in set (0.01 sec)\n
    • Example 2
    -- Using the INSTR function to find the first occurrence of 'o' in the string 'Hello World' will return 5, as 'o' first appears at the 5th position in 'Hello World'.\nmysql> SELECT INSTR('Hello World', 'o');\n+-----------------------+\n| instr(Hello World, o) |\n+-----------------------+\n|                     5 |\n+-----------------------+\n1 row in set (0.01 sec)\n
    • Example 3
    -- Create a table named t1, which contains two VARCHAR type columns a and b\nCREATE TABLE t1(a VARCHAR, b VARCHAR);\n\n-- Insert three rows of data into the table t1\nINSERT INTO t1 VALUES('axa','x'),('abababa','qq'),('qwer','er');\n\n-- Select each row from table t1, then use the INSTR function to find the position at which the string in column b first appears in column a\nmysql> select instr(a,b) from t1;\n+-------------+\n| instr(a, b) |\n+-------------+\n|           2 |\n|           0 |\n|           3 |\n+-------------+\n3 rows in set (0.01 sec)\n\n-- Select each row from table t1, then use the INSTR function to find the position at which NULL first appears in column a\n-- Since NULL is an unknown value, this query will return NULL\nmysql> select instr(a,null) from t1;\n+----------------+\n| instr(a, null) |\n+----------------+\n|           NULL |\n|           NULL |\n|           NULL |\n+----------------+\n3 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/","title":"LEFT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#description","title":"Description","text":"

    This function LEFT() returns the leftmost len characters from the string str, or NULL if any argument is NULL.

    This function is multibyte safe.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#syntax","title":"Syntax","text":"
    > LEFT(str,len)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#arguments","title":"Arguments","text":"Arguments Description str Required. The string to extract from. len Required. The number of characters to extract. If this parameter is larger than the number of characters in string, this function will return string"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#examples","title":"Examples","text":"
    mysql> select left('abcde', 3) from dual;\n+----------------+\n| left(abcde, 3) |\n+----------------+\n| abc            |\n+----------------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\nCREATE TABLE t1 (str VARCHAR(100) NOT NULL, len INT);\ninsert into t1 values('abcdefghijklmn',3);\ninsert into t1 values('  ABCDEFGH123456', 3);\ninsert into t1 values('ABCDEF  GHIJKLMN', 20);\ninsert into t1 values('ABCDEFGHijklmn   ', -1);\ninsert into t1 values('ABCDEFGH123456', -35627164);\ninsert into t1 values('', 3);\nmysql> select left(str, len) from t1;\n+------------------+\n| left(str, len)   |\n+------------------+\n| abc              |\n|   A              |\n| ABCDEF  GHIJKLMN |\n|                  |\n|                  |\n|                  |\n+------------------+\n6 rows in set (0.01 sec)\n\nmysql> select left('sdfsdfsdfsdf', len) from t1;\n+-------------------------+\n| left(sdfsdfsdfsdf, len) |\n+-------------------------+\n| sdf                     |\n| sdf                     |\n| sdfsdfsdfsdf            |\n|                         |\n|                         |\n| sdf                     |\n+-------------------------+\n6 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/","title":"LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#description","title":"Description","text":"

    The length() function returns the length of the string.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#syntax","title":"Syntax","text":"
    > LENGTH(str)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#arguments","title":"Arguments","text":"Arguments Description str Required. String you want to calculate."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#examples","title":"Examples","text":"
    > select a,length(a) from t1;\n\na   length(a)\na       1\nab      2\nabc     3\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/","title":"LPAD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#description","title":"Description","text":"

    This function LPAD(str,len,padstr) returns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#syntax","title":"Syntax","text":"
    > LPAD(str,len,padstr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#arguments","title":"Arguments","text":"Arguments Description str Required. The string to be padded. CHAR and VARCHAR both are supported. len Required. padstr Required. The string used to pad on the left. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> CREATE TABLE t1(Student_id INT,Student_name VARCHAR(100),Student_Class CHAR(20));\n> INSERT INTO t1\nVALUES\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> SELECT Student_id, Student_name,LPAD(Student_Class, 10, ' _') AS LeftPaddedString FROM t1;\n+------------+-----------------+------------------+\n| Student_id | Student_name    | LeftPaddedString |\n+------------+-----------------+------------------+\n|          1 | Ananya Majumdar |  _ _ _ _IX       |\n|          2 | Anushka Samanta |  _ _ _ _ X       |\n|          3 | Aniket Sharma   |  _ _ _ _XI       |\n|          4 | Anik Das        |  _ _ _ _ X       |\n|          5 | Riya Jain       |  _ _ _ _IX       |\n|          6 | Tapan Samanta   |  _ _ _ _ X       |\n+------------+-----------------+------------------+\n> SELECT Student_id, lpad(Student_name,4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 | Anan             |\n|          2 | Anus             |\n|          3 | Anik             |\n|          4 | Anik             |\n|          5 | Riya             |\n|          6 | Tapa             |\n+------------+------------------+\n> SELECT Student_id, lpad(Student_name,-4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 | NULL             |\n|          2 | NULL             |\n|          3 | NULL             |\n|          4 | NULL             |\n|          5 | NULL             |\n|          6 | NULL             |\n+------------+------------------+\n> SELECT Student_id, lpad(Student_name,0,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 |                  |\n|          2 |                  |\n|          3 |                  |\n|          4 |                  |\n|          5 |                  |\n|          6 |                  |\n+------------+------------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/","title":"LTRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#description","title":"Description","text":"

    This function LTRIM() returns the string with leading space characters removed.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#syntax","title":"Syntax","text":"
    > LTRIM(str)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> create table t1(a char(8),b varchar(10));\n> insert into t1 values('  matrix',' matrixone');\n> select ltrim(a),ltrim(b) from t1;\n\n+----------+-----------+\n| ltrim(a) | ltrim(b)  |\n+----------+-----------+\n| matrix   | matrixone |\n+----------+-----------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/","title":"OCT(N)","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#description","title":"Description","text":"

    This function OCT(N) returns a string representation of the octal value of N, where N is a longlong (BIGINT) number. Returns NULL if N is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#syntax","title":"Syntax","text":"
    > OCT(N)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#arguments","title":"Arguments","text":"Arguments Description N Required. UINT Type"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#examples","title":"Examples","text":"
    SELECT OCT(12);\n+---------+\n| oct(12) |\n+---------+\n| 14.0000 |\n+---------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/","title":"REPEAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#description","title":"Description","text":"

    Returns a string consisting of the string str repeated count times. If count is less than 1, returns an empty string. Returns NULL if str or count is NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#syntax","title":"Syntax","text":"
    > REPEAT(str,count)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#arguments","title":"Arguments","text":"Arguments Description str Required. The string to repeat. count Required. The number of times to repeat."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#examples","title":"Examples","text":"
    mysql> SELECT repeat('abc', -1);\n+-----------------+\n| repeat(abc, -1) |\n+-----------------+\n|                 |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT repeat('abc', 1), repeat('abc', 2), repeat('abc', 3);\n+----------------+----------------+----------------+\n| repeat(abc, 1) | repeat(abc, 2) | repeat(abc, 3) |\n+----------------+----------------+----------------+\n| abc            | abcabc         | abcabcabc      |\n+----------------+----------------+----------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/","title":"REVERSE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#description","title":"Description","text":"

    Returns the string str with the order of the characters reversed.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#syntax","title":"Syntax","text":"
    > REVERSE(str)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#arguments","title":"Arguments","text":"Arguments Description Str Required. both CHAR and VARCHAR are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> create table t1(a varchar(12),c char(30));\n> insert into t1 values('sdfad  ','2022-02-02 22:22:22');\n> insert into t1 values('  sdfad  ','2022-02-02 22:22:22');\n> insert into t1 values('adsf  sdfad','2022-02-02 22:22:22');\n> insert into t1 values('    sdfad','2022-02-02 22:22:22');\n> select reverse(a),reverse(c) from t1;\n+-------------+---------------------+\n| reverse(a)  | reverse(c)          |\n+-------------+---------------------+\n|   dafds     | 22:22:22 20-20-2202 |\n|   dafds     | 22:22:22 20-20-2202 |\n| dafds  fsda | 22:22:22 20-20-2202 |\n| dafds       | 22:22:22 20-20-2202 |\n+-------------+---------------------+\n> select a from t1 where reverse(a) like 'daf%';\n+-------------+\n| a           |\n+-------------+\n| adsf  sdfad |\n|     sdfad   |\n+-------------+\n> select reverse(a) reversea,reverse(reverse(a)) normala from t1;\n+-------------+-------------+\n| reversea    | normala     |\n+-------------+-------------+\n|   dafds     | sdfad       |\n|   dafds     |   sdfad     |\n| dafds  fsda | adsf  sdfad |\n| dafds       |     sdfad   |\n+-------------+-------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/","title":"RPAD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#description","title":"Description","text":"

    This function RPAD(str,len,padstr) returns the string str, right-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#syntax","title":"Syntax","text":"
    > RPAD(str,len,padstr)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#arguments","title":"Arguments","text":"Arguments Description str Required. The string to be padded. CHAR and VARCHAR both are supported. len Required. padstr Required. The string used to pad on the right. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> CREATE TABLE t1(Student_id INT,Student_name VARCHAR(100),Student_Class CHAR(20));\n> INSERT INTO t1\nVALUES\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> SELECT Student_id, Student_name,RPAD(Student_Class, 10, ' _') AS LeftPaddedString FROM t1;\n+------------+-----------------+------------------+\n| Student_id | Student_name    | LeftPaddedString |\n+------------+-----------------+------------------+\n|          1 | Ananya Majumdar | IX _ _ _ _       |\n|          2 | Anushka Samanta | X _ _ _ _        |\n|          3 | Aniket Sharma   | XI _ _ _ _       |\n|          4 | Anik Das        | X _ _ _ _        |\n|          5 | Riya Jain       | IX _ _ _ _       |\n|          6 | Tapan Samanta   | X _ _ _ _        |\n+------------+-----------------+------------------+\n> SELECT Student_id, rpad(Student_name,4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 | Anan             |\n|          2 | Anus             |\n|          3 | Anik             |\n|          4 | Anik             |\n|          5 | Riya             |\n|          6 | Tapa             |\n+------------+------------------+\n> SELECT Student_id, rpad(Student_name,-4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 | NULL             |\n|          2 | NULL             |\n|          3 | NULL             |\n|          4 | NULL             |\n|          5 | NULL             |\n|          6 | NULL             |\n+------------+------------------+\n> SELECT Student_id, rpad(Student_name,0,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 |                  |\n|          2 |                  |\n|          3 |                  |\n|          4 |                  |\n|          5 |                  |\n|          6 |                  |\n+------------+------------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/","title":"RTRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#description","title":"Description","text":"

    This function RTRIM() returns the string with trailing space characters removed.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#syntax","title":"Syntax","text":"
    > RTRIM(str)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> create table t1(a char(8),b varchar(10));\n> insert into t1 values('matrix  ','matrixone ');\n> select rtrim(a),rtrim(b) from t1;\n\n+----------+-----------+\n| rtrim(a) | rtrim(b)  |\n+----------+-----------+\n| matrix   | matrixone |\n+----------+-----------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/","title":"SPACE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#description","title":"Description","text":"

    SPACE(N) Returns a string consisting of N space characters.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#syntax","title":"Syntax","text":"
    > SPACE(N)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#arguments","title":"Arguments","text":"Arguments Description N Required. UINT Type"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> CREATE TABLE t1\n(\nEmployee_name VARCHAR(100) NOT NULL,\nJoining_Date DATE NOT NULL\n);\n> INSERT INTO t1\n(Employee_name, Joining_Date )\nVALUES\n('     Ananya Majumdar', '2000-01-11'),\n('   Anushka Samanta', '2002-11-10' ),\n('   Aniket Sharma ', '2005-06-11' ),\n('   Anik Das', '2008-01-21'  ),\n('  Riya Jain', '2008-02-01' ),\n('    Tapan Samanta', '2010-01-11' ),\n('   Deepak Sharma', '2014-12-01'  ),\n('   Ankana Jana', '2018-08-17'),\n('  Shreya Ghosh', '2020-09-10') ;\n> INSERT INTO t1\n(Employee_name, Joining_Date ) values('     ','2014-12-01');\n> select * from t1 where Employee_name=space(5);\n+---------------+--------------+\n| Employee_name | Joining_Date |\n+---------------+--------------+\n|               | 2014-12-01   |\n+---------------+--------------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/","title":"SPLIT_PART()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#description","title":"Description","text":"

    The SPLIT_PART() function is used to split a string into multiple parts based on a given delimiter and returns the specified part.

    If the specified part (designated by the unsigned_integer parameter) exceeds the actual number of existing parts, SPLIT_PART() will return NULL.

    SPLIT_PART() counts parts from left to right only. If unsigned_integer is a negative number, an error will occur.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#syntax","title":"Syntax","text":"
    > SPLIT_PART(expr, delimiter, unsigned_integer)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#arguments","title":"Arguments","text":"Arguments Description expr Required. The string to be split. delimiter Required. The delimiter used to split the string. unsigned_integer Required. This is an integer specifying which part of the string to return. The first part is 1, the second part is 2, and so on."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#examples","title":"Examples","text":"
    • Example 1
    -- Split the string 'axbxc' and use 'x' as the delimiter. This function will return the first part of the string 'axbxc'. Therefore, the result of executing this SQL statement is 'a' because 'a' is the first part of the string 'axbxc' split on the basis of the 'x' delimiter.\nmysql> select split_part('axbxc','x',1);\n+-------------------------+\n| split_part(axbxc, x, 1) |\n+-------------------------+\n| a                       |\n+-------------------------+\n1 row in set (0.00 sec)\n
    • Example 2
    -- Create a new table 't1' with three columns: 'a' (varchar type), 'b' (varchar type), and 'c' (int type).\ncreate table t1(a varchar,b varchar,c int);\n-- Insert multiple rows of data into the 't1' table\ninsert into t1 values('axbxc','x',1),('axbxcxd','x',2),('axbxcxd','x',3),('axbxcxd','xc',1),('axbxcxd','xc',2),('axbxcxd','xc',3),('axbxcxd','asas',1),('axbxcxd','asas',2),(null,'asas',3),('axbxcxd',null,3),('axbxcxd','asas',null),('axxx','x',1),('axxx','x',2);\n-- Query uses the split_part function to process each row in the 't1' table. For each row, it splits the value of the 'a' column into multiple parts (using the value of the 'b' column as the delimiter) and then returns the specified part (designated by the value of the 'c' column). For example, for the first row of data ('axbxc', 'x', 1), it returns 'a' because 'a' is the first part of the string 'axbxc' split on the basis of the 'x' delimiter.\nmysql> select split_part(a,b,c) from t1;\n+---------------------+\n| split_part(a, b, c) |\n+---------------------+\n| a                   |\n| b                   |\n| c                   |\n| axb                 |\n| xd                  |\n| NULL                |\n| axbxcxd             |\n| NULL                |\n| NULL                |\n| NULL                |\n| NULL                |\n| a                   |\n| NULL                |\n+---------------------+\n13 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/","title":"STARTSWITH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#description","title":"Description","text":"

    Returns 1 whether string starts with the specified prefix, otherwise it returns 0.This function is case sensitive.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#syntax","title":"Syntax","text":"
    > STARTSWITH(str,prefix)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR both are supported. prefix Required. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#returned-values","title":"Returned Values","text":"
    • 1, if the string starts with the specified prefix.
    • 0, if the string does not start with the specified prefix.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#examples","title":"Examples","text":"
    > drop table if exists t1;\n> create table t1(a int,b varchar(100),c char(20));\n> insert into t1 values\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> select a,startswith(b,'An') from t1;\n+------+-------------------+\n| a    | startswith(b, An) |\n+------+-------------------+\n|    1 |                 1 |\n|    2 |                 1 |\n|    3 |                 1 |\n|    4 |                 1 |\n|    5 |                 0 |\n|    6 |                 0 |\n+------+-------------------+\n> select a,b,c from t1 where startswith(b,'An')=1 and startswith(c,'I')=1;\n+------+-----------------+------+\n| a    | b               | c    |\n+------+-----------------+------+\n|    1 | Ananya Majumdar | IX   |\n+------+-----------------+------+\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/","title":"SUBSTRING_INDEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#description","title":"Description","text":"

    This function SUBSTRING_INDEX() returns the substring from string str before count occurrences of the delimiter delim.

    If count is positive, everything to the left of the final delimiter (counting from the left) is returned.

    If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.

    SUBSTRING_INDEX() returns NULL if any of its arguments are NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#syntax","title":"Syntax","text":"
    > SUBSTRING_INDEX(str,delim,count)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#arguments","title":"Arguments","text":"Arguments Description str A string. delim A delimiter. count An integer indicating the number of occurrences of delim."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#examples","title":"Examples","text":"
    mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);\n+--------------------------------------+\n| substring_index(www.mysql.com, ., 2) |\n+--------------------------------------+\n| www.mysql                            |\n+--------------------------------------+\n1 row in set (0.03 sec)\n\nmysql> select substring_index('xyz', 'abc', 9223372036854775808);\n+------------------------------------------------+\n| substring_index(xyz, abc, 9223372036854775808) |\n+------------------------------------------------+\n| xyz                                            |\n+------------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2);\n+---------------------------------------+\n| substring_index(www.mysql.com, ., -2) |\n+---------------------------------------+\n| mysql.com                             |\n+---------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('192,168,8,203', ',', 2), ',',-1);\n+--------------------------------------------------------------+\n| substring_index(substring_index(192,168,8,203, ,, 2), ,, -1) |\n+--------------------------------------------------------------+\n| 168                                                          |\n+--------------------------------------------------------------+\n1 row in set (0.02 sec)\n\ncreate table test(a varchar(100), b varchar(20), c int);\ninsert into test values('www.mysql.com', '.', 0);\ninsert into test values('www.mysql.com', '.', 1);\ninsert into test values('www.mysql.com', '.', 2);\ninsert into test values('www.mysql.com', '.', 3);\ninsert into test values('www.mysql.com', '.', 9223372036854775808);\ninsert into test values('www.mysql.com', '.', -1);\ninsert into test values('www.mysql.com', '.', -2);\ninsert into test values('www.mysql.com', '.', -3);\nmysql> select SUBSTRING_INDEX(a, b, c) from test;\n+--------------------------+\n| substring_index(a, b, c) |\n+--------------------------+\n|                          |\n| www                      |\n| www.mysql                |\n| www.mysql.com            |\n| com                      |\n| mysql.com                |\n| www.mysql.com            |\n+--------------------------+\n7 rows in set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/","title":"SUBSTRING()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#description","title":"Description","text":"

    SUBSTR() and MID() are both synonyms of SUBSTRING(). The forms without a len argument return a substring from string str starting at position pos. The forms with a len argument return a substring len characters long from string str, starting at position pos.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#syntax","title":"Syntax","text":"
    > SUBSTRING(str,pos)\n> SUBSTR(str,pos,len)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR are both supported pos Required. len Optional."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#examples","title":"Examples","text":"
    > CREATE TABLE IF NOT EXISTS t1 (\npub_id varchar(8) COLLATE latin1_general_ci NOT NULL DEFAULT '',\npub_name varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT '',\npub_city varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\ncountry varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\ncountry_office varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\nno_of_branch int NOT NULL DEFAULT 0,\nestd date NOT NULL DEFAULT '2000-01-01'\n);\n\n> INSERT INTO t1 (pub_id, pub_name, pub_city, country, country_office, no_of_branch, estd) VALUES\n('P001', 'Jex Max Publication', 'New York', 'USA', 'New York', 15, '1969-12-25'),\n('P002', 'BPP Publication', 'Mumbai', 'India', 'New Delhi', 10, '1985-10-01'),\n('P003', 'New Harrold Publication', 'Adelaide', 'Australia', 'Sydney', 6, '1975-09-05'),\n('P004', 'Ultra Press Inc.', 'London', 'UK', 'London', 8, '1948-07-10'),\n('P005', 'Mountain Publication', 'Houstan', 'USA', 'Sun Diego', 25, '1975-01-01'),\n('P006', 'Summer Night Publication', 'New York', 'USA', 'Atlanta', 10, '1990-12-10'),\n('P007', 'Pieterson Grp. of Publishers', 'Cambridge', 'UK', 'London', 6, '1950-07-15'),\n('P008', 'Novel Publisher Ltd.', 'New Delhi', 'India', 'Bangalore', 10, '2000-01-01');\n\n> SELECT pub_name, SUBSTR(pub_name,4,5) FROM t1 WHERE country='USA';\n+--------------------------+------------------------+\n| pub_name                 | substr(pub_name, 4, 5) |\n+--------------------------+------------------------+\n| Jex Max Publication      |  Max                   |\n| Mountain Publication     | ntain                  |\n| Summer Night Publication | mer N                  |\n+--------------------------+------------------------+\n3 rows in set (0.04 sec)\n\n> SELECT pub_name, SUBSTR(pub_name,5) FROM t1 WHERE country='USA';\n+--------------------------+----------------------+\n| pub_name                 | substr(pub_name, 5)  |\n+--------------------------+----------------------+\n| Jex Max Publication      | Max Publication      |\n| Mountain Publication     | tain Publication     |\n| Summer Night Publication | er Night Publication |\n+--------------------------+----------------------+\n3 rows in set (0.03 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/","title":"TRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#description","title":"Description","text":"

    This function TRIM() returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.

    This function is multibyte safe. It returns NULL if any of its arguments are NULL.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#syntax","title":"Syntax","text":"
    > TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR are both supported"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#examples","title":"Examples","text":"
    mysql> select trim(' abc '), trim('abc '), trim(' abc'), trim('abc');\n+-------------+------------+------------+-----------+\n| trim( abc ) | trim(abc ) | trim( abc) | trim(abc) |\n+-------------+------------+------------+-----------+\n| abc         | abc        | abc        | abc       |\n+-------------+------------+------------+-----------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\ncreate table t1(a varchar(100), b varchar(100));\ninsert into t1 values('abc', 'abc');\ninsert into t1 values('\u554aabc\u54e6', '\u554aabc\u54e6');\ninsert into t1 values('\u554a\u554ao', 'o');\ninsert into t1 values('\u554a\u554ao', '\u554a');\ninsert into t1 values('\u554a\u554ao', 'o\u554a');\nmysql> select trim(both a from b) from t1;\n+---------------------+\n| trim(both a from b) |\n+---------------------+\n|                     |\n|                     |\n| o                   |\n| \u554a                  |\n| o\u554a                 |\n+---------------------+\n5 rows in set (0.00 sec)\n\nmysql> select trim(leading a from b) from t1;\n+------------------------+\n| trim(leading a from b) |\n+------------------------+\n|                        |\n|                        |\n| o                      |\n| \u554a                     |\n| o\u554a                    |\n+------------------------+\n5 rows in set (0.01 sec)\n\nmysql> select trim(trailing a from b) from t1;\n+-------------------------+\n| trim(trailing a from b) |\n+-------------------------+\n|                         |\n|                         |\n| o                       |\n| \u554a                      |\n| o\u554a                     |\n+-------------------------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/","title":"Regular Expressions Overview","text":"

    Regular expressions provide a powerful method for matching text patterns. You can use simple wildcards (such as %, _) in LIKE statements, but regular expressions offer more flexibility and matching options.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/#scenarios","title":"Scenarios","text":"

    Regular expressions can perform complex string matching and manipulation. Here are some common use cases:

    • Data Validation: Regular expressions can validate whether data complies with a specific format, such as checking whether a field contains a valid email address, phone number, or social security number. For example, you can use a regular expression to find all email addresses that do not conform to the standard format:

      SELECT email\nFROM users\nWHERE email NOT REGEXP '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\\.[A-Za-z]{2,}$';\n
    • Data Filtering: Regular expressions can be used to search for data that contains or does not contain specific patterns. For example, if you want to find all phone numbers that start with a specific prefix, you can use a regular expression to match these numbers:

      SELECT phone_number\nFROM users\nWHERE phone_number REGEXP '^180';\n
    • Data Cleaning: Regular expressions are also instrumental in data cleaning. For example, you may need to clear special characters and spaces or extract numbers from strings; regular expressions can quickly implement these functions:

      SELECT REGEXP_REPLACE(name, '[^a-zA-Z]', '')\nFROM users;\n

      This SQL will return the result of all non-alphabetical characters in the name field being replaced.

    • Text Analysis: If you are conducting text analysis, regular expressions can help you find specific words or phrases in the text and can even be used for certain forms of natural language processing.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/#special-characters","title":"Special Characters","text":"

    Regular expressions use POSIX (Portable Operating System Interface) extended regular expressions. Here are some special characters to note:

    Character Explanation . Matches any single character (except a newline) * Indicates the preceding element can be repeated any number of times (including zero times) + Indicates the preceding element can be repeated one or more times. ? Indicates the primary element can be repeated zero or once. {n} Indicates the primary element can be repeated n times. {n,} Indicates the primary element can be repeated n times or more. {n,m} Indicates the primary element can be repeated from n to m times. ^ Indicates matching the beginning of the string. $ Indicates matching the end of the string. [abc] Indicates matching a, b, or c. [^abc] Indicates matching any character that is not a, b, or c. (abc|def) Indicates matching abc or def. \\d Indicates matching numbers \\s Indicates matching whitespace characters \\w Indicates matching word characters \\D, \\S and \\W Indicate matching opposite character sets

    Note

    In regular expressions, these special characters need to be escaped using \\; for example, \\\\. indicates matching an actual . character, not any character.

    MatrixOne's regular expressions are case-sensitive by default. If you want to perform case-insensitive matching, you can use syntax like REGEXP_LIKE(column, pattern, 'i'). Where i indicates case insensitivity.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/#reference","title":"Reference","text":"

    List of Regular Expression Functions

    Name Definition NOT REGEXP Negation of REGEXP REGEXP_INSTR() Starting index of substring matching regular expression REGEXP_LIKE() Whether string matches regular expression REGEXP_REPLACE() Replace substring matching regular expression REGEXP_SUBSTR() Return substring matching regular expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/","title":"NOT REGEXP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#description","title":"Description","text":"

    NOT REGEXP is used to test whether a string does not match a specified regular expression.

    If column_name does not match pattern, it returns TRUE. If it matches, it returns FALSE.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#syntax","title":"Syntax","text":"
    > column_name NOT REGEXP pattern\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#explanations","title":"Explanations","text":"
    • column_name is the column to match.

    • pattern is the regular expression to apply.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#examples","title":"Examples","text":"
    CREATE TABLE example (\nid INT AUTO_INCREMENT,\ntext VARCHAR(255),\nPRIMARY KEY(id)\n);\n\n\nINSERT INTO example (text)\nVALUES ('Hello1'),\n('Hello2'),\n('World'),\n('HelloWorld'),\n('Hello_World'),\n('example'),\n('example1'),\n('example2');\n\nmysql> SELECT * FROM example WHERE text NOT REGEXP '[0-9]';\n+------+-------------+\n| id   | text        |\n+------+-------------+\n|    3 | World       |\n|    4 | HelloWorld  |\n|    5 | Hello_World |\n|    6 | example     |\n+------+-------------+\n4 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/","title":"REGEXP_INSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#description","title":"Description","text":"

    REGEXP_INSTR() returns the starting position in the string of the matched regular expression pattern. If no match is found, the function returns 0.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#syntax","title":"Syntax","text":"
    > REGEXP_INSTR(expr, pat[, pos[, occurrence[, return_option[, match_type]]]])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#explanations","title":"Explanations","text":"
    • expr is the string to match.

    • pat is the regular expression to match in the string.

    • pos: The position in expr at which to start the search. If omitted, the default is 1.

    • occurrence: Which occurrence of a match to replace. If omitted, the default is 0 (which means replace all occurrences).

    • return_option: This is an optional parameter specifying whether the returned position is where the pattern starts or ends. If 0 or omitted, the function returns the position at which the pattern begins. If 1, the function returns the position after the position where the pattern ends.

    • match_type: The optional match_type argument is a string that may contain any or all the following characters specifying how to perform matching:

      • 'c': Case-sensitive matching by default.
      • 'i': Case-insensitive matching.
      • 'n': The . character matches line terminators. The default is for . matching to stop at the end of a line.
      • 'm': Multiple-line mode. Recognize line terminators within the string. The default behavior is to match line terminators only at the start and end of the string expression.
      • 'u': Unix-only line endings. Only the newline character is recognized as a line ending by the ., ^, and $ match operators.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#examples","title":"Examples","text":"
    mysql> SELECT REGEXP_INSTR('Hello, my number is 12345.', '[0-9]+');\n+--------------------------------------------------+\n| regexp_instr(Hello, my number is 12345., [0-9]+) |\n+--------------------------------------------------+\n|                                               21 |\n+--------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('apple', 'z+');\n+-------------------------+\n| regexp_instr(apple, z+) |\n+-------------------------+\n|                       0 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('Hello, World!', 'World');\n+------------------------------------+\n| regexp_instr(Hello, World!, World) |\n+------------------------------------+\n|                                  8 |\n+------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('Hello, World! World!', 'World', 1, 2);\n+-------------------------------------------------+\n| regexp_instr(Hello, World! World!, World, 1, 2) |\n+-------------------------------------------------+\n|                                              15 |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/","title":"REGEXP_LIKE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#description","title":"Description","text":"

    Returns TRUE if the string expr matches the regular expression specified by the pattern pat, FALSE otherwise. If expr or pat is NULL, the return value is NULL.

    REGEXP and RLIKE are synonyms for REGEXP_LIKE().

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#syntax","title":"Syntax","text":"
    > REGEXP_LIKE(expr, pat[, match_type])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#explanations","title":"Explanations","text":"
    • expr is the string to search for.

    • pat is a regular expression to look for in the string.

    • match_type: The optional match_type argument is a string that may contain any or all the following characters specifying how to perform matching:

      • 'c': Case-sensitive matching by default.
      • 'i': Case-insensitive matching.
      • 'n': The . character matches line terminators. The default is for . matching to stop at the end of a line.
      • 'm': Multiple-line mode. Recognize line terminators within the string. The default behavior is to match line terminators only at the start and end of the string expression.
      • 'u': Unix-only line endings. Only the newline character is recognized as a line ending by the ., ^, and $ match operators.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#examples","title":"Examples","text":"
    mysql> SELECT REGEXP_INSTR('Hello, my number is 12345.', '[0-9]+');\n+--------------------------------------------------+\n| regexp_instr(Hello, my number is 12345., [0-9]+) |\n+--------------------------------------------------+\n|                                               21 |\n+--------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('apple', 'z+');\n+-------------------------+\n| regexp_instr(apple, z+) |\n+-------------------------+\n|                       0 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_LIKE('CamelCase', 'CAMELCASE');\n+-----------------------------------+\n| regexp_like(CamelCase, CAMELCASE) |\n+-----------------------------------+\n| false                             |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT REGEXP_LIKE('CamelCase', 'CAMELCASE', 'i');\n+--------------------------------------+\n| regexp_like(CamelCase, CAMELCASE, i) |\n+--------------------------------------+\n| true                                 |\n+--------------------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/","title":"REGEXP_REPLACE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#description","title":"Description","text":"

    REGEXP_REPLACE() is used to replace a string matching a given regular expression pattern with the specified new string.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#syntax","title":"Syntax","text":"
    > REGEXP_REPLACE(expr, pat, repl[, pos[, occurrence[, match_type]]])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#explanations","title":"Explanations","text":"
    • expr is the string to replace.

    • pat This is a regular expression, the function will find all strings that match this pattern.

    • repl is the replacement string used to replace the found matching string.

    • pos: The position in expr at which to start the search. If omitted, the default is 1.

    • occurrence: Which occurrence of a match to replace. If omitted, the default is 0 (which means replace all occurrences).

    • match_type: The optional match_type argument is a string that may contain any or all the following characters specifying how to perform matching:

      • 'c': Case-sensitive matching by default.
      • 'i': Case-insensitive matching.
      • 'n': The . character matches line terminators. The default is for . matching to stop at the end of a line.
      • 'm': Multiple-line mode. Recognize line terminators within the string. The default behavior is to match line terminators only at the start and end of the string expression.
      • 'u': Unix-only line endings. Only the newline character is recognized as a line ending by the ., ^, and $ match operators.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#examples","title":"Examples","text":"
    mysql> SELECT REGEXP_REPLACE('Hello, World!', 'World', 'Universe');\n+------------------------------------------------+\n| regexp_replace(Hello, World!, World, Universe) |\n+------------------------------------------------+\n| Hello, Universe!                               |\n+------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat','Cat', 'Tiger') 'Result';\n+---------------------------+\n| Result                    |\n+---------------------------+\n| Tiger Dog Tiger Dog Tiger |\n+---------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/","title":"REGEXP_SUBSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#description","title":"Description","text":"

    REGEXP_SUBSTR() is used to return the substring of the string expr that matches the regular expression pattern pat.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#syntax","title":"Syntax","text":"
    > REGEXP_SUBSTR(expr, pat[, pos[, occurrence[, match_type]]])\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#explanations","title":"Explanations","text":"
    • expr: This is the original string in which to look for matches.

    • pat: This is a regular expression pattern, the function will look for strings that match this pattern.

    • pos: The position in expr at which to start the search. If omitted, the default is 1.

    • occurrence: Which occurrence of a match to replace. If omitted, the default is 0 (which means replace all occurrences).

    • match_type: The optional match_type argument is a string that may contain any or all the following characters specifying how to perform matching:

      • 'c': Case-sensitive matching by default.
      • 'i': Case-insensitive matching.
      • 'n': The . character matches line terminators. The default is for . matching to stop at the end of a line.
      • 'm': Multiple-line mode. Recognize line terminators within the string. The default behavior is to match line terminators only at the start and end of the string expression.
      • 'u': Unix-only line endings. Only the newline character is recognized as a line ending by the ., ^, and $ match operators.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#examples","title":"Examples","text":"
    mysql> SELECT REGEXP_SUBSTR('1a 2b 3c', '[0-9]a');\n+---------------------------------+\n| regexp_substr(1a 2b 3c, [0-9]a) |\n+---------------------------------+\n| 1a                              |\n+---------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_SUBSTR('Lend for land', '^C') Result;\n+--------+\n| Result |\n+--------+\n| NULL   |\n+--------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/","title":"UNNEST()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#description","title":"Description","text":"

    The UNNEST function is used to expand the column or parameter of the array type in the JSON type data into a table. It splits the elements in the array in the JSON-type data into individual rows so that the array elements can be processed individually or joined with other tables.

    When given an empty array, the UNNEST function returns an empty list because there are no additional elements.

    When a NULL value is entered, the UNNEST function returns an empty table because NULL is not a valid array.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#syntax","title":"Syntax","text":"
    > UNNEST(array_expression)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#arguments","title":"Arguments","text":"Arguments Description array_expression Required. It is an array expression that can be an array column, an array constant, or the return value of an array function."},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#examples","title":"Examples","text":"
    • Example 1:
    -- Expand a string array containing JSON objects, '{\"a\":1}' is a string array containing a single element. This element is a string representing a JSON object.\n> select * from unnest('{\"a\":1}') u;\n+----------------+------+------+------+-------+-------+----------+\n| col            | seq  | key  | path | index | value | this     |\n+----------------+------+------+------+-------+-------+----------+\n| UNNEST_DEFAULT |    0 | a    | $.a  |  NULL | 1     | {\"a\": 1} |\n+----------------+------+------+------+-------+-------+----------+\n1 row in set (0.00 sec)\n\n-- Expand a string array '[1,2,3]' containing integers, and use the alias u to represent the expanded columns.\n> select * from unnest('[1,2,3]') u;\n+----------------+------+------+------+-------+-------+-----------+\n| col            | seq  | key  | path | index | value | this      |\n+----------------+------+------+------+-------+-------+-----------+\n| UNNEST_DEFAULT |    0 | NULL | $[0] |     0 | 1     | [1, 2, 3] |\n| UNNEST_DEFAULT |    0 | NULL | $[1] |     1 | 2     | [1, 2, 3] |\n| UNNEST_DEFAULT |    0 | NULL | $[2] |     2 | 3     | [1, 2, 3] |\n+----------------+------+------+------+-------+-------+-----------+\n3 rows in set (0.00 sec)\n\n-- Expands a string array '[1,2,3]' containing integers and selects the first element of the array to return as part of the result set. '$[0]' is a path expression specifying the array elements to select, and true is a boolean indicating whether to return a path and uses the alias u for expanded columns.\n> select * from unnest('[1,2,3]','$[0]',true) u;\n+----------------+------+------+------+-------+-------+------+\n| col            | seq  | key  | path | index | value | this |\n+----------------+------+------+------+-------+-------+------+\n| UNNEST_DEFAULT |    0 | NULL | $[0] |  NULL | NULL  | 1    |\n+----------------+------+------+------+-------+-------+------+\n1 row in set (0.00 sec)\n
    • Example 2:
    create table t1 (a json,b int);\ninsert into t1 values ('{\"a\":1,\"b\":[{\"c\":2,\"d\":3},false,4],\"e\":{\"f\":true,\"g\":[null,true,1.1]}}',1);\ninsert into t1 values ('[1,true,false,null,\"aaa\",1.1,{\"t\":false}]',2);\n> select * from t1;\n+---------------------------------------------------------------------------------------+------+\n| a                                                                                     | b    |\n+---------------------------------------------------------------------------------------+------+\n| {\"a\": 1, \"b\": [{\"c\": 2, \"d\": 3}, false, 4], \"e\": {\"f\": true, \"g\": [null, true, 1.1]}} |    1 |\n| [1, true, false, null, \"aaa\", 1.1, {\"t\": false}]                                      |    2 |\n+---------------------------------------------------------------------------------------+------+\n2 rows in set (0.00 sec)\n\n-- Expand the elements of array t1.a from table t1 and select the expanded elements to return as part of the result set. \"$a\" is a path expression specifying the array elements to select; true is a Boolean value indicating whether to return the path; use f.* to select all columns after expansion; f is an alias for the UNNEST function, representing expanded the result of.\nmysql> select f.* from t1,unnest(t1.a, \"$.a\", true) as f;\n+------+------+------+------+-------+-------+------+\n| col  | seq  | key  | path | index | value | this |\n+------+------+------+------+-------+-------+------+\n| t1.a |    0 | NULL | $.a  |  NULL | NULL  | 1    |\n| t1.a |    0 | NULL | $.a  |  NULL | NULL  | 1    |\n+------+------+------+------+-------+-------+------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/","title":"DENSE_RANK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/#description","title":"Description","text":"

    DENSE_RANK() gives each row in the dataset a unique rank, very similar to the RANK() function. The DENSE_RANK() function first sorts the dataset according to the columns specified in the ORDER BY clause, then assigns each row a unique rank.

    The DENSE_RANK() function handles ties (i.e., two or more rows with the same value) slightly differently than the RANK() function. In the case of a link, DENSE_RANK() will assign the same rank to all rows with the same value but will not skip any ranks immediately following it. For example, if two rows rank 1, the next row gets rank 2, not 3.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/#syntax","title":"Syntax","text":"
    > DENSE_RANK() OVER (\n    [PARTITION BY column_1, column_2, ... ]\n    ORDER BY column_3, column_4, ...\n)\n
    • The PARTITION BY clause is optional and divides the dataset into partitions; the rank is computed individually inside each partition.
    • The ORDER BY clause defines how the dataset is sorted, i.e., according to which column or columns to sort. You can specify ascending (ASC) or descending (DESC) sorting.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/#examples","title":"Examples","text":"
    -- Create a new table, 'SalesTable' with three fields: 'Department', 'Employee', and 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- Insert data into the 'SalesTable' table; each row contains a department (Department), an employee (Employee), and their sales (Sales)\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- Query the 'SalesTable' table and return the employee's name, their sales, and their sales rank (using the 'DENSE_RANK()' function)\n-- In this query, the 'DENSE_RANK()' function ranks all employees in descending order of sales (specified by 'ORDER BY Sales DESC')\n-- If multiple employees have the same sales, they will get the same rank, and the rank of the next sales will not be skipped. So, if two employees are number one in sales, the next employee is number two, not number three.\nmysql> SELECT\nEmployee,\nSales,\nDENSE_RANK() OVER(ORDER BY Sales DESC) FROM\nSalesTable;\n+----------+-------+-----------------------------------------+\n| employee | sales | dense_rank() over (order by sales desc) |\n+----------+-------+-----------------------------------------+\n| Jane     |  1200 |                                       1 |\n| Bob      |  1100 |                                       2 |\n| John     |  1000 |                                       3 |\n| Alex     |   900 |                                       4 |\n| Charlie  |   850 |                                       5 |\n| Alice    |   800 |                                       6 |\n+----------+-------+-----------------------------------------+\n6 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/","title":"RANK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/#description","title":"Description","text":"

    RANK() provides a unique rank for each row in the dataset. RANK() first sorts the dataset according to the columns specified in the ORDER BY clause, then assigns each row a unique rank.

    The RANK() function has a unique behavior when it handles the case of equal values \u200b\u200b(i.e., tie). When two or more rows have the same value, they get the same rank. It will then skip the rank or ranks that follow it. For example, if two rows rank 1, the next row gets rank 3, not 2.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/#syntax","title":"Syntax","text":"
    > RANK() OVER (\n    [PARTITION BY column_1, column_2, ... ]\n    ORDER BY column_3, column_4, ...\n)\n
    • The PARTITION BY clause is optional and divides the dataset into partitions; the rank is computed individually inside each partition.
    • The ORDER BY clause defines how the dataset is sorted, i.e., according to which column or columns to sort. You can specify ascending (ASC) or descending (DESC) sorting.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/#examples","title":"Examples","text":"
    -- Create a new table, 'SalesTable' with three fields: 'Department', 'Employee', and 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- Insert data into the 'SalesTable' table; each row contains a department (Department), an employee (Employee), and their sales (Sales)\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- Query the 'SalesTable' table and return each employee in each department, their sales, and the total sales of their department (DepartmentSales)\n-- will also return each employee's sales rank in their department (SalesRank)\n-- For the total sales, use the window function SUM(), and use 'OVER(PARTITION BY Department)' to calculate each department separately\n-- For sales ranking, use the window function RANK(), and use 'OVER(PARTITION BY Department ORDER BY Sales DESC)' to rank employees in each department in descending order by sales\n-- In the RANK() function, if two employees have the same sales, they get the same rank, and the next sales rank is skipped. For example, if two employees are number one in sales, the next sales rank is number three, not number two.\nmysql> SELECT\nDepartment,\nEmployee,\nSales,\nSUM(Sales) OVER(PARTITION BY Department) AS DepartmentSales,\nRANK() OVER(PARTITION BY Department ORDER BY Sales DESC) AS SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------------+-----------+\n| department | employee | sales | DepartmentSales | SalesRank |\n+------------+----------+-------+-----------------+-----------+\n| HR         | Charlie  |   850 |            1650 |         1 |\n| HR         | Alice    |   800 |            1650 |         2 |\n| Marketing  | Jane     |  1200 |            2200 |         1 |\n| Marketing  | John     |  1000 |            2200 |         2 |\n| Sales      | Bob      |  1100 |            2000 |         1 |\n| Sales      | Alex     |   900 |            2000 |         2 |\n+------------+----------+-------+-----------------+-----------+\n6 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/","title":"ROW_NUMBER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/#description","title":"Description","text":"

    ROW_NUMBER() provides a unique ordinal number for each row in the dataset, starting at one and ending with the last row in the result set. It first sorts the dataset according to the columns specified in the ORDER BY clause and then assigns each row a unique number.

    Unlike the RANK() and DENSE_RANK() functions, ROW_NUMBER() gives each row a different row number when dealing with ties (i.e., two or more rows with the same value).

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/#syntax","title":"Syntax","text":"
    > ROW_NUMBER() OVER (\n    [PARTITION BY column_1, column_2, ... ]\n    ORDER BY column_3, column_4, ...\n)\n
    • The PARTITION BY clause is optional and divides the dataset into partitions; the rank is computed individually inside each partition.
    • The ORDER BY clause defines how the dataset is sorted, i.e., according to which column or columns to sort. You can specify ascending (ASC) or descending (DESC) sorting.
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/#examples","title":"Examples","text":"
    -- Create a new table, 'SalesTable' with three fields: 'Department', 'Employee', and 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- Insert data into the 'SalesTable' table; each row contains a department (Department), an employee (Employee), and their sales (Sales)\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- Query the sales ranking of employees in each department\n-- Use the ROW_NUMBER() function to rank employees by Department (Sales)\n-- The ROW_NUMBER() function divides the data set into multiple partitions according to the department (Department), then sorts the sales in descending order within each partition, and assigns each row a unique row number (SalesRank )\n-- So, the employee with the highest sales in each department will get row number 1, the employee with the second highest sales will get row number 2, and so on\nmysql> SELECT\nDepartment,\nEmployee,\nSales,\nROW_NUMBER() OVER (PARTITION BY Department ORDER BY Sales DESC) as SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------+\n| department | employee | sales | SalesRank |\n+------------+----------+-------+-----------+\n| HR         | Charlie  |   850 |         1 |\n| HR         | Alice    |   800 |         2 |\n| Marketing  | Jane     |  1200 |         1 |\n| Marketing  | John     |  1000 |         2 |\n| Sales      | Bob      |  1100 |         1 |\n| Sales      | Alex     |   900 |         2 |\n+------------+----------+-------+-----------+\n6 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/","title":"CURRENT_ROLE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#description","title":"Description","text":"

    Returns the role of the current session.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#syntax","title":"Syntax","text":"
    SELECT CURRENT_ROLE();\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#examples","title":"Examples","text":"
    mysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin        |\n+----------------+\n1 row in set (0.00 sec)\n\n-- Create a role and switch to the new role\ncreate role use_role_1;\ngrant all on database * to use_role_1;\ngrant use_role_1 to root;\nset role use_role_1;\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| use_role_1     |\n+----------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/","title":"CURRENT_ROLE_NAME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#description","title":"Description","text":"

    CURRENT_ROLE_NAME() is used to query the name of the role owned by the user you are currently logged in.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#syntax","title":"Syntax","text":"
    > CURRENT_ROLE_NAME()\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#examples","title":"Examples","text":"
    mysql> select current_role_name();\n+---------------------+\n| current_role_name() |\n+---------------------+\n| moadmin             |\n+---------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/","title":"CURRENT_USER, CURRENT_USER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#description","title":"Description","text":"

    Returns the current user account; the returned account format is username@hostname. The return value is a string in the utf8mb3 character set.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#syntax","title":"Syntax","text":"
    SELECT CURRENT_USER();\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#examples","title":"Examples","text":"
    mysql> select current_user();\n+----------------+\n| current_user() |\n+----------------+\n| root@0.0.0.0   |\n+----------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/","title":"CURRENT_USER_NAME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#description","title":"Description","text":"

    CURRENT_USER_NAME() is used to query the name of the user you are currently logged in as.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#syntax","title":"Syntax","text":"
    > CURRENT_USER_NAME()\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#examples","title":"Examples","text":"
    mysql> select current_user_name();\n+---------------------+\n| current_user_name() |\n+---------------------+\n| root                |\n+---------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/","title":"PURGE_LOG()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#description","title":"Description","text":"

    PURGE_LOG() deletes logs recorded in MatrixOne database system tables. Returning 0 means the deletion is successful; if the deletion fails, an error message will be returned.

    Note

    Only the root user (cluster administrator with MOADMIN privilege) can execute the PURGE_LOG() function for log deletion.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#syntax","title":"Syntax","text":"
    > PURGE_LOG('sys_table_name', 'date')\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#arguments","title":"Arguments","text":"Arguments Description 'sys_table_name' Currently, there are only three system tables that can be deleted: metric, rawlog, and statement_info. Note: 'sys_table_name' must be enclosed in quotes. 'date' Select a date and delete logs generated before that date. Note: 'date' must be enclosed in single quotes.

    Note

    MatrixOne has only three system log tables: metric, rawlog, and statement_info. For more information about these three tables, please refer to MatrixOne System Database and Tables.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#examples","title":"Examples","text":"
    • Example 1:
    -- Delete the statement_info type logs before 2023-06-30\nmysql> select purge_log('statement_info', '2023-06-30') a;\n+------+\n| a    |\n+------+\n| 0    |\n+------+\n1 row in set (0.01 sec)\n
    • Example 2:
    -- Query the time and quantity of metric log collection\nmysql> select date(collecttime), count(1) from system_metrics.metric group by date(collecttime);\n+-------------------+----------+\n| date(collecttime) | count(1) |\n+-------------------+----------+\n| 2023-07-07        |    20067 |\n| 2023-07-06        |    30246 |\n| 2023-07-05        |    27759 |\n+-------------------+----------+\n3 rows in set (0.00 sec)\n\n-- Delete rawlog, statement_info, and metric logs before 2023-07-06\nmysql> select purge_log('rawlog, statement_info, metric', '2023-07-06');\n+-------------------------------------------------------+\n| purge_log(rawlog, statement_info, metric, 2023-07-06) |\n+-------------------------------------------------------+\n|                                                     0 |\n+-------------------------------------------------------+\n1 row in set (0.33 sec)\n\n-- Query the number of metric logs for the three days of 2023-07-05, 2023-07-06 and 2023-07-07 again\nmysql> select date(collecttime), count(1) from system_metrics.metric group by date(collecttime);\n+-------------------+----------+\n| date(collecttime) | count(1) |\n+-------------------+----------+\n| 2023-07-06        |    30246 |\n| 2023-07-07        |    20121 |\n+-------------------+----------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/","title":"VERSION","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#description","title":"Description","text":"

    The VERSION() function is used to retrieve the version information of the current database management system. This function typically returns a string containing the version number of the database management system. For example, 0.8 indicates that the version of the MatrixOne database is 0.8.

    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#syntax","title":"Syntax","text":"
    > VERSION()\n
    "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#example","title":"Example","text":"
    mysql> select version();\n+-----------+\n| version() |\n+-----------+\n| 0.8       |\n+-----------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Language-Structure/comment/","title":"Comments","text":"

    This document describes the comment syntax supported by MatrixOne.

    MatrixOne supports three comment styles:

    • Use # character to comment a line.
    mysql> select 100-99;   # This comment continues to the end of line\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.01 sec)\n
    • Use -- to comment a line. The -- (double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on).
    mysql> select 100-99;   -- This comment continues to the end of line\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.01 sec)\n
    • From a /* sequence to the following */ sequence, as in the C programming language. This syntax enables a comment to extend over multiple lines because the beginning and closing sequences need not be on the same line.
    mysql> select 100 /* this is an in-line comment */ -99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.01 sec)\n

    Or:

    mysql> select 100\n/*\nthis is an in-line comment\n*/\n-99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Language-Structure/comment/#mysql-compatible-comment-syntax","title":"MySQL-compatible comment syntax","text":"

    The same as MySQL, MatrixOne supports a variant of C comment style:

    mysql> select 100 /*! Specific code */ -99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.02 sec)\n

    Or:

    mysql> select 100 /*!50110 Specific code */ -99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/Language-Structure/comment/#matrixone-specific-comment-syntax","title":"MatrixOne specific comment syntax","text":"

    MatrixOne supports a variant of C comment style:

    mysql> select 100-99;   // This comment continues to the end of line\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.03 sec)\n

    Or:

    mysql> // This comment continues to the line\n-> select 100-99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n
    "},{"location":"MatrixOne/Reference/Language-Structure/comment/#constraints","title":"Constraints","text":"

    MatrixOne does not support nested comments.

    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/","title":"Keywords","text":"

    This document introduces the keywords of MatrixOne. In MatrixOne, reserved keywords and non-reserved keywords are classified. When you use SQL statements, you can check reserved keywords and non-reserved keywords.

    Keyword is a word with a special meaning in SQL statements, such as SELECT, UPDATE, DELETE, and so on.

    • Reserved keyword: A word in a keyword that requires special processing before it can be used as an identifier is called a reserved keyword.

    When using reserved keywords as identifiers, they must be wrapped with backticks. Otherwise, an error will be reported:

    \\\\The reserved keyword select is not wrapped in backticks, resulting in an error.\nmysql> CREATE TABLE select (a INT);\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 19 near \" select (a INT)\";\n\n\\\\Correctly wrap the reserved keyword select with backticks.\nmysql> CREATE TABLE `select` (a INT);\nQuery OK, 0 rows affected (0.02 sec)\n
    • Non-reserved keywords: keywords can be directly used as identifiers, called non-reserved keywords.

    When using non-reserved keywords as identifiers, they can be used directly without wrapping them in backticks.

    \\\\BEGIN is not a reserved keyword and can be wrapped without backticks.\nmysql> CREATE TABLE `select` (BEGIN int);\nQuery OK, 0 rows affected (0.01 sec)\n

    Note

    Unlike MySQL, in MatrixOne, if the qualifier . is used, an error will be reported if the reserved keywords are not wrapped in backticks. It is recommended to avoid using reserved keywords when creating tables and databases:

    mysql> CREATE TABLE test.select (BEGIN int);\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 24 near \"select (BEGIN int)\";\n
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#reserved-keyword","title":"Reserved keyword","text":""},{"location":"MatrixOne/Reference/Language-Structure/keywords/#a","title":"A","text":"
    • ADD
    • ADMIN_NAME
    • ALL
    • AND
    • AS
    • ASC
    • ASCII
    • AUTO_INCREMENT
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#b","title":"B","text":"
    • BETWEEN
    • BINARY
    • BY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#c","title":"C","text":"
    • CASE
    • CHAR
    • CHARACTER
    • CHECK
    • COLLATE
    • COLLATION
    • CONVERT
    • COALESCE
    • COLUMN_NUMBER
    • CONSTRAINT
    • CREATE
    • CROSS
    • CURRENT
    • CURRENT_DATE
    • CURRENT_ROLE
    • CURRENT_USER
    • CURRENT_TIME
    • CURRENT_TIMESTAMP
    • CIPHER
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#d","title":"D","text":"
    • DATABASE
    • DATABASES
    • DECLARE
    • DEFAULT
    • DELAYED
    • DELETE
    • DESC
    • DESCRIBE
    • DISTINCT
    • DISTINCTROW
    • DIV
    • DROP
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#e","title":"E","text":"
    • ELSE
    • ENCLOSED
    • END
    • ESCAPE
    • ESCAPED
    • EXCEPT
    • EXISTS
    • EXPLAIN
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#f","title":"F","text":"
    • FALSE
    • FAILED_LOGIN_ATTEMPTS
    • FIRST
    • FOLLOWING
    • FOR
    • FORCE
    • FOREIGN
    • FROM
    • FULLTEXT
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#g","title":"G","text":"
    • GROUP
    • GROUPS
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#h","title":"H","text":"
    • HAVING
    • HOUR
    • HIGH_PRIORITY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#i","title":"I","text":"
    • IDENTIFIED
    • IF
    • IGNORE
    • IMPORT
    • IN
    • INFILE
    • INDEX
    • INNER
    • INSERT
    • INTERVAL
    • INTO
    • INT1
    • INT2
    • INT3
    • INT4
    • INT8
    • IS
    • ISSUER
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#j","title":"J","text":"
    • JOIN
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#k","title":"K","text":"
    • KEY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#l","title":"L","text":"
    • LAST
    • LEADING
    • LEFT
    • LIKE
    • LIMIT
    • LINES
    • LOAD
    • LOCALTIME
    • LOCALTIMESTAMP
    • LOCK
    • LOCKS
    • LOW_PRIORITY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#m","title":"M","text":"
    • MATCH
    • MAXVALUE
    • MICROSECOND
    • MINUTE
    • MOD
    • MODUMP
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#n","title":"N","text":"
    • NATURAL
    • NODE
    • NOT
    • NONE
    • NULL
    • NULLS
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#o","title":"O","text":"
    • ON
    • OPTIONAL
    • OPTIONALLY
    • OR
    • ORDER
    • OUTER
    • OUTFILE
    • OVER
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#p","title":"P","text":"
    • PASSWORD_LOCK_TIME
    • PARTITION
    • PRECEDING
    • PRIMARY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#q","title":"Q","text":"
    • QUICK
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#r","title":"R","text":"
    • RANDOM
    • REGEXP
    • RENAME
    • REPLACE
    • RETURNS
    • REUSE
    • RIGHT
    • REQUIRE
    • REPEAT
    • ROW
    • ROWS
    • ROW_COUNT
    • REFERENCES
    • RECURSIVE
    • REVERSE
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#s","title":"S","text":"
    • SAN
    • SECONDARY
    • SSL
    • SUBJECT
    • SCHEMA
    • SCHEMAS
    • SELECT
    • SECOND
    • SEPARATOR
    • SET
    • SHOW
    • SQL_SMALL_RESULT
    • SQL_BIG_RESULT
    • STRAIGHT_JOIN
    • STARTING
    • SUSPEND
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#t","title":"T","text":"
    • TABLE
    • TABLE_NUMBER
    • TABLE_SIZE
    • TABLE_VALUES
    • TERMINATED
    • THEN
    • TO
    • TRAILING
    • TRUE
    • TRUNCATE
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#u","title":"U","text":"
    • UNBOUNDED
    • UNION
    • UNIQUE
    • UPDATE
    • USE
    • USING
    • UTC_DATE
    • UTC_TIME
    • UTC_TIMESTAMP
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#v","title":"V","text":"
    • VALUES
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#w","title":"W","text":"
    • WHEN
    • WHERE
    • WEEK
    • WITH
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#non-reserved-keyword","title":"Non reserved keyword","text":""},{"location":"MatrixOne/Reference/Language-Structure/keywords/#a_1","title":"A","text":"
    • ACCOUNT
    • ACCOUNTS
    • AGAINST
    • AVG_ROW_LENGTH
    • AUTO_RANDOM
    • ATTRIBUTE
    • ACTION
    • ALGORITHM
    • ANY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#b_1","title":"B","text":"
    • BEGIN
    • BIGINT
    • BIT
    • BLOB
    • BOOL
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#c_1","title":"C","text":"
    • CHAIN
    • CHECKSUM
    • CLUSTER
    • COMPRESSION
    • COMMENT_KEYWORD
    • COMMIT
    • COMMITTED
    • CHARSET
    • COLUMNS
    • CONNECTION
    • CONSISTENT
    • COMPRESSED
    • COMPACT
    • COLUMN_FORMAT
    • CASCADE
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#d_1","title":"D","text":"
    • DATA
    • DATE
    • DATETIME
    • DECIMAL
    • DYNAMIC
    • DISK
    • DO
    • DOUBLE
    • DIRECTORY
    • DUPLICATE
    • DELAY_KEY_WRITE
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#e_1","title":"E","text":"
    • ENUM
    • ENCRYPTION
    • ENFORCED
    • ENGINE
    • ENGINES
    • ERRORS
    • EXPANSION
    • EXPIRE
    • EXTENDED
    • EXTENSION
    • EXTERNAL
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#f_1","title":"F","text":"
    • FORMAT
    • FLOAT_TYPE
    • FULL
    • FIXED
    • FIELDS
    • FORCE_QUOTE
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#g_1","title":"G","text":"
    • GEOMETRY
    • GEOMETRYCOLLECTION
    • GLOBAL
    • GRANT
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#h_1","title":"H","text":"
    • HASH
    • HEADER
    • HISTORY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#i_1","title":"I","text":"
    • INT
    • INTEGER
    • INDEXES
    • ISOLATION
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#j_1","title":"J","text":"
    • JSON
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#k_1","title":"K","text":"
    • KEY_BLOCK_SIZE
    • KEYS
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#l_1","title":"L","text":"
    • LANGUAGE
    • LESS
    • LEVEL
    • LINESTRING
    • LINEAR
    • LIST
    • LONGBLOB
    • LONGTEXT
    • LOCAL
    • LOW_CARDINALITY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#m_1","title":"M","text":"
    • MAX_CONNECTIONS_PER_HOUR
    • MAX_FILE_SIZE
    • MAX_QUERIES_PER_HOUR
    • MAX_ROWS
    • MAX_UPDATES_PER_HOUR
    • MAX_USER_CONNECTIONS
    • MEDIUMBLOB
    • MEDIUMINT
    • MEDIUMTEXT
    • MEMORY
    • MIN_ROWS
    • MODE
    • MONTH
    • MULTILINESTRING
    • MULTIPOINT
    • MULTIPOLYGON
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#n_1","title":"N","text":"
    • NAMES
    • NCHAR
    • NUMERIC
    • NEVER
    • NO
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#o_1","title":"O","text":"
    • OFFSET
    • ONLY
    • OPTIMIZE
    • OPEN
    • OPTION
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#p_1","title":"P","text":"
    • PACK_KEYS
    • PASSWORD
    • PARTIAL
    • PARTITIONS
    • POINT
    • POLYGON
    • PROCEDURE
    • PROFILES
    • PROXY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#q_1","title":"Q","text":"
    • QUARTER
    • QUERY
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#r_1","title":"R","text":"
    • ROLE
    • RANGE
    • READ
    • REAL
    • REORGANIZE
    • REDUNDANT
    • REPAIR
    • REPEATABLE
    • RELEASE
    • REVOKE
    • REPLICATION
    • ROW_FORMAT
    • ROLLBACK
    • RESTRICT
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#s_1","title":"S","text":"
    • SESSION
    • SERIALIZABLE
    • SHARE
    • SIGNED
    • SMALLINT
    • SNAPSHOT
    • SOME
    • SPATIAL
    • START
    • STATUS
    • STORAGE
    • STREAM
    • STATS_AUTO_RECALC
    • STATS_PERSISTENT
    • STATS_SAMPLE_PAGES
    • SUBPARTITIONS
    • SUBPARTITION
    • SIMPLE
    • S3OPTION
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#t_1","title":"T","text":"
    • TABLES
    • TEXT
    • THAN
    • TINYBLOB
    • TIME
    • TIMESTAMP
    • TINYINT
    • TINYTEXT
    • TRANSACTION
    • TRIGGER
    • TRIGGERS
    • TYPE
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#u_1","title":"U","text":"
    • UNCOMMITTED
    • UNKNOWN
    • UNSIGNED
    • UNUSED
    • UNLOCK
    • URL
    • USER
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#v_1","title":"V","text":"
    • VARBINARY
    • VARCHAR
    • VARIABLES
    • VIEW
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#w_1","title":"W","text":"
    • WRITE
    • WARNINGS
    • WORK
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#x","title":"X","text":"
    • X509
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#y","title":"Y","text":"
    • YEAR
    "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#z","title":"Z","text":"
    • ZEROFILL
    "},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/","title":"JDBC supported features list in MatrixOne","text":"

    Using JDBC to develop applications, MatrixOne supports the following classes and objects:

    "},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#1-connection-class-get-the-database-connection-object","title":"1. Connection (Class): Get the database connection object","text":""},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#method-of-the-class","title":"Method of the Class","text":"
    1. Obtain the executed Sql object Statement

      • Statement createStatement();
      • Statement prepareStatement(String sql);
    2. Manage the transaction

      • Enable the transaction: setAutoCommit(boolean autoCommit), call this method to set the parameter to false, which enable the transaction
      • Commit the transaction: void commit()
      • Rollback the transaction: void rollback()
    Methon of the connection interface Supported(Y)/Not support(N) createStatement() Y prepareStatement(String sql) Y prepareCall(String sql) Y nativeSQL(String sql) Y setAutoCommit(boolean autoCommit) Y getAutoCommit() Y commit() Y rollback() Y close() Y isClosed() Y getMetaData() Y setReadOnly(boolean readOnly) Y isReadOnly() Y setCatalog() Y getCatalog() Y setTransactionIsolation(int level) N getTransactionIsolation() N getWarnings() N clearWarnings() N createStatement(int resultSetType, int resultSetConcurrency) Y prepareStatement(String sql, int resultSetType, int resultSetConcurrency) Y prepareCall(String sql, int resultSetType, int resultSetConcurrency) Y getTypeMap() N setTypeMap(java.util.Map<String,Class<?>> map) N setHoldability(int holdability) N getHoldability() N setSavepoint() N setSavepoint(String name) N rollback(Savepoint savepoint) N releaseSavepoint(Savepoint savepoint) N createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) Y prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) Y prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) Y prepareStatement(String sql, int autoGeneratedKeys) Y prepareStatement(String sql, int columnIndexes[]) Y prepareStatement(String sql, String columnNames[]) Y createClob() N createBlob() N createNClob() N createSQLXML() N isValid() Y setClientInfo(String name, String value) N setClientInfo(Properties properties) N getClientInfo(String name) N getClientInfo() N createArrayOf(String typeName, Object[] elements) N createStruct(String typeName, Object[] attributes) N setSchema(String schema) N getSchema() N abort(Executor executor) N setNetworkTimeout(Executor executor, int milliseconds) Y getNetworkTimeout() Y"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#2-method-of-the-statement-class","title":"2. Method of the Statement class","text":"Method of the Statement class Supported(Y)/Not support(N) executeQuery(String sql) Y executeUpdate(String sql) Y close() Y getMaxFieldSize() Y setMaxFieldSize() Y getMaxRows() Y setMaxRows() Y setEscapeProcessing() N getQueryTimeout() Y setQueryTimeout(int seconds) Y cancel() Y getWarnings() N clearWarnings() N setCursorName(String name) N execute(String sql) Y getResultSet() Y getUpdateCount() Y getMoreResults() Y setFetchDirection(int direction) Y getFetchDirection() N setFetchSize(int rows) Y getFetchSize() Y getResultSetConcurrency() Y getResultSetType() Y addBatch( String sql) Y clearBatch() Y executeBatch() Y getConnection() Y getMoreResults(int current) Y getGeneratedKeys() Y executeUpdate(String sql, int autoGeneratedKeys) Y executeUpdate(String sql, int columnIndexes[]) Y executeUpdate(String sql, String columnNames[]) Y execute(String sql, int autoGeneratedKeys) Y execute(String sql, int columnIndexes[]) Y execute(String sql, String columnNames[]) Y getResultSetHoldability() Y isClosed() Y setPoolable(boolean poolable) N isPoolable() N closeOnCompletion() Y isCloseOnCompletion() Y"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#3-method-of-the-resultset-class","title":"3. Method of the ResultSet class","text":"Method of the ResultSet class Supported(Y)/Not support(N) next() Y close() Y wasNull() Y getString(int columnIndex) Y getBoolean(int columnIndex) Y getByte(int columnIndex) Y getShort(int columnIndex) Y getInt(int columnIndex) Y getLong(int columnIndex) Y getFloat(int columnIndex) Y getDouble(int columnIndex) Y getBigDecimal(int columnIndex, int scale) Y getBytes(int columnIndex) Y getDate(int columnIndex) Y getTime(int columnIndex) Y getTimestamp(int columnIndex) Y getAsciiStream(int columnIndex) Y getUnicodeStream(int columnIndex) Y getBinaryStream(int columnIndex) Y getWarnings() N clearWarnings() N getCursorName() N getMetaData() Y getObject() N findColumn() Y getCharacterStream() Y isBeforeFirst() Y isAfterLast() Y isFirst() Y isLast() Y beforeFirst() Y afterLast() Y first() Y last() Y getRow() Y absolute() Y relative() Y previous() Y setFetchDirection() Y getFetchDirection() Y setFetchSize() Y getFetchSize() Y getType() Y getConcurrency() Y rowUpdated() Y rowInserted() Y rowDeleted() Y update()(String of data types) Y updateNull() Y"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#4-method-of-the-resultsetmetadata","title":"4. Method of the ResultSetMetaData","text":"Method of the ResultSetMetaData Supported(Y)/Not support(N) getColumnCount() Y isAutoIncrement() Y isCaseSensitive() Y isSearchable() Y isCurrency() Y isNullable() Y isSigned() Y getColumnDisplaySize() Y getColumnLabel() Y getColumnName() Y getSchemaName() N getPrecision() Y getScale() Y getTableName() Y getCatalogName() Y getColumnType() Y getColumnTypeName() Y isReadOnly() N isWritable() N isDefinitelyWritable() N getColumnClassName() Y"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#displaysize-prec-and-scale-statistics-of-mysql-data-type","title":"DisplaySize, Prec, and Scale statistics of Mysql data type","text":"Data types DisplaySize Prec Scale TINYINT 4 4 0 SMALLINT 6 6 0 INT 11 11 0 BIGINT 20 20 0 TINYINT UNSIGNED 3 3 0 SMALLINT UNSIGNED 5 5 0 INT UNSIGNED 10 10 0 BIGINT UNSIGNED 20 20 0 DECIMAL64(according to the actual) 17 15 2 DECIMAL128(according to the actual) 23 21 3 FLOAT 12 12 31 DOUBLE 22 22 31 VARCHAR(according to the actual) 100 100 0 CHAR(according to the actual) 100 100 0 DATE 10 10 0 DATETIME 19 19 0 TIMESTAMP 19 19 0 JSON 2147483647 2147483647 0"},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/","title":"MatrixOne DDL statement partitioning supported","text":""},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#1-the-partition-type-supported-by-matrixone","title":"1. The partition type supported by MatrixOne","text":"

    MatrixOne DDL statements support six partition types, which are the same as the MySQL official website:

    • KEY Partitioning
    • HASH Partitioning

    Subpartitioning syntax is currently supported, but plan builds are not.

    "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#2-about-partition-keys","title":"2. About Partition Keys","text":""},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#partition-keys-primary-keys-and-unique-keys","title":"Partition Keys, Primary Keys and Unique Keys","text":"

    The relationship rules of Partition Keys, Primary Keys, and Unique Keys can be summarized as follows:

    • All columns used in a partitioning expression for a partitioned table must be part of every unique key that the table may have.

    !!! note The Unique KEY includes PrimaryKey and unique key.

    • That is, each unique key on a table must use each column of the table's partitioning expression. A unique key also includes the primary key of a table because, by definition, a table's primary key is also a unique one.
    "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#examples","title":"Examples","text":"

    For example, because the unique key on the table does not use every column in the table, each statement that creates the table below is invalid:

    > CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1, col2)\n)\nPARTITION BY HASH(col3)\nPARTITIONS 4;\nERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function\n\n> CREATE TABLE t2 (\n     col1 INT NOT NULL,\n     col2 DATE NOT NULL,\n     col3 INT NOT NULL,\n     col4 INT NOT NULL,\n     UNIQUE KEY (col1),\n     UNIQUE KEY (col3)\n )\n  PARTITION BY HASH(col1 + col3)\n  PARTITIONS 4;\n\nERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function\n
    "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#about-the-partition-key-is-null","title":"About the partition KEY is NULL","text":"
    1. KEY only accepts lists with Null or more column names. In cases where the table has a primary key, any column used as a partitioning key must contain some or all of the table's primary keys.

      If no column name is specified as the partitioning key, you can ues the table's primary key. For example, the following CREATE TABLE statement is valid in MySQL.

    2. If there is no primary KEY but a UNIQUE KEY, the UNIQUE KEY is used as the partitioning key.

      For example, in the following table construction sentence, the KEY partition key is NULL, no primary key is defined, but the unique key is used as the partitioning key when the partition expression is constructed:

    CREATE TABLE t1 (\ncol1 INT  NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1, col2)\n)\nPARTITION BY KEY()\nPARTITIONS 4;\n

    Note

    Other partition rules are the same as MySQL.

    "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#3-about-matrixone-partition-expressions","title":"3. About MatrixOne Partition Expressions","text":"

    \u200bWhen a DDL statement constructs a partitioned table, a partition expression is generated for each partition definition. The partition expression can calculate the partition to which the data belongs.

    In the plan build phase, the partition information data structure in the DDL statement is plan.PartitionInfo:

    type PartitionInfo struct {\nType                 PartitionType\nExpr                 *Expr\nPartitionExpression  *Expr\nColumns              []*Expr\nPartitionColumns     []string\nPartitionNum         uint64\nPartitions           []*PartitionItem\nAlgorithm            int64\nIsSubPartition       bool\nPartitionMsg         string\n}\n

    PartitionExpression is the partition expression. Partition expressions are MatrixOne's way of converting a partition clause into an expression. Each partition expression is constructed as follows:

    "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#key-partitioning","title":"KEY Partitioning","text":"

    KEY partitioning will construct a partition expression based on the partition key and the number of partitions. The result of the partition expression is an integer greater than or equal to 0, representing the partition sequence number, which increases sequentially from zero.

    SQL example is as below:

    CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nPRIMARY KEY (col1, col2)\n)\nPARTITION BY KEY(col1)\nPARTITIONS 4;\n
    "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#hash-partitioning","title":"HASH Partitioning","text":"

    HASH partitioning will construct a partition expression based on the partition function and the number of partitions. The result of the partition expression is an integer greater than or equal to 0, representing the partition sequence number, which increases sequentially from zero.

    SQL example is as below:

    CREATE TABLE t1 (\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n)\nPARTITION BY LINEAR HASH( YEAR(col3))\nPARTITIONS 6;\n
    "},{"location":"MatrixOne/Reference/Operators/interval/","title":"INTERVAL","text":""},{"location":"MatrixOne/Reference/Operators/interval/#description","title":"Description","text":"
    • The INTERVAL values are used mainly for date and time calculations. The INTERVAL in expressions represents a temporal interval.

    • Temporal intervals are used for certain functions, such as DATE_ADD() and DATE_SUB().

    • Temporal arithmetic also can be performed in expressions using INTERVAL together with the + or - operator:

      date + INTERVAL expr unit\ndate - INTERVAL expr unit\n
      • INTERVAL expr unit is permitted on either side of the + operator if the expression on the other side is a date or datetime value.
      • For the - operator, INTERVAL expr unit is permitted only on the right side, because it makes no sense to subtract a date or datetime value from an interval.
    "},{"location":"MatrixOne/Reference/Operators/interval/#syntax","title":"Syntax","text":"
    > INTERVAL (expr,unit)\n
    "},{"location":"MatrixOne/Reference/Operators/interval/#arguments","title":"Arguments","text":"Arguments Description expr represents a quantity. unit the unit for interpreting the quantity; it is a specifier such as HOUR, DAY, or WEEK.

    Note: The INTERVAL keyword and the unit specifier are not case-sensitive.

    • Temporal Interval Expression and Unit Arguments
    unit Value Expected expr Format MICROSECOND MICROSECONDS SECOND SECONDS MINUTE MINUTES HOUR HOURS DAY DAYS WEEK WEEKS MONTH MONTHS QUARTER QUARTERS YEAR YEARS SECOND_MICROSECOND 'SECONDS.MICROSECONDS' MINUTE_MICROSECOND 'MINUTES:SECONDS.MICROSECONDS' MINUTE_SECOND 'MINUTES:SECONDS' HOUR_MICROSECOND 'HOURS:MINUTES:SECONDS.MICROSECONDS' HOUR_SECOND 'HOURS:MINUTES:SECONDS' HOUR_MINUTE 'HOURS:MINUTES' DAY_MICROSECOND 'DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' DAY_SECOND 'DAYS HOURS:MINUTES:SECONDS' DAY_MINUTE 'DAYS HOURS:MINUTES' DAY_HOUR 'DAYS HOURS' YEAR_MONTH 'YEARS-MONTHS'

    We permits any punctuation delimiter in the expr format. Those shown in the table are the suggested delimiters.

    "},{"location":"MatrixOne/Reference/Operators/interval/#examples","title":"Examples","text":""},{"location":"MatrixOne/Reference/Operators/interval/#example-1","title":"Example 1","text":"
    • Temporal intervals are used for DATE_ADD() and DATE_SUB():
    mysql> SELECT DATE_SUB('2018-05-01',INTERVAL 1 YEAR);\n+-----------------------------------------+\n| date_sub(2018-05-01, interval(1, year)) |\n+-----------------------------------------+\n| 2017-05-01                              |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2020-12-31 23:59:59', INTERVAL 1 SECOND);\n+----------------------------------------------------+\n| date_add(2020-12-31 23:59:59, interval(1, second)) |\n+----------------------------------------------------+\n| 2021-01-01 00:00:00                                |\n+----------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_ADD('2018-12-31 23:59:59', INTERVAL 1 DAY);\n+-------------------------------------------------+\n| date_add(2018-12-31 23:59:59, interval(1, day)) |\n+-------------------------------------------------+\n| 2019-01-01 23:59:59                             |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2100-12-31 23:59:59', INTERVAL '1:1' MINUTE_SECOND);\n+-------------------------------------------------------------+\n| date_add(2100-12-31 23:59:59, interval(1:1, minute_second)) |\n+-------------------------------------------------------------+\n| 2101-01-01 00:01:00                                         |\n+-------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_SUB('2025-01-01 00:00:00', INTERVAL '1 1:1:1' DAY_SECOND);\n+--------------------------------------------------------------+\n| date_sub(2025-01-01 00:00:00, interval(1 1:1:1, day_second)) |\n+--------------------------------------------------------------+\n| 2024-12-30 22:58:59                                          |\n+--------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('1900-01-01 00:00:00', INTERVAL '-1 10' DAY_HOUR);\n+----------------------------------------------------------+\n| date_add(1900-01-01 00:00:00, interval(-1 10, day_hour)) |\n+----------------------------------------------------------+\n| 1899-12-30 14:00:00.000000                               |\n+----------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_SUB('1998-01-02', INTERVAL 31 DAY);\n+-----------------------------------------+\n| date_sub(1998-01-02, interval(31, day)) |\n+-----------------------------------------+\n| 1997-12-02                              |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('1992-12-31 23:59:59.000002', INTERVAL '1.999999' SECOND_MICROSECOND);\n+------------------------------------------------------------------------------+\n| date_add(1992-12-31 23:59:59.000002, interval(1.999999, second_microsecond)) |\n+------------------------------------------------------------------------------+\n| 1993-01-01 00:00:01.000001                                                   |\n+------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/interval/#example-2","title":"Example 2","text":"
    • Using INTERVAL together with the + or - operator
    mysql> SELECT '2018-12-31 23:59:59' + INTERVAL 1 SECOND;\n+-------------------------------------------+\n| 2018-12-31 23:59:59 + interval(1, second) |\n+-------------------------------------------+\n| 2019-01-01 00:00:00                       |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT INTERVAL 1 DAY + '2018-12-31';\n+-------------------------------+\n| interval(1, day) + 2018-12-31 |\n+-------------------------------+\n| 2019-01-01                    |\n+-------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT '2025-01-01' - INTERVAL 1 SECOND;\n+----------------------------------+\n| 2025-01-01 - interval(1, second) |\n+----------------------------------+\n| 2024-12-31 23:59:59              |\n+----------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/interval/#example-3","title":"Example 3","text":"

    If you add to or subtract from a date value something that contains a time part, the result is automatically converted to a datetime value:

    mysql> SELECT DATE_ADD('2023-01-01', INTERVAL 1 DAY);\n+----------------------------------------+\n| date_add(2023-01-01, interval(1, day)) |\n+----------------------------------------+\n| 2023-01-02                             |\n+----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2023-01-01', INTERVAL 1 HOUR);\n+-----------------------------------------+\n| date_add(2023-01-01, interval(1, hour)) |\n+-----------------------------------------+\n| 2023-01-01 01:00:00                     |\n+-----------------------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/interval/#example-4","title":"Example 4","text":"

    If you add MONTH, YEAR_MONTH, or YEAR and the resulting date has a day that is larger than the maximum day for the new month, the day is adjusted to the maximum days in the new month:

    mysql> SELECT DATE_ADD('2019-01-30', INTERVAL 1 MONTH);\n+------------------------------------------+\n| date_add(2019-01-30, interval(1, month)) |\n+------------------------------------------+\n| 2019-02-28                               |\n+------------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/interval/#example-5","title":"Example 5","text":"

    Date arithmetic operations require complete dates and do not work with incomplete dates such as '2016-07-00' or badly malformed dates:

    mysql> SELECT DATE_ADD('2016-07-00', INTERVAL 1 DAY);\n+----------------------------------------+\n| date_add(2016-07-00, interval(1, day)) |\n+----------------------------------------+\n| NULL                                   |\n+----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT '2005-03-32' + INTERVAL 1 MONTH;\n+---------------------------------+\n| 2005-03-32 + interval(1, month) |\n+---------------------------------+\n| NULL                            |\n+---------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/operator-precedence/","title":"Operator Precedence","text":"

    Operator precedences are shown in the following list, from highest precedence to the lowest. Operators that are shown together on a line have the same precedence.

    From highest precedence to the lowest Operators 1 INTERVAL 2 BINARY, COLLATE 3 ! 4 - (unary minus), ~ (unary bit inversion) 5 ^ 6 *, /, DIV, %, MOD 7 -, + 8 <<, >> 9 & 10 | 11 = (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, , IN, MEMBER OF 12 BETWEEN, CASE, WHEN, THEN, ELSE 13 NOT 14 AND, && 15 XOR 16 OR, || 17 = (assignment)

    The precedence of = depends on whether it is used as a comparison operator (=) or as an assignment operator (=). When used as a comparison operator, it has the same precedence as , >=, >, <=, <, <>, !=, IS, LIKE, and IN().

    For operators that occur at the same precedence level within an expression, evaluation proceeds left to right, with the exception that assignments evaluate right to left.

    "},{"location":"MatrixOne/Reference/Operators/operators/operators/","title":"Operators Overview","text":""},{"location":"MatrixOne/Reference/Operators/operators/operators/#arithmetic-operators","title":"Arithmetic Operators","text":"Name Description %,MOD Modulo operator * Multiplication operator + Addition operator - Minus operator - Change the sign of the argument / Division operator DIV Integer division"},{"location":"MatrixOne/Reference/Operators/operators/operators/#assignment-operators","title":"Assignment Operators","text":"Name Description = Equal operator"},{"location":"MatrixOne/Reference/Operators/operators/operators/#bit-functions-and-operators","title":"Bit Functions and Operators","text":"Name Description & Bitwise AND >> Right shift << Left shift ^ Bitwise XOR | Bitwise OR ~ Bitwise inversion"},{"location":"MatrixOne/Reference/Operators/operators/operators/#cast-functions-and-operators","title":"Cast Functions and Operators","text":"Name Description BINARY() Convert a value to a binary string CAST() Cast a value as a certain type CONVERT() Cast a value as a certain type"},{"location":"MatrixOne/Reference/Operators/operators/operators/#comparison-functions-and-operators","title":"Comparison Functions and Operators","text":"Name Description > Greater than operator >= Greater than or equal operator < Less than operator <>,!= Not equal operator <= Less than or equal operator = Equal operator BETWEEN ... AND ... Whether a value is within a range of values IN() Whether a value is within a set of values IS Test a value against a boolean IS NOT Test a value against a boolean IS NOT NULL NOT NULL value test IS NULL NULL value test ISNULL instead of = to test whether a value is NULL LIKE Simple pattern matching ILIKE Simple pattern matching. Same as LIKE. But it is not case sensitive. NOT BETWEEN ... AND ... Whether a value is not within a range of values NOT IN shorthand for multiple XOR conditions NOT LIKE Negation of simple pattern matching COALESCE Return the first non-null value in a list"},{"location":"MatrixOne/Reference/Operators/operators/operators/#flow-control-functions","title":"Flow Control Functions","text":"Name Description CASE Case operator IF() If/else construct IFNULL() Null if/else construct NULLIF() Return NULL if expr1 = expr2"},{"location":"MatrixOne/Reference/Operators/operators/operators/#logical-operators","title":"Logical Operators","text":"Name Description AND,&& Logical AND NOT,! Negates value OR Logical OR XOR Logical XOR"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/","title":"+","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#description","title":"Description","text":"

    The + operator is used for addition.

    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#syntax","title":"Syntax","text":"
    > SELECT value1+value2;\n
    > SELECT column1+column2... FROM table_name;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#examples","title":"Examples","text":"
    mysql> select 1123.2333+1233.3331;\n+-----------------------+\n| 1123.2333 + 1233.3331 |\n+-----------------------+\n|             2356.5664 |\n+-----------------------+\n1 row in set (0.01 sec)\n
    create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1+5 from t2;\n+--------+\n| c1 + 5 |\n+--------+\n|      2 |\n|      6 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1+c2 from t2;\n+---------+\n| c1 + c2 |\n+---------+\n|      -1 |\n|       3 |\n+---------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/","title":"Arithmetic Operators Overview","text":"Name Description %,MOD Modulo operator * Multiplication operator + Addition operator - Minus operator - Change the sign of the argument / Division operator DIV Integer division

    The usual arithmetic operators are available. The result is determined according to the following rules:

    • In the case of -, +, and *, the result is calculated with BIGINT (64-bit) precision if both operands are integers.

    • If both operands are integers and any of them are unsigned, the result is an unsigned integer.

    • If any of the operands of a +,-, /, *, % is a real or string value, the precision of the result is the precision of the operand with the maximum precision.

    In division performed with /, the scale of the result when using two exact-value operands is the scale of the first operand plus the value of the div_precision_increment system variable. For example, the result of the expression 5.05 / 0.014 has a scale of 13 decimal places (360.7142857142857).

    These rules are applied for each operation, such that nested calculations imply the precision of each component. Hence, (14620 / 9432456) / (24250 / 9432456), resolves first to (0.0014) / (0.0026), with the final result having 16 decimal places (0.6028865979381443).

    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/#constraints","title":"Constraints","text":"
    • Arithmetic operators only apply to numbers.
    • To ensure that components and subcomponents of a calculation use the appropriate level of precision. See Cast Functions and Operators.
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/","title":"DIV","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/#description","title":"Description","text":"

    The DIV operator is used for integer division. Discards from the division result any fractional part to the right of the decimal point.

    If either operand has a non-integer type, the operands are converted to DECIMAL and divided using DECIMAL arithmetic before converting the result to BIGINT. If the result exceeds BIGINT range, an error occurs.

    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/#syntax","title":"Syntax","text":"
    > SELECT value1 DIV value2;\n
    > SELECT column1 DIV column2... FROM table_name;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/#examples","title":"Examples","text":"
    mysql> SELECT 5 DIV 2, -5 DIV 2, 5 DIV -2, -5 DIV -2;\n+---------+----------+----------+-----------+\n| 5 div 2 | -5 div 2 | 5 div -2 | -5 div -2 |\n+---------+----------+----------+-----------+\n|       2 |       -2 |       -2 |         2 |\n+---------+----------+----------+-----------+\n1 row in set (0.00 sec)\n
    create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1 DIV 3 from t2;\n+----------+\n| c1 div 3 |\n+----------+\n|       -1 |\n|        0 |\n+----------+\n2 rows in set (0.00 sec)\n\nmysql> select c1 DIV c2 from t2;\n+-----------+\n| c1 div c2 |\n+-----------+\n|        -1 |\n|         0 |\n+-----------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/","title":"/","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#description","title":"Description","text":"

    The / operator is used for division.

    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#syntax","title":"Syntax","text":"
    > SELECT value1/value2;\n
    > SELECT column1/column2... FROM table_name;\n

    Division by zero produces a error result.

    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#examples","title":"Examples","text":"
    mysql> select 1123.2333/1233.3331;\n+-----------------------+\n| 1123.2333 / 1233.3331 |\n+-----------------------+\n|    0.9107298750029493 |\n+-----------------------+\n1 row in set (0.00 sec)\n
    create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1/2 from t2;\n+--------+\n| c1 / 2 |\n+--------+\n|   -1.5 |\n|    0.5 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1/c2 from t2;\n+---------+\n| c1 / c2 |\n+---------+\n|    -1.5 |\n|     0.5 |\n+---------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/","title":"-","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#description","title":"Description","text":"

    The - operator is used for subtraction.

    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#syntax","title":"Syntax","text":"
    > SELECT value1-value2;\n
    > SELECT column1-column2... FROM table_name;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#examples","title":"Examples","text":"
    mysql> select 1123.2333-1233.3331;\n+-----------------------+\n| 1123.2333 - 1233.3331 |\n+-----------------------+\n|   -110.09979999999996 |\n+-----------------------+\n1 row in set (0.00 sec)\n
    create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1-5 from t2;\n+--------+\n| c1 - 5 |\n+--------+\n|     -8 |\n|     -4 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1-c2 from t2;\n+---------+\n| c1 - c2 |\n+---------+\n|      -5 |\n|      -1 |\n+---------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/","title":"%,MOD","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#description","title":"Description","text":"

    The %,MOD operator is used for modulo operation. Returns the remainder of N divided by M. For more information.

    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#syntax","title":"Syntax","text":"
    > SELECT N % M, N MOD M;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#examples","title":"Examples","text":"
    mysql> select 12 mod 5;\n+--------+\n| 12 % 5 |\n+--------+\n|      2 |\n+--------+\n1 row in set (0.00 sec)\n
    create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1 mod 2 from t2;\n+--------+\n| c1 % 2 |\n+--------+\n|     -1 |\n|      1 |\n+--------+\n2 rows in set (0.01 sec)\n\nmysql> select c1 mod c2 from t2;\n+---------+\n| c1 % c2 |\n+---------+\n|      -1 |\n|       1 |\n+---------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/","title":"*","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#description","title":"Description","text":"

    The * operator is used for multiplication.

    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#syntax","title":"Syntax","text":"
    > SELECT value1*value2;\n
    > SELECT column1*column2... FROM table_name;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#examples","title":"Examples","text":"
    mysql> select 1123.2333*1233.3331;\n+-----------------------+\n| 1123.2333 * 1233.3331 |\n+-----------------------+\n|    1385320.8079122303 |\n+-----------------------+\n1 row in set (0.01 sec)\n
    create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1*2 from t2;\n+--------+\n| c1 * 2 |\n+--------+\n|     -6 |\n|      2 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1*c2 from t2;\n+---------+\n| c1 * c2 |\n+---------+\n|      -6 |\n|       2 |\n+---------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/","title":"-","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#description","title":"Description","text":"

    Unary minus. This operator changes the sign of the operand.

    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#syntax","title":"Syntax","text":"
    > SELECT -column1, -column2, ...\nFROM table_name;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#examples","title":"Examples","text":"
    mysql> select -2;\n+------+\n| -2   |\n+------+\n|   -2 |\n+------+\n
    create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select -c1 from t2;\n+------+\n| -c1  |\n+------+\n|    3 |\n|   -1 |\n+------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/","title":"Assignment Operators Overview","text":""},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/#assignment-operators-overview","title":"Assignment Operators Overview","text":"Name Description = Equal operator"},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/","title":"=","text":""},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#description","title":"Description","text":"

    This = operator is used to perform value assignments in the below cases:

    • Within a SET statement, = is treated as an assignment operator that causes the user variable on the left hand side of the operator to take on the value to its right. The value on the right hand side may be a literal value, another variable storing a value, or any legal expression that yields a scalar value, including the result of a query (provided that this value is a scalar value). You can perform multiple assignments in the same SET statement.

    • In the SET clause of an UPDATE statement, = also acts as an assignment operator. You can make multiple assignments in the same SET clause of an UPDATE statement.

    • In any other context, = is treated as a comparison operator.

    "},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#syntax","title":"Syntax","text":"
    > SELECT column1, column2, ...\nFROM table_name\nWHERE columnN = value1;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#examples","title":"Examples","text":"
    create table t1 (a bigint(3), b bigint(5) primary key);\ninsert into t1 VALUES (1,1),(1,2);\nupdate t1 set a=2 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 |    1 |\n|    1 |    2 |\n+------+------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bit-functions-and-operators-overview/","title":"Bit Functions and Operators","text":"Name Description & Bitwise AND >> Right shift << Left shift ^ Bitwise XOR [ ](bitwise-or.md) ~ Bitwise inversion

    Bit functions and operators required BIGINT (64-bit integer) arguments and returned BIGINT values, so they had a maximum range of 64 bits. Non-BIGINT arguments were converted to BIGINT prior to performing the operation and truncation could occur.

    Bit functions and operators permit binary string type arguments (BINARY, VARBINARY, and the BLOB types) and return a value of like type, which enables them to take arguments and produce return values larger than 64 bits. Nonbinary string arguments are converted to BIGINT and processed as such, as before.

    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/","title":"&","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#description","title":"Description","text":"

    Bitwise AND operator returns an unsigned 64-bit integer.

    The result type depends on whether the arguments are evaluated as binary strings or numbers:

    • Binary-string evaluation occurs when the arguments have a binary string type, and at least one of them is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to unsigned 64-bit integers as necessary.

    • Binary-string evaluation produces a binary string of the same length as the arguments. If the arguments have unequal lengths, an ER_INVALID_BITWISE_OPERANDS_SIZE error occurs. Numeric evaluation produces an unsigned 64-bit integer.

    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#syntax","title":"Syntax","text":"
    > SELECT value1 & value2;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#examples","title":"Examples","text":"
    mysql> SELECT 29 & 15;\n+---------+\n| 29 & 15 |\n+---------+\n|      13 |\n+---------+\n1 row in set (0.06 sec)\n\nCREATE TABLE bitwise (a_int_value INT NOT NULL,b_int_value INT NOT NULL);\nINSERT bitwise VALUES (170, 75);  mysql> SELECT a_int_value & b_int_value FROM bitwise;  +---------------------------+\n| a_int_value & b_int_value |\n+---------------------------+\n|                        10 |\n+---------------------------+\n1 row in set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/","title":"~","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#description","title":"Description","text":"

    Invert all bits.

    The result type depends on whether the bit argument is evaluated as a binary string or number:

    • Binary-string evaluation occurs when the bit argument has a binary string type, and is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to an unsigned 64-bit integer as necessary.

    • Binary-string evaluation produces a binary string of the same length as the bit argument. Numeric evaluation produces an unsigned 64-bit integer.

    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#syntax","title":"Syntax","text":"
    > SELECT value1 ~ value2;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#examples","title":"Examples","text":"
    mysql> select ~-5;\n+--------+\n| ~ (-5) |\n+--------+\n|      4 |\n+--------+\n1 row in set (0.00 sec)\n\nmysql> select ~null;\n+-------+\n| ~null |\n+-------+\n|  NULL |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> select ~a, ~b from t1;\n+------+----------------------+\n| ~a   | ~b                   |\n+------+----------------------+\n|    0 | 18446744073709551614 |\n|    4 | 18446744073709551610 |\n+------+----------------------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/","title":"|","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#description","title":"Description","text":"

    Bitwise OR.

    The result type depends on whether the arguments are evaluated as binary strings or numbers:

    • Binary-string evaluation occurs when the arguments have a binary string type, and at least one of them is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to unsigned 64-bit integers as necessary.

    • Binary-string evaluation produces a binary string of the same length as the arguments. If the arguments have unequal lengths, an ER_INVALID_BITWISE_OPERANDS_SIZE error occurs. Numeric evaluation produces an unsigned 64-bit integer.

    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#syntax","title":"Syntax","text":"
    > SELECT value1 | value2;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#examples","title":"Examples","text":"
    mysql> SELECT 29 | 15;\n+---------+\n| 29 | 15 |\n+---------+\n|      31 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null | 2;\n+----------+\n| null | 2 |\n+----------+\n|     NULL |\n+----------+\n1 row in set (0.01 sec)\n\nmysql> select null | 2;\n+----------+\n| null | 2 |\n+----------+\n|     NULL |\n+----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a | 2, b | 2 from t1;\n+-------+-------+\n| a | 2 | b | 2 |\n+-------+-------+\n|    -1 |     3 |\n|    -5 |     7 |\n+-------+-------+\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/","title":"^","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#description","title":"Description","text":"

    Bitwise XOR.

    The result type depends on whether the arguments are evaluated as binary strings or numbers:

    • Binary-string evaluation occurs when the arguments have a binary string type, and at least one of them is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to unsigned 64-bit integers as necessary.

    • Binary-string evaluation produces a binary string of the same length as the arguments. If the arguments have unequal lengths, an ER_INVALID_BITWISE_OPERANDS_SIZE error occurs. Numeric evaluation produces an unsigned 64-bit integer.

    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#syntax","title":"Syntax","text":"
    > SELECT value1 ^ value2;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#examples","title":"Examples","text":"
    mysql> SELECT 1 ^ 1;\n+-------+\n| 1 ^ 1 |\n+-------+\n|     0 |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> SELECT 1 ^ 0;\n+-------+\n| 1 ^ 0 |\n+-------+\n|     1 |\n+-------+\n1 row in set (0.01 sec)\n\nmysql> SELECT 11 ^ 3;\n+--------+\n| 11 ^ 3 |\n+--------+\n|      8 |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select null ^ 2;\n+----------+\n| null ^ 2 |\n+----------+\n|     NULL |\n+----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a ^ 2, b ^ 2 from t1;\n+-------+-------+\n| a ^ 2 | b ^ 2 |\n+-------+-------+\n|    -3 |     3 |\n|    -7 |     7 |\n+-------+-------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/","title":"<<","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#description","title":"Description","text":"

    Shifts a longlong (BIGINT) number or binary string to the left.

    The result type depends on whether the bit argument is evaluated as a binary string or number:

    • Binary-string evaluation occurs when the bit argument has a binary string type, and is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to an unsigned 64-bit integer as necessary.

    • Binary-string evaluation produces a binary string of the same length as the bit argument. Numeric evaluation produces an unsigned 64-bit integer.

    Bits shifted off the end of the value are lost without warning, regardless of the argument type. In particular, if the shift count is greater or equal to the number of bits in the bit argument, all bits in the result are 0.

    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#syntax","title":"Syntax","text":"
    > SELECT value1 << value2;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#examples","title":"Examples","text":"
    mysql> SELECT 1 << 2;\n+--------+\n| 1 << 2 |\n+--------+\n|      4 |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select -1 << 2;\n+---------+\n| -1 << 2 |\n+---------+\n|      -4 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null << 2;\n+-----------+\n| null << 2 |\n+-----------+\n|      NULL |\n+-----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a << 2, b << 2 from t1;\n+--------+--------+\n| a << 2 | b << 2 |\n+--------+--------+\n|     -4 |      4 |\n|    -20 |     20 |\n+--------+--------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/","title":">>","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#description","title":"Description","text":"

    Shifts a longlong (BIGINT) number or binary string to the right.

    The result type depends on whether the bit argument is evaluated as a binary string or number:

    • Binary-string evaluation occurs when the bit argument has a binary string type, and is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to an unsigned 64-bit integer as necessary.

    • Binary-string evaluation produces a binary string of the same length as the bit argument. Numeric evaluation produces an unsigned 64-bit integer.

    Bits shifted off the end of the value are lost without warning, regardless of the argument type. In particular, if the shift count is greater or equal to the number of bits in the bit argument, all bits in the result are 0.

    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#syntax","title":"Syntax","text":"
    > SELECT value1 >> value2;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#examples","title":"Examples","text":"
    mysql> select 1024 >> 2;\n+-----------+\n| 1024 >> 2 |\n+-----------+\n|       256 |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select -5 >> 2;\n+---------+\n| -5 >> 2 |\n+---------+\n|      -2 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null >> 2;\n+-----------+\n| null >> 2 |\n+-----------+\n|      NULL |\n+-----------+\n1 row in set (0.00 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a >> 2, b >> 2 from t1;\n+--------+--------+\n| a >> 2 | b >> 2 |\n+--------+--------+\n|     -1 |      0 |\n|     -2 |      1 |\n+--------+--------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/","title":"BINARY","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#description","title":"Description","text":"

    The BINARY() function is a function used to convert a value into a binary string. It is typically used when comparing text or character data, treating strings as binary rather than ordinary character data. This enables binary comparisons of character data regardless of character set or encoding.

    The BINARY() function implements binary comparison of character data, which handles cases such as case-sensitive string comparison.

    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#syntax","title":"Syntax","text":"
    > BINARY value\n
    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#parameter-values","title":"Parameter Values","text":"Parameter Description value Required. The value to convert"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#examples","title":"Examples","text":"
    CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, password VARCHAR(100) NOT NULL);\n\nINSERT INTO users (username, password) VALUES ('JohnDoe', 'Abcd123'), ('AliceSmith', 'Efgh456'), ('BobJohnson', 'ijkl789');\n\n-- Use the BINARY() operator for password verification, and the BINARY password = 'Abcd123' part treats the password value as a binary string, so the comparison is case-sensitive. If the entered password matches a record in the database, the query will return the corresponding user id and username. Otherwise, an empty result will be returned.\nmysql> SELECT id, username FROM users WHERE username = 'JohnDoe' AND BINARY password = 'Abcd123';\n+------+----------+\n| id   | username |\n+------+----------+\n|    1 | JohnDoe  |\n+------+----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT id, username FROM users WHERE username = 'JohnDoe' AND BINARY password = 'abcd123';\nEmpty set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast-functions-and-operators-overview/","title":"Cast Functions and Operators","text":"Name Description BINARY() convert a value to a binary string CAST() Cast a value as a certain type CONVERT() Cast a value as a certain type"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/","title":"CAST","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#description","title":"Description","text":"

    The CAST() function converts a value (of any type) into the specified datatype.

    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#syntax","title":"Syntax","text":"
    > CAST(value AS datatype)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#parameter-values","title":"Parameter Values","text":"Parameter Description value Required. The value to convert datatype Required. The datatype to convert to

    Currently, cast can support following conversion:

    • Conversion between numeric types, mainly including SIGNED, UNSIGNED, FLOAT, and DOUBLE type.
    • Numeric types to character CHAR type.
    • Numeric character types to numerical types(negative into SIGNED).
    • Time type (including Date, Datetime, Timestamp, and Time) is converted to INT type, with decimal point rounding
    • Time types (including Date, Datetime, Timestamp, and Time) are converted to fixed-point types with decimal places

    A detailed data type conversion rule can be refered to Data Conversion Rule.

    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#examples","title":"Examples","text":"
    drop table if exists t1;\nCREATE TABLE t1 (a int,b float,c char(1),d varchar(15));\nINSERT INTO t1 VALUES (1,1.5,'1','-2');\n\nmysql> SELECT CAST(a AS FLOAT) a_cast,CAST(b AS UNSIGNED) b_cast,CAST(c AS SIGNED) c_cast, CAST(d AS SIGNED) d_cast from t1;\n+--------+--------+--------+--------+\n| a_cast | b_cast | c_cast | d_cast |\n+--------+--------+--------+--------+\n| 1.0000 |      1 |      1 |     -2 |\n+--------+--------+--------+--------+\n\nmysql> SELECT CAST(a AS CHAR) a_cast, CAST(b AS CHAR) b_cast,CAST(c AS DOUBLE) c_cast, CAST(d AS FLOAT) d_cast from t1;\n+--------+--------+--------+---------+\n| a_cast | b_cast | c_cast | d_cast  |\n+--------+--------+--------+---------+\n| 1      | 1.5    | 1.0000 | -2.0000 |\n+--------+--------+--------+---------+\n
    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#constraints","title":"Constraints","text":"
    • Non-numeric character types cannot be converted to numeric types.
    • Numeric and character types with formats of Data cannot be converted to Date.
    • Date and Datetime types cannot be converted to character types.
    • Date and Datetime cannot be converted to each other.
    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/","title":"CONVERT","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#description","title":"Description","text":"

    The CONVERT() function converts a value into the specified datatype or character set.

    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#syntax","title":"Syntax","text":"
    > CONVERT(value, type)\n

    Or:

    > CONVERT(value USING charset)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#parameter-values","title":"Parameter Values","text":"Parameter Description value Required. The value to convert. datatype Required. The datatype to convert to. charset Required. The character set to convert to.

    Currently, convert can support following conversion:

    • Conversion between numeric types, mainly including SIGNED, UNSIGNED, FLOAT, and DOUBLE type.
    • Numeric types to character CHAR type.
    • Numeric character types to numerical types(negative into SIGNED).
    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#examples","title":"Examples","text":"
    mysql> select convert(150,char);\n+-------------------+\n| cast(150 as char) |\n+-------------------+\n| 150               |\n+-------------------+\n1 row in set (0.01 sec)\n
    CREATE TABLE t1(a tinyint);\nINSERT INTO t1 VALUES (127);\n\nmysql> SELECT 1 FROM\n-> (SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1) AS s LIMIT 1;\n+------+\n| 1    |\n+------+\n|    1 |\n+------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#constraints","title":"Constraints","text":"
    • Non-numeric character types cannot be converted to numeric types.
    • Numeric and character types with formats of Data cannot be converted to Date.
    • Date and Datetime types cannot be converted to character types.
    • Date and Datetime cannot be converted to each other.
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/","title":"=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#description","title":"Description","text":"

    The = operator returns true only if the left-hand operand is equal to the right-hand operand.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#syntax","title":"Syntax","text":"
    > SELECT x = y;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#examples","title":"Examples","text":"
    mysql> SELECT 2 = 2;\n+-------+\n| 2 = 2 |\n+-------+\n| true  |\n+-------+\n1 row in set (0.01 sec)\n
    create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where userID=spID and userID=score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n|      1 |    1 |     1 |\n|      2 |    2 |     2 |\n|      3 |    3 |     3 |\n+--------+------+-------+\n3 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/","title":"BETWEEN ... AND ...","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#description","title":"Description","text":"

    If expr is greater than or equal to min and expr is less than or equal to max, BETWEEN returns true, otherwise it returns false.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#syntax","title":"Syntax","text":"
    > expr BETWEEN min AND max\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#examples","title":"Examples","text":"
    mysql> SELECT 2 BETWEEN 1 AND 3, 2 BETWEEN 3 and 1;\n+-------------------+-------------------+\n| 2 between 1 and 3 | 2 between 3 and 1 |\n+-------------------+-------------------+\n| true              | false             |\n+-------------------+-------------------+\n1 row in set (0.01 sec)\n
    create table t (id bigint unsigned, b int);\ninsert into t values(8894754949779693574,1);\ninsert into t values(8894754949779693579,2);\ninsert into t values(17790886498483827171,3);\n\nmysql> select count(*) from t where id>=8894754949779693574 and id =17790886498483827171 order by 1 asc;\n+----------+\n| count(*) |\n+----------+\n|        0 |\n+----------+\n\nmysql> select count(*) from t where id between 8894754949779693574 and 17790886498483827171;\n+----------+\n| count(*) |\n+----------+\n|        0 |\n+----------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/","title":"COALESCE()","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#description","title":"Description","text":"

    The COALESCE() function returns the first non-null value in a list.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#syntax","title":"Syntax","text":"
    > COALESCE(val1, val2, ...., val_n)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#arguments","title":"Arguments","text":"Arguments Description val1, val2, val_n Required. The values to test"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#examples","title":"Examples","text":"
    • Example: Calculate
    mysql> SELECT COALESCE(1)+COALESCE(1);\n+---------------------------+\n| coalesce(1) + coalesce(1) |\n+---------------------------+\n|                         2 |\n+---------------------------+\n
    • Example: Comparison
    drop table if exists t2;\ncreate table t2(a float, b datetime);\ninsert into t2 values (12.345, '2022-02-20 10:10:10.999999');\ninsert into t2 values (3.45646, NULL);\ninsert into t2 values(NULL, '2023-04-03 22:10:29.999999');\ninsert into t2 values (NULL, NULL);\n\nmysql> select * from t2;\n+---------+---------------------+\n| a       | b                   |\n+---------+---------------------+\n|  12.345 | 2022-02-20 10:10:11 |\n| 3.45646 | NULL                |\n|    NULL | 2023-04-03 22:10:30 |\n|    NULL | NULL                |\n+---------+---------------------+\nmysql> select coalesce(a, 1.0) from t2;\n+--------------------+\n| coalesce(a, 1.0)   |\n+--------------------+\n| 12.345000267028809 |\n| 3.4564599990844727 |\n|                  1 |\n|                  1 |\n+--------------------+\nmysql> select coalesce(a, 1) from t2;\n+--------------------+\n| coalesce(a, 1)     |\n+--------------------+\n| 12.345000267028809 |\n| 3.4564599990844727 |\n|                  1 |\n|                  1 |\n+--------------------+\nmysql> select coalesce(b, 2022-01-01) from t2;\n+---------------------------+\n| coalesce(b, 2022 - 1 - 1) |\n+---------------------------+\n| 2022-02-20 10:10:11       |\n|                           |\n| 2023-04-03 22:10:30       |\n|                           |\n+---------------------------+\n
    • Example: ORDER BY Clause
    CREATE TABLE t1 ( a INTEGER, b varchar(255) );\nINSERT INTO t1 VALUES (1,'z');\nINSERT INTO t1 VALUES (2,'y');\nINSERT INTO t1 VALUES (3,'x');\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(MIN(b), 'a');\n+-------+\n| min_b |\n+-------+\n| x     |\n| y     |\n| z     |\n+-------+\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(min_b, 'a');\n+-------+\n| min_b |\n+-------+\n| x     |\n| y     |\n| z     |\n+-------+\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(MIN(b), 'a') DESC;\n+-------+\n| min_b |\n+-------+\n| z     |\n| y     |\n| x     |\n+-------+\n
    • Example: Case When Clause
    mysql> select if(1, cast(1111111111111111111 as unsigned), 1) i,case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, coalesce(cast(1111111111111111111 as unsigned), 1) co;\n+---------------------+---------------------+---------------------+\n| i                   | c                   | co                  |\n+---------------------+---------------------+---------------------+\n| 1111111111111111111 | 1111111111111111111 | 1111111111111111111 |\n+---------------------+---------------------+---------------------+\n
    • Example: IN Subquery
    CREATE TABLE ot (col_int_nokey int(11), col_varchar_nokey varchar(1));\nINSERT INTO ot VALUES (1,'x');\nCREATE TABLE it (col_int_key int(11), col_varchar_key varchar(1));\nINSERT INTO it VALUES (NULL,'x'), (NULL,'f');\n\nmysql> SELECT col_int_nokey FROM ot WHERE col_varchar_nokey IN(SELECT col_varchar_key FROM it WHERE coalesce(col_int_nokey, 1) );\n+---------------+\n| col_int_nokey |\n+---------------+\n|             1 |\n+---------------+\n
    • Example: WHERE
    CREATE TABLE ot1(a INT);\nCREATE TABLE ot2(a INT);\nCREATE TABLE ot3(a INT);\nCREATE TABLE it1(a INT);\nCREATE TABLE it2(a INT);\nCREATE TABLE it3(a INT);\nINSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);\nINSERT INTO ot2 VALUES(0),(2),(4),(6);\nINSERT INTO ot3 VALUES(0),(3),(6);\nINSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);\nINSERT INTO it2 VALUES(0),(2),(4),(6);\nINSERT INTO it3 VALUES(0),(3),(6);\n\nmysql> SELECT * FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3);\n+------+------+\n| a    | a    |\n+------+------+\n|    0 |    0 |\n|    1 | NULL |\n|    3 | NULL |\n|    5 | NULL |\n|    6 |    6 |\n|    7 | NULL |\n+------+------+\n
    • Example: HAVING
    drop table if exists t1;\ncreate table t1(a datetime);\nINSERT INTO t1 VALUES (NULL), ('2001-01-01 00:00:00.12'), ('2002-01-01 00:00:00.567');\n\nmysql> select a from t1 group by a having COALESCE(a)<\"2002-01-01\";\n+---------------------+\n| a                   |\n+---------------------+\n| 2001-01-01 00:00:00 |\n+---------------------+\n
    • Example: ON CONDITION
    drop table if exists t1;\ndrop table if exists t2;\ncreate table t1(a INT,  b varchar(255));\ncreate table t2(a INT,  b varchar(255));\ninsert into t1 values(1, \"\u4f60\u597d\"), (3, \"\u518d\u89c1\");\ninsert into t2 values(2, \"\u65e5\u671f\u65f6\u95f4\"), (4, \"\u660e\u5929\");\n> SELECT t1.a, t2.a FROM t1 JOIN t2 ON (length(COALESCE(t1.b)) = length(COALESCE(t2.b)));\n+------+------+\n| a    | a    |\n+------+------+\n|    1 |    4 |\n|    3 |    4 |\n+------+------+\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/comparison-functions-and-operators-overview/","title":"Comparison Functions and Operators Overview","text":"Name Description > Greater than operator >= Greater than or equal operator < Less than operator <>,!= Not equal operator <= Less than or equal operator = Equal operator BETWEEN ... AND ... Whether a value is within a range of values COALESCE Return the first non-null value in a list IN() Whether a value is within a set of values IS Test a value against a boolean IS NOT Test a value against a boolean IS NOT NULL NOT NULL value test IS NULL NULL value test ISNULL NULL value test LIKE Simple pattern matching ILIKE Simple pattern matching. Same as LIKE. But it is not case sensitive. NOT BETWEEN ... AND ... Whether a value is not within a range of values NOT IN shorthand for multiple XOR conditions. NOT LIKE Negation of simple pattern matching

    Comparison operations result in a value of TRUE, FALSE, or NULL. These operations work for both numbers and strings. Strings are automatically converted to numbers and numbers to strings as necessary.

    The following relational comparison operators can be used to compare not only scalar operands, but row operands:

    =  >  <  >=  <=  <>  !=\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/","title":"INTERVAL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#description","title":"Description","text":"

    The INTERVAL operator returns 0 if N < N1, 1 if N < N2 and so on or -1 if N is NULL. All arguments are treated as integers. It is required that N1 < N2 < N3 < ... < Nn for this function to work correctly. This is because a binary search is used (very fast).

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#syntax","title":"Syntax","text":"
    > INTERVAL(N,N1,N2,N3,...)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#examples","title":"Examples","text":"
    >\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/","title":"ISNULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#description","title":"Description","text":"

    The ISNULL() function can be used instead of = to test whether a value is NULL. (Comparing a value to NULL using = always yields NULL.)

    If expression is NULL, this function returns true. Otherwise, it returns false.

    The ISNULL() function shares some special behaviors with the IS NULL comparison operator. See the description of IS NULL.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#syntax","title":"Syntax","text":"
    > ISNULL(expr)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#examples","title":"Examples","text":"
    • Example 1:
    mysql> SELECT ISNULL(1+1);\n+---------------+\n| isnull(1 + 1) |\n+---------------+\n| false         |\n+---------------+\n1 row in set (0.02 sec)\n
    • Example 2:
    CREATE TABLE students (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, birth_date DATE );\n\nINSERT INTO students (name, birth_date) VALUES ('John Doe', '2000-05-15'), ('Alice Smith', NULL), ('Bob Johnson', '1999-10-20');\n\n-- Use the ISNULL() function to find students whose birth date is not filled in:\nmysql> SELECT * FROM students WHERE ISNULL(birth_date);\n+------+-------------+------------+\n| id   | name        | birth_date |\n+------+-------------+------------+\n|    2 | Alice Smith | NULL       |\n+------+-------------+------------+\n1 row in set (0.00 sec)\n\n-- The ISNULL() function can also use IS NULL to achieve the same function, so the following queries are also equivalent:\nmysql> SELECT * FROM students WHERE birth_date IS NULL;\n+------+-------------+------------+\n| id   | name        | birth_date |\n+------+-------------+------------+\n|    2 | Alice Smith | NULL       |\n+------+-------------+------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/","title":"STRCMP","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#description","title":"Description","text":"

    The STRCMP() returns 0 if the strings are the same, -1 if the first argument is smaller than the second according to the current sort order, and NULL if either argument is NULL. It returns 1 otherwise.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#syntax","title":"Syntax","text":"
    > STRCMP(expr1,expr2)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#examples","title":"Examples","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/","title":">=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#description","title":"Description","text":"

    The >= operator returns true only if the left-hand operand is greater than or equal to the right-hand operand.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#syntax","title":"Syntax","text":"
    > SELECT x >= y;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#examples","title":"Examples","text":"
    mysql> SELECT 2 >= 2;\n+--------+\n| 2 >= 2 |\n+--------+\n| true   |\n+--------+\n1 row in set (0.01 sec)\n
    create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where spID>=userID*score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n|      1 |    1 |     1 |\n+--------+------+-------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/","title":">","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#description","title":"Description","text":"

    The > operator returns true only if the left-hand operand is greater than the right-hand operand.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#syntax","title":"Syntax","text":"
    > SELECT x > y;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#examples","title":"Examples","text":"
    mysql> SELECT 2 > 2;\n+-------+\n| 2 > 2 |\n+-------+\n| false |\n+-------+\n1 row in set (0.00 sec)\n
    create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select spID,userID,score from t1 where spID>(userID-1);\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n|    1 |      1 |     1 |\n|    2 |      2 |     2 |\n|    2 |      1 |     4 |\n|    3 |      3 |     3 |\n|    1 |      1 |     5 |\n+------+--------+-------+\n5 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/","title":"ILIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#description","title":"Description","text":"

    The ILIKE operator is used similarly to the LIKE operator to search for a specified pattern in a column in the WHERE clause.

    The main difference between the ILIKE operator and the LIKE operator is case sensitivity. When using ILIKE, characters in a string are treated the same whether they are uppercase or lowercase.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#syntax","title":"Syntax","text":"
    > SELECT column1, column2, ...\nFROM table_name\nWHERE columnN ILIKE pattern;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#examples","title":"Examples","text":"
    drop table t1;\ncreate table t1(a varchar(20));\ninsert into t1 values ('abc'), ('ABC'), ('abC');\nselect * from t1 where a ilike '%abC%';\n\nmysql> select * from t1 where a ilike '%abC%';\n+------+\n| a    |\n+------+\n| abc  |\n| ABC  |\n| abC  |\n+------+\n3 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/","title":"IN","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#description","title":"Description","text":"

    The IN operator allows you to specify multiple values in a WHERE clause. And it's a shorthand for multiple OR conditions.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#syntax","title":"Syntax","text":"
    > SELECT column1, column2, ...\nFROM table_name\nWHERE column_name IN (value1, value2, ...);\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#examples","title":"Examples","text":"
    create table t2(a int,b varchar(5),c float, d date, e datetime);\ninsert into t2 values(1,'a',1.001,'2022-02-08','2022-02-08 12:00:00');\ninsert into t2 values(2,'b',2.001,'2022-02-09','2022-02-09 12:00:00');\ninsert into t2 values(1,'c',3.001,'2022-02-10','2022-02-10 12:00:00');\ninsert into t2 values(4,'d',4.001,'2022-02-11','2022-02-11 12:00:00');\n\nmysql> select * from t2 where a in (2,4);\na   b   c   d   e\n2   b   2.0010  2022-02-09  2022-02-09 12:00:00\n4   d   4.0010  2022-02-11  2022-02-11 12:00:00\n\nmysql> select * from t2 where a not in (2,4);\na   b   c   d   e\n1   a   1.0010  2022-02-08  2022-02-08 12:00:00\n1   c   3.0010  2022-02-10  2022-02-10 12:00:00\n\nmysql> select * from t2 where b not in ('e',\"f\");\na   b   c   d   e\n1   a   1.0010  2022-02-08  2022-02-08 12:00:00\n2   b   2.0010  2022-02-09  2022-02-09 12:00:00\n1   c   3.0010  2022-02-10  2022-02-10 12:00:00\n4   d   4.0010  2022-02-11  2022-02-11 12:00:00\n\nmysql> select * from t2 where e not in ('2022-02-09 12:00:00') and a in (4,5);\na   b   c   d   e\n4   d   4.0010  2022-02-11  2022-02-11 12:00:00\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#constraints","title":"Constraints","text":"
    • Currently, only constant lists are supported on the left side of IN.
    • There can only be a single column to the left of IN, not a tuple of multiple columns.
    • NULL values couldn't appear in the list to the right of IN.
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/","title":"IS NOT NULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/#description","title":"Description","text":"

    The IS NOT NULL function tests whether a value is not NULL.

    If expression is NOT NULL, this function returns true. Otherwise, it returns false.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/#syntax","title":"Syntax","text":"
    > expression IS NOT NULL\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/#examples","title":"Examples","text":"
    mysql> SELECT 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL;\n+---------------+---------------+------------------+\n| 1 is not null | 0 is not null | null is not null |\n+---------------+---------------+------------------+\n| true          | true          | false            |\n+---------------+---------------+------------------+\n1 row in set (0.01 sec)\n
    create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n| NULL  | NULL  |\n+-------+-------+\nmysql> select * from t1 where b is NOT NULL;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n+-------+-------+\n4 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/","title":"IS NOT","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#description","title":"Description","text":"

    The IS NOT tests a value against a boolean value, where boolean_value can be TRUE, FALSE, or UNKNOWN.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#syntax","title":"Syntax","text":"
    > IS NOT boolean_value\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#examples","title":"Examples","text":"
    mysql> SELECT 1 IS NOT TRUE, 0 IS NOT FALSE, NULL IS NOT UNKNOWN;\n+-----------+------------+----------+\n| 1 != true | 0 != false | null !=  |\n+-----------+------------+----------+\n| false     | false      | NULL     |\n+-----------+------------+----------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/","title":"IS NULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#description","title":"Description","text":"

    The IS NOT NULL function tests whether a value is NULL.

    It returns TRUE if a NULL value is found, otherwise it returns FALSE. It can be used in a SELECT, INSERT, UPDATE, or DELETE statement.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#syntax","title":"Syntax","text":"
    > expression IS NULL\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#examples","title":"Examples","text":"
    mysql> SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL;\n+-----------+-----------+--------------+\n| 1 is null | 0 is null | null is null |\n+-----------+-----------+--------------+\n| false     | false     | true         |\n+-----------+-----------+--------------+\n1 row in set (0.01 sec)\n
    create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n| NULL  | NULL  |\n+-------+-------+\nmysql> select * from t1 where a IS NULL;\n+------+------+\n| a    | b    |\n+------+------+\n| NULL | NULL |\n+------+------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/","title":"IS","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#description","title":"Description","text":"

    The IS tests a value against a boolean value, where boolean_value can be TRUE, FALSE, or UNKNOWN.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#syntax","title":"Syntax","text":"
    > IS boolean_value\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#examples","title":"Examples","text":"
    mysql> SELECT 1 IS TRUE, 0 IS FALSE, NULL IS UNKNOWN;\n+----------+-----------+---------+\n| 1 = true | 0 = false | null =  |\n+----------+-----------+---------+\n| true     | true      | NULL    |\n+----------+-----------+---------+\n1 row in set (0.01 sec)\n
    create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n| NULL  | NULL  |\n+-------+-------+\nmysql> select * from t1 where a<=b and a is not NULL;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | true  |\n| false | false |\n+-------+-------+\n3 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/","title":"<=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#description","title":"Description","text":"

    The <= operator returns true only if the left-hand operand is less than or equal to the right-hand operand.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#syntax","title":"Syntax","text":"
    > SELECT x <= y;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#examples","title":"Examples","text":"
    mysql> SELECT 2 <= 2;\n+--------+\n| 2 <= 2 |\n+--------+\n| true   |\n+--------+\n1 row in set (0.00 sec)\n
    create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,score,spID from t1 where userID<=score/spID;\n+--------+-------+------+\n| userid | score | spid |\n+--------+-------+------+\n|      1 |     1 |    1 |\n|      1 |     4 |    2 |\n|      1 |     5 |    1 |\n|     11 |    99 |    5 |\n+--------+-------+------+\n4 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/","title":"<","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#description","title":"Description","text":"

    The < operator returns true only if the left-hand operand is less than the right-hand operand.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#syntax","title":"Syntax","text":"
    > SELECT x < y;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#examples","title":"Examples","text":"
    mysql> SELECT 2 < 2;\n+-------+\n| 2 < 2 |\n+-------+\n| false |\n+-------+\n1 row in set (0.00 sec)\n
    create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select spID,userID,score from t1 where (userID-1)<spID;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n|    1 |      1 |     1 |\n|    2 |      2 |     2 |\n|    2 |      1 |     4 |\n|    3 |      3 |     3 |\n|    1 |      1 |     5 |\n+------+--------+-------+\n5 rows in set (0.00 sec)\nmysql> select spID,userID,score from t1 where spID<(userID-1);\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n|    4 |      6 |    10 |\n|    5 |     11 |    99 |\n+------+--------+-------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/","title":"LIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#description","title":"Description","text":"

    The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

    There are two wildcards often used in conjunction with the LIKE operator:

    • The percent sign % wildcard: means to match any sequence of characters (including empty character sequences).

      • %text: matches a string ending with \"text\".
      • text%: matches a string starting with \"text\".
      • %text%: Matches a string containing \"text\".
    • Underscore _ wildcard: means match a single character.

      • te_t: can match \"text\", \"test\", etc.
    • Other characters: The LIKE operator is case-sensitive for other characters.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#syntax","title":"Syntax","text":"
    > SELECT column1, column2, ...\nFROM table_name\nWHERE columnN LIKE pattern;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#examples","title":"Examples","text":"
    drop table t1;\ncreate table t1(a varchar(20));\ninsert into t1 values ('abc'), ('ABC'), ('abC');\nselect * from t1 where a ilike '%abC%';\n\nmysql> select * from t1 where a like '%abC%';\n+------+\n| a    |\n+------+\n| abC  |\n+------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/","title":"NOT BETWEEN ... AND ...","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#description","title":"Description","text":"

    If expr is less than or equal to min and expr is greater than or equal to max, NOT BETWEEN returns true, otherwise it returns false.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#syntax","title":"Syntax","text":"
    > expr NOT BETWEEN min AND max\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#examples","title":"Examples","text":"
    mysql> SELECT 2 NOT BETWEEN 1 AND 3, 2 NOT BETWEEN 3 and 1;\n+-----------------------+-----------------------+\n| 2 not between 1 and 3 | 2 not between 3 and 1 |\n+-----------------------+-----------------------+\n| false                 | true                  |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n
    create table t (id bigint unsigned, b int);\ninsert into t values(8894754949779693574,1);\ninsert into t values(8894754949779693579,2);\ninsert into t values(17790886498483827171,3);\n\nmysql> select count(*) from t where id>=8894754949779693574 and id =17790886498483827171 order by 1 asc;\n+----------+\n| count(*) |\n+----------+\n|        0 |\n+----------+\nmysql> select count(*) from t where id not between 8894754949779693574 and 17790886498483827171;\n+----------+\n| count(*) |\n+----------+\n|        3 |\n+----------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/","title":"<>,!=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#description","title":"Description","text":"

    The <>,!= operator returns true only if the left-hand operand is not equal to the right-hand operand.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#syntax","title":"Syntax","text":"
    > SELECT x <> y;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#examples","title":"Examples","text":"
    mysql> SELECT 2 <> 2;\n+--------+\n| 2 != 2 |\n+--------+\n| false  |\n+--------+\n1 row in set (0.01 sec)\n
    create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where userID=spID and userID<>score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n|      1 |    1 |     5 |\n+--------+------+-------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/","title":"NOT IN","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#description","title":"Description","text":"

    The NOT IN operator allows you to specify multiple values in a WHERE clause. And it's a shorthand for multiple XOR conditions.

    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#syntax","title":"Syntax","text":"
    > SELECT column1, column2, ...\nFROM table_name\nWHERE column_name NOT IN (value1, value2, ...);\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#examples","title":"Examples","text":"
    create table t2(a int,b varchar(5),c float, d date, e datetime);\ninsert into t2 values(1,'a',1.001,'2022-02-08','2022-02-08 12:00:00');\ninsert into t2 values(2,'b',2.001,'2022-02-09','2022-02-09 12:00:00');\ninsert into t2 values(1,'c',3.001,'2022-02-10','2022-02-10 12:00:00');\ninsert into t2 values(4,'d',4.001,'2022-02-11','2022-02-11 12:00:00');\n\nmysql> select * from t2 where a not in (2,4);\n+------+------+-------+------------+----------------------------+\n| a    | b    | c     | d          | e                          |\n+------+------+-------+------------+----------------------------+\n|    1 | a    | 1.001 | 2022-02-08 | 2022-02-08 12:00:00.000000 |\n|    1 | c    | 3.001 | 2022-02-10 | 2022-02-10 12:00:00.000000 |\n+------+------+-------+------------+----------------------------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t2 where b not in ('e',\"f\");\n+------+------+-------+------------+----------------------------+\n| a    | b    | c     | d          | e                          |\n+------+------+-------+------------+----------------------------+\n|    1 | a    | 1.001 | 2022-02-08 | 2022-02-08 12:00:00.000000 |\n|    2 | b    | 2.001 | 2022-02-09 | 2022-02-09 12:00:00.000000 |\n|    1 | c    | 3.001 | 2022-02-10 | 2022-02-10 12:00:00.000000 |\n|    4 | d    | 4.001 | 2022-02-11 | 2022-02-11 12:00:00.000000 |\n+------+------+-------+------------+----------------------------+\n4 rows in set (0.01 sec)\n\nmysql> select * from t2 where e not in ('2022-02-09 12:00:00') and a in (4,5);\na   b   c   d   e\n4   d   4.0010  2022-02-11  2022-02-11 12:00:00\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#constraints","title":"Constraints","text":"
    • Currently, only constant lists are supported on the left side of NOT IN.
    • There can only be a single column to the left of NOT IN, not a tuple of multiple columns.
    • NULL values couldn't appear in the list to the right of NOT IN.
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/","title":"NOT LIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/#description","title":"Description","text":"

    The NOT LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

    There are two wildcards often used in conjunction with the NOT LIKE operator:

    • The percent sign (%) represents zero, one, or multiple characters.
    • The underscore sign (_) represents one, single character.
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/#syntax","title":"Syntax","text":"
    > SELECT column1, column2, ...\nFROM table_name\nWHERE columnN NOT LIKE pattern;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/#examples","title":"Examples","text":"
    create table t1 (a char(10));\ninsert into t1 values('abcdef');\ninsert into t1 values('_bcdef');\ninsert into t1 values('a_cdef');\ninsert into t1 values('ab_def');\ninsert into t1 values('abc_ef');\ninsert into t1 values('abcd_f');\ninsert into t1 values('abcde_');\n\nmysql> select * from t1 where a not like 'a%';\n+--------+\n| a      |\n+--------+\n| _bcdef |\n+--------+\nmysql> select * from t1 where a not like \"%d_\\_\";\n+--------+\n| a      |\n+--------+\n| abc_ef |\n+--------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/","title":"CASE WHEN","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/#description","title":"Description","text":"

    CASE WHEN statement is used in that evaluates a list of conditions and returns one of multiple possible result expressions.

    Cases come in two formats: a simple CASE function compares an expression to a set of simple expressions to determine the result. The CASE search function evaluates a set of Boolean expressions to determine the result. Both formats support the optional ELSE argument.

    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/#syntax","title":"Syntax","text":"
    • Syntax 1:
    CASE value WHEN compare_value THEN result [WHEN compare_value THEN result ...] [ELSE result] END\n

    This CASE syntax returns the result for the first value=compare_value comparison that is true.

    • Syntax 2:
    CASE WHEN condition THEN result [WHEN condition THEN result ...] [ELSE result] END\n

    This CASE syntax returns the result for the first condition that is true. If no comparison or condition is true, the result after ELSE is returned, or NULL if there is no ELSE part.

    note

    The CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END.

    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/#examples","title":"Examples","text":"
    mysql> SELECT CASE WHEN 1>0 THEN 'true' ELSE 'false' END;\n+------------------------------------------+\n| case when 1 > 0 then true else false end |\n+------------------------------------------+\n| true                                     |\n+------------------------------------------+\n1 row in set (0.00 sec)\n
    CREATE TABLE t1 (a INT, b INT);\nQuery OK, 0 rows affected (0.01 sec)\n\nINSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3);\nQuery OK, 6 rows affected (0.01 sec)\n\nmysql> SELECT CASE WHEN AVG(a)>=0 THEN 'Positive' ELSE 'Negative' END FROM t1 GROUP BY b;\n+-------------------------------------------------------+\n| case when avg(a) >= 0 then Positive else Negative end |\n+-------------------------------------------------------+\n| Positive                                              |\n| Positive                                              |\n| Positive                                              |\n+-------------------------------------------------------+\n3 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/flow-control-functions-overview/","title":"Flow Control Functions","text":"Name Description CASE Case operator IF() If/else construct IFNULL() Null if/else construct NULLIF() Return NULL if expr1 = expr2"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/","title":"IF","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#description","title":"Description","text":"

    The IF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.

    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#syntax","title":"Syntax","text":"
    > IF(expr1,expr2,expr3)\n
    • If expr1 is TRUE (expr1 <> 0 and expr1 IS NOT NULL), IF() returns expr2. Otherwise, it returns expr3.

    • If only one of expr2 or expr3 is explicitly NULL, the result type of the IF() function is the type of the non-NULL expression.

    • The default return type of IF() (which may matter when it is stored into a temporary table) is calculated as follows:

      • If expr2 or expr3 produce a string, the result is a string.

      • If expr2 and expr3 are both strings, the result is case-sensitive if either string is case-sensitive.

      • If expr2 or expr3 produce a floating-point value, the result is a floating-point value.

      • If expr2 or expr3 produce an integer, the result is an integer.

    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#examples","title":"Examples","text":"
    mysql> SELECT IF(1>2,2,3);\n+-----------------+\n| if(1 > 2, 2, 3) |\n+-----------------+\n|               3 |\n+-----------------+\n1 row in set (0.01 sec)\nmysql> SELECT IF(1<2,'yes','no');\n+--------------------+\n| if(1 < 2, yes, no) |\n+--------------------+\n| yes                |\n+--------------------+\n1 row in set (0.00 sec)\n
    CREATE TABLE t1 (st varchar(255) NOT NULL, u int(11) NOT NULL);\nINSERT INTO t1 VALUES ('a',1),('A',1),('aa',1),('AA',1),('a',1),('aaa',0),('BBB',0);\n\nmysql> select if(u=1,st,st) s from t1 order by s;\n+------+\n| s    |\n+------+\n| A    |\n| AA   |\n| BBB  |\n| a    |\n| a    |\n| aa   |\n| aaa  |\n+------+\n7 rows in set (0.00 sec)\n\nmysql> select if(u=1,st,st) s from t1 where st like \"%a%\" order by s;\n+------+\n| s    |\n+------+\n| a    |\n| a    |\n| aa   |\n| aaa  |\n+------+\n4 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#constraints","title":"Constraints","text":"

    Parameters BIGINT and VARCHAR are not supported with the function 'if'.

    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/","title":"IFNULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/#description","title":"Description","text":"

    If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2. The default return type of IFNULL(expr1,expr2) is the more \"general\" of the two expressions, in the order STRING, REAL, or INTEGER.

    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/#syntax","title":"Syntax","text":"
    > IFNULL(expr1,expr2)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/#examples","title":"Examples","text":"
    mysql> SELECT IFNULL(NULL,10);\n+------------------+\n| ifnull(null, 10) |\n+------------------+\n|               10 |\n+------------------+\n1 row in set (0.00 sec)\n
    mysql> SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL);\n+-----------------------------------------+\n| cast(ifnull(null, null) as decimal(10)) |\n+-----------------------------------------+\n|                                    NULL |\n+-----------------------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/","title":"NULLIF","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#description","title":"Description","text":"

    The NULLIF() function returns NULL if expr1 = expr2 is true, otherwise returns expr1.

    The return value has the same type as the first argument.

    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#syntax","title":"Syntax","text":"
    > NULLIF(expr1,expr2)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#examples","title":"Examples","text":"
    CREATE TABLE employees ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, salary DECIMAL(10, 2) );\n\nINSERT INTO employees (name, salary) VALUES ('John Doe', 1000), ('Alice Smith', 2000), ('Bob Johnson', 1500);\n\n-- Use the NULLIF() function to set the salary of employees whose salary is a specific value to NULL. The NULLIF(salary, 1500) function will compare the value of the salary field with 1500. Returns NULL if the salary value equals 1500; otherwise, returns the salary value.\nmysql> SELECT name, salary, NULLIF(salary, 1500) AS adjusted_salary FROM employees;\n+-------------+---------+-----------------+\n| name        | salary  | adjusted_salary |\n+-------------+---------+-----------------+\n| John Doe    | 1000.00 | 1000.00         |\n| Alice Smith | 2000.00 | 2000.00         |\n| Bob Johnson | 1500.00 |                 |\n+-------------+---------+-----------------+\n3 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/","title":"AND,&&","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#description","title":"Description","text":"

    Logical AND,&&. Evaluates to true if all operands are nonzero and not NULL, to false if one or more operands are 0, otherwise NULL is returned.

    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#syntax","title":"Syntax","text":"
    > SELECT column_1 AND column_2 FROM table_name;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#examples","title":"Examples","text":"
    mysql> select 1 and 1;\n+---------+\n| 1 and 1 |\n+---------+\n| true    |\n+---------+\nmysql> select 1 and 0;\n+---------+\n| 1 and 0 |\n+---------+\n| false   |\n+---------+\nmysql> select 1 and null;\n+------------+\n| 1 and null |\n+------------+\n| NULL       |\n+------------+\nmysql> select null and 0;\n+------------+\n| null and 0 |\n+------------+\n| false      |\n+------------+\n1 row in set (0.01 sec)\n
    create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\nmysql> select a and b from t1;\n+---------+\n| a and b |\n+---------+\n| false   |\n| false   |\n| true    |\n| false   |\n| NULL    |\n+---------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/logical-operators-overview/","title":"Logical Operators","text":"Name Description AND,&& Logical AND NOT,! Negates value OR Logical OR XOR Logical XOR"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/","title":"NOT,!","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#description","title":"Description","text":"

    Logical NOT,!. Evaluates to true if the operand is 0, to false if the operand is nonzero, and NOT NULL returns NULL.

    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#syntax","title":"Syntax","text":"
    > SELECT not column_name FROM table_name;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#examples","title":"Examples","text":"
    mysql> select not 0;\n+-------+\n| not 0 |\n+-------+\n| true  |\n+-------+\n1 row in set (0.02 sec)\nmysql> select not null;\n+----------+\n| not null |\n+----------+\n| NULL     |\n+----------+\n1 row in set (0.00 sec)\nmysql> select not 1;\n+-------+\n| not 1 |\n+-------+\n| false |\n+-------+\n1 row in set (0.01 sec)\n
    create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select not a and not b from t1;\n+-----------------+\n| not a and not b |\n+-----------------+\n| false           |\n| false           |\n| false           |\n| true            |\n| NULL            |\n+-----------------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#constraints","title":"Constraints","text":"

    ! is not supported for now.

    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/","title":"OR","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#description","title":"Description","text":"

    Logical OR,||. When both operands are non-NULL, the result is true if any operand is nonzero, and false otherwise. With a NULL operand, the result is true if the other operand is nonzero, and NULL otherwise. If both operands are NULL, the result is NULL.

    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#syntax","title":"Syntax","text":"
    > SELECT column_1 OR column_2 FROM table_name;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#examples","title":"Examples","text":"
    mysql> select 1 or 1;\n+--------+\n| 1 or 1 |\n+--------+\n| true   |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select 1 or 0;\n+--------+\n| 1 or 0 |\n+--------+\n| true   |\n+--------+\n1 row in set (0.00 sec)\n\nmysql> select 0 or 0;\n+--------+\n| 0 or 0 |\n+--------+\n| false  |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select 0 or null;\n+-----------+\n| 0 or null |\n+-----------+\n| NULL      |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> select 1 or null;\n+-----------+\n| 1 or null |\n+-----------+\n| true      |\n+-----------+\n1 row in set (0.00 sec)\n
    create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select a or b from t1;\n+--------+\n| a or b |\n+--------+\n| true   |\n| true   |\n| true   |\n| false  |\n| NULL   |\n+--------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/","title":"XOR","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#description","title":"Description","text":"

    Logical XOR. Returns NULL if either operand is NULL. For non-NULL operands, evaluates to true if an odd number of operands is nonzero, otherwise false is returned.

    a XOR b is mathematically equal to (a AND (NOT b)) OR ((NOT a) and b).

    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#syntax","title":"Syntax","text":"
    > SELECT column_1 XOR column_2 FROM table_name;\n
    "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#examples","title":"Examples","text":"
    mysql> select 1 xor 1;\n+---------+\n| 1 xor 1 |\n+---------+\n| false   |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select 1 xor 0;\n+---------+\n| 1 xor 0 |\n+---------+\n| true    |\n+---------+\n1 row in set (0.00 sec)\n\nmysql> select 1 xor null;\n+------------+\n| 1 xor null |\n+------------+\n| NULL       |\n+------------+\n1 row in set (0.01 sec)\n\nmysql> select 1 xor 1 xor 1;\n+---------------+\n| 1 xor 1 xor 1 |\n+---------------+\n| true          |\n+---------------+\n1 row in set (0.00 sec)\n
    create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select a xor b from t1;\n+---------+\n| a xor b |\n+---------+\n| true    |\n| true    |\n| false   |\n| false   |\n| NULL    |\n+---------+\n5 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/","title":"ALTER ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#description","title":"Description","text":"

    Modify account information.

    Note

    1. The cluster administrator (i.e., the root user) can modify the password of the account it creates.
    2. Accounts themselves can modify their own passwords.
    3. Only the cluster administrator (i.e., the root user) can perform SUSPEND \u200b\u200band RECOVER (OPEN) account operations.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#syntax","title":"Syntax","text":"
    > ALTER ACCOUNT [IF EXISTS]\naccount auth_option [COMMENT 'comment_string']\n\nauth_option: {\nADMIN_NAME [=] 'admin_name'\nIDENTIFIED BY 'auth_string'\n}\n\nstatus_option: {\nOPEN\n| SUSPEND\n| RESTRICTED\n}\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#auth_option","title":"auth_option","text":"

    Modifies the account's default account name and authorization mode, auth_string specifies the password explicitly.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#status_option","title":"status_option","text":"

    Set the state of the account. They are stored as VARCHAR in the mo_account table under the system database mo_catalog.

    • SUSPEND: Suspend the account's service; the account can no longer access MatrixOne after the suspension.

      • When the SUSPEND state is enabled for the account, access behavior will be suspended even if the account is accessing it.
      • To unsuspend the user's service, switch the status to OPEN to unsuspend the service; that is, run ALTER ACCOUNT account_name OPEN to unsuspend the service.
    • OPEN: Resume a suspended account, after which the account will usually access MatrixOne.

    • RESTRICTED: Allows the user to access and perform limited actions. After the RESTRICTED state is enabled for this tenant, this tenant can only perform SHOW/DELETE/SELECT/USE operations on the database, and other operations cannot be used.
      • When the RESTRICTED state is enabled for the tenant, access behavior will be restricted even if the account is accessing it.
      • To lift the restrictions on the user, switch the status to OPEN to remove the restrictions.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#comment","title":"comment","text":"

    Account notes are stored as VARCHAR in the table mo_account in the system database mo_catalog.

    COMMENT can be arbitrary quoted text, and the new COMMENT replaces any existing user comments. As follows:

    mysql> desc mo_catalog.mo_account;\n+----------------+--------------+------+------+---------+-------+---------+\n| Field          | Type         | Null | Key  | Default | Extra | Comment |\n+----------------+--------------+------+------+---------+-------+---------+\n| account_id     | INT          | YES  |      | NULL    |       |         |\n| account_name   | VARCHAR(300) | YES  |      | NULL    |       |         |\n| status         | VARCHAR(300) | YES  |      | NULL    |       |         |\n| created_time   | TIMESTAMP    | YES  |      | NULL    |       |         |\n| comments       | VARCHAR(256) | YES  |      | NULL    |       |         |\n| suspended_time | TIMESTAMP    | YES  |      | null    |       |         |\n+----------------+--------------+------+------+---------+-------+---------+\n6 rows in set (0.06 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#examples","title":"Examples","text":"
    • Example 1: Modify the information on the account
    -- Create a account named \"root1\" with password \"111\"\nmysql> create account acc1 admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.42 sec)\n-- Change the initial password \"111\" to \"Abcd_1234@1234\"\nmysql> alter account acc1 admin_name \"root1\" identified by \"Abcd_1234@1234\";\nQuery OK, 0 rows affected (0.01 sec)\n-- Modify the comment for account \"root1\"\nmysql> alter account acc1 comment \"new account\";\nQuery OK, 0 rows affected (0.02 sec)\n-- Check to verify that the \"new account\" comment has been added to the account \"root1\"\nmysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status | suspended_time | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| acc1         | root1      | 2023-02-15 06:26:51 | open   | NULL           |        5 |          34 |       787 | 0.036 | new account    |\n| sys          | root       | 2023-02-14 06:58:15 | open   | NULL           |        8 |          57 |      3767 | 0.599 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n3 rows in set (0.19 sec)\n
    • Example 2: Modify the status of the account
    -- Create a account named \"root1\" with password \"111\"\nmysql> create account accx admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.27 sec)\n-- Modify the account status to \"suspend\", that is, suspend user access to MatrixOne.\nmysql> alter account accx suspend;\nQuery OK, 0 rows affected (0.01 sec)\n-- Check if the modification status is successful.\nmysql> show accounts;\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status  | suspended_time      | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| accx         | root1      | 2023-02-15 06:26:51 | suspend | 2023-02-15 06:27:15 |        5 |          34 |       787 | 0.036 | new accout     |\n| sys          | root       | 2023-02-14 06:58:15 | open    | NULL                |        8 |          57 |      3767 | 0.599 | system account |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n2 rows in set (0.15 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/","title":"ALTER ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#description","title":"Description","text":"

    Modify account information.

    Note

    1. The cluster administrator (i.e., the root user) can modify the password of the account it creates.
    2. Accounts themselves can modify their own passwords.
    3. Only the cluster administrator (i.e., the root user) can perform SUSPEND \u200b\u200band RECOVER (OPEN) account operations.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#syntax","title":"Syntax","text":"
    > ALTER ACCOUNT [IF EXISTS]\naccount auth_option [COMMENT 'comment_string']\n\nauth_option: {\nADMIN_NAME [=] 'admin_name'\nIDENTIFIED BY 'auth_string'\n}\n\nstatus_option: {\nOPEN\n| SUSPEND\n}\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#auth_option","title":"auth_option","text":"

    Modifies the default account name and authorization mode of the account, auth_string specifies the password explicitly.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#status_option","title":"status_option","text":"

    Set the state of the account. They are stored as VARCHAR in the mo_account table under the system database mo_catalog.

    • SUSPEND: Suspend the account's service; that is, the account can no longer access MatrixOne after the suspension; users who are accessing the account can continue to access, and after closing the session, they will no longer be able to access MatrixOne.
    • OPEN: Resume a suspended account, after which the account will usually access MatrixOne.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#comment","title":"comment","text":"

    Account notes are stored as VARCHAR in the table mo_account in the system database mo_catalog.

    COMMENT can be arbitrary quoted text, and the new COMMENT replaces any existing user comments. As follows:

    mysql> desc mo_catalog.mo_account;\n+----------------+--------------+------+------+---------+-------+---------+\n| Field          | Type         | Null | Key  | Default | Extra | Comment |\n+----------------+--------------+------+------+---------+-------+---------+\n| account_id     | INT          | YES  |      | NULL    |       |         |\n| account_name   | VARCHAR(300) | YES  |      | NULL    |       |         |\n| status         | VARCHAR(300) | YES  |      | NULL    |       |         |\n| created_time   | TIMESTAMP    | YES  |      | NULL    |       |         |\n| comments       | VARCHAR(256) | YES  |      | NULL    |       |         |\n| suspended_time | TIMESTAMP    | YES  |      | null    |       |         |\n+----------------+--------------+------+------+---------+-------+---------+\n6 rows in set (0.06 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#examples","title":"Examples","text":"
    • Example 1: Modify the information on the account
    -- Create a account named \"root1\" with password \"111\"\nmysql> create account acc1 admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.42 sec)\n-- Change the initial password \"111\" to \"Abcd_1234@1234\"\nmysql> alter account acc1 admin_name \"root1\" identified by \"Abcd_1234@1234\";\nQuery OK, 0 rows affected (0.01 sec)\n-- Modify the comment for account \"root1\"\nmysql> alter account acc1 comment \"new account\";\nQuery OK, 0 rows affected (0.02 sec)\n-- Check to verify that the \"new account\" comment has been added to the account \"root1\"\nmysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status | suspended_time | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| acc1         | root1      | 2023-02-15 06:26:51 | open   | NULL           |        5 |          34 |       787 | 0.036 | new account    |\n| sys          | root       | 2023-02-14 06:58:15 | open   | NULL           |        8 |          57 |      3767 | 0.599 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n3 rows in set (0.19 sec)\n
    • Example 2: Modify the status of the account
    -- Create a account named \"root1\" with password \"111\"\nmysql> create account accx admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.27 sec)\n-- Modify the account status to \"suspend\", that is, suspend user access to MatrixOne.\nmysql> alter account accx suspend;\nQuery OK, 0 rows affected (0.01 sec)\n-- Check if the modification status is successful.\nmysql> show accounts;\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status  | suspended_time      | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| accx         | root1      | 2023-02-15 06:26:51 | suspend | 2023-02-15 06:27:15 |        5 |          34 |       787 | 0.036 | new accout     |\n| sys          | root       | 2023-02-14 06:58:15 | open    | NULL                |        8 |          57 |      3767 | 0.599 | system account |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n2 rows in set (0.15 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/","title":"ALTER USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#description","title":"Description","text":"

    Modify the attributes and passwords of database users.

    Note

    1. Accounts can modify the passwords of the users they create and only modify the passwords of one user at a time. The modified passwords will take effect on the next login, and the current session will not be interrupted.
    2. Users can modify their own passwords, and the modified passwords will take effect on the next login, and the current session will not be interrupted.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#syntax","title":"Syntax","text":"
    ALTER USER [IF EXISTS]\n    user auth_option\n\nauth_option: {\n    IDENTIFIED BY 'auth_string'}\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#auth_option","title":"auth_option","text":"

    Specifies the default user name and authorization mode of the account, auth_string specifies the password explicitly.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#examples","title":"Examples","text":"
    -- Create a user named \"admin_1\" with password \"123456\"\nmysql> create user admin_1 identified by '123456';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Modify the user's initial password \"123456\" to \"111111\"\nmysql> alter user 'admin_1' identified by '111111';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Check if the password was changed successfully\nmysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time        | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n|       0 | localhost | root      | 111                   | unlock | 2023-04-19 06:37:58 | NULL         | PASSWORD   |       0 |     0 |            0 |\n|       1 | localhost | root      | 111                   | unlock | 2023-04-19 06:37:58 | NULL         | PASSWORD   |       0 |     0 |            0 |\n|       2 | localhost | admin_1   | 111111                | unlock | 2023-04-21 06:21:31 | NULL         | PASSWORD   |       1 |     0 |            1 |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n3 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/","title":"CREATE ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#description","title":"Description","text":"

    Create a new account in your organization.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#syntax","title":"Syntax","text":"
    > CREATE ACCOUNT  [IF NOT EXISTS]\naccount auth_option\n[COMMENT 'comment_string']\n\nauth_option: {\n    ADMIN_NAME [=] 'admin_name'\n    IDENTIFIED BY 'auth_string'\n}\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#auth_option","title":"auth_option","text":"

    Specifies the default account name and authorization mode of the account, auth_string specifies the password explicitly.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#examples","title":"Examples","text":"
    > create account tenant_test admin_name = 'root' identified by '111' comment 'tenant_test';\nQuery OK, 0 rows affected (0.08 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/","title":"CREATE ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#description","title":"Description","text":"

    Create a new role in the system.

    After creating roles, you can grant object privileges to the role and then grant the role to other roles or individual users to enable access control security for objects in the system.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#syntax","title":"Syntax","text":"
    > CREATE ROLE [IF NOT EXISTS] role [, role ] ...\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#examples","title":"Examples","text":"
    > create role rolex;\nQuery OK, 0 rows affected (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/","title":"CREATE USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#description","title":"Description","text":"

    Creates a new user in the system.

    To use CREATE USER, you must have the CREATE USER privilege.

    • The default role with CREATE USER privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#syntax","title":"Syntax","text":"
    > CREATE USER [IF NOT EXISTS]\n    user auth_option [, user auth_option] ...\n    [DEFAULT ROLE rolename]  \n    [COMMENT 'comment_string' | ATTRIBUTE 'json_object']\n\nauth_option: {\n    IDENTIFIED BY 'auth_string'\n}\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#explanations","title":"Explanations","text":"

    An user when first created has no privileges and a default role of NONE. To assign privileges or roles, use the GRANT statement.

    The basic SQL statement of CREAT USER is as follows:

    create user user_name identified by 'password';\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#identified-by-auth_string","title":"IDENTIFIED BY 'auth_string'","text":"

    CREATE USER permits these auth_option syntaxes:

    • 'auth_string': 'auth_string' value (the default is password) will be stored in the mo_user system table.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#default-role","title":"DEFAULT ROLE","text":"

    The DEFAULT ROLE clause defines which roles become active when the user connects to MatrixOne and authenticates, or when the user executes the SET ROLE statement during a session.

    create user user_name identified by 'password' default role role_rolename;\n

    The DEFAULT ROLE clause permits a list of one or more comma-separated role names. These roles must exist at the time CREATE USER is executed; otherwise the statement raises an error, and the user is not created.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#examples","title":"Examples","text":"
    > create user userx identified by '111';\nQuery OK, 0 rows affected (0.04 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#constraints","title":"Constraints","text":"

    MatrxiOne does not supports CREATE USER COMMENT and CREATE USER ATTRIBUTE now.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/","title":"DROP ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#description","title":"Description","text":"

    Delete the account in your organization.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#syntax","title":"Syntax","text":"
    > DROP ACCOUNT  [IF EXISTS] account\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#examples","title":"Examples","text":"
    > drop account if exists tenant_test;\nQuery OK, 0 rows affected (0.12 sec)\n

    Note

    If the account is in the session, when the account is removed, the session will be disconnected and MatrixOne can no longer be connected.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/","title":"DROP ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#description","title":"Description","text":"

    Removes the specified role from the system.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#syntax","title":"Syntax","text":"
    > DROP ROLE [IF EXISTS] role [, role ] ...\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#examples","title":"Examples","text":"
    > drop role if exists rolex;\nQuery OK, 0 rows affected (0.02 sec)\n

    Note

    If the user using this role is in a session, when the role is removed, the session will be disconnected immediately, and this role can no longer be used for operations.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/","title":"DROP USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#description","title":"Description","text":"

    Removes the specified user from the system.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#syntax","title":"Syntax","text":"
    > DROP USER [IF EXISTS] user [, user] ...\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#examples","title":"Examples","text":"
    > drop user if exists userx;\nQuery OK, 0 rows affected (0.02 sec)\n

    Note

    If the user is in a session, when the user is removed, the session is disconnected and MatrixOne can no longer be connected.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/","title":"GRANT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#description","title":"Description","text":"

    The GRANT statement assigns privileges and roles to MatrixOne users and roles.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#grant-overview","title":"GRANT Overview","text":"

    System permissions are those of the initial System account administrator ( The corresponding user is the root). The System account administrator can create and delete other accounts, and manage accounts. A System account administrator cannot manage other resources of other accounts.

    To use GRANT to GRANT permissions to other users or roles, you must first have the WITH GRANT OPTION permissions and the permissions you are granting. Use the' SHOW GRANTS' statement to find out the grant status of your current or another role. For more information, see SHOW GRANTS.

    The REVOKE statement is related to GRANT and enables administrators to remove account privileges. For more information on REVOKE, see REVOKE.

    Normally, a cluster has one root by default, the root first uses CREATE ACCOUNT to create a new account and define its nonprivilege characteristics such as its password, then account uses CREATE USER to create an user and uses GRANT to define its privileges. ALTER ACCOUNT may be used to change the nonprivilege characteristics of existing accounts. ALTER USER is used to change the privilege characteristics of existing users. For more information on privileges supported by MatrixOne, see Privilege Control Types.

    GRANT responds with Query OK, 0 rows affected when executed successfully. To determine what privileges result from the operation, use SHOW GRANTS

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#syntax","title":"Syntax","text":"
    > GRANT\n    priv_type [(column_list)]\n      [, priv_type [(column_list)]] ...\n    ON [object_type] priv_level\n    TO user_or_role [, user_or_role] ...\n\nGRANT role [, role] ...\n    TO user_or_role [, user_or_role] ...\n    [WITH ADMIN OPTION]\n\nobject_type: {\n    TABLE\n  | FUNCTION\n  | PROCEDURE\n}\n\npriv_level: {\n    *\n  | *.*\n  | db_name.*\n  | db_name.tbl_name\n  | tbl_name\n  | db_name.routine_name\n}\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#explanations","title":"Explanations","text":"

    The GRANT statement enables account to grant privileges and roles, which can be granted to users and roles. These syntax restrictions apply:

    • GRANT cannot mix granting both privileges and roles in the same statement. A given GRANT statement must grant either privileges or roles.

    • The ON clause distinguishes whether the statement grants privileges or roles:

      • With ON, the statement grants privileges.

      • Without ON, the statement grants roles.

      • It is permitted to assign both privileges and roles to an account, but you must use separate GRANT statements, each with syntax appropriate to what is to be granted.

    To grant a privilege with GRANT, you must have the GRANT OPTION privilege, and you must have the privileges that you are granting.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#database-privileges","title":"Database Privileges","text":"

    Database privileges apply to all objects in a given database. To assign database-level privileges, use ON db_name * syntax:

    grant all on database * to role1;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#table-privileges","title":"Table Privileges","text":"

    Table privileges apply to all columns in a given table. To assign table-level privileges, use ON db_name.tbl_name syntax:

    grant all on table *.* to role1;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#granting-roles","title":"Granting Roles","text":"

    GRANT syntax without an ON clause grants roles rather than individual privileges. A role is a named collection of privileges. For example:

    grant role3 to role_user;\n

    Each role to be granted must exist, as well as each user account or role to which it is to be granted.

    These privileges are required to grant roles:

    • You have the privilege to grant or revoke any role to users or roles.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#examples","title":"Examples","text":"
    > drop user if exists user_prepare_01;\n> drop role if exists role_prepare_1;\n> create user user_prepare_01 identified by '123456';\n> create role role_prepare_1;\n> create database if not exists p_db;\n> grant create table ,drop table on database *.*  to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant connect on account * to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant insert,select on table *.* to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant role_prepare_1 to user_prepare_01;\nQuery OK, 0 rows affected (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/","title":"REVOKE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#description","title":"Description","text":"

    Removes one or more privileges on a securable object from a role. The privileges that can be revoked are object-specific.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#syntax","title":"Syntax","text":"
    > REVOKE [IF EXISTS]\n    priv_type [(column_list)]\n      [, priv_type [(column_list)]] ...\n    ON object_type priv_level\n\n> REVOKE [IF EXISTS] role [, role ] ...\n    FROM user_or_role [, user_or_role ] ...\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#examples","title":"Examples","text":"
    > CREATE USER mouser IDENTIFIED BY '111';\nQuery OK, 0 rows affected (0.10 sec)\n\n> CREATE ROLE role_r1;\nQuery OK, 0 rows affected (0.05 sec)\n\n> GRANT role_r1 to mouser;\nQuery OK, 0 rows affected (0.04 sec)\n\n> GRANT create table on database * to role_r1;\nQuery OK, 0 rows affected (0.03 sec)\n\n> SHOW GRANTS for mouser@localhost;\n+-------------------------------------------------------+\n| Grants for mouser@localhost                           |\n+-------------------------------------------------------+\n| GRANT create table ON database * `mouser`@`localhost` |\n| GRANT connect ON account  `mouser`@`localhost`        |\n+-------------------------------------------------------+\n2 rows in set (0.02 sec)\n\n> REVOKE role_r1 from mouser;\nQuery OK, 0 rows affected (0.04 sec)\n\n> SHOW GRANT for mouser@localhost;\n+------------------------------------------------+\n| Grants for mouser@localhost                    |\n+------------------------------------------------+\n| GRANT connect ON account  `mouser`@`localhost` |\n+------------------------------------------------+\n1 row in set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/","title":"ALTER PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#description","title":"Description","text":"

    ALTER PUBLICATION can change the attributes of a publication.

    You must own the publication to use ALTER PUBLICATION. Adding a table to a publication additionally requires owning that table.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#syntax","title":"Syntax","text":"
    ALTER PUBLICATION pubname ACCOUNT \u0005\n    { ALL\n    | account_name, [, ... ]\n    | ADD account_name, [, ... ]\n    | DROP account_name, [, ... ]\u0005\n    [ COMMENT 'string']\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#explanations","title":"Explanations","text":"
    • pubname: The name of an existing publication whose definition is to be altered.
    • account_name: The user name of the owner of the publication.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#examples","title":"Examples","text":"
    create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\nmysql> alter publication pub3 account add accx;\nshow create publication pub3;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show create publication pub3;\n+-------------+-----------------------------------------------------------------------+\n| Publication | Create Publication                                                    |\n+-------------+-----------------------------------------------------------------------+\n| pub3        | CREATE PUBLICATION `pub3` DATABASE `t` ACCOUNT `acc0`, `acc1`, `accx` |\n+-------------+-----------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show publications;\n+------+----------+\n| Name | Database |\n+------+----------+\n| pub3 | t        |\n+------+----------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/","title":"ALTER STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#description","title":"Description","text":"

    ALTER STAGE is used to modify the attributes of an existing named internal or external stage.

    Note

    Cluster administrators (i.e., root users) and account administrators can modify the data stage.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#syntax","title":"Syntax","text":"
    > ALTER STAGE [ IF EXISTS ] { stage_name }\n   { StageParams }\n   [ directoryTableParams ]\n   [ COMMENT = '<string_literal>' ]\n\nStageParams (for Amazon S3) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for Aliyun OSS) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for File System) :\nURL= 'filepath'\n\ndirectoryTableParams :\nENABLE = { TRUE | FALSE }\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#explanations","title":"Explanations","text":"
    • IF NOT EXISTS: An optional parameter used to check whether a stage with the same name already exists when modifying a stage, avoiding duplicate creations.

    • stage_name: The name of the stage to be modified.

    • StageParams: This parameter group is used to specify the stage's configuration parameters.

      • endpoint: The connection URL for the stage, indicating the location of the object storage service. This URL's content may vary for object storage services like Amazon S3, Aliyun OSS, or a file system. For example s3.us-west-2.amazonaws.com

      • CREDENTIALS: This JSON object contains the credentials required to connect to the object storage service, such as access_key_id, secret_access_key, etc.

    • directoryTableParams: This parameter group is used to specify the configuration of a directory table associated with the stage.

      • ENABLE: Indicates whether the directory table is enabled, with values TRUE or FALSE values.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#examples","title":"Examples","text":"
    CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- Create internal data stage\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- Export data from the table to data stage\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- You can see your exported table in your local directory\n\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+---------+\n| STAGE_NAME | URL                         | STATUS  | COMMENT |\n+------------+-----------------------------+---------+---------+\n| stage1     | /Users/Prinz/03testrepo/csv | ENABLED |         |\n+------------+-----------------------------+---------+---------+\n1 row in set (0.01 sec)\n\n-- modify the stage1\nmysql> ALTER STAGE stage1 SET COMMENT 'user stage';\n\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+------------+\n| STAGE_NAME | URL                         | STATUS  | COMMENT    |\n+------------+-----------------------------+---------+------------+\n| stage1     | /Users/Prinz/03testrepo/csv | ENABLED | user stage |\n+------------+-----------------------------+---------+------------+\n1 row in set (0.00 sec)\n\n-- disable the data stage named 'stage1'\nmysql> ALTER STAGE stage1 SET ENABLE = FALSE;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- Try to export the data of the user table to the data stage named 'stage1:/user.csv', but stage1 has been disabled, so it is no longer available, and an error is reported\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\nERROR 20101 (HY000): internal error: stage 'stage1' is invalid, please check\n\n-- Re-enable with a data stage named 'stage1'\nmysql> ALTER STAGE stage1 SET ENABLE = TRUE;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- The export can be executed successfully again\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/","title":"ALTER TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#description","title":"Description","text":"

    ALTER TABLE is used to modify the existing data table structure.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#syntax","title":"Syntax","text":"
    ALTER TABLE tbl_name\n    [alter_option [, alter_option] ...]\n\nalter_option: {\n    table_options\n  | ADD [COLUMN] col_name column_definition\n        [FIRST | AFTER col_name]\n  | ADD [COLUMN] (col_name column_definition,...)\n  | ADD {[INDEX | KEY] [index_name]\n        [index_option] ...\n  | ADD [CONSTRAINT] UNIQUE [INDEX | KEY]\n        [index_name][index_option] ...\n  | ADD [CONSTRAINT] FOREIGN KEY\n        [index_name] (col_name,...)\n        reference_definition\n  | ADD [CONSTRAINT [symbol]] PRIMARY KEY\n        [index_type] (key_part,...)\n  | CHANGE [COLUMN] old_col_name new_col_name column_definition\n        [FIRST | AFTER col_name]\n  | ALTER INDEX index_name {VISIBLE | INVISIBLE}\n  | DROP [COLUMN] col_name\n  | DROP {INDEX | KEY} index_name\n  | DROP FOREIGN KEY fk_symbol\n  | DROP PRIMARY KEY\n  | RENAME [TO | AS] new_tbl_name\n  | MODIFY [COLUMN] col_name column_definition\n        [FIRST | AFTER col_name]\n  | RENAME COLUMN old_col_name TO new_col_name\n    }\n\nkey_part: {col_name [(length)] | (expr)} [ASC | DESC]\nindex_option: {\n  COMMENT[=]'string'\n}\ntable_options:\n    table_option [[,] table_option] ...\ntable_option: {\n  COMMENT [=] 'string'\n}\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#explanations","title":"Explanations","text":"

    The explanations of each parameter are as the following:

    1. ALTER TABLE tbl_name: Indicates modifying a table named tbl_name.
    2. alter_option: Indicates that one or more change options can be executed, separated by commas.

      • table_options: Used to set or modify table options, such as table comments (COMMENT).
      • ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name]: Adds a new column to the table, specifying the position of the new column (before or after a particular column).
      • ADD [COLUMN] (col_name column_definition, ...): Adds multiple new columns simultaneously.
      • ADD {[INDEX | KEY] [index_name] [index_option] ...: Adds an index, specifying the index name and index options (such as comments).
      • ADD [CONSTRAINT] UNIQUE [INDEX | KEY] [index_name][index_option] ...: Adds a UNIQUE constraint or UNIQUE index.
      • ADD [CONSTRAINT] FOREIGN KEY [index_name] (col_name, ...) reference_definition: Adds a FOREIGN KEY constraint.
      • ADD [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (key_part,...): Add a primary key constraint.
      • CHANGE [COLUMN] old_col_name new_col_name column_definition [FIRST | AFTER col_name]: Modify the column definition, column name and order.
      • ALTER INDEX index_name {VISIBLE | INVISIBLE}: Changes the visibility of an index.
      • DROP [COLUMN] col_name: Drops a column.
      • DROP {INDEX | KEY} index_name: Drops an index.
      • DROP FOREIGN KEY fk_symbol: Drops a FOREIGN KEY constraint.
      • DROP PRIMARY KEY: Delete the primary key.
      • RENAME [TO | AS] new_tbl_name: Renames the table.
      • MODIFY [COLUMN] col_name column_definition [FIRST | AFTER col_name]: Modify column definition and order.
      • RENAME COLUMN old_col_name TO new_col_name: Rename a column.
    3. key_part: Represents the components of an index, which can be column names (when creating an index on a text column, you might specify a length for the index to only consider a certain number of characters in that column. If you create an index using a column name without specifying a length, the index will use the entire column value as an index component. In some cases, this may result in reduced performance, especially when dealing with large text or binary data columns. Specifying a length is usually unnecessary for smaller data types, such as integers or dates.).

    4. index_option: Represents index options, such as comments (COMMENT).
    5. table_options: Represents table options, such as table comments (COMMENT).
    6. table_option: Specific table options, such as comments (COMMENT).
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#examples","title":"Examples","text":"
    • Example 1:
    -- Create table f1 with two integer columns: fa (primary key) and fb (unique key)\nCREATE TABLE f1(fa INT PRIMARY KEY, fb INT UNIQUE KEY);\n-- Create table c1 with two integer columns: ca and cb\nCREATE TABLE c1 (ca INT, cb INT);\n-- Add a foreign key constraint named ffa to table c1, associating column ca of table c1 with column fa of table f1\nALTER TABLE c1 ADD CONSTRAINT ffa FOREIGN KEY (ca) REFERENCES f1(fa);\n-- Insert a record into table f1: (2, 2)\nINSERT INTO f1 VALUES (2, 2);\n-- Insert a record into table c1: (1, 1)\nINSERT INTO c1 VALUES (1, 1);\n-- Insert a record into table c1: (2, 2)\nINSERT INTO c1 VALUES (2, 2);\n-- Select all records from table c1 and order by column ca\nmysql> select ca, cb from c1 order by ca;\n+------+------+\n| ca   | cb   |\n+------+------+\n|    2 |    2 |\n+------+------+\n1 row in set (0.01 sec)\n-- Drop the foreign key constraint named ffa from table c1\nALTER TABLE c1 DROP FOREIGN KEY ffa;\n-- Insert a record into table c1: (1, 1)\nINSERT INTO c1 VALUES (1, 1);\n-- Select all records from table c1 and order by column ca\nmysql> select ca, cb from c1 order by ca;\n+------+------+\n| ca   | cb   |\n+------+------+\n|    1 |    1 |\n|    2 |    2 |\n+------+------+\n2 rows in set (0.01 sec)\n
    • Example 2:
    -- Create a new table 't1' with columns a, b, c, and d. Column 'a' is of type INTEGER, 'b' is of type CHAR(10), 'c' is of type DATE, and 'd' is of type DECIMAL(7,2). A unique key is added on columns 'a' and 'b'.\nCREATE TABLE t1(a INTEGER, b CHAR(10), c DATE, d DECIMAL(7,2), UNIQUE KEY(a, b));\n\n-- Describe the structure of the 't1' table.\nmysql> desc t1;\n+-------+--------------+------+------+---------+-------+---------+\n| Field | Type         | Null | Key  | Default | Extra | Comment |\n+-------+--------------+------+------+---------+-------+---------+\n| a     | INT(32)      | YES  |      | NULL    |       |         |\n| b     | CHAR(10)     | YES  |      | NULL    |       |         |\n| c     | DATE(0)      | YES  |      | NULL    |       |         |\n| d     | DECIMAL64(7) | YES  |      | NULL    |       |         |\n+-------+--------------+------+------+---------+-------+---------+\n4 rows in set (0.01 sec)\n\n-- Insert three rows into the 't1' table.\nINSERT INTO t1 VALUES(1, 'ab', '1980-12-17', 800);\nINSERT INTO t1 VALUES(2, 'ac', '1981-02-20', 1600);\nINSERT INTO t1 VALUES(3, 'ad', '1981-02-22', 500);\n\n-- Display all the rows from the 't1' table.\nmysql> select * from t1;\n+------+------+------------+---------+\n| a    | b    | c          | d       |\n+------+------+------------+---------+\n|    1 | ab   | 1980-12-17 |  800.00 |\n|    2 | ac   | 1981-02-20 | 1600.00 |\n|    3 | ad   | 1981-02-22 |  500.00 |\n+------+------+------------+---------+\n3 rows in set (0.01 sec)\n\n-- Alter the 't1' table to add a primary key 'pk1' on columns 'a' and 'b'.\nmysql> alter table t1 add primary key pk1(a, b);\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Describe the modified structure of the 't1' table after adding the primary key.\nmysql> desc t1;\n+-------+--------------+------+------+---------+-------+---------+\n| Field | Type         | Null | Key  | Default | Extra | Comment |\n+-------+--------------+------+------+---------+-------+---------+\n| a     | INT(32)      | NO   | PRI  | null    |       |         |\n| b     | CHAR(10)     | NO   | PRI  | null    |       |         |\n| c     | DATE(0)      | YES  |      | null    |       |         |\n| d     | DECIMAL64(7) | YES  |      | null    |       |         |\n+-------+--------------+------+------+---------+-------+---------+\n4 rows in set (0.01 sec)\n\n-- Display all the rows from the 't1' table after adding the primary key.\nmysql> select * from t1;\n+------+------+------------+---------+\n| a    | b    | c          | d       |\n+------+------+------------+---------+\n|    1 | ab   | 1980-12-17 |  800.00 |\n|    2 | ac   | 1981-02-20 | 1600.00 |\n|    3 | ad   | 1981-02-22 |  500.00 |\n+------+------+------------+---------+\n3 rows in set (0.00 sec)\n
    • Example 3:
    CREATE TABLE t1 (a INTEGER PRIMARY KEY, b CHAR(10));\nmysql> desc t1;\n+-------+----------+------+------+---------+-------+---------+\n| Field | Type     | Null | Key  | Default | Extra | Comment |\n+-------+----------+------+------+---------+-------+---------+\n| a     | INT(32)  | NO   | PRI  | NULL    |       |         |\n| b     | CHAR(10) | YES  |      | NULL    |       |         |\n+-------+----------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\ninsert into t1 values(1, 'ab');\ninsert into t1 values(2, 'ac');\ninsert into t1 values(3, 'ad');\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 | ab   |\n|    2 | ac   |\n|    3 | ad   |\n+------+------+\n3 rows in set (0.01 sec)\n\n-- Modify table 't1', change column 'a' name to 'x', and change datatype to VARCHAR(20).\nmysql> alter table t1 change a x VARCHAR(20);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> desc t1;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type        | Null | Key  | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| x     | VARCHAR(20) | NO   | PRI  | null    |       |         |\n| b     | CHAR(10)    | YES  |      | null    |       |         |\n+-------+-------------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t1;\n+------+------+\n| x    | b    |\n+------+------+\n| 1    | ab   |\n| 2    | ac   |\n| 3    | ad   |\n+------+------+\n3 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#constraints","title":"Constraints","text":"
    1. The clauses: CHANGE [COLUMN], MODIFY [COLUMN], RENAME COLUMN, ADD [CONSTRAINT [symbol]] PRIMARY KEY, DROP PRIMARY KEY, and ALTER COLUMN ORDER BY can be freely combined in ALTER TABLE, these are not supported to be used with other clauses for the time being.
    2. Temporary tables currently do not support using ALTER TABLE to modify the table structure.
    3. Tables created using CREATE TABLE ... CLUSTER BY... do not allow modifications to the table structure using ALTER TABLE.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/","title":"ALTER VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#description","title":"Description","text":"

    ALTER VIEW is used to alter an existing view.

    If any of the views named in the syntax parameter list do not exist, the statement reports an error and cannot change those views that do not exist.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#syntax","title":"Syntax","text":"
    > ALTER VIEW view_name [(column_list)]\n  AS select_statement\n  [WITH [CASCADED | LOCAL] CHECK OPTION]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values(1),(2),(3),(4);\ncreate view v5 as select * from t1;\n\nmysql> select * from v5;\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n4 rows in set (0.01 sec)\n\nalter view v5 as select * from t1 where a=1;\n\nmysql> select * from v5;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.01 sec)\n\nalter view v5 as select * from t1 where a > 2;\n\nmysql> select * from v5;\n+------+\n| a    |\n+------+\n|    3 |\n|    4 |\n+------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/","title":"CREATE DATABASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#description","title":"Description","text":"

    Create a database.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#syntax","title":"Syntax","text":"
    > CREATE DATABASE [IF NOT EXISTS] <database_name> [create_option] ...\n\n> create_option: [DEFAULT] {\n    CHARACTER SET [=] charset_name\n  | COLLATE [=] collation_name\n  | ENCRYPTION [=] {'Y' | 'N'}\n}\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#examples","title":"Examples","text":"
    CREATE DATABASE IF NOT EXISTS test01;\n

    Expected Result

    You can use SHOW DATABASES to check if the databases have been created.

    mysql> show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| mo_task            |\n| information_schema |\n| mysql              |\n| system_metrics     |\n| system             |\n| test01             |\n| mo_catalog         |\n+--------------------+\n10 rows in set (0.01 sec)\n

    You can see that the new database test01 has been created in addition to the six system databases.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#constraints","title":"Constraints","text":"
    • Only UTF-8 CHARACTER SET is supported for now.
    • CHARACTER SET, COLLATE, ENCRYPTION can be used but don't work.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/","title":"CREATE EXTERNAL TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#description","title":"Description","text":"

    External table access data in external sources as if it were in a table in the database.

    You can connect to the database and create metadata for the external table using DDL.

    The DDL for an external table consists of two parts: one part that describes the MatrixOne column types, and another part (the access parameters) that describes the mapping of the external data to the MatrixOne data columns.

    This document describe how to create a new tables outside of the MatrixOne databases.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#common-syntax","title":"Common syntax","text":"
    > CREATE EXTERNAL TABLE [IF NOT EXISTS] [db.]table_name;\n(\n    name1 type1,\n    name2 type2,\n    ...\n)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#syntax_1","title":"Syntax","text":"
    ## Create a external table for a local file (specify the compression format)\ncreate external table t(...) localfile{\"filepath\"='<string>', \"compression\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n## Create a external table for a local file (if no compression format is specified, the format is auto, and the file format is automatically checked)\ncreate external table t(...) localfile{\"filepath\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n\n## Create a external table for an S3 file (specify the compression format)\ncreate external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n## Create a external table for an S3 file (if no compression format is specified, the format is auto, and the file format is automatically checked)\ncreate external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#parameter-description","title":"Parameter Description","text":"Parameter Description endpoint A endpoint is a URL that can conncect to AWS Web service. For example: s3.us-west-2.amazonaws.com access_key_id S3 Access key ID secret_access_key S3 Secret access key bucket S3 Bucket to access filepath relative file path region AWS S3 Area compression Compressed format of S3 files. If empty, it indicates uncompressed files. Supported fields or Compressed format are \"auto\", \"none\", \"gzip\", \"bzip2\", \"flate\", \"zlib\", and \"lz4\". auto Compressed format: indicates that the file name extension automatically checks the compressed format of a file none Compressed format: indicates the uncompressed format, and the rest indicates the compressed format of the file"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#example","title":"Example","text":"
    create external table ex_table_cpk(clo1 tinyint,clo2 smallint,clo3 int,clo4 bigint,clo5 tinyint unsigned,clo6 smallint unsigned,clo7 int unsigned,clo8 bigint unsigned,col9 float,col10 double,col11 varchar(255),col12 Date,col13 DateTime,col14 timestamp,col15 bool,col16 decimal(5,2),col17 text,col18 varchar(255),col19 varchar(255),col20 varchar(255))infile{\"filepath\"='$resources/external_table_file/cpk_table_1.csv'};\n

    For more information on creating an external table with an s3option mapping to an S3 file, see Import the data from S3 Compatible object storage.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#constraints","title":"Constraints","text":"

    MatrixOne only supports select on EXTERNAL TABLE, delete, insert, and update is not supported.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/","title":"CREATE INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#description","title":"Description","text":"

    Create indexes on tables to query data more quickly and efficiently.

    You can't see the index; the index can only be used to speed up the search/query.

    Updating a table with an index takes longer than updating a table without an index because the index also needs to be updated. Therefore, the ideal approach is to create indexes only on frequently searched columns (and tables).

    There are two common types of indexes, namely:

    • Primary Key: The primary key index, that is, the index identified on the primary key column.
    • Secondary Index: the secondary index, that is, the index identified on the non-primary key.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#syntax","title":"Syntax","text":"
    > CREATE [UNIQUE] INDEX index_name\nON tbl_name (key_part,...)\nCOMMENT 'string'\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#create-unique-index","title":"CREATE UNIQUE INDEX","text":"

    Creates a unique index on a table. Duplicate values are not allowed.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(id int PRIMARY KEY,name VARCHAR(255),age int);\ninsert into t1 values(1,\"Abby\", 24);\ninsert into t1 values(2,\"Bob\", 25);\ninsert into t1 values(3,\"Carol\", 23);\ninsert into t1 values(4,\"Dora\", 29);\ncreate unique index idx on t1(name);\nmysql> select * from t1;\n+------+-------+------+\n| id   | name  | age  |\n+------+-------+------+\n|    1 | Abby  |   24 |\n|    2 | Bob   |   25 |\n|    3 | Carol |   23 |\n|    4 | Dora  |   29 |\n+------+-------+------+\n4 rows in set (0.00 sec)\n\nmysql> show create table t1;\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                     |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1    | CREATE TABLE `t1` (\n`id` INT NOT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`age` INT DEFAULT NULL,\nPRIMARY KEY (`id`),\nUNIQUE KEY `idx` (`name`)\n) |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n\ncreate table t2 (\ncol1 bigint primary key,\ncol2 varchar(25),\ncol3 float,\ncol4 varchar(50)\n);\ncreate unique index idx on t2(col2) comment 'create varchar index';\ninsert into t2 values(1,\"Abby\", 24,'zbcvdf');\ninsert into t2 values(2,\"Bob\", 25,'zbcvdf');\ninsert into t2 values(3,\"Carol\", 23,'zbcvdf');\ninsert into t2 values(4,\"Dora\", 29,'zbcvdf');\nmysql> select * from t2;\n+------+-------+------+--------+\n| col1 | col2  | col3 | col4   |\n+------+-------+------+--------+\n|    1 | Abby  |   24 | zbcvdf |\n|    2 | Bob   |   25 | zbcvdf |\n|    3 | Carol |   23 | zbcvdf |\n|    4 | Dora  |   29 | zbcvdf |\n+------+-------+------+--------+\n4 rows in set (0.00 sec)\nmysql> show create table t2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                                                                              |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t2    | CREATE TABLE `t2` (\n`col1` BIGINT NOT NULL,\n`col2` VARCHAR(25) DEFAULT NULL,\n`col3` FLOAT DEFAULT NULL,\n`col4` VARCHAR(50) DEFAULT NULL,\nPRIMARY KEY (`col1`),\nUNIQUE KEY `idx` (`col2`) COMMENT `create varchar index`\n) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/","title":"CREATE PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#description","title":"Description","text":"

    CREATE PUBLICATION adds a new publication into the current database.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#syntax","title":"Syntax","text":"
    CREATE PUBLICATION pubname\n    DATABASE database_name ACCOUNT\n    [ { ALL\n    | account_name, [, ... ] }]\n    [ COMMENT 'string']\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#explanations","title":"Explanations","text":"
    • pubname: The publication name. The publication name must be distinct from the name of any existing publication in the current database.
    • database_name: specifies the database name that exists under the current account.
    • account_name: The account name. The name of the account which obtains the publication.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#examples","title":"Examples","text":"
    create database t;\ncreate account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\nmysql> create publication pub1 database t account acc0,acc1;\nQuery OK, 0 rows affected (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#constraints","title":"Constraints","text":"

    MatrxiOne currently only supports publishing one database at a time.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/","title":"CREATE SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#description","title":"Description","text":"

    The CREATE SEQUENCE user creates a sequence object. A sequence is a unique database object that can automatically generate a unique sequence of numbers. Typically, sequences are used to automatically generate unique values for a table's primary key fields.

    CREATE SEQUENCE is a command that creates an auto-increment number sequence to generate unique, continuous numeric values, usually used to create values for primary key columns or other columns requiring auto-increment numbers.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#syntax","title":"Syntax","text":"
    > CREATE SEQUENCE [ IF NOT EXISTS ] SEQUENCE_NAME\n    [ AS data_type ]\n    [ INCREMENT [ BY ] increment ]\n    [ MINVALUE minvalue] [ MAXVALUE maxvalue]\n    [ START [ WITH ] start ] [ [ NO ] CYCLE ]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#data_type","title":"data_type","text":"

    The optional clause AS data_type specifies the data type of the sequence. Supported data types include smallint [unsigned], integer [unsigned], and bigint [unsigned], with bigint being the default. The data type determines the default minimum and maximum values for the sequence.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#increment","title":"INCREMENT","text":"

    The optional clause INCREMENT [BY] increment specifies the value to add to the current sequence value to create a new value. Positive values generate ascending sequences, and negative values generate descending sequences; the default value is 1.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#minvalue","title":"MINVALUE","text":"

    The optional clause MINVALUE minvalue determines the minimum value that the sequence can generate. If this clause is not provided or MINVALUE is not specified, a default value will be used. The default value for an ascending sequence is 1, and for a descending sequence it is the minimum value for the data type.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#maxvalue","title":"MAXVALUE","text":"

    The optional clause MAXVALUE maxvalue determines the maximum value for the sequence. If this clause is not provided or MAXVALUE is not specified, a default value will be used. The default value for an ascending sequence is the maximum value for the data type, and for a descending sequence it is -1.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#start","title":"START","text":"

    The optional clause START [WITH] start allows the sequence to start from any point. The default starting value is the minimum value for an ascending sequence and the maximum value for a descending sequence.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#cycle","title":"CYCLE","text":"

    The CYCLE option allows the sequence to wrap around when it reaches the maximum or minimum value for an ascending or descending sequence, respectively. If the limit is reached, the next generated number will be the minimum or maximum value, respectively.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#operations","title":"Operations","text":"

    The following functions are used to manipulate sequence values:

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#nextvalsequence_name","title":"NEXTVAL(sequence_name)","text":"

    Sets the current value to the next value in the sequence and returns it.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#currvalsequence_name","title":"CURRVAL(sequence_name)","text":"

    Returns the current value in the sequence.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#setvalsequence_name-n-b","title":"SETVAL(sequence_name, n [,b])","text":"

    Sets the current value in the sequence to n.

    • If b is set to true, the next call to NEXTVAL will return n.
    • If b is set to false, the next call to NEXTVAL will return n+increment.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#lastval","title":"LASTVAL()","text":"

    Return the value of any sequence obtained by NEXTVAL in the current session; if the current value is set by SETVAL first, and then use LASTVAL to operate on the sequence, return SETVAL The current value of the setting. Since 'LASTVAL()' returns a 'NEXTVAL' value, 'LASTVAL()' can only be initialized by 'NEXTVAL'.

    LASTVAL() is affected by SETVAL(sequence_name, n [,true]) to change the current value, as shown in the following example:

    Suppose a sequence named seq_id was created with a starting value of 1, an increment of 1, and a maximum value of 1000:

    CREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\n

    Then, the NEXTVAL() function can be used to get the next sequence value and automatically increment the sequence counter:

    SELECT NEXTVAL('seq_id');\n

    Next, the LASTVAL() function can be used to return the current value of the sequence:

    SELECT LASTVAL();\n

    Alternatively, the SETVAL() function can be used to set the current value to 30, with the optional [,b] parameter set to true:

    SELECT SETVAL('seq_id', 30);\n

    Afterward, the NEXTVAL() function can be used again to get the next sequence value:

    SELECT NEXTVAL('seq_id');\n

    This will return 31 because the current value has been set to 30, and the NEXTVAL() function will return the next sequence value 31.

    SELECT LASTVAL();\n

    Using LASTVAL() will return the value of the sequence that was retrieved with NEXTVAL() in the current session, which is 31 in this case.

    The above example shows that if the current value is set using SETVAL(sequence_name, n [,true]) and then the next sequence value is retrieved using NEXTVAL, calling LASTVAL() again will return the value of the sequence retrieved with NEXTVAL().

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#using-sequence-in-a-table","title":"Using SEQUENCE in a table","text":"

    To use a sequence in a table, the following steps need to be completed:

    1. Create a sequence object: A sequence named \"my_sequence\" can be created using the following SQL command:

      CREATE SEQUENCE my_sequence;\n

      This will create a simple sequence object that will start at 1 and increment by 1.

    2. Apply a sequence to a field in a table: To apply a sequence to a field in a table, you need to specify a default value for the next value in the sequence in the table definition, as follows:

      CREATE TABLE my_table (\nid INTEGER DEFAULT nextval('my_sequence'),\nname VARCHAR(50));\n

      In the example above, the \"id\" field will automatically get the following unique value from the sequence as its default value.

    3. Insert data: After the table and sequence have been defined, you can use the INSERT statement to insert data into the table. When inserting a row of data, if no value is specified for the \"id\" field, MatrixOne will automatically get the following unique value from the sequence as its default value.

      For example, the following statement will insert a row into the \"my_table\" table and automatically assign a unique value to the \"id\" field:

      INSERT INTO my_table (name) VALUES ('John');\nINSERT INTO my_table (name) VALUES ('Tom');\n
    4. Using sequences makes it easy to automatically assign unique identifiers in the form, thus avoiding the possible errors of manually assigning identifiers. Use the following statement for query verification:

      mysql> select * from my_table;\n+------+------+\n| id   | name |\n+------+------+\n|    1 | John |\n|    2 | Tom  |\n+------+------+\n2 rows in set (0.01 sec)\n

    Note

    When using SEQUENCE in a table, the auto_increment and sequence cannot be used together; otherwise, an error will be reported.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#examples","title":"Examples","text":"
    -- Create a sequence named \"seq_id\" that starts from 1, increments by 1, and has a maximum value of 1000:\nCREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\n-- After creating the sequence, the NEXTVAL function can be used to retrieve the next sequence value as shown below:\nmysql> SELECT NEXTVAL('seq_id');\n+-----------------+\n| nextval(seq_id) |\n+-----------------+\n| 1               |\n+-----------------+\n1 row in set (0.02 sec)\n-- This command will return the next value in the sequence (e.g., 1) and automatically increment the counter of the sequence.\n\n-- The CURRVAL function returns the current value.\nmysql> SELECT CURRVAL('seq_id');\n+-----------------+\n| currval(seq_id) |\n+-----------------+\n| 1               |\n+-----------------+\n1 row in set (0.01 sec)\n\n-- Returns the most recent value retrieved by NEXTVAL in the current session for any sequence.\nmysql> SELECT LASTVAL();\n+-----------+\n| lastval() |\n+-----------+\n| 1         |\n+-----------+\n1 row in set (0.00 sec)\n\n-- Set the current value to 30.\nmysql> SELECT SETVAL('seq_id', 30);\n+--------------------+\n| setval(seq_id, 30) |\n+--------------------+\n| 30                 |\n+--------------------+\n1 row in set (0.02 sec)\n\n-- The NEXTVAL function retrieves the next sequence value.\nmysql> SELECT NEXTVAL('seq_id');\n+-----------------+\n| nextval(seq_id) |\n+-----------------+\n| 31              |\n+-----------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/","title":"CREATE STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#description","title":"Description","text":"

    The CREATE STAGE command is used in the MatrixOne database to create a named internal or external data stage for data export. By creating a data stage and exporting data to it, you can download data files to your local system or store them in cloud storage services.

    • Internal Stage: Internal stages store data files within the MatrixOne system. Internal stages can be either permanent or temporary.

    • External Stage: External stages reference data files stored outside the MatrixOne environment. Currently, the following cloud storage services are supported:

      • Amazon S3 buckets
      • Aliyun buckets

    The storage location can be private/protected or public\u2014however, data held in archival cloud storage classes that require restoration before retrieval cannot be accessed.

    An internal or external stage can include a directory table. Directory tables maintain a catalog of staged file directories in cloud storage.

    • Configure a specified path to control the write permissions for user SELECT INTO operations. After creation, users can only write to the set STAGE path.

    • If no STAGE is created or all STAGE instances are DISABLED, users can write to any path permitted by the operating system or object storage permissions.

    • If not using a STAGE, users must forcefully include credential information during SELECT INTO operations.

    Note

    1. Cluster administrators (i.e., root users) and tenant administrators can create data stages.
    2. Once created, data tables can only be imported to the paths specified in the STAGE.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#syntax","title":"Syntax","text":"
    > CREATE STAGE [ IF NOT EXISTS ] { stage_name }\n   { StageParams }\u0005\n   [ directoryTableParams ]\n   [ COMMENT = '<string_literal>' ]\n\nStageParams (for Amazon S3) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for Aliyun OSS) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for File System) :\nURL= 'filepath'\n\ndirectoryTableParams :\nENABLE = { TRUE | FALSE }\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#explanations","title":"Explanations","text":"
    • IF NOT EXISTS: An optional parameter used to check whether a stage with the same name already exists when creating a stage, avoiding duplicate creations.

    • stage_name: The name of the stage to be created.

    • StageParams: This parameter group is used to specify the stage's configuration parameters.

      • endpoint: The connection URL for the stage, indicating the location of the object storage service. This URL's content may vary for object storage services like Amazon S3, Aliyun OSS, or a file system. For example s3.us-west-2.amazonaws.com

      • CREDENTIALS: This JSON object contains the credentials required to connect to the object storage service, such as access_key_id, secret_access_key, etc.

    • directoryTableParams: This parameter group is used to specify the configuration of a directory table associated with the stage.

      • ENABLE: Indicates whether the directory table is enabled, with values TRUE or FALSE values.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#examples","title":"Examples","text":"
    CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- Create internal data stage\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- Export data from the table to data stage\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- You can see your exported table in your local directory\n\n-- After setting the data stage, the data table can only be exported to the specified path, and an error will be reported when exporting to other paths\nmysql> SELECT * FROM user INTO OUTFILE '~/tmp/csv2/user.txt';\nERROR 20101 (HY000): internal error: stage exists, please try to check and use a stage instead\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/","title":"CREATE...FROM...PUBLICATION...","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#description","title":"Description","text":"

    CREATE...FROM...PUBLICATION... is when the subscriber subscribes to a publication created by the publisher to obtain the publisher's shared data.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#syntax","title":"Syntax","text":"
    CREATE DATABASE database_name\nFROM account_name\nPUBLICATION pubname;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#explanations","title":"Explanations","text":"
    • database_name: The name of the database created by the subscriber.
    • pubname: The name of the publication that the publisher has published.
    • account_name: The account name of the publication can be obtained.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#examples","title":"Examples","text":"
    --Suppose the system administrator creates a account acc1 as the subscriber\ncreate account acc1 admin_name 'root' identified by '111';\n\n--Assuming session 1 is the publisher, the publisher first publishes a database to the account\ncreate database sys_db_1;\nuse sys_db_1;\ncreate table sys_tbl_1(a int primary key );\ninsert into sys_tbl_1 values(1),(2),(3);\ncreate view v1 as (select * from sys_tbl_1);\ncreate publication sys_pub_1 database sys_db_1;\nmysql> show publications;\n+-----------+----------+\n| Name      | Database |\n+-----------+----------+\n| sys_pub_1 | sys_db_1 |\n+-----------+----------+\n1 row in set (0.01 sec)\n\n--Open a new session again, assuming that session 2 is the subscriber and the subscriber subscribes to the published database\nmysql -h 127.0.0.1 -P 6001 -u acc1:root -p  -- Log into the account\ncreate database sub1 from sys publication pub1;\n\nmysql> create database sub1 from sys publication sys_pub_1;\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| system             |\n| system_metrics     |\n| information_schema |\n| mysql              |\n| mo_catalog         |\n| sub1               |\n+--------------------+\n6 rows in set (0.00 sec)\n\nmysql> show subscriptions;\n+------+--------------+\n| Name | From_Account |\n+------+--------------+\n| sub1 | sys          |\n+------+--------------+\n1 row in set (0.01 sec)\n\nmysql> use sub1;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nmysql> show tables;\n+----------------+\n| Tables_in_sub1 |\n+----------------+\n| sys_tbl_1      |\n| v1             |\n+----------------+\n2 rows in set (0.01 sec)\n\nmysql> desc sys_tbl_1;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type    | Null | Key  | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a     | INT(32) | NO   | PRI  | NULL    |       |         |\n+-------+---------+------+------+---------+-------+---------+\n1 row in set (0.01 sec)\n\nmysql> select * from sys_tbl_1 order by a;\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.01 sec)\n-- Subscribe successfully\n

    Note

    If you need to unsubscribe, you can directly delete the subscribed database. Refer to 'DROP DATABASE`.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/","title":"CREATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#description","title":"Description","text":"

    Create a new table.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#syntax","title":"Syntax","text":"
    > CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n    (create_definition,...)\n    [table_options]\n    [partition_options]\n\ncreate_definition: {\n    col_name column_definition\n  | [CONSTRAINT [symbol]] PRIMARY KEY\n      [index_type] (key_part,...)\n      [index_option] ...\n  | [CONSTRAINT [symbol]] FOREIGN KEY\n      [index_name] (col_name,...)\n      reference_definition\n}\n\ncolumn_definition: {\n    data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]\n      [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]\n      [COMMENT 'string']\n      [reference_definition]\n  | data_type\n      [[PRIMARY] KEY]\n      [COMMENT 'string']\n      [reference_definition]\n}\n\nreference_definition:\n    REFERENCES tbl_name (key_part,...)\n      [ON DELETE reference_option]\n      [ON UPDATE reference_option]\n\nreference_option:\n    RESTRICT | CASCADE | SET NULL | NO ACTION\u0005\n\ntable_options:\n    table_option [[,] table_option] ...\n\ntable_option: {\n  | AUTO_INCREMENT [=] value\n  | COMMENT [=] 'string'\n  | START TRANSACTION\u0005\n}\n\npartition_options:\n    PARTITION BY\n        { [LINEAR] HASH(expr)\n        | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)}\n    [PARTITIONS num]\n    [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n     [VALUES\n         {LESS THAN {(expr | value_list) | MAXVALUE}\n         |\n         IN (value_list)}]\n     [COMMENT [=] 'string' ]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#explanations","title":"Explanations","text":"

    Various parameters and options that can be used when creating a table, including table creation, column definition, constraints, options, and partitioning, are explained below:

    • CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name: This is the primary table syntax. The TEMPORARY keyword indicates creating a temporary table, IF NOT EXISTS ensures creation only if the table doesn't exist, and tbl_name is the name of the table to be created.

    • (create_definition,...): This is the section for column definitions, used to define the table's columns and their attributes.

    • [table_options]: This is for table-level options where you can set parameters like storage engine, character set, etc.

    • [partition_options]: This is used for partitioned tables and defining partitioning methods and keys.

    The create_definition section is used to define attributes for each column, and it can contain the following:

    • col_name column_definition: This defines the column name and its attributes, including data type, whether it can be null, default value, etc.

    • [CONSTRAINT [symbol]] PRIMARY KEY: This defines a primary key constraint and can set a constraint name and the columns that make up the primary key.

    • [CONSTRAINT [symbol]] FOREIGN KEY: This defines a foreign key constraint and can set a constraint name, columns for the foreign key, and the referenced table.

    The column_definition section is used to define attributes for specific columns and can include the following:

    • data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]: This defines the data type of the column, whether it can be null, and its default value.

    • [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]: This sets options like auto-increment, uniqueness, and primary key constraint.

    • [COMMENT 'string']: This sets a comment for the column.

    • [reference_definition]: This is an optional reference definition used to define foreign key constraints.

    The reference_definition section is used to define references for foreign keys and includes the following:

    • REFERENCES tbl_name (key_part,...): This specifies the referenced table and columns for the foreign key.

    • [ON DELETE reference_option]: This sets the action to be taken when a referenced row is deleted.

    • [ON UPDATE reference_option]: This sets the action to be taken when a referenced row is updated.

    reference_option represents the options for foreign key actions, including RESTRICT, CASCADE, SET NULL, and NO ACTION.

    The table_options section sets table-level options, including initial auto-increment value, table comments, etc.

    The partition_options section defines options for partitioned tables, including partitioning methods, partition keys, and the number of partitions.

    For more detailed syntax explanations, see the following content.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#temporary-tables","title":"Temporary Tables","text":"

    You can use the TEMPORARY keyword when creating a table. A TEMPORARY table is visible only within the current session, and is dropped automatically when the session is closed. This means that two different sessions can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name. (The existing table is hidden until the temporary table is dropped.)

    Dropping a database does automatically drop any TEMPORARY tables created within that database.

    The creating session can perform any operation on the table, such as DROP TABLE, INSERT, UPDATE, or SELECT.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#comment","title":"COMMENT","text":"

    A comment for a column or a table can be specified with the COMMENT option.

    • Up to 1024 characters long. The comment is displayed by the SHOW CREATE TABLE and SHOW FULL COLUMNS statements. It is also shown in the COLUMN_COMMENT column of the INFORMATION_SCHEMA.COLUMNS table.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#auto_increment","title":"AUTO_INCREMENT","text":"

    The initial AUTO_INCREMENT value for the table.

    An integer column can have the additional attribute AUTO_INCREMENT. When you insert a value of NULL (recommended) or 0 into an indexed AUTO_INCREMENT column, the column is set to the next sequence value. Typically this is value+1, where the value is the largest value for the column currently in the table. AUTO_INCREMENT sequences begin with 1 default.

    There can be only one AUTO_INCREMENT column per table, which must be indexed and cannot have a DEFAULT value. An AUTO_INCREMENT column works properly only if it contains only positive values. Inserting a negative number is regarded as inserting a very large positive number. This is done to avoid precision problems when numbers \"wrap\" over from positive to negative and also to ensure that you do not accidentally get an AUTO_INCREMENT column that contains 0.

    You can use the AUTO_INCREMENT attribute to define the starting value of an auto-increment column. If you want to set the starting value of the auto-increment column to 10, you can use the AUTO_INCREMENT keyword when creating the table and specify the starting value later.

    For example, to create a table and define an auto-increment column with a starting value of 10, you can use the following SQL statement:

    -- set up\ncreate table t1(a int auto_increment primary key) auto_increment = 10;\n

    In this example, the id column is an auto-incrementing column with a starting value 10. When a new record is inserted into the table, the value of the id column will start from 10 and increment by 1 each time. If the starting value of AUTO_INCREMENT is not specified, the default starting value is 1, which is automatically incremented by 1 each time.

    Note

    1. MatrixOne currently only supports the default increment step size of 1; regardless of the initial value of the auto-increment column, each auto-increment is 1. Temporarily does not support setting the incremental step size.
    2. MatrixOne only syntax supports using the system variable set @@auto_increment_offset=n to set the initial value of the auto-increment column, but it does not take effect.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#primary-key","title":"PRIMARY KEY","text":"

    The PRIMARY KEY constraint uniquely identifies each record in a table.

    Primary keys must contain UNIQUE values, and cannot contain NULL values.

    A table can have only ONE primary key; and in the table, this primary key can consist of single column (field).

    • SQL PRIMARY KEY on CREATE TABLE

    The following SQL creates a PRIMARY KEY on the \"ID\" column when the \"Persons\" table is created:

    > CREATE TABLE Persons (\n    ID int NOT NULL,\n    LastName varchar(255) NOT NULL,\n    FirstName varchar(255),\n    Age int,\n    PRIMARY KEY (ID)\n);\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#foreign-key","title":"FOREIGN KEY","text":"

    The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables.

    A FOREIGN KEY is a field (or collection of fields) in one table, that refers to the PRIMARY KEY in another table.

    The table with the foreign key is called the child table, and the table with the primary key is called the referenced or parent table.

    The FOREIGN KEY constraint prevents invalid data from being inserted into the foreign key column, because it has to be one of the values contained in the parent table.

    When defining FOREIGN KEY, the following rules need to be followed:

    • The parent table must already exist in the database or be a table currently being created. In the latter case, the parent table and the slave table are the same table, such a table is called a self-referential table, and this structure is called self-referential integrity.

    • A primary key must be defined for the parent table.

    • Specify the column name or combination of column names after the table name of the parent table. This column or combination of columns must be the primary or candidate key of the primary table.

    • The number of columns in the foreign key must be the same as the number of columns in the primary key of the parent table.

    • The data type of the column in the foreign key must be the same as the data type of the corresponding column in the primary key of the parent table.

    The following is an example to illustrate the association of parent and child tables through FOREIGN KEY and PRIMARY KEY:

    First, create a parent table with field a as the primary key:

    create table t1(a int primary key,b varchar(5));\ninsert into t1 values(101,'abc'),(102,'def');\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|  101 | abc  |\n|  102 | def  |\n+------+------+\n2 rows in set (0.00 sec)\n

    Then create a child table with field c as the foreign key, associated with parent table field a:

    create table t2(a int ,b varchar(5),c int, foreign key(c) references t1(a));\ninsert into t2 values(1,'zs1',101),(2,'zs2',102);\ninsert into t2 values(3,'xyz',null);\nmysql> select * from t2;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 | zs1  |  101 |\n|    2 | zs2  |  102 |\n|    3 | xyz  | NULL |\n+------+------+------+\n3 rows in set (0.00 sec)\n

    In addition, [ON DELETE reference_option] and [ON UPDATE reference_option] are used when defining a foreign key relationship to specify actions to be taken when records in the parent table are deleted or updated. These two parameters are primarily used to maintain data integrity and consistency:

    • ON DELETE reference_option: This parameter specifies how to handle associated foreign key data when data in the referenced table is deleted. Common options include:

      • RESTRICT: If related foreign key data exists in the referenced table, deletion of data in the table is not allowed. This prevents accidental deletion of related data, ensuring data consistency.

      • CASCADE: When data in the referenced table is deleted, associated foreign key data is also deleted. This is used for cascading deletion of related data to maintain data integrity.

      • SET NULL: When data in the referenced table is deleted, the value of the foreign key column is set to NULL. This is used to retain foreign key data while disconnecting it from the referenced data upon deletion.

      • NO ACTION: Indicates no action is taken; it only checks for the existence of associated data. This is similar to RESTRICT but may have minor differences in some databases.

    • ON UPDATE reference_option: This parameter specifies how to handle associated foreign key data when data in the referenced table is updated. Common options are similar to those of ON DELETE reference_option, and their usage is identical, but they apply to data update operations.

    See the example below:

    Suppose there are two tables, Orders and Customers, where the Orders table has a foreign key column customer_id referencing the id column in the Customers table. If, when a customer is deleted from the Customers table, you also want to delete the associated order data, you can use ON DELETE CASCADE.

    CREATE TABLE Customers (\nid INT PRIMARY KEY,\nname VARCHAR(50)\n);\n\nCREATE TABLE Orders (\nid INT PRIMARY KEY,\norder_number VARCHAR(10),\ncustomer_id INT,\nFOREIGN KEY (customer_id) REFERENCES Customers(id) ON DELETE CASCADE\n);\n

    In the above example, when a customer is deleted from the Customers table, the associated order data will also be deleted through cascading, maintaining data integrity. Similarly, the ON UPDATE parameter can handle update operations.

    For more information on data integrity constraints, see Data Integrity Constraints Overview.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#cluster-by","title":"Cluster by","text":"

    Cluster by is a command used to optimize the physical arrangement of a table. When creating a table, the Cluster by command can physically sort the table based on a specified column for tables without a primary key. It will rearrange the data rows to match the order of values in that column. Using Cluster by improves query performance.

    • The syntax for a single column is: create table() cluster by col;
    • The syntax for multiple columns is: create table() cluster by (col1, col2);

    Note: Cluster by cannot coexist with a primary key, or a syntax error will occur. Cluster by can only be specified when creating a table and does not support dynamic creation.

    For more information on using Cluster by for performing tuning, see Using Cluster by for performance tuning.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#table-partition-and-partitions","title":"Table PARTITION and PARTITIONS","text":"
    partition_options:\n PARTITION BY\n     { [LINEAR] HASH(expr)\n     | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)\n [PARTITIONS num]\n [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n     [VALUES\n         {LESS THAN {(expr | value_list) | MAXVALUE}\n         |\n         IN (value_list)}]\n     [COMMENT [=] 'string' ]\n

    Partitions can be modified, merged, added to tables, and dropped from tables.

    • PARTITION BY

    If used, a partition_options clause begins with PARTITION BY. This clause contains the function that is used to determine the partition; the function returns an integer value ranging from 1 to num, where num is the number of partitions.

    • HASH(expr)

    Hashes one or more columns to create a key for placing and locating rows. expr is an expression using one or more table columns. For example, these are both valid CREATE TABLE statements using PARTITION BY HASH:

    CREATE TABLE t1 (col1 INT, col2 CHAR(5))\n    PARTITION BY HASH(col1);\n\nCREATE TABLE t1 (col1 INT, col2 CHAR(5), col3 DATETIME)\n    PARTITION BY HASH ( YEAR(col3) );\n
    • KEY(column_list)

    This is similar to HASH. The column_list argument is simply a list of 1 or more table columns (maximum: 16). This example shows a simple table partitioned by key, with 4 partitions:

    CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE)\n    PARTITION BY KEY(col3)\n    PARTITIONS 4;\n

    For tables that are partitioned by key, you can employ linear partitioning by using the LINEAR keyword. This has the same effect as with tables that are partitioned by HASH. This example uses linear partitioning by key to distribute data between 5 partitions:

    CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE)\n    PARTITION BY LINEAR KEY(col3)\n    PARTITIONS 5;\n
    • RANGE(expr)

    In this case, expr shows a range of values using a set of VALUES LESS THAN operators. When using range partitioning, you must define at least one partition using VALUES LESS THAN. You cannot use VALUES IN with range partitioning.

    PARTITION ... VALUES LESS THAN ... statements work in a consecutive fashion. VALUES LESS THAN MAXVALUE works to specify \"leftover\" values that are greater than the maximum value otherwise specified.

    The clauses must be arranged in such a way that the upper limit specified in each successive VALUES LESS THAN is greater than that of the previous one, with the one referencing MAXVALUE coming last of all in the list.

    • PARTITIONS num

    The number of partitions may optionally be specified with a PARTITIONS num clause, where num is the number of partitions. If both this clause and any PARTITION clauses are used, num must be equal to the total number of any partitions that are declared using PARTITION clauses.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#examples","title":"Examples","text":"
    • Example 1: Create a common table
    CREATE TABLE test(a int, b varchar(10));\nINSERT INTO test values(123, 'abc');\n\nmysql> SELECT * FROM test;\n+------+---------+\n|   a  |    b    |\n+------+---------+\n|  123 |   abc   |\n+------+---------+\n
    • Example 2: Add comments when creating a table
    create table t2 (a int, b int) comment = \"fact table\";\n\nmysql> show create table t2;\n+-------+---------------------------------------------------------------------------------------+\n| Table | Create Table                                                                          |\n+-------+---------------------------------------------------------------------------------------+\n| t2    | CREATE TABLE `t2` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL\n) COMMENT='fact table',    |\n+-------+---------------------------------------------------------------------------------------+\n
    • Example 3: Add comments to columns when creating tables
    create table t3 (a int comment 'Column comment', b int) comment = \"table\";\n\nmysql> SHOW CREATE TABLE t3;\n+-------+----------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                             |\n+-------+----------------------------------------------------------------------------------------------------------+\n| t3    | CREATE TABLE `t3` (\n`a` INT DEFAULT NULL COMMENT 'Column comment',\n`b` INT DEFAULT NULL\n) COMMENT='table',     |\n+-------+----------------------------------------------------------------------------------------------------------+\n
    • Example 4: Create a common partitioned table
    CREATE TABLE tp1 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY KEY(col3) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp1;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                             |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp1   | CREATE TABLE `tp1` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col3) partitions 4 |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- do not specify the number of partitions\nCREATE TABLE tp2 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY KEY(col3);\n\nmysql> SHOW CREATE TABLE tp2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| tp2   | CREATE TABLE `tp2` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col3) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- Specify partition algorithm\nCREATE TABLE tp3\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY KEY ALGORITHM = 1 (col3);\n\n\nmysql> show create table tp3;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| tp3   | CREATE TABLE `tp3` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 1 (col3) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- Specify partition algorithm and the number of partitions\nCREATE TABLE tp4 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY LINEAR KEY ALGORITHM = 1 (col3) PARTITIONS 5;\n\nmysql> SHOW CREATE TABLE tp4;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                    |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp4   | CREATE TABLE `tp4` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by linear key algorithm = 1 (col3) partitions 5 |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- Multi-column partition\nCREATE TABLE tp5\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY KEY(col1, col2) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp5;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                   |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp5   | CREATE TABLE `tp5` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col1, col2) partitions 4 |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- Create a primary key column partition\nCREATE TABLE tp6\n(\ncol1 INT  NOT NULL PRIMARY KEY,\ncol2 DATE NOT NULL,\ncol3 INT  NOT NULL,\ncol4 INT  NOT NULL\n) PARTITION BY KEY(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp6;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                                        |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp6   | CREATE TABLE `tp6` (\n`col1` INT NOT NULL,\n`col2` DATE NOT NULL,\n`col3` INT NOT NULL,\n`col4` INT NOT NULL,\nPRIMARY KEY (`col1`)\n) partition by key algorithm = 2 (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- Create HASH partition\nCREATE TABLE tp7\n(\ncol1 INT,\ncol2 CHAR(5)\n) PARTITION BY HASH(col1);\n\nmysql> SHOW CREATE TABLE tp7;\n+-------+------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                         |\n+-------+------------------------------------------------------------------------------------------------------+\n| tp7   | CREATE TABLE `tp7` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL\n) partition by hash (col1) |\n+-------+------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- Specifies the number of HASH partitions when creating hash partition\nCREATE TABLE tp8\n(\ncol1 INT,\ncol2 CHAR(5)\n) PARTITION BY HASH(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp8;\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                      |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| tp8   | CREATE TABLE `tp8` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL\n) partition by hash (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- specify the partition granularity when creating a partition\nCREATE TABLE tp9\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATETIME\n) PARTITION BY HASH (YEAR(col3));\n\nmysql> SHOW CREATE TABLE tp9;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                             |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n| tp9   | CREATE TABLE `tp9` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATETIME DEFAULT NULL\n) partition by hash (year(col3)) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- specify the partition granularity and number of partitions when creating a partition\nCREATE TABLE tp10\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY LINEAR HASH( YEAR(col3)) PARTITIONS 6;\n\nmysql> SHOW CREATE TABLE tp10;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                              |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp10  | CREATE TABLE `tp10` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by linear hash (year(col3)) partitions 6 |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- Use the primary key column as the HASH partition when creating a partition\nCREATE TABLE tp12 (col1 INT NOT NULL PRIMARY KEY, col2 DATE NOT NULL, col3 INT NOT NULL, col4 INT NOT NULL) PARTITION BY HASH(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp12;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                            |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp12  | CREATE TABLE `tp12` (\n`col1` INT NOT NULL,\n`col2` DATE NOT NULL,\n`col3` INT NOT NULL,\n`col4` INT NOT NULL,\nPRIMARY KEY (`col1`)\n) partition by hash (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
    • Example 5: Primary key auto increment
    drop table if exists t1;\ncreate table t1(a bigint primary key auto_increment,\nb varchar(10));\ninsert into t1(b) values ('bbb');\ninsert into t1 values (3, 'ccc');\ninsert into t1(b) values ('bbb1111');\n\nmysql> select * from t1 order by a;\n+------+---------+\n| a    | b       |\n+------+---------+\n|    1 | bbb     |\n|    3 | ccc     |\n|    4 | bbb1111 |\n+------+---------+\n3 rows in set (0.01 sec)\n\ninsert into t1 values (2, 'aaaa1111');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a    | b        |\n+------+----------+\n|    1 | bbb      |\n|    2 | aaaa1111 |\n|    3 | ccc      |\n|    4 | bbb1111  |\n+------+----------+\n4 rows in set (0.00 sec)\n\ninsert into t1(b) values ('aaaa1111');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a    | b        |\n+------+----------+\n|    1 | bbb      |\n|    2 | aaaa1111 |\n|    3 | ccc      |\n|    4 | bbb1111  |\n|    5 | aaaa1111 |\n+------+----------+\n5 rows in set (0.01 sec)\n\ninsert into t1 values (100, 'xxxx');\ninsert into t1(b) values ('xxxx');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a    | b        |\n+------+----------+\n|    1 | bbb      |\n|    2 | aaaa1111 |\n|    3 | ccc      |\n|    4 | bbb1111  |\n|    5 | aaaa1111 |\n|  100 | xxxx     |\n|  101 | xxxx     |\n+------+----------+\n7 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#constraints","title":"Constraints","text":"
    1. Currently, it is not supported to use the ALTER TABLE table_name DROP PRIMARY KEY statement to drop the primary key from a table.
    2. The ALTER TABLE table_name AUTO_INCREMENT = n; statement is not supported to modify the initial value of the auto-increment column.
    3. In MatrixOne, only syntax supports using the system variable set @@auto_increment_increment=n to set the incremental step size, and only syntax supports using the system variable set @@auto_increment_offset=n to set the default auto-increment column initial value, but it does not take effect; currently supports setting the initial value AUTO_INCREMENT=n of the auto-increment column, but the step size is still 1 by default.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/","title":"CREATE VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/#description","title":"Description","text":"

    The view is a virtual table based on the result-set of an SQL statement.

    A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.

    You can add SQL statements and functions to a view and present the data as if the data were coming from one single table.

    A view is created with the CREATE VIEW statement.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/#syntax","title":"Syntax","text":"
    > CREATE VIEW view_name AS\n  SELECT column1, column2, ...\n  FROM table_name\n  WHERE condition;\n

    Note

    A view always shows up-to-date data! The database engine recreates the view, every time a user queries it.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/#examples","title":"Examples","text":"
    • Example 1:
    CREATE TABLE t00(a INTEGER);\nINSERT INTO t00 VALUES (1),(2);\nCREATE TABLE t01(a INTEGER);\nINSERT INTO t01 VALUES (1);\nCREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\n\nmysql> SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    1 |\n|    2 | NULL |\n+------+------+\n2 rows in set (0.01 sec)\n\nmysql> SELECT * FROM v0 WHERE b >= 0;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    1 |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> SHOW CREATE VIEW v0;\n+------+----------------------------------------------------------------------------+\n| View | Create View                                                                |\n+------+----------------------------------------------------------------------------+\n| v0   | CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a) |\n+------+----------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
    • Example 2:
    drop table if exists t1;\ncreate table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\ninsert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\ndrop table if exists t2;\ncreate table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\ninsert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\nmysql> select * from (select * from t1) sub where id > 4;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.01 sec)\n\ncreate view v1 as select * from (select * from t1) sub where id > 4;\ncreate view v2 as select ti as t,fl as f from (select * from t1) sub where dl <> 4;\ncreate view v3 as select * from (select ti as t,fl as f from t1 where dl <> 4) sub;\ncreate view v4 as select id,min(ti) from (select * from t1) sub group by id;\ncreate view v5 as select * from (select id,min(ti) from (select * from t1) t1 group by id) sub;\nmysql> select * from v1;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.00 sec)\n\nmysql> select * from v2;\n+------+----------+\n| t    | f        |\n+------+----------+\n|    1 |  1113.32 |\n|    2 |  2252.05 |\n|    6 |  3663.21 |\n|    7 |  4715.22 |\n|    1 |    51.26 |\n|    3 |    632.1 |\n|    4 |  7443.11 |\n|    7 |     8758 |\n|    8 | 9849.312 |\n+------+----------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v3;\n+------+----------+\n| t    | f        |\n+------+----------+\n|    1 |  1113.32 |\n|    2 |  2252.05 |\n|    6 |  3663.21 |\n|    7 |  4715.22 |\n|    1 |    51.26 |\n|    3 |    632.1 |\n|    4 |  7443.11 |\n|    7 |     8758 |\n|    8 | 9849.312 |\n+------+----------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v4;\n+------+---------+\n| id   | min(ti) |\n+------+---------+\n|    1 |       1 |\n|    2 |       2 |\n|    3 |       6 |\n|    4 |       7 |\n|    5 |       1 |\n|    6 |       3 |\n|    7 |       4 |\n|    8 |       7 |\n|    9 |       8 |\n+------+---------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v5;\n+------+---------+\n| id   | min(ti) |\n+------+---------+\n|    1 |       1 |\n|    2 |       2 |\n|    3 |       6 |\n|    4 |       7 |\n|    5 |       1 |\n|    6 |       3 |\n|    7 |       4 |\n|    8 |       7 |\n|    9 |       8 |\n+------+---------+\n9 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/","title":"DROP DATABASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#description","title":"Description","text":"

    Drop a database.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#syntax","title":"Syntax","text":"
    > DROP DATABASE [IF EXISTS] <database_name>\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#examples","title":"Examples","text":"
    CREATE DATABASE test01;\n\nmysql> DROP DATABASE test01;\nQuery OK, 0 rows affected (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/","title":"DROP INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#description","title":"Description","text":"

    This statement deletes the index from the currently selected table and will report an error if the index does not exist unless the IF EXISTS modifier is used.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#syntax","title":"Syntax","text":"
    > DROP INDEX index_name ON tbl_name\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#examples","title":"Examples","text":"
    create table t5(a int, b int, unique key(a));\nmysql> show create table t5;\n+-------+----------------------------------------------------------------------------------------+\n| Table | Create Table                                                                           |\n+-------+----------------------------------------------------------------------------------------+\n| t5    | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`)\n) |\n+-------+----------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\ncreate index b on t5(b);\nmysql> show create table t5;\n+-------+-------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                          |\n+-------+-------------------------------------------------------------------------------------------------------+\n| t5    | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`),\nKEY `b` (`b`)\n) |\n+-------+-------------------------------------------------------------------------------------------------------+\n1 row in set (0.02 sec)\n\ndrop index b on t5;\nmysql> show create table t5;\n+-------+----------------------------------------------------------------------------------------+\n| Table | Create Table                                                                           |\n+-------+----------------------------------------------------------------------------------------+\n| t5    | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`)\n) |\n+-------+----------------------------------------------------------------------------------------+\n1 row in set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/","title":"DROP PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#description","title":"Description","text":"

    DROP PUBLICATION can delete the existed publication.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#syntax","title":"Syntax","text":"
    DROP PUBLICATION pubname;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#explanations","title":"Explanations","text":"
    • pubname: The name of an existing publication whose definition is to be deleted.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#examples","title":"Examples","text":"
    create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nmysql> show publications;\n+------+----------+\n| Name | Database |\n+------+----------+\n| pub3 | t        |\n+------+----------+\n1 row in set (0.00 sec)\n\nmysql> drop publication pub3;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> show publications;\nEmpty set (0.00 sec)  
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/","title":"DROP SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#description","title":"Description","text":"

    DROP SEQUENCE is used to drop a sequence. It allows you to delete sequences previously created with the CREATE SEQUENCE command.

    Deleting a sequence deletes all properties and values of the sequence. Therefore, before dropping a sequence, you must ensure that no tables are still using the sequence.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#syntax","title":"Syntax","text":"
    > DROP SEQUENCE [ IF EXISTS ] SEQUENCE_NAME [, ...]\n  [IF EXISTS]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#examples","title":"Examples","text":"
    -- Delete the sequence named \"seq_id\"\nDROP SEQUENCE seq_id;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/","title":"DROP STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#description","title":"Description","text":"

    DROP STAGE drops a named internal or external data stage from the database. The data stage is a temporary storage area that loads data from a file into a database table or exports data from a database table to a file. Use the DROP STAGE command to remove stages of data that are no longer needed from the database, freeing storage space and avoiding additional storage charges.

    Note

    The cluster administrator (i.e., the root user) and account administrators can delete data stages.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#syntax","title":"Syntax","text":"
    -- Delete internal stage\n> DROP STAGE [IF EXISTS] {internal_stage_name};\n\n-- Delete external stage\n> DROP STAGE  [IF EXISTS] {external_stage_name};\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#examples","title":"Examples","text":"
    CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- Create internal data stage\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- Export data from the table to data stage\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- You can see your exported table in your local directory\n\n-- delete stage1\nmysql> drop stage stage1;\nQuery OK, 0 rows affected (0.01 sec)\n\n-- stage1 has been deleted; the data stage is not available\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\nERROR 20101 (HY000): internal error: stage 'stage1' is not exists, please check\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/","title":"DROP TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#description","title":"Description","text":"

    Deletes the table.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#syntax","title":"Syntax","text":"
    > DROP TABLE [IF EXISTS] [db.]name\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#examples","title":"Examples","text":"
    CREATE TABLE table01(a int);\n\nmysql> DROP TABLE table01;\nQuery OK, 0 rows affected (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/","title":"DROP VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#description","title":"Description","text":"

    DROP VIEW removes one or more views.

    If any views named in the argument list do not exist, the statement fails with an error indicating by name which nonexisting views it was unable to drop, and no changes are made.

    The IF EXISTS clause prevents an error from occurring for views that don't exist. When this clause is given, a NOTE is generated for each nonexistent view.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#syntax","title":"Syntax","text":"
    > DROP VIEW [IF EXISTS]\n    view_name [, view_name] ...\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#examples","title":"Examples","text":"
    CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT);\nCREATE VIEW v1 AS SELECT * FROM t1;\n\nmysql> DROP VIEW v1;\nQuery OK, 0 rows affected (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/","title":"TRUNCATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#description","title":"Description","text":"

    The TRUNCATE TABLE statement deletes all rows in a table without logging individual row deletions. TRUNCATE TABLE is similar to a DELETE statement without a WHERE clause; however, TRUNCATE TABLE is faster and uses fewer system and transaction log resources.

    TRUNCATE TABLE has the following characteristics:

    • It cannot be restored after the TRUNCATE TABLE is deleted.

    • If the table has an AUTO_INCREMENT column, the TRUNCATE TABLE statement resets the auto-increment value to zero.

    • The TRUNCATE TABLE statement deletes rows individually if the table has FOREIGN KEY constraints.

    • If the table does not have any FOREIGN KEY constraints, the TRUNCATE TABLE statement will drop the table and recreate a new one with the same structure

    The difference between DROP TABLE, TRUNCATE TABLE, and DELETE TABLE:

    • DROP TABLE: Use DROP TABLE when you no longer need the table.
    • TRUNCATE TABLE: Use TRUNCATE TABLE to keep the table, but delete all records.
    • DELETE TABLE: When you want to delete some records, use DELETE TABLE.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#syntax","title":"Syntax","text":"
    > TRUNCATE [TABLE] table_name;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#table","title":"TABLE","text":"

    The TABLE keyword is optional. Use this to distinguish the TRUNCATE TABLE statement from the TRUNCATE function.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#examples","title":"Examples","text":"
    create table index_table_05 (col1 bigint not null auto_increment,col2 varchar(25),col3 int,col4 varchar(50),primary key (col1),unique key col2(col2),key num_id(col4));\ninsert into index_table_05(col2,col3,col4) values ('apple',1,'10'),('store',2,'11'),('bread',3,'12');\nmysql> select * from index_table_05;\n+------+-------+------+------+\n| col1 | col2  | col3 | col4 |\n+------+-------+------+------+\n|    1 | apple |    1 | 10   |\n|    2 | store |    2 | 11   |\n|    3 | bread |    3 | 12   |\n+------+-------+------+------+\n3 rows in set (0.00 sec)\n\nmysql> truncate table index_table_05;\nQuery OK, 0 rows affected (0.12 sec)\n\nmysql> select * from index_table_05;\nEmpty set (0.03 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/","title":"LOAD DATA","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#description","title":"Description","text":"

    The LOAD DATA statement reads rows from a text file into a table at a very high speed. The file can be read from the server host or a S3 compatible object storage. LOAD DATA is the complement of SELECT ... INTO OUTFILE. To write data from a table to a file, use SELECT ... INTO OUTFILE. To read the file back into a table, use LOAD DATA. The syntax of the FIELDS and LINES clauses is the same for both statements.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#load-external-data","title":"Load external data","text":"
    > LOAD DATA [LOCAL]\n    INFILE 'file_name'\n    INTO TABLE tbl_name\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY 'string']\n        [[OPTIONALLY] ENCLOSED BY 'char']\n    ]\n    [LINES\n        [STARTING BY 'string']\n        [TERMINATED BY 'string']\n    ]\n    [IGNORE number {LINES | ROWS}]\n    [SET column_name_1=nullif(column_name_1, expr1), column_name_2=nullif(column_name_2, expr2)...]\n    [PARALLEL {'TRUE' | 'FALSE'}]\n

    Parameter Explanation

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#input-file-location","title":"Input File Location","text":"
    • LOAD DATA INFILE 'file_name': Indicates that the data file to be loaded is on the same machine as the MatrixOne host server. file_name can be the relative path name of the storage location of the file, or it can be the absolute path name.

    • LOAD DATA LOCAL INFILE 'file_name': indicates that the data file to be loaded is not on the same machine as the MatrixOne host server; that is, the data file is on the client server. file_name can be the relative path name of the storage location of the file, or it can be the absolute path name.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#field-and-line-handling","title":"Field and Line Handling","text":"

    For both the LOAD DATA and SELECT ... INTO OUTFILE statements, the syntax of the FIELDS and LINES clauses is the same. Both clauses are optional, but FIELDS must precede LINES if both are specified.

    If you specify a FIELDS clause, each of its subclauses (TERMINATED BY, [OPTIONALLY] ENCLOSED BY) is also optional, except that you must specify at least one of them. Arguments to these clauses are permitted to contain only ASCII characters.

    If you specify no FIELDS or LINES clause, the defaults are the same as if you had written this:

    FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n'\n

    Note

    • FIELDS TERMINATED BY ',': with and only ,, | or \\t as delimiters.
    • ENCLOSED BY '\"': with and only \" as the included character.
    • LINES TERMINATED BY '\\n': Use and only use \\n or \\r\\n as the line separator.

    FIELDS TERMINATED BY

    FIELDS TERMINATED BY specifies the delimiter for a field. The FIELDS TERMINATED BY values can be more than one character.

    For example, to read the comma-delimited file, the correct statement is:

    LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',';\n

    If instead you tried to read the file with the statement shown following, it would not work because it instructs LOAD DATA to look for tabs between fields:

    LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY '\\t';\n

    The likely result is that each input line would be interpreted as a single field. You may encounter an error of \"ERROR 20101 (HY000): internal error: the table column is larger than input data column\".

    FIELDS ENCLOSED BY

    FIELDS TERMINATED BY option specifies the character enclose the input values. ENCLOSED BY value must be a single character. If the input values are not necessarily enclosed within quotation marks, use OPTIONALLY before the ENCLOSED BY option.

    For example, if some input values are enclosed within quotation marks, some are not:

    LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"';\n

    LINES TERMINATED BY

    LINES TERMINATED BY specifies the delimiter for the a line. The LINES TERMINATED BY values can be more than one character.

    For example, if the lines in a csv file are terminated by carriage return/newline pairs, you can load it with LINES TERMINATED BY '\\r\\n':

    LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n  LINES TERMINATED BY '\\r\\n';\n

    LINE STARTING BY

    If all the input lines have a common prefix that you want to ignore, you can use LINES STARTING BY 'prefix_string' to skip the prefix and anything before it. If a line does not include the prefix, the entire line is skipped. Suppose that you issue the following statement:

    LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ','  LINES STARTING BY 'xxx';\n

    If the data file looks like this:

    xxx\"abc\",1\nsomething xxx\"def\",2\n\"ghi\",3\n

    The resulting rows are (\"abc\",1) and (\"def\",2). The third row in the file is skipped because it does not contain the prefix.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#ignore-lines","title":"IGNORE LINES","text":"

    The IGNORE number LINES clause can be used to ignore lines at the start of the file. For example, you can use IGNORE 1 LINES to skip an initial header line containing column names:

    LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1 IGNORE 1 LINES;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#set","title":"SET","text":"

    MatrixOne only supports SET column_name=nullif(column_name,expr). That is, when column_name = expr, it returns NULL; otherwise, it returns the original value of column_name. For example, SET a=nullif(a,1), if a=1, returns NULL; otherwise, it returns the original value of column a.

    By setting the parameter, you can use SET column_name=nullif(column_name,\"null\") to return the NULL value in the column when loading the file.

    Example

    1. The details of the local file test.txt are as follows:

      id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\nnull,wederTom,\"man\"\n
    2. Create a table named user in MatrixOne:

      create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\n
    3. Load test.txt into the table user:

      LOAD DATA INFILE '/tmp/test.txt' INTO TABLE user SET id=nullif(id,\"null\");\n
    4. The result of the talbe is as below:

      select * from user;\n+------+-----------+------+\n| id   | user_name | sex  |\n+------+-----------+------+\n|    1 | weder     | man  |\n|    2 | tom       | man  |\n| null | wederTom  | man  |\n+------+-----------+------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#parallel","title":"PARALLEL","text":"

    For a sizeable well-formed file, such as a JSOLLines file or a CSV file with no line breaks in a line of data, you can use PARALLEL to load the file in parallel to speed up the loading.

    For example, for a large file of 2 G, use two threads to load; the second thread first splits and locates the 1G position, then reads and loads backward. In this way, two threads can read large files at the same time, and each thread can read 1G of data.

    Enable/Disable Parallel Loading Command Line Example:

    --  Enable Parallel Loading\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'TRUE';\n\n--  Disable Parallel Loading\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'FALSE';\n\n--  Parallel loading is disabled by default\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES;\n

    Note

    [PARALLEL {'TRUE' | 'FALSE'}] currently only support TRUE or FALSE and are not case-sensitive.

    Note: If the PARALLEL field is not added in the LOAD statement, for CSV files, parallel loading is disabled by default; for JSOLLines files, parallel loading is enabled by default. If there is a line terminator in the CSV file, such as '\\n', otherwise it may cause data errors when the file is loaded. If the file is too large, manually splitting the file from the '\\n' as the starting and ending point is recommended, then enabling parallel loading.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#load-time-series-data","title":"Load Time-Series Data","text":"
    > LOAD DATA INLINE FORMAT='' DATA=''\nINTO TABLE tbl_name\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY 'string']\n        [[OPTIONALLY] ENCLOSED BY 'char']\n    ]\n    [LINES\n        [STARTING BY 'string']\n        [TERMINATED BY 'string']\n    ]\n    [IGNORE number {LINES | ROWS}]\n

    Parameter Explanation

    The SQL command LOAD DATA INLINE for loading time-series data has the following parameter explanations:

    • FORMAT: Specifies the format of the time-series data being loaded; for example, FORMAT='csv' indicates that the data being loaded is in CSV format. It supports the same formats as LOAD DATA INFILE.

    • DATA: Specifies the actual time-series data to be loaded. In the example, DATA='1\\n2\\n' indicates that the data to be loaded consists of two lines containing the numbers 1 and 2.

    Note

    Parameters such as FIELDS, COLUMNS, TERMINATED BY, ENCLOSED BY, LINES, STARTING BY, and IGNORE can be referred to the parameter explanations of LOAD DATA INFILE as mentioned earlier.

    Example command for loading time-series data: load data inline format='csv', data='1\\n2\\n' into table t1;. This command loads the specified data in CSV format (which includes two lines, namely 1 and 2) into a database table named t1.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#supported-file-formats","title":"Supported file formats","text":"

    In MatrixOne's current release, LOAD DATA supports CSV(comma-separated values) format and JSONLines format file. See full tutorials for loading csv and jsonline.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#csv-format-standard-description","title":"CSV format standard description","text":"

    The CSV format loaded by MatrixOne conforms to the RFC4180 standard, and the CSV format is specified as follows:

    1. Each record is on a separate line, separated by a newline character (CRLF):

      aaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

    2. The last record in the file can have a terminating newline or no terminating newline (CRLF):

      aaa,bbb,ccc CRLF\nzzz,yyy,xxx\n

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

    3. An optional header line appears as the first line of the file and has the same format as a standard record line. For example:

      field_name,field_name,field_name CRLF\naaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n

      Imported into the table as follows:

      +------------+------------+------------+ | field_name | field_name | field_name | +------------+------------+------------+ | aaa | bbb | ccc | | zzz | yyy | xxx | +------------+------------+------------+

    4. In the header and each record, there may be one or more fields separated by commas. Whitespace within a field is part of the field and should not be ignored. A comma cannot follow the last field in each record. For example:

      aaa,bbb,ccc\n

      Or:

      a aa, bbb,cc c\n

      Both examples are correct.

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | bbb | ccc | +---------+---------+---------+

      Or:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | a aa | bbb | cc c | +---------+---------+---------+

    5. Each field can be enclosed in double quotes or not. Double quotes cannot appear inside a field if the field is not enclosed in double-quotes. For example:

      \"aaa\",\"bbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n

      Or:

      \"aaa\",\"bbb\",ccc CRLF\nzzz,yyy,xxx\n

      Both examples are correct.

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | bbb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

    6. Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes. For example:

      \"aaa\",\"b CRLF\nbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

    7. If double quotation marks are used to enclose the field, then multiple double quotation marks appearing in the field must also be enclosed in double quotation marks; otherwise, the first quotation mark of two double quotation marks in the field will be parsed as an escape character, thus keep a single, double quote. For example:

      \"aaa\",\"b\",\"bb\",\"ccc\"\n

      The above CSV will parse \"b\"\"bb\" into b\"bb; if the correct field is b\"\"bb, then it should be written as:

      \"aaa\",\"b\"\"\"\"bb\",\"ccc\"\n

      Or:

      \"aaa\",b\"\"bb,\"ccc\"\n

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b\"\"bb | ccc | +---------+---------+---------+

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#examples","title":"Examples","text":"

    The SSB Test is an example of LOAD DATA syntax. Complete a SSB Test with MatrixOne

    > LOAD DATA INFILE '/ssb-dbgen-path/lineorder_flat.tbl ' INTO TABLE lineorder_flat;\n

    The above statement means: load the lineorder_flat.tbl data set under the directory path /ssb-dbgen-path/ into the MatrixOne data table lineorder_flat.

    You can also refer to the following syntax examples to quickly understand LOAD DATA:

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#example-1-load-csv","title":"Example 1: LOAD CSV","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#simple-example","title":"Simple example","text":"

    The data in the file locally named char_varchar.csv is as follows:

    a|b|c|d\n\"a\"|\"b\"|\"c\"|\"d\"\n'a'|'b'|'c'|'d'\n\"'a'\"|\"'b'\"|\"'c'\"|\"'d'\"\n\"aa|aa\"|\"bb|bb\"|\"cc|cc\"|\"dd|dd\"\n\"aa|\"|\"bb|\"|\"cc|\"|\"dd|\"\n\"aa|||aa\"|\"bb|||bb\"|\"cc|||cc\"|\"dd|||dd\"\n\"aa'|'||aa\"|\"bb'|'||bb\"|\"cc'|'||cc\"|\"dd'|'||dd\"\naa\"aa|bb\"bb|cc\"cc|dd\"dd\n\"aa\"aa\"|\"bb\"bb\"|\"cc\"cc\"|\"dd\"dd\"\n\"aa\"\"aa\"|\"bb\"\"bb\"|\"cc\"\"cc\"|\"dd\"\"dd\"\n\"aa\"\"\"aa\"|\"bb\"\"\"bb\"|\"cc\"\"\"cc\"|\"dd\"\"\"dd\"\n\"aa\"\"\"\"aa\"|\"bb\"\"\"\"bb\"|\"cc\"\"\"\"cc\"|\"dd\"\"\"\"dd\"\n\"aa\"\"|aa\"|\"bb\"\"|bb\"|\"cc\"\"|cc\"|\"dd\"\"|dd\"\n\"aa\"\"\"\"|aa\"|\"bb\"\"\"\"|bb\"|\"cc\"\"\"\"|cc\"|\"dd\"\"\"\"|dd\"\n|||\n||||\n\"\"|\"\"|\"\"|\n\"\"\"\"|\"\"\"\"|\"\"\"\"|\"\"\"\"\n\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"\n

    Create a table named t1 in MatrixOne:

    mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(\n-> col1 char(225),\n-> col2 varchar(225),\n-> col3 text,\n-> col4 varchar(225)\n-> );\nQuery OK, 0 rows affected (0.02 sec)\n

    Load the data file into table t1:

    load data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|';\n

    The query result is as follows:

    mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa|aa     | bb|bb     | cc|cc     | dd|dd     |\n| aa|       | bb|       | cc|       | dd|       |\n| aa|||aa   | bb|||bb   | cc|||cc   | dd|||dd   |\n| aa'|'||aa | bb'|'||bb | cc'|'||cc | dd'|'||dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"|aa    | bb\"|bb    | cc\"|cc    | dd\"|dd    |\n| aa\"\"|aa   | bb\"\"|bb   | cc\"\"|cc   | dd\"\"|dd   |\n|           |           |           |           |\n|           |           |           |           |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n20 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#add-conditional-example","title":"Add conditional Example","text":"

    Following the example above, you can modify the LOAD DATA statement and add LINES STARTING BY 'aa' ignore 10 lines; at the end of the statement to experience the difference:

    delete from t1;\nload data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|' LINES STARTING BY 'aa' ignore 10 lines;\n

    The query result is as follows:

    mysql> select * from t1;\n+---------+---------+---------+---------+\n| col1    | col2    | col3    | col4    |\n+---------+---------+---------+---------+\n| aa\"aa   | bb\"bb   | cc\"cc   | dd\"dd   |\n| aa\"\"aa  | bb\"\"bb  | cc\"\"cc  | dd\"\"dd  |\n| aa\"\"aa  | bb\"\"bb  | cc\"\"cc  | dd\"\"dd  |\n| aa\"|aa  | bb\"|bb  | cc\"|cc  | dd\"|dd  |\n| aa\"\"|aa | bb\"\"|bb | cc\"\"|cc | dd\"\"|dd |\n|         |         |         |         |\n|         |         |         |         |\n|         |         |         |         |\n| \"       | \"       | \"       | \"       |\n| \"\"      | \"\"      | \"\"      | \"\"      |\n+---------+---------+---------+---------+\n10 rows in set (0.00 sec)\n

    As you can see, the query result ignores the first line and and ignores the common prefix aa.

    For more information on loding csv, see Import the .csv data.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#example-2-load-jsonlines","title":"Example 2: LOAD JSONLines","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#simple-example_1","title":"Simple example","text":"

    The data in the file locally named jsonline_array.jl is as follows:

    [true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11,[\"1\",2,null,false,true,{\"q\":1}],\"1qaz\",null,null]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\",{\"c\":1,\"b\":[\"a\",\"b\",{\"q\":4}]},\"1aza\",null,null]\n

    Create a table named t1 in MatrixOne:

    mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(col1 bool,col2 int,col3 varchar(100), col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float,col9 json,col10 text,col11 json,col12 bool);\nQuery OK, 0 rows affected (0.03 sec)\n

    Load the data file into table t1:

    load data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1;\n

    The query result is as follows:

    mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4       | col5                | col6                | col7 | col8   | col9                                  | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | [\"1\", 2, null, false, true, {\"q\": 1}] | 1qaz  | NULL  | NULL  |\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1}   | 1aza  | NULL  | NULL  |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#add-conditional-example_1","title":"Add conditional Example","text":"

    Following the example above, you can modify the LOAD DATA statement and add ignore 1 lines at the end of the statement to experience the difference:

    delete from t1;\nload data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1 ignore 1 lines;\n

    The query result is as follows:

    mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4       | col5                | col6                | col7 | col8   | col9                                | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1} | 1aza  | NULL  | NULL  |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n1 row in set (0.00 sec)\n

    As you can see, the query result ignores the first line.

    For more information on loding JSONLines, see Import the JSONLines data.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#constraints","title":"Constraints","text":"
    1. The REPLACE and IGNORE modifiers control handling of new (input) rows that duplicate existing table rows on unique key values (PRIMARY KEY or UNIQUE index values) are not supported in MatrixOne yet.
    2. Input pre-pressing with SET is supported very limitedly. Only SET columns_name=nullif(expr1,expr2) is supported.
    3. When enabling the parallel loading, it must be ensured that each row of data in the file does not contain the specified line terminator, such as '\\n'; otherwise, it will cause data errors during file loading.
    4. The parallel loading of files requires that the files be in uncompressed format, and parallel loading of files in compressed form is not currently supported.
    5. When you use load data local, you need to use the command line to connect to the MatrixOne service host: mysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile.
    6. MatrixOne does not support ESCAPED BY currently. Writing or reading special characters differs from MySQL to some extent.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/","title":"CASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#description","title":"Description","text":"

    The CASE statement for stored programs implements a complex conditional construct.

    Note: There is also a CASE operator, which differs from the CASE statement described here. See Flow Control Functions. The CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END.

    If no when_value or search_condition matches the value tested and the CASE statement contains no ELSE clause, a Case not found for CASE statement error results.

    Each statement_list consists of one or more SQL statements; an empty statement_list is not permitted.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#syntax-1","title":"Syntax 1","text":"
    CASE case_value\n    WHEN when_value THEN statement_list\n    [WHEN when_value THEN statement_list] ...\n    [ELSE statement_list]\nEND CASE\n

    For the first syntax, case_value is an expression. This value is compared to the when_value expression in each WHEN clause until one of them is equal. When an equal when_value is found, the corresponding THEN clause statement_list executes. If no when_value is equal, the ELSE clause statement_list executes, if there is one.

    This syntax cannot be used to test for equality with NULL because NULL = NULL is false.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#syntax-2","title":"Syntax 2","text":"
    CASE\n    WHEN search_condition THEN statement_list\n    [WHEN search_condition THEN statement_list] ...\n    [ELSE statement_list]\nEND CASE\n

    For the second syntax, each WHEN clause search_condition expression is evaluated until one is true, at which point its corresponding THEN clause statement_list executes. If no search_condition is equal, the ELSE clause statement_list executes, if there is one.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#examples","title":"Examples","text":"
    CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER);\nINSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1);\n\nmysql> SELECT CASE AVG (c0) WHEN any_value(c1) * any_value(c2) THEN 1 END FROM t1;\n+------------------------------------------------------------+\n| case avg(c0) when any_value(c1) * any_value(c2) then 1 end |\n+------------------------------------------------------------+\n|                                                          1 |\n+------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CASE any_value(c1) * any_value(c2) WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1;\n+--------------------------------------------------------------------------------+\n| case any_value(c1) * any_value(c2) when sum(c0) then 1 when avg(c0) then 2 end |\n+--------------------------------------------------------------------------------+\n|                                                                              2 |\n+--------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CASE any_value(c1) WHEN any_value(c1) + 1 THEN 1 END, ABS(AVG(c0)) FROM t1;\n+------------------------------------------------------+--------------+\n| case any_value(c1) when any_value(c1) + 1 then 1 end | abs(avg(c0)) |\n+------------------------------------------------------+--------------+\n|                                                 NULL |            1 |\n+------------------------------------------------------+--------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/","title":"DELETE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#description","title":"Description","text":"

    DELETE statement removes rows from a single table or multiple tables.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#single-table-syntax","title":"Single-Table Syntax","text":"
    DELETE FROM tbl_name [[AS] tbl_alias]\n    [WHERE where_condition]\n    [ORDER BY ...]\n    [LIMIT row_count]\n

    The DELETE statement deletes rows from tbl_name and returns the number of deleted rows.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#explanations","title":"Explanations","text":"
    • The conditions in the optional WHERE clause identify which rows to delete. With no WHERE clause, all rows are deleted.
    • If the ORDER BY clause is specified, the rows are deleted in the order that is specified. -The LIMIT clause places a limit on the number of rows that can be deleted.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#examples","title":"Examples","text":"
    • Single-Table Examples
    CREATE TABLE t1 (a bigint(3), b bigint(5) primary key);\ninsert INTO t1 VALUES (1,1),(1,2);\ndelete from t1 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    2 |\n+------+------+\n
    • Multiple-Table Examples

    Multiple-table join Syntax is also supported.

    drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a int);\ninsert into t1 values(1), (2), (4);\ncreate table t2 (b int);\ninsert into t2 values(1), (2), (5);\ndelete t1 from t1 join t2 where t1.a = 2;\n\nmysql> select * from t1;\n+------+\n| a    |\n+------+\n|    1 |\n|    4 |\n+------+\n2 rows in set (0.00 sec)\n
    drop database if exists db1;\ndrop database if exists db2;\ncreate database db1;\ncreate database db2;\nuse db2;\ndrop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values (1),(2),(4);\nuse db1;\ndrop table if exists t2;\ncreate table t2 (b int);\ninsert into t2 values(1),(2),(3);\ndelete from db1.t2, db2.t1 using db1.t2 join db2.t1 on db1.t2.b = db2.t1.a where 2 > 1;\n\nmysql> select * from db1.t2;\n+------+\n| b    |\n+------+\n|    3 |\n+------+\nmysql> select * from db2.t1;\n+------+\n| a    |\n+------+\n|    4 |\n+------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/","title":"INSERT INTO SELECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#description","title":"Description","text":"

    The INSERT INTO SELECT statement copies data from one table and inserts it into another table.

    The existing records in the target table are unaffected.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#syntax","title":"Syntax","text":"
    INSERT INTO table2 (column1, column2, column3, ...)\nSELECT column1, column2, column3, ...\nFROM table1\nWHERE condition;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#examples","title":"Examples","text":"
    create table t1(id int, name varchar(10));\ninsert into t1 values(1, 'a');\ninsert into t1 values(2, 'b');\ninsert into t1 values(3, 'c');\ncreate table t2(id int, appname varchar(10), country varchar(10));\ninsert into t2 values(1, 'appone', 'CN');\ninsert into t2 values(2, 'apptwo', 'CN');\nINSERT INTO t1 (name) SELECT appname FROM t2;\n\nmysql> select * from t1;\n+------+--------+\n| id   | name   |\n+------+--------+\n|    1 | a      |\n|    2 | b      |\n|    3 | c      |\n| NULL | appone |\n| NULL | apptwo |\n+------+--------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/","title":"INSERT ... ON DUPLICATE KEY UPDATE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/#description","title":"Description","text":"

    INSERT ... ON DUPLICATE KEY UPDATE is used to insert data into the database table; if the data already exists, update the data; otherwise, insert new data.

    The INSERT INTO statement is a standard statement used to insert data into a database table; the ON DUPLICATE KEY UPDATE statement performs an update operation when there are duplicate records in the table. If a record with the same unique index or primary key exists in the table, use the UPDATE clause to update the corresponding column value; otherwise, use the INSERT clause to insert a new record.

    It should be noted that the premise of using this syntax is that a primary key constraint needs to be established in the table to determine whether there are duplicate records. At the same time, both the update operation and the insert operation need to set the corresponding column value. Otherwise, a syntax error will result.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/#syntax","title":"Syntax","text":"
    > INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n  [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...];\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/#examples","title":"Examples","text":"
    CREATE TABLE user (\nid INT(11) NOT NULL PRIMARY KEY,\nname VARCHAR(50) NOT NULL,\nage INT(3) NOT NULL\n);\n-- Insert a new data; it does not exist, insert the new data\nINSERT INTO user (id, name, age) VALUES (1, 'Tom', 18)\nON DUPLICATE KEY UPDATE name='Tom', age=18;\n\nmysql> select * from user;\n+------+------+------+\n| id   | name | age  |\n+------+------+------+\n|    1 | Tom  |   18 |\n+------+------+------+\n1 row in set (0.01 sec)\n\n-- Increment the age field of an existing record by 1 while keeping the name field unchanged\nINSERT INTO user (id, name, age) VALUES (1, 'Tom', 18)\nON DUPLICATE KEY UPDATE age=age+1;\n\nmysql> select * from user;\n+------+------+------+\n| id   | name | age  |\n+------+------+------+\n|    1 | Tom  |   19 |\n+------+------+------+\n1 row in set (0.00 sec)\n\n-- Insert a new record, and update the name and age fields to the specified values\nINSERT INTO user (id, name, age) VALUES (2, 'Lucy', 20)\nON DUPLICATE KEY UPDATE name='Lucy', age=20;\n\nmysql> select * from user;\n+------+------+------+\n| id   | name | age  |\n+------+------+------+\n|    1 | Tom  |   19 |\n|    2 | Lucy |   20 |\n+------+------+------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/#constraints","title":"Constraints","text":"

    Unique key are not currently supported with INSERT ... ON DUPLICATE KEY UPDATE, and since unique key can be null, some unknown errors can occur.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/","title":"INSERT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#description","title":"Description","text":"

    Writing data.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#syntax","title":"Syntax","text":"
    > INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(a int default (1+12), b int);\ninsert into t1(b) values(1), (1);\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|   13 |    1 |\n|   13 |    1 |\n+------+------+\n2 rows in set (0.01 sec)\n\ndrop table if exists t1;\ncreate table t1 (a date);\ninsert into t1 values(DATE(\"2017-06-15 09:34:21\")),(DATE(\"2019-06-25 10:12:21\")),(DATE(\"2019-06-25 18:20:49\"));\n\nmysql> select * from t1;\n+------------+\n| a          |\n+------------+\n| 2017-06-15 |\n| 2019-06-25 |\n| 2019-06-25 |\n+------------+\n3 rows in set (0.00 sec)\n\ndrop table if exists t;\nCREATE TABLE t (i1 INT, d1 DOUBLE, e2 DECIMAL(5,2));\nINSERT INTO t VALUES ( 6, 6.0, 10.0/3), ( null, 9.0, 10.0/3), ( 1, null, 10.0/3), ( 2, 2.0, null );\n\nmysql> select * from t;\n+------+------+------+\n| i1   | d1   | e2   |\n+------+------+------+\n|    6 |    6 | 3.33 |\n| NULL |    9 | 3.33 |\n|    1 | NULL | 3.33 |\n|    2 |    2 | NULL |\n+------+------+------+\n4 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/","title":"LOAD DATA","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#description","title":"Description","text":"

    The LOAD DATA statement reads rows from a text file into a table at a very high speed. The file can be read from the server host or a S3 compatible object storage. LOAD DATA is the complement of SELECT ... INTO OUTFILE. To write data from a table to a file, use SELECT ... INTO OUTFILE. To read the file back into a table, use LOAD DATA. The syntax of the FIELDS and LINES clauses is the same for both statements.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#syntax","title":"Syntax","text":"
    > LOAD DATA [LOCAL]\n    INFILE 'file_name'\n    INTO TABLE tbl_name\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY 'string']\n        [[OPTIONALLY] ENCLOSED BY 'char']\n    ]\n    [LINES\n        [STARTING BY 'string']\n        [TERMINATED BY 'string']\n    ]\n    [IGNORE number {LINES | ROWS}]\n    [SET column_name_1=nullif(column_name_1, expr1), column_name_2=nullif(column_name_2, expr2)...]\n    [PARALLEL {'TRUE' | 'FALSE'}]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#input-file-location","title":"Input File Location","text":"
    • LOAD DATA INFILE 'file_name': Indicates that the data file to be loaded is on the same machine as the MatrixOne host server. file_name can be the relative path name of the storage location of the file, or it can be the absolute path name.

    • LOAD DATA LOCAL INFILE 'file_name': indicates that the data file to be loaded is not on the same machine as the MatrixOne host server; that is, the data file is on the client server. file_name can be the relative path name of the storage location of the file, or it can be the absolute path name.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#ignore-lines","title":"IGNORE LINES","text":"

    The IGNORE number LINES clause can be used to ignore lines at the start of the file. For example, you can use IGNORE 1 LINES to skip an initial header line containing column names:

    LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1 IGNORE 1 LINES;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#field-and-line-handling","title":"Field and Line Handling","text":"

    For both the LOAD DATA and SELECT ... INTO OUTFILE statements, the syntax of the FIELDS and LINES clauses is the same. Both clauses are optional, but FIELDS must precede LINES if both are specified.

    If you specify a FIELDS clause, each of its subclauses (TERMINATED BY, [OPTIONALLY] ENCLOSED BY) is also optional, except that you must specify at least one of them. Arguments to these clauses are permitted to contain only ASCII characters.

    If you specify no FIELDS or LINES clause, the defaults are the same as if you had written this:

    FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n'\n

    Note

    • FIELDS TERMINATED BY ',': with and only ,, | or \\t as delimiters.
    • ENCLOSED BY '\"': with and only \" as the included character.
    • LINES TERMINATED BY '\\n': Use and only use \\n or \\r\\n as the line separator.

    FIELDS TERMINATED BY

    FIELDS TERMINATED BY specifies the delimiter for a field. The FIELDS TERMINATED BY values can be more than one character.

    For example, to read the comma-delimited file, the correct statement is:

    LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',';\n

    If instead you tried to read the file with the statement shown following, it would not work because it instructs LOAD DATA to look for tabs between fields:

    LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY '\\t';\n

    The likely result is that each input line would be interpreted as a single field. You may encounter an error of \"ERROR 20101 (HY000): internal error: the table column is larger than input data column\".

    FIELDS ENCLOSED BY

    FIELDS TERMINATED BY option specifies the character enclose the input values. ENCLOSED BY value must be a single character. If the input values are not necessarily enclosed within quotation marks, use OPTIONALLY before the ENCLOSED BY option.

    For example, if some input values are enclosed within quotation marks, some are not:

    LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"';\n

    LINES TERMINATED BY

    LINES TERMINATED BY specifies the delimiter for the a line. The LINES TERMINATED BY values can be more than one character.

    For example, if the lines in a csv file are terminated by carriage return/newline pairs, you can load it with LINES TERMINATED BY '\\r\\n':

    LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n  LINES TERMINATED BY '\\r\\n';\n

    LINE STARTING BY

    If all the input lines have a common prefix that you want to ignore, you can use LINES STARTING BY 'prefix_string' to skip the prefix and anything before it. If a line does not include the prefix, the entire line is skipped. Suppose that you issue the following statement:

    LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ','  LINES STARTING BY 'xxx';\n

    If the data file looks like this:

    xxx\"abc\",1\nsomething xxx\"def\",2\n\"ghi\",3\n

    The resulting rows are (\"abc\",1) and (\"def\",2). The third row in the file is skipped because it does not contain the prefix.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#set","title":"SET","text":"

    MatrixOne only supports SET column_name=nullif(column_name,expr). That is, when column_name = expr, it returns NULL; otherwise, it returns the original value of column_name. For example, SET a=nullif(a,1), if a=1, returns NULL; otherwise, it returns the original value of column a.

    By setting the parameter, you can use SET column_name=nullif(column_name,\"null\") to return the NULL value in the column when loading the file.

    Example

    1. The details of the local file test.txt are as follows:

      id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\nnull,wederTom,\"man\"\n
    2. Create a table named user in MatrixOne:

      create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\n
    3. Load test.txt into the table user:

      LOAD DATA INFILE '/tmp/test.txt' INTO TABLE user SET id=nullif(id,\"null\");\n
    4. The result of the talbe is as below:

      select * from user;\n+------+-----------+------+\n| id   | user_name | sex  |\n+------+-----------+------+\n|    1 | weder     | man  |\n|    2 | tom       | man  |\n| null | wederTom  | man  |\n+------+-----------+------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#parallel","title":"PARALLEL","text":"

    For a sizeable well-formed file, such as a JSOLLines file or a CSV file with no line breaks in a line of data, you can use PARALLEL to load the file in parallel to speed up the loading.

    For example, for a large file of 2 G, use two threads to load; the second thread first splits and locates the 1G position, then reads and loads backward. In this way, two threads can read large files at the same time, and each thread can read 1G of data.

    Enable/Disable Parallel Loading Command Line Example:

    --  Enable Parallel Loading\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'TRUE';\n\n--  Disable Parallel Loading\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'FALSE';\n\n--  Parallel loading is disabled by default\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES;\n

    Note

    [PARALLEL {'TRUE' | 'FALSE'}] currently only support TRUE or FALSE and are not case-sensitive.

    Note: If the PARALLEL field is not added in the LOAD statement, for CSV files, parallel loading is disabled by default; for JSOLLines files, parallel loading is enabled by default. If there is a line terminator in the CSV file, such as '\\n', otherwise it may cause data errors when the file is loaded. If the file is too large, manually splitting the file from the '\\n' as the starting and ending point is recommended, then enabling parallel loading.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#supported-file-formats","title":"Supported file formats","text":"

    In MatrixOne's current release, LOAD DATA supports CSV(comma-separated values) format and JSONLines format file. See full tutorials for loading csv and jsonline.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#csv-format-standard-description","title":"CSV format standard description","text":"

    The CSV format loaded by MatrixOne conforms to the RFC4180 standard, and the CSV format is specified as follows:

    1. Each record is on a separate line, separated by a newline character (CRLF):

      aaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

    2. The last record in the file can have a terminating newline or no terminating newline (CRLF):

      aaa,bbb,ccc CRLF\nzzz,yyy,xxx\n

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

    3. An optional header line appears as the first line of the file and has the same format as a standard record line. For example:

      field_name,field_name,field_name CRLF\naaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n

      Imported into the table as follows:

      +------------+------------+------------+ | field_name | field_name | field_name | +------------+------------+------------+ | aaa | bbb | ccc | | zzz | yyy | xxx | +------------+------------+------------+

    4. In the header and each record, there may be one or more fields separated by commas. Whitespace within a field is part of the field and should not be ignored. A comma cannot follow the last field in each record. For example:

      aaa,bbb,ccc\n

      Or:

      a aa, bbb,cc c\n

      Both examples are correct.

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | bbb | ccc | +---------+---------+---------+

      Or:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | a aa | bbb | cc c | +---------+---------+---------+

    5. Each field can be enclosed in double quotes or not. Double quotes cannot appear inside a field if the field is not enclosed in double-quotes. For example:

      \"aaa\",\"bbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n

      Or:

      \"aaa\",\"bbb\",ccc CRLF\nzzz,yyy,xxx\n

      Both examples are correct.

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | bbb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

    6. Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes. For example:

      \"aaa\",\"b CRLF\nbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

    7. If double quotation marks are used to enclose the field, then multiple double quotation marks appearing in the field must also be enclosed in double quotation marks; otherwise, the first quotation mark of two double quotation marks in the field will be parsed as an escape character, thus keep a single, double quote. For example:

      \"aaa\",\"b\",\"bb\",\"ccc\"\n

      The above CSV will parse \"b\"\"bb\" into b\"bb; if the correct field is b\"\"bb, then it should be written as:

      \"aaa\",\"b\"\"\"\"bb\",\"ccc\"\n

      Or:

      \"aaa\",b\"\"bb,\"ccc\"\n

      Imported into the table as follows:

      +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b\"\"bb | ccc | +---------+---------+---------+

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#examples","title":"Examples","text":"

    The SSB Test is an example of LOAD DATA syntax. Complete a SSB Test with MatrixOne

    > LOAD DATA INFILE '/ssb-dbgen-path/lineorder_flat.tbl ' INTO TABLE lineorder_flat;\n

    The above statement means: load the lineorder_flat.tbl data set under the directory path /ssb-dbgen-path/ into the MatrixOne data table lineorder_flat.

    You can also refer to the following syntax examples to quickly understand LOAD DATA:

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#example-1-load-csv","title":"Example 1: LOAD CSV","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#simple-example","title":"Simple example","text":"

    The data in the file locally named char_varchar.csv is as follows:

    a|b|c|d\n\"a\"|\"b\"|\"c\"|\"d\"\n'a'|'b'|'c'|'d'\n\"'a'\"|\"'b'\"|\"'c'\"|\"'d'\"\n\"aa|aa\"|\"bb|bb\"|\"cc|cc\"|\"dd|dd\"\n\"aa|\"|\"bb|\"|\"cc|\"|\"dd|\"\n\"aa|||aa\"|\"bb|||bb\"|\"cc|||cc\"|\"dd|||dd\"\n\"aa'|'||aa\"|\"bb'|'||bb\"|\"cc'|'||cc\"|\"dd'|'||dd\"\naa\"aa|bb\"bb|cc\"cc|dd\"dd\n\"aa\"aa\"|\"bb\"bb\"|\"cc\"cc\"|\"dd\"dd\"\n\"aa\"\"aa\"|\"bb\"\"bb\"|\"cc\"\"cc\"|\"dd\"\"dd\"\n\"aa\"\"\"aa\"|\"bb\"\"\"bb\"|\"cc\"\"\"cc\"|\"dd\"\"\"dd\"\n\"aa\"\"\"\"aa\"|\"bb\"\"\"\"bb\"|\"cc\"\"\"\"cc\"|\"dd\"\"\"\"dd\"\n\"aa\"\"|aa\"|\"bb\"\"|bb\"|\"cc\"\"|cc\"|\"dd\"\"|dd\"\n\"aa\"\"\"\"|aa\"|\"bb\"\"\"\"|bb\"|\"cc\"\"\"\"|cc\"|\"dd\"\"\"\"|dd\"\n|||\n||||\n\"\"|\"\"|\"\"|\n\"\"\"\"|\"\"\"\"|\"\"\"\"|\"\"\"\"\n\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"\n

    Create a table named t1 in MatrixOne:

    mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(\n-> col1 char(225),\n-> col2 varchar(225),\n-> col3 text,\n-> col4 varchar(225)\n-> );\nQuery OK, 0 rows affected (0.02 sec)\n

    Load the data file into table t1:

    load data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|';\n

    The query result is as follows:

    mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa|aa     | bb|bb     | cc|cc     | dd|dd     |\n| aa|       | bb|       | cc|       | dd|       |\n| aa|||aa   | bb|||bb   | cc|||cc   | dd|||dd   |\n| aa'|'||aa | bb'|'||bb | cc'|'||cc | dd'|'||dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"|aa    | bb\"|bb    | cc\"|cc    | dd\"|dd    |\n| aa\"\"|aa   | bb\"\"|bb   | cc\"\"|cc   | dd\"\"|dd   |\n|           |           |           |           |\n|           |           |           |           |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n20 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#add-conditional-example","title":"Add conditional Example","text":"

    Following the example above, you can modify the LOAD DATA statement and add LINES STARTING BY 'aa' ignore 10 lines; at the end of the statement to experience the difference:

    delete from t1;\nload data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|' LINES STARTING BY 'aa' ignore 10 lines;\n

    The query result is as follows:

    mysql> select * from t1;\n+---------+---------+---------+---------+\n| col1    | col2    | col3    | col4    |\n+---------+---------+---------+---------+\n| aa\"aa   | bb\"bb   | cc\"cc   | dd\"dd   |\n| aa\"\"aa  | bb\"\"bb  | cc\"\"cc  | dd\"\"dd  |\n| aa\"\"aa  | bb\"\"bb  | cc\"\"cc  | dd\"\"dd  |\n| aa\"|aa  | bb\"|bb  | cc\"|cc  | dd\"|dd  |\n| aa\"\"|aa | bb\"\"|bb | cc\"\"|cc | dd\"\"|dd |\n|         |         |         |         |\n|         |         |         |         |\n|         |         |         |         |\n| \"       | \"       | \"       | \"       |\n| \"\"      | \"\"      | \"\"      | \"\"      |\n+---------+---------+---------+---------+\n10 rows in set (0.00 sec)\n

    As you can see, the query result ignores the first line and and ignores the common prefix aa.

    For more information on loding csv, see Import the .csv data.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#example-2-load-jsonlines","title":"Example 2: LOAD JSONLines","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#simple-example_1","title":"Simple example","text":"

    The data in the file locally named jsonline_array.jl is as follows:

    [true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11,[\"1\",2,null,false,true,{\"q\":1}],\"1qaz\",null,null]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\",{\"c\":1,\"b\":[\"a\",\"b\",{\"q\":4}]},\"1aza\",null,null]\n

    Create a table named t1 in MatrixOne:

    mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(col1 bool,col2 int,col3 varchar(100), col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float,col9 json,col10 text,col11 json,col12 bool);\nQuery OK, 0 rows affected (0.03 sec)\n

    Load the data file into table t1:

    load data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1;\n

    The query result is as follows:

    mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4       | col5                | col6                | col7 | col8   | col9                                  | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | [\"1\", 2, null, false, true, {\"q\": 1}] | 1qaz  | NULL  | NULL  |\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1}   | 1aza  | NULL  | NULL  |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#add-conditional-example_1","title":"Add conditional Example","text":"

    Following the example above, you can modify the LOAD DATA statement and add ignore 1 lines at the end of the statement to experience the difference:

    delete from t1;\nload data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1 ignore 1 lines;\n

    The query result is as follows:

    mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4       | col5                | col6                | col7 | col8   | col9                                | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1} | 1aza  | NULL  | NULL  |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n1 row in set (0.00 sec)\n

    As you can see, the query result ignores the first line.

    For more information on loding JSONLines, see Import the JSONLines data.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#constraints","title":"Constraints","text":"
    1. The REPLACE and IGNORE modifiers control handling of new (input) rows that duplicate existing table rows on unique key values (PRIMARY KEY or UNIQUE index values) are not supported in MatrixOne yet.
    2. Input pre-pressing with SET is supported very limitedly. Only SET columns_name=nullif(expr1,expr2) is supported.
    3. When enabling the parallel loading, it must be ensured that each row of data in the file does not contain the specified line terminator, such as '\\n'; otherwise, it will cause data errors during file loading.
    4. The parallel loading of files requires that the files be in uncompressed format, and parallel loading of files in compressed form is not currently supported.
    5. When you use load data local, you need to use the command line to connect to the MatrixOne service host: mysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile.
    6. MatrixOne does not support ESCAPED BY currently. Writing or reading special characters differs from MySQL to some extent.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/","title":"REPLACE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#description","title":"Description","text":"

    REPLACE is a string function and a data manipulation statement for a replacement operation. The REPLACE statement functions to insert data into the table. If there is already a qualified record in the table, the record will be deleted first, and then new data will be inserted. New data will be inserted directly if there is no matching record in the table.

    REPLACE is typically used on tables with unique constraints.

    • The REPLACE statement requires that a primary key or unique index exist in the table to determine whether the same record exists.
    • When using the REPLACE statement to insert a new record, the old record will be deleted if a record with the same primary key or unique index already exists. Then a new record will be inserted, which may cause the value of the auto-increment column to change.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#syntax","title":"Syntax","text":"
    REPLACE\n    [INTO] tbl_name\n    [(col_name [, col_name] ...)]\n    { VALUES(value_list)\n      |\n      VALUES row_constructor_list\n    }\n\nREPLACE\n    [INTO] tbl_name\n    SET assignment_list\n\nvalue:\n    {expr | DEFAULT}\n\nvalue_list:\n    value [, value] ...\n\nrow_constructor_list:\n    ROW(value_list)\n\nassignment:\n    col_name = value\n\nassignment_list:\n    assignment [, assignment] ...\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#explanations","title":"Explanations","text":"

    The REPLACE statement inserts data into a table or updates existing data. Its syntax has two forms: an insert form based on column names and an update form based on the SET clause.

    The following is an explanation of each parameter:

    1. INTO: optional keyword indicating which table to insert or update data.

    2. tbl_name: Indicates the table's name to insert or update data.

    3. col_name: Optional parameter indicating the column's name to be inserted or updated. In the insert form, the column to be inserted can be specified by column name; in the update form, the column to be updated can be specified.

    4. value: Indicates the value to be inserted or updated. It can be a concrete expression (expr) or a default value (DEFAULT).

    5. value_list: Indicates a set of values \u200b\u200bto be inserted. Separate multiple values \u200b\u200bwith commas.

    6. (Not supported yet) row_constructor_list: Indicates a row consisting of a set of values \u200b\u200bfor insertion. Values \u200b\u200bon each row are enclosed in parentheses and separated by commas.

    7. assignment: Indicates the association between a column name and its corresponding value, which is used to update the form.

    8. assignment_list: Indicates the association of multiple column names and corresponding values, which is used to update the form\u2014separate multiple column names and values \u200b\u200bwith commas.

    Note

    • When using the insert form, you can use the VALUES keyword followed by value_list means inserting one row of data.
    • When using the update form, use the SET keyword followed by assignment_list to specify the columns to update and the corresponding values.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#examples","title":"Examples","text":"
    create table names(id int PRIMARY KEY,name VARCHAR(255),age int);\n\n-- Insert a row of data, id=1, name=\"Abby\", age=24\nreplace into names(id, name, age) values(1,\"Abby\", 24);\nmysql> select name, age from names where id = 1;\n+------+------+\n| name | age  |\n+------+------+\n| Abby |   24 |\n+------+------+\n1 row in set (0.00 sec)\n\nmysql> select * from names;\n+------+------+------+\n| id   | name | age  |\n+------+------+------+\n|    1 | Abby |   24 |\n+------+------+------+\n1 row in set (0.00 sec)\n\n-- Use the replace statement to update the record with id=1 to have the values \u200b\u200b\"Bob\" and 25 in the name and age columns\nreplace into names(id, name, age) values(1,\"Bobby\", 25);\n\nmysql> select name, age from names where id = 1;\n+-------+------+\n| name  | age  |\n+-------+------+\n| Bobby |   25 |\n+-------+------+\n1 row in set (0.00 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id   | name  | age  |\n+------+-------+------+\n|    1 | Bobby |   25 |\n+------+-------+------+\n1 row in set (0.01 sec)\n\n-- Use the replace statement to insert a row of data, id=2, name=\"Ciro\", age is NULL\nreplace into names set id = 2, name = \"Ciro\";\n\nmysql> select name, age from names where id = 2;\n+------+------+\n| name | age  |\n+------+------+\n| Ciro | NULL |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id   | name  | age  |\n+------+-------+------+\n|    1 | Bobby |   25 |\n|    2 | Ciro  | NULL |\n+------+-------+------+\n2 rows in set (0.00 sec)\n\n-- Use the replace statement to update the record with id=2 to have the value of the name column \"Ciro\" and the value of the age column 17\nreplace into names set id = 2, name = \"Ciro\", age = 17;\n\nmysql> select name, age from names where id = 2;\n+------+------+\n| name | age  |\n+------+------+\n| Ciro |   17 |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id   | name  | age  |\n+------+-------+------+\n|    1 | Bobby |   25 |\n|    2 | Ciro  |   17 |\n+------+-------+------+\n2 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#constraints","title":"Constraints","text":"

    MatrixOne does not currently support rows of values \u200b\u200binserted using the VALUES row_constructor_list parameter.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/","title":"UPDATE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#description","title":"Description","text":"

    The UPDATE statement is used to modify the existing records in a table.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#single-table-syntax","title":"Single-table Syntax","text":"
    UPDATE table_reference\n    SET assignment_list\n    [WHERE where_condition]\n    [ORDER BY ...]\n    [LIMIT row_count]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#explanations","title":"Explanations","text":"
    • The UPDATE statement updates columns of existing rows in the named table with new values.
    • The SET clause indicates which columns to modify and the values they should be given. Each value can be given as an expression, or the keyword DEFAULT to set a column explicitly to its default value.
    • The WHERE clause, if given, specifies the conditions that identify which rows to update. With no WHERE clause, all rows are updated.
    • If the ORDER BY clause is specified, the rows are updated in the order that is specified.
    • The LIMIT clause places a limit on the number of rows that can be updated.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#examples","title":"Examples","text":"
    • Single-table Examples
    CREATE TABLE t1 (a bigint(3), b bigint(5) primary key);\ninsert INTO t1 VALUES (1,1),(1,2);\nupdate t1 set a=2 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 |    1 |\n|    1 |    2 |\n+------+------+\n
    • Multiple-table Examples
    drop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values(1), (2), (4);\ndrop table if exists t2;\ncreate table t2 (b int);\ninsert into t2 values(1), (2), (3);\nupdate t1, t2 set a = 1, b =2;\n\nmysql> select * from t1;\n+------+\n| a    |\n+------+\n|    1 |\n|    1 |\n|    1 |\n+------+\n\nupdate t1, t2 set a = null, b =null;\n\nmysql> select * from t2;\n+------+\n| b    |\n+------+\n| NULL |\n| NULL |\n| NULL |\n+------+\nmysql> select * from t1;\n+------+\n| a    |\n+------+\n| NULL |\n| NULL |\n| NULL |\n+------+\n

    Multiple-table join Syntax is also supported.

    drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a int, b int, c int);\ninsert into t1 values(1, 2, 3), (4, 5, 6), (7, 8, 9);\ncreate table t2 (a int, b int, c int);\ninsert into t2 values(1, 2, 3), (4, 5, 6), (7, 8, 9);\nupdate t1 join t2 on t1.a = t2.a set t1.b = 222, t1.c = 333, t2.b = 222, t2.c = 333;\n\nmysql> select * from t1;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 |  222 |  333 |\n|    4 |  222 |  333 |\n|    7 |  222 |  333 |\n+------+------+------+\n\nmysql> with t11 as (select * from (select * from t1) as t22) update t11 join t2 on t11.a = t2.a set t2.b = 666;\n\nmysql> select * from t2;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 |  666 |  333 |\n|    4 |  666 |  333 |\n|    7 |  666 |  333 |\n+------+------+------+\n3 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/","title":"CURRENT_ROLE()","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/#description","title":"Description","text":"

    Returns the role of the current session.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/#syntax","title":"Syntax","text":"
    SELECT CURRENT_ROLE();\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/#examples","title":"Examples","text":"
    mysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin        |\n+----------------+\n1 row in set (0.00 sec)\n\n-- Create a role and switch to the new role\ncreate role use_role_1;\ngrant all on database * to use_role_1;\ngrant use_role_1 to root;\nset role use_role_1;\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| use_role_1     |\n+----------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/","title":"LAST_INSERT_ID()","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#description","title":"Description","text":"

    The LAST_INSERT_ID() function returns the AUTO_INCREMENT id of the last row that has been inserted or updated in a table.

    When the argument is NULL, LAST_INSERT_ID() returns a value representing the first automatically generated value successfully inserted for an AUTO_INCREMENT column as a result of the most recently executed INSERT statement; if you haven't inserted a column before, then the return value start at 1, and if you've inserted a column before, then the return value of the AUTO_INCREMENT column increases by 1.

    The value of LAST_INSERT_ID() remains unchanged if no rows are successfully inserted.

    In MySQL, if you insert multiple rows using a single INSERT statement, LAST_INSERT_ID() returns the value generated for the first inserted row only. For example:

    mysql> CREATE TABLE t (id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, name VARCHAR(10) NOT NULL);\nmysql> INSERT INTO t VALUES (NULL, 'Bob');\nmysql> SELECT * FROM t;\n+----+------+\n| id | name |\n+----+------+\n|  1 | Bob  |\n+----+------+\n\nmysql> SELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|                1 |\n+------------------+\n\nmysql> INSERT INTO t VALUES (NULL, 'Mary'), (NULL, 'Jane'), (NULL, 'Lisa');\n\nmysql> SELECT * FROM t;\n+----+------+\n| id | name |\n+----+------+\n|  1 | Bob  |\n|  2 | Mary |\n|  3 | Jane |\n|  4 | Lisa |\n+----+------+\n\nmysql> SELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|                2 |\n+------------------+\n

    But in MatrixOne, we have a different behavior; if you insert multiple rows using a single INSERT statement, LAST_INSERT_ID() returns the value generated for the last inserted row. Like the example above, when you execute INSERT INTO t VALUES (NULL, 'Mary'), (NULL, 'Jane'), (NULL, 'Lisa');, the LAST_INSERT_ID() will return 4.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#syntax","title":"Syntax","text":"
    LAST_INSERT_ID(), LAST_INSERT_ID(expr)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#examples","title":"Examples","text":"
    create table t1(a int auto_increment primary key);\ninsert into t1 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|                1 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t1 values(11);\ninsert into t1 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|               12 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t1 values(null);\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|               13 |\n+------------------+\n1 row in set (0.02 sec)\n\ncreate table t2(a int auto_increment primary key);\ninsert into t2 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|                1 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t2 values(100);\ninsert into t2 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|              101 |\n+------------------+\n1 row in set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/","title":"LAST_QUERY_ID","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#description","title":"Description","text":"

    Returns the ID of a specified query in the current session. If no query is specified, the most recently-executed query is returned.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#syntax","title":"Syntax","text":"
    LAST_QUERY_ID( [ <num> ] )\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#arguments","title":"Arguments","text":"

    num: Specifies the query to return, based on the position of the query (within the session).

    Default: -1

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#usage-notes","title":"Usage Notes","text":"

    Positive numbers start with the first query executed in the session. For example:

    • LAST_QUERY_ID(1) returns the first query.

    • LAST_QUERY_ID(2) returns the second query.

    • LAST_QUERY_ID(6) returns the sixth query.

    Negative numbers start with the most recently-executed query in the session. For example:

    • LAST_QUERY_ID(-1) returns the most recently-executed query (equivalent to LAST_QUERY_ID()).

    • LAST_QUERY_ID(-2) returns the second most recently-executed query.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#examples","title":"Examples","text":"
    mysql> SELECT LAST_QUERY_ID(-1);\n+--------------------------------------+\n| last_query_id(-1)                    |\n+--------------------------------------+\n| af974680-b1b5-11ed-8eb9-5ad2460dea4f |\n+--------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT LAST_QUERY_ID();\n+--------------------------------------+\n| last_query_id()                      |\n+--------------------------------------+\n| 550e4d44-b1b5-11ed-8eb9-5ad2460dea4f |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/","title":"INTERSECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/#description","title":"Description","text":"

    INTERSECT returns only the different rows of two or more queries.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/#syntax","title":"Syntax","text":"
    SELECT column_list FROM table_1\nINTERSECT\nSELECT column_list FROM table_2;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/#examples","title":"Examples","text":"
    drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a smallint, b bigint, c int);\ninsert into t1 values (1,2,3);\ninsert into t1 values (1,2,3);\ninsert into t1 values (3,4,5);\ninsert into t1 values (4,5,6);\ninsert into t1 values (4,5,6);\ninsert into t1 values (1,1,2);\ncreate table t2 (a smallint, b bigint, c int);\ninsert into t2 values (1,2,3);\ninsert into t2 values (3,4,5);\ninsert into t2 values (1,2,1);\n\nmysql> select * from t1 intersect select * from t2;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 |    2 |    3 |\n|    3 |    4 |    5 |\n+------+------+------+\n2 rows in set (0.01 sec)\n\nmysql> select a, b from t1 intersect select b, c from t2;\n+------+------+\n| a    | b    |\n+------+------+\n|    4 |    5 |\n+------+------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/","title":"MINUS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#description","title":"Description","text":"

    MINUS compares the result of two queries and returns the different rows in the first query that are not output by the second query.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#syntax","title":"Syntax","text":"
    SELECT column_list_1 FROM table_1\nMINUS\nSELECT columns_list_2 FROM table_2;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#examples","title":"Examples","text":"
    • Example 1
    CREATE TABLE t1 (id INT PRIMARY KEY);\nCREATE TABLE t2 (id INT PRIMARY KEY);\nINSERT INTO t1 VALUES (1),(2),(3);\nINSERT INTO t2 VALUES (2),(3),(4);\n\nmysql> SELECT id FROM t1 MINUS SELECT id FROM t2;\n+------+\n| id   |\n+------+\n|    1 |\n+------+\n
    • Example 2
    drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a smallint, b bigint, c int);\ninsert into t1 values (1,2,3);\ninsert into t1 values (1,2,3);\ninsert into t1 values (3,4,5);\ninsert into t1 values (4,5,6);\ninsert into t1 values (4,5,6);\ninsert into t1 values (1,1,2);\ncreate table t2 (a smallint, b bigint, c int);\ninsert into t2 values (1,2,3);\ninsert into t2 values (3,4,5);\ninsert into t2 values (1,2,1);\n\nmysql> select * from t1 minus select * from t2;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 |    1 |    2 |\n|    4 |    5 |    6 |\n+------+------+------+\n\nmysql> select a, b from t1 minus select b, c from t2;\n+------+------+\n| a    | b    |\n+------+------+\n|    3 |    4 |\n|    1 |    1 |\n|    1 |    2 |\n+------+------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/","title":"SELECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#description","title":"Description","text":"

    Retrieves data from a table.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#syntax","title":"Syntax","text":"
    SELECT\n[ALL | DISTINCT ]\nselect_expr [, select_expr] [[AS] alias] ...\n[INTO variable [, ...]]\n[FROM table_references\n[WHERE where_condition]\n[GROUP BY {col_name | expr | position}\n[ASC | DESC]]\n[HAVING where_condition]\n[ORDER BY {col_name | expr | position}\n[ASC | DESC]] [ NULLS { FIRST | LAST } ]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}]\n[FOR {UPDATE}]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#explanations","title":"Explanations","text":"

    The most commonly used clauses of SELECT statements are these:

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#select_expr","title":"select_expr","text":"

    Each select_expr indicates a column that you want to retrieve. There must be at least one select_expr.

    The list of select_expr terms comprises the select list that indicates which columns to retrieve. Terms specify a column or expression or can use *-shorthand:

    • A select list consisting only of a single unqualified * can be used as shorthand to select all columns from all tables:
    SELECT * FROM t1\n
    • tbl_name.* can be used as a qualified shorthand to select all columns from the named table:
    SELECT t1.*, t2.* FROM t1\n
    • A select_expr can be given an alias using AS alias_name.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#table_references","title":"table_references","text":"
    • The FROM table_references clause indicates the table or tables from which to retrieve rows.

    • You can refer to a table within the default database as tbl_name, or as db_name.tbl_name to specify a database explicitly. You can refer to a column as col_name, tbl_name.col_name, or db_name.tbl_name.col_name. You need not specify a tbl_name or db_name.tbl_name prefix for a column reference unless the reference would be ambiguous.

    • A table reference can be aliased using tbl_name AS alias_name or tbl_name alias_name.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#where","title":"WHERE","text":"

    The WHERE clause, if given, indicates the condition or conditions that rows must satisfy to be selected. where_condition is an expression that evaluates to true for each row to be selected. The statement selects all rows if there is no WHERE clause.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#group-by","title":"GROUP BY","text":"

    Columns selected for output can be referred to in ORDER BY and GROUP BY clauses using column names, column aliases, or column positions.

    Note

    • In the GROUP BY or HAVING clauses, it is not allowed to use an alias to define another alias.
    • In the GROUP BY or HAVING clauses, the SQL engine first attempts to group or filter by column names. If the corresponding column names are not found in these clauses, it checks if aliases match and use the matched aliases as a fallback.
    • It is recommended to avoid ambiguous column references when using aliases in the GROUP BY or HAVING clauses. In such cases, the SQL engine looks for matching columns based on the aliases, and if multiple matches are found, it will raise an error.
    • In the ORDER BY clause, sorting is first attempted using aliases. If aliases are not found, the SQL engine attempts sorting using column names.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#having","title":"HAVING","text":"

    The HAVING clause, like the WHERE clause, specifies selection conditions.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#order-by","title":"ORDER BY","text":"

    To sort in reverse order, add the DESC (descending) keyword to the name of the column in the ORDER BY clause that you are sorting by. The default is ascending order; this can be specified explicitly using the ASC keyword.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#limit","title":"LIMIT","text":"

    The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#for-update","title":"FOR UPDATE","text":"

    SELECT...FOR UPDATE is mainly used to lock a set of data rows in transaction processing to prevent them from being modified by other concurrent transactions. This statement is most commonly used in \"read-modify-write\" scenarios. That is, when you need to read a data set, make changes to it, and then write the results back to the database, you don't want other transactions to modify this data set.

    Using SELECT FOR UPDATE in a transaction can lock the selected rows until the transaction ends (either by commit or rollback) and the locks are released. This way, other transactions attempting to modify these rows are blocked until the first transaction is complete.

    See the example below:

    START TRANSACTION;\n\nSELECT * FROM Orders\nWHERE OrderID = 1\nFOR UPDATE;\n

    In the above transaction, the SELECT FOR UPDATE statement selects and locks the row with OrderID 1 in the Orders table. Other transactions cannot modify this row before the transaction ends. After you have finished modifying this row, you can commit the transaction to release the lock:

    UPDATE Orders\nSET Quantity = Quantity - 1\nWHERE OrderID = 1;\n\nCOMMIT;\n

    The above UPDATE statement modifies the Quantity value of the selected row, and then the COMMIT statement commits the transaction and releases the lock. At this point, other blocked transactions can continue. If you decide not to make any changes, you can use the ROLLBACK statement to end the transaction and release the lock.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#examples","title":"Examples","text":"
    create table t1 (spID int,userID int,score smallint);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\ninsert into t1 values (null,0,99);\n\nmysql> SELECT * FROM t1 WHERE spID>2 AND userID <2 || userID >=2 OR userID < 2 LIMIT 3;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| NULL |      0 |    99 |\n|    1 |      1 |     1 |\n|    2 |      2 |     2 |\n+------+--------+-------+\n\nmysql> SELECT userID,MAX(score) max_score FROM t1 WHERE userID <2 || userID > 3 GROUP BY userID ORDER BY max_score;\n+--------+-----------+\n| userid | max_score |\n+--------+-----------+\n|      1 |         5 |\n|      6 |        10 |\n|      0 |        99 |\n|     11 |        99 |\n+--------+-----------+\n\nmysql> select userID,count(score) from t1 group by userID having count(score)>1 order by userID;\n+--------+--------------+\n| userid | count(score) |\n+--------+--------------+\n|      1 |            3 |\n+--------+--------------+\n\nmysql> select userID,count(score) from t1 where userID>2 group by userID having count(score)>1 order by userID;\nEmpty set (0.01 sec)s\n\nmysql> select * from t1 order by spID asc nulls last;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n|    1 |      1 |     1 |\n|    1 |      1 |     5 |\n|    2 |      2 |     2 |\n|    2 |      1 |     4 |\n|    3 |      3 |     3 |\n|    4 |      6 |    10 |\n|    5 |     11 |    99 |\n| NULL |      0 |    99 |\n+------+--------+-------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#constraints","title":"Constraints","text":"
    1. SELECT...FOR UPDATE currently only supports single-table queries.
    2. INTO OUTFILE is limitedly support.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/","title":"Combining Queries (UNION,\u00a0INTERSECT,\u00a0MINUS)","text":"

    The results of the two queries can be combined using the set operations UNION, INTERSECT, and MINUS. The syntax is as below:

    query1 UNION [ALL] query2\nquery1 INTERSECT [ALL] query2\nquery1 MINUS [ALL] query2\n

    Tips: Where query1 and query2 are queries that can use any of the features discussed up to this point.

    UNION effectively appends the result of query2 to the result of query1 (although there is no guarantee that this is the order in which the rows are returned). Furthermore, it eliminates duplicate rows from its result, in the same way as DISTINCT, unless UNION ALL is used.

    INTERSECT returns all rows in both the result of query1 and query2. Duplicate rows are eliminated unless INTERSECT ALL is used.

    MINUS returns all rows in the result of query1 but not in query2. (This is sometimes called the difference between two queries.) Again, duplicates are eliminated unless MINUS ALL is used.

    To calculate the union, intersection, or difference of two queries, the two queries must be \"union compatible\", which means that they return the same number of columns and the corresponding columns have compatible data types.

    Set operations can be combined, for example:

    query1 UNION query2 MINUS query3\n

    which is equivalent to:

    (query1 UNION query2) MINUS query3\n

    As shown here, you can use parentheses to control the order of evaluation. Without parentheses, UNION and MINUS associate left-to-right, but INTERSECT binds more tightly than those two operators. Thus

    query1 UNION query2 INTERSECT query3\n

    that means:

    query1 UNION (query2 INTERSECT query3)\n

    You can also surround an individual query with parentheses. This is important if the query needs to use any of the clauses discussed in the following sections, such as LIMIT. Without parentheses, you'll get a syntax error, or else the clause will be understood as applying to the output of the set operation rather than one of its inputs. For example:

    SELECT a FROM b UNION SELECT x FROM y LIMIT 10\n

    is accepted, but it means:

    (SELECT a FROM b UNION SELECT x FROM y) LIMIT 10\n

    not as below:

    SELECT a FROM b UNION (SELECT x FROM y LIMIT 10)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/#reference","title":"Reference","text":"

    For more information on the single syntax as above, see:

    • UNION
    • INTERSECT
    • MINUS
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/","title":"UNION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#description","title":"Description","text":"

    UNION combines the result from multiple SELECT statements into a single result set.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#syntax","title":"Syntax","text":"
    SELECT ... UNION [ALL | DISTINCT] SELECT ... [UNION [ALL | DISTINCT] SELECT ...]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#arguments","title":"Arguments","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#union-distinct-and-union-all","title":"UNION [DISTINCT] and UNION ALL","text":"

    By default, duplicate rows are removed from the UNION results. UNION is used as the same as UNION [DISTINCT].

    Combining the result sets of two or more queries using the UNION operator requires the following conditions:

    • All SELECT statements must have the same number and order of columns.

    • Data types must be same or convertible.

    With UNION ALL, repeated lines (if available) are retained in the result.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#order-by-and-limit-in-union","title":"ORDER BY and LIMIT In UNION","text":"

    To apply anORDER BY or LIMIT clause to an individual SELECT, parenthesize the SELECT and place the clause inside the parentheses:

    Use of ORDER BY for individual SELECT statements implies nothing about the order in which the rows appear in the final result because UNION by default produces an unordered set of rows. Therefore, ORDER BY in this context typically is used in conjunction with LIMIT, to determine the subset of the selected rows to retrieve for the SELECT, even though it does not necessarily affect the order of those rows in the final UNION result.

    For example:

    (SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10)\nUNION\n(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);\n

    Or:

    (SELECT a FROM t1 WHERE a=10 AND B=1)\nUNION\n(SELECT a FROM t2 WHERE a=11 AND B=2)\nORDER BY a LIMIT 10;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#examples","title":"Examples","text":"
    CREATE TABLE t1 (id INT PRIMARY KEY);\nCREATE TABLE t2 (id INT PRIMARY KEY);\nINSERT INTO t1 VALUES (1),(2),(3);\nINSERT INTO t2 VALUES (2),(3),(4);\n\nmysql> SELECT id FROM t1 UNION SELECT id FROM t2;\n+------+\n| id   |\n+------+\n|    4 |\n|    1 |\n|    2 |\n|    3 |\n+------+\n\nmysql> SELECT id FROM t1 UNION ALL SELECT id FROM t2;\n+------+\n| id   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n
    drop table t1;\nCREATE TABLE t1 (a INT, b INT);\nINSERT INTO t1 VALUES ROW(4,-2),ROW(5,9),ROW(10,1),ROW(11,2),ROW(13,5);\ndrop table t2;\nCREATE TABLE t2 (a INT, b INT);\nINSERT INTO t2 VALUES ROW(1,2),ROW(3,4),ROW(11,2),ROW(10,3),ROW(15,8);\n\nmysql> (SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10) UNION (SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);\n+------+\n| a    |\n+------+\n|   10 |\n|   11 |\n+------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/","title":"WITH (Common Table Expressions)","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#description","title":"Description","text":"

    Common Table Expression (CTE) is a temporary result set defined within the scope of a single statement, valid only during the execution of the query. It can self-reference and can be referenced multiple times within the same query. Its purpose is simplifying complex queries, enhance code readability, and improve maintainability. A CTE can be seen as a temporary view that exists only for the query's execution and is not visible to external queries.

    Once defined, a CTE can be referenced like a SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement.

    The WITH clause is used to specify Common Table Expressions, and the WITH clause can include one or more comma-separated clauses. Each clause provides a subquery that generates a result set and associates a name with the subquery.

    Use Cases:

    • CTEs can reuse the same subquery in multiple places, avoiding redundant logic.
    • They can simplify recursive queries, such as querying tree-structured data.
    • Complex queries can be broken down into smaller parts using CTEs, making the query logic clearer and more understandable.

    Common Table Expressions are divided into two types: non-recursive and recursive:

    • Non-recursive CTE refers to an expression in which the CTE does not reference itself. It is used to build a one-time temporary result set and does not involve recursion.

    • Recursive CTE refers to an expression in which the CTE references itself. It handles data with recursive structures, such as trees or graphs. A recursive CTE includes a base query (initial condition) in its definition, then performs recursive operations on the result of that base query until a stop condition is met.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#non-recursive-cte","title":"Non-recursive CTE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#syntax","title":"Syntax","text":"
    WITH <query_name> AS (\n    <query_definition>\n)\nSELECT ... FROM <query_name>;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#explanations","title":"Explanations","text":"
    • <query_name>: Specifies the temporary name assigned to the CTE result set. It can be any valid identifier, similar to a table or column name.

    • <query_definition>: The query statement defines the CTE result set. It can be any valid SELECT query used to create the result set of the CTE.

    • SELECT ... FROM <query_name>: This is the query executed on the CTE, where you can use the name of the CTE.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#recursive-cte","title":"Recursive CTE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#syntax_1","title":"Syntax","text":"
    WITH RECURSIVE <query_name> AS (\n    <query_definition>\n)\nSELECT ... FROM <query_name>;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#explanations_1","title":"Explanations","text":"
    • WITH RECURSIVE: Indicates that this is a recursive CTE.

    • <query_name>: Specifies the temporary name assigned to the result set of the recursive CTE. It can be any valid identifier, similar to a table or column name.

    • <query_definition>: This consists of two parts in the context of a recursive CTE:

      • Initial part: Defines the recursion's initial condition and result set.
      • Recursive function: Defines how to recursively generate the next round of the result set from the initial result set.
    • SELECT ... FROM <query_name>: Use the name of the recursive CTE to query the recursive CTE.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#guidelines-for-using-recursive-ctes","title":"Guidelines for Using Recursive CTEs","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#anchor-and-recursive-members","title":"Anchor and Recursive Members","text":"

    A recursive common table expression (CTE) must consist of at least two query definitions: an anchor member and a recursive member. The anchor member should come before the first recursive member, and you can define multiple anchor and recursive members. All CTE query definitions are considered anchor members unless they reference the CTE itself.

    Suppose you have a table named Employee that contains employee information, including fields like EmployeeID, Name, and ManagerID, representing the employee's ID, name, and ID of their manager. You can use a recursive CTE to query the hierarchical relationship between employees and subordinates.

    Assuming the table data is as follows:

    EmployeeID Name ManagerID 1 Alice NULL 2 Bob 1 3 Charlie 1 4 David 2 5 Eve 2 6 Frank 3

    Here's an example of using a recursive CTE to query the hierarchical relationship between employees and their subordinates:

    WITH RECURSIVE EmployeeHierarchy AS (\n-- Anchor member: Find top-level employees\nSELECT EmployeeID, Name, ManagerID, 0 AS Level\nFROM Employee\nWHERE ManagerID IS NULL\n\nUNION ALL\n\n-- Recursive member: Recursively query subordinate employees\nSELECT e.EmployeeID, e.Name, e.ManagerID, eh.Level + 1\nFROM Employee AS e\nJOIN EmployeeHierarchy AS eh ON e.ManagerID = eh.EmployeeID\n)\nSELECT Name, Level\nFROM EmployeeHierarchy;\n

    In the above example:

    • The anchor member selects top-level employees (with ManagerID as NULL) and sets their level (Level) to 0.
    • The recursive member queries subordinate employees based on the previous round's results (EmployeeHierarchy), incrementing the level.
    • The final query uses SELECT to retrieve employee names and levels from the recursive CTE.

    Executing this query will provide information about the hierarchical relationship between employees and their subordinates. Both anchor and recursive members together form the structure of a recursive query. On the other hand, a non-recursive CTE is used to create a temporary result set with a single query definition, and you only need to reference this CTE in your query without concerning anchor and recursive members.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#operators-and-statement-requirements","title":"Operators and Statement Requirements","text":"
    • Set Operators: Anchor members must be combined using set operators (such as UNION ALL, UNION, INTERSECT, or EXCEPT). Only UNION ALL is allowed between the last anchor member and the first recursive member, as well as when combining multiple recursive members.

    • Column Matching: The number of columns in anchor and recursive members must be the same.

    • Data Types: Columns in the recursive member must have the same data types as the corresponding columns in the anchor member.

    • FROM Clause: The FROM clause of a recursive member can only reference the CTE expression_name once.

    • Unsupported Features: Certain features are not allowed in the CTE_query_definition of a recursive member, including:

      • Using the SELECT DISTINCT keyword for distinct queries.
      • Using GROUP BY to group results.
      • Using HAVING to filter results after grouping.
      • Scalar aggregation applies an aggregate function (like SUM, AVG, etc.) to a set of rows and returns a single value.
      • Outer join operations like LEFT, RIGHT, and OUTER JOIN (though INNER JOIN is allowed).
      • Subqueries.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#examples","title":"Examples","text":"
    • Non-recursive CTE example:
    CREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nsalary INT\n);\n\nINSERT INTO employees (id, name, salary) VALUES\n(1, 'Alice', 50000),\n(2, 'Bob', 60000),\n(3, 'Charlie', 75000),\n(4, 'David', 55000),\n(5, 'Eve', 80000);\n\n-- Query employees whose salary is higher than the average salary\nmysql> WITH avg_salary AS (\nSELECT AVG(salary) AS avg_salary FROM employees)\nSELECT name, salary\nFROM employees\nJOIN avg_salary ON salary > avg_salary.avg_salary;\n+---------+--------+\n| name    | salary |\n+---------+--------+\n| Charlie |  75000 |\n| Eve     |  80000 |\n+---------+--------+\n2 rows in set (0.00 sec)\n
    • Recursive CTE example:
    CREATE TABLE employees_hierarchy (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nmanager_id INT\n);\n\nINSERT INTO employees_hierarchy (id, name, manager_id) VALUES\n(1, 'Alice', NULL),\n(2, 'Bob', 1),\n(3, 'Charlie', 1),\n(4, 'David', 2),\n(5, 'Eve', 2),\n(6, 'Frank', 3);\n\n-- Query an employee and all his employees\nmysql> WITH RECURSIVE employee_hierarchy_cte (id, name, manager_id, level) AS (\nSELECT id, name, manager_id, 0\nFROM employees_hierarchy\nWHERE name = 'Alice'\nUNION ALL\nSELECT e.id, e.name, e.manager_id, eh.level + 1\nFROM employees_hierarchy AS e\nJOIN employee_hierarchy_cte AS eh ON e.manager_id = eh.id\n)\nSELECT name, level\nFROM employee_hierarchy_cte;\n+---------+-------+\n| name    | level |\n+---------+-------+\n| Alice   |     0 |\n| Bob     |     1 |\n| Charlie |     1 |\n| David   |     2 |\n| Eve     |     2 |\n| Frank   |     2 |\n+---------+-------+\n6 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/","title":"FULL JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#description","title":"Description","text":"

    The FULL JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records.

    note

    FULL OUTER JOIN and FULL JOIN are the same.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#syntax","title":"Syntax","text":"
    > SELECT column_name(s)\nFROM table1\nFULL OUTER JOIN table2\nON table1.column_name=table2.column_name;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#examples","title":"Examples","text":"
    drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 full join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n+----------+--------------------+------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/","title":"INNER JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#description","title":"Description","text":"

    The INNER JOIN keyword selects records that have matching values in both tables.(Same as JOIN)

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#syntax","title":"Syntax","text":"
    > SELECT column_name(s)\nFROM table1\nINNER JOIN table2\nON table1.column_name = table2.column_name;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#examples","title":"Examples","text":"
    drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n+----------+--------------------+------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/","title":"JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/#description","title":"Description","text":"

    The JOIN statement is used to combine rows from two or more tables.

    The following figure shows seven usages of LEFT JOIN, RIGHT JOIN, INNER JOIN, and OUTER JOIN.

    • LEFT JOIN
    SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL
    • RIGHT JOIN
    SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL
    • INNER JOIN
    SELECT [select_list] FROM TableA A INNER JOIN TableB B ON A.Key=B.Key
    • FULL JOIN
    SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL OR B.Key IS NULL

    For more information, see the reference below:

    • LEFT JOIN
    • RIGHT JOIN
    • INNER JOIN
    • FULL JOIN
    • OUTER JOIN
    • NATURAL JOIN
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/","title":"LEFT JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/#description","title":"Description","text":"

    The LEFT JOIN keyword returns all records from the left table (table1), and the matching records from the right table (table2). The result is 0 records from the right side, if there is no match.

    note

    In some databases LEFT JOIN is called LEFT OUTER JOIN.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/#syntax","title":"Syntax","text":"
    > SELECT column_name(s)\nFROM table1\nLEFT JOIN table2\nON table1.column_name=table2.column_name;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/#examples","title":"Examples","text":"
    drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 left join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n| NULL     | NULL               |    0 |\n+----------+--------------------+------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/","title":"NATURAL JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#description","title":"Description","text":"

    The NATURAL JOIN of two tables is defined to be semantically equivalent to an INNER JOIN or a LEFT JOIN with a USING clause that names all columns that exist in both tables.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#syntax","title":"Syntax","text":"
    > SELECT table_column1, table_column2...\nFROM table_name1\nNATURAL JOIN table_name2;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#examples","title":"Examples","text":"
    create table t1(id int,desc1 varchar(50),desc2 varchar(50));\ncreate table t2(id int,desc3 varchar(50),desc4 varchar(50));\nINSERT INTO t1(id,desc1,desc2) VALUES(100,'desc11','desc12'),(101,'desc21','desc22'),(102,'desc31','desc32');\nINSERT INTO t2(id,desc3,desc4) VALUES(101,'desc41','desc42'),(103,'desc51','desc52'),(105,'desc61','desc62');\n\nmysql> SELECT t1.id,t2.id,desc1,desc2,desc3,desc4 FROM t1 NATURAL JOIN t2;\n+------+------+--------+--------+--------+--------+\n| id   | id   | desc1  | desc2  | desc3  | desc4  |\n+------+------+--------+--------+--------+--------+\n|  101 |  101 | desc21 | desc22 | desc41 | desc42 |\n+------+------+--------+--------+--------+--------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/","title":"OUTER JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/#description","title":"Description","text":"

    When performing an INNER JOIN, rows from either table that are unmatched in the other table are not returned. In an OUTER JOIN, unmatched rows in one or both tables can be returned. There are a few types of outer joins:

    • LEFT JOIN returns only unmatched rows from the left table. For more information, see LEFT JOIN.
    • RIGHT JOIN returns only unmatched rows from the right table.For more information, see RIGHT JOIN.
    • FULL OUTER JOIN returns unmatched rows from both tables.For more information, see FULL JOIN.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/#examples","title":"Examples","text":"
    create table t1 (a1 int, a2 char(3));\ninsert into t1 values(10,'aaa'), (10,null), (10,'bbb'), (20,'zzz');\ncreate table t2(a1 char(3), a2 int, a3 real);\ninsert into t2 values('AAA', 10, 0.5);\ninsert into t2 values('BBB', 20, 1.0);\n\nmysql> select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10;\n+------+------+------+------+\n| a1   | a2   | a1   | a2   |\n+------+------+------+------+\n|   10 | aaa  | AAA  |   10 |\n|   10 | aaa  | BBB  |   20 |\n|   10 | NULL | AAA  |   10 |\n|   10 | NULL | BBB  |   20 |\n|   10 | bbb  | AAA  |   10 |\n|   10 | bbb  | BBB  |   20 |\n|   20 | zzz  | NULL | NULL |\n+------+------+------+------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/","title":"RIGHT JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#description","title":"Description","text":"

    The RIGHT JOIN keyword returns all records from the right table (table2), and the matching records from the left table (table1). The result is NULL records from the left side, if there is no match.

    note

    In some databases RIGHT JOIN is called RIGHT OUTER JOIN.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#syntax","title":"Syntax","text":"
    > SELECT column_name(s)\nFROM table1\nRIGHT JOIN table2\nON table1.column_name=table2.column_name;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#examples","title":"Examples","text":"
    drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 right join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n+----------+--------------------+------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/","title":"Comparisons Using Subqueries","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#description","title":"Description","text":"

    The most common use of a subquery is in the form:

    non_subquery_operand comparison_operator (subquery)\n

    Where comparison_operator is one of these operators:

    =  >  <  >=  <=  <>  !=  <=>\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#syntax","title":"Syntax","text":"
    > SELECT column_name(s) FROM table_name WHERE 'a' = (SELECT column1 FROM t1)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#examples","title":"Examples","text":"
    create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t3 values (6),(7),(3);\n\nmysql> select * from t3 where a = (select b from t2);\nERROR 1105 (HY000): scalar subquery returns more than 1 row\nmysql> select * from t3 where a = (select distinct b from t2);\n+------+\n| a    |\n+------+\n|    7 |\n+------+\n1 rows in set (0.01 sec)\n\nmysql> select a,b from t4 where a > ( select a ,b from t2 where a>1);\nERROR 1105 (HY000): Internal error: Unknow type TUPLE\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/","title":"Derived Tables","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#description","title":"Description","text":"

    This topic describes subqueries that occur as nested SELECT statements in the FROM clause of an outer SELECT statement. Such subqueries are sometimes called derived tables or table expressions because the outer query uses the results of the subquery as a data source.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#syntax","title":"Syntax","text":"

    Every table in a FROM clause must have a name, therefore the [AS] name clause is mandatory. Any columns in the subquery select list must have unique names.

    > SELECT ... FROM (subquery) [AS] name ...\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#examples","title":"Examples","text":"
    CREATE TABLE tb1 (c1 INT, c2 CHAR(5), c3 FLOAT);\nINSERT INTO tb1 VALUES (1, '1', 1.0);\nINSERT INTO tb1 VALUES (2, '2', 2.0);\nINSERT INTO tb1 VALUES (3, '3', 3.0);\n\nmysql> select * from tb1;\n+------+------+--------+\n| c1   | c2   | c3     |\n+------+------+--------+\n|    1 | 1    | 1.0000 |\n|    2 | 2    | 2.0000 |\n|    3 | 3    | 3.0000 |\n+------+------+--------+\n3 rows in set (0.03 sec)\n\nmysql> SELECT sc1, sc2, sc3 FROM (SELECT c1 AS sc1, c2 AS sc2, c3*3 AS sc3 FROM tb1) AS sb WHERE sc1 > 1;\n+------+------+--------+\n| sc1  | sc2  | sc3    |\n+------+------+--------+\n|    2 | 2    | 6.0000 |\n|    3 | 3    | 9.0000 |\n+------+------+--------+\n2 rows in set (0.02 sec)\n
    • Subquery with Join:
    create table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values('000','NewYorkPublicLibra',1);\ninsert into t3 values('001','NewYorkPublicLibra',2);\ninsert into t3 values('002','NewYorkPublicLibra',3);\ninsert into t3 values('003','NewYorkPublicLibra',4);\ninsert into t3 values('004','NewYorkPublicLibra',5);\ninsert into t3 values('005','NewYorkPublicLibra',6);\ninsert into t3 values('006','SanFransiscoPublic',5);\ninsert into t3 values('007','BerkeleyPublic1',3);\ninsert into t3 values('007','BerkeleyPublic2',3);\ninsert into t3 values('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select * from (select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1) sub ;\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n+----------+--------------------+------+\n4 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/","title":"Subqueries with ALL","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#description","title":"Description","text":"

    The word ALL, which must follow a comparison operator, means \"return TRUE if the comparison is TRUE for ALL of the values in the column that the subquery returns.\":

    operand comparison_operator ALL (subquery)\n

    For example:

    SELECT s1 FROM t1 WHERE s1 > ALL (SELECT s1 FROM t2);\n

    Suppose that there is a row in table t1 containing (10). The expression is TRUE if table t2 contains (-5,0,+5) because 10 is greater than all three values in t2. The expression is FALSE if table t2 contains (12,6,NULL,-100) because there is a single value 12 in table t2 that is greater than 10, and the result returns Empty set. The expression is unknown (that is, NULL) if table t2 contains (0,NULL,1).

    Finally, the expression is TRUE if table t2 is empty. So, the following expression is TRUE when table t2 is empty:

    SELECT * FROM t1 WHERE 1 > ALL (SELECT s1 FROM t2);\n

    But this expression is NULL when table t2 is empty:

    SELECT * FROM t1 WHERE 1 > (SELECT s1 FROM t2);\n

    In addition, the following expression is NULL when table t2 is empty:

    SELECT * FROM t1 WHERE 1 > ALL (SELECT MAX(s1) FROM t2);\n

    In general, tables containing NULL values and empty tables are \"edge cases.\" When writing subqueries, always consider whether you have taken those two possibilities into account.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#syntax","title":"Syntax","text":"
    > SELECT column_name(s) FROM table_name {WHERE | HAVING} [not] expression comparison_operator ALL (subquery)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#examples","title":"Examples","text":"
    create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select * from t3 where a <> all (select b from t2);\n+------+\n| a    |\n+------+\n|    6 |\n|    3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t4 where 5 > all (select a from t5);\n+------+------+\n| a    | b    |\n+------+------+\n|    4 |    8 |\n|    3 |    8 |\n|    5 |    9 |\n+------+------+\n3 rows in set (0.01 sec)\n\nmysql> select * from t3 where 10 > all (select b from t2);\n+------+\n| a    |\n+------+\n|    6 |\n|    7 |\n|    3 |\n+------+\n3 rows in set (0.00 sec)\n\nmysql> select a,b from t6 where a > all ( select a ,b from t4 where a>3);\nERROR 1105 (HY000): subquery should return 1 column\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/","title":"Subqueries with ANY or SOME","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#description","title":"Description","text":"

    Comparison operators (=, >, < , etc.) are used only on subqueries that return one row. SQL Subqueries with ANY, you can make comparisons on subqueries that return multiple rows. ANY evaluate whether any or all of the values returned by a subquery match the left-hand expression.

    Subqueries that use the ANY keyword return true when any value retrieved in the subquery matches the value of the left-hand expression.

    note

    The word SOME is an alias for ANY.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#syntax","title":"Syntax","text":"
    > SELECT column_name(s) FROM table_name WHERE column_name ANY (subquery);\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#examples","title":"Examples","text":"
    create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select * from t3 where a <> any (select b from t2);\n+------+\n| a    |\n+------+\n|    6 |\n|    3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t3 where a <> some (select b from t2);\n+------+\n| a    |\n+------+\n|    6 |\n|    3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t3 where a = some (select b from t2);\n+------+\n| a    |\n+------+\n|    7 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select * from t3 where a = any (select b from t2);\n+------+\n| a    |\n+------+\n|    7 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select a,b from t6 where a >  any ( select a ,b from t4 where a>3);\nERROR 1105 (HY000): subquery should return 1 column\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/","title":"Subqueries with EXISTS or NOT EXISTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#description","title":"Description","text":"

    The EXISTS operator is used to test for the existence of any record in a subquery.

    If a subquery returns any rows at all, EXISTS subquery is TRUE, and NOT EXISTS subquery is FALSE.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#syntax","title":"Syntax","text":"
    > SELECT column_name(s)\nFROM table_name\nWHERE EXISTS\n(SELECT column_name FROM table_name WHERE condition);\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#examples","title":"Examples","text":"
    create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t3 values (6),(7),(3);\n\nmysql> select * from t3 where exists (select * from t2 where t2.b=t3.a);\n+------+\n| a    |\n+------+\n|    7 |\n+------+\n1 row in set (0.00 sec)\nmysql> select * from t3 where not exists (select * from t2 where t2.b=t3.a);\n+------+\n| a    |\n+------+\n|    6 |\n|    3 |\n+------+\n2 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/","title":"Subqueries with IN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#description","title":"Description","text":"

    A subquery can be used with the IN operator as \"expression IN (subquery)\". The subquery should return a single column with one or more rows to form a list of values to be used by the IN operation.

    Use the IN clause for multiple-record, single-column subqueries. After the subquery returns results introduced by IN or NOT IN, the outer query uses them to return the final result.

    • If any row in the sub-query result matches, the answer is true.
    • If the subquery result is empty, the answer is false.
    • If no row in the sub-query result matches, the answer is also false.
    • If all of the values in the sub-query result are null, the answer is false.
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#syntax","title":"Syntax","text":"
    > SELECT ... FROM table_name WHERE column_name IN (subquery)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#examples","title":"Examples","text":"
    create table t1(val varchar(10));\ninsert into t1 values ('aaa'), ('bbb'),('eee'),('mmm'),('ppp');\n\nmysql> select count(*) from t1 as w1 where w1.val in (select w2.val from t1 as w2 where w2.val like 'm%') and w1.val in (select w3.val from t1 as w3 where w3.val like 'e%');\n+----------+\n| count(*) |\n+----------+\n|        0 |\n+----------+\n1 row in set (0.01 sec)\n
    create table t1 (id int not null, text varchar(20) not null default '', primary key (id));\ninsert into t1 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text11'), (12, 'text12');\n\nmysql> select * from t1 where id not in (select id from t1 where id < 8);\n+------+--------+\n| id   | text   |\n+------+--------+\n|    8 | text8  |\n|    9 | text9  |\n|   10 | text10 |\n|   11 | text11 |\n|   12 | text12 |\n+------+--------+\n5 rows in set (0.00 sec)\n
    CREATE TABLE t1 (a int);\nCREATE TABLE t2 (a int, b int);\nCREATE TABLE t3 (b int NOT NULL);\nINSERT INTO t1 VALUES (1), (2), (3), (4);\nINSERT INTO t2 VALUES (1,10), (3,30);\n\nmysql> select * from t1 where t1.a in (SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.a=t1.a);\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT * FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10;\nEmpty set (0.01 sec)\nmysql> SELECT * FROM t1 WHERE t1.a NOT IN (SELECT a FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10);\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n4 rows in set (0.00 sec)\n
    create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select a,b from t6 where (a,b) in ( select a,b from t4 where a>3);\nEmpty set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/","title":"SUBQUERY","text":"

    A subquery is a SELECT statement within another statement. is a SQL query nested inside a larger query.

    Here is an example of a subquery:

    SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);\n

    In this example, SELECT * FROM t1 ... is the outer query (or outer statement), and (SELECT column1 FROM t2) is the subquery. We say that the subquery is nested within the outer query, and in fact it is possible to nest subqueries within other subqueries, to a considerable depth. A subquery must always appear within parentheses.

    The main advantages of subqueries are:

    • They allow queries that are structured so that it is possible to isolate each part of a statement.

    • They provide alternative ways to perform operations that would otherwise require complex joins and unions.

    • Many people find subqueries more readable than complex joins or unions.

    A subquery may occur in:

    • A SELECT clause
    • A FROM clause
    • A WHERE clause

    For more information, see the reference below:

    • Derived Tables
    • Comparisons Using Subqueries
    • SUBQUERY WITH ANY or SOME
    • SUBQUERY WITH ALL
    • SUBQUERY WITH EXISTS
    • SUBQUERY WITH IN
    "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/#constraints","title":"Constraints","text":"

    MatrixOne does not support selecting multiple columns for the subquery.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/","title":"KILL","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#description","title":"Description","text":"

    The KILL statement terminates a running query or process.

    Info

    Terminating a process or query may result in the loss of unsaved data; terminating a running query may consume system resources and affect other running queries.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#syntax","title":"Syntax","text":"
    > KILL [CONNECTION | QUERY] processlist_id\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#explanations","title":"Explanations","text":"

    process_id refers to the identifier of the process or query to be terminated. process_id is the connection identifier if the CONNECTION keyword is used, and process_id is the query identifier if the QUERY keyword is used.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#examples","title":"Examples","text":"
    select connection_id();\n+-----------------+\n| connection_id() |\n+-----------------+\n|            1008 |\n+-----------------+\n1 row in set (0.00 sec)\n\n-- Terminate query process\nmysql> kill query 1008;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- Terminate the connection process\nmysql> kill connection 1008;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- Test for disconnection\nmysql> show databases;\nERROR 2013 (HY000): Lost connection to MySQL server during query\nNo connection. Trying to reconnect...\nConnection id:    1180\n-- The connection has been disconnected, and the service has started to reconnect\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/","title":"USE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#description","title":"Description","text":"

    The USE statement tells MatrixOne to use the named database as the default (current) database for subsequent statements.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#syntax","title":"Syntax","text":"
    > USE db_name\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#examples","title":"Examples","text":"
    > USE db1;\n> SELECT COUNT(*) FROM mytable; 
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/","title":"Obtaining Information with EXPLAIN ANALYZE","text":"

    EXPLAIN ANALYZE is a profiling tool for your queries that will show you where SQL spends time on your query and why. It will plan the query, instrument it and execute it while counting rows and measuring time spent at various points in the execution plan. When execution finishes, EXPLAIN ANALYZE will print the plan and the measurements instead of the query result.

    EXPLAIN ANALYZE, which runs a statement and produces EXPLAIN output along with timing and additional, iterator-based, information about how the optimizer's expectations matched the actual execution. For each iterator, the following information is provided:

    • Estimated execution cost

    Some iterators are not accounted for by the cost model, and so are not included in the estimate.

    • Estimated number of returned rows

    • Time to return first row

    • Time spent executing this iterator (including child iterators, but not parent iterators), in milliseconds.

    • Number of rows returned by the iterator

    • Number of loops

    The query execution information is displayed using the TREE output format, in which nodes represent iterators. EXPLAIN ANALYZE always uses the TREE output format, also can optionally be specified explicitly using FORMAT=TREE; formats other than TREE remain unsupported.

    EXPLAIN ANALYZE can be used with SELECT statements, as well as with multi-table UPDATE and DELETE statements.

    You can terminate this statement using KILL QUERY or CTRL-C.

    EXPLAIN ANALYZE cannot be used with FOR CONNECTION.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/#example","title":"Example","text":"

    Create table

    CREATE TABLE t1 (\nc1 INTEGER DEFAULT NULL,\nc2 INTEGER DEFAULT NULL\n);\n\nCREATE TABLE t2 (\nc1 INTEGER DEFAULT NULL,\nc2 INTEGER DEFAULT NULL\n);\n\nCREATE TABLE t3 (\npk INTEGER NOT NULL PRIMARY KEY,\ni INTEGER DEFAULT NULL\n);\n

    Example output:

    > EXPLAIN ANALYZE SELECT * FROM t1 JOIN t2 ON (t1.c1 = t2.c2)\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN:   Analyze: timeConsumed=0us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN:   ->  Join\n*************************** 4. row ***************************\nQUERY PLAN:         Analyze: timeConsumed=5053us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN:         Join Type: INNER\n*************************** 6. row ***************************\nQUERY PLAN:         Join Cond: (t1.c1 = t2.c2)\n*************************** 7. row ***************************\nQUERY PLAN:         ->  Table Scan on aaa.t1\n*************************** 8. row ***************************\nQUERY PLAN:               Analyze: timeConsumed=2176us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 9. row ***************************\nQUERY PLAN:         ->  Table Scan on aaa.t2\n*************************** 10. row ***************************\nQUERY PLAN:               Analyze: timeConsumed=0us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n10 rows in set (0.00 sec)\n\n> EXPLAIN ANALYZE SELECT * FROM t3 WHERE i > 8\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN:   Analyze: timeConsumed=0us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN:   ->  Table Scan on aaa.t3\n*************************** 4. row ***************************\nQUERY PLAN:         Analyze: timeConsumed=154us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN:         Filter Cond: (CAST(t3.i AS BIGINT) > 8)\n5 rows in set (0.00 sec)\n\n> EXPLAIN ANALYZE SELECT * FROM t3 WHERE pk > 17\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN:   Analyze: timeConsumed=0us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN:   ->  Table Scan on aaa.t3\n*************************** 4. row ***************************\nQUERY PLAN:         Analyze: timeConsumed=309us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN:         Filter Cond: (CAST(t3.pk AS BIGINT) > 17)\n5 rows in set (0.00 sec)\n

    Values shown for actual time in the output of this statement are expressed in milliseconds.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/","title":"EXPLAIN Output Format","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#output-structure","title":"Output Structure","text":"

    The command's result is a textual description of the plan selected for the statement, optionally annotated with execution statistics.

    Take the following SQL as an example, we demonstrate the output structure.

    explain select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n
    +--------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                 |\n+--------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=400.00 ndv=0.00 rowsize=0                                     |\n|   ->  Aggregate(cost=0.00..0.00 card=400.00 ndv=0.00 rowsize=0                             |\n|         Group Key:#[0,1], #[0,0]                                                           |\n|         Aggregate Functions: count(#[0,0])                                                 |\n|         ->  Join(cost=0.00..0.00 card=400.00 ndv=0.00 rowsize=0                            |\n|               Join Type: INNER                                                             |\n|               Join Cond: (#[1,2] = #[0,0])                                                 |\n|               ->  Table Scan on abc.t2(cost=0.00..0.00 card=8.00 ndv=0.00 rowsize=0        |\n|               ->  Join(cost=0.00..0.00 card=50.00 ndv=0.00 rowsize=0                       |\n|                     Join Type: INNER                                                       |\n|                     Join Cond: (#[0,0] = #[1,1])                                           |\n|                     ->  Table Scan on abc.t1(cost=0.00..0.00 card=5.00 ndv=0.00 rowsize=0  |\n|                     ->  Table Scan on abc.t3(cost=0.00..0.00 card=10.00 ndv=0.00 rowsize=0 |\n+--------------------------------------------------------------------------------------------+\n13 rows in set (0.00 sec)\n

    EXPLAIN outputs a tree structure, named as Execution Plan Tree. Every leaf node includes the information of node type, affected objects and other properties such as cost, rowsize and so on. We can simplify the above example only with node type information. It visualizes the whole process of a SQL query, shows which operation nodes it goes through and what are their cost estimation.

    Project\n\u2514\u2500\u2500 Aggregate\n    \u2514\u2500\u2500 Join\n        \u2514\u2500\u2500 Table Scan\n        \u2514\u2500\u2500 Join\n              \u2514\u2500\u2500Table Scan\n              \u2514\u2500\u2500Table Scan\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#node-types","title":"Node types","text":"

    MatrixOne supports the following node types:

    Node Type Name in Explain Node_TABLE_SCAN Table Scan Node_VALUE_SCAN Values Scan Node_PROJECT Project Node_AGG Aggregate Node_FILTER Filter Node_JOIN Join Node_SORT Sort Node_INSERT Insert Node_UPDATE Update Node_DELETE Delete"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#table-scan","title":"Table Scan","text":"Property Format Description cost cost=0.00..0.00 The first is estimated start-up cost. This is the time expended before the output phase can begin, e.g., time to do the sorting in a sort node. The second is estimated total cost. This is stated on the assumption that the plan node is run to completion, i.e., all available rows are retrieved. In practice a node's parent node might stop short of reading all available rows (see the LIMIT example below). card card=14.00 Estimated column cardinality. ndv ndv=0.00 Estimated number of distinct values. rowsize rowsize=0.00 Estimated rowsize. output Output: #[0,0], #[0,1], #[0,2], #[0,3], #[0,4], #[0,5], #[0,6], #[0,7] Node output information. Table Table : 'emp' (0:'empno', 1:'ename', 2:'job', 3:'mgr',) Table definition information after column pruning. Filter Cond Filter Cond: (CAST(#[0,5] AS DECIMAL128) > CAST(20 AS DECIMAL128)) Filter condition."},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#values-scan","title":"Values Scan","text":"Property Format Description cost (cost=0.00..0.00 card=14.00 ndv=0.00 rowsize=0) Estimated cost output Output: 0 Node output information"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#project","title":"Project","text":"Property Format Description cost (cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) Estimated cost output Output: (CAST(#[0,0] AS INT64) + 2) Node output information"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#aggregate","title":"Aggregate","text":"Property Format Description cost (cost=0.00..0.00 card=14.00 ndv=0.00 rowsize=0) Estimated cost output Output: #[0,0], #[0,1], #[0,2], #[0,3], #[0,4], #[0,5], #[0,6], #[0,7] Node output information Group Key Group Key:#[0,0] Key for grouping Aggregate Functions Aggregate Functions: max(#[0,1]) Aggregate function name"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#filter","title":"Filter","text":"Property Format Description cost (cost=0.00..0.00 card=14.00 ndv=0.00 rowsize=0) Estimated cost output Output: #[0,0], #[0,1], #[0,2], #[0,3], #[0,4], #[0,5], #[0,6], #[0,7] Node output information Filter Cond Filter Cond: (CAST(#[0,1] AS INT64) > 10) Filter condition"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#join","title":"Join","text":"Property Format Description cost (cost=0.00..0.00 card=14.00 ndv=0.00 rowsize=0) Estimated cost output Output: #[0,0] Node output information Join Type: INNER Join Type: INNER Join type Join Cond Join Cond: (#[0,0] = #[1,0]) Join condition"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#sort","title":"Sort","text":"Property Format Description cost (cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) Estimated cost output Output: #[0,0], #[0,1], #[0,2], #[0,3], #[0,4], #[0,5], #[0,6], #[0,7] Node output information Sort Key Sort Key: #[0,0] DESC, #[0,1] INTERNAL Sort key Limit Limit: 10 Number limit for output data Offset Offset: 20 Number offset for output data"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/","title":"EXPLAIN","text":"

    EXPLAIN \u2014 show the execution plan of a statement.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#syntax","title":"Syntax","text":"
    EXPLAIN [ ( option [, ...] ) ] statement\n\nwhere option can be one of:\n    ANALYZE [ boolean ]\n    VERBOSE [ boolean ]\n    FORMAT { TEXT | JSON }\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#description","title":"Description","text":"

    This command displays the execution plan that the MatrixOne planner generates for the supplied statement. The execution plan shows how the table(s) referenced by the statement will be scanned \u2014 by plain sequential scan, index scan, and so on. \u2014 and if multiple tables are referenced, what join algorithms will be used to bring together the required rows from each input table.

    The most critical part of the display is the estimated statement execution cost, which is the planner's guess at how long it will take to run the statement (measured in cost units that are arbitrary, but conventionally mean disk page fetches). Actually two numbers are shown: the start-up cost before the first row can be returned, and the total cost to return all the rows. For most queries the total cost is what matters, but in contexts such as a subquery in EXISTS, the planner will choose the smallest start-up cost instead of the smallest total cost (since the executor will stop after getting one row, anyway). Also, if you limit the number of rows to return with a LIMIT clause, the planner makes an appropriate interpolation between the endpoint costs to estimate which plan is really the cheapest.

    The ANALYZE option causes the statement to be actually executed, not only planned. Then actual run time statistics are added to the display, including the total elapsed time expended within each plan node (in milliseconds) and the total number of rows it actually returned. This is useful for seeing whether the planner's estimates are close to reality.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#parameters","title":"Parameters","text":"
    • ANALYZE:

    Carry out the command and show actual run times and other statistics. This parameter defaults to FALSE.

    • VERBOSE:

    Display additional information regarding the plan. Specifically, include the output column list for each node in the plan tree, schema-qualify table and function names, always label variables in expressions with their range table alias, and always print the name of each trigger for which statistics are displayed. This parameter is FALSE by default.

    • FORMAT:

    Specify the output format, which can be TEXT, JSON. Non-text output contains the same information as the text output format, but is easier for programs to parse. This parameter is TEXT by dafault.

    • BOOLEAN:

    Specifies whether the selected option should be turned on or off. You can write TRUEto enable the option, and FALSE to disable it. The boolean value can also be omitted, in which case TRUE is assumed.

    • STETEMENT

    MatrixOne supports any SELECT, UPDATE, DELETE statement execution plan. For INSERT statement, only INSERT INTO..SELECT is supported in 0.5.1 version. INSERT INTO...VALUES is not supported yet.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#examples","title":"Examples","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_table_scan","title":"Node_TABLE_SCAN","text":"
    mysql> explain verbose SELECT N_NAME, N_REGIONKEY a FROM NATION WHERE N_NATIONKEY > 0 OR N_NATIONKEY < 10;\n+------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                         |\n+------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                             |\n|   Output: #[0,0], #[0,1]                                                           |\n|   ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)      |\n|         Output: #[0,1], #[0,2]                                                     |\n|         Table: 'nation' (0:'n_nationkey', 1:'n_name', 2:'n_regionkey')             |\n|         Filter Cond: ((CAST(#[0,0] AS INT64) > 0) or (CAST(#[0,0] AS INT64) < 10)) |\n+------------------------------------------------------------------------------------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_value_scan","title":"Node_VALUE_SCAN","text":"
    mysql> explain verbose select abs(-1);\n+-----------------------------------------------------------------------------+\n| QUERY PLAN                                                                  |\n+-----------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=1.00 ndv=0.00 rowsize=0)                       |\n|   Output: 1                                                                 |\n|   ->  Values Scan \"*VALUES*\" (cost=0.00..0.00 card=1.00 ndv=0.00 rowsize=0) |\n|         Output: 0                                                           |\n+-----------------------------------------------------------------------------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_sort","title":"Node_SORT","text":"
    mysql> explain verbose SELECT N_NAME, N_REGIONKEY a FROM NATION WHERE N_NATIONKEY > 0 AND N_NATIONKEY < 10 ORDER BY N_NAME, N_REGIONKEY DESC;\n+--------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                 |\n+--------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                     |\n|   Output: #[0,0], #[0,1]                                                                   |\n|   ->  Sort(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                  |\n|         Output: #[0,0], #[0,1]                                                             |\n|         Sort Key: #[0,0] INTERNAL,  #[0,1] DESC                                            |\n|         ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                         |\n|               Output: #[0,0], #[0,1]                                                       |\n|               ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)  |\n|                     Output: #[0,1], #[0,2]                                                 |\n|                     Table: 'nation' (0:'n_nationkey', 1:'n_name', 2:'n_regionkey')         |\n|                     Filter Cond: (CAST(#[0,0] AS INT64) > 0), (CAST(#[0,0] AS INT64) < 10) |\n+--------------------------------------------------------------------------------------------+\n

    With limit and offset:

    mysql> explain SELECT N_NAME, N_REGIONKEY FROM NATION WHERE abs(N_REGIONKEY) > 0 AND N_NAME LIKE '%AA' ORDER BY N_NAME DESC, N_REGIONKEY limit 10;\n+-------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                |\n+-------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                    |\n|   ->  Sort(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                 |\n|         Sort Key: #[0,0] DESC,  #[0,1] INTERNAL                                           |\n|         Limit: 10                                                                         |\n|         ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|               ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|                     Filter Cond: (abs(CAST(#[0,1] AS INT64)) > 0), (#[0,0] like '%AA')    |\n+-------------------------------------------------------------------------------------------+\n
    mysql> explain SELECT N_NAME, N_REGIONKEY FROM NATION WHERE abs(N_REGIONKEY) > 0 AND N_NAME LIKE '%AA' ORDER BY N_NAME DESC, N_REGIONKEY LIMIT 10 offset 20;\n+-------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                |\n+-------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                    |\n|   ->  Sort(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                 |\n|         Sort Key: #[0,0] DESC,  #[0,1] INTERNAL                                           |\n|         Limit: 10, Offset: 20                                                             |\n|         ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|               ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|                     Filter Cond: (abs(CAST(#[0,1] AS INT64)) > 0), (#[0,0] like '%AA')    |\n+-------------------------------------------------------------------------------------------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_agg","title":"Node_AGG","text":"
    mysql> explain verbose SELECT count(*) FROM NATION group by N_NAME;\n+-------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                          |\n+-------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                              |\n|   Output: #[0,0]                                                                    |\n|   ->  Aggregate(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                      |\n|         Output: #[-2,0]                                                             |\n|         Group Key:#[0,1]                                                            |\n|         Aggregate Functions: starcount(#[0,0])                                      |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|               Output: #[0,0], #[0,1]                                                |\n|               Table: 'nation' (0:'n_nationkey', 1:'n_name')                         |\n+-------------------------------------------------------------------------------------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_join","title":"Node_JOIN","text":"
    mysql> explain verbose SELECT NATION.N_NAME, REGION.R_NAME FROM NATION join REGION on NATION.N_REGIONKEY = REGION.R_REGIONKEY WHERE NATION.N_REGIONKEY > 10 AND LENGTH(NATION.N_NAME) > LENGTH(REGION.R_NAME);\n+--------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                 |\n+--------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=125.00 ndv=0.00 rowsize=0)                                    |\n|   Output: #[0,1], #[0,0]                                                                   |\n|   ->  Filter(cost=0.00..0.00 card=125.00 ndv=0.00 rowsize=0)                               |\n|         Output: #[0,0], #[0,1]                                                             |\n|         Filter Cond: (length(CAST(#[0,1] AS CHAR)) > length(CAST(#[0,0] AS CHAR)))         |\n|         ->  Join(cost=0.00..0.00 card=125.00 ndv=0.00 rowsize=0)                           |\n|               Output: #[0,1], #[1,0]                                                       |\n|               Join Type: INNER                                                             |\n|               Join Cond: (#[1,1] = #[0,0])                                                 |\n|               ->  Table Scan on tpch.region(cost=0.00..0.00 card=5.00 ndv=0.00 rowsize=0)  |\n|                     Output: #[0,0], #[0,1]                                                 |\n|                     Table: 'region' (0:'r_regionkey', 1:'r_name')                          |\n|               ->  Table Scan on tpch.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|                     Output: #[0,0], #[0,1]                                                 |\n|                     Table: 'nation' (0:'n_name', 1:'n_regionkey')                          |\n|                     Filter Cond: (CAST(#[0,1] AS INT64) > 10)                              |\n+--------------------------------------------------------------------------------------------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_insert","title":"Node_INSERT","text":"
    mysql> explain verbose INSERT NATION select * from nation;\n+---------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                  |\n+---------------------------------------------------------------------------------------------+\n| Insert on db1.nation (cost=0.0..0.0 rows=0 ndv=0 rowsize=0)                                 |\n|   Output: #[0,0], #[0,1], #[0,2], #[0,3]                                                    |\n|   ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                |\n|         Output: #[0,0], #[0,1], #[0,2], #[0,3]                                              |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)         |\n|               Output: #[0,0], #[0,1], #[0,2], #[0,3]                                        |\n|               Table: 'nation' (0:'n_nationkey', 1:'n_name', 2:'n_regionkey', 3:'n_comment') |\n+---------------------------------------------------------------------------------------------+\n7 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_update","title":"Node_Update","text":"
    mysql> explain verbose UPDATE NATION SET N_NAME ='U1', N_REGIONKEY=2 WHERE N_NATIONKEY > 10 LIMIT 20;\n+-------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                          |\n+-------------------------------------------------------------------------------------+\n| Update on db1.nation (cost=0.0..0.0 rows=0 ndv=0 rowsize=0)                         |\n|   ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|         Output: #[0,0], 'U1', CAST(2 AS INT32)                                      |\n|         Limit: 20                                                                   |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|               Output: #[0,1]                                                        |\n|               Table: 'nation' (0:'n_nationkey', 1:'PADDR')                          |\n|               Filter Cond: (CAST(#[0,0] AS INT64) > 10)                             |\n+-------------------------------------------------------------------------------------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_delete","title":"Node_Delete","text":"
    mysql> explain verbose DELETE FROM NATION WHERE N_NATIONKEY > 10;\n+-------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                          |\n+-------------------------------------------------------------------------------------+\n| Delete on db1.nation (cost=0.0..0.0 rows=0 ndv=0 rowsize=0)                         |\n|   ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|         Output: #[0,0]                                                              |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|               Output: #[0,1]                                                        |\n|               Table: 'nation' (0:'n_nationkey', 1:'PADDR')                          |\n|               Filter Cond: (CAST(#[0,0] AS INT64) > 10)                             |\n+-------------------------------------------------------------------------------------+\n

    With limit:

    mysql>  explain verbose DELETE FROM NATION WHERE N_NATIONKEY > 10 LIMIT 20;\n+-------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                          |\n+-------------------------------------------------------------------------------------+\n| Delete on db1.nation (cost=0.0..0.0 rows=0 ndv=0 rowsize=0)                         |\n|   ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|         Output: #[0,0]                                                              |\n|         Limit: 20                                                                   |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|               Output: #[0,1]                                                        |\n|               Table: 'nation' (0:'n_nationkey', 1:'PADDR')                          |\n|               Filter Cond: (CAST(#[0,0] AS INT64) > 10)                             |\n+-------------------------------------------------------------------------------------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/","title":"DEALLOCATE PREPARE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#description","title":"Description","text":"

    To deallocate a prepared statement produced with PREPARE, use a DEALLOCATE PREPARE statement that refers to the prepared statement name. Attempting to execute a prepared statement after deallocating it results in an error. If too many prepared statements are created and not deallocated by either the DEALLOCATE PREPARE statement or the end of the session, you might encounter the upper limit enforced by the max_prepared_stmt_count system variable.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#syntax","title":"Syntax","text":"
    {DEALLOCATE | DROP} PREPARE stmt_name\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#arguments","title":"Arguments","text":"Arguments Description stmt_name The name of the prepared statement."},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#examples","title":"Examples","text":"
    > CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\n> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\n> SET @si_min = -9223372036854775808;\n> SET @si_max = 9223372036854775807;\n> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.00 sec)\n\n> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk   | ui   | si                   |\n+------+------+----------------------+\n|    0 |    0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.01 sec)\n\n> EXECUTE s2 USING @si_max;\n+------+----------------------+---------------------+\n| pk   | ui                   | si                  |\n+------+----------------------+---------------------+\n|    1 | 18446744073709551615 | 9223372036854775807 |\n+------+----------------------+---------------------+\n1 row in set (0.01 sec)\n\n> DEALLOCATE PREPARE s2;\nQuery OK, 0 rows affected (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/","title":"EXECUTE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#description","title":"Description","text":"

    After preparing a statement with PREPARE, you execute it with an EXECUTE statement that refers to the prepared statement name. If the prepared statement contains any parameter markers, you must supply a USING clause that lists user variables containing the values to be bound to the parameters. Parameter values can be supplied only by user variables, and the USING clause must name exactly as many variables as the number of parameter markers in the statement.

    You can execute a given prepared statement multiple times, passing different variables to it or setting the variables to different values before each execution.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#syntax","title":"Syntax","text":"
    EXECUTE stmt_name\n    [USING @var_name [, @var_name] ...]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#arguments","title":"Arguments","text":"Arguments Description stmt_name The name of the prepared statement."},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#examples","title":"Examples","text":"
    > CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\n> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\n> SET @si_min = -9223372036854775808;\n> SET @si_max = 9223372036854775807;\n> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.00 sec)\n\n> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk   | ui   | si                   |\n+------+------+----------------------+\n|    0 |    0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.01 sec)\n\n> EXECUTE s2 USING @si_max;\n+------+----------------------+---------------------+\n| pk   | ui                   | si                  |\n+------+----------------------+---------------------+\n|    1 | 18446744073709551615 | 9223372036854775807 |\n+------+----------------------+---------------------+\n1 row in set (0.01 sec)\n\n> DEALLOCATE PREPARE s2;\nQuery OK, 0 rows affected (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/","title":"PREPARE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#description","title":"Description","text":"

    The PREPARE statement prepares a SQL statement and assigns it a name, The prepared statement is executed with EXECUTE and released with DEALLOCATE PREPARE.

    Statement names are not case-sensitive.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#syntax","title":"Syntax","text":"
    PREPARE stmt_name FROM preparable_stmt\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#arguments","title":"Arguments","text":"Arguments Description stmt_name The name of the prepared statement. preparable_stmt a string literal or a user variable that contains the text of the SQL statement. The text must represent a single statement, not multiple statements. Within the statement, ? characters can be used as parameter markers to indicate where data values are to be bound to the query later when you execute it. The ? characters should not be enclosed within quotation marks, even if you intend to bind them to string values. Parameter markers can be used only where data values should appear, not for SQL keywords, identifiers, and so forth.

    If a prepared statement with the given name already exists, it is deallocated implicitly before the new statement is prepared. This means that if the new statement contains an error and cannot be prepared, an error is returned and no statement with the given name exists.

    The scope of a prepared statement is the session within which it is created, which as several implications:

    • A prepared statement created in one session is not available to other sessions.

    • When a session ends, whether normally or abnormally, its prepared statements no longer exist. If auto-reconnect is enabled, the client is not notified that the connection was lost. For this reason, clients may wish to disable auto-reconnect.

    A parameter used in a prepared statement has its type determined when the statement is first prepared, and retains this type whenever EXECUTE is invoked for this prepared statement. Rules for determining a parameter's type are listed here:

    • A parameter which is an operand of a binary arithmetic operator has the same data type as the other operand.

    • If both operands of a binary arithmetic operator are parameters, the type of the parameters is decided by the context of the operator.

    • If a parameter is the operand of a unary arithmetic operator, the parameter's type is decided by the context of the operator.

    • If an arithmetic operator has no type-determining context, the derived type for any parameters involved is DOUBLE PRECISION. This can happen, for example, when the parameter is a top-level node in a SELECT list, or when it is part of a comparison operator.

    • A parameter which is an operand of a character string operator has the same derived type as the aggregated type of the other operands. If all operands of the operator are parameters, the derived type is VARCHAR; its collation is determined by the value of collation_connection.

    • A parameter which is an operand of a temporal operator has type DATETIME if the operator returns a DATETIME, TIME if the operator returns a TIME, and DATE if the operator returns a DATE.

    • A parameter which is an operand of a binary comparison operator has the same derived type as the other operand of the comparison.

    • A parameter that is an operand of a ternary comparison operator such as BETWEEN has the same derived type as the aggregated type of the other operands.

    • If all operands of a comparison operator are parameters, the derived type for each of them is VARCHAR, with collation determined by the value of collation_connection.

    • A parameter that is an output operand of any of CASE, COALESCE, IF, IFNULL, or NULLIF has the same derived type as the aggregated type of the operator's other output operands.

    • If all output operands of any of CASE, COALESCE, IF, IFNULL, or NULLIF are parameters, or they are all NULL, the type of the parameter is decided by the context of the operator.

    • If the parameter is an operand of any of CASE, COALESCE(), IF, or IFNULL, and has no type-determining context, the derived type for each of the parameters involved is VARCHAR, and its collation is determined by the value of collation_connection.

    • A parameter which is the operand of a CAST() has the same type as specified by the CAST().

    • If a parameter is an immediate member of a SELECT list that is not part of an INSERT statement, the derived type of the parameter is VARCHAR, and its collation is determined by the value of collation_connection.

    • If a parameter is an immediate member of a SELECT list that is part of an INSERT statement, the derived type of the parameter is the type of the corresponding column into which the parameter is inserted.

    • If a parameter is used as source for an assignment in a SET clause of an UPDATE statement or in the ON DUPLICATE KEY UPDATE clause of an INSERT statement, the derived type of the parameter is the type of the corresponding column which is updated by the SET or ON DUPLICATE KEY UPDATE clause.

    • If a parameter is an argument of a function, the derived type depends on the function's return type.

    For some combinations of actual type and derived type, an automatic repreparation of the statement is triggered. Repreparation does not occur if any of the following conditions are true:

    • NULL is used as the actual parameter value.

    • A parameter is an operand of a CAST(). (Instead, a cast to the derived type is attempted, and an exception raised if the cast fails.)

    • A parameter is a string. (In this case, an implicit CAST(? AS derived_type) is performed.)

    • The derived type and actual type of the parameter are both INTEGER and have the same sign.

    • The parameter's derived type is DECIMAL and its actual type is either DECIMAL or INTEGER.

    • The derived type is DOUBLE and the actual type is any numeric type.

    • Both the derived type and the actual type are string types.

    • If the derived type is temporal and the actual type is temporal. Exceptions: The derived type is TIME and the actual type is not TIME; the derived type is DATE and the actual type is not DATE.

    • The derived type is temporal and the actual type is numeric.

    For cases other than those just listed, the statement is reprepared and the actual parameter types are used instead of the derived parameter types.

    These rules also apply to a user variable referenced in a prepared statement.

    Using a different data type for a given parameter or user variable within a prepared statement for executions of the statement subsequent to the first execution causes the statement to be reprepared. This is less efficient; it may also lead to the parameter's (or variable's) actual type to vary, and thus for results to be inconsistent, with subsequent executions of the prepared statement. For these reasons, it is advisable to use the same data type for a given parameter when re-executing a prepared statement.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#examples","title":"Examples","text":"
    > create table t13 (a int primary key);\n> insert into t13 values (1);\n> select * from t13 where 3 in (select (1+1) union select 1);\nEmpty set (0.01 sec)\n\n> select * from t13 where 3 in (select (1+2) union select 1);\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.01 sec)\n\n> prepare st_18492 from 'select * from t13 where 3 in (select (1+1) union select 1)';\nQuery OK, 0 rows affected (0.00 sec)\n\n> execute st_18492;\nEmpty set (0.01 sec)\n\n> prepare st_18493 from 'select * from t13 where 3 in (select (2+1) union select 1)';\nQuery OK, 0 rows affected (0.00 sec)\n\n> execute st_18493;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.00 sec)\n\n> deallocate prepare st_18492;\nQuery OK, 0 rows affected (0.00 sec)\n\n> deallocate prepare st_18493;\nQuery OK, 0 rows affected (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/","title":"SHOW ACCOUNTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#description","title":"Description","text":"

    Lists the meta information and statistics for the accounts created.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#syntax","title":"Syntax","text":"
    > SHOW ACCOUNTS;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#meta-information-of-account","title":"Meta information of account","text":"Column Name Details Type Date Source ACCOUNT_NAME Account name varchar mo_account ADMIN_NAME The default administrator name is created varchar In the mo_user table under each account CREATED Created time timestamp mo_account STATUS Status, OPEN or SUSPENDED varchar mo_account SUSPENDED_TIME Suspended time timestamp mo_account DB_COUNT the number of databases bigint unsigned mo_tables TABLE_COUNT the number of tables bigint unsigned mo_tables ROW_COUNT Total line number bigint unsigned sum(mo_table_rows()) SIZE Total space used (MB) decimal(29,3) sum(mo_table_size(mt.reldatabase,mt.relname) COMMENT COMMENT information at creation time varchar mo_account"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#examples","title":"Examples","text":"
    mysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status | suspended_time | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| sys          | root       | 2023-02-14 06:58:15 | open   | NULL           |        8 |          57 |      2681 | 0.351 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n1 row in set (0.14 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/","title":"SHOW COLLATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#description","title":"Description","text":"

    This statement lists collations supported by MatrixOne. By default, the output from SHOW COLLATION includes all available collations. The LIKE clause, if present, indicates which collation names to match. The WHERE clause can be given to select rows using more general conditions.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#syntax","title":"Syntax","text":"
    > SHOW COLLATION\n    [LIKE 'pattern' | WHERE expr]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#examples","title":"Examples","text":"
    mysql> show collation;\n+-------------+---------+------+----------+---------+\n| Collation   | Charset | Id   | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 |   46 | Yes      |       1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n\nmysql> show collation like '%';\n+-------------+---------+------+----------+---------+\n| Collation   | Charset | Id   | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 |   46 | Yes      |       1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n\nmysql> show collation where 'Charset'='utf8mb4';\n+-------------+---------+------+----------+---------+\n| Collation   | Charset | Id   | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 |   46 | Yes      |       1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/","title":"SHOW COLUMNS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#description","title":"Description","text":"

    SHOW COLUMNS displays information about the columns in a given table.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#syntax","title":"Syntax","text":"
    > SHOW [FULL] {COLUMNS}\n    {FROM | IN} tbl_name\n    [{FROM | IN} db_name]\n    [LIKE 'pattern' | WHERE expr]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(\ncol1 int comment 'First column',\ncol2 float comment '\"%$^&*()_+@!',\ncol3 varchar comment 'ZD5lTndyuEzw49gxR',\ncol4 bool comment ''\n);\nmysql> show columns from t1;\n+-------+----------------+------+------+---------+-------+-------------------+\n| Field | Type           | Null | Key  | Default | Extra | Comment           |\n+-------+----------------+------+------+---------+-------+-------------------+\n| col1  | INT            | YES  |      | NULL    |       | First column      |\n| col2  | FLOAT          | YES  |      | NULL    |       | \"%$^&*()_+@!      |\n| col3  | VARCHAR(65535) | YES  |      | NULL    |       | ZD5lTndyuEzw49gxR |\n| col4  | BOOL           | YES  |      | NULL    |       |                   |\n+-------+----------------+------+------+---------+-------+-------------------+\n4 rows in set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/","title":"SHOW CREATE PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#description","title":"Description","text":"

    Returns the SQL statement when PUBLICATION was created.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#syntax","title":"Syntax","text":"
    SHOW CREATE PUBLICATION pubname;\u0005\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#examples","title":"Examples","text":"
    create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\nmysql> alter publication pub3 account add accx;\nshow create publication pub3;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show create publication pub3;\n+-------------+-----------------------------------------------------------------------+\n| Publication | Create Publication                                                    |\n+-------------+-----------------------------------------------------------------------+\n| pub3        | CREATE PUBLICATION `pub3` DATABASE `t` ACCOUNT `acc0`, `acc1`, `accx` |\n+-------------+-----------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/","title":"SHOW CREATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#description","title":"Description","text":"

    This statement shows the CREATE TABLE statement that creates the named table.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#syntax","title":"Syntax","text":"
    > SHOW CREATE TABLE tbl_name\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#examples","title":"Examples","text":"
    drop table if exists t1;\ncreate table t1(\ncol1 int comment 'First column',\ncol2 float comment '\"%$^&*()_+@!',\ncol3 varchar comment 'ZD5lTndyuEzw49gxR',\ncol4 bool comment ''\n);\nmysql> show create table t1;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                                                                     |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1    | CREATE TABLE `t1` (\n`col1` INT DEFAULT NULL COMMENT 'First column',\n`col2` FLOAT DEFAULT NULL COMMENT '\"%$^&*()_+@!',\n`col3` VARCHAR(65535) DEFAULT NULL COMMENT 'ZD5lTndyuEzw49gxR',\n`col4` BOOL DEFAULT NULL\n) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/","title":"SHOW CREATE VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#description","title":"Description","text":"

    This statement shows the CREATE VIEW statement that creates the named view.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#syntax","title":"Syntax","text":"
    > SHOW CREATE VIEW view_name\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#examples","title":"Examples","text":"
    create table test_table(col1 int, col2 float, col3 bool, col4 Date, col5 varchar(255), col6 text);\ncreate view test_view as select * from test_table;\nmysql> show create view test_view;\n+-----------+---------------------------------------------------+\n| View      | Create View                                       |\n+-----------+---------------------------------------------------+\n| test_view | create view test_view as select * from test_table |\n+-----------+---------------------------------------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/","title":"SHOW DATABASES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#description","title":"Description","text":"

    SHOW DATABASES lists the databases on the MatrixOne. SHOW SCHEMAS is a synonym for SHOW DATABASES. The LIKE clause, if present, indicates which database names to match. The WHERE clause can be given to select rows using more general conditions.

    MatrixOne implements databases as directories in the data directory, so this statement simply lists directories in that location.

    Database information is also available from the INFORMATION_SCHEMA SCHEMATA table.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#syntax","title":"Syntax","text":"
    > SHOW {DATABASES | SCHEMAS}\n    [LIKE 'pattern' | WHERE expr]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#examples","title":"Examples","text":"
    create database demo_1;\n\nmysql> show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| mo_task            |\n| information_schema |\n| mysql              |\n| system_metrics     |\n| system             |\n| demo_1         |\n| mo_catalog         |\n+--------------------+\n7 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/","title":"SHOW FUNCTION STATUS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#description","title":"Description","text":"

    SHOW FUNCTION STATUS displays information about all functions in the database, including function name, database name, creation time, etc.

    The SHOW FUNCTION STATUS command only shows user-defined functions, not system functions.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#syntax","title":"Syntax","text":"
    > SHOW FUNCTION STATUS\n    [LIKE 'pattern' | WHERE expr]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#explanations","title":"Explanations","text":"

    LIKE 'pattern' is an optional argument to filter the functions to display. pattern is a string that can use % and _ wildcards. For example, to display all functions starting with my_function, the following command can be used:

    SHOW FUNCTION STATUS LIKE 'my_function%';\n

    The output will include the function name, database name, type, creation time, and modification time.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#examples","title":"Examples","text":"
    mysql> create function twosum (x float, y float) returns float language sql as 'select $1 + $2' ;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> create function mysumtable(x int) returns int language sql as 'select mysum(test_val, id) from tbl1 where id = $1';\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> create function helloworld () returns int language sql as 'select id from tbl1 limit 1';\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> show function status;\n+------+------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| Db   | Name       | Type     | Definer | Modified            | Created             | Security_type | Comment | character_set_client | collation_connection | Database Collation |\n+------+------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| aab  | twosum     | FUNCTION | root    | 2023-03-27 06:25:41 | 2023-03-27 06:25:41 | DEFINER       |         | utf8mb4              | utf8mb4_0900_ai_ci   | utf8mb4_0900_ai_ci |\n| aab  | mysumtable | FUNCTION | root    | 2023-03-27 06:25:51 | 2023-03-27 06:25:51 | DEFINER       |         | utf8mb4              | utf8mb4_0900_ai_ci   | utf8mb4_0900_ai_ci |\n| aab  | helloworld | FUNCTION | root    | 2023-03-27 06:25:58 | 2023-03-27 06:25:58 | DEFINER       |         | utf8mb4              | utf8mb4_0900_ai_ci   | utf8mb4_0900_ai_ci |\n+------+------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n3 rows in set (0.00 sec)\n\nmysql> show function status like 'two%';\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| Db   | Name   | Type     | Definer | Modified            | Created             | Security_type | Comment | character_set_client | collation_connection | Database Collation |\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| aab  | twosum | FUNCTION | root    | 2023-03-27 06:25:41 | 2023-03-27 06:25:41 | DEFINER       |         | utf8mb4              | utf8mb4_0900_ai_ci   | utf8mb4_0900_ai_ci |\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/","title":"SHOW GRANTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#description","title":"Description","text":"

    Use the SHOW GRANTS statement to display all grant information for a user. This would display privileges that were assigned to the user using the GRANT command.

    SHOW GRANTS requires the SELECT privilege privileges to query all tables in the mo_catalog database, except to display privileges and roles for the current user.

    To name the account or role for SHOW GRANTS, use the same format as for the GRANT statement, for example:

    show grants for 'root'@'localhost';\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#syntax","title":"Syntax","text":"
    > SHOW GRANTS FOR {username[@hostname] | rolename};\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#examples","title":"Examples","text":"
    > create role role1;\n> grant all on table *.* to role1;\n> grant create table, drop table on database *.* to role1;\n> create user user1 identified by 'pass1';\n> grant role1 to user1;\n> show grants for 'user1'@'localhost';\n+--------------------------------------------------------+\n| Grants for user1@localhost                             |\n+--------------------------------------------------------+\n| GRANT connect ON account  `user1`@`localhost`          |\n| GRANT table all ON table *.* `user1`@`localhost`       |\n| GRANT create table ON database *.* `user1`@`localhost` |\n| GRANT drop table ON database *.* `user1`@`localhost`   |\n+--------------------------------------------------------+\n4 rows in set (0.00 sec)\n\nmysql> show grants for ROLE role1;\n+--------------------------------------------+\n| Grants for role1                           |\n+--------------------------------------------+\n| GRANT table all ON table *.* `role1`       |\n| GRANT create table ON database *.* `role1` |\n| GRANT drop table ON database *.* `role1`   |\n+--------------------------------------------+\n3 rows in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/","title":"SHOW INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#description","title":"Description","text":"

    SHOW INDEX returns table index information.

    SHOW INDEX returns the following fields:

    Fields Description Table The name of the table. Non_unique 0 if the index cannot contain duplicates, 1 if it can. Key_name The name of the index. If the index is the primary key, the name is always PRIMARY. Seq_in_index The column sequence number in the index, starting with 1. Column_name The column name. See also the description for the Expression column. Collation How the column is sorted in the index. This can have values A (ascending), D (descending), or NULL (not sorted). Cardinality An estimate of the number of unique values in the index. To update this number, run ANALYZE TABLE or (for MyISAM tables) myisamchk -a.Cardinality is counted based on statistics stored as integers, so the value is not necessarily exact even for small tables. The higher the cardinality, the greater the chance that MySQL uses the index when doing joins. Sub_part The index prefix. That is, the number of indexed characters if the column is only partly indexed, NULL if the entire column is indexed. Note: Prefix limits are measured in bytes. However, prefix lengths for index specifications in CREATE TABLE, ALTER TABLE, and CREATE INDEX statements are interpreted as number of characters for nonbinary string types (CHAR, VARCHAR, TEXT) and number of bytes for binary string types (BINARY, VARBINARY, BLOB). Take this into account when specifying a prefix length for a nonbinary string column that uses a multibyte character set. Packed Indicates how the key is packed. NULL if it is not. Null Contains YES if the column may contain NULL values and '' if not. Index_type The index method used (BTREE, FULLTEXT, HASH, RTREE). Comment Information about the index not described in its own column, such as disabled if the index is disabled. Visible Whether the index is visible to the optimizer. Expression For a nonfunctional key part, Column_name indicates the column indexed by the key part and Expression is NULL.For a functional key part, Column_name column is NULL and Expression indicates the expression for the key part."},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#syntax","title":"Syntax","text":"
    > SHOW {INDEX | INDEXES}\n    {FROM | IN} tbl_name\n    [{FROM | IN} db_name]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#explanations","title":"Explanations","text":"

    An alternative to tbl_name FROM db_name syntax is db_name.tbl_name.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#examples","title":"Examples","text":"
    CREATE TABLE show_01(sname varchar(30),id int);\nmysql> show INDEX FROM show_01;\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n| Table   | Non_unique | Key_name   | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment          | Visible | Expression |\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n| show_01 |          0 | id         |            1 | id          | A         |           0 | NULL     | NULL   | YES  |            |                  | YES     | NULL       |\n| show_01 |          0 | sname      |            1 | sname       | A         |           0 | NULL     | NULL   | YES  |            |                  | YES     | NULL       |\n| show_01 |          0 | __mo_rowid |            1 | __mo_rowid  | A         |           0 | NULL     | NULL   | NO   |            | Physical address | NO      | NULL       |\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n3 rows in set (0.02 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/","title":"SHOW PROCESSLIST","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#description","title":"Description","text":"

    SHOW PROCESSLIST is used to view a list of currently executing threads (also known as a process list), providing information about all active connections and executing queries on the MatrixOne server.

    SHOW PROCESSLIST is used to monitor and manage activities in the database, identify potential issues, help diagnose query performance problems, and aid in decision-making to optimize database operations:

    • Monitoring Database Activity: By executing SHOW PROCESSLIST, you can view the queries and operations currently running in the database in real time. This is useful for monitoring database activity and promptly identifying potential performance issues. You can see which queries are running, their status, and whether there are long-running or blocked queries, as well as information about locks, deadlocks, or resource contention.

    • Terminating Queries: By examining the process list, you can identify the query ID of a specific query that needs to be terminated and then use the KILL command to stop that particular query. This is beneficial for controlling long-running queries or resolving deadlock situations.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#syntax","title":"Syntax","text":"
    > SHOW PROCESSLIST;\n

    The explanations for the queried table structure are as follows:

    Column Name Data Type Constraint Remarks node_id varchar not null Node ID uniquely identifies different nodes in the database cluster. In MatrixOne, a node corresponds to a CN (Compute Node). Note: - In the single-node version of MatrixOne, there is usually only one node and all processes run on this node, so all processes have the same node_id. - In the distributed version of MatrixOne, each node has a unique node_id. System tenants can view the node_id corresponding to the nodes where all executing threads run. In contrast, non-system tenants can only see the node_id corresponding to the nodes where threads executing for their tenant are running. conn_id uint32 not null Connection ID used to identify different database connections. To terminate a specific database connection, use the KILL CONNECTION conn_id; command. Each connection in the database is assigned a unique conn_id for identification. Note: System tenants can view all conn_id, while non-system tenants can only see conn_id for their tenant. session_id varchar not null Session ID account varchar not null account Note: Under the system, account, sessions, and account names can be viewed. Non-system accounts can only view sessions and account names of their accounts. user varchar not null User host varchar not null Hostname of client-server db varchar Database name session_start varchar Session start time command varchar not null Command type, e.g., COM_QUERY info varchar Current or previous SQL statement txn_id varchar not null Current or previous transaction ID statement_id varchar Current or previous statement ID statement_type varchar Current or previous statement type query_type varchar Query type, e.g., DDL, DML, etc. sql_source_type varchar SQL source type, e.g., external_sql, internal_sql, etc. query_start varchar Query start time"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#examples","title":"Examples","text":"
    mysql> SHOW PROCESSLIST;\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n| node_id                              | conn_id | session_id                           | account | user                                 | host           | db      | session_start              | command   | info                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | txn_id                           | statement_id                         | statement_type   | query_type | sql_source_type | query_start                |\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf |       1 | 97f85f80-2a5c-11ee-ae41-5ad2460dea4f | sys     | mo_logger                            | 127.0.0.1:6001 |         | 2023-07-24 19:59:27.005755 | COM_QUERY | COMMIT                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |                                  |                                      |                  |            | internal_sql    |                            |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf |       8 | a056b7c6-2a5c-11ee-ae42-5ad2460dea4f | sys     | root                                 | 127.0.0.1:6001 | aab     | 2023-07-24 19:59:41.045851 | COM_QUERY | SHOW PROCESSLIST                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | c207acc30a19432f8d3cbac387c6e520 | 421aadaa-2a68-11ee-ae5b-5ad2460dea4f | Show Processlist | Other      | external_sql    | 2023-07-24 21:22:56.907266 |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf |      24 | 0915f91a-2a63-11ee-ae4d-5ad2460dea4f | sys     | 3bf028e0-aa43-4917-b82f-ed533c0f401e | 127.0.0.1:6001 | mo_task | 2023-07-24 20:45:33.762679 | COM_QUERY | select\ntask_id,\ntask_metadata_id,\ntask_metadata_executor,\ntask_metadata_context,\ntask_metadata_option,\ntask_parent_id,\ntask_status,\ntask_runner,\ntask_epoch,\nlast_heartbeat,\nresult_code,\nerror_msg,\ncreate_at,\nend_at\nfrom mo_task.sys_async_task where task_id>17 AND task_runner='dd1dccb4-4d3c-41f8-b482-5251dc7a41bf' AND task_status=1 order by task_id limit 3 |                                  |                                      |                  |            | internal_sql    |                            |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf |      36 | d8aa4060-2a67-11ee-ae59-5ad2460dea4f | sys     | 3bf028e0-aa43-4917-b82f-ed533c0f401e | 127.0.0.1:6001 | mo_task | 2023-07-24 21:20:00.009746 | COM_QUERY | select\ncron_task_id,\ntask_metadata_id,\ntask_metadata_executor,\ntask_metadata_context,\ntask_metadata_option,\ncron_expr,\nnext_time,\ntrigger_times,\ncreate_at,\nupdate_at\nfrom mo_task.sys_cron_task                                                                                                                                                                        |                                  |                                      |                  |            | internal_sql    |                            |\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n4 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/","title":"SHOW PUBLICATIONS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#description","title":"Description","text":"

    Returns a list of all PUBLICATION names and corresponding database names.

    For more information, you need have the authority of account administrator; check the system table mo_pubs for more parameters.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#syntax","title":"Syntax","text":"
    SHOW PUBLICATIONS;\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#examples","title":"Examples","text":"
    create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nmysql> show publications;\n+------+----------+\n| Name | Database |\n+------+----------+\n| pub3 | t        |\n+------+----------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/","title":"SHOW ROLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#description","title":"Description","text":"

    Lists the meta information of the roles created under your account, including role name, creator, creation time, and comments.

    Note: To query the role you are currently using, use the select current_role() statement.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#syntax","title":"Syntax","text":"
    > SHOW ROLES [LIKE 'pattern'];\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#examples","title":"Examples","text":"
    -- Show the roles currently under your account\nmysql> show roles;\n+-----------+---------+---------------------+----------+\n| ROLE_NAME | CREATOR | CREATED_TIME        | COMMENTS |\n+-----------+---------+---------------------+----------+\n| moadmin   |       0 | 2023-04-19 06:37:58 |          |\n| public    |       0 | 2023-04-19 06:37:58 |          |\n+-----------+---------+---------------------+----------+\n2 rows in set (0.01 sec)\n\n-- create a new role named rolex\nmysql> create role rolex;\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Show the roles currently under your account\nmysql> show roles;\n+-----------+---------+---------------------+----------+\n| ROLE_NAME | CREATOR | CREATED_TIME        | COMMENTS |\n+-----------+---------+---------------------+----------+\n| rolex     |       1 | 2023-04-19 06:43:29 |          |\n| moadmin   |       0 | 2023-04-19 06:37:58 |          |\n| public    |       0 | 2023-04-19 06:37:58 |          |\n+-----------+---------+---------------------+----------+\n3 rows in set (0.01 sec)\n\n-- Query the role you are currently using\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin        |\n+----------------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/","title":"SHOW SEQUENCES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#description","title":"Description","text":"

    SHOW SEQUENCES is used to view the name and list type of the current sequence list.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#syntax","title":"Syntax","text":"
    > SHOW SQUENCES\n       [WHERE expr]\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#examples","title":"Examples","text":"
    CREATE SEQUENCE s1 START 101;\nCREATE SEQUENCE s3 as smallint INCREMENT 10 MINVALUE -100 MAXVALUE 100 START 0 CYCLE;\nCREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\nmysql> show sequences;\n+--------+-----------+\n| Names  | Data Type |\n+--------+-----------+\n| s3     | SMALLINT  |\n| s1     | BIGINT    |\n| seq_id | BIGINT    |\n+--------+-----------+\n3 rows in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/","title":"SHOW STAGES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#description","title":"Description","text":"

    Display the data stage of the current database creation as a list.

    MatrixOne users use SHOW STAGES to view all the data stages of the current database and can choose a valid path to export the data to.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#syntax","title":"Syntax","text":"
    > SHOW STAGES [LIKE 'pattern']\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#examples","title":"Examples","text":"
    CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- Create internal data stage\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- Export data from table to the data stage\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- You can see your exported table in your local directory\n\n-- Display the data stage of the current database creation as a list.\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+---------+\n| STAGE_NAME | URL                         | STATUS  | COMMENT |\n+------------+-----------------------------+---------+---------+\n| stage1     | /tmp                        | ENABLED |         |\n+------------+-----------------------------+---------+---------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/","title":"SHOW SUBSCRIPTIONS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#description","title":"Description","text":"

    Returns a list of all subscription library names and source account names.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#syntax","title":"Syntax","text":"
    SHOW SUBSCRIPTIONS;\u0005\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#examples","title":"Examples","text":"
    Create database sub1 from sys publication pub1;\n\nmysql> create database sub1 from sys publication sys_pub_1;\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> show subscriptions;\n+------+--------------+\n| Name | From_Account |\n+------+--------------+\n| sub1 | sys          |\n+------+--------------+\n1 row in set (0.01 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/","title":"SHOW TABLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#description","title":"Description","text":"

    Shows the list of tables in the currently selected database.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#syntax","title":"Syntax","text":"
    > SHOW TABLES  [LIKE 'pattern' | WHERE expr | FROM 'pattern' | IN 'pattern']\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#examples","title":"Examples","text":"
    > SHOW TABLES;\n+---------------+\n| name          |\n+---------------+\n| clusters      |\n| contributors  |\n| databases     |\n| functions     |\n| numbers       |\n| numbers_local |\n| numbers_mt    |\n| one           |\n| processes     |\n| settings      |\n| tables        |\n| tracing       |\n+---------------+\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/","title":"SHOW VARIABLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#description","title":"Description","text":"

    SHOW VARIABLES shows the values of MatrixOne system variables.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#syntax","title":"Syntax","text":"
    > SHOW VARIABLES\n    [LIKE 'pattern']\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#explanations","title":"Explanations","text":"
    • With a LIKE clause, the statement displays only rows for those variables with names that match the pattern.

    • To get a list of variables whose name match a pattern, use the % wildcard character in a LIKE clause.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#examples","title":"Examples","text":"
    mysql> SHOW VARIABLES;\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n| Variable_name            | Value                                                                                                                 |\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n| auto_increment_increment | 1                                                                                                                     |\n| auto_increment_offset    | 1                                                                                                                     |\n| autocommit               | 1                                                                                                                     |\n| character_set_client     | utf8mb4                                                                                                               |\n| character_set_connection | utf8mb4                                                                                                               |\n| character_set_database   | utf8mb4                                                                                                               |\n| character_set_results    | utf8mb4                                                                                                               |\n| character_set_server     | utf8mb4                                                                                                               |\n| collation_connection     | default                                                                                                               |\n| collation_server         | utf8mb4_bin                                                                                                           |\n| completion_type          | NO_CHAIN                                                                                                              |\n| host                     | 0.0.0.0                                                                                                               |\n| init_connect             |                                                                                                                       |\n| interactive_timeout      | 28800                                                                                                                 |\n| license                  | APACHE                                                                                                                |\n| lower_case_table_names   | 0                                                                                                                     |\n| max_allowed_packet       | 16777216                                                                                                              |\n| net_write_timeout        | 60                                                                                                                    |\n| performance_schema       | 0                                                                                                                     |\n| port                     | 6001                                                                                                                  |\n| profiling                | 0                                                                                                                     |\n| query_result_maxsize     | 100                                                                                                                   |\n| query_result_timeout     | 24                                                                                                                    |\n| save_query_result        | 0                                                                                                                     |\n| sql_mode                 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |\n| sql_safe_updates         | 0                                                                                                                     |\n| sql_select_limit         | 18446744073709551615                                                                                                  |\n| system_time_zone         |                                                                                                                       |\n| testbotchvar_nodyn       | 0                                                                                                                     |\n| testbothvar_dyn          | 0                                                                                                                     |\n| testglobalvar_dyn        | 0                                                                                                                     |\n| testglobalvar_nodyn      | 0                                                                                                                     |\n| testsessionvar_dyn       | 0                                                                                                                     |\n| testsessionvar_nodyn     | 0                                                                                                                     |\n| time_zone                | SYSTEM                                                                                                                |\n| transaction_isolation    | REPEATABLE-READ                                                                                                       |\n| transaction_read_only    | 0                                                                                                                     |\n| tx_isolation             | REPEATABLE-READ                                                                                                       |\n| tx_read_only             | 0                                                                                                                     |\n| version_comment          | MatrixOne                                                                                                             |\n| wait_timeout             | 28800                                                                                                                 |\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n41 rows in set (0.01 sec)\n\nmysql> show variables like 'auto%';\n+--------------------------+-------+\n| Variable_name            | Value |\n+--------------------------+-------+\n| auto_increment_increment | 1     |\n| auto_increment_offset    | 1     |\n| autocommit               | 1     |\n+--------------------------+-------+\n3 rows in set (0.00 sec)\n\nmysql> show variables like 'auto_increment_increment';\n+--------------------------+-------+\n| Variable_name            | Value |\n+--------------------------+-------+\n| auto_increment_increment | 1     |\n+--------------------------+-------+\n1 row in set (0.00 sec)\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/","title":"SET ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#description","title":"Description","text":"

    Specifies the active/current primary role or secondary role for the session.

    The authorization to perform any SQL action other than creating objects can be provided by secondary roles.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#syntax","title":"Syntax","text":"
    > SET SECONDARY ROLE {\n    NONE\n  | ALL  \n}\nSET ROLE role\n
    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#explanations","title":"Explanations","text":"

    A role is a collection of permissions, and a user can correspond to multiple roles.

    For example, user1 has the primary role role1, secondary roles role2 and role3, role1 is granted the permissions pri1 and pri2; role2 is given the permission pri3; role3 is given the permission pri4, the permission comparison representation is as follows:

    User name Role name Privilege name user1 role1 pri1,pri2 role2 pri3 role3 pri4

    For a more intuitive understanding, you can refer to the following example:

    User Role Privilege Name Tom Application Developer Read Data, Write Data O&M expert Read data Database Administrator Administrator Privileges

    At this time, Tom's main role is an application developer, and Tom needs to call administrator authority, then Tom can use two methods:

    • To switch his role to database administrator, use the SET ROLE role statement.
    • To use all privileges of primary and secondary roles, use the SET SECONDARY ROLE ALL statement.

    The two statements are explained as follows:

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-secondary-role-all","title":"SET SECONDARY ROLE ALL","text":"

    The union of all roles of the user.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-secondary-role-none","title":"SET SECONDARY ROLE NONE","text":"

    Kicking all roles except the PRIMARY ROLE from the current session.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-role-role","title":"SET ROLE role","text":"

    Switching the current ROLE to a new role.

    "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#examples","title":"Examples","text":"
    > drop role if exists use_role_1,use_role_2,use_role_3,use_role_4,use_role_5;\n> drop user if exists use_user_1,use_user_2;\n> drop database if exists use_db_1;\n> create role use_role_1,use_role_2,use_role_3,use_role_4,use_role_5;\n> create database use_db_1;\n> create user use_user_1 identified by '123456' default role use_role_1;\n##grant the `select`, `insert` and `update` privileges of all tables to use_role_1\n> grant select ,insert ,update on table *.* to use_role_1;\n#grant all the privileges of database to use_role_2\n> grant all on database * to use_role_2;\n#grant the use_role_2 to use_user_1\n> grant use_role_2 to use_user_1;\n#create table named `use_table_1`\n> create table use_db_1.use_table_1(a int,b varchar(20),c double );\n#set user use_user_1 primary and secondary roles are all available\n> set secondary role all;\n#show the privileges of `use_user_1`\n> show grants for 'use_user_1'@'localhost';\n+-----------------------------------------------------------+\n| Grants for use_user_1@localhost                           |\n+-----------------------------------------------------------+\n| GRANT select ON table *.* `use_user_1`@`localhost`        |\n| GRANT insert ON table *.* `use_user_1`@`localhost`        |\n| GRANT update ON table *.* `use_user_1`@`localhost`        |\n| GRANT connect ON account  `use_user_1`@`localhost`        |\n| GRANT database all ON database * `use_user_1`@`localhost` |\n+-----------------------------------------------------------+\n5 rows in set (0.01 sec)\n#It can be seen that the `use_user_1` has the default privilege to connect to MatrixOne; it also has the `select`, `insert` and `update` privileges on all tables, and also has all the privileges on the database\n
    "},{"location":"MatrixOne/Reference/System-Parameters/configuration-settings/","title":"Boot Parameters for standalone installation","text":"

    There are three configuration files cn.toml, tn.toml and log.toml in the matrixone/etc/launch-tae-CN-tae-TN/ directory.

    The parameters contained in each configuration file are explained as follows:

    "},{"location":"MatrixOne/Reference/System-Parameters/configuration-settings/#cntoml","title":"cn.toml","text":"Parameters Description service-type = \"CN\" Node Type data-dir = \"./mo-data\" Default data directory [log] level = \"info\" Log level, can be modified to info/debug/error/faltal format = \"console\" Log format max-size = 512 Log default length [hakeeper-client] HAkeeper default address and port, not recommended to change service-addresses = [ \"127.0.0.1:32001\",] [metacache] Metadata Cache memory-capacity = \"512MB\" Set the cache size for metadata, default is 512MB. The data caching feature results in slower first-time queries, but subsequent queries will be faster. [[fileservice]] fileservice, not recommended to change name = \"LOCAL\" fileservice storage type, local storage backend = \"DISK\" fileservice backend, disk [[fileservice]] name = \"SHARED\" fileservice storage type, S3 backend = \"DISK\" fileservice backend, disk data-dir = \"mo-data/s3\" s3 storage data directory [fileservice.cache] memory-capacity = \"512MB\" cache memory size used by fileservice disk-capacity = \"8GB\" cache disk size used by fileservice disk-path = \"mo-data/file-service-cache\" fileservice disk cache path disk-min-evict-interval = \"7m\" Interval for disk cache recovery, in seconds (s) or minutes (m) disk-evict-target = 0.8 Target capacity for disk cache recovery, parameter is the ratio of template capacity to total capacity [[fileservice]] name = \"ETL\" fileservice storage type, ETL backend = \"DISK-ETL\" fileservice backend, DISK-ETL [observability] Observability parameter, disabled by default disableTrace = true disableMetric = true [cn] cn code number, cannot be modified uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" [cn.Engine] Storage engine of the cn node, distributed tae, cannot be modified type = \"distributed-tae\" [cn.txn] enable-sacrificing-freshness = false When set to true and push mode, this parameter does not guarantee that a transaction can see the latest committed data. Instead, it uses the latest Logtail commit timestamp received by the current CN as the transaction start time. This setting ensures that a transaction on the same database connection can see the data written by its previously committed transactions. enable-cn-based-consistency = false When the above parameter is set to true, it ensures external consistency on the same CN. When a transaction starts, it can see the data written by previously committed transactions."},{"location":"MatrixOne/Reference/System-Parameters/configuration-settings/#tntoml","title":"tn.toml","text":"Parameters Description service-type = \"TN\" Node Type data-dir = \"./mo-data\" Default data directory [log] level = \"info\" Log level, can be modified to info/debug/error/faltal format = \"console\" Log format max-size = 512 Log default length [hakeeper-client] HAkeeper default address and port, not recommended to change service-addresses = [ \"127.0.0.1:32001\",] [metacache] Metadata Cache memory-capacity = \"512MB\" Set the cache size for metadata, default is 512MB. The data caching feature results in slower first-time queries, but subsequent queries will be faster. [[fileservice]] fileservice, not recommended to change name = \"LOCAL\" fileservice storage type, local storage backend = \"DISK\" fileservice backend, disk [[fileservice]] name = \"SHARED\" fileservice storage type, S3 backend = \"DISK\" fileservice backend, disk data-dir = \"mo-data/s3\" s3 storage data directory [fileservice.cache] memory-capacity = \"512MB\" cache memory size used by fileservice disk-capacity = \"8GB\" cache disk size used by fileservice disk-path = \"mo-data/file-service-cache\" fileservice disk cache path disk-min-evict-interval = \"7m\" Interval for disk cache recovery, in seconds (s) or minutes (m) disk-evict-target = 0.8 Target capacity for disk cache recovery, parameter is the ratio of template capacity to total capacity [[fileservice]] name = \"ETL\" fileservice storage type, ETL backend = \"DISK-ETL\" fileservice backend, DISK-ETL [tn] uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" uuid of TN, cannot be modified [tn.Txn.Storage] The storage engine of the TN transaction backend, cannot be modified backend = \"TAE\" log-backend = \"logservice\" [tn.Txn] incremental-dedup = false If set to false, TN initiates deduplication for all data. If set to true, TN will only deduplicate primary key data after the snapshot timestamp. [tn.Ckp] the checkpoint related parameters of TN, not recommended to change flush-interval = \"60s\" internal refresh interval min-count = 100 Minimum number of checkpoints scan-interval = \"5s\" internal scan interval incremental-interval = \"180s\" checkpoint increment interval global-min-count = 60 The global minimum number of TN checkpoints [tn.LogtailServer] listen-address = \"0.0.0.0:32003\" logtail listening port service-address = \"127.0.0.1:32003\" logtail internal access address rpc-max-message-size = \"16KiB\" maximum rpc message size used by logtail rpc-payload-copy-buffer-size = \"16KiB\" rpc copy buffer size rpc-enable-checksum = true whether to enable rpc checksum logtail-collect-interval = \"2ms\" logtail statistics collection interval logtail-response-send-timeout = \"10s\" logtail sending timeout max-logtail-fetch-failure = 5 The maximum number of failures allowed by fetching logtail"},{"location":"MatrixOne/Reference/System-Parameters/configuration-settings/#logtoml","title":"log.toml","text":"Parameters Description service-type = \"LOG\" Node Type data-dir = \"./mo-data\" Default data directory [log] level = \"info\" Log level, can be modified to info/debug/error/faltal format = \"console\" Log format max-size = 512 Log default length [[fileservice]] fileservice configuration, not recommended to change name = \"LOCAL\" fileservice storage type, local storage backend = \"DISK\" fileservice backend media, disk [[fileservice]] name = \"SHARED\" fileservice storage type, S3 backend = \"DISK\" fileservice backend, disk data-dir = \"mo-data/s3\" s3 storage data directory [fileservice.cache] memory-capacity = \"512MB\" cache memory size used by fileservice disk-capacity = \"8GB\" cache disk size used by fileservice disk-path = \"mo-data/file-service-cache\" fileservice disk cache path disk-min-evict-interval = \"7m\" Interval for disk cache recovery, in seconds (s) or minutes (m) disk-evict-target = 0.8 Target capacity for disk cache recovery, parameter is the ratio of template capacity to total capacity [[fileservice]] name = \"ETL\" fileservice storage type, ETL backend = \"DISK-ETL\" fileservice backend, DISK-ETL [observability] Monitor parameters statusPort = 7001 Reserve the monitoring port of Prometheus enableTraceDebug = false Enable the dbug mode of the trace [hakeeper-client] HAkeeper default address and port, not recommended to change service-addresses = [ \"127.0.0.1:32001\",] [logservice] The parameters of logservice, cannot be modified deployment-id = 1 Deployment ID of logservice uuid = \"7c4dccb4-4d3c-41f8-b482-5251dc7a41bf\" Node ID of logservice raft-address = \"127.0.0.1:32000\" The address of the raft protocol logservice-address = \"127.0.0.1:32001\" logservice address gossip-address = \"127.0.0.1:32002\" The address of the gossip protocol gossip-seed-addresses = [\"127.0.0.1:32002\",] The root node address of the gossip protocol gossip-allow-self-as-seed = true Whether to allow the gossip protocol to use this node as a root node [logservice.BootstrapConfig] Bootstrap parameters, cannot be modified bootstrap-cluster = true Whether bootstrap cluster launchs num-of-log-shards = 1 The number of shards of logservice num-of-tn-shards = 1 The number of shards of tn num-of-log-shard-replicas = 1 The number of replicas of the logservice shard init-hakeeper-members = [ \"131072:7c4dccb4-4d3c-41f8-b482-5251dc7a41bf\",] Initialize members of hakeeper"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/","title":"Distributed Common Parameters Configuration","text":"

    In the matrixone/etc/launch-with-proxy/ directory, there are four configuration files: cn.toml, tn.toml, proxy.toml, and log.toml. The parameters contained in these configuration files are explained below:

    "},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#cntoml","title":"cn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#default-parameters","title":"Default Parameters","text":"

    The cn.toml file contains the following default parameters:

    Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [cn] cn node, not editable / port-base Starting port number used by \"cn\". Find an available port for internal services by incrementing from this base port number, continuously checking the next 20 ports port-base = 18000 service-host Service connection address used for registration with HAKeeper service-host = \"127.0.0.1\" [cn.frontend] Frontend configuration section port Port for MatrixOne to listen on and for client connections port = 6001 host Listening IP address host = \"0.0.0.0\" [fileservice.s3] S3 File service configuration section bucket S3 bucket name bucket = \"my-bucket\" key-prefix S3 key prefix key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#extended-parameters","title":"Extended Parameters","text":"

    In the cn.toml file, you can also customize and add the following configuration parameters:

    Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"log1.log\" [cn.frontend] Frontend configuration section unix-socket Listen on Unix domain socket unix-socket = \"/tmp/mysql.sock\" lengthOfQueryPrinted Console output query length lengthOfQueryPrinted = 200000 enableTls Enable TLS enableTls = false tlsCaFile Client SSL CA list file path tlsCaFile = '' tlsCertFile Client X509 PEM format key file path tlsCertFile = '' tlsKeyFile Client X509 PEM format key file path tlsKeyFile = '' saveQueryResult Save query results saveQueryResult = false queryResultTimeout Query result timeout queryResultTimeout = 24 queryResultMaxsize Maximum query result size queryResultMaxsize = 100 lowerCaseTableNames Case sensitivity of identifiers. The default value is 1, which means case-insensitive lowerCaseTableNames = 1 [cn.Txn] Transaction configuration section isolation Transaction isolation level. This parameter configures the isolation level on the node (cn). The isolation level defines how transactions behave when dealing with concurrent operations. By default, if the isolation level (Isolation) is not set and the transaction mode (Mode) is set to optimistic, the isolation level will be set to Serializable Isolation (SI). When the transaction mode is pessimistic, the isolation level will be set to Read Committed Isolation (RC). Default: RC isolation = \"RC\" mode Transaction mode. This parameter configures the transaction mode on the node (cn). The transaction mode defines how operations and concurrency are handled in transactions. Valid values are optimistic and pessimistic, with the default being pessimistic. mode = \"pessimistic\" [fileservice.s3] endpoint S3 endpoint address endpoint = \"s3.amazonaws.com\" [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" disk-path Disk cache path disk-path = \"/var/matrixone/cache\" disk-capacity Disk cache capacity disk-capacity = \"8GB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. statusPort = 7001 enableMetricToProm Enable metric service. If set to true, metric service will be enabled enableMetricToProm = false disableMetric Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to disableMetric = false disableTrace Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data disableTrace = false longQueryTime Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#tntoml","title":"tn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#default-parameters_1","title":"Default Parameters","text":"

    The tn.toml file contains the following default parameters:

    Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [dn] TN node, not editable uuid Unique identifier of TN, not editable uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" port-base Starting port number used by \"TN\". Find an available port for internal services by incrementing from this base port number, continuously checking the next 20 ports port-base = 19000 service-host Service connection address used for registration with HAKeeper service-host = \"0.0.0.0\" [fileservice.s3] S3 File service configuration section bucket S3 bucket name bucket = \"my-bucket\" key-prefix S3 key prefix key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#extended-parameters_1","title":"Extended Parameters","text":"

    In the tn.toml file, you can also customize and add the following configuration parameters:

    | Parameter |

    Explanation | Example | |-------------------|-------------------------------------------|---------------------------| | [log] | Log configuration section | | | format | Log save format as JSON or other | format = \"console\" | | filename | Log filename | filename = \"log1.log\" | | [dn.LogtailServer]| Logtail server configuration section | | | rpc-enable-checksum| Enable RPC checksum | rpc-enable-checksum = false| | [fileservice.s3] | | | | endpoint | S3 endpoint address | endpoint = \"s3.amazonaws.com\"| | [fileservice.cache]| File service cache configuration section | | | memory-capacity | Cache memory size | memory-capacity = \"512MB\" | | disk-path | Disk cache path | disk-path = \"/var/matrixone/cache\"| | disk-capacity | Disk cache capacity | disk-capacity = \"8GB\"| | [observability] | Observability parameters | | | host | Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. | host = \"0.0.0.0\" | | statusPort | Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. | statusPort = 7001 | | enableMetricToProm | Enable metric service. If set to true, metric service will be enabled | enableMetricToProm = false| | disableMetric | Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to | disableMetric = false | | disableTrace | Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data | disableTrace = false | | longQueryTime | Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. | longQueryTime = 1.0 |

    "},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#logtoml","title":"log.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#default-parameters_2","title":"Default Parameters","text":"

    The log.toml file contains the following default parameters:

    Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [logservice] Logservice configuration section uuid Unique identifier of Logservice, not editable uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" data-dir Default data directory data-dir = \"./mo-data/logservice\" [fileservice.s3] S3 File service configuration section bucket S3 bucket name bucket = \"my-bucket\" key-prefix S3 key prefix key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#extended-parameters_2","title":"Extended Parameters","text":"

    In the log.toml file, you can also customize and add the following configuration parameters:

    Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"log1.log\" [logservice.BootstrapConfig] num-of-log-shards num-of-log-shards = 0 num-of-tn-shards num-of-tn-shards = 0 num-of-log-shard-replicas num-of-log-shard-replicas = 0 [fileservice.s3] endpoint S3 endpoint address endpoint = \"s3.amazonaws.com\" [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" disk-path Disk cache path disk-path = \"/var/matrixone/cache\" disk-capacity Disk cache capacity disk-capacity = \"8GB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. statusPort = 7001 enableMetricToProm Enable metric service. If set to true, metric service will be enabled enableMetricToProm = false disableMetric Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to disableMetric = false disableTrace Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data disableTrace = false longQueryTime Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#proxytoml","title":"proxy.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#default-parameters_3","title":"Default Parameters","text":"

    The proxy.toml file contains the following default parameters:

    Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [proxy] Proxy configuration section listen-address Listen address, default is 0.0.0.0:6009 listen-address = \"0.0.0.0:6009\" [fileservice.s3] S3 File service configuration section bucket S3 bucket name bucket = \"my-bucket\" key-prefix S3 key prefix key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#extended-parameters_3","title":"Extended Parameters","text":"

    In the proxy.toml file, you can also customize and add the following configuration parameters:

    Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"log1.log

    \" | | [proxy] | Proxy configuration section | | | rebalance-interval | Rebalance interval. This is the time interval between two rebalance operations. In distributed systems, rebalance operations are performed to balance the load between servers, ensuring each server has a similar workload. | rebalance-interval = 30 | | rebalance-disabled | Rebalance disabled flag. If set to true, the rebalance is disabled, and the system won't perform rebalance operations automatically. | rebalance-disabled = false| | rebalance-tolerance| Rebalance tolerance. This parameter indicates the tolerance level of the rebalance. When the number of connections exceeds the average value avg * (1 + tolerance), the connections will be migrated to other CN (Compute Node) servers. The tolerance value should be less than 1, defining to what extent the number of connections can exceed the average without triggering a rebalance operation. For example, if tolerance is set to 0.3 when the number of connections on a server exceeds 30% of the average connection count, rebalance operations will migrate connections to other servers to balance the load. | rebalance-tolerance = 0.3 | | [fileservice.s3] | | | | endpoint | S3 endpoint address | endpoint = \"s3.amazonaws.com\"| | [fileservice.cache]| File service cache configuration section | | | memory-capacity | Cache memory size | memory-capacity = \"512MB\" | | disk-path | Disk cache path | disk-path = \"/var/matrixone/cache\"| | disk-capacity | Disk cache capacity | disk-capacity = \"8GB\"| | [observability] | Observability parameters | | | host | Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. | host = \"0.0.0.0\" | | statusPort | Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. | statusPort = 7001 | | enableMetricToProm | Enable metric service. If set to true, metric service will be enabled | enableMetricToProm = false| | disableMetric | Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to | disableMetric = false | | disableTrace | Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data | disableTrace = false | | longQueryTime | Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. | longQueryTime = 1.0 |

    "},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/","title":"Standalone Common Parameters Configuration","text":"

    Four configuration files are in the matrixone/etc/launch/ directory: cn.toml, tn.toml, proxy.toml, and log.toml, used to configure standard parameters.

    "},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#cntoml","title":"cn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#default-parameters","title":"Default Parameters","text":"

    The cn.toml file contains the following default parameters:

    Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [cn] cn node, not editable / port-base Starting port number used by \"cn\", continuously finding 20 available ports for internal services starting from this port number port-base = 18000 service-host Service connection address used for registration to HAKeeper service-host = \"127.0.0.1\" [cn.frontend] Frontend configuration section port Port for MatrixOne to listen and for client connections port = 6001 host Listening IP address host = \"0.0.0.0\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#extended-parameters","title":"Extended Parameters","text":"

    In the cn.toml file, you can also customize and add the following configuration parameters:

    Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"mo.log\" [cn.frontend] Frontend configuration section unix-socket Listen to Unix domain interface unix-socket = \"/tmp/mysql.sock\" lengthOfQueryPrinted Console output query length lengthOfQueryPrinted = 200000 enableTls Enable TLS enableTls = false tlsCaFile Client SSL CA list file path tlsCaFile = '' tlsCertFile Client X509 PEM format key file path tlsCertFile = '' tlsKeyFile Client X509 PEM format key file path tlsKeyFile = '' saveQueryResult Save query results saveQueryResult = false queryResultTimeout Query result timeout time queryResultTimeout = 24 queryResultMaxsize Query result maximum size queryResultMaxsize = 100 lowerCaseTableNames Identifier case sensitivity, the default parameter value is 1, indicating case insensitivity lowerCaseTableNames = 1 [cn.Txn] Transaction configuration section isolation Transaction isolation level, used to configure the transaction isolation level on the \"cn\" node. The isolation level defines the behavior of transactions during concurrent operations. By default, if the isolation level (Isolation) is not set, it will be set to Serializable Isolation (SI) when the transaction mode (Mode) is set to optimistic and to Read Committed Isolation (RC) when the transaction mode is set to pessimistic. Default: RC isolation = \"RC\" mode Transaction mode configures the transaction mode on the \"cn\" node. The transaction mode defines how operations and concurrency are handled in a transaction. Possible values are optimistic and pessimistic, with the default value being optimistic. mode = \"optimistic\" [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. statusPort = 7001 enableMetricToProm Enable metric service. If set to true, metric service will be enabled enableMetricToProm = false disableMetric Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to disableMetric = false disableTrace Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data disableTrace = false longQueryTime Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#tntoml","title":"tn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#default-parameters_1","title":"Default Parameters","text":"

    The tn.toml file contains the following default parameters:

    Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [dn] TN node, not editable uuid Unique identifier of TN, not editable uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" port-base Starting port number used by \"TN\", continuously finding 20 available ports for internal services starting from this port number port-base = 19000 service-host Service connection address used for registration to HAKeeper service-host = \"0.0.0.0\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#extended-parameters_1","title":"Extended Parameters","text":"

    In the tn.toml file, you can also customize and add the following configuration parameters:

    Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"tn.log\" [dn.LogtailServer] Logtail Server configuration section rpc-enable-checksum Enable RPC checksum rpc-enable-checksum = false [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically

    Provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. | statusPort = 7001 | | enableMetricToProm | Enable metric service. If set to true, metric service will be enabled | enableMetricToProm = false| | disableMetric | Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to | disableMetric = false | | disableTrace | Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data | disableTrace = false | | longQueryTime | Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. | longQueryTime = 1.0 |

    "},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#logtoml","title":"log.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#default-parameters_2","title":"Default Parameters","text":"

    The log.toml file contains the following default parameters:

    Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [logservice] Logservice configuration section uuid Unique identifier of Logservice, not editable uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" data-dir Default data directory data-dir = \"./mo-data\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#extended-parameters_2","title":"Extended Parameters","text":"

    In the log.toml file, you can also customize and add the following configuration parameters:

    Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"log1.log\" [logservice] Logservice configuration section logservice-address Logservice address logservice-address = \"0.0.0.0:32000\" raft-address Raft address raft-address = \"0.0.0.0:32001\" gossip-address Gossip address gossip-address = \"0.0.0.0:32002\" gossip-seed-addresses Gossip seed node addresses gossip-seed-addresses = \" \" [LogtailServer.BootstrapConfig] LogtailServer bootstrap configuration section init-hakeeper-members Initial HAKeeper members init-hakeeper-members = \" \" [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. statusPort = 7001 enableMetricToProm Enable metric service. If set to true, metric service will be enabled enableMetricToProm = false disableMetric Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to disableMetric = false disableTrace Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data disableTrace = false longQueryTime Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#proxytoml","title":"proxy.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#default-parameters_3","title":"Default Parameters","text":"

    The proxy.toml file contains the following default parameters:

    Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [proxy] Proxy configuration section listen-address Listen address, default is 0.0.0.0:6009 listen-address = \"0.0.0.0:6009\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#extended-parameters_3","title":"Extended Parameters","text":"

    In the proxy.toml file, you can also customize and add the following configuration parameters:

    Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"proxy.log\" [proxy] Proxy configuration section rebalance-interval Rebalance interval. This is the time interval between two rebalance operations. In distributed systems, rebalance operations are performed to balance the load between servers and ensure each server has a similar workload. rebalance-interval = 30 rebalance-disabled Rebalance disable flag. If set to true, the rebalance will be disabled, and the system will not automatically perform rebalance operations. rebalance-disabled = false rebalance-tolerance Rebalance tolerance. This parameter indicates the tolerance of the rebalance. When the number of connections exceeds the average value avg * (1 + tolerance), the connections will be migrated to other CN (compute node) servers. The tolerance value should be less than 1, defining to what extent the number of connections can exceed the average value without triggering a rebalance operation. For example, suppose tolerance is set to 0.3 when a server's connections exceed 30% of the average connection count. In that case, the rebalance operation will migrate connections to other servers to balance the load. rebalance-tolerance = 0.3 [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" [observability] Observability parameters

    | | | host | Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. | host = \"0.0.0.0\" | | statusPort | Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. | statusPort = 7001 | | enableMetricToProm | Enable metric service. If set to true, metric service will be enabled | enableMetricToProm = false| | disableMetric | Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to | disableMetric = false | | disableTrace | Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data | disableTrace = false | | longQueryTime | Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. | longQueryTime = 1.0 |

    "},{"location":"MatrixOne/Reference/System-Parameters/system-parameter/","title":"System Parameters Overview","text":"

    In MatrixOne, various database system parameters are involved, some configured through configuration files and take effect only during startup. Such parameters are referred to as static parameters.

    Another type is parameters that can be dynamically configured on the client and take effect immediately. These are referred to as dynamic parameters. Both parameters are used to configure and control the behavior of the MatrixOne server.

    Dynamic parameter modifications can be done at the session and global levels.

    • Global Level Parameter Configuration: Pertains to parameter configuration for the current tenant in MatrixOne. These parameters affect all new sessions connected to this tenant. Global parameters are persistently stored in the metadata table mo_catalog.mo_mysql_compatbility_mode when the MatrixOne server starts, and changes to global parameters will take effect on the next login.

    • Session Level Parameter Configuration: Pertains to parameter configuration for an individual MatrixOne connection. These parameters only affect the behavior of that connection. When the connection is established, session parameters are read from mo_catalog.mo_mysql_compatbility_mode and can be configured for the current connection using client commands. The session parameter configuration will be reset to the default values when the connection is closed.

    It's worth noting that MatrixOne is a multi-tenant database, and the set global command will only affect the current tenant.

    "},{"location":"MatrixOne/Reference/System-Parameters/system-parameter/#reference-documentation","title":"Reference Documentation","text":"

    For documentation on static parameters, you can refer to:

    • Standalone Common Parameters Configuration
    • Distributed Common Parameters Configuration

    For documentation on dynamic parameters, you can refer to:

    • System Variables Overview
    • Custom Variables
    "},{"location":"MatrixOne/Reference/Variable/custom-variable/","title":"Setting custom variable","text":"

    In MatrixOne, custom variables are a mechanism for storing and manipulating values. Custom variables can be set through the the'SET'statement, and the value can be kept unchanged throughout the session. You can customize variables through the SET command and use it in SQL. The specific syntax is as follows:

    SET @variable_name = value;\n

    @variable_name is the name of the custom variable, and value is the value to be assigned to the variable. Once defined, the variable can be used in the SQL statement instead of the actual value.

    For example, the following statement will define a variable named @max_salary and set it to 100000:

    SET @max_salary = 100000;\n--View the value set by the @max_salary variable\nmysql> select @max_salary;\n+-------------+\n| @max_salary |\n+-------------+\n| 100000      |\n+-------------+\n1 row in set (0.01 sec)\n

    When using a custom variable, you can include it in an SQL statement and reference it as @variable_name. For example, the following statement will return all employee records whose salary is less than @max_salary:

    SELECT * FROM employees WHERE salary < @max_salary;\n

    You can affect the result of an SQL query by changing the value of a custom variable. For example, the following statement will change the value of @max_salary and return a new query result:

    SET @max_salary = 80000;\nSELECT * FROM employees WHERE salary < @max_salary;\n

    It should be noted that custom variables only remain valid in the current session, and when the session ends, the variables will be deleted and released. In addition, variable names must start with the @ symbol and are case-sensitive.

    "},{"location":"MatrixOne/Reference/Variable/custom-variable/#simple-example","title":"Simple Example","text":"

    Now let's define two variables, a and b:

    > SET  @a=2, @b=3;\nQuery OK, 0 rows affected (0.00 sec)\n\n> select @a;\n+------+\n| @a   |\n+------+\n|    2 |\n+------+\n1 row in set (0.00 sec)\n\n> select @b;\n+------+\n| @b   |\n+------+\n|    3 |\n+------+\n1 row in set (0.00 sec)\n

    Using custom variables in SQL:

    > create table t1(a int,b varchar(1));\nQuery OK, 0 rows affected (0.02 sec)\n\n> insert into t1 values(@a,@b);\nQuery OK, 1 row affected (0.02 sec)\n\n> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 | 3    |\n+------+------+\n1 row in set (0.01 sec)\n

    Note

    The variables a and b are both ints here. If you want a string of 2 or 3, it is recommended to use SET @a ='2', @b='3';.

    "},{"location":"MatrixOne/Reference/Variable/custom-variable/#mysql-compatibility","title":"MySQL compatibility","text":"

    MatrixOne supports the session level, which is the same as MySQL support.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/","title":"lower_case_table_names support","text":"

    There are 5 different modes for the MatrixOne case sensitivity, and the case parameter lower_case_table_names can be set to 0, 1, 2, 3, or 4.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#parameter-explanation","title":"Parameter Explanation","text":""},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-0","title":"Setting Parameter Value to 0","text":"

    Setting lower_case_table_names to 0 stores identifiers as the original strings, and name comparisons are case sensitive.

    Examples

    set global lower_case_table_names = 0;\ncreate table Tt (Aa int);\ninsert into Tt values (1), (2), (3);\n\nmysql> select Aa from Tt;\n+------+\n| Aa   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
    "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-1","title":"Setting Parameter Value to 1","text":"

    Setting lower_case_table_names to 1 stores identifiers as lowercase, and name comparisons are case insensitive.

    Examples

    set global lower_case_table_names = 1;\ncreate table Tt (Aa int);\ninsert into Tt values (1), (2), (3);\n\nmysql> select Aa from Tt;\n+------+\n| aa   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
    set global lower_case_table_names = 1;\ncreate table t(a int);\ninsert into t values(1), (2), (3);\n\n-- Column aliases display the original string when the result set is returned, but name comparisons are case insensitive, as shown in the following example:\nmysql> select a as Aa from t;\n+------+\n| Aa   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
    "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-2","title":"Setting Parameter Value to 2","text":"

    Setting lower_case_table_names to 2 stores identifiers as the original strings, and name comparisons are case insensitive.

    Examples

    set global lower_case_table_names = 2;\ncreate table Tt (Aa int);\ninsert into tt values (1), (2), (3);\n\nmysql> select AA from tt;\n+------+\n| Aa   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
    "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-3","title":"Setting Parameter Value to 3","text":"

    Setting lower_case_table_names to 3 stores identifiers as uppercase, and name comparisons are case insensitive.

    Examples

    set global lower_case_table_names = 3;\ncreate table Tt (Aa int);\ninsert into Tt values (1), (2), (3);\n\nmysql> select Aa from Tt;\n+------+\n| AA   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
    "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-4","title":"Setting Parameter Value to 4","text":"

    Setting lower_case_table_names to 4 stores identifiers with `` as the original strings and case sensitive, while others are converted to lowercase.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#configuration-parameters","title":"Configuration Parameters","text":"
    • To configure globally, insert the following code in the cn.toml configuration file before starting MatrixOne:
    [cn.frontend]\nlowerCaseTableNames = \"0\" // default is 1\n# 0 stores identifiers as the original strings and name comparisons are case sensitive\n# 1 stores identifiers as lowercase and name comparisons are case insensitive\n# 2 stores identifiers as the original strings and name comparisons are case insensitive\n# 3 stores identifiers as uppercase and name comparisons are case insensitive\n# 4 stores identifiers with `` as the original strings and case sensitive, while others are converted to lowercase\n

    When configuring globally, each cn needs to be configured if multiple cns are started. For configuration file parameter instructions, seeBoot Parameters for standalone installation.

    Note

    Currently, you can only set the parameter to 0 or 1. However, the parameter 2,3 or 4 is not supported.

    • To enable saving query results only for the current session:
    set global lower_case_table_names = 1;\n

    When creating a database, MatrixOne automatically obtains the value of lower_case_table_names as the default value for initializing the database configuration.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#features-that-are-different-from-mysql","title":"Features that are different from MySQL","text":"

    MatrixOne lower_case_table_names is set to 1 by default and only supports setting the value to 0 or 1.

    The default value in MySQL:

    • On Linux: 0. Table and database names are stored on disk using the letter case specified in the CREATE TABLE or CREATE DATABASE statement. Name comparisons are case-sensitive.
    • On Windows: 1. It means that table names are stored in lowercase on disk, and name comparisons are not case-sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.
    • On macOS: 2. Table and database names are stored on disk using the letter case specified in the CREATE TABLE or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case-sensitive.
    "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#constraints","title":"Constraints","text":"

    MatrixOne system variable lower_case_table_names does not currently support setting values 2, 3, or 4.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/","title":"save_query_result Support","text":"

    After enabling save_query_result, MatrixOne will save the query results.

    Three parameters affect the saving of query results:

    • save_query_result: enables/disables the saving of query results.
    • query_result_timeout: sets the time for saving query results.
    • query_result_maxsize: sets the maximum size of a single query result.
    "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#enable-save_query_result","title":"Enable save_query_result","text":"

    Enable saving query results for the current session only:

    -- The default is off\nset global save_query_result = on  
    • If you need to enable it globally, you can modify the configuration file cn.toml before starting MatrixOne, insert the following code, and save it:
    [cn.frontend]\nsaveQueryResult = \"on\"  // The default is off\n
    "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#set-the-saving-time","title":"Set the saving time","text":"

    Set the save time unit to hours.

    • Enable query_result_timeout only for the current session:
    -- The default is 24\nset global query_result_timeout = 48\n
    • If you need to enable it globally, you can modify the configuration file cn.toml before starting MatrixOne, insert the following code, and save it:
    [cn.frontend]\nqueryResultTimeout = 48  //The default is 24\n

    Note: If the save time is set to a shorter value than the previous one, it will not affect the previous save results.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#set-the-maximum-value-of-a-single-query-result","title":"Set the maximum value of a single query result","text":"

    Set the maximum unit of a single query result to MB.

    • Set the maximum value of query results for the current session only:
    -- The default is 100\nset global query_result_maxsize = 200\n
    • If you need to enable it globally, you can modify the configuration file cn.toml before starting MatrixOne, insert the following code, and save it:
    [cn.frontend]\nqueryResultMaxsize = 200 // The default is 100\n

    Note: If the maximum value of a single query result is set smaller than the previous setting, it will not affect the size of the last saved results.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#query-metadata-information","title":"Query metadata information","text":"

    You can use the following SQL statement to query metadata information:

    select * from meta_scan(query_id) as u;\n\u5f53\u524d account_id\nselect query_id from meta_scan(query_id) as u;\n

    The metadata information is as follows:

    Column Name Type Remarks query_id uuid query result ID statement text SQL statement executed account_id uint32 account ID role_id uint32 role ID result_path text The path to save the query results, the default is the mo-data/s3 path of the matrixone folder, if you want to modify the default path, you need to modify data-dir = \"mo-data/s3\" in the configuration file . For a description of configuration file parameters, see Common Parameter Configuration created_time timestamp creation time result_size float Result size in MB. tables text tables used by SQL user_id uint32 user ID expired_time timestamp timeout of query result column_map text If the query has a column result name with the same name, the result scan will remap the column name"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#save-query-results","title":"Save query results","text":"

    You can store query results locally or in S3.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#syntax","title":"Syntax","text":"
    MODUMP QUERY_RESULT query_id INTO s3_path\n[FIELDS TERMINATED BY 'char']\n[ENCLOSED BY 'char']\n[LINES TERMINATED BY 'string']\n[header 'bool']\n[MAX_FILE_SIZE unsigned_number]\n
    • query_id: A string of UUID.

    • s3_path: the path where the query result file is saved. The default is the mo-data/s3 path in the matrixone folder. If you need to modify the default path, you must modify data-dir = \"mo-data/s3\" in the configuration file. For more information about configuration file parameters, see Common Parameter Configuration

    root@rootMacBook-Pro 02matrixone % cd matrixone/mo-data\nroot@rootMacBook-Pro mo-data % ls\ntn-data         etl             local           logservice-data s3\n

    Note: If you need to export the csv file. The path needs to start with etl:.

    • [FIELDS TERMINATED BY 'char']: optional parameter. Field delimiter, the default is single quote '.

    • [ENCLOSED BY 'char']: optional parameter. Fields include symbols, which default to double quotes \".

    • [LINES TERMINATED BY 'string']: optional parameter. The end of line symbol, the default is the newline symbol \\n.

    The first row of the csv file is a header row for each column name.- [header 'bool']: optional parameter. The bool type can choose true or false.

    • [MAX_FILE_SIZE unsigned_number]: optional parameter. The maximum file size of the file is in KB. The default is 0.
    "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#example","title":"Example","text":"
    -- Enable save_query_result\nmysql> set global save_query_result = on;\n-- Set the saving time to 24 hours\nmysql> set global query_result_timeout = 24;\n-- Set the maximum value of a single query result to 100M\nmysql> set global query_result_maxsize = 200;\n-- Create a table and insert datas\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\n-- You can check the table structure to confirm that the inserted data is correct\nmysql> select a from t1;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.16 sec)\n-- Query the most recently executed query ID in the current session\nmysql> select last_query_id();\n+--------------------------------------+\n| last_query_id()                      |\n+--------------------------------------+\n| c187873e-c25d-11ed-aa5a-acde48001122 |\n+--------------------------------------+\n1 row in set (0.12 sec)\n-- Get the query results for this query ID\nmysql> select * from result_scan('c187873e-c25d-11ed-aa5a-acde48001122') as t;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.01 sec)\n-- Check the metadata for this query ID\nmysql> select * from meta_scan('c187873e-c25d-11ed-aa5a-acde48001122') as t;\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| query_id                             | statement        | account_id | role_id | result_path                                                         | create_time         | result_size          | tables | user_id | expired_time        | ColumnMap |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| c187873e-c25d-11ed-aa5a-acde48001122 | select a from t1 |          0 |       0 | SHARED:/query_result/sys_c187873e-c25d-11ed-aa5a-acde48001122_1.blk | 2023-03-14 19:45:45 | 0.000003814697265625 | t1     |       1 | 2023-03-15 19:45:45 | t1.a -> a |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n1 row in set (0.00 sec)\n\n-- Save query results locally\nMODUMP QUERY_RESULT c187873e-c25d-11ed-aa5a-acde48001122 INTO 'etl:your_local_path';\n
    "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#constraints","title":"Constraints","text":"

    MatrixOne only supports on saving the query results of SELECT and SHOW.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/","title":"SQL Mode","text":"

    sql_mode is a system parameter in MatrixOne, which specifies the mode in which MatrixOne executes queries and operations. sql_mode can affect the syntax and semantic rules of MatrixOne, thus altering the behavior of MatrixOne's SQL queries. This article will introduce the purpose of sql_mode, standard modes, and how to set sql_mode.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#why-set-sql_mode","title":"Why set sql_mode","text":"

    sql_mode can control the behavior of MatrixOne, including how to handle NULL values, perform insert operations, and sort and compare strings. It can ensure strict compliance with SQL standards and avoid non-standard behavior. In addition, sql_mode can help developers better identify errors and potential issues in SQL statements.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#default-modes-of-sql_mode","title":"Default modes of sql_mode","text":"

    The following are the standard modes of sql_mode, which are also the default modes in MatrixOne:

    • ONLY_FULL_GROUP_BY: The GROUP BY clause is used to group query results and perform aggregate calculations on each group, such as COUNT, SUM, AVG, etc. In the GROUP BY clause, the specified columns are the grouping columns. Other columns can be identified in the SELECT list, including aggregate or non-aggregate function columns. Without the ONLY_FULL_GROUP_BY mode, if a non-aggregate function column is set in the SELECT list, MatrixOne will select any value that matches the GROUP BY column use it to calculate the aggregate function by default.

    Note

    If your table structure is complex and for ease of querying, you can disable the ONLY_FULL_GROUP_BY mode.

    • STRICT_TRANS_TABLES: When executing INSERT and UPDATE statements, an error will be reported if the data does not conform to the rules defined for the table.

    • NO_ZERO_IN_DATE: Prohibits inserting zero values into fields of type DATE or DATETIME.

    • NO_ZERO_DATE: Prohibits inserting or updating the field value of 0000-00-00 as a date or datetime type. The purpose of this mode is to avoid inserting invalid or illegal values into a date or datetime field and require the use of a valid date or datetime values. If such an operation is performed, an error will be reported. It should be noted that the NO_ZERO_DATE mode is only effective for insert or update operations. For existing 0000-00-00 values, they can still be queried and used.

    • ERROR_FOR_DIVISION_BY_ZERO: This mode throws an error when dividing by zero.

    • NO_ENGINE_SUBSTITUTION: This mode throws an error when executing ALTER TABLE or CREATE TABLE statements. The purpose of this mode is to force the use of the specified storage engine, preventing data inconsistencies or performance issues. The specified storage engine is unavailable or does not exist instead of automatically substituting it with another available storage engine. If automatic substitution of storage engines is desired, this mode can be removed from the sql_mode or set to other supported sql_mode methods. It is important to note that this mode only applies to ALTER TABLE or CREATE TABLE statements and does not affect the storage engine of existing tables.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#optional-modes-for-sql_mode","title":"Optional modes for sql_mode","text":"
    • ANSI: ANSI is a standard SQL language specification developed by ANSI (American National Standards Institute). In ANSI mode, SQL statements must comply with the ANSI SQL standard, which means that specific SQL language extensions or features specific to a particular database cannot be used.

    • ALLOW_INVALID_DATES: ALLOW_INVALID_DATES, also known as \"loose mode\" in MatrixOne SQL mode, allows the insertion of invalid dates in standard date format, such as '0000-00-00' or '2000-00-00'. This mode exists to be compatible with some earlier versions of MySQL and non-standard date formats. It is important to note that inserting invalid dates in ALLOW_INVALID_DATES mode can cause unexpected behavior, as invalid dates will not be handled appropriately. Therefore, it is always recommended to use the standard date format.

    • ANSI_QUOTES: ANSI_QUOTES is a strict mode in SQL mode, used to enforce SQL standards more strictly. In ANSI_QUOTES mode, MatrixOne treats double quotes as identifier quotes instead of string quotes. If you want to use double quotes to quote an identifier such as a table name or column name, you must use double quotes instead of single quotes. For example, the following SQL statement is correct in ANSI_QUOTES mode:

    SELECT \"column_name\" FROM \"table_name\";\n

    In the default SQL mode, double quotes will be interpreted as string quotes, resulting in incorrect syntax. Therefore, to use double quotes to quote identifiers, you must set MatrixOne to the ANSI_QUOTES mode.

    It should be noted that using the ANSI_QUOTES mode may cause SQL syntax incompatibility with other database systems because most other database systems use double quotes as string quotes rather than identifier quotes. Therefore, ANSI_QUOTES mode should be used cautiously when writing portable SQL statements.

    • HIGH_NOT_PRECEDENCE: HIGH_NOT_PRECEDENCE is called the \"high-priority NOT operator\" mode in MatrixOne SQL mode. In HIGH_NOT_PRECEDENCE mode, MatrixOne treats the NOT operator as a high-priority operator, meaning its priority is higher than most other operators. This means that if you use both the NOT operator and other operators in an SQL statement, MatrixOne will first calculate the result of the NOT operator and then calculate the results of the other operators. For example:
    SELECT * FROM table WHERE NOT column = 1 AND column2 = 'value';\n

    In HIGH_NOT_PRECEDENCE mode, MatrixOne will first calculate the result of NOT column = 1, and then calculate the result of column2 = 'value'. If the NOT operator is not correctly placed in the statement, it may result in unexpected results.

    It should be noted that in MatrixOne's default SQL mode, the NOT operator has the same priority as other operators. If you need to use the HIGH_NOT_PRECEDENCE mode, make sure to use parentheses in your SQL statements to clarify the priority.

    • IGNORE_SPACE: IGNORE_SPACE is referred to as the \"ignore space\" mode in MatrixOne SQL mode. In IGNORE_SPACE mode, MatrixOne ignores multiple spaces or tabs in an SQL statement and only considers one space or tab as a delimiter. This means that the following two SQL statements are equivalent in IGNORE_SPACE mode:
    SELECT * FROM my_table;\nSELECT*FROM my_table;\n

    The purpose of this mode is to make SQL statements more flexible and readable by allowing any number of spaces or tabs between keywords. However, it should be noted that in some cases, this mode may cause unexpected behavior, such as syntax errors when spaces or tabs are incorrectly placed in SQL functions or column names.

    By default, MatrixOne does not enable the IGNORE_SPACE mode. To enable this mode, you can use the SQL command SET sql_mode='IGNORE_SPACE' when connecting to MatrixOne.

    • NO_AUTO_VALUE_ON_ZERO: NO_AUTO_VALUE_ON_ZERO is called the \"no auto value on zero\" mode in MatrixOne SQL mode. In NO_AUTO_VALUE_ON_ZERO mode, when you insert a value of 0 into an auto-increment column, MatrixOne does not treat it as an auto-increment value but as a regular 0 value. This means that if you insert a value of 0 into an auto-increment column, the value of that column will not be automatically incremented but will remain 0 in NO_AUTO_VALUE_ON_ZERO mode. For example, the following SQL statement will not auto-increment the id column in NO_AUTO_VALUE_ON_ZERO mode:
    CREATE TABLE my_table (\nid INT(11) NOT NULL AUTO_INCREMENT,\nname VARCHAR(255) NOT NULL,\nPRIMARY KEY (id)\n);\n\nINSERT INTO my_table (id, name) VALUES (0, 'John');\n

    In the default SQL mode, when you insert a value of 0 into an auto-increment column, MatrixOne treats it as an auto-increment value and automatically increases it to the next available one. However, this may not be the desired behavior in some cases, so you can use the NO_AUTO_VALUE_ON_ZERO mode to disable it.

    If you use the NO_AUTO_VALUE_ON_ZERO mode, inserting data with a value of 0 may cause primary key duplicates or unique vital conflicts. So, extra attention is needed when you insert data.

    • NO_BACKSLASH_ESCAPES: NO_BACKSLASH_ESCAPES is also known as \"no backslash escapes\" mode in MatrixOne SQL mode. In NO_BACKSLASH_ESCAPES mode, MatrixOne does not treat the backslash as an escape character. This means that you cannot use the backslash to escape special characters, such as quotes or percent signs, in SQL statements. Instead, if you need to use these special characters in SQL statements, you must use other methods to escape them, such as using single quotes to represent double quotes in strings. For example, the following SQL statement will cause a syntax error in NO_BACKSLASH_ESCAPES mode:
    SELECT 'It's a nice day' FROM my_table;\n

    In the default SQL mode, MatrixOne allows backslashes to escape special characters, so backslashes can be used in SQL statements to run characters such as quotes and percent signs. However, in some cases, using backslash escapes may result in confusion or incorrect results, so the NO_BACKSLASH_ESCAPES mode can be used to prohibit this behavior.

    If you use the NO_BACKSLASH_ESCAPES mode, you must use other ways to escape special characters, which may make SQL statements more complex and difficult to understand. Therefore, it's necessary to consider when using this mode carefully.

    • NO_DIR_IN_CREATE: known as \"no directory in create\" mode in MatrixOne SQL mode, prohibits directory paths in CREATE TABLE statements. In the NO_DIR_IN_CREATE mode, MatrixOne will report an error when a directory path is used in the column definition of a CREATE TABLE statement, which includes a way that contains a file name. For example:
    CREATE TABLE my_table (\nid INT(11) NOT NULL AUTO_INCREMENT,\nname VARCHAR(255) NOT NULL,\ndatafile '/var/lib/MatrixOne/my_table_data.dat',\nPRIMARY KEY (id)\n);\n

    In the SQL statement above, the datafile column defines a path containing a file name, specifying the file storing table data. In the NO_DIR_IN_CREATE mode, MatrixOne does not allow the use of such directory paths in CREATE TABLE statements and requires that the file path and file name be defined separately, for example:

    CREATE TABLE my_table (\nid INT(11) NOT NULL AUTO_INCREMENT,\nname VARCHAR(255) NOT NULL,\ndatafile VARCHAR(255) NOT NULL,\nPRIMARY KEY (id)\n) DATA DIRECTORY '/var/lib/MatrixOne/' INDEX DIRECTORY '/var/lib/MatrixOne/';\n

    The data file column in the SQL statement above only defines the file name. In contrast, the file path is defined separately in the DATA DIRECTORY and INDEX DIRECTORY clauses of the CREATE TABLE statement.

    It should be noted that the NO_DIR_IN_CREATE mode does not affect column definitions in already created tables but only affects column definitions in CREATE TABLE statements. Therefore, when using this mode, you'll need careful consideration to ensure your SQL statements meet its requirements.

    • NO_UNSIGNED_SUBTRACTION: NO_UNSIGNED_SUBTRACTION is also also known as \"no unsigned subtraction\" mode in MatrixOne SQL mode, treats the result of the subtraction of unsigned integers with the subtraction operator (-) as a signed integer instead of an unsigned integer. This means that if the value of the unsigned integer is smaller than the subtrahend, the result will be a negative number instead of an unsigned integer. For example:
    SET SQL_MODE = 'NO_UNSIGNED_SUBTRACTION';\nSELECT CAST(1 AS UNSIGNED) - CAST(2 AS UNSIGNED);\n

    In the SQL statement above, the NO_UNSIGNED_SUBTRACTION mode treats CAST(1 AS UNSIGNED) - CAST(2 AS UNSIGNED) as a signed integer operation, so the result is -1 instead of the result of an unsigned integer operation, which is 4294967295.

    It should be noted that the NO_UNSIGNED_SUBTRACTION mode only affects unsigned integers that are subtracted using the subtraction operator (-), and other operations that use unsigned integers are not affected. If you need to perform many unsigned integer operations in MatrixOne, using appropriate type conversions in your code is recommended to avoid potential errors.

    • PAD_CHAR_TO_FULL_LENGTH: PAD_CHAR_TO_FULL_LENGTH is called the \"pad CHAR to full length\" mode in MatrixOne SQL mode.

    In the PAD_CHAR_TO_FULL_LENGTH mode, when you define a column of CHAR type, MatrixOne pads the column's value with spaces to make its length equal to the length specified for the column. This is because in MatrixOne, a column of CHAR type always occupies the defined length when stored, and any shortfall is filled with spaces. However, by default, the character set used by MatrixOne may be a multi-byte character set, so if spaces are used for padding, it may lead to incorrect length calculation.

    In the PAD_CHAR_TO_FULL_LENGTH mode, MatrixOne uses the maximum character length of the character set to pad the column of CHAR type to ensure that the length it occupies matches the defined size. This can avoid the problem of length calculation errors when using multi-byte character sets, but it also increases the use of storage space.

    It should be noted that the PAD_CHAR_TO_FULL_LENGTH mode only affects columns of CHAR type and does not affect columns of other varieties. If you need to use CHAR type columns in MatrixOne and correctly calculate the length of column values in a multi-byte character set, you can consider using the PAD_CHAR_TO_FULL_LENGTH mode.

    • PIPES_AS_CONCAT: PIPES_AS_CONCAT is called the \"pipes as concatenation\" mode in MatrixOne SQL mode. In the PIPES_AS_CONCAT mode, MatrixOne treats the vertical bar symbol (|) as a string concatenation rather than a bitwise operator. If you use the standing bar symbol to concatenate two strings, MatrixOne will treat them as one string instead of interpreting them as a binary bit operation.

    For example, the following SQL statement will return an error in the default mode because MatrixOne treats the vertical bar symbol as a bitwise operator:

    SELECT 'abc' | 'def';\n

    However, if the SQL mode is set to PIPES_AS_CONCAT, the above SQL statement will return the string 'abcdef'.

    Note that if your SQL statement contains the vertical bar symbol and it should be treated as a bitwise operator, do not use the PIPES_AS_CONCAT mode. Conversely, if you need to treat the vertical bar symbol as a string concatenation operator, use the PIPES_AS_CONCAT mode.

    • REAL_AS_FLOAT: REAL_AS_FLOAT is known as \"treat REAL type as FLOAT type\" mode in MatrixOne SQL mode.

    In REAL_AS_FLOAT mode, MatrixOne treats data of the REAL type as data of the FLOAT type. This means that MatrixOne uses the storage format of the FLOAT type to store data of the REAL type, rather than the more precise but also more space-consuming DOUBLE type storage format.

    Note that since the storage format of FLOAT type data occupies less space than DOUBLE type data, treating data of the REAL type as data of the FLOAT type can save storage space in some cases. However, doing so will also reduce the precision of the data, as FLOAT type data can only provide about 7 significant digits of precision, while DOUBLE type data can provide about 15 significant digits of precision.

    If you need to store high-precision floating-point data in MatrixOne, it is recommended not to use the REAL_AS_FLOAT mode and use DOUBLE type data to store it. If you do not require high data precision, you may consider using the REAL_AS_FLOAT mode to save storage space.

    • STRICT_ALL_TABLES: STRICT_ALL_TABLES is known as \"enable strict mode\" mode in MatrixOne SQL mode. In STRICT_ALL_TABLES mode, MatrixOne enables a series of strict checks to ensure that insert, update, and delete operations comply with constraints such as data types, NULL values, and foreign keys. Specifically, STRICT_ALL_TABLES mode performs the following operations:

    a. Rejects illegal values from being inserted into any column. b. Rejects NULL values from being inserted into non-NULL columns. c. Rejects values outside the allowed range from being inserted into any column. d. Rejects strings from being inserted into numeric type columns. e. Rejects date or time strings from being inserted into non-date or time type columns. f. Rejects values that exceed the length defined for CHAR, VARCHAR, and TEXT type columns from being inserted. g. Rejects values with mismatched data types from being inserted into foreign key columns.

    Note that enabling strict mode may cause problems for some old applications as they may assume that MatrixOne does not perform mandatory constraint checks. If you encounter problems when updating or migrating applications, consider disabling strict mode or modifying the application to comply with strict mode requirements.

    • TIME_TRUNCATE_FRACTIONAL: TIME_TRUNCATE_FRACTIONAL is known as \"truncate fractional part of time\" mode in MatrixOne SQL mode. In TIME_TRUNCATE_FRACTIONAL mode, MatrixOne truncates the fractional part of data of the TIME, DATETIME, and TIMESTAMP types, retaining only the integer part. This means that if you insert time data with a fractional part into a column of the TIME,DATETIME, or TIMESTAMP type, MatrixOne will truncate the fractional part and set it to 0.

    Note that enabling the TIME_TRUNCATE_FRACTIONAL mode may cause some loss of data precision, as truncating the fractional part may lose some critical time information. If you need to store and manipulate accurate time data, it is recommended not to use the TIME_TRUNCATE_FRACTIONAL mode.

    • TRADITIONAL: TRADITIONAL is a type of schema in the MatrixOne SQL mode, also known as the \"traditional\" mode. In TRADITIONAL mode, MatrixOne enables a series of strict checks to ensure that insert, update, and delete operations conform to SQL standard constraints. Specifically, the TRADITIONAL mode performs the following operations:

    a. Enables STRICT_TRANS_TABLES and STRICT_ALL_TABLES modes. b. Rejects INSERT statements that omit column names to ensure all columns are explicitly assigned values. c. Rejects inserting values with unclear data types into foreign key columns. d. Rejects inserting strings into numeric columns. e. Rejects inserting date or time strings into non-date or time-type columns. f. Rejects inserting values that exceed the defined length of CHAR, VARCHAR, and TEXT columns. g. Rejects using non-aggregate columns in the GROUP BY clause. h. Rejects using non-listed non-aggregate columns in the SELECT statement. i. It should be noted that enabling traditional mode may cause issues with some older applications that assume MatrixOne will not perform mandatory constraint checks. If you encounter problems when updating or migrating applications, consider the traditional disabling mode or modifying the applications to comply with traditional mode requirements.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#how-to-set-sql_mode","title":"How to set sql_mode","text":"

    The sql_mode can be set using the SET statement, for example:

    SET sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY';\n

    The sql_mode can also be set in the configuration file of MatrixOne, for example:

    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY;\n

    In the example settings above, MatrixOne will use the STRICT_TRANS_TABLES, NO_ZERO_IN_DATE, and ONLY_FULL_GROUP_BY modes.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#constraints","title":"Constraints","text":"

    MatrixOne is compatible with MySQL, except the ONLY_FULL_GROUP_BY mode; other modes of sql_mode only implement syntax support.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/","title":"Server System Variables","text":"

    MatrixOne server system variables are variables used to control or configure the behavior of the database engine or other components in the MatrixOne server. The values of these variables can be set and changed using the SET statement.

    System variables can be divided into two categories: Global variables and Session variables.

    • Global variables: Global variables apply to all connected sessions of the MatrixOne server. Their values are set when the MatrixOne server starts and remain unchanged until the server is shut down. Global variables are typically used to control the behavior of the MatrixOne server, such as specifying default backup and restore locations, the default language environment, and so on.

    • Session variables: Session variables apply only to the currently connected user's session of the MatrixOne server. Their values can be changed anytime during the user's connection and are automatically cleared when the user disconnects. Session variables are typically used to control session behavior, such as how to print the information displayed and specify transaction isolation levels.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#how-to-query-system-variables","title":"How to query system variables?","text":"

    You can use the following SQL to query:

    SHOW VARIABLES;\n

    This will list all system variables and their current values. If you only want to see system variables related to a specific topic, you can use the following syntax:

    SHOW VARIABLES LIKE '%theme%';\n

    This will list all system variables with names containing the word theme and their current values.

    Note: The LIKE operator is used for fuzzy matching query strings, with % representing zero or more arbitrary characters. Therefore, the above command will match any system variables with names containing the word theme.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#how-to-query-global-variables","title":"How to query global variables?","text":"

    You can use the following SQL to query:

    SHOW GLOBAL VARIABLES;\n

    This will list all global variables and their current values. If you only want to see global variables related to a specific topic, you can use the following syntax:

    SHOW GLOBAL VARIABLES LIKE '%theme%';\n

    This will list all global variables with names containing the word theme and their current values.

    Note: The LIKE operator is used for fuzzy matching query strings, with % representing zero or more arbitrary characters. Therefore, the above command will match any global variables with names containing the word theme.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#how-to-query-session-variables","title":"How to query session variables?","text":"

    You can use the following SQL to query:

    SHOW SESSION VARIABLES;\n

    This will list all session variables and their current values. If you only want to see session variables related to a specific topic, you can use the following syntax:

    SHOW SESSION VARIABLES LIKE '%theme%';\n

    This will list all session variables with names containing the word theme and their current values.

    Note: The LIKE operator is used for fuzzy matching query strings, with % representing zero or more arbitrary characters. Therefore, the above command will match any session variables with names containing the word theme.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#system-veariable-reference","title":"System Veariable Reference","text":"Variable_name Cmd-Line(Y/N) Option File(Y/N) Variable Type System Var(Y/N) Var Scope(Global/Both/Session) Dynamic(Y/N) Default Value Optional value auto_increment_increment Y N int Y Both Y 1 1-65535 auto_increment_offset Y N int Y Both Y 1 1-65535 autocommit Y N bool Y Both Y TRUE FALSE character_set_client Y N string Y Both Y \"utf8mb4\" character_set_connection Y N string Y Both Y \"utf8mb4\" character_set_database Y N string Y Both Y \"utf8mb4\" character_set_results Y N string Y Both Y \"utf8mb4\" character_set_server Y N string Y Both Y \"utf8mb4\" collation_connection Y N string Y Both Y \"default\" collation_server Y N string Y Both Y \"utf8mb4_bin\" completion_type Y N enum Y Both Y \"NO_CHAIN\" \"NO_CHAIN\",\"CHAIN\", \"RELEASE\" host Y N string Y Both N \"0.0.0.0\" init_connect Y N string Y Both Y \"\" interactive_timeout Y N int Y Both Y 28800 1-31536000 license Y N string Y Both N \"APACHE\" lower_case_table_names Y N int Y Both N 1 0-2 max_allowed_packet Y N int Y Both Y 16777216 1024-1073741824 net_write_timeout Y N int Y Both Y 60 1-31536000 performance_schema Y N int Y Both Y 0 0-1 port Y N int Y Both N 6001 0-65535 profiling Y N int Y Both Y 0 0-1 query_result_maxsize Y N uint Y Both Y 100 0-18446744073709551615 query_result_timeout Y N uint Y Both Y 24 0-18446744073709551615 save_query_result Y N bool Y Both Y FALSE TRUE sql_mode Y N set Y Both Y \"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\" \"ANSI\", \"TRADITIONAL\", \"ALLOW_INVALID_DATES\", \"ANSI_QUOTES\", \"ERROR_FOR_DIVISION_BY_ZERO\", \"HIGH_NOT_PRECEDENCE\", \"IGNORE_SPACE\", \"NO_AUTO_VALUE_ON_ZERO\", \"NO_BACKSLASH_ESCAPES\", \"NO_DIR_IN_CREATE\", \"NO_ENGINE_SUBSTITUTION\", \"NO_UNSIGNED_SUBTRACTION\", \"NO_ZERO_DATE\", \"NO_ZERO_IN_DATE\", \"ONLY_FULL_GROUP_BY\", \"PAD_CHAR_TO_FULL_LENGTH\", \"PIPES_AS_CONCAT\", \"REAL_AS_FLOAT\", \"STRICT_ALL_TABLES\", \"STRICT_TRANS_TABLES\", \"TIME_TRUNCATE_FRACTIONAL\" sql_safe_updates Y N int Y Both Y 0 0-1 sql_select_limit Y N uint Y Both Y 18446744073709551615 0-18446744073709551615 system_time_zone Y N string Y Both N \"\" time_zone Y N string Y Both N \"SYSTEM\" transaction_isolation Y N enum Y Both Y \"REPEATABLE-READ\" \"READ-UNCOMMITTED\", \"READ-COMMITTED\", \"REPEATABLE-READ\",\"REPEATABLE-READ\", \"SERIALIZABLE\" transaction_read_only Y N int Y Both Y 0 0-1 version_comment Y N string Y Both N \"MatrixOne\" wait_timeout Y N int Y Both Y 28800 1-2147483"},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#constraints","title":"Constraints","text":"
    1. To be compatible with MySQL, MatrixOne currently only implements syntax support for the system variables.
    2. MatrixOne is compatible with MySQL, except the ONLY_FULL_GROUP_BY mode; other modes of sql_mode only implement syntax support.
    "},{"location":"MatrixOne/Reference/Variable/system-variables/timezone/","title":"Time Zone Support","text":"

    The time zone in MatrixOne is decided by three time_zone system variables: global.time_zone, session.time_zone, global.system_time_zone.

    • global.system_time_zone indicates the server system time zone. When the server starts, it attempts to determine the time zone of the host machine and uses it to set the system_time_zone system variable.

    • The server current time zone. The global.time_zone system variable indicates the time zone the server currently is operating in. The initial time_zone value is 'SYSTEM', which indicates that the server time zone is the same as the system time zone.

    You can use the following statement to set the global server time_zone value at runtime. But it won't be effective in the current session, only if you exit and reconnect to MatrixOne you may see the time_zone affected.

    > SET GLOBAL time_zone = timezone;\n
    • Per-session time zones. Each client that connects has its own session time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement. This setting will only last during the current session.
    SET time_zone = timezone;\n

    You can use the following statement to view the current values of the global, client-specific and system time zones:

    > SELECT @@global.time_zone, @@session.time_zone, @@global.system_time_zone;\n+-------------+-------------+--------------------+\n| @@time_zone | @@time_zone | @@system_time_zone |\n+-------------+-------------+--------------------+\n| timezone    | +08:00      | CST                |\n+-------------+-------------+--------------------+\n1 row in set (0.01 sec)\n

    To set the format of the value of the time_zone:

    • The value SYSTEM indicates that the time zone should be the same as the server system time zone.

    • The value UTC indicates that the time zone is set to Coordinated Universal Time. Only UTC as time zone abbreviation is supported.

    • The value can be given as a string indicating an offset from UTC of the form HH:MM with a + or -, such as +10:00 or -06:00. The permitted range is -13:59 to +14:00, inclusive.

    The current session time zone setting affects the display and storage of time values that are zone-sensitive. This includes the values displayed by functions such as NOW() and values stored in and retrieved from TIMESTAMP columns.

    The session time zone setting does not affect values displayed by functions such as UTC_TIMESTAMP() or values in DATE, TIME, or DATETIME columns.

    Note

    Only the values of the Timestamp data type is affected by time zone. This is because the Timestamp data type uses the literal value + time zone information. Other data types, such as Datetime/Date/Time, do not have time zone information, thus their values are not affected by the changes of time zone.

    > SELECT @@global.time_zone, @@session.time_zone, @@global.system_time_zone;\n+-------------+-------------+--------------------+\n| @@time_zone | @@time_zone | @@system_time_zone |\n+-------------+-------------+--------------------+\n| SYSTEM      | SYSTEM      | CST                |\n+-------------+-------------+--------------------+\n1 row in set (0.00 sec)\n\n> create table t (ts timestamp, dt datetime);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> set @@time_zone = 'UTC';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> insert into t values ('2017-09-30 11:11:11', '2017-09-30 11:11:11');\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> set @@time_zone = '+08:00';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select * from t;\n+---------------------+---------------------+\n| ts                  | dt                  |\n+---------------------+---------------------+\n| 2017-09-30 19:11:11 | 2017-09-30 11:11:11 |\n+---------------------+---------------------+\n1 row in set (0.00 sec)\n

    In this example, no matter how you adjust the value of the time zone, the value of the Datetime data type is not affected. But the displayed value of the Timestamp data type changes if the time zone information changes. In fact, the value that is stored in the storage does not change, it's just displayed differently according to different time zone setting.

    Note

    Time zone is involved during the conversion of the value of Timestamp and Datetime, which is handled based on the current time_zone.

    "},{"location":"MatrixOne/Reference/Variable/system-variables/timezone/#changing-matrixone-time-zone","title":"Changing MatrixOne Time Zone","text":"
    1. View the current time and time zone:
    > select now();\n+----------------------------+\n| now()                      |\n+----------------------------+\n| 2022-10-14 18:38:27.876181 |\n+----------------------------+\n1 row in set (0.00 sec)\n\n> show variables like \"%time_zone%\";\n+------------------+--------+\n| Variable_name    | Value  |\n+------------------+--------+\n| system_time_zone | CST    |\n| time_zone        | SYSTEM |\n+------------------+--------+\n2 rows in set (0.00 sec)\n
    • time_zone indicates that MatrixOne uses the system time zone.

    • system_time_zone indicates the time zone which server system uses.

    • modify the time zone:

    set global time_zone = '+08:00';\nset time_zone = '+08:00';\n
    • set global time_zone = '+08:00';: Change the global time zone to Beijing time if we are in the east eight zones.
    • set time_zone = '+08:00';: Change the time zone of the current session.
    "},{"location":"MatrixOne/Reference/Variable/system-variables/timezone/#constraints","title":"Constraints","text":"

    Only (+/-)HH:MM form and UTC is supported for setting time_zone values.

    "},{"location":"MatrixOne/Release-Notes/release-timeline/","title":"MatrixOne Release Timeline","text":"

    This document shows all the released MatrixOne versions in reverse chronological order.

    Version Release Date v1.0.0-rc1 2023/8/24 v0.8.0 2023/6/30 v0.7.0 2023/2/23 v0.6.0 2022/11/29 v0.5.1 2022/8/19 v0.5.0 2022/7/18 v0.4.0 2022/5/5 v0.3.0 2022/3/10 v0.2.0 2022/1/6 v0.1.0 2021/10/24"},{"location":"MatrixOne/Release-Notes/v0.1.0/","title":"MatrixOne v0.1.0 Release Notes","text":"

    We are excited to announce the first release of MatrixOne 0.1.0 on 2021/10/24. Cheers!

    "},{"location":"MatrixOne/Release-Notes/v0.1.0/#docker","title":"Docker","text":"

    docker pull matrixorigin/matrixone:0.1.0

    "},{"location":"MatrixOne/Release-Notes/v0.1.0/#features","title":"Features","text":""},{"location":"MatrixOne/Release-Notes/v0.1.0/#sql","title":"SQL","text":"

    Following SQL statements are supported in this release.

    "},{"location":"MatrixOne/Release-Notes/v0.1.0/#ddl","title":"DDL","text":"
    • CREATE / DROP DATABASE
    • CREATE / DROP TABLE
    "},{"location":"MatrixOne/Release-Notes/v0.1.0/#dml","title":"DML","text":"
    • INSERT
    • LOAD DATA
    • SELECT
      • WHERE
      • GROUP BY
      • ORDER BY
      • LIMIT, OFFSET
    • SHOW
      • DATABASES
      • TABLES
    • USE
    "},{"location":"MatrixOne/Release-Notes/v0.1.0/#data-types","title":"Data Types","text":"
    • TINYINT / SMALLINT / INT / BIGINT, SIGNED / UNSIGNED
    • FLOAT / DOUBLE
    • CHAR / VARCHAR
    "},{"location":"MatrixOne/Release-Notes/v0.1.0/#operators","title":"Operators","text":"
    • <, >=, <, <=, <>, !=, =
    • BETWEEN \u2026 AND \u2026, NOT BETWEEN \u2026 AND \u2026
    • AND, &&, OR, ||
    • +, -, *, /, %, MOD, DIV, NEG
    • CAST
    "},{"location":"MatrixOne/Release-Notes/v0.1.0/#aggregation-functions","title":"Aggregation Functions","text":"
    • COUNT
    • SUM
    • AVG
    • MAX
    • MIN
    "},{"location":"MatrixOne/Release-Notes/v0.1.0/#database-engine","title":"Database Engine","text":"
    • MySQL dialect is supported.
    • Build-in Append only columnar engine(AOE) has been supported as the first fusion database engine.
    • Real-time analytical queries are supported.
    • Vectorized query execution engine, based on MPP solution, is introduced.
    • Part of the expression execution has been vectorized through SIMD instructions.
    • Distributed AOE with strong consistency guaranteed by RAFT has been supported.
    • The performance of replicated state machine has been greatly improved through the unique design of reusing RAFT log as well as Write-Ahead log without any redundancy.
    "},{"location":"MatrixOne/Release-Notes/v0.1.0/#contributors","title":"Contributors","text":"

    This release includes 453 commits by 16 authors. Special thanks to the first author:

    Yan Wenze (@nnsgmsone) Chen Mingsong(@m-schen) Jin Hai (@JinHai-CN) Jiang xinmeng (@jiangxinmeng1) Li Yang (@lignay) Lin Junhong (@iamlinjunhong) lni (@lni) Long Ran (@aunjgr) Peng Zhen (@daviszhen) Qin Shuqi (@sukki37) Shen JiangWei(@LeftHandCold) Wei Ziran (@w-zr) Xiong Jingjuan (@anitajjx) Xu Peng (@XuPeng-SH) Yan Wenze(@nnsgmsone) Zilong Zhou (@zzl200012) Zhang Yingfeng (@yingfeng)

    "},{"location":"MatrixOne/Release-Notes/v0.2.0/","title":"MatrixOne v0.2.0 Release Notes","text":"

    We are excited to announce MatrixOne 0.2.0 release on 2022/1/6. Cheers!

    "},{"location":"MatrixOne/Release-Notes/v0.2.0/#docker","title":"Docker","text":"

    docker pull matrixorigin/matrixone:0.2.0

    "},{"location":"MatrixOne/Release-Notes/v0.2.0/#features","title":"Features","text":"
    • Support automatic rebalancing for the built-in AOE columnar storage engine.
    • Introduce new SQL parser.
    • Introduce factorized SQL execution engine which is the fastest MPP in Golang.
    • Support CREATE / DROP INDEX.
    • Support PRIMARY KEY in CREATE TABLE.
    • Support more data types for SQL binary operators.
    • Support equi join with group by or aggregation statements.
    • Support new types of DATE and DATETIME.
    "},{"location":"MatrixOne/Release-Notes/v0.2.0/#database-engine","title":"Database Engine","text":"
    • For continuous table creation actions in a script, the parameter of pre-allocated-group-num should be set to a bigger value such in cluster scenarios. Otherwise, \"no available raft group\" may be notified during tables creation sequence.
    "},{"location":"MatrixOne/Release-Notes/v0.2.0/#contributors","title":"Contributors","text":"

    This release includes 243 commits by 21 authors.

    • BingLin Chang (@decster)
    • Chen Mingsong(@m-schen)
    • Nan Deng (@dengn)
    • Jin Hai (@JinHai-CN)
    • Jiang xinmeng (@jiangxinmeng1)
    • Li Yang (@lignay)
    • Lin Junhong (@iamlinjunhong)
    • lni (@lni)
    • Long Ran (@aunjgr)
    • Peng Zhen (@daviszhen)
    • Qin Shuqi (@sukki37)
    • Shen JiangWei(@LeftHandCold)
    • Jian Wang(@jianwan0214)
    • broccoliSpicy(@broccoliSpicy)
    • Ryan Wang(@wanglei4687)
    • Xiong Jingjuan (@anitajjx)
    • Xu Peng (@XuPeng-SH)
    • Yan Wenze(@nnsgmsone)
    • Yuesheng Li(@reusee)
    • Zilong Zhou (@zzl200012)
    • Zhang Yingfeng (@yingfeng)
    "},{"location":"MatrixOne/Release-Notes/v0.3.0/","title":"MatrixOne v0.3.0 Release Notes","text":"

    We are excited to announce MatrixOne 0.3.0 release on 2022/3/10. Cheers!

    "},{"location":"MatrixOne/Release-Notes/v0.3.0/#docker","title":"Docker","text":"

    docker pull matrixorigin/matrixone:0.3.0

    "},{"location":"MatrixOne/Release-Notes/v0.3.0/#features","title":"Features","text":"
    • Exports data into CSV file.
    • Introduces parallel execution and improve performance for projection query.
    • Introduces IN operator and allows you to specify multiple values in a WHERE clause.
    • Support NULLABLE column in group by expression.
    • Introduces new functions: round and floor.
    • Introduces a Chaos Testing framework for distributed system.
    "},{"location":"MatrixOne/Release-Notes/v0.3.0/#known-issues","title":"Known issues","text":"
    • For continuous table creation actions in a script, the parameter of pre-allocated-group-num should be set to a bigger value such in cluster scenarios. Otherwise, \"no available raft group\" may be notified during tables creation sequence.
    "},{"location":"MatrixOne/Release-Notes/v0.3.0/#contributors","title":"Contributors","text":"

    This release includes 157 commits by 21 authors.

    • broccoliSpicy(@broccoliSpicy)
    • Chen Mingsong(@m-schen)
    • hanfang (@aptend)
    • O2 (@ikenchina)
    • Jin Hai (@JinHai-CN)
    • Jiang xinmeng (@jiangxinmeng1)
    • Lin Junhong (@iamlinjunhong)
    • Long Ran (@aunjgr)
    • Nan Deng (@dengn)
    • Otter(@WenhaoKong2001)
    • Peng Zhen (@daviszhen)
    • Qin Shuqi (@sukki37)
    • Sundy Li(@sundy-li)
    • Shen JiangWei(@LeftHandCold)
    • Jian Wang(@jianwan0214)
    • Wan Hanbo(@wanhanbo )
    • Xu Peng (@XuPeng-SH)
    • Yan Wenze(@nnsgmsone)
    • Yuesheng Li(@reusee)
    • Zilong Zhou (@zzl200012)
    • Zhang Yingfeng (@yingfeng)
    "},{"location":"MatrixOne/Release-Notes/v0.3.0/#new-contributors","title":"New Contributors","text":"
    • @wanhanbo made their first contribution in https://github.com/matrixorigin/matrixone/pull/1600
    • @ikenchina made their first contribution in https://github.com/matrixorigin/matrixone/pull/1685
    • @sundy-li made their first contribution in https://github.com/matrixorigin/matrixone/pull/1704
    • @WenhaoKong2001 made their first contribution in https://github.com/matrixorigin/matrixone/pull/1838

    We appreciate your contribution! Welcome to MatrixOne community.

    "},{"location":"MatrixOne/Release-Notes/v0.3.0/#full-changelog","title":"Full Changelog","text":"

    https://github.com/matrixorigin/matrixone/compare/v0.2.0...v0.3.0

    "},{"location":"MatrixOne/Release-Notes/v0.4.0/","title":"MatrixOne v0.4.0 Release Notes","text":"

    We are excited to announce MatrixOne 0.4.0 release on 2022/5/5. Cheers!

    "},{"location":"MatrixOne/Release-Notes/v0.4.0/#docker","title":"Docker","text":"

    docker pull matrixorigin/matrixone:0.4.0

    "},{"location":"MatrixOne/Release-Notes/v0.4.0/#features","title":"Features","text":"
    • Support inner join with equality operator.
    • Support subquery within from clause.
    • Support decimal data type.
    • Support following builtin functions:
      • Mathematical: Abs, Log, Ln, Ceil, Exp, Power, Pi, Sin, Sinh, Cos, ACos, Tan, ATan, Cot
      • Datetime: Month, Weekday, Date, DayOfYear
      • String: Space, Reverse, Substring, Ltrim, Rtrim, StartsWith, EndsWith, Lpad, Rpad, Empty, LengthUTF8
    • Support following aggregate functions:
      • Bit_and, Bit_or, Bit_xor, Stddev_pop, Var
    "},{"location":"MatrixOne/Release-Notes/v0.4.0/#known-issues","title":"Known issues","text":"
    • For continuous table creation actions in a script, the parameter of pre-allocated-group-num should be set to a bigger value such in cluster scenarios. Otherwise, \"no available raft group\" may be notified during tables creation sequence.
    "},{"location":"MatrixOne/Release-Notes/v0.4.0/#contributors","title":"Contributors","text":"

    This release includes 253 commits by 50 authors.

    "},{"location":"MatrixOne/Release-Notes/v0.4.0/#new-contributors","title":"New Contributors","text":"
    • @BePPPower
    • @JackTan25
    • @Charlie17Li
    • @domingozhang
    • @Fungx
    • @JasonPeng1310
    • @jiajunhuang
    • @NTH19
    • @noneback
    • @RinChanNOWWW
    • @chaixuqing
    • @Y7n05h
    • @yuxubinchen
    • @adlternative
    • @ajian2002
    • @bxiiiiii
    • @coderzc
    • @e11jah
    • @fengttt
    • @florashi181
    • @hiyoyolumi
    • @jinfuchiang
    • @ouyuanning
    • @qingxinhome
    • @supermario1990
    • @whileskies
    • @xiw5
    • @yclchuxue
    • @ZtXavier

    We appreciate your contribution! Welcome to MatrixOne community.

    "},{"location":"MatrixOne/Release-Notes/v0.4.0/#full-changelog","title":"Full Changelog","text":"

    https://github.com/matrixorigin/matrixone/compare/v0.3.0...v0.4.0

    "},{"location":"MatrixOne/Release-Notes/v0.5.0/","title":"MatrixOne v0.5.0 Release Notes","text":"

    We are excited to announce MatrixOne 0.5.0 release on 2022/7/18. In this release, MatrixOne has a stand-alone columnar storage engine which can support HTAP workloads. Cheers!

    "},{"location":"MatrixOne/Release-Notes/v0.5.0/#docker","title":"Docker","text":"
    docker pull matrixorigin/matrixone:0.5.0\n
    "},{"location":"MatrixOne/Release-Notes/v0.5.0/#features","title":"Features","text":"
    • Support ACID transaction with a Snapshot Isolation level.
    • Support UPDATE, DELETE and INSERT INTO ... SELECT ... statement.
    • Support BOOL and Timestamp data type.
    • Support LEFT / RIGHT / OUTER / NATURAL JOIN.
    • Support Having expression.
    • Support subquery.
    • Support Common Table Expression.
    • Support CASE ... WHEN expression.
    • Support Interval expression.
    • Support Explain plan tree.
    • Support new aggregate function: any_value
    • Lots of new functions are supported.
    "},{"location":"MatrixOne/Release-Notes/v0.5.0/#known-issues","title":"Known issues","text":"
    • Hotfix on 0.5.0 may cause data format incompatable.
    • 'Too many open files' error might be issued when user insert/update/delete data or create/drop table frequently. User need to increase the 'max open files' to resolve the issue.
    • Running 1GB TPCH benchmark test with memory less than 64GB may result in an out of memory error.
    • Loading large size of CSV file than 100GB might lead to system hanging. #3858
    • Mixed TP and AP work loads running for a long time, might cause system panic. #3947 #3961
    "},{"location":"MatrixOne/Release-Notes/v0.5.0/#contributors","title":"Contributors","text":"

    This release includes 811 commits by 73 authors.

    "},{"location":"MatrixOne/Release-Notes/v0.5.0/#new-contributors","title":"New Contributors","text":"
    • @lawrshen
    • @lyfer233
    • @wuliuqii
    • @ericsyh
    • @dongdongyang33
    • @aylei
    • @richelleguice
    • @aressu1985
    • @mklzl

    We appreciate your contribution! Welcome to MatrixOne community.

    "},{"location":"MatrixOne/Release-Notes/v0.5.0/#full-changelog","title":"Full Changelog","text":"

    https://github.com/matrixorigin/matrixone/compare/v0.4.0...v0.5.0

    "},{"location":"MatrixOne/Release-Notes/v0.5.1/","title":"MatrixOne v0.5.1 Release Notes","text":"

    We are excited to announce MatrixOne 0.5.1 release on 2022/8/19. In this release, MatrixOne resolved some log replaying and storage Garbage Collection(GC) issues.

    "},{"location":"MatrixOne/Release-Notes/v0.5.1/#docker","title":"Docker","text":"
    docker pull matrixorigin/matrixone:0.5.1\n
    "},{"location":"MatrixOne/Release-Notes/v0.5.1/#function-optimize","title":"Function Optimize","text":"
    • Optimize checkpoint in replay. #4214
    • Fix the bug that block and index file reference count is not released. #4052
    • Fix the bug that replay dead loop when the log is not full. #4051

    These bugs lead to some stability issues of a MatrixOne instance.

    "},{"location":"MatrixOne/Release-Notes/v0.5.1/#full-changelog","title":"Full Changelog","text":"

    https://github.com/matrixorigin/matrixone/compare/v0.4.0...v0.5.1

    "},{"location":"MatrixOne/Release-Notes/v0.6.0/","title":"MatrixOne v0.6.0 Release Notes","text":"

    We are excited to announce MatrixOne 0.6.0 release on 2022/11/29. In this release, MatrixOne has upgraded to a disaggregated compute and storage architecture, with a cloud native HTAP engine and many new features. Cheers!

    "},{"location":"MatrixOne/Release-Notes/v0.6.0/#docker","title":"Docker","text":"
    docker pull matrixorigin/matrixone:0.6.0\n
    "},{"location":"MatrixOne/Release-Notes/v0.6.0/#features","title":"Features","text":"
    • Support distributed ACID transaction with a Snapshot Isolation level.
    • Support TEXT, BLOB, TIME, JSON data type.
    • Support multi-tenancy with account, user and role.
    • Support VIEW.
    • Support Java, Python, Golang connector and Mybatis, Spring JPA, SQLAlchemy ORM connection.
    • Support import CSV and JSON data from local file system and cloud S3 storage.
    • Implemented a MatrixOne dedicated backup tool modump.
    • Support composite primary key, unique key and auto-increment constraint.
    • Add system_metrics database in the catalog to monitor instance status.
    • Add system database in the catalog to record user statements and system logs.
    • Support timezone.
    • Support TLS encrypted connection.
    • Support pre-compilation statements PREPARE, EXECUTE, DEALLOCATE.
    • Support EXPLAIN ANALYZE.
    • Support UNION, UNION ALL, INTERSECT, MINUS operators.
    • Support TEMPORARY TABLE.
    • Support EXTERNAL TABLE.
    • Support PARTITION BY.
    • Add many system variables and tables to maintain MySQL compatibility.
    • Add many new JSON, Datetime functions.
    "},{"location":"MatrixOne/Release-Notes/v0.6.0/#known-issues","title":"Known Issues","text":"
    • 0.6.0 data format is not compatible with the previous versions.
    • Transactional performance doesn't compete with mature DBMS products.
    • Composite Primary Key, Unique Key and Secondary Key doesn't improve any performance. #6028
    • Insert/update into select having more than 100MB data will fail in a distributed setting. #6780
    • Execute load data in a loop may cause out of memory. #6793
    • Data race happens in a distributed setting. #6855, #6926
    • Background jobs have a low probability causing user transaction being aborted due to r-w conflict. #6049
    • Insert file into BLOB type might fail. #6302
    "},{"location":"MatrixOne/Release-Notes/v0.6.0/#contributors","title":"Contributors","text":"

    This release includes 1520 commits by 97 authors.

    "},{"location":"MatrixOne/Release-Notes/v0.6.0/#new-contributors","title":"New Contributors","text":"
    • @lokax
    • @triump2020
    • @Abirdcfly
    • @yjw1268
    • @Juneezee
    • @ZoranPandovski
    • @Toms1999
    • @xy2398437254
    • @goodMan-code
    • @DanielZhangQD
    • @taofengliu
    • @TszKitLo40
    • @TheR1sing3un
    • @qqIsAProgrammer

    We appreciate your contribution! Welcome to MatrixOne community.

    "},{"location":"MatrixOne/Release-Notes/v0.6.0/#full-changelog","title":"Full Changelog","text":"

    https://github.com/matrixorigin/matrixone/compare/v0.5.1...v0.6.0

    "},{"location":"MatrixOne/Release-Notes/v0.7.0/","title":"MatrixOne v0.7.0 Release Notes","text":"

    We are excited to announce MatrixOne 0.7.0 release on 2023/2/23. In this release, MatrixOne version 0.7.0 has been optimized for stability and performance under a cloud-native architecture and complete database functionality.

    To improve stability, we have optimized the memory management mechanism to significantly reduce the likelihood of memory leaks. We have also adjusted the timeout mechanism of some modules to prevent the system from becoming unresponsive during extreme cases, such as data import and restart. Additionally, we have fixed the issue where a single module failure in the distributed architecture would cause a system-wide collapse.

    To enhance performance, this iteration has focused on read and write optimization. For reading, we have implemented Zonemap-based statistical information and provided a better execution plan. We have also added the Cluster by field when creating a table to arrange data in advance, making it easier to obtain data faster. Furthermore, we have optimized many performance bottlenecks, including the IN operator, type conversion, and predicate filtering. As for writing, this iteration has achieved many parallel writes to shared storage directly through the CN node, greatly improving loading performance.

    "},{"location":"MatrixOne/Release-Notes/v0.7.0/#docker","title":"Docker","text":"
    docker pull matrixorigin/matrixone:0.7.0\n
    "},{"location":"MatrixOne/Release-Notes/v0.7.0/#features","title":"Features","text":"
    • Support parallel load data mode.
    • Support Foreign Key.
    • Support adding Cluster by in DDL statements.
    • Add a MYSQL_COMPATBILITY_MODE to manage MySQL-compatible behaviors.
    • Modify the system default isolation level parameter to REPEATABLE_READ for better MySQL compatibility.
    • Improve Unique Index behavior.
    • Support to load data from the client machine.
    • Support Alter View.
    • Add query_result() function to get saved query results.
    • Support account suspending.
    • Support system table sharing to accounts.
    • Support aggregate function group_concat.
    • Support built-in functions: format, replace, curdate, field, substring_index, and other system functions.
    "},{"location":"MatrixOne/Release-Notes/v0.7.0/#known-issues","title":"Known Issues","text":"
    • 0.7.0 data format is not compatible with the previous versions.
    • Transactional performance doesn't compete with mature DBMS products.
    • The concurrent performance of OLTP type load is unstable.
    • Secondary Key doesn't improve any performance.
    • Only support up to 100GB benchmark testing.
    • Out of memory(OOM) error or context deadline will occur after 5 hours of frequent testing.
    • Loading multiple GB-level large tables in a distributed cluster will cause OOM problems.
    "},{"location":"MatrixOne/Release-Notes/v0.7.0/#contributors","title":"Contributors","text":"

    This release includes 656 commits by 43 authors.

    "},{"location":"MatrixOne/Release-Notes/v0.7.0/#new-contributors","title":"New Contributors","text":"
    • @sourcelliu
    • @iceTTTT
    • @chrisxu333
    • @songjiayang
    • @dr-lab
    • @arjunsk
    • @Morranto

    We appreciate your contribution! Welcome to MatrixOne community.

    "},{"location":"MatrixOne/Release-Notes/v0.7.0/#full-changelog","title":"Full Changelog","text":"

    https://github.com/matrixorigin/matrixone/compare/v0.6.0...v0.7.0

    "},{"location":"MatrixOne/Release-Notes/v0.8.0/","title":"MatrixOne v0.8.0 Release Notes","text":"

    We are excited to announce MatrixOne 0.8.0 release on 2023/6/30.

    After four months of intensive development, MatrixOne has achieved significant performance, scalability, and usability enhancements. This update's highlight is the Proxy module's introduction, which accurately associates various SQL requests and load types with corresponding CN groups. This results in notable improvements in critical functions such as tenant isolation, read-write separation, and separation of transaction processing (TP) and analytical processing (AP) loads. Worth noting is that this 0.8.0 release is the final version of MatrixOne before its full public launch and also serves as the public Beta version of the MatrixOne product. We cordially invite all users and developers to download, test, and give feedback. Cheers!

    "},{"location":"MatrixOne/Release-Notes/v0.8.0/#docker","title":"Docker","text":"
    • General Image:
    docker pull matrixorigin/matrixone:0.8.0\n
    • If you are using the network in mainland China, you can pull the image on Alibaba Cloud:
    docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:0.8.0\n
    "},{"location":"MatrixOne/Release-Notes/v0.8.0/#key-points","title":"Key Points","text":""},{"location":"MatrixOne/Release-Notes/v0.8.0/#performance","title":"Performance","text":"
    • OLTP Performance: In common OLTP scenarios such as point queries and insertions, MatrixOne's performance has improved several times, reaching the performance level of MySQL in the standalone version.
    • OLAP Performance: MatrixOne has further improved its OLAP performance. Standard OLAP benchmarks such as TPCH are comparable to the performance of leading OLAP databases in the industry.
    • Scalability: MatrixOne implements second-level expansion of CN computing nodes, and after expansion, the performance of OLTP and OLAP increases linearly.
    "},{"location":"MatrixOne/Release-Notes/v0.8.0/#improved-usability","title":"Improved Usability","text":"
    • Backward Compatibility of Data Format: Starting from version 0.8.0, all subsequent versions of MatrixOne will be compatible with the underlying data storage format of version 0.8.0. When upgrading the version, you no longer need to delete or re-import the old data directory.
    • Simplified Deployment and Administration Tools: This iteration provides a simplified deployment and administration command-line tool, mo_ctl, which helps users quickly check the basic hardware environment, initialize configurations, and perform one-click installation and deployment. Both standalone and distributed version users no longer need to use complex Linux and K8s native commands for deployment and maintenance.
    • Improved MySQL Compatibility: An upper and lower case mode compatible with MySQL has been added, and a tool for converting SQL from MySQL to MatrixOne is provided. Additionally, MatrixOne has added many table structures in the information_schema library, significantly reducing the adaptation work required for migration from MySQL.
    • Support for Pessimistic Transactions: To better adapt to the current OLTP application transaction usage habits, MatrixOne has added support for pessimistic transactions. Also, MatrixOne supports SI and RC isolation levels. There is no need to set a retry mechanism for potential conflicts arising from optimistic transactions. At the same time, MatrixOne has added support for the Select for update command. (Experimental)
    "},{"location":"MatrixOne/Release-Notes/v0.8.0/#other-features","title":"Other Features","text":"
    • Support window function RANK(), ROW_NUMBER() and DENSE_RANK().
    • Support the BINARY type and related functions.
    • Support data sharing between tenants and PUBLISH/SUBSCRIBE functions.
    • Support INSERT...ON DUPLICATE KEY UPDATE statement.
    • Add Sequence and related statements.
    • Support ADD [COLUMN] | DROP [COLUMN] in the ALTER TABLE statement.
    • Support multi-layer foreign key.
    • Support RAND() built-in function.
    • Support setting global variables in configuration files.
    • Secure initial MatrixOne account by password replacement.
    • Several types of partitioning are supported. (Experimental)
    "},{"location":"MatrixOne/Release-Notes/v0.8.0/#known-issues","title":"Known Issues","text":"
    • Data formats of versions before 0.8.0 are incompatible and cannot be upgraded directly.
    • Secondary indexes have not been improved in any performance.
    • Occasional memory leaks may lead to system out-of-memory(OOM) errors.
    • Workload isolation tags are currently only supported in JDBC.
    • TN represents a single point of failure for distributed version.
    • Occasional system hang-ups under high-concurrency workloads.
    • Pessimistic transaction has a few fatal bugs remaining.
    "},{"location":"MatrixOne/Release-Notes/v0.8.0/#contributors","title":"Contributors","text":""},{"location":"MatrixOne/Release-Notes/v0.8.0/#new-contributors","title":"New Contributors","text":"
    • @zengyan1
    • @forsaken628
    • @gavinyue
    • @gouhongshen
    • @WitcherTheWhite

    We appreciate your contribution! Welcome to the MatrixOne community.

    "},{"location":"MatrixOne/Release-Notes/v0.8.0/#full-changelog","title":"Full Changelog","text":"

    https://github.com/matrixorigin/matrixone/compare/v0.7.0...v0.8.0

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/","title":"MatrixOne v1.0.0-RC1 Release Notes","text":"

    We are thrilled to announce the release of MatrixOne 1.0.0-RC1 on 2023/8/24!

    This milestone marks we have basically achieved the initial design goal of the MatrixOne open-source project. Cheers!

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#matrixone-100-rc1-review","title":"MatrixOne 1.0.0-RC1 Review","text":"

    MatrixOne is designed to provide a unified and scalable database management solution for transactional, analytical and streaming workloads and powers a wide range of applications. In general, MatrixOne 1.0.0-RC1 has delivered a cloud-native architecture with separated storage and computing, presenting a fully-functional database with high performance queries and elastic scaling with familiar relational SQL. The OLTP and OLAP performance of MatrixOne has also reached the industry's average level, meanwhile MatrixOne provides an experimental function of Stream table and Kafka connector for streaming processing.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#sql","title":"SQL","text":"
    • Syntax: MatrixOne SQL syntax is highly compatible with MySQL 8.0.
    • DDL: Supports common DDL statements such as CREATE, ALTER, and DELETE databases, tables, views, and partitioned tables.
    • DML: Supports common DML statements including INSERT, UPDATE, DELETE, and data import/export statements.
    • Basic SQL query: Supports basic query capabilities such as grouping, deduplication, filtering, sorting, limiting, regular expressions, etc.
    • Advanced SQL query: Supports advanced query capabilities including views, subqueries, joins, unions, Common Table Expressions (CTE), window functions, prepared statements, etc.
    • Data Types: Supports data types including integer, floating-point, string, date/time, boolean, enum, binary, and JSON types.
    • Aggregate Functions: Supports common aggregate functions such as AVG, COUNT, MIN, MAX, SUM, etc.
    • System Functions and Operators: Supports common string, date/time, mathematical functions, and operators.
    • Indexes and Constraints: Supports primary keys, unique constraints, non-null constraints, foreign keys, auto-increment constraints, and secondary indexes.
    • Streaming: Supports the creation of streaming tables and integration with Kafka data sources.
    • Multi-tenancy: Supports the creation and management of internal tenants within the database.
    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#data-import-and-export","title":"Data Import and Export","text":"
    • Supports batch insert data using INSERT, LOAD DATA, SOURCE, etc.
    • Supports data export using SELECT INTO and modump methods.
    • Supports direct import from local files and object storage.
    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#transactions","title":"Transactions","text":"
    • Supports ACID (Atomicity, Consistency, Isolation, Durability) transaction properties.
    • Supports transaction initiation, commit, and rollback operations.
    • Supports both pessimistic and optimistic transactions, allowing users to switch between them.
    • Provides configuration options for isolation levels, including Snapshot Isolation and Read Committed.
    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#deployment","title":"Deployment","text":"
    • Supports both standalone and distributed deployment architectures.
    • Supports deployment through source code, binary packages, Docker, and Kubernetes.
    • Supports deployment on public cloud, private cloud, and physical machines.
    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#application-development","title":"Application Development","text":"
    • Supports native connectors for popular development languages such as Java, Python, and Golang, including JDBC, pymysql, go-sql-driver.
    • Supports common ORM frameworks for various languages such as MyBatis, Spring JPA, SQLAlchemy, GORM.
    • Supports popular MySQL management tools like Navicat, MySQL Workbench, DBeaver, HeidiSQL.
    • Provides a standalone and distributed command-line management tool named mo_ctl.
    • Includes comprehensive database logging and query recording capabilities, with the ability to integrate with visualization components like Grafana for real-time cluster monitoring.
    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#security-and-privileges","title":"Security and Privileges","text":"
    • Supports Transport Layer Security (TLS) encrypted connections.
    • Supports Role-Based Access Control (RBAC).
    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#backup-and-restore","title":"Backup and Restore","text":"
    • Supports logical backups using the modump tool.
    • Supports physical backups using the mobr tool.
    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#matrixone-use-cases","title":"MatrixOne Use Cases","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#operational-analytics","title":"Operational Analytics","text":"

    As the data volume of common IT systems such as OA, ERP, CRM, etc., increases with business growth, traditional single-node databases may not meet their performance requirements. Many companies set up a separate analytical database system to meet the needs of important reporting requirements at month-end or quarter-end, or use sharding techniques to reduce query loads. An operational analytics system is one that allows you to make quick decisions based on the current operational system. MatrixOne can fulfill the requirements of both the business system and the analytical system with a single database, while providing powerful scalability that can seamlessly expand as the business grows.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#real-time-analytics","title":"Real-time Analytics","text":"

    For typical OLAP (Online Analytical Processing) applications in business, such as dashboards and BI reports, massive data analysis is often required. When the data volume becomes significant, performance bottlenecks may arise, resulting in poor timeliness. MatrixOne offers fast data ingestion, powerful analytical performance and scalability, enabling accelerated processing of complex and large-scale SQL queries, achieving sub-second response times, and improving the agility of enterprise decision-making and analysis.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#iot-monitoring","title":"IoT Monitoring","text":"

    With the widespread application of sensors and network technologies, various IoT devices generate massive amounts of data, such as manufacturing plant production lines, renewable energy vehicles, city surveillance cameras, and more. The scale of data can easily reach hundreds of terabytes or even petabytes. There is an increasing demand for enterprises to store and utilize this data. Traditional database solutions cannot handle the real-time data ingestion and processing required in such massive and large-scale scenarios. MatrixOne provides powerful capabilities for streaming data ingestion and processing, along with robust scalability to handle any workload and data volume, fully meeting the requirements of this scenario.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#fluctuating-web-applications","title":"Fluctuating Web Applications","text":"

    For internet-based web applications such as gaming, e-commerce, entertainment, social media, news, etc., where user numbers are large and business fluctuations are frequent and significant, substantial computing resources are often required to support business demands during peak events. MatrixOne, with its fully cloud-native architecture, offers exceptional scalability, automatically scaling up or down in response to changes in the business, thereby greatly reducing the operational complexity for users.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#saas-applications","title":"SaaS Applications","text":"

    SaaS applications have experienced explosive growth in recent years. In SaaS application development, a multi-tenant model needs to be considered. Traditional solutions often involve either shared database instances for multiple tenants or dedicated database instances for each tenant, facing a trade-off between management costs and isolation. MatrixOne comes with built-in multi-tenancy capabilities, providing natural workload isolation between tenants and independent scalability. It also offers centralized management capabilities, effectively addressing cost, ease of management, and isolation requirements, making it the ideal choice for SaaS applications.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#quick-start","title":"Quick Start","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#docker","title":"Docker","text":"
    docker pull matrixorigin/matrixone:1.0.0-rc1\n

    This documentation site also provides detailed architecture instructions, installation guides, and development tutorials to help you explore the features and capabilities of MatrixOne here.

    Additionally, our GitHub and community forums are available for any questions, discussions, or feedback you may have.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#whats-changed-from-08-to-10","title":"What's changed from 0.8 to 1.0","text":"

    From 0.8 to 1.0, we mainly developed some new functions and improve usability for production-level deployment.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#key-new-features","title":"Key New Features","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#physical-backupenterprise-edition","title":"Physical Backup(Enterprise Edition)","text":"

    In this version, we have introduced the physical backup feature, allowing users to easily backup and restore databases. Now, you can effortlessly create snapshots of your database and restore to previous states when needed, ensuring data integrity and reliability.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#stream-computing","title":"Stream Computing","text":"

    As the final piece of the HSTAP architecture puzzle, we have completed the framework design for stream computing. In this iteration, we have added the ability to create streaming tables and implemented a Kafka connector to meet the streaming data ingestion needs of various time-series scenarios.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#recursive-cte","title":"Recursive CTE","text":"

    Recursive CTE (Common Table Expression) is a feature that allows for repeatedly executing an initial CTE to return subsets of data until the complete result set is obtained. The implementation in this iteration enables users to easily handle hierarchical data and build more complex and flexible queries using recursive queries.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#key-improvements","title":"Key Improvements","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#mysql-ddl-compatibility","title":"MySQL DDL Compatibility","text":"

    We have further improved MatrixOne's compatibility with MySQL, enabling better support for MySQL table creation statements. Now, users can seamlessly migrate existing MySQL applications to MatrixOne without modifying existing table creation statements.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#session-migration-during-scaling","title":"Session Migration during Scaling","text":"

    We have added the capability to migrate sessions seamlessly during distributed instance scaling operations. Users can easily adjust the capacity of MatrixOne without impacting existing sessions and business operations.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#simplified-system-configuration","title":"Simplified System Configuration","text":"

    We have significantly simplified the startup configuration options for both single-node and distributed versions, allowing users to quickly and easily start the database.

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#mo_ctl-tool","title":"mo_ctl Tool","text":"

    We have optimized the functionality of the mo_ctl maintenance tool for both single-node and distributed setups, providing more powerful and user-friendly maintenance capabilities. Now, you can effortlessly deploy, upgrade, scale, and perform other maintenance operations using the distributed mo_ctl tool (Enterprise Edition).

    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#other-features","title":"Other Features","text":"
    • Add Replace for DDL
    • Add column modification for Alter Table
    • Add Create Stage statement, simplify Data Import/Export process
    • Add Show Processlist for checking system status
    • Add enum data type
    • Add Year data type
    • Add To_Days/To_Seconds system functions
    • Improve Group by behavior by alias support
    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#known-issues","title":"Known Issues","text":"
    • Secondary Key doesn't improve any performance.
    • Memory leak occasionally happens and may lead to an OOM error.
    • DN is a single point of failure for distributed version.
    • Occasional system hung under high concurrency workload.
    "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#full-changelog","title":"Full Changelog","text":"

    https://github.com/matrixorigin/matrixone/compare/v0.8.0...v1.0.0-rc1

    "},{"location":"MatrixOne/Security/Authentication/","title":"Authentication and Authorization","text":"

    When accessing the MatrixOne database, users need to undergo authentication and authorization. Currently, MatrixOne only supports username-password authentication. The database verifies the identity of the user accessing the data, confirms whether the user can be associated with a database user, and checks the validity of the provided password.

    "},{"location":"MatrixOne/Security/Authentication/#syntax","title":"Syntax","text":"

    In MatrixOne, a user's login identity comprises acccount_name, user_name, host, and password. The complete syntax is as follows:

    mysql -h host -p password -u accountname:username -P port\n

    The -h, -p, and -P parameters are the same as those used in MySQL. The difference lies in:

    • -u represents the user. In MatrixOne's user system, users are a concept below the tenant account. Therefore, when logging in, you need to specify the tenant account_name first and then specify the user username within the tenant to complete the login. If account_name is not specified, the default is the system tenant sys.

    Example:

    > mysql -h 127.0.0.1 -P6001 -utenant1:u1 -p111\n

    Note

    For the standalone version of MatrixOne, you can configure the connection string as parameters in the mo_ctl tool to simplify the login process.

    "},{"location":"MatrixOne/Security/Authentication/#query-current-user","title":"Query Current User","text":"

    After logging in, you can retrieve information about the current user using the user() or current_user() functions.

    mysql> select user();\n+--------------------+\n| user()             |\n+--------------------+\n| tenant1:u1@0.0.0.0 |\n+--------------------+\n1 row in set (0.00 sec)\nmysql> select current_user();\n+--------------------+\n| current_user()     |\n+--------------------+\n| tenant1:u1@0.0.0.0 |\n+--------------------+\n1 row in set (0.00 sec)\n

    Note

    MatrixOne currently does not support IP whitelisting. Therefore, regardless of the location you log in, the user will always be shown as 0.0.0.0.

    "},{"location":"MatrixOne/Security/Authentication/#query-all-users","title":"Query All Users","text":"

    Each user identity is unique, and users with the accountadmin role in a tenant can view all users within that tenant.

    mysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string                     | status | created_time        | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n|   10001 | localhost | u1        | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-10 06:43:44 | NULL         | PASSWORD   |       0 |     0 |            1 |\n|       0 | localhost | root      | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-08 03:17:27 | NULL         | PASSWORD   |       0 |     0 |            0 |\n|       1 | localhost | root      | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-08 03:17:27 | NULL         | PASSWORD   |       0 |     0 |            0 |\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n3 rows in set (0.01 sec)\n

    Note

    The location and table structure of user records in MatrixOne differs from MySQL. In MatrixOne, user metadata is not stored in the mysql.user table but in the mo_catalog.mo_user table.

    "},{"location":"MatrixOne/Security/Authentication/#constraints","title":"Constraints","text":"
    1. MatrixOne currently does not enforce password complexity requirements. It is recommended that users set strong passwords. For password modification operations, refer to Password Management.
    2. The initial password for the initial user (root user of the sys tenant) in MatrixOne is 111. After users modify their passwords, they need to remember the new password. Once a password is forgotten, MatrixOne currently does not provide a means to retrieve or bypass security verification to reset the password. Reinstallation of MatrixOne is required.
    "},{"location":"MatrixOne/Security/Security-Permission-Overview/","title":"Security and Permissions Overview","text":"

    Database security and permissions are critical to ensuring the protection and management of a database system and the data it stores. It involves a range of strategies, measures, and permission controls to ensure that only authorized users can access, modify, and operate the database. This chapter introduces the security and permission management system of the MatrixOne database.

    "},{"location":"MatrixOne/Security/Security-Permission-Overview/#security-management","title":"Security Management","text":"

    MatrixOne database security aims to protect the database from unauthorized access, data leaks, data tampering, and other security threats. MatrixOne provides the following capabilities to ensure database security:

    • Identity authentication and authentication: Enhance database security through identity identification, user authentication, roles, and password management.
    • Access control: Restrict access to the database system and specific data objects only to authorized users using authentication and authorization mechanisms.
    • Data transmission encryption: Encrypt data transmission to ensure that data cannot be intercepted, decrypted, and read during transmission.
    • Audit and logging: Monitor database activities, record access, and operation logs to track abnormal behavior, and conduct audits.
    "},{"location":"MatrixOne/Security/Security-Permission-Overview/#permission-management","title":"Permission Management","text":"

    MatrixOne database permission management manages user access and operation permissions to the database. Implementing fine-grained permission controls ensures that each user can only perform the necessary operations and restricts access to sensitive data. MatrixOne's database permission management includes the following aspects:

    • User roles and permission assignments: Assign users to different roles, each with different levels of permissions. Then associate permissions with roles to simplify permission management.
    • Object-level permissions: Define user access and operation permissions for specific database objects, such as tables and views, to ensure that users can only perform operations within their authorized scope.
    • Permission inheritance and control: Using inheritance mechanisms, transfer role permissions to users or other roles and control the inheritance process to ensure proper permission inheritance and management.
    "},{"location":"MatrixOne/Security/TLS-introduction/","title":"Data Transmission Encryption","text":"

    This document will introduce MatrixOne's support for data transmission encryption and how to enable encrypted transmission.

    "},{"location":"MatrixOne/Security/TLS-introduction/#overview","title":"Overview","text":"

    MatrixOne uses non-encrypted transmission by default and supports encrypted transmission based on TLS protocol. Encrypted transmission can reduce the risk of leakage of sensitive information in the database. Encrypted transmission is the process of encrypting and decrypting information using keys, which can effectively protect data security.

    Transport Layer Security (TLS) is a widely adopted security protocol. The protocol versions supported by MatrixOne include TLS 1.0, TLS 1.1, and TLS 1.2.

    • Do not enable TLS encrypted transmission (default): Use the username and password to connect to MatrixOne directly.
    • Use encrypted transmission: It is necessary to enable encrypted transmission support on the MatrixOne server and specify the use of encrypted transmission on the client side. You can follow the instructions in this article to enable TLS secure connections.
    "},{"location":"MatrixOne/Security/TLS-introduction/#how-to-use","title":"How to Use","text":"

    Main steps of TLS secure connection configuration:

    1. First, enable TLS in MatrixOne.

    2. Then, configure the MySQL client security connection parameters.

    After completing the configuration of these two main steps, a TLS secure connection can be established.

    "},{"location":"MatrixOne/Security/TLS-introduction/#step-1-enable-matrixones-tls-support","title":"Step 1: Enable MatrixOne's TLS support","text":"
    1. Generate certificate and key: MatrixOne does not yet support loading a private key protected by a password, so a private key file without a password must be provided. Certificates and keys can be issued and generated using OpenSSL. It is recommended to use the tool mysql_ssl_rsa_setup that comes with MySQL to generate quickly:

      #Check your local MySQL client installation directory\nps -ef|grep mysql\n#Go to the installation directory of your local MySQL client\ncd /usr/local/mysql/bin\n#Generate certificate and key\n./mysql_ssl_rsa_setup --datadir=<yourpath>\n#Check your generated pem file\nls <yourpath>\n\u251c\u2500\u2500 ca-key.pem\n\u251c\u2500\u2500 ca.pem\n\u251c\u2500\u2500 client-cert.pem\n\u251c\u2500\u2500 client-key.pem\n\u251c\u2500\u2500 private_key.pem\n\u251c\u2500\u2500 public_key.pem\n\u251c\u2500\u2500 server-cert.pem\n\u2514\u2500\u2500 server-key.pem\n

      Note: <yourpath> in the above code is the local directory path where you need to store the generated certificate and key files.

    2. Enter the cn.toml configuration file in your local MatrixOne file directory path matrixone/etc/launch-tae-CN-tae-TN/:

      You can also use the vim command to open the cn. toml file directly in the terminal

      vim $matrixone/etc/launch-tae-CN-tae-TN/cn.toml\n

      Copy and paste the code below into the configuration file:

      [cn.frontend]\n#default is false. With true. Server will support tls\nenableTls = true\n\n#default is ''. Path of file that contains X509 certificate in PEM format for client\ntlsCertFile = \"<yourpath>/server-cert.pem\"\n\n#default is ''. Path of file that contains X509 key in PEM format for client\ntlsKeyFile = \"<yourpath>/server-key.pem\"\n\n#default is ''. Path of file that contains list of trusted SSL CAs for client\ntlsCaFile = \"<yourpath>/ca.pem\"\n

      Note: <yourpath> in the above code is the local directory path where you need to store the generated certificate and key files

      In the above code, the configuration parameters are explained as follows:

      Parameters Description enableTls Bool, enable TLS support on the MatrixOne server. tlsCertFile Specify the SSL certificate file path tlsKeyFile Specify the private key corresponding to the certificate file tlsCaFile Optional, specify the trusted CA certificate file path

      Note: If you use Docker to install and launch MatrixOne, before modifying the configuration file, you need to mount the configuration file first and then modify it. For more information, see Mount directory to Docker container.

    3. Verify that MatrixOne's SSL is enabled.

      \u2460 Use the MySQL client to connect to MatrixOne:

      mysql -h 127.0.0.1 -P 6001 -uroot -p111\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n

      \u2461 Use the Status command to check whether SSL is enabled.

      Successfully enabled, the code example is as follows; you can see that the SSL status is Cipher in use is TLS_AES_128_GCM_SHA256:

      mysql> status\nmysql  Ver 8.0.28 for macos11 on arm64 (MySQL Community Server - GPL)\n\nConnection id:          1001\nCurrent database:\nCurrent user:           root@0.0.0.0\nSSL:                    Cipher in use is TLS_AES_128_GCM_SHA256\nCurrent pager:          stdout\nUsing outfile:          ''\nUsing delimiter:        ;\nServer version:         8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\nProtocol version:       10\nConnection:             127.0.0.1 via TCP/IP\nServer characterset:    utf8mb4\nDB     characterset:    utf8mb4\nClient characterset:    utf8mb4\nConn.  characterset:    utf8mb4\nTCP port:               6001\nBinary data as:         Hexadecimal\n--------------\n

      If it is not enabled successfully, the returned result is as follows; you can see that the SSL status is Not in use; you need to recheck whether the local directory path (namely ) of the certificate and key file you configured in the above steps is correct:

      mysql> status;\n/usr/local/mysql/bin/mysql  Ver 8.0.30 for macos12 on arm64 (MySQL Community Server - GPL)\n\nConnection id:      1009\nCurrent database:   test\nCurrent user:       root@0.0.0.0\nSSL:            Not in use\nCurrent pager:      stdout\nUsing outfile:      ''\nUsing delimiter:    ;\nServer version:     8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\nProtocol version:   10\nConnection:     127.0.0.1 via TCP/IP\nServer characterset:    utf8mb4\nDb     characterset:    utf8mb4\nClient characterset:    utf8mb4\nConn.  characterset:    utf8mb4\nTCP port:       6001\nBinary data as:     Hexadecimal\n--------------\n

      After completing the above steps, MatrixOne's TLS is enabled.

      "},{"location":"MatrixOne/Security/TLS-introduction/#step-2-configure-the-parameters-of-mysql-client","title":"Step 2: Configure the parameters of MySQL client","text":"

      When a MySQL client connects to Matrix One Server, the encrypted connection behavior needs to be specified by the --ssl-mode parameter, such as:

      mysql -h 127.0.0.1 -P 6001 -uroot -p111 --ssl-mode=PREFFERED\n

      Info

      The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

      The value types of ssl mode are as follows:

      ssl-mode value Description DISABLED Establish an encrypted connection without SSL/TLS, synonymous with skip-ssl. PREFFERED The default behavior is first to establish an encrypted connection using SSL/TLS; if it cannot be established, it will try to establish a non-SSL/TLS connection. REQUIRED Only SSL/TLS will be attempted to establish an encrypted connection, and if the connection cannot be established, the connection will fail. VERIFY_CA As with the REQUIRED behavior, and also verifies that the CA certificate on the Server side is valid. VERIFY_IDENTITY It acts like VERIFY_CA and verifies that the host in the server-side CA certificate is the same as the hostname for the actual connection.

      Note

      When the client specifies --ssl-mode=VERIFY_CA, it needs to use --ssl-ca to specify the CA certificate; If --ssl-mode=VERIFY_IDENTITY is specified on the client, you need to specify the CA certificate. You need to use --ssl-key to specify the client private key and --ssl-cert to specify the client certificate.

      "},{"location":"MatrixOne/Security/audit/","title":"Audit","text":""},{"location":"MatrixOne/Security/audit/#overview","title":"Overview","text":"

      The audit function records user behaviors and major internal events in the database. After logging in to the database, it registers all users' database operations and major internal events. It is also one of the essential features of many enterprise databases.

      In daily database operation and maintenance, an audit is a very effective means to ensure that all behaviors of database users comply with the law. When important events occur in the database, such as start and stop, node breakdown, and so on., the audit content can be very convenient for tracing the behavior of the protective device library before and after the period.

      It is necessary to enable database audit when you need to effectively and completely monitor necessary service information tables or system configuration tables. For example, it monitors all user A's behaviors in the database to discover the source of data modification or deletion promptly. For the monitoring of major internal events in the database, the fault can be rectified immediately, and the root cause of the accident can be traced back.

      MatrixOne supports auditing user behavior, operation logs, and SQL statements. The audit data of MatrixOne is stored in the database table, and the audit data can be queried directly through SQL interaction.

      "},{"location":"MatrixOne/Security/audit/#enable-audit","title":"Enable Audit","text":"

      To enable the audit, execute the following SQL statements:

      drop database if exists mo_audits;\ncreate database mo_audits;\nuse mo_audits;\ncreate view mo_user_action as select request_at,user,host,statement,status from system.statement_info where user in (select distinct user_name from mo_catalog.mo_user) and statement not like '______internal_%' order by request_at desc;\ncreate view mo_events as select timestamp,level,message from system.log_info where level in ('error','panic','fatal') order by timestamp desc;\n
      "},{"location":"MatrixOne/Security/audit/#audit-query","title":"Audit Query","text":"

      To audit user behaviors, execute the following SQL statement:

      mysql> select * from mo_audits.mo_user_action;\n

      The example query result as below:

      +----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n| request_at                 | user | host    | statement                                                                                                                                                                                                                                      | status  |\n+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n| 2023-02-10 19:54:28.831970 | root | 0.0.0.0 | create view mo_user_action as select request_at, user, host, statement, status from system.statement_info where user in (select distinct user_name from mo_catalog.mo_user) and statement not like \"______internal_%\" order by request_at desc | Success |\n| 2023-02-10 19:54:14.079939 | root | 0.0.0.0 | show tables                                                                                                                                                                                                                                    | Success |\n| 2023-02-10 19:54:14.076260 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:54:14.071728 | root | 0.0.0.0 | use mo_audits                                                                                                                                                                                                                                  | Success |\n| 2023-02-10 19:54:14.071108 | root | 0.0.0.0 | select database()                                                                                                                                                                                                                              | Success |\n| 2023-02-10 19:54:01.007241 | root | 0.0.0.0 | create database mo_audits                                                                                                                                                                                                                      | Success |\n| 2023-02-10 19:53:48.924819 | root | 0.0.0.0 | drop database if exists mo_audits                                                                                                                                                                                                              | Success |\n| 2023-02-10 19:30:59.668646 | root | 0.0.0.0 | show triggers                                                                                                                                                                                                                                  | Success |\n| 2023-02-10 19:30:53.438212 | root | 0.0.0.0 | show locks                                                                                                                                                                                                                                     | Success |\n| 2023-02-10 19:30:44.258894 | root | 0.0.0.0 | show index from t                                                                                                                                                                                                                              | Success |\n| 2023-02-10 19:30:43.662063 | root | 0.0.0.0 | create table t (a int, b int, c int, primary key (a))                                                                                                                                                                                          | Success |\n| 2023-02-10 19:30:23.104830 | root | 0.0.0.0 | show triggers                                                                                                                                                                                                                                  | Success |\n| 2023-02-10 19:30:20.062010 | root | 0.0.0.0 | show tables                                                                                                                                                                                                                                    | Success |\n| 2023-02-10 19:30:20.060324 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:30:20.055515 | root | 0.0.0.0 | use aab                                                                                                                                                                                                                                        | Success |\n| 2023-02-10 19:30:20.055186 | root | 0.0.0.0 | select database()                                                                                                                                                                                                                              | Success |\n| 2023-02-10 19:30:17.152087 | root | 0.0.0.0 | create database aab                                                                                                                                                                                                                            | Success |\n| 2023-02-10 19:30:10.621294 | root | 0.0.0.0 | create aab                                                                                                                                                                                                                                     | Failed  |\n| 2023-02-10 19:29:59.983433 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:29:45.370956 | root | 0.0.0.0 | show index from t                                                                                                                                                                                                                              | Failed  |\n| 2023-02-10 19:29:44.875580 | root | 0.0.0.0 | create table t (a int, b int, c int, primary key (a))                                                                                                                                                                                          | Failed  |\n| 2023-02-10 19:29:44.859588 | root | 0.0.0.0 | drop table if exists t                                                                                                                                                                                                                         | Success |\n| 2023-02-10 19:29:19.974775 | root | 0.0.0.0 | show index                                                                                                                                                                                                                                     | Failed  |\n| 2023-02-10 19:29:11.188286 | root | 0.0.0.0 | show locks                                                                                                                                                                                                                                     | Success |\n| 2023-02-10 19:29:06.618778 | root | 0.0.0.0 | show node list                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:19:11.319058 | root | 0.0.0.0 | show triggers                                                                                                                                                                                                                                  | Failed  |\n| 2023-02-10 19:19:06.809302 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:18:52.840282 | root | 0.0.0.0 | show triggers                                                                                                                                                                                                                                  | Failed  |\n| 2023-02-10 10:54:09.892254 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 10:54:04.468721 | root | 0.0.0.0 | select @@version_comment limit 1                                                                                                                                                                                                               | Success |\n+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n30 rows in set (0.81 sec)\n

      Query database internal status change query, execute the following SQL statement to view:

      mysql> select * from mo_events;\n

      The example query result as below:

      |\n| 2022-10-18 15:26:20.293735 | error | error: timeout, converted to code 20429                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| 2022-10-18 15:26:20.293725 | error | failed to propose initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| 2022-10-18 15:26:20.288695 | error | failed to set initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| 2022-10-18 15:26:20.288559 | error | failed to propose initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| 2022-10-18 15:26:20.285384 | error | failed to set initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| 2022-10-18 15:26:20.285235 | error | failed to propose initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| 2022-10-18 15:26:18.473472 | error | failed to join the gossip group, 1 error occurred:\n    * Failed to join 127.0.0.1:32022: dial tcp 127.0.0.1:32022: connect: connection refused                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| 2022-10-18 15:26:18.469029 | error | failed to join the gossip group, 1 error occurred:\n    * Failed to join 127.0.0.1:32012: dial tcp 127.0.0.1:32012: connect: connection refused       \n
      "},{"location":"MatrixOne/Security/audit/#disable-audit","title":"Disable Audit","text":"

      To disable the audit, execute the following SQL statement:

      > drop database if exists mo_audits;\n
      "},{"location":"MatrixOne/Security/password-mgmt/","title":"MatrixOne Password Management","text":"

      To protect the security of user passwords, MatrixOne supports password management capabilities:

      • Password complexity strategy: Requires users to set strong passwords to prevent empty or weak passwords.
      "},{"location":"MatrixOne/Security/password-mgmt/#password-complexity-strategy","title":"Password Complexity Strategy","text":"

      MatrixOne recommends that users set complex passwords to ensure account security.

      • Suggested complexity: uppercase letters, lowercase letters, numbers, and special symbols.
      • Recommended length: no less than 12 characters.
      "},{"location":"MatrixOne/Security/password-mgmt/#modify-password-permissions","title":"Modify Password Permissions","text":"
      • System Administrator (i.e., the root user): Has the highest authority. Can modify the password of the root user itself and the password of Accounts created by the root user.
      • Accounts: Have authority second only to the system administrator. They can modify their own password and the password of ordinary users created by the Account.
      • Other ordinary users: Can only modify their own passwords.

      For more information about permission levels, see Privilege Control Types.

      "},{"location":"MatrixOne/Security/password-mgmt/#tutorial-of-password-changing","title":"Tutorial of Password Changing","text":""},{"location":"MatrixOne/Security/password-mgmt/#root-user-changing-password","title":"Root User Changing Password","text":""},{"location":"MatrixOne/Security/password-mgmt/#root-user-changing-their-own-password","title":"Root User Changing their own Password","text":"

      After starting MatrixOne and successfully logging in with the root, you can use the following command to change the password:

      mysql> alter user root identified by '${your password}'\n

      After the change is completed, you can go ahead and exit the current session and log into MatrixOne again for the new password to take effect.

      Note

      Since the root account is the user with the highest authority by default, please log in with the initial account password and change the password in time.

      "},{"location":"MatrixOne/Security/password-mgmt/#root-changing-accounts-password","title":"Root Changing Account's Password","text":"

      Refer to ALTER ACCOUNT

      "},{"location":"MatrixOne/Security/password-mgmt/#other-users-changing-password","title":"Other Users Changing Password","text":""},{"location":"MatrixOne/Security/password-mgmt/#account-changing-their-own-password","title":"Account Changing their own Password","text":"

      Refer to ALTER ACCOUNT

      "},{"location":"MatrixOne/Security/password-mgmt/#account-changing-the-password-of-other-users-they-created","title":"Account Changing The Password Of Other Users They Created","text":"

      Refer to ALTER USER

      "},{"location":"MatrixOne/Security/password-mgmt/#ordinary-user-changing-their-own-password","title":"Ordinary User Changing their own Password","text":"

      Refer to ALTER USER

      "},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/","title":"Create accounts, Verify Resource Isolation","text":"

      When initializing access to the MatrixOne cluster, the system will automatically generate a default cluster administrator. The cluster administrator is automatically granted the authority to manage accounts by default, but cannot manage resources under the account.

      This document will guide you to use the cluster administrator to create two new accounts, grant the permissions of the accountadmin, and check whether the resource isolation between accounts is implemented.

      "},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/#before-you-start","title":"Before you start","text":"
      • MatrixOne cluster has been depolyed and connected.
      • You have obtained the cluster administrator user name and password (The default user name and password are root and 111 respectively).
      "},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/#steps","title":"Steps","text":"
      1. Log into MatrixOne with the cluster administrator's username (root by default) and password:

        mysql -h 127.0.0.1 -P 6001 -u root -p\n
      2. Create a new account:

        • The login username and password of account a1 are: admin1, test123
        • The login username and password of account a2 are: admin2, test456
        create account a1 ADMIN_NAME 'admin1' IDENTIFIED BY 'test123';\ncreate account a2 ADMIN_NAME 'admin2' IDENTIFIED BY 'test456';\n
      3. Use admin1 to log in to account a1, and create data table db1.t1:

        mysql -h 127.0.0.1 -P 6001 -u a1:admin1 -p\ncreate database db1;\ncreate table db1.t1(c1 int,c2 varchar);\ninsert into db1.t1 values (1,'shanghai'),(2,'beijing');\n

        Use the following command to verify whether the table was created successfully for account a1:

        mysql> select * from db1.t1;\n+------+----------+\n| c1   | c2       |\n+------+----------+\n|    1 | shanghai |\n|    2 | beijing  |\n+------+----------+\n2 rows in set (0.01 sec)\n
      4. Login to account a2 using admin2:

        mysql -h 127.0.0.1 -P 6001 -u a2:admin2 -p\n

        Check db1.t1 data in account a1:

        mysql> select * from db1.t1;\nERROR 1064 (HY000): SQL parser error: table \"t1\" does not exist\n

        The above command runs an error, which proves that the database db1 in the account a1 cannot be seen in the account a2:

      5. The database db1 and table db1.t1 can also be created in the account a2:

        mysql> create database db1;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> create table db1.t1(c1 int,c2 varchar);\nQuery OK, 0 rows affected (0.05 sec)\n\nmysql> insert into db1.t1 values (3,'guangzhou');\nQuery OK, 1 row affected (0.05 sec)\n

        Insert different data into table db1.t1 of account a2 from table db1.t1 in account a1 and check:

        mysql> insert into db1.t1 values (3,'guangzhou');\nQuery OK, 1 row affected (0.05 sec)\n\nmysql> select * from db1.t1;\n+------+-----------+\n| c1   | c2        |\n+------+-----------+\n|    3 | guangzhou |\n+------+-----------+\n1 row in set (0.01 sec)\n

        It can be seen that even though the database and table in account a1 have the same name, the two databases and tables do not interfere with each other and are completely isolated.

      "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/","title":"Create a new account, use the new account, creates users, create roles, and grant the privilege","text":"

      When initializing access to the MatrixOne cluster, the system will automatically generate a default account, which is the cluster administrator. The default user name of the cluster administrator is root. root is both a cluster administrator and a system account administrator. root can create and manage other common accounts (non-system account administrators).

      This document will guide you through creating a new account, switching to the new account to log in, using the new account account to create users, creating roles, creating permissions, and granting user privileges.

      "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#before-you-start","title":"Before you start","text":"
      • MatrixOne cluster has been depolyed and connected.
      • You have obtained the cluster administrator user name and password (The default user name and password are root and 111 respectively).
      "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#steps","title":"Steps","text":""},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#step-1-create-a-new-account","title":"Step 1: Create a new account","text":"
      1. Log into MatrixOne with the cluster administrator's username (root by default) and password:

        mysql -h 127.0.0.1 -P 6001 -u root -p\n
      2. Create a new account a1; the username and password of account a1 are: admin, test123:

        create account a1 ADMIN_NAME 'admin' IDENTIFIED BY 'test123';\n

        Check all accounts information in the cluster (only root can view):

        mysql> select * from mo_catalog.mo_account;\n+------------+--------------+--------+---------------------+----------------+----------------+\n| account_id | account_name | status | created_time        | comments       | suspended_time |\n+------------+--------------+--------+---------------------+----------------+----------------+\n|          1 | a1           | open   | 2022-12-19 14:47:19 |                | NULL           |\n|          0 | sys          | open   | 2022-12-07 11:00:58 | system account | NULL           |\n+------------+--------------+--------+---------------------+----------------+----------------+\n
      "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#step-2-log-in-to-the-new-account-account-create-users-create-roles-and-grant-the-privilege","title":"Step 2: Log in to the new account account, create users, create roles and grant the privilege","text":"
      1. You can reopen a new session with admin login to account a1:

        mysql -h 127.0.0.1 -P 6001 -u a1:admin -p\n
      2. Now you can check the default users and roles under the account as a1:

        mysql> select * from mo_catalog.mo_role;\n+---------+--------------+---------+-------+---------------------+----------+\n| role_id | role_name    | creator | owner | created_time        | comments |\n+---------+--------------+---------+-------+---------------------+----------+\n|       2 | accountadmin |       0 |     0 | 2022-12-19 14:47:20 |          |\n|       1 | public       |       0 |     0 | 2022-12-19 14:47:20 |          |\n+---------+--------------+---------+-------+---------------------+----------+\n2 rows in set (0.01 sec)\n\nmysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time        | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n|       2 | localhost | admin     | test123               | unlock | 2022-12-19 14:47:20 | NULL         | PASSWORD   |       0 |     0 |            2 |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n1 row in set (0.00 sec)\n

        After account a1 is successfully created, it has account administrator privileges by default so that you can view the system table information under account a1. In the mo_user table, it can be observed that there is currently a user account named admin, which is specified when creating a account; in addition, there are two default roles, accountadmin and public:

        • accountadmin has the highest authority of the account, and the account named admin is granted by default;
        • The system will authorize the public role for each new ordinary user by default, and the initial permission of the public role is connect, that is, to connect to MatrixOne.

        In addition, you can also view the privilege sets of these default roles in the system table:

        mysql> select * from mo_catalog.mo_role_privs;\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n| role_id | role_name    | obj_type | obj_id | privilege_id | privilege_name     | privilege_level | operation_user_id | granted_time        | with_grant_option |\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n|       2 | accountadmin | account  |      0 |            3 | create user        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            4 | drop user          | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            5 | alter user         | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            6 | create role        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            7 | drop role          | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            9 | create database    | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           10 | drop database      | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           11 | show databases     | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           12 | connect            | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           13 | manage grants      | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           14 | account all        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           18 | show tables        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           20 | create table       | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           23 | drop table         | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           26 | alter table        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           21 | create view        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           24 | drop view          | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           27 | alter view         | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           28 | database all       | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           29 | database ownership | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           30 | select             | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           31 | insert             | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           32 | update             | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           33 | truncate           | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           34 | delete             | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           35 | reference          | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           36 | index              | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           37 | table all          | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           38 | table ownership    | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           41 | values             | t               |                 0 | 2022-12-19 14:47:20 | true              |\n|       1 | public       | account  |      0 |           12 | connect            | *               |                 0 | 2022-12-19 14:47:20 | true              |\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n
      3. In account a1, create a new user and role:

        • Username and password for user u1 are: u1, user123
        • Username and password for user u2 are: u2, user456
        • Role r1 is named: r1
        • Role r2 is named: r2
        create user u1 identified by 'user123';\ncreate user u2 identified by 'user456';\ncreate role r1;\ncreate role r2;\n
      4. Create database db1 and create table t1 in db1:

        create database db1;\ncreate table db1.t1(c1 int,c2 varchar);\n
      5. Grant select privilege on db1.t1 to r1 and insert privilege to r2:

        grant select on table db1.t1 to r1;\ngrant insert on table db1.t1 to r2;\n
      6. Grant role r1 to user u1; grant role r2 to user u2:

        grant r1 to u1;\ngrant r2 to u2;\n

        At this point, the newly created user, role, and object permission relationship is shown in the following figure:

      "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#step-3-verify-the-privilege-is-valid","title":"Step 3: Verify the privilege is valid","text":"

      Log in to account a1 with users u1 and u2, respectively, to verify that the privileges are in effect.

      Since u2 has been granted the r2 role, and r2 has been granted the insert privilege of db1.t1, so u2 has the insert privilege of db1.t1, that is, db1.t1 insert data.

      Use u1 to log into a1 to verify that the privilege is valid:

      mysql -h 127.0.0.1 -P 6001 -u a1:u2:r2 -p\n\nmysql> insert into db1.t1 values (1,'shanghai'),(2,'beijing');\nQuery OK, 2 rows affected (0.04 sec)\n\nmysql> select * from db1.t1;\nERROR 20101 (HY000): internal error: do not have privilege to execute the statement\n

      u2 can successfully insert data into the table db1.t1, but cannot view the data in the table db1.t1.

      Similarly, you can use u1 to log in to a1 for privilege verification:

      mysql -h 127.0.0.1 -P 6001 -u a1:u1:r1 -p\n\nmysql> select * from db1.t1;\n+------+----------+\n| c1   | c2       |\n+------+----------+\n|    1 | shanghai |\n|    2 | beijing  |\n+------+----------+\n2 rows in set (0.01 sec)\n\nmysql> insert into db1.t1 values (3,'guangzhou');\nERROR 20101 (HY000): internal error: do not have privilege to execute the statement\n

      As shown in the above code, u1 can successfully query the data of table db1.t1, but cannot insert data into it.

      Note

      For more information about system tables, see MatrixOne System Database and Tables

      "},{"location":"MatrixOne/Security/how-tos/user-guide/","title":"Privileges Management Overview","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#manage-account","title":"Manage Account","text":"
      • Prerequisites: Account management is only possible with a cluster administrator (the default account is the root).

      The roles and permissions corresponding to the root are shown in the following table:

      Username Explanation Role Privilege Description root Cluster administrator MOADMIN Create, edit, delete accounts Automatically generated and granted after cluster creation root System account administrator MOADMIN Manage all resources under the system account, including users, roles, databases/tables/views, authorization management Automatically generated and granted after the cluster is created"},{"location":"MatrixOne/Security/how-tos/user-guide/#create-account","title":"Create Account","text":"

      SQL Statement

      create account <account_name> admin_name='<user_name>' identified by '<password>';\n

      Parameter Description

      Parameter Description account_name account name user_name The administrator username of the newly created account, which will be automatically granted the highest privilege role of the account, namely ACCOUNTADMIN password Newly created account administrator password

      For more information, see CREATE ACCOUNT.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#select-account","title":"Select Account","text":"

      SQL Statement

      select * from mo_catalog.mo_account;\n
      "},{"location":"MatrixOne/Security/how-tos/user-guide/#delect-account","title":"Delect Account","text":"

      SQL Statement

      drop account if exists <account_name>;\n

      Parameter Description

      Parameter Description account_name The name of the account to be deleted

      Note

      After the account is deleted, it cannot be restored, including all data under the account account. Please use it with caution.

      For more information, see DROP ACCOUNT.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#manage-user","title":"Manage User","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#create-user","title":"Create User","text":"
      • Prerequisites: Has the CREATE USER privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Create a username and password for a user in the current account.

      SQL Statement

      create user <user_name> identified by '<password>';\n

      Parameter Description

      Parameter Description user_name The name of a new user password The password of a new user

      For more information, see CREATE USER.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#view-user","title":"View User","text":"
      • Prerequisites: Has the privilege to view users.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: View all the users in the current account.

      SQL Statement

      select * from mo_catalog.mo_user;\n
      "},{"location":"MatrixOne/Security/how-tos/user-guide/#delete-user","title":"Delete User","text":"
      • Prerequisites: Has the DROP USER privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Delete the specified user in the current account.

      SQL Statement

      drop user if exist <user_name>;\n

      Parameter Description

      Parameter Description user_name The name of the user to be deleted

      Note

      When deleting a user, you need to stop the user's current session first, otherwise the deletion will fail.

      For more information, see DROP USER.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#manage-role","title":"Manage Role","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#create-role","title":"Create Role","text":"
      • Prerequisites: Has the CREATE ROLE privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Create a custom role in the current account.

      SQL Statement

      create role <role_name>;\n

      Parameter Description

      Parameter Description role_name The name of a new role

      For more information, see CREATE ROLE.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#view-role","title":"View Role","text":"
      • Prerequisites: Has the privilege to view role.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: View all the roles in the current account.

      SQL Statement

      select * from mo_catalog.mo_role;\n
      "},{"location":"MatrixOne/Security/how-tos/user-guide/#switch-role","title":"Switch Role","text":"
      • Prerequisites: Has the SET ROLE privilege. By default, all users have this privilege.

      • Introduction: Switch the role of the user in the account, and obtain the privilege of the secondary role to execute the corresponding SQL.

      SQL Statement

      set role <role_name>;\n

      Parameter Description

      Parameter Description role_name The name of the role to be switched

      For more information, see SET ROLE.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#delete-role","title":"Delete Role","text":"
      • Prerequisites: Has the DROP ROLE privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Delete the specified role in the current account.

      SQL Statement

      drop role if exists <role_name>;\n

      Parameter Description

      Parameter Description role_name The name of the role to be deleted

      Note

      When deleting a specified role, the roles of authorized users will be recovered simultaneously.

      For more information, see DROP ROLE.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#manage-privilege","title":"Manage Privilege","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#grant-an-object-privilege-to-a-role","title":"Grant an object privilege to a role","text":"
      • Prerequisites: Has the MANAGE GRANTS privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Grant an object privilege to a role.

      SQL Statement

      grant <privilege> on <object_type> <object_name> to <role_name>\n

      Parameter Description

      Parameter Description privilege Privilege Name object_type The type of object object_name The name of object role_name The name of the role which is granted

      For more information, see GRANT.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#grant-certain-kind-of-object-privileges-to-a-role","title":"Grant certain kind of object privileges to a role","text":"
      • Prerequisites: Has the MANAGE GRANTS privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Grant the privilege on all databases/tables to a role.

      SQL Statement

      grant <privilege> on database * to <role_name>;\ngrant <privilege> on table *.* to <role_name>;\n

      Parameter Description

      Parameter Description privilege Privilege Name role_name The name of the role which is granted

      Note

      Although this operation is relatively simple when authorizing multiple objects of the same category, it is also prone to permission leakage, so please use it with caution.

      For more information, see GRANT.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#grant-a-role-to-a-user","title":"Grant a role to a user","text":"
      • Prerequisites: Has the MANAGE GRANTS privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Grant a role to a user.

      SQL Statement

      grant <role_name> to <user_name>;\n

      Parameter Description

      Parameter Description role_name The name of the role which is granted user_name The name of the user which is granted

      For more information, see GRANT.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#one-role-inherit-the-privileges-of-another-role","title":"One role inherit the privileges of another role","text":"
      • Prerequisites: Has the MANAGE GRANTS privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Let role_b inherit all privileges of role_a.

      SQL Statement

      grant <role_a> to <role_b>;\n

      Note

      The permissions are inherited dynamically. If the permissions of role_a change, the permissions inherited by role_b will also change dynamically. MatrixOne does not allow role ring inheritance; that is, role1 inherits role2, role2 inherits role3, but role3 can not inherits role1.

      For more information, see GRANT ROLE.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#show-the-privilege-of-user","title":"Show the privilege of user","text":"
      • Prerequisites: Has the SHOW GRANTS privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Show all privileges currently owned by the specified user.

      SQL Statement

      show grants for <user_name>@<localhost>\n

      Parameter Description

      Parameter Description user_name The name of user which is granted.

      For more information, see SHOW GRANTS.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#revoke-the-role-of-user","title":"Revoke the role of user","text":"
      • Prerequisites: Has the REVOKE privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Remove a role from a user.

      SQL Statement

      revoke <role_name> from <user_name>\n

      Parameter Description

      Parameter Description role_name The name of role which is granted. user_name The name of user which is granted.

      For more information, see REVOKE.

      "},{"location":"MatrixOne/Security/how-tos/user-guide/#revoke-privilege-of-roles","title":"Revoke privilege of roles","text":"
      • Prerequisites: Has the REVOKE privilege.

        \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

      • Introduction: Revoke privileges on an object in a role.

      SQL Statement

      revoke <privilege> on <object_type> <object_name> to <role_name>;\n

      Parameter Description

      Parameter Description privilege Privilege object_type The type of the object object_name The name of the object role_name A role that needs to be granted

      For more information, see REVOKE.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/","title":"Privilege Management Overview","text":"

      MatrixOne privilege management helps you manage accounts and users' life cycles, assign users complementary roles, and control access rights to resources in MatrixOne. When there are multiple users in a database or cluster unit, privilege management ensures that users only access authorized help, and granting users the principle of least authority can reduce enterprise information security risks. MatrixOne can also implement multi-account solutions through rights management. In MatrixOne, the data or resources owned by each account in the cluster are safely isolated, and users across cluster units cannot access the help of other cluster units. Only users authorized to access resources in the cluster have the right to access this A resource within a cluster unit.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#privilege-management-features","title":"Privilege Management Features","text":"

      MatrixOne's privilege management is designed and implemented by combining two security models: RBAC (Role-based access control) and discretionary access control (DAC, Discretionary access control). These two security models are neutral access. The control mechanism mainly revolves around role and authority authorization strategies. It not only ensures data access security but also provides flexible and convenient management methods for database operation and maintenance personnel.

      • Role-Based Access Control (RBAC): assign privileges to roles, and then assign roles to users.

      • Discretionary Access Control (DAC): Every object has an owner who can set and grant access privileges to that object.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#key-concepts","title":"Key Concepts","text":""},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#object","title":"Object","text":"

      In MatrixOne, the privileges are encapsulated in an entity, which is objectto facilitate the management of multiple operation privileges.

      For example, operation privileges such as Select, Insert, and Update is encapsulated in the Table object. For more information about object privileges, please refer to MatrixOne Privilege Control Types.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#relationship-between-objects","title":"Relationship between objects","text":"

      As shown in the diagram below: from above, higher-level objects can create (or delete) lower-level objects.

      The hierarchical relationships in the above figure are all 1:n relationships; that is, multiple accounts can be created in one cluster, multiple users and roles can be created under one account, and multiple tables and views can be created in one database.

      In MatrixOne, although the operation privileges in each object are independent of each other (for example, the SHOW TABLES privilege in the Database object is not directly related to the SELECT privilege in the Table object), the creation of objects still has Certain associations, for example, the CREAT TABLE privilege in the Database object can create Table objects, which forms a hierarchical relationship between objects,

      Then, since high-level objects can create low-level objects, the higher-level objects are object creators (Owner).

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#object-creators-owner","title":"Object creators (Owner)","text":"

      When an object is created, the creator is the object's owner, who has the highest authority to manage the object (that is, Ownership authority, which is all the authority encapsulated in the object). The owner's operation authority sets all operations on the object.

      For example, the Table object has Select, Insert, Update, Delete, Truncate, and Ownership privileges; if a role has the Ownership privilege of a certain Table, then the role is equivalent to having Select, Insert, Update, Delete, Truncate privileges.

      Due to the transitivity between privileges, roles, and users, you can understand the creator of an object (starting now referred to as the object owner) as a role.

      How to understand that the creator of an object is a role?

      A user can have multiple roles at the same time. For example, User A has three roles: Role 1, Role 2, and Role 3. Each role has different privileges, as shown in the following figure, to help you quickly understand this behavior:

      If User A is currently using Role 1, User A needs to create a new User B, but the current Role 1 does not have privilege to create new users. Role 2 has the authorization to create new users, then User A needs to switch to the Role 2 role and create a new user. Then, the Owner of New User B is Role 2, and other roles, Role 1 and Role 3, cannot have the ownership of User B.

      Owner points to the object

      • An object's Owner is a role, and the object's original Owner is the role that created it.

      • There is only one Owner of an object at any time.

      • A role can create multiple objects so that a role can be the Owner of multiple objects.

      • A role is an object, so a role also has an Owner.

      • When the Owner of an object is deleted, the Owner of the object will be automatically changed to the Owner of the deleted role.

      • The owner can be transferred to another role.

      Note: ACCOUNTADMIN (account administrator role, automatically generated after the account is created) is not the Owner of the objects used in the account. Still, it has the Ownership privilege of all objects.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#cluste","title":"Cluste","text":"

      The cluster is the highest-level object in MatrixOne privileges management.

      Tip: The collection of operational privileges on cluster objects is called system privileges.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#account","title":"Account","text":"

      In the MatrixOne cluster, multiple accounts with completely isolated data and user authority systems can be created and managed, and these resource-isolated accounts can be managed. This multi-account function not only saves the cost of deploying and operating multiple sets of data business systems but also can take advantage of sharing hardware resources between accounts to save machine costs to the greatest extent.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#system-account","title":"System Account","text":"

      To be compatible with the usage habits of traditional non-multi-account databases, MatrixOne will automatically create a new system default account after the cluster is created, that is, Sys Account. If you only have one set of data business systems that need to be managed by MatrixOne, there is no need to create more accounts, log in and access the Sys Account directly.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#role","title":"Role","text":"

      A role is also an object used to manage and grant privileges in MatrixOne.

      First of all, you need to have a high-privilege account first to do some initial resource allocation; for example, create some roles and users by Sys Account or Account, grant object privileges to the role, and then grant the role to the user, at this time, the user can operate on the object. It needs to be granted to a user. In a account, the user cannot perform any operations if a user is not granted a role.

      Role is set up to save the operation cost of granting the same authority. The three privileges p1, p2, and p3 must be granted to users u1, u2, and u3. You only need to grant p1, p2, and p3 to role r1 first, then grant role r1 to users u1, u2, and u3 simultaneously. It is easier to operate than granting each privilege to each user separately, and this advantage will become more obvious as the number of users and privileges increases. At the same time, the emergence of roles further abstracts the privilege set and its relationship, which is also very convenient for later privilege maintenance.

      After the cluster and account (Account) are created, MatrixOne will automatically create some default roles and users (see the Initialization Access section below for details); these roles have the highest management authority and are used to manage the cluster and account at the beginning ( Account), we do not recommend that you grant these roles to users who execute SQL daily. Excessive privileges will introduce more security issues. Therefore, MatrixOne supports the creation of custom roles. You can customize roles according to the user's business needs and assign appropriate privileges to these roles.

      Highlights

      In MatrixOne, the behavior details of roles are as follows:

      • A role can be granted multiple privileges.
      • A role can be granted to multiple users.
      • A role can pass its privileges to another role.

        • Use all the privileges of a role to another role; for example, pass all the privileges of role1 to role2, then role2 inherits the privileges of role1,
      • Roles and users only take effect within their respective Account, including the Sys Account.

      Note

      1. The privilege inheritance of roles is dynamic. If the privileges of the inherited role change, the scope of privileges inherited by the inherited role will also change dynamically.
      2. The inheritance relationship of roles cannot form a loop. For example, role1 inherits role2, role 2 inherits role3, and role3 inherits role1.
      3. The transfer of privileges between roles makes privilege management more convenient, but it also has risks. For this reason, MatrixOne only allows roles with Manage Grants privilege to do this kind of operation. This privilege is granted to the system default role MOADMIN by default or ACCOUNTADMIN, and it is not recommended to grant this privilege to a custom role when creating a new one.
      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#role-switching","title":"Role Switching","text":"

      A user is granted multiple roles to perform different types of data services.

      Main role: The user can only use one of the roles at a particular moment; we call the currently used role main role.

      Secondary role: In addition to the main role, the set of other roles owned by the user is called the secondary role.

      By default, if a user wants to execute SQL with another role's privilege, he needs to switch roles first (Use SQL as set role <role>). In addition, to be compatible with the privilege behavior of classic databases, MatrixOne also supports the function of using secondary roles: use set secondary role all; after executing this SQL, the user can have the privileges of all his roles at the same time, execute set secondary role none to turn off this feature.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#application-scenarios","title":"Application scenarios","text":""},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#resource-isolation-scenarios-introduction","title":"Resource Isolation Scenarios Introduction","text":"

      Company A purchased a MatrixOne cluster and completed the deployment. Since Company A has a large scale, many complex business lines, and a huge amount of data, it wants to develop an application for a certain business line, assuming it is named BusinessApp. Still, it needs to be isolated from the data of other business lines. So how does MatrxiOne isolate these data resources and authority resources?

      After completing the deployment of the MatrixOne cluster, Tom of the R&D department obtained the account of the cluster administrator, and the company assigned him to complete the task of resource isolation. Tom needs to do this:

      1. Tom logs into MatrixOne with the cluster administrator account.
      2. Tom needs to create two accounts first, one is BusinessAccount and the other is ElseAccount.

        • The data resources within BusinessAccount are mainly used to develop the application BusinessApp.
        • Data resources within ElseAccount may be used for other business purposes.

      For the specific operation of resource isolation, please refer to Quick Start: Create accounts, Verify Resource Isolation.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#introduction-to-user-creation-and-authorization-scenarios","title":"Introduction to User Creation and Authorization Scenarios","text":"

      Still using the above scenario example, Tom gives the account account BusinessAccount to the company's data administrator Robert, and asks Robert to assign new user accounts and privileges to other R&D colleagues.

      R&D colleague Joe is the application developer of this company. A project BusinessApp, Joe has a development task, and Joe needs to use all the data in the database. Then Robert will help Joe open an account and authorize Joe:

      1. Robert first creates a user account (i.e., user) for Joe, named Joe_G, and Joe uses Joe_G to log in to MatrixOne.
      2. Robert creates another role for Joe, named Appdeveloper, and assigns the Appdeveloper role to Joe's user account Joe_G.
      3. Robert grants the ALL ON DATABASE permission to the role Appdeveloper.
      4. Joe can use the account Joe_G to log in to MatrixOne, and has full authority to operate the database for development.

      For specific user creation and authorization operations, see Quick start: Create a new account, use the new account, creates users, create roles, and grant the privilege.

      "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#initialize-access","title":"Initialize Access","text":"

      After initializing the cluster or account, the system will automatically generate some default users and default roles:

      Username Explanation Role Privilege Description root Cluster administrator MOADMIN Create, edit, delete accounts Automatically generated and granted after cluster creation root System account administrator MOADMIN Manage all resources under the system account, including users, roles, databases/tables/views, authorization management Automatically generated and granted after the cluster is created account administrator ACCOUNTADMIN Manage all resources under common accounts, including users, roles, databases/tables/views, and authorization management Accounts are automatically generated and granted after they are created All users Ordinary users PUBLIC Connect to MatrixOne After all users are created, they are automatically granted the PUBLIC role"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#quick-start","title":"Quick Start","text":"
      • Quick Start: Create accounts, Verify Resource Isolation
      • Quick start: Create a new account, use the new account, creates users, create roles, and grant the privilege
      • Typical Application Scenarios
      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/","title":"Privilege Management Scenario","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-overview","title":"Scenario overview","text":"
      • If your company has deployed a MatrixOne cluster after the deployment, a cluster administrator will automatically exist when the cluster is initialized. If you like, contact the project manager or sales representative of MatrixOne to get the account information and initial password. Using the cluster administrator, you can create a new account, manage the life cycle of the account, and assign the account account password to the corresponding person in charge of your company. For more information on how to manage accounts, see Quick Start: Create accounts, Verify Resource Isolation or Privilege Management Operation Guide.

      • If your enterprise only needs to use MatrixOne cluster account resources, after the deployment is complete, the MatrixOne cluster administrator will help you open an account administrator account. Please contact the MatrixOne project manager or sales representative for the account information and initial password. Using the account administrator account, you can create new users, manage user lifecycles and resources in the account (users, roles, and permissions), and assign user account passwords to the corresponding persons in charge of your company. For more information on how to manage accounts, see Quick Start: Create accounts, Verify Resource Isolation or Privilege Management Operation Guide.

      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-1-create-a-new-data-administrator-and-grant-the-privilege","title":"Scenario 1: Create a new data administrator and grant the privilege","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-introduction","title":"Scenario Introduction","text":"

      In practical application scenarios, it is necessary to set up a data administrator position responsible for managing the allocation of resources in the entire database. For example, other company members need to be assigned a user account, password, and role and be granted minimum Usage rights.

      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#before-you-start","title":"Before you start","text":"
      • You first need to have an account of account Administrator.

      • Already connected to the MatrixOne cluster.

      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#solution","title":"Solution","text":"

      Create a data administrator role and grant him global management permissions within the account; then, you need to do the following:

      • Create a new user, username: dbauser; password: 123456.
      • Assign a data administrator role to this user, and the role is named: dba.
      • This role requires the following permissions:
        • Own all permissions of the account object: With this permission, the data administrator can create new users and new roles and assign permissions to other users.
        • Own all permissions of database objects: With this permission, the data administrator can create, edit, and delete databases.
        • Own all permissions of the table object: With this permission, the data administrator can create, edit, and delete data tables.
      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#steps","title":"Steps","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#step-1-use-the-account-administrator-to-create-the-database-administrator","title":"Step 1: Use the account administrator to create the database administrator","text":"
      1. Log in to the account with the account administrator account:

        Note: The account administrator account account1 here is an example; you can customize it when creating an account administrator.

        mysql -h 127.0.0.1 -P 6001 -u account1:admin:admin -p\n
      2. Create a user and named dbauser with a password of 123456:

        create user dbauser identified by \"123456\";\n
      3. Create a data administrator role named dba:

        create role dba;\n
      4. Grant the privilege to the role the following permissions:

        • Full permissions on the account object
        • Full permissions on database objects
        • Full permissions on the table object
        grant all on account * to dba with grant option;\ngrant all on database * to dba with grant option;\ngrant all on table *.* to dba with grant option;\n
      5. Grant role dba to user dbauser:

        grant dba to dbauser;\n
      6. Check the privilege using the following command:

        show grants for dbauser@localhost;\n
      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#step-2-use-the-data-administrator-to-log-and-test","title":"Step 2: Use the data administrator to log and test","text":"
      1. Log into MatrixOne with the data administrator account dbauser:

        mysql -h 127.0.0.1 -P 6001 -u account1:dbauser:dba -p\n
      2. Check the privileges of dbauser:

        show grants for dbauser@localhost;\n
      3. Check the role of dbauser:

        SET SECONDARY ROLE ALL;\nuse mo_catalog;\nselect mu.user_name,mr.role_name from mo_role mr,mo_user mu,mo_user_grant mug where mu.user_id=mug.user_id and mr.role_id=mug.role_id and mu.user_name='dbauser';\n
      4. Create a database to verify the privilege is valid:

        drop database if exists test;\ncreate database test;\nuse test;\ncreate table t1(a int);\ninsert into t1 values(1),(2),(3);\nselect * from t1;\n
      5. The above code indicates that the verification is successful.

      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-2-application-system-goes-online","title":"Scenario 2: Application System Goes Online","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-introduction_1","title":"Scenario Introduction","text":"

      When the application system goes online, a new database and corresponding database user will be created according to the usage requirements of the application system, and this user will be granted all permissions of the target database.

      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#before-you-start_1","title":"Before you start","text":"
      • You first need to have an account of account administrator (or you, as a user, already have full privileges to create new users and authorize new user the database objects).

      • Already connected to the MatrixOne cluster.

      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#solution_1","title":"Solution","text":"
      • Requirement 1: The application system requires a new database dedicated to application development.

        • Solution: Create a new database named appdb.
      • Requirement 2: The application system requires a dedicated role.

        • Solution: Create a new database role, named approle, and grant all database privileges to this role.
      • Requirement 3: The application system requires a dedicated person to manage the database.

        • Solution: Create a new database user, named appuser, and authorize the role to this user.
      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#steps_1","title":"Steps","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#step-1-the-account-administrator-creates-and-authorizes-the-database-user","title":"Step 1: The account administrator creates and authorizes the database user","text":"
      1. Log in to the account with the account administrator:

        Note: The account administrator account account1 here is an example; you can customize it when creating an account administrator.

        mysql -h 127.0.0.1 -P 6001 -u account1:admin:admin -p\n
      2. To create the database required by the application, name the database appdb :

        create database appdb;\n
      3. Create a role named approle and grant this role full privilege to database appdb :

        create role approle;\ngrant all on database appdb to approle;\ngrant all on table appdb.* to approle;\n
      4. Create user appuser with password 123456 and grant the role approle to appuser :

        create user appuser identified by \"123456\" default role approle;\n
      "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#step-2-use-the-data-user-to-log-in-and-test","title":"Step 2: Use the data user to log in and test","text":"
      1. Log into MatrixOne with the data user appuser:

        mysql -h127.0.0.1 -utest:appuser -P6001 -p123456\n
      2. Verify the privileges of the data user appuser:

        set secondary role all;\nuse appdb;\ncreate table t1(a int);\ninsert into t1 values(1),(2),(3);\nselect * from t1;\ndrop table t1;\n
      3. The above code indicates that the verification is successful.

      "},{"location":"MatrixOne/Security/role-priviledge-management/best-practice/","title":"Best Practices","text":"

      The following are typical roles and recommended minimum permissions in MatrixOne for you to reference.

      "},{"location":"MatrixOne/Security/role-priviledge-management/best-practice/#engineer-responsible-for-database-resource-user-role-permission-management","title":"Engineer responsible for database resource (user, role, permission) management","text":"

      Database Administrator

      • Main job functions: manage all configuration information in the tenant, user permissions, backup and recovery, performance tuning, troubleshooting
      • Reference grant role: the default administrator role accountadmin generated when creating a tenant.
      • Refer to granting permissions: user management (CREATE USER, ALTER USER, DROP USER), authority management (MANAGE GRANTS)
      "},{"location":"MatrixOne/Security/role-priviledge-management/best-practice/#engineer-responsible-for-data-management","title":"Engineer responsible for data management","text":"

      Data Operation and Maintenance Engineer

      • Main job function: manage all data and metadata information in the tenant, and authorize data permissions
      • Refer to Granting Permissions: Tenant-Level Data Management (ALL ON ACCOUNT)

      App Developer

      • Main job function: operate specific databases under the development environment tenant, and have read-only permission from the system tenant
      • Refer to grant permissions: database level data management (ALL ON DATABASE), system database read-only (SELECT ON DATABASE)

      Application System Management Engineer

      • Main job function: operate specific databases under the production environment tenant
      • Refer to Granting Permissions: Data Management at the Database Level (ALL ON DATABASE)

      System Monitoring Engineer

      • Main job function: monitor all system statistics and error messages under the tenant
      • Refer to grant permissions: read-only permissions for all system databases (SELECT ON DATABASE)
      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/","title":"Complete a SSB Test with MatrixOne","text":"

      The Star Schema Benchmark(SSB)Test is a popular scenario for OLAP database performance test. By going through this tutorial, you'll learn how to complete a SSB Test with MatrixOne.

      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#1-compile-dbgen","title":"1. Compile dbgen","text":"
      git clone git@github.com:vadimtk/ssb-dbgen.git\ncd ssb-dbgen\nmake\n

      Note

      Compile dbgen on a PC with M1 chip. See Deployment FAQs.

      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#2-generate-data","title":"2. Generate data","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#option-1-generate-the-single-table-dataset","title":"Option 1: Generate the single table dataset","text":"

      With -s 1 dbgen generates 6 million rows (670MB), while while -s 10 it generates 60 million rows (which takes some time)

      ./dbgen -s 1 -T c\n./dbgen -s 1 -T l\n./dbgen -s 1 -T p\n./dbgen -s 1 -T s\n./dbgen -s 1 -T d\n
      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#option-2-download-the-large-wide-table-dataset","title":"Option 2: Download the large wide table dataset","text":"

      We have also prepared a 1GB large wide table dataset for downloading. You can get the data files directly:

      https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/lineorder_flat.tar.bz2\n
      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#3-create-tables-in-matrixone","title":"3. Create tables in MatrixOne","text":"
      create database if not exists ssb;\nuse ssb;\n\ndrop table if exists lineorder;\ndrop table if exists part;\ndrop table if exists supplier;\ndrop table if exists customer;\ndrop table if exists date;\ndrop table if exists lineorder_flat;\n\ncreate table lineorder (\n        lo_orderkey bigint,\n        lo_linenumber int,\n        lo_custkey int,\n        lo_partkey int,\n        lo_suppkey int,\n        lo_orderdate date,\n        lo_orderpriority char (15),\n        lo_shippriority tinyint,\n        lo_quantity double,\n        lo_extendedprice double,\n        lo_ordtotalprice double,\n        lo_discount double,\n        lo_revenue double,\n        lo_supplycost double,\n        lo_tax double,\n        lo_commitdate date,\n        lo_shipmode char (10)\n) ;\n\ncreate table part (\n        p_partkey int,\n        p_name varchar (22),\n        p_mfgr char (6),\n        p_category char (7),\n        p_brand char (9),\n        p_color varchar (11),\n        p_type varchar (25),\n        p_size int,\n        p_container char (10)\n) ;\n\ncreate table supplier (\n        s_suppkey int,\n        s_name char (25),\n        s_address varchar (25),\n        s_city char (10),\n        s_nation char (15),\n        s_region char (12),\n        s_phone char (15)\n) ;\n\ncreate table customer (\n        c_custkey int,\n        c_name varchar (25),\n        c_address varchar (25),\n        c_city char (10),\n        c_nation char (15),\n        c_region char (12),\n        c_phone char (15),\n        c_mktsegment char (10)\n) ;\n\ncreate table date (\n        d_datekey date,\n        d_date char (18),\n        d_dayofweek char (9),\n        d_month char (9),\n        d_year int,\n        d_yearmonthnum int,\n        d_yearmonth char (7),\n        d_daynuminweek varchar(12),\n        d_daynuminmonth int,\n        d_daynuminyear int,\n        d_monthnuminyear int,\n        d_weeknuminyear int,\n        d_sellingseason varchar (12),\n        d_lastdayinweekfl varchar (1),\n        d_lastdayinmonthfl varchar (1),\n        d_holidayfl varchar (1),\n        d_weekdayfl varchar (1)\n) ;\n\nCREATE TABLE lineorder_flat(\n  LO_ORDERKEY bigint key,\n  LO_LINENUMBER int,\n  LO_CUSTKEY int,\n  LO_PARTKEY int,\n  LO_SUPPKEY int,\n  LO_ORDERDATE date,\n  LO_ORDERPRIORITY char(15),\n  LO_SHIPPRIORITY tinyint,\n  LO_QUANTITY double,\n  LO_EXTENDEDPRICE double,\n  LO_ORDTOTALPRICE double,\n  LO_DISCOUNT double,\n  LO_REVENUE int unsigned,\n  LO_SUPPLYCOST int unsigned,\n  LO_TAX double,\n  LO_COMMITDATE date,\n  LO_SHIPMODE char(10),\n  C_NAME varchar(25),\n  C_ADDRESS varchar(25),\n  C_CITY char(10),\n  C_NATION char(15),\n  C_REGION char(12),\n  C_PHONE char(15),\n  C_MKTSEGMENT char(10),\n  S_NAME char(25),\n  S_ADDRESS varchar(25),\n  S_CITY char(10),\n  S_NATION char(15),\n  S_REGION char(12),\n  S_PHONE char(15),\n  P_NAME varchar(22),\n  P_MFGR char(6),\n  P_CATEGORY char(7),\n  P_BRAND char(9),\n  P_COLOR varchar(11),\n  P_TYPE varchar(25),\n  P_SIZE int,\n  P_CONTAINER char(10)\n);\n
      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#4-load-data-into-the-created-tables","title":"4. Load data into the created tables","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#option-1-load-the-sigle-table-dataset-into-related-tables-with-this-command-in-matrixone","title":"Option 1: Load the sigle table dataset into related tables with this command in MatrixOne","text":"
      load data infile '/ssb-dbgen-path/supplier.tbl' into table supplier FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/customer.tbl' into table customer FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/date.tbl' into table date FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/part.tbl' into table part FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/lineorder.tbl' into table lineorder FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n

      Then you can query data in MatrixOne with the created table.

      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#option-2-load-the-large-wide-table-dataset-into-the-lineorder_flat","title":"Option 2: Load the large wide table dataset into the lineorder_flat","text":"
      load data infile '/ssb-dbgen-path/lineorder_flat.tbl' into table lineorder_flat FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#5-run-ssb-queries","title":"5. Run SSB Queries","text":"

      Note

      GROUP BY does not support using the alias name for now.

      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#flat-table-queries","title":"Flat table queries","text":"
      -- Q1.1\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25;\n\n-- Q1.2\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1994 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35;\n\n-- Q1.3\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1994 AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35;\n\n-- Q2.1\nSELECT sum(LO_REVENUE),year(LO_ORDERDATE) AS year,P_BRAND FROM lineorder_flat WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' GROUP BY year(LO_ORDERDATE), P_BRAND ORDER BY year,P_BRAND;\n\n-- Q2.2\nSELECT sum(LO_REVENUE), year(LO_ORDERDATE) AS year, P_BRAND FROM lineorder_flat WHERE P_BRAND BETWEEN 'MFGR#2221' AND 'MFGR#2228' AND S_REGION = 'ASIA' GROUP BY year(LO_ORDERDATE), P_BRAND ORDER BY year, P_BRAND;\n\n-- Q2.3\nSELECT sum(LO_REVENUE), year(LO_ORDERDATE) AS year, P_BRAND FROM lineorder_flat WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' GROUP BY year(LO_ORDERDATE), P_BRAND ORDER BY year, P_BRAND;\n\n-- Q3.1\nSELECT C_NATION, S_NATION, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year(LO_ORDERDATE)  between 1992 AND 1997 GROUP BY C_NATION, S_NATION, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n-- Q3.2\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE C_NATION = 'CHINA' AND S_NATION = 'CHINA' AND year(LO_ORDERDATE)  between 1992 AND 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE)  ORDER BY year asc, revenue desc;\n\n-- Q3.3\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE (C_CITY = 'UNITED KI0' OR C_CITY = 'UNITED KI7') AND (S_CITY = 'UNITED KI0' OR S_CITY = 'UNITED KI7') AND year(LO_ORDERDATE)  between 1992 AND 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n-- Q3.4\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE (C_CITY = 'UNITED KI0' OR C_CITY = 'UNITED KI7') AND (S_CITY = 'MOZAMBIQU1' OR S_CITY = 'KENYA    4') AND year(LO_ORDERDATE)= 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n-- Q4.1\nSELECT year(LO_ORDERDATE) AS year, C_NATION, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') GROUP BY year(LO_ORDERDATE), C_NATION ORDER BY year, C_NATION;\n\n-- Q4.2\nSELECT year(LO_ORDERDATE) AS year, S_NATION, P_CATEGORY, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year(LO_ORDERDATE) = 1997 OR year(LO_ORDERDATE) = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') GROUP BY  year(LO_ORDERDATE), S_NATION, P_CATEGORY ORDER BY year, S_NATION, P_CATEGORY;\n\n-- Q4.3\nSELECT year(LO_ORDERDATE) AS year, S_CITY, P_BRAND, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE S_NATION = 'UNITED STATES' AND (year(LO_ORDERDATE) = 1997 OR year(LO_ORDERDATE) = 1998) AND P_CATEGORY = 'MFGR#14' GROUP BY  year(LO_ORDERDATE), S_CITY, P_BRAND ORDER BY year, S_CITY, P_BRAND;\n
      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#multiple-tables-queries","title":"Multiple tables queries","text":"
      -- Q1.1\nselect sum(lo_revenue) as revenue\nfrom lineorder join date on lo_orderdate = d_datekey\nwhere year(d_datekey)  = 1993 and lo_discount between 1 and 3 and lo_quantity < 25;\n\n-- Q1.2\nselect sum(lo_revenue) as revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\nwhere d_yearmonthnum = 199401\nand lo_discount between 4 and 6\nand lo_quantity between 26 and 35;\n\n-- Q1.3\nselect sum(lo_revenue) as revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\nwhere d_weeknuminyear = 6 and year(d_datekey)  = 1994\nand lo_discount between 5 and 7\nand lo_quantity between 26 and 35;\n\n-- Q2.1\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_category = 'MFGR#12' and s_region = 'AMERICA'\ngroup by year(d_datekey), p_brand\norder by year, p_brand;\n\n-- Q2.2\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_brand between 'MFGR#2221' and 'MFGR#2228' and s_region = 'ASIA'\ngroup by year(d_datekey), p_brand\norder by year, p_brand;\n\n-- Q2.3\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_brand = 'MFGR#2239' and s_region = 'EUROPE'\ngroup by year(d_datekey), p_brand\norder by year, p_brand;\n\n-- Q3.1\nselect c_nation, s_nation, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere c_region = 'ASIA' and s_region = 'ASIA' and year(d_datekey) between 1992 and 1997\ngroup by c_nation, s_nation, year(d_datekey)\norder by year asc, lo_revenue desc;\n\n-- Q3.2\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere c_nation = 'UNITED STATES' and s_nation = 'UNITED STATES'\nand year(d_datekey) between 1992 and 1997\ngroup by c_city, s_city, year(d_datekey)\norder by year asc, lo_revenue desc;\n\n-- Q3.3\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere (c_city='UNITED KI1' or c_city='UNITED KI5')\nand (s_city='UNITED KI1' or s_city='UNITED KI5')\nand year(d_datekey) between 1992 and 1997\ngroup by c_city, s_city, year(d_datekey)\norder by year asc, lo_revenue desc;\n\n-- Q3.4\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere (c_city='UNITED KI1' or c_city='UNITED KI5') and (s_city='UNITED KI1' or s_city='UNITED KI5') and d_yearmonth = '199712'\ngroup by c_city, s_city, year(d_datekey)\norder by year(d_datekey) asc, lo_revenue desc;\n\n-- Q4.1\nselect year(d_datekey) as year, c_nation, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere c_region = 'AMERICA' and s_region = 'AMERICA' and (p_mfgr = 'MFGR#1' or p_mfgr = 'MFGR#2')\ngroup by year(d_datekey), c_nation\norder by year, c_nation;\n\n-- Q4.2\nselect year(d_datekey) as year, s_nation, p_category, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere c_region = 'AMERICA'and s_region = 'AMERICA'\nand (year(d_datekey) = 1997 or year(d_datekey) = 1998)\nand (p_mfgr = 'MFGR#1' or p_mfgr = 'MFGR#2')\ngroup by year(d_datekey), s_nation, p_category\norder by year, s_nation, p_category;\n\n-- Q4.3\nselect year(d_datekey) as year, s_city, p_brand, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin dates on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere\n(year(d_datekey) = 1997 or year(d_datekey) = 1998)\nand c_region = 'AMERICA'\nand s_nation = 'UNITED STATES'\nand p_category = 'MFGR#14'\ngroup by year, s_city, p_brand\norder by year, s_city, p_brand;\n
      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#6-expected-results","title":"6. Expected Results","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#flat-table-queries-expected-results","title":"Flat table queries expected results","text":"
      -- Q1.1\n+--------------+\n| revenue      |\n+--------------+\n| 702223464659 |\n+--------------+\n\n-- Q1.2\n+---------------+\n| revenue       |\n+---------------+\n| 1842875090496 |\n+---------------+\n\n-- Q1.3\n+---------------+\n| revenue       |\n+---------------+\n| 2208738861324 |\n+---------------+\n\n-- Q2.1\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand   |\n+-----------------+------+-----------+\n|       283684289 | 1992 | MFGR#121  |\n|      1344702529 | 1992 | MFGR#1210 |\n|       757158682 | 1992 | MFGR#1211 |\n|      1156022815 | 1992 | MFGR#1212 |\n|       676164367 | 1992 | MFGR#1213 |\n|       522779256 | 1992 | MFGR#1214 |\n|       233507213 | 1992 | MFGR#1215 |\n|       726755819 | 1992 | MFGR#1216 |\n|      1865504710 | 1992 | MFGR#1217 |\n|       685600451 | 1992 | MFGR#1218 |\n|       814671470 | 1992 | MFGR#1219 |\n|       655405800 | 1992 | MFGR#122  |\n|       962120553 | 1992 | MFGR#1220 |\n|       961393626 | 1992 | MFGR#1221 |\n|       922110830 | 1992 | MFGR#1222 |\n|       814842712 | 1992 | MFGR#1223 |\n|      1402773165 | 1992 | MFGR#1224 |\n|       977517439 | 1992 | MFGR#1225 |\n|      1392114944 | 1992 | MFGR#1226 |\n|       658922951 | 1992 | MFGR#1227 |\n|       892495927 | 1992 | MFGR#1228 |\n|       806609100 | 1992 | MFGR#1229 |\n|       578875657 | 1992 | MFGR#123  |\n|       691236902 | 1992 | MFGR#1230 |\n|       482715249 | 1992 | MFGR#1231 |\n|       618556590 | 1992 | MFGR#1232 |\n|       981657009 | 1992 | MFGR#1233 |\n|      1050794669 | 1992 | MFGR#1234 |\n|      1335217991 | 1992 | MFGR#1235 |\n|       686009527 | 1992 | MFGR#1236 |\n|       605242584 | 1992 | MFGR#1237 |\n|       430455641 | 1992 | MFGR#1238 |\n|       359654993 | 1992 | MFGR#1239 |\n|       818818457 | 1992 | MFGR#124  |\n|      1388502581 | 1992 | MFGR#1240 |\n|       711566198 | 1992 | MFGR#125  |\n|       893045647 | 1992 | MFGR#126  |\n|      1240534333 | 1992 | MFGR#127  |\n|       871966127 | 1992 | MFGR#128  |\n|       719176622 | 1992 | MFGR#129  |\n|       245880758 | 1993 | MFGR#121  |\n|      1480662753 | 1993 | MFGR#1210 |\n|       982292725 | 1993 | MFGR#1211 |\n|      1001136766 | 1993 | MFGR#1212 |\n|       227144072 | 1993 | MFGR#1213 |\n|       291611370 | 1993 | MFGR#1214 |\n|       454576668 | 1993 | MFGR#1215 |\n|       772027256 | 1993 | MFGR#1216 |\n|      1155751851 | 1993 | MFGR#1217 |\n|       897883050 | 1993 | MFGR#1218 |\n|      1209508962 | 1993 | MFGR#1219 |\n|       530577973 | 1993 | MFGR#122  |\n|       901650471 | 1993 | MFGR#1220 |\n|       739540494 | 1993 | MFGR#1221 |\n|       698751459 | 1993 | MFGR#1222 |\n|      1327979157 | 1993 | MFGR#1223 |\n|      1476697469 | 1993 | MFGR#1224 |\n|       792103134 | 1993 | MFGR#1225 |\n|      1420277376 | 1993 | MFGR#1226 |\n|      1446032835 | 1993 | MFGR#1227 |\n|       884375309 | 1993 | MFGR#1228 |\n|       522705868 | 1993 | MFGR#1229 |\n|       601685233 | 1993 | MFGR#123  |\n|       806727248 | 1993 | MFGR#1230 |\n|       399477390 | 1993 | MFGR#1231 |\n|       894047578 | 1993 | MFGR#1232 |\n|       496067089 | 1993 | MFGR#1233 |\n|      1050223756 | 1993 | MFGR#1234 |\n|       891681399 | 1993 | MFGR#1235 |\n|      1402903631 | 1993 | MFGR#1236 |\n|       347380448 | 1993 | MFGR#1237 |\n|       514853194 | 1993 | MFGR#1238 |\n|       410543863 | 1993 | MFGR#1239 |\n|       673483594 | 1993 | MFGR#124  |\n|       713343630 | 1993 | MFGR#1240 |\n|       512610707 | 1993 | MFGR#125  |\n|      1228110634 | 1993 | MFGR#126  |\n|       936958961 | 1993 | MFGR#127  |\n|       579067515 | 1993 | MFGR#128  |\n|       636174833 | 1993 | MFGR#129  |\n|       370347074 | 1994 | MFGR#121  |\n|       483900410 | 1994 | MFGR#1210 |\n|      1240306281 | 1994 | MFGR#1211 |\n|      1003345253 | 1994 | MFGR#1212 |\n|       557310864 | 1994 | MFGR#1213 |\n|       314972328 | 1994 | MFGR#1214 |\n|      1130260810 | 1994 | MFGR#1215 |\n|       401618319 | 1994 | MFGR#1216 |\n|       652173601 | 1994 | MFGR#1217 |\n|       923612074 | 1994 | MFGR#1218 |\n|       469711377 | 1994 | MFGR#1219 |\n|       580152115 | 1994 | MFGR#122  |\n|       433134653 | 1994 | MFGR#1220 |\n|       730569849 | 1994 | MFGR#1221 |\n|       607609104 | 1994 | MFGR#1222 |\n|       949877669 | 1994 | MFGR#1223 |\n|      1644687916 | 1994 | MFGR#1224 |\n|       492974194 | 1994 | MFGR#1225 |\n|       921499688 | 1994 | MFGR#1226 |\n|       719059761 | 1994 | MFGR#1227 |\n|      1000497056 | 1994 | MFGR#1228 |\n|       486968927 | 1994 | MFGR#1229 |\n|       734124906 | 1994 | MFGR#123  |\n|       645016873 | 1994 | MFGR#1230 |\n|       526638240 | 1994 | MFGR#1231 |\n|      1358112405 | 1994 | MFGR#1232 |\n|      1167074905 | 1994 | MFGR#1233 |\n|      1102915239 | 1994 | MFGR#1234 |\n|       693058125 | 1994 | MFGR#1235 |\n|      1673392892 | 1994 | MFGR#1236 |\n|       849630029 | 1994 | MFGR#1237 |\n|       721392705 | 1994 | MFGR#1238 |\n|      1237195774 | 1994 | MFGR#1239 |\n|      1107832795 | 1994 | MFGR#124  |\n|       827906290 | 1994 | MFGR#1240 |\n|       682827304 | 1994 | MFGR#125  |\n|      1198768141 | 1994 | MFGR#126  |\n|      1274148181 | 1994 | MFGR#127  |\n|       738849138 | 1994 | MFGR#128  |\n|       751136619 | 1994 | MFGR#129  |\n|       318978803 | 1995 | MFGR#121  |\n|       383199448 | 1995 | MFGR#1210 |\n|      1300165814 | 1995 | MFGR#1211 |\n|      1550400731 | 1995 | MFGR#1212 |\n|       451958158 | 1995 | MFGR#1213 |\n|       431434279 | 1995 | MFGR#1214 |\n|       713735582 | 1995 | MFGR#1215 |\n|       919323722 | 1995 | MFGR#1216 |\n|      1542358864 | 1995 | MFGR#1217 |\n|       500930092 | 1995 | MFGR#1218 |\n|      1208162086 | 1995 | MFGR#1219 |\n|       785707989 | 1995 | MFGR#122  |\n|       993828211 | 1995 | MFGR#1220 |\n|       667253893 | 1995 | MFGR#1221 |\n|      1654114297 | 1995 | MFGR#1222 |\n|       986528377 | 1995 | MFGR#1223 |\n|       755014642 | 1995 | MFGR#1224 |\n|      1090300100 | 1995 | MFGR#1225 |\n|      1063626454 | 1995 | MFGR#1226 |\n|      1382528859 | 1995 | MFGR#1227 |\n|       919953351 | 1995 | MFGR#1228 |\n|       457795295 | 1995 | MFGR#1229 |\n|       953851827 | 1995 | MFGR#123  |\n|       807209283 | 1995 | MFGR#1230 |\n|       236304454 | 1995 | MFGR#1231 |\n|       668449537 | 1995 | MFGR#1232 |\n|       240657083 | 1995 | MFGR#1233 |\n|       920389826 | 1995 | MFGR#1234 |\n|       684096065 | 1995 | MFGR#1235 |\n|      1005844219 | 1995 | MFGR#1236 |\n|       626170996 | 1995 | MFGR#1237 |\n|       984581826 | 1995 | MFGR#1238 |\n|       602850634 | 1995 | MFGR#1239 |\n|      1172025628 | 1995 | MFGR#124  |\n|       489788581 | 1995 | MFGR#1240 |\n|       643100327 | 1995 | MFGR#125  |\n|       894596661 | 1995 | MFGR#126  |\n|       706917239 | 1995 | MFGR#127  |\n|       428671983 | 1995 | MFGR#128  |\n|       971611472 | 1995 | MFGR#129  |\n|       306497573 | 1996 | MFGR#121  |\n|       890719726 | 1996 | MFGR#1210 |\n|      1761977172 | 1996 | MFGR#1211 |\n|       633845765 | 1996 | MFGR#1212 |\n|       475801202 | 1996 | MFGR#1213 |\n|       271930385 | 1996 | MFGR#1214 |\n|       366399844 | 1996 | MFGR#1215 |\n|       877472476 | 1996 | MFGR#1216 |\n|       970366290 | 1996 | MFGR#1217 |\n|       537175690 | 1996 | MFGR#1218 |\n|       956970528 | 1996 | MFGR#1219 |\n|       711962074 | 1996 | MFGR#122  |\n|      1062161683 | 1996 | MFGR#1220 |\n|       406293744 | 1996 | MFGR#1221 |\n|       785404335 | 1996 | MFGR#1222 |\n|       579267044 | 1996 | MFGR#1223 |\n|      1220640256 | 1996 | MFGR#1224 |\n|       490130196 | 1996 | MFGR#1225 |\n|      1603805636 | 1996 | MFGR#1226 |\n|      1530646510 | 1996 | MFGR#1227 |\n|      1093328922 | 1996 | MFGR#1228 |\n|       596520140 | 1996 | MFGR#1229 |\n|       450815571 | 1996 | MFGR#123  |\n|       315053350 | 1996 | MFGR#1230 |\n|       198951017 | 1996 | MFGR#1231 |\n|       579778438 | 1996 | MFGR#1232 |\n|       480905486 | 1996 | MFGR#1233 |\n|      1433336215 | 1996 | MFGR#1234 |\n|       560925251 | 1996 | MFGR#1235 |\n|      1038766181 | 1996 | MFGR#1236 |\n|       783697960 | 1996 | MFGR#1237 |\n|       972656445 | 1996 | MFGR#1238 |\n|       614528801 | 1996 | MFGR#1239 |\n|      1418931894 | 1996 | MFGR#124  |\n|       995139591 | 1996 | MFGR#1240 |\n|       824028471 | 1996 | MFGR#125  |\n|       669475113 | 1996 | MFGR#126  |\n|       831704651 | 1996 | MFGR#127  |\n|       920514555 | 1996 | MFGR#128  |\n|       436162421 | 1996 | MFGR#129  |\n|       553684594 | 1997 | MFGR#121  |\n|      1317368046 | 1997 | MFGR#1210 |\n|      1617056983 | 1997 | MFGR#1211 |\n|      1196031005 | 1997 | MFGR#1212 |\n|      1056458336 | 1997 | MFGR#1213 |\n|       352179650 | 1997 | MFGR#1214 |\n|       511058114 | 1997 | MFGR#1215 |\n|       658259312 | 1997 | MFGR#1216 |\n|      1238450697 | 1997 | MFGR#1217 |\n|       376245955 | 1997 | MFGR#1218 |\n|       913437812 | 1997 | MFGR#1219 |\n|      1114996000 | 1997 | MFGR#122  |\n|       814059433 | 1997 | MFGR#1220 |\n|       817328516 | 1997 | MFGR#1221 |\n|       541428597 | 1997 | MFGR#1222 |\n|      1260539052 | 1997 | MFGR#1223 |\n|      1766426582 | 1997 | MFGR#1224 |\n|      1221271245 | 1997 | MFGR#1225 |\n|      1499152922 | 1997 | MFGR#1226 |\n|       491586909 | 1997 | MFGR#1227 |\n|       911517084 | 1997 | MFGR#1228 |\n|       728186585 | 1997 | MFGR#1229 |\n|       904363416 | 1997 | MFGR#123  |\n|       605369014 | 1997 | MFGR#1230 |\n|       290370455 | 1997 | MFGR#1231 |\n|       602414397 | 1997 | MFGR#1232 |\n|       765339065 | 1997 | MFGR#1233 |\n|      1170973957 | 1997 | MFGR#1234 |\n|       860319765 | 1997 | MFGR#1235 |\n|      1031080311 | 1997 | MFGR#1236 |\n|       736404810 | 1997 | MFGR#1237 |\n|      1012330790 | 1997 | MFGR#1238 |\n|       681055343 | 1997 | MFGR#1239 |\n|       601626600 | 1997 | MFGR#124  |\n|       920404157 | 1997 | MFGR#1240 |\n|      1007678757 | 1997 | MFGR#125  |\n|       622347203 | 1997 | MFGR#126  |\n|      1215295592 | 1997 | MFGR#127  |\n|       822274972 | 1997 | MFGR#128  |\n|       643903475 | 1997 | MFGR#129  |\n|       470008435 | 1998 | MFGR#121  |\n|       568508492 | 1998 | MFGR#1210 |\n|       323759101 | 1998 | MFGR#1211 |\n|       572013331 | 1998 | MFGR#1212 |\n|       448137748 | 1998 | MFGR#1213 |\n|       137422458 | 1998 | MFGR#1214 |\n|       346491756 | 1998 | MFGR#1215 |\n|       454542243 | 1998 | MFGR#1216 |\n|       759205210 | 1998 | MFGR#1217 |\n|       674544462 | 1998 | MFGR#1218 |\n|       735952270 | 1998 | MFGR#1219 |\n|       490186568 | 1998 | MFGR#122  |\n|       769456686 | 1998 | MFGR#1220 |\n|       654540341 | 1998 | MFGR#1221 |\n|       800329859 | 1998 | MFGR#1222 |\n|       263849231 | 1998 | MFGR#1223 |\n|       445461642 | 1998 | MFGR#1224 |\n|       387808862 | 1998 | MFGR#1225 |\n|       675424382 | 1998 | MFGR#1226 |\n|       265906673 | 1998 | MFGR#1227 |\n|       585938371 | 1998 | MFGR#1228 |\n|       683188537 | 1998 | MFGR#1229 |\n|       304403717 | 1998 | MFGR#123  |\n|       533781674 | 1998 | MFGR#1230 |\n|       304060011 | 1998 | MFGR#1231 |\n|       635275907 | 1998 | MFGR#1232 |\n|       658295080 | 1998 | MFGR#1233 |\n|       524133341 | 1998 | MFGR#1234 |\n|       363911877 | 1998 | MFGR#1235 |\n|       300885635 | 1998 | MFGR#1236 |\n|       532608453 | 1998 | MFGR#1237 |\n|       484291410 | 1998 | MFGR#1238 |\n|       445336624 | 1998 | MFGR#1239 |\n|       719027801 | 1998 | MFGR#124  |\n|       518860961 | 1998 | MFGR#1240 |\n|       491235383 | 1998 | MFGR#125  |\n|       520917638 | 1998 | MFGR#126  |\n|      1158787745 | 1998 | MFGR#127  |\n|       401190922 | 1998 | MFGR#128  |\n|       406656337 | 1998 | MFGR#129  |\n+-----------------+------+-----------+\n\n-- Q2.2\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand   |\n+-----------------+------+-----------+\n|      1259802358 | 1992 | MFGR#2221 |\n|      1728549344 | 1992 | MFGR#2222 |\n|      1375260024 | 1992 | MFGR#2223 |\n|      1299982475 | 1992 | MFGR#2224 |\n|      1541960331 | 1992 | MFGR#2225 |\n|      1151853513 | 1992 | MFGR#2226 |\n|      1271175264 | 1992 | MFGR#2227 |\n|      1726441695 | 1992 | MFGR#2228 |\n|      1251460032 | 1993 | MFGR#2221 |\n|      1331062515 | 1993 | MFGR#2222 |\n|       902809293 | 1993 | MFGR#2223 |\n|       980512417 | 1993 | MFGR#2224 |\n|      1253088003 | 1993 | MFGR#2225 |\n|       959195148 | 1993 | MFGR#2226 |\n|       555593932 | 1993 | MFGR#2227 |\n|      2186479174 | 1993 | MFGR#2228 |\n|      1094092222 | 1994 | MFGR#2221 |\n|      1491699323 | 1994 | MFGR#2222 |\n|      1501160826 | 1994 | MFGR#2223 |\n|      1387107418 | 1994 | MFGR#2224 |\n|      1641588884 | 1994 | MFGR#2225 |\n|      1387296390 | 1994 | MFGR#2226 |\n|      1038341470 | 1994 | MFGR#2227 |\n|      1565763138 | 1994 | MFGR#2228 |\n|      1412945650 | 1995 | MFGR#2221 |\n|      1546178356 | 1995 | MFGR#2222 |\n|      1218352073 | 1995 | MFGR#2223 |\n|      1052197762 | 1995 | MFGR#2224 |\n|      1822921900 | 1995 | MFGR#2225 |\n|       728142181 | 1995 | MFGR#2226 |\n|       966131607 | 1995 | MFGR#2227 |\n|      1379320517 | 1995 | MFGR#2228 |\n|      1042767284 | 1996 | MFGR#2221 |\n|       994733835 | 1996 | MFGR#2222 |\n|      1615788545 | 1996 | MFGR#2223 |\n|      1113980216 | 1996 | MFGR#2224 |\n|      1622570253 | 1996 | MFGR#2225 |\n|      1540226758 | 1996 | MFGR#2226 |\n|      1115687883 | 1996 | MFGR#2227 |\n|      1716355343 | 1996 | MFGR#2228 |\n|       867705636 | 1997 | MFGR#2221 |\n|      1529877498 | 1997 | MFGR#2222 |\n|      1594444450 | 1997 | MFGR#2223 |\n|       587421043 | 1997 | MFGR#2224 |\n|      1112274470 | 1997 | MFGR#2225 |\n|      1327884722 | 1997 | MFGR#2226 |\n|       884180880 | 1997 | MFGR#2227 |\n|      1664207656 | 1997 | MFGR#2228 |\n|       827743515 | 1998 | MFGR#2221 |\n|       662242310 | 1998 | MFGR#2222 |\n|       861445539 | 1998 | MFGR#2223 |\n|       694538672 | 1998 | MFGR#2224 |\n|       675179021 | 1998 | MFGR#2225 |\n|       480728720 | 1998 | MFGR#2226 |\n|       643763072 | 1998 | MFGR#2227 |\n|       994499201 | 1998 | MFGR#2228 |\n+-----------------+------+-----------+\n\n-- Q2.3\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand   |\n+-----------------+------+-----------+\n|      1428843284 | 1992 | MFGR#2239 |\n|      1865666054 | 1993 | MFGR#2239 |\n|      2242753254 | 1994 | MFGR#2239 |\n|      1446677305 | 1995 | MFGR#2239 |\n|       921681503 | 1996 | MFGR#2239 |\n|      1549990572 | 1997 | MFGR#2239 |\n|       926327433 | 1998 | MFGR#2239 |\n+-----------------+------+-----------+\n\n-- Q3.1\n+-----------+-----------+------+-------------+\n| c_nation  | s_nation  | year | revenue     |\n+-----------+-----------+------+-------------+\n| VIETNAM   | CHINA     | 1992 | 17194479086 |\n| JAPAN     | CHINA     | 1992 | 15572594510 |\n| JAPAN     | JAPAN     | 1992 | 13861682954 |\n| INDONESIA | CHINA     | 1992 | 13499663933 |\n| VIETNAM   | INDONESIA | 1992 | 13163103649 |\n| JAPAN     | INDONESIA | 1992 | 13035158590 |\n| INDIA     | CHINA     | 1992 | 12987688902 |\n| INDONESIA | JAPAN     | 1992 | 12939737918 |\n| VIETNAM   | JAPAN     | 1992 | 12174715858 |\n| JAPAN     | VIETNAM   | 1992 | 11669093753 |\n| INDIA     | INDONESIA | 1992 | 11452602145 |\n| INDONESIA | INDONESIA | 1992 | 10394407561 |\n| INDIA     | JAPAN     | 1992 | 10313084900 |\n| JAPAN     | INDIA     | 1992 | 10035511089 |\n| CHINA     | CHINA     | 1992 |  9828744666 |\n| VIETNAM   | VIETNAM   | 1992 |  9701522505 |\n| INDONESIA | INDIA     | 1992 |  9271105764 |\n| INDIA     | INDIA     | 1992 |  8879645522 |\n| CHINA     | INDONESIA | 1992 |  8373693838 |\n| CHINA     | JAPAN     | 1992 |  8051248951 |\n| VIETNAM   | INDIA     | 1992 |  7804539029 |\n| INDONESIA | VIETNAM   | 1992 |  7615465790 |\n| CHINA     | INDIA     | 1992 |  7344868842 |\n| INDIA     | VIETNAM   | 1992 |  6830508508 |\n| CHINA     | VIETNAM   | 1992 |  6529888238 |\n| JAPAN     | CHINA     | 1993 | 18839180326 |\n| VIETNAM   | CHINA     | 1993 | 14761890330 |\n| JAPAN     | INDONESIA | 1993 | 13648082171 |\n| INDONESIA | CHINA     | 1993 | 13518181805 |\n| INDIA     | CHINA     | 1993 | 13249555999 |\n| JAPAN     | JAPAN     | 1993 | 12667833152 |\n| JAPAN     | VIETNAM   | 1993 | 11529854580 |\n| CHINA     | CHINA     | 1993 | 11216468573 |\n| INDONESIA | INDONESIA | 1993 | 10953284722 |\n| VIETNAM   | INDONESIA | 1993 | 10582912267 |\n| INDIA     | JAPAN     | 1993 | 10482950584 |\n| VIETNAM   | JAPAN     | 1993 | 10370811002 |\n| INDIA     | INDONESIA | 1993 | 10145286112 |\n| INDONESIA | JAPAN     | 1993 |  9850020303 |\n| VIETNAM   | VIETNAM   | 1993 |  9591468153 |\n| CHINA     | INDONESIA | 1993 |  9015864524 |\n| CHINA     | JAPAN     | 1993 |  8972996729 |\n| INDONESIA | INDIA     | 1993 |  8903638786 |\n| JAPAN     | INDIA     | 1993 |  8848048514 |\n| INDONESIA | VIETNAM   | 1993 |  8024464882 |\n| VIETNAM   | INDIA     | 1993 |  7806575746 |\n| INDIA     | VIETNAM   | 1993 |  7537331106 |\n| INDIA     | INDIA     | 1993 |  7211053846 |\n| CHINA     | VIETNAM   | 1993 |  6700022269 |\n| CHINA     | INDIA     | 1993 |  6327331541 |\n| JAPAN     | CHINA     | 1994 | 15661051644 |\n| VIETNAM   | CHINA     | 1994 | 13958591931 |\n| JAPAN     | JAPAN     | 1994 | 13566252348 |\n| CHINA     | CHINA     | 1994 | 12870010072 |\n| VIETNAM   | JAPAN     | 1994 | 12728320716 |\n| INDONESIA | CHINA     | 1994 | 12295790872 |\n| INDIA     | CHINA     | 1994 | 12166419121 |\n| JAPAN     | INDONESIA | 1994 | 11358955025 |\n| INDIA     | INDONESIA | 1994 | 11111248365 |\n| JAPAN     | INDIA     | 1994 | 10078806371 |\n| VIETNAM   | INDONESIA | 1994 |  9923852578 |\n| INDIA     | JAPAN     | 1994 |  9839136767 |\n| CHINA     | JAPAN     | 1994 |  9836586308 |\n| INDONESIA | JAPAN     | 1994 |  9786694572 |\n| INDIA     | VIETNAM   | 1994 |  9551081406 |\n| JAPAN     | VIETNAM   | 1994 |  9035431932 |\n| VIETNAM   | INDIA     | 1994 |  9032319402 |\n| INDONESIA | INDONESIA | 1994 |  8876012426 |\n| CHINA     | INDONESIA | 1994 |  8375581981 |\n| VIETNAM   | VIETNAM   | 1994 |  8095638136 |\n| INDONESIA | INDIA     | 1994 |  7943993512 |\n| INDONESIA | VIETNAM   | 1994 |  7927236697 |\n| INDIA     | INDIA     | 1994 |  7534915457 |\n| CHINA     | VIETNAM   | 1994 |  6062387221 |\n| CHINA     | INDIA     | 1994 |  5816794324 |\n| VIETNAM   | CHINA     | 1995 | 15128423080 |\n| INDONESIA | CHINA     | 1995 | 14794647970 |\n| INDIA     | CHINA     | 1995 | 14724240804 |\n| JAPAN     | CHINA     | 1995 | 14579848516 |\n| CHINA     | CHINA     | 1995 | 14296657586 |\n| INDIA     | JAPAN     | 1995 | 13511381754 |\n| JAPAN     | JAPAN     | 1995 | 12015968288 |\n| VIETNAM   | INDONESIA | 1995 | 11290647784 |\n| JAPAN     | INDONESIA | 1995 | 10968840402 |\n| INDIA     | INDONESIA | 1995 | 10879296370 |\n| CHINA     | INDONESIA | 1995 | 10611767914 |\n| VIETNAM   | JAPAN     | 1995 | 10493043807 |\n| INDONESIA | INDONESIA | 1995 | 10350165199 |\n| VIETNAM   | INDIA     | 1995 | 10147175135 |\n| CHINA     | JAPAN     | 1995 |  9967113498 |\n| JAPAN     | VIETNAM   | 1995 |  9871240910 |\n| INDONESIA | JAPAN     | 1995 |  9554798320 |\n| JAPAN     | INDIA     | 1995 |  9224478715 |\n| INDIA     | INDIA     | 1995 |  8880501531 |\n| VIETNAM   | VIETNAM   | 1995 |  8530802028 |\n| INDIA     | VIETNAM   | 1995 |  8470249830 |\n| CHINA     | INDIA     | 1995 |  8460557790 |\n| INDONESIA | VIETNAM   | 1995 |  8393411088 |\n| CHINA     | VIETNAM   | 1995 |  7838238263 |\n| INDONESIA | INDIA     | 1995 |  7001659338 |\n| JAPAN     | CHINA     | 1996 | 14974943391 |\n| INDIA     | CHINA     | 1996 | 14236197987 |\n| VIETNAM   | CHINA     | 1996 | 13723231674 |\n| JAPAN     | INDONESIA | 1996 | 13304501801 |\n| INDONESIA | CHINA     | 1996 | 12444022202 |\n| CHINA     | CHINA     | 1996 | 12120893189 |\n| INDIA     | JAPAN     | 1996 | 11649117519 |\n| INDONESIA | JAPAN     | 1996 | 11345350775 |\n| VIETNAM   | JAPAN     | 1996 | 11294284203 |\n| INDONESIA | INDONESIA | 1996 | 11111201530 |\n| JAPAN     | INDIA     | 1996 | 10871364136 |\n| JAPAN     | JAPAN     | 1996 | 10836947449 |\n| INDIA     | INDONESIA | 1996 | 10568008435 |\n| JAPAN     | VIETNAM   | 1996 | 10503890555 |\n| VIETNAM   | INDONESIA | 1996 | 10494783196 |\n| INDONESIA | VIETNAM   | 1996 |  9940440124 |\n| INDONESIA | INDIA     | 1996 |  9864980677 |\n| VIETNAM   | VIETNAM   | 1996 |  9560258720 |\n| INDIA     | VIETNAM   | 1996 |  9324764214 |\n| INDIA     | INDIA     | 1996 |  9023346020 |\n| VIETNAM   | INDIA     | 1996 |  8968179949 |\n| CHINA     | INDONESIA | 1996 |  8877441837 |\n| CHINA     | JAPAN     | 1996 |  8749420872 |\n| CHINA     | VIETNAM   | 1996 |  6973983457 |\n| CHINA     | INDIA     | 1996 |  6515658476 |\n| JAPAN     | CHINA     | 1997 | 15365039212 |\n| INDONESIA | CHINA     | 1997 | 14159930904 |\n| VIETNAM   | CHINA     | 1997 | 13678288757 |\n| INDIA     | CHINA     | 1997 | 13599028484 |\n| JAPAN     | JAPAN     | 1997 | 12921870544 |\n| CHINA     | CHINA     | 1997 | 12720975220 |\n| VIETNAM   | JAPAN     | 1997 | 11929000810 |\n| VIETNAM   | INDONESIA | 1997 | 11325447090 |\n| JAPAN     | INDONESIA | 1997 | 10764312416 |\n| INDONESIA | JAPAN     | 1997 | 10555558162 |\n| INDONESIA | INDONESIA | 1997 | 10416928126 |\n| CHINA     | INDONESIA | 1997 | 10317902565 |\n| INDIA     | JAPAN     | 1997 | 10272590051 |\n| JAPAN     | VIETNAM   | 1997 |  9940032294 |\n| CHINA     | JAPAN     | 1997 |  9519485461 |\n| JAPAN     | INDIA     | 1997 |  9465935835 |\n| INDIA     | INDONESIA | 1997 |  9405085270 |\n| INDONESIA | INDIA     | 1997 |  8930955270 |\n| INDIA     | INDIA     | 1997 |  8295504178 |\n| VIETNAM   | VIETNAM   | 1997 |  8293412532 |\n| INDONESIA | VIETNAM   | 1997 |  8116443059 |\n| INDIA     | VIETNAM   | 1997 |  7960292262 |\n| VIETNAM   | INDIA     | 1997 |  7529455873 |\n| CHINA     | VIETNAM   | 1997 |  7038413355 |\n| CHINA     | INDIA     | 1997 |  6530770558 |\n+-----------+-----------+------+-------------+\n\n-- Q3.2\n\n+------------+------------+------+-----------+\n| c_city     | s_city     | year | revenue   |\n+------------+------------+------+-----------+\n| CHINA    3 | CHINA    0 | 1992 | 539864249 |\n| CHINA    0 | CHINA    6 | 1992 | 471363128 |\n| CHINA    8 | CHINA    1 | 1992 | 421384110 |\n| CHINA    6 | CHINA    1 | 1992 | 382204882 |\n| CHINA    6 | CHINA    7 | 1992 | 355755835 |\n| CHINA    8 | CHINA    9 | 1992 | 349006417 |\n| CHINA    7 | CHINA    7 | 1992 | 320232842 |\n| CHINA    8 | CHINA    3 | 1992 | 296105733 |\n| CHINA    5 | CHINA    3 | 1992 | 277283951 |\n| CHINA    6 | CHINA    6 | 1992 | 265527771 |\n| CHINA    4 | CHINA    1 | 1992 | 237402078 |\n| CHINA    8 | CHINA    6 | 1992 | 234720401 |\n| CHINA    4 | CHINA    6 | 1992 | 230169075 |\n| CHINA    9 | CHINA    1 | 1992 | 223815249 |\n| CHINA    1 | CHINA    1 | 1992 | 223467947 |\n| CHINA    2 | CHINA    1 | 1992 | 219559691 |\n| CHINA    9 | CHINA    6 | 1992 | 205915890 |\n| CHINA    7 | CHINA    9 | 1992 | 201288909 |\n| CHINA    1 | CHINA    6 | 1992 | 195622902 |\n| CHINA    9 | CHINA    7 | 1992 | 190345063 |\n| CHINA    8 | CHINA    4 | 1992 | 174478626 |\n| CHINA    1 | CHINA    7 | 1992 | 173803257 |\n| CHINA    9 | CHINA    9 | 1992 | 162458028 |\n| CHINA    6 | CHINA    0 | 1992 | 154260702 |\n| CHINA    8 | CHINA    0 | 1992 | 149794069 |\n| CHINA    5 | CHINA    9 | 1992 | 149369922 |\n| CHINA    8 | CHINA    8 | 1992 | 147607252 |\n| CHINA    6 | CHINA    4 | 1992 | 147137516 |\n| CHINA    7 | CHINA    8 | 1992 | 139974858 |\n| CHINA    5 | CHINA    6 | 1992 | 138467127 |\n| CHINA    3 | CHINA    6 | 1992 | 119521008 |\n| CHINA    8 | CHINA    7 | 1992 | 109887269 |\n| CHINA    6 | CHINA    3 | 1992 | 107201214 |\n| CHINA    9 | CHINA    4 | 1992 | 101504450 |\n| CHINA    1 | CHINA    3 | 1992 | 101388208 |\n| CHINA    7 | CHINA    0 | 1992 |  98475237 |\n| CHINA    5 | CHINA    8 | 1992 |  98370738 |\n| CHINA    2 | CHINA    6 | 1992 |  93254616 |\n| CHINA    2 | CHINA    4 | 1992 |  86394644 |\n| CHINA    3 | CHINA    7 | 1992 |  81027008 |\n| CHINA    5 | CHINA    4 | 1992 |  78587418 |\n| CHINA    3 | CHINA    9 | 1992 |  78114762 |\n| CHINA    2 | CHINA    0 | 1992 |  77786892 |\n| CHINA    2 | CHINA    8 | 1992 |  75605732 |\n| CHINA    4 | CHINA    3 | 1992 |  75101512 |\n| CHINA    7 | CHINA    4 | 1992 |  74119240 |\n| CHINA    2 | CHINA    9 | 1992 |  73413108 |\n| CHINA    5 | CHINA    7 | 1992 |  73199718 |\n| CHINA    4 | CHINA    4 | 1992 |  72839118 |\n| CHINA    1 | CHINA    9 | 1992 |  68538220 |\n| CHINA    0 | CHINA    8 | 1992 |  65856888 |\n| CHINA    0 | CHINA    9 | 1992 |  65590624 |\n| CHINA    3 | CHINA    8 | 1992 |  64556586 |\n| CHINA    2 | CHINA    7 | 1992 |  63336330 |\n| CHINA    4 | CHINA    9 | 1992 |  57645963 |\n| CHINA    0 | CHINA    7 | 1992 |  55251918 |\n| CHINA    0 | CHINA    1 | 1992 |  51774462 |\n| CHINA    6 | CHINA    8 | 1992 |  45676858 |\n| CHINA    3 | CHINA    3 | 1992 |  41147560 |\n| CHINA    3 | CHINA    4 | 1992 |  36838082 |\n| CHINA    5 | CHINA    0 | 1992 |  36554488 |\n| CHINA    3 | CHINA    1 | 1992 |  32036313 |\n| CHINA    4 | CHINA    8 | 1992 |  31517575 |\n| CHINA    0 | CHINA    3 | 1992 |  25524054 |\n| CHINA    1 | CHINA    4 | 1992 |  12681846 |\n| CHINA    7 | CHINA    3 | 1992 |  11395152 |\n| CHINA    6 | CHINA    9 | 1992 |   8642375 |\n| CHINA    8 | CHINA    6 | 1993 | 638396852 |\n| CHINA    7 | CHINA    6 | 1993 | 576731239 |\n| CHINA    2 | CHINA    6 | 1993 | 528008729 |\n| CHINA    8 | CHINA    9 | 1993 | 522412584 |\n| CHINA    8 | CHINA    7 | 1993 | 475478848 |\n| CHINA    8 | CHINA    1 | 1993 | 452064153 |\n| CHINA    0 | CHINA    1 | 1993 | 425902649 |\n| CHINA    9 | CHINA    1 | 1993 | 405252987 |\n| CHINA    6 | CHINA    9 | 1993 | 385005953 |\n| CHINA    8 | CHINA    8 | 1993 | 382884778 |\n| CHINA    0 | CHINA    6 | 1993 | 344911487 |\n| CHINA    6 | CHINA    7 | 1993 | 341436211 |\n| CHINA    3 | CHINA    6 | 1993 | 291652051 |\n| CHINA    7 | CHINA    1 | 1993 | 257769861 |\n| CHINA    8 | CHINA    0 | 1993 | 231981252 |\n| CHINA    4 | CHINA    6 | 1993 | 215180968 |\n| CHINA    3 | CHINA    0 | 1993 | 213320777 |\n| CHINA    9 | CHINA    6 | 1993 | 207281000 |\n| CHINA    5 | CHINA    9 | 1993 | 206555882 |\n| CHINA    6 | CHINA    1 | 1993 | 205665388 |\n| CHINA    5 | CHINA    1 | 1993 | 193491875 |\n| CHINA    2 | CHINA    9 | 1993 | 193324425 |\n| CHINA    5 | CHINA    8 | 1993 | 190521023 |\n| CHINA    7 | CHINA    0 | 1993 | 183487919 |\n| CHINA    0 | CHINA    9 | 1993 | 170223958 |\n| CHINA    6 | CHINA    8 | 1993 | 166821272 |\n| CHINA    3 | CHINA    8 | 1993 | 163053528 |\n| CHINA    2 | CHINA    0 | 1993 | 158276154 |\n| CHINA    3 | CHINA    1 | 1993 | 153652018 |\n| CHINA    5 | CHINA    6 | 1993 | 151359347 |\n| CHINA    6 | CHINA    0 | 1993 | 140494698 |\n| CHINA    8 | CHINA    4 | 1993 | 139857147 |\n| CHINA    2 | CHINA    7 | 1993 | 136009418 |\n| CHINA    5 | CHINA    7 | 1993 | 133892119 |\n| CHINA    9 | CHINA    9 | 1993 | 118965507 |\n| CHINA    1 | CHINA    1 | 1993 | 108898379 |\n| CHINA    6 | CHINA    6 | 1993 | 100311475 |\n| CHINA    0 | CHINA    4 | 1993 |  93483068 |\n| CHINA    1 | CHINA    4 | 1993 |  87714152 |\n| CHINA    4 | CHINA    1 | 1993 |  87690658 |\n| CHINA    4 | CHINA    7 | 1993 |  83701574 |\n| CHINA    1 | CHINA    0 | 1993 |  82670983 |\n| CHINA    7 | CHINA    4 | 1993 |  77396461 |\n| CHINA    5 | CHINA    4 | 1993 |  73556161 |\n| CHINA    4 | CHINA    8 | 1993 |  72203335 |\n| CHINA    0 | CHINA    7 | 1993 |  70395334 |\n| CHINA    3 | CHINA    4 | 1993 |  64771003 |\n| CHINA    7 | CHINA    8 | 1993 |  64514099 |\n| CHINA    3 | CHINA    7 | 1993 |  62868516 |\n| CHINA    8 | CHINA    3 | 1993 |  56504804 |\n| CHINA    2 | CHINA    4 | 1993 |  56031779 |\n| CHINA    1 | CHINA    7 | 1993 |  48951262 |\n| CHINA    7 | CHINA    3 | 1993 |  45962220 |\n| CHINA    4 | CHINA    9 | 1993 |  43158138 |\n| CHINA    7 | CHINA    9 | 1993 |  42611979 |\n| CHINA    2 | CHINA    8 | 1993 |  38092546 |\n| CHINA    1 | CHINA    9 | 1993 |  29665374 |\n| CHINA    1 | CHINA    3 | 1993 |  23991216 |\n| CHINA    6 | CHINA    6 | 1994 | 596294890 |\n| CHINA    8 | CHINA    6 | 1994 | 542104721 |\n| CHINA    6 | CHINA    1 | 1994 | 504359553 |\n| CHINA    3 | CHINA    7 | 1994 | 476727294 |\n| CHINA    3 | CHINA    6 | 1994 | 476349724 |\n| CHINA    8 | CHINA    9 | 1994 | 427241348 |\n| CHINA    6 | CHINA    9 | 1994 | 358191581 |\n| CHINA    9 | CHINA    6 | 1994 | 352344057 |\n| CHINA    3 | CHINA    0 | 1994 | 351708546 |\n| CHINA    8 | CHINA    0 | 1994 | 351131413 |\n| CHINA    3 | CHINA    3 | 1994 | 339279574 |\n| CHINA    0 | CHINA    1 | 1994 | 298307857 |\n| CHINA    0 | CHINA    7 | 1994 | 289536010 |\n| CHINA    0 | CHINA    6 | 1994 | 285639032 |\n| CHINA    7 | CHINA    6 | 1994 | 263170455 |\n| CHINA    2 | CHINA    8 | 1994 | 250332990 |\n| CHINA    6 | CHINA    4 | 1994 | 235897763 |\n| CHINA    5 | CHINA    1 | 1994 | 234681515 |\n| CHINA    8 | CHINA    7 | 1994 | 234390101 |\n| CHINA    1 | CHINA    6 | 1994 | 232792764 |\n| CHINA    8 | CHINA    1 | 1994 | 223808842 |\n| CHINA    4 | CHINA    6 | 1994 | 209522926 |\n| CHINA    8 | CHINA    4 | 1994 | 208632636 |\n| CHINA    7 | CHINA    3 | 1994 | 202424117 |\n| CHINA    4 | CHINA    7 | 1994 | 185487544 |\n| CHINA    2 | CHINA    7 | 1994 | 183551771 |\n| CHINA    7 | CHINA    1 | 1994 | 178421732 |\n| CHINA    4 | CHINA    1 | 1994 | 176262868 |\n| CHINA    5 | CHINA    6 | 1994 | 173651872 |\n| CHINA    0 | CHINA    4 | 1994 | 173584501 |\n| CHINA    8 | CHINA    8 | 1994 | 172179808 |\n| CHINA    9 | CHINA    1 | 1994 | 169617585 |\n| CHINA    0 | CHINA    9 | 1994 | 167569085 |\n| CHINA    5 | CHINA    8 | 1994 | 162066559 |\n| CHINA    7 | CHINA    9 | 1994 | 161041255 |\n| CHINA    5 | CHINA    4 | 1994 | 154820955 |\n| CHINA    7 | CHINA    0 | 1994 | 152844960 |\n| CHINA    2 | CHINA    6 | 1994 | 149839190 |\n| CHINA    7 | CHINA    8 | 1994 | 149536114 |\n| CHINA    1 | CHINA    4 | 1994 | 142403628 |\n| CHINA    9 | CHINA    9 | 1994 | 131064832 |\n| CHINA    2 | CHINA    1 | 1994 | 124489283 |\n| CHINA    2 | CHINA    0 | 1994 | 114263273 |\n| CHINA    5 | CHINA    7 | 1994 | 113311766 |\n| CHINA    8 | CHINA    3 | 1994 | 112573609 |\n| CHINA    3 | CHINA    4 | 1994 | 104903651 |\n| CHINA    4 | CHINA    0 | 1994 | 101914439 |\n| CHINA    3 | CHINA    1 | 1994 |  98253251 |\n| CHINA    1 | CHINA    7 | 1994 |  94582288 |\n| CHINA    4 | CHINA    4 | 1994 |  92818317 |\n| CHINA    1 | CHINA    9 | 1994 |  85220541 |\n| CHINA    6 | CHINA    3 | 1994 |  84604801 |\n| CHINA    0 | CHINA    3 | 1994 |  77574978 |\n| CHINA    1 | CHINA    3 | 1994 |  74435316 |\n| CHINA    4 | CHINA    9 | 1994 |  72622300 |\n| CHINA    3 | CHINA    8 | 1994 |  72559366 |\n| CHINA    9 | CHINA    0 | 1994 |  69298222 |\n| CHINA    3 | CHINA    9 | 1994 |  67472592 |\n| CHINA    6 | CHINA    8 | 1994 |  66271372 |\n| CHINA    7 | CHINA    4 | 1994 |  59634606 |\n| CHINA    2 | CHINA    9 | 1994 |  56882136 |\n| CHINA    1 | CHINA    1 | 1994 |  56592337 |\n| CHINA    5 | CHINA    9 | 1994 |  52879724 |\n| CHINA    9 | CHINA    4 | 1994 |  49324497 |\n| CHINA    2 | CHINA    3 | 1994 |  45042384 |\n| CHINA    7 | CHINA    7 | 1994 |  44458451 |\n| CHINA    5 | CHINA    0 | 1994 |  39091925 |\n| CHINA    9 | CHINA    3 | 1994 |  39082405 |\n| CHINA    0 | CHINA    8 | 1994 |  28203459 |\n| CHINA    6 | CHINA    7 | 1994 |  27243775 |\n| CHINA    0 | CHINA    0 | 1994 |  15591040 |\n| CHINA    2 | CHINA    6 | 1995 | 832176707 |\n| CHINA    8 | CHINA    6 | 1995 | 793322102 |\n| CHINA    3 | CHINA    7 | 1995 | 505446788 |\n| CHINA    7 | CHINA    9 | 1995 | 483519933 |\n| CHINA    4 | CHINA    6 | 1995 | 440320366 |\n| CHINA    8 | CHINA    1 | 1995 | 394522570 |\n| CHINA    7 | CHINA    1 | 1995 | 393861389 |\n| CHINA    5 | CHINA    1 | 1995 | 343166828 |\n| CHINA    1 | CHINA    7 | 1995 | 341736584 |\n| CHINA    8 | CHINA    7 | 1995 | 323623203 |\n| CHINA    6 | CHINA    6 | 1995 | 312876143 |\n| CHINA    3 | CHINA    6 | 1995 | 306516324 |\n| CHINA    7 | CHINA    6 | 1995 | 294840537 |\n| CHINA    3 | CHINA    3 | 1995 | 290066240 |\n| CHINA    8 | CHINA    3 | 1995 | 289182495 |\n| CHINA    3 | CHINA    1 | 1995 | 288853766 |\n| CHINA    0 | CHINA    1 | 1995 | 279082523 |\n| CHINA    0 | CHINA    8 | 1995 | 265291443 |\n| CHINA    1 | CHINA    6 | 1995 | 262283412 |\n| CHINA    4 | CHINA    1 | 1995 | 246559891 |\n| CHINA    2 | CHINA    8 | 1995 | 246465167 |\n| CHINA    6 | CHINA    7 | 1995 | 246385862 |\n| CHINA    9 | CHINA    6 | 1995 | 231314393 |\n| CHINA    2 | CHINA    7 | 1995 | 224354491 |\n| CHINA    4 | CHINA    7 | 1995 | 222368398 |\n| CHINA    0 | CHINA    7 | 1995 | 221334917 |\n| CHINA    6 | CHINA    3 | 1995 | 217756587 |\n| CHINA    6 | CHINA    9 | 1995 | 215736018 |\n| CHINA    4 | CHINA    9 | 1995 | 210496516 |\n| CHINA    0 | CHINA    6 | 1995 | 197891458 |\n| CHINA    8 | CHINA    9 | 1995 | 192018213 |\n| CHINA    7 | CHINA    0 | 1995 | 188804482 |\n| CHINA    5 | CHINA    6 | 1995 | 186378531 |\n| CHINA    6 | CHINA    1 | 1995 | 165831073 |\n| CHINA    1 | CHINA    3 | 1995 | 165118263 |\n| CHINA    6 | CHINA    8 | 1995 | 157640218 |\n| CHINA    1 | CHINA    1 | 1995 | 150838433 |\n| CHINA    1 | CHINA    4 | 1995 | 147632879 |\n| CHINA    6 | CHINA    0 | 1995 | 147314401 |\n| CHINA    5 | CHINA    4 | 1995 | 142820978 |\n| CHINA    5 | CHINA    9 | 1995 | 141416829 |\n| CHINA    2 | CHINA    0 | 1995 | 135608473 |\n| CHINA    5 | CHINA    7 | 1995 | 131596218 |\n| CHINA    0 | CHINA    4 | 1995 | 129159370 |\n| CHINA    3 | CHINA    9 | 1995 | 126837748 |\n| CHINA    8 | CHINA    0 | 1995 | 126564932 |\n| CHINA    0 | CHINA    3 | 1995 | 121337041 |\n| CHINA    7 | CHINA    7 | 1995 | 118697587 |\n| CHINA    5 | CHINA    8 | 1995 | 116538842 |\n| CHINA    8 | CHINA    8 | 1995 | 110161904 |\n| CHINA    9 | CHINA    0 | 1995 | 109582187 |\n| CHINA    9 | CHINA    1 | 1995 | 103455098 |\n| CHINA    2 | CHINA    1 | 1995 | 100264691 |\n| CHINA    7 | CHINA    3 | 1995 |  99011859 |\n| CHINA    3 | CHINA    0 | 1995 |  90383390 |\n| CHINA    4 | CHINA    3 | 1995 |  89908903 |\n| CHINA    7 | CHINA    8 | 1995 |  81425699 |\n| CHINA    3 | CHINA    4 | 1995 |  77577579 |\n| CHINA    4 | CHINA    8 | 1995 |  74805746 |\n| CHINA    9 | CHINA    7 | 1995 |  74597020 |\n| CHINA    9 | CHINA    9 | 1995 |  73514511 |\n| CHINA    5 | CHINA    0 | 1995 |  73274726 |\n| CHINA    8 | CHINA    4 | 1995 |  61708487 |\n| CHINA    1 | CHINA    0 | 1995 |  58753734 |\n| CHINA    3 | CHINA    8 | 1995 |  57133566 |\n| CHINA    9 | CHINA    4 | 1995 |  53259334 |\n| CHINA    1 | CHINA    9 | 1995 |  46177797 |\n| CHINA    2 | CHINA    4 | 1995 |  45147325 |\n| CHINA    0 | CHINA    0 | 1995 |  43963173 |\n| CHINA    0 | CHINA    9 | 1995 |  40184107 |\n| CHINA    1 | CHINA    8 | 1995 |  18859188 |\n| CHINA    8 | CHINA    7 | 1996 | 621957444 |\n| CHINA    3 | CHINA    9 | 1996 | 530082848 |\n| CHINA    8 | CHINA    6 | 1996 | 525755549 |\n| CHINA    8 | CHINA    1 | 1996 | 399229343 |\n| CHINA    6 | CHINA    7 | 1996 | 365540749 |\n| CHINA    8 | CHINA    8 | 1996 | 351864283 |\n| CHINA    1 | CHINA    6 | 1996 | 329186504 |\n| CHINA    9 | CHINA    6 | 1996 | 321113085 |\n| CHINA    3 | CHINA    6 | 1996 | 318264871 |\n| CHINA    2 | CHINA    6 | 1996 | 315233397 |\n| CHINA    2 | CHINA    9 | 1996 | 285852841 |\n| CHINA    9 | CHINA    9 | 1996 | 264510548 |\n| CHINA    5 | CHINA    6 | 1996 | 261385523 |\n| CHINA    8 | CHINA    9 | 1996 | 259497265 |\n| CHINA    6 | CHINA    6 | 1996 | 258200131 |\n| CHINA    4 | CHINA    9 | 1996 | 257345949 |\n| CHINA    6 | CHINA    9 | 1996 | 247667288 |\n| CHINA    2 | CHINA    7 | 1996 | 234569026 |\n| CHINA    2 | CHINA    1 | 1996 | 218568966 |\n| CHINA    4 | CHINA    1 | 1996 | 207383476 |\n| CHINA    0 | CHINA    1 | 1996 | 204596428 |\n| CHINA    3 | CHINA    0 | 1996 | 204375870 |\n| CHINA    4 | CHINA    0 | 1996 | 202299286 |\n| CHINA    4 | CHINA    4 | 1996 | 191983261 |\n| CHINA    4 | CHINA    8 | 1996 | 183961012 |\n| CHINA    4 | CHINA    6 | 1996 | 183872085 |\n| CHINA    6 | CHINA    8 | 1996 | 182132356 |\n| CHINA    7 | CHINA    9 | 1996 | 170941341 |\n| CHINA    0 | CHINA    6 | 1996 | 168082672 |\n| CHINA    1 | CHINA    7 | 1996 | 165942066 |\n| CHINA    1 | CHINA    9 | 1996 | 165878775 |\n| CHINA    9 | CHINA    8 | 1996 | 156009357 |\n| CHINA    7 | CHINA    7 | 1996 | 155842944 |\n| CHINA    2 | CHINA    0 | 1996 | 147709906 |\n| CHINA    5 | CHINA    7 | 1996 | 147257366 |\n| CHINA    1 | CHINA    8 | 1996 | 141840928 |\n| CHINA    2 | CHINA    4 | 1996 | 136244052 |\n| CHINA    9 | CHINA    0 | 1996 | 130997019 |\n| CHINA    1 | CHINA    0 | 1996 | 124362038 |\n| CHINA    0 | CHINA    9 | 1996 | 114011231 |\n| CHINA    7 | CHINA    3 | 1996 | 112398764 |\n| CHINA    4 | CHINA    7 | 1996 | 110567337 |\n| CHINA    3 | CHINA    4 | 1996 | 109269982 |\n| CHINA    5 | CHINA    1 | 1996 | 107482704 |\n| CHINA    6 | CHINA    4 | 1996 | 105485170 |\n| CHINA    1 | CHINA    4 | 1996 | 105320270 |\n| CHINA    0 | CHINA    7 | 1996 | 102545071 |\n| CHINA    2 | CHINA    3 | 1996 | 100407151 |\n| CHINA    0 | CHINA    4 | 1996 |  95913303 |\n| CHINA    7 | CHINA    0 | 1996 |  94706269 |\n| CHINA    6 | CHINA    1 | 1996 |  86949951 |\n| CHINA    8 | CHINA    3 | 1996 |  84157344 |\n| CHINA    2 | CHINA    8 | 1996 |  83176903 |\n| CHINA    5 | CHINA    9 | 1996 |  83104330 |\n| CHINA    7 | CHINA    8 | 1996 |  81490639 |\n| CHINA    9 | CHINA    3 | 1996 |  79655829 |\n| CHINA    5 | CHINA    0 | 1996 |  77489995 |\n| CHINA    8 | CHINA    0 | 1996 |  76989056 |\n| CHINA    9 | CHINA    1 | 1996 |  72011031 |\n| CHINA    7 | CHINA    4 | 1996 |  64764322 |\n| CHINA    5 | CHINA    4 | 1996 |  62827767 |\n| CHINA    5 | CHINA    8 | 1996 |  62673237 |\n| CHINA    7 | CHINA    6 | 1996 |  61880459 |\n| CHINA    3 | CHINA    7 | 1996 |  56642844 |\n| CHINA    3 | CHINA    1 | 1996 |  50799366 |\n| CHINA    3 | CHINA    3 | 1996 |  42601269 |\n| CHINA    4 | CHINA    3 | 1996 |  38290290 |\n| CHINA    3 | CHINA    8 | 1996 |  21263056 |\n| CHINA    7 | CHINA    1 | 1996 |  14836937 |\n| CHINA    5 | CHINA    3 | 1996 |  13611339 |\n| CHINA    1 | CHINA    3 | 1996 |   8430793 |\n| CHINA    1 | CHINA    1 | 1996 |   1601332 |\n| CHINA    1 | CHINA    7 | 1997 | 664436721 |\n| CHINA    8 | CHINA    9 | 1997 | 585552148 |\n| CHINA    8 | CHINA    6 | 1997 | 543571889 |\n| CHINA    8 | CHINA    7 | 1997 | 516131917 |\n| CHINA    6 | CHINA    7 | 1997 | 467477883 |\n| CHINA    3 | CHINA    9 | 1997 | 444914344 |\n| CHINA    5 | CHINA    6 | 1997 | 353316321 |\n| CHINA    6 | CHINA    4 | 1997 | 338136205 |\n| CHINA    0 | CHINA    7 | 1997 | 329137493 |\n| CHINA    5 | CHINA    1 | 1997 | 328142466 |\n| CHINA    8 | CHINA    4 | 1997 | 308276385 |\n| CHINA    6 | CHINA    9 | 1997 | 306814317 |\n| CHINA    5 | CHINA    9 | 1997 | 301145803 |\n| CHINA    7 | CHINA    1 | 1997 | 299575802 |\n| CHINA    8 | CHINA    8 | 1997 | 282083295 |\n| CHINA    4 | CHINA    9 | 1997 | 280242025 |\n| CHINA    9 | CHINA    1 | 1997 | 253155313 |\n| CHINA    4 | CHINA    6 | 1997 | 234247182 |\n| CHINA    5 | CHINA    0 | 1997 | 217246162 |\n| CHINA    9 | CHINA    4 | 1997 | 215424663 |\n| CHINA    0 | CHINA    6 | 1997 | 211152240 |\n| CHINA    3 | CHINA    6 | 1997 | 205982217 |\n| CHINA    7 | CHINA    6 | 1997 | 196440117 |\n| CHINA    1 | CHINA    6 | 1997 | 195757737 |\n| CHINA    2 | CHINA    3 | 1997 | 189836909 |\n| CHINA    7 | CHINA    8 | 1997 | 189291379 |\n| CHINA    9 | CHINA    6 | 1997 | 189236146 |\n| CHINA    3 | CHINA    1 | 1997 | 188537684 |\n| CHINA    9 | CHINA    7 | 1997 | 182516267 |\n| CHINA    0 | CHINA    0 | 1997 | 182459980 |\n| CHINA    5 | CHINA    8 | 1997 | 177077882 |\n| CHINA    2 | CHINA    6 | 1997 | 176030529 |\n| CHINA    2 | CHINA    1 | 1997 | 168770050 |\n| CHINA    8 | CHINA    0 | 1997 | 167294093 |\n| CHINA    4 | CHINA    3 | 1997 | 161980658 |\n| CHINA    3 | CHINA    4 | 1997 | 154433882 |\n| CHINA    6 | CHINA    6 | 1997 | 153336736 |\n| CHINA    6 | CHINA    3 | 1997 | 151596497 |\n| CHINA    8 | CHINA    1 | 1997 | 145432603 |\n| CHINA    1 | CHINA    4 | 1997 | 126773981 |\n| CHINA    1 | CHINA    0 | 1997 | 120594770 |\n| CHINA    7 | CHINA    3 | 1997 | 119618460 |\n| CHINA    6 | CHINA    1 | 1997 | 119529805 |\n| CHINA    2 | CHINA    9 | 1997 | 114591288 |\n| CHINA    7 | CHINA    7 | 1997 | 111335941 |\n| CHINA    5 | CHINA    3 | 1997 | 111044153 |\n| CHINA    6 | CHINA    0 | 1997 | 104404276 |\n| CHINA    1 | CHINA    1 | 1997 |  98869501 |\n| CHINA    7 | CHINA    0 | 1997 |  97198605 |\n| CHINA    7 | CHINA    9 | 1997 |  92872632 |\n| CHINA    0 | CHINA    9 | 1997 |  91097832 |\n| CHINA    9 | CHINA    9 | 1997 |  86479272 |\n| CHINA    2 | CHINA    7 | 1997 |  79380820 |\n| CHINA    9 | CHINA    0 | 1997 |  78499693 |\n| CHINA    1 | CHINA    9 | 1997 |  73589328 |\n| CHINA    2 | CHINA    8 | 1997 |  71633835 |\n| CHINA    8 | CHINA    3 | 1997 |  70505885 |\n| CHINA    3 | CHINA    0 | 1997 |  61039282 |\n| CHINA    0 | CHINA    3 | 1997 |  58325113 |\n| CHINA    5 | CHINA    7 | 1997 |  55476389 |\n| CHINA    4 | CHINA    7 | 1997 |  46480159 |\n| CHINA    0 | CHINA    1 | 1997 |  38223038 |\n| CHINA    4 | CHINA    1 | 1997 |  21636342 |\n| CHINA    9 | CHINA    3 | 1997 |  13092788 |\n| CHINA    6 | CHINA    8 | 1997 |   2490092 |\n+------------+------------+------+-----------+\n\n-- Q3.3\n+------------+------------+------+-----------+\n| c_city     | s_city     | year | revenue   |\n+------------+------------+------+-----------+\n| UNITED KI0 | UNITED KI7 | 1992 | 251282102 |\n| UNITED KI0 | UNITED KI0 | 1992 | 170005406 |\n| UNITED KI7 | UNITED KI7 | 1992 |  36835396 |\n| UNITED KI0 | UNITED KI7 | 1993 | 560335810 |\n| UNITED KI0 | UNITED KI0 | 1993 | 294257692 |\n| UNITED KI7 | UNITED KI0 | 1993 | 159005896 |\n| UNITED KI7 | UNITED KI7 | 1993 | 139029264 |\n| UNITED KI0 | UNITED KI7 | 1994 | 739847089 |\n| UNITED KI0 | UNITED KI0 | 1994 | 302339390 |\n| UNITED KI7 | UNITED KI7 | 1994 | 275609814 |\n| UNITED KI7 | UNITED KI0 | 1994 | 117654093 |\n| UNITED KI0 | UNITED KI7 | 1995 | 540994655 |\n| UNITED KI0 | UNITED KI0 | 1995 | 230825439 |\n| UNITED KI7 | UNITED KI0 | 1995 | 197347696 |\n| UNITED KI7 | UNITED KI7 | 1995 | 136620517 |\n| UNITED KI0 | UNITED KI7 | 1996 | 448412094 |\n| UNITED KI0 | UNITED KI0 | 1996 | 203511607 |\n| UNITED KI7 | UNITED KI7 | 1996 |  94528075 |\n| UNITED KI7 | UNITED KI0 | 1996 |  35448536 |\n| UNITED KI7 | UNITED KI0 | 1997 | 289323850 |\n| UNITED KI7 | UNITED KI7 | 1997 | 214791175 |\n| UNITED KI0 | UNITED KI7 | 1997 | 196510174 |\n| UNITED KI0 | UNITED KI0 | 1997 | 125066127 |\n+------------+------------+------+-----------+\n\n-- Q3.4\n+------------+------------+------+-----------+\n| c_city     | s_city     | year | revenue   |\n+------------+------------+------+-----------+\n| UNITED KI7 | KENYA    4 | 1997 | 170083300 |\n| UNITED KI0 | MOZAMBIQU1 | 1997 | 155234463 |\n| UNITED KI0 | KENYA    4 | 1997 |  87283610 |\n+------------+------------+------+-----------+\n\n-- Q4.1\n+------+---------------+-------------+\n| year | c_nation      | profit      |\n+------+---------------+-------------+\n| 1992 | ARGENTINA     | 13746243380 |\n| 1992 | BRAZIL        | 15762831144 |\n| 1992 | CANADA        | 17477043721 |\n| 1992 | PERU          | 14698567030 |\n| 1992 | UNITED STATES | 14043501956 |\n| 1993 | ARGENTINA     | 13992888207 |\n| 1993 | BRAZIL        | 15146262693 |\n| 1993 | CANADA        | 12463985574 |\n| 1993 | PERU          | 11385007831 |\n| 1993 | UNITED STATES | 10651361815 |\n| 1994 | ARGENTINA     | 13128610315 |\n| 1994 | BRAZIL        | 13764866493 |\n| 1994 | CANADA        | 13723188154 |\n| 1994 | PERU          | 12784683808 |\n| 1994 | UNITED STATES | 12554422837 |\n| 1995 | ARGENTINA     | 14337205612 |\n| 1995 | BRAZIL        | 15068918320 |\n| 1995 | CANADA        | 14529005783 |\n| 1995 | PERU          | 13086675480 |\n| 1995 | UNITED STATES | 11330297649 |\n| 1996 | ARGENTINA     | 13659108915 |\n| 1996 | BRAZIL        | 12660837584 |\n| 1996 | CANADA        | 14558903190 |\n| 1996 | PERU          | 14162285166 |\n| 1996 | UNITED STATES | 11117076866 |\n| 1997 | ARGENTINA     | 12556399750 |\n| 1997 | BRAZIL        | 13961587144 |\n| 1997 | CANADA        | 15567856947 |\n| 1997 | PERU          | 13595325340 |\n| 1997 | UNITED STATES | 10779073839 |\n| 1998 | ARGENTINA     |  7843424759 |\n| 1998 | BRAZIL        |  8853904827 |\n| 1998 | CANADA        |  8286104334 |\n| 1998 | PERU          |  5822590950 |\n| 1998 | UNITED STATES |  8526236814 |\n+------+---------------+-------------+\n\n-- Q4.2\n+------+---------------+------------+------------+\n| year | s_nation      | p_category | profit     |\n+------+---------------+------------+------------+\n| 1997 | ARGENTINA     | MFGR#11    | 1636950553 |\n| 1997 | ARGENTINA     | MFGR#12    | 1265547847 |\n| 1997 | ARGENTINA     | MFGR#13    | 1505131346 |\n| 1997 | ARGENTINA     | MFGR#14    | 1405447137 |\n| 1997 | ARGENTINA     | MFGR#15    | 1564085340 |\n| 1997 | ARGENTINA     | MFGR#21    | 1335009490 |\n| 1997 | ARGENTINA     | MFGR#22    | 1309054179 |\n| 1997 | ARGENTINA     | MFGR#23    | 1305213794 |\n| 1997 | ARGENTINA     | MFGR#24    | 1089725126 |\n| 1997 | ARGENTINA     | MFGR#25    | 1291995512 |\n| 1997 | BRAZIL        | MFGR#11    |  721240147 |\n| 1997 | BRAZIL        | MFGR#12    |  928318830 |\n| 1997 | BRAZIL        | MFGR#13    | 1164674879 |\n| 1997 | BRAZIL        | MFGR#14    | 1215622587 |\n| 1997 | BRAZIL        | MFGR#15    |  940971658 |\n| 1997 | BRAZIL        | MFGR#21    | 1158909618 |\n| 1997 | BRAZIL        | MFGR#22    | 1251221641 |\n| 1997 | BRAZIL        | MFGR#23    | 1552552455 |\n| 1997 | BRAZIL        | MFGR#24    |  929057361 |\n| 1997 | BRAZIL        | MFGR#25    |  574645288 |\n| 1997 | CANADA        | MFGR#11    | 1170341370 |\n| 1997 | CANADA        | MFGR#12    | 1220238121 |\n| 1997 | CANADA        | MFGR#13    | 1245774025 |\n| 1997 | CANADA        | MFGR#14    | 1032046642 |\n| 1997 | CANADA        | MFGR#15    |  738650612 |\n| 1997 | CANADA        | MFGR#21    | 1476055209 |\n| 1997 | CANADA        | MFGR#22    | 1239005798 |\n| 1997 | CANADA        | MFGR#23    |  869393804 |\n| 1997 | CANADA        | MFGR#24    | 1466964051 |\n| 1997 | CANADA        | MFGR#25    | 1358922727 |\n| 1997 | PERU          | MFGR#11    | 1031023174 |\n| 1997 | PERU          | MFGR#12    |  731821491 |\n| 1997 | PERU          | MFGR#13    | 1044642877 |\n| 1997 | PERU          | MFGR#14    |  654877417 |\n| 1997 | PERU          | MFGR#15    | 1201769474 |\n| 1997 | PERU          | MFGR#21    | 1275496672 |\n| 1997 | PERU          | MFGR#22    |  599324545 |\n| 1997 | PERU          | MFGR#23    | 1200754744 |\n| 1997 | PERU          | MFGR#24    |  942152801 |\n| 1997 | PERU          | MFGR#25    | 1064322995 |\n| 1997 | UNITED STATES | MFGR#11    | 2365218925 |\n| 1997 | UNITED STATES | MFGR#12    | 1132346574 |\n| 1997 | UNITED STATES | MFGR#13    | 2460882362 |\n| 1997 | UNITED STATES | MFGR#14    | 2190816877 |\n| 1997 | UNITED STATES | MFGR#15    | 1687829921 |\n| 1997 | UNITED STATES | MFGR#21    | 2125880770 |\n| 1997 | UNITED STATES | MFGR#22    | 2013348097 |\n| 1997 | UNITED STATES | MFGR#23    | 2570581084 |\n| 1997 | UNITED STATES | MFGR#24    | 2724372315 |\n| 1997 | UNITED STATES | MFGR#25    | 1480012758 |\n| 1998 | ARGENTINA     | MFGR#11    |  783662770 |\n| 1998 | ARGENTINA     | MFGR#12    |  472818450 |\n| 1998 | ARGENTINA     | MFGR#13    |  585091533 |\n| 1998 | ARGENTINA     | MFGR#14    |  507297527 |\n| 1998 | ARGENTINA     | MFGR#15    |  549185408 |\n| 1998 | ARGENTINA     | MFGR#21    |  972928972 |\n| 1998 | ARGENTINA     | MFGR#22    | 1508294213 |\n| 1998 | ARGENTINA     | MFGR#23    |  517896738 |\n| 1998 | ARGENTINA     | MFGR#24    |  240754731 |\n| 1998 | ARGENTINA     | MFGR#25    |  757030162 |\n| 1998 | BRAZIL        | MFGR#11    |  826283793 |\n| 1998 | BRAZIL        | MFGR#12    |  482293349 |\n| 1998 | BRAZIL        | MFGR#13    | 1037202334 |\n| 1998 | BRAZIL        | MFGR#14    |  743598666 |\n| 1998 | BRAZIL        | MFGR#15    |  584176304 |\n| 1998 | BRAZIL        | MFGR#21    |  557259779 |\n| 1998 | BRAZIL        | MFGR#22    |  535654445 |\n| 1998 | BRAZIL        | MFGR#23    |  403656721 |\n| 1998 | BRAZIL        | MFGR#24    | 1305217551 |\n| 1998 | BRAZIL        | MFGR#25    | 1109801463 |\n| 1998 | CANADA        | MFGR#11    |  936169617 |\n| 1998 | CANADA        | MFGR#12    | 1017751308 |\n| 1998 | CANADA        | MFGR#13    |  850046376 |\n| 1998 | CANADA        | MFGR#14    |  808138010 |\n| 1998 | CANADA        | MFGR#15    |  701990010 |\n| 1998 | CANADA        | MFGR#21    |  402611051 |\n| 1998 | CANADA        | MFGR#22    |  382705122 |\n| 1998 | CANADA        | MFGR#23    |  509674722 |\n| 1998 | CANADA        | MFGR#24    | 1003021250 |\n| 1998 | CANADA        | MFGR#25    |  574602788 |\n| 1998 | PERU          | MFGR#11    |  552608732 |\n| 1998 | PERU          | MFGR#12    |  500581456 |\n| 1998 | PERU          | MFGR#13    |  894607711 |\n| 1998 | PERU          | MFGR#14    |  386487826 |\n| 1998 | PERU          | MFGR#15    | 1044780577 |\n| 1998 | PERU          | MFGR#21    |  184346232 |\n| 1998 | PERU          | MFGR#22    |  674942976 |\n| 1998 | PERU          | MFGR#23    |  665523956 |\n| 1998 | PERU          | MFGR#24    |  631374203 |\n| 1998 | PERU          | MFGR#25    |  602609608 |\n| 1998 | UNITED STATES | MFGR#11    | 1230069867 |\n| 1998 | UNITED STATES | MFGR#12    | 1557720319 |\n| 1998 | UNITED STATES | MFGR#13    |  999206739 |\n| 1998 | UNITED STATES | MFGR#14    |  605040268 |\n| 1998 | UNITED STATES | MFGR#15    |  850219215 |\n| 1998 | UNITED STATES | MFGR#21    | 1032550760 |\n| 1998 | UNITED STATES | MFGR#22    | 1370141401 |\n| 1998 | UNITED STATES | MFGR#23    | 1226632297 |\n| 1998 | UNITED STATES | MFGR#24    | 1528135100 |\n| 1998 | UNITED STATES | MFGR#25    | 1127867278 |\n+------+---------------+------------+------------+\n\n-- Q4.3\n+------+------------+-----------+-----------+\n| year | s_city     | p_brand   | profit    |\n+------+------------+-----------+-----------+\n| 1997 | UNITED ST0 | MFGR#1410 |  58481513 |\n| 1997 | UNITED ST0 | MFGR#1412 |  33582225 |\n| 1997 | UNITED ST0 | MFGR#1413 | 135625490 |\n| 1997 | UNITED ST0 | MFGR#1414 |  18581969 |\n| 1997 | UNITED ST0 | MFGR#142  | 164080005 |\n| 1997 | UNITED ST0 | MFGR#1420 |  30831591 |\n| 1997 | UNITED ST0 | MFGR#1424 |   4085253 |\n| 1997 | UNITED ST0 | MFGR#1425 | 163183170 |\n| 1997 | UNITED ST0 | MFGR#1427 |  87578288 |\n| 1997 | UNITED ST0 | MFGR#1428 | 109488143 |\n| 1997 | UNITED ST0 | MFGR#143  | 198055627 |\n| 1997 | UNITED ST0 | MFGR#1430 |  52544552 |\n| 1997 | UNITED ST0 | MFGR#1432 | 158742311 |\n| 1997 | UNITED ST0 | MFGR#144  |  43479982 |\n| 1997 | UNITED ST0 | MFGR#1440 |  40412893 |\n| 1997 | UNITED ST0 | MFGR#145  | 175568435 |\n| 1997 | UNITED ST1 | MFGR#141  |  11932912 |\n| 1997 | UNITED ST1 | MFGR#1411 |  40637463 |\n| 1997 | UNITED ST1 | MFGR#1415 |  27562355 |\n| 1997 | UNITED ST1 | MFGR#1421 | 100271780 |\n| 1997 | UNITED ST1 | MFGR#1422 | 103286764 |\n| 1997 | UNITED ST1 | MFGR#1423 | 106114459 |\n| 1997 | UNITED ST1 | MFGR#1427 | 157715681 |\n| 1997 | UNITED ST1 | MFGR#1428 |  91550168 |\n| 1997 | UNITED ST1 | MFGR#1430 |  56560173 |\n| 1997 | UNITED ST1 | MFGR#1431 | 248448914 |\n| 1997 | UNITED ST1 | MFGR#1435 |    994228 |\n| 1997 | UNITED ST1 | MFGR#144  |  55729825 |\n| 1997 | UNITED ST1 | MFGR#145  | 118034196 |\n| 1997 | UNITED ST1 | MFGR#146  |  99170724 |\n| 1997 | UNITED ST1 | MFGR#147  |   5123001 |\n| 1997 | UNITED ST2 | MFGR#141  | 111908637 |\n| 1997 | UNITED ST2 | MFGR#1414 |  96864725 |\n| 1997 | UNITED ST2 | MFGR#1415 | 123601050 |\n| 1997 | UNITED ST2 | MFGR#1421 |  21014618 |\n| 1997 | UNITED ST2 | MFGR#1427 |  46524767 |\n| 1997 | UNITED ST2 | MFGR#1429 |  18800062 |\n| 1997 | UNITED ST2 | MFGR#1431 |  79199532 |\n| 1997 | UNITED ST2 | MFGR#1432 |  53841788 |\n| 1997 | UNITED ST2 | MFGR#1433 | 133842836 |\n| 1997 | UNITED ST2 | MFGR#1434 |  96443006 |\n| 1997 | UNITED ST2 | MFGR#1435 |  50858424 |\n| 1997 | UNITED ST2 | MFGR#1438 |  64571457 |\n| 1997 | UNITED ST2 | MFGR#144  |  61319000 |\n| 1997 | UNITED ST2 | MFGR#146  |  69558050 |\n| 1997 | UNITED ST2 | MFGR#147  |  41160961 |\n| 1997 | UNITED ST2 | MFGR#149  |  31735872 |\n| 1997 | UNITED ST3 | MFGR#1410 | 306449140 |\n| 1997 | UNITED ST3 | MFGR#1411 | 114677189 |\n| 1997 | UNITED ST3 | MFGR#1412 |  49229127 |\n| 1997 | UNITED ST3 | MFGR#1413 | 174911640 |\n| 1997 | UNITED ST3 | MFGR#1415 | 134932298 |\n| 1997 | UNITED ST3 | MFGR#1416 |  97111854 |\n| 1997 | UNITED ST3 | MFGR#1417 | 176279103 |\n| 1997 | UNITED ST3 | MFGR#1418 |  70684147 |\n| 1997 | UNITED ST3 | MFGR#1420 |  27591782 |\n| 1997 | UNITED ST3 | MFGR#1422 |  39411253 |\n| 1997 | UNITED ST3 | MFGR#1424 | 226736650 |\n| 1997 | UNITED ST3 | MFGR#1426 |  63997112 |\n| 1997 | UNITED ST3 | MFGR#1429 |    556053 |\n| 1997 | UNITED ST3 | MFGR#143  |  73550925 |\n| 1997 | UNITED ST3 | MFGR#1430 | 218807697 |\n| 1997 | UNITED ST3 | MFGR#1431 |  39936281 |\n| 1997 | UNITED ST3 | MFGR#1432 |  44356689 |\n| 1997 | UNITED ST3 | MFGR#1435 |  49225455 |\n| 1997 | UNITED ST3 | MFGR#1436 |  90326644 |\n| 1997 | UNITED ST3 | MFGR#1439 |  84615817 |\n| 1997 | UNITED ST3 | MFGR#144  |  59081596 |\n| 1997 | UNITED ST3 | MFGR#1440 |  59601014 |\n| 1997 | UNITED ST3 | MFGR#145  | 100692258 |\n| 1997 | UNITED ST3 | MFGR#147  | 142417874 |\n| 1997 | UNITED ST3 | MFGR#148  |  38233221 |\n| 1997 | UNITED ST5 | MFGR#1416 |  62387773 |\n| 1997 | UNITED ST5 | MFGR#1417 |  54974702 |\n| 1997 | UNITED ST5 | MFGR#1418 |  87301086 |\n| 1997 | UNITED ST5 | MFGR#1421 |   9869673 |\n| 1997 | UNITED ST5 | MFGR#1422 |  58912225 |\n| 1997 | UNITED ST5 | MFGR#1424 |  80038584 |\n| 1997 | UNITED ST5 | MFGR#1428 |  44422717 |\n| 1997 | UNITED ST5 | MFGR#1430 |  67186074 |\n| 1997 | UNITED ST5 | MFGR#1433 | 105646942 |\n| 1997 | UNITED ST5 | MFGR#1434 |  13923867 |\n| 1997 | UNITED ST5 | MFGR#145  | 104286534 |\n| 1997 | UNITED ST5 | MFGR#146  |  20965182 |\n| 1997 | UNITED ST5 | MFGR#148  | 170596496 |\n| 1997 | UNITED ST5 | MFGR#149  |  42639213 |\n| 1997 | UNITED ST6 | MFGR#1411 |  48199726 |\n| 1997 | UNITED ST6 | MFGR#1413 |  28825982 |\n| 1997 | UNITED ST6 | MFGR#1414 | 107783723 |\n| 1997 | UNITED ST6 | MFGR#1415 |  92119787 |\n| 1997 | UNITED ST6 | MFGR#1416 |  35390328 |\n| 1997 | UNITED ST6 | MFGR#1417 |  92594053 |\n| 1997 | UNITED ST6 | MFGR#1418 |  67638716 |\n| 1997 | UNITED ST6 | MFGR#1421 |  98608466 |\n| 1997 | UNITED ST6 | MFGR#143  |  23938737 |\n| 1997 | UNITED ST6 | MFGR#1432 | 104846191 |\n| 1997 | UNITED ST6 | MFGR#1435 | 185809031 |\n| 1997 | UNITED ST6 | MFGR#1436 |  82920407 |\n| 1997 | UNITED ST6 | MFGR#1438 | 137524730 |\n| 1997 | UNITED ST6 | MFGR#146  |  28124052 |\n| 1997 | UNITED ST7 | MFGR#141  |  65266383 |\n| 1997 | UNITED ST7 | MFGR#1411 |  78295166 |\n| 1997 | UNITED ST7 | MFGR#1413 |  37554700 |\n| 1997 | UNITED ST7 | MFGR#1414 |  20428356 |\n| 1997 | UNITED ST7 | MFGR#1416 |  92381468 |\n| 1997 | UNITED ST7 | MFGR#1418 | 105276410 |\n| 1997 | UNITED ST7 | MFGR#1419 | 116086880 |\n| 1997 | UNITED ST7 | MFGR#1420 |  62010492 |\n| 1997 | UNITED ST7 | MFGR#1428 |  50904528 |\n| 1997 | UNITED ST7 | MFGR#1430 | 103558679 |\n| 1997 | UNITED ST7 | MFGR#1431 |  38342548 |\n| 1997 | UNITED ST7 | MFGR#1436 |  59859992 |\n| 1997 | UNITED ST7 | MFGR#1437 |  90701341 |\n| 1997 | UNITED ST7 | MFGR#147  | 133840269 |\n| 1997 | UNITED ST7 | MFGR#148  | 175852097 |\n| 1997 | UNITED ST9 | MFGR#1411 |  62786695 |\n| 1997 | UNITED ST9 | MFGR#1416 |  25354497 |\n| 1997 | UNITED ST9 | MFGR#1417 |  47367797 |\n| 1997 | UNITED ST9 | MFGR#1418 |  27220077 |\n| 1997 | UNITED ST9 | MFGR#142  |  41015203 |\n| 1997 | UNITED ST9 | MFGR#1423 |  41473506 |\n| 1997 | UNITED ST9 | MFGR#1424 |  10735092 |\n| 1997 | UNITED ST9 | MFGR#1425 |  27926087 |\n| 1997 | UNITED ST9 | MFGR#1426 | 136645966 |\n| 1997 | UNITED ST9 | MFGR#1430 |  41283531 |\n| 1997 | UNITED ST9 | MFGR#1433 |    497505 |\n| 1997 | UNITED ST9 | MFGR#1434 | 101147110 |\n| 1997 | UNITED ST9 | MFGR#1436 |  30923170 |\n| 1997 | UNITED ST9 | MFGR#145  |  18049495 |\n| 1997 | UNITED ST9 | MFGR#146  |  43726737 |\n| 1998 | UNITED ST0 | MFGR#1413 | 131487843 |\n| 1998 | UNITED ST0 | MFGR#1426 |  52942692 |\n| 1998 | UNITED ST0 | MFGR#146  |  13567224 |\n| 1998 | UNITED ST1 | MFGR#1410 |  65992198 |\n| 1998 | UNITED ST1 | MFGR#1416 | 115552383 |\n| 1998 | UNITED ST1 | MFGR#1418 |  15646035 |\n| 1998 | UNITED ST1 | MFGR#1419 | 129708776 |\n| 1998 | UNITED ST1 | MFGR#1428 |  18176281 |\n| 1998 | UNITED ST1 | MFGR#1431 |  17985830 |\n| 1998 | UNITED ST1 | MFGR#1436 |  16714417 |\n| 1998 | UNITED ST1 | MFGR#145  |  48297153 |\n| 1998 | UNITED ST2 | MFGR#1418 |   9240384 |\n| 1998 | UNITED ST2 | MFGR#1419 |  40909344 |\n| 1998 | UNITED ST2 | MFGR#1420 |  78625306 |\n| 1998 | UNITED ST2 | MFGR#1426 |  67161050 |\n| 1998 | UNITED ST2 | MFGR#1430 |  19028508 |\n| 1998 | UNITED ST2 | MFGR#1434 | 127804385 |\n| 1998 | UNITED ST2 | MFGR#1435 |  75092689 |\n| 1998 | UNITED ST2 | MFGR#1436 |  54579894 |\n| 1998 | UNITED ST2 | MFGR#1440 |  29067722 |\n| 1998 | UNITED ST2 | MFGR#148  |  78886426 |\n| 1998 | UNITED ST3 | MFGR#141  |   4311846 |\n| 1998 | UNITED ST3 | MFGR#1412 |  98979253 |\n| 1998 | UNITED ST3 | MFGR#1415 | 102275672 |\n| 1998 | UNITED ST3 | MFGR#1416 |  50781431 |\n| 1998 | UNITED ST3 | MFGR#1419 |  37451476 |\n| 1998 | UNITED ST3 | MFGR#1420 |  24660608 |\n| 1998 | UNITED ST3 | MFGR#1422 |  98548762 |\n| 1998 | UNITED ST3 | MFGR#1424 |  96601854 |\n| 1998 | UNITED ST3 | MFGR#1425 |  74508450 |\n| 1998 | UNITED ST3 | MFGR#1426 | 330583054 |\n| 1998 | UNITED ST3 | MFGR#1427 |  41352585 |\n| 1998 | UNITED ST3 | MFGR#1428 |  61979722 |\n| 1998 | UNITED ST3 | MFGR#1429 |    869295 |\n| 1998 | UNITED ST3 | MFGR#1432 |  66991135 |\n| 1998 | UNITED ST3 | MFGR#146  |  35929398 |\n| 1998 | UNITED ST3 | MFGR#147  |   8484972 |\n| 1998 | UNITED ST3 | MFGR#149  |  11793257 |\n| 1998 | UNITED ST5 | MFGR#1410 |  55951811 |\n| 1998 | UNITED ST5 | MFGR#1413 |  13403140 |\n| 1998 | UNITED ST5 | MFGR#142  |  24156762 |\n| 1998 | UNITED ST5 | MFGR#1422 | 105826683 |\n| 1998 | UNITED ST5 | MFGR#1430 |  67851607 |\n| 1998 | UNITED ST5 | MFGR#1431 |  84833774 |\n| 1998 | UNITED ST5 | MFGR#1434 |  45541810 |\n| 1998 | UNITED ST5 | MFGR#1437 |  33353745 |\n| 1998 | UNITED ST5 | MFGR#146  |  19891496 |\n| 1998 | UNITED ST6 | MFGR#1413 | 135522572 |\n| 1998 | UNITED ST6 | MFGR#1416 | 185707286 |\n| 1998 | UNITED ST6 | MFGR#1417 |  80511133 |\n| 1998 | UNITED ST6 | MFGR#1419 | 127132766 |\n| 1998 | UNITED ST6 | MFGR#142  |  72629474 |\n| 1998 | UNITED ST6 | MFGR#1435 | 158543190 |\n| 1998 | UNITED ST7 | MFGR#1412 |  56750777 |\n| 1998 | UNITED ST7 | MFGR#1424 |  89508621 |\n| 1998 | UNITED ST7 | MFGR#1425 | 160377031 |\n| 1998 | UNITED ST7 | MFGR#1434 |  20882477 |\n| 1998 | UNITED ST7 | MFGR#146  | 100783548 |\n| 1998 | UNITED ST7 | MFGR#147  |  61595522 |\n| 1998 | UNITED ST9 | MFGR#1412 |   5049765 |\n| 1998 | UNITED ST9 | MFGR#142  |  69919113 |\n| 1998 | UNITED ST9 | MFGR#1425 |  11003199 |\n| 1998 | UNITED ST9 | MFGR#1426 | 103616972 |\n| 1998 | UNITED ST9 | MFGR#1435 |  18879758 |\n| 1998 | UNITED ST9 | MFGR#1438 | 101903219 |\n+------+------------+-----------+-----------+\n
      "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#multiple-tables-queries-expected-results","title":"Multiple tables queries expected results","text":"
      -- Q1.1\n+--------------+\n| revenue      |\n+--------------+\n| 218453880421 |\n+--------------+\n\n-- Q1.2\n+---------+\n| revenue |\n+---------+\n|    NULL |\n+---------+\n\n-- Q1.3\n+-------------+\n| revenue     |\n+-------------+\n| 17527575453 |\n+-------------+\n\n-- Q2.1\n+------------+------+-----------+\n| lo_revenue | year | p_brand   |\n+------------+------+-----------+\n| 1135676414 | 1992 | MFGR#121  |\n| 1221327580 | 1992 | MFGR#1210 |\n| 1101539324 | 1992 | MFGR#1211 |\n| 1298411712 | 1992 | MFGR#1212 |\n| 1248062482 | 1992 | MFGR#1213 |\n| 1340976936 | 1992 | MFGR#1214 |\n| 1266304940 | 1992 | MFGR#1215 |\n| 1349693562 | 1992 | MFGR#1216 |\n| 1350186870 | 1992 | MFGR#1217 |\n| 1200404140 | 1992 | MFGR#1218 |\n| 1076087188 | 1992 | MFGR#1219 |\n| 1310653344 | 1992 | MFGR#122  |\n| 1080525764 | 1992 | MFGR#1220 |\n| 1112241266 | 1992 | MFGR#1221 |\n| 1181525554 | 1992 | MFGR#1222 |\n| 1070897302 | 1992 | MFGR#1223 |\n| 1407505222 | 1992 | MFGR#1224 |\n| 1141665736 | 1992 | MFGR#1225 |\n| 1228123186 | 1992 | MFGR#1226 |\n| 1163518776 | 1992 | MFGR#1227 |\n| 1289285184 | 1992 | MFGR#1228 |\n| 1281716860 | 1992 | MFGR#1229 |\n| 1579511670 | 1992 | MFGR#123  |\n|  937070174 | 1992 | MFGR#1230 |\n| 1184873312 | 1992 | MFGR#1231 |\n| 1328550304 | 1992 | MFGR#1232 |\n| 1227770200 | 1992 | MFGR#1233 |\n| 1334798562 | 1992 | MFGR#1234 |\n| 1280580140 | 1992 | MFGR#1235 |\n| 1003785122 | 1992 | MFGR#1236 |\n| 1182963006 | 1992 | MFGR#1237 |\n|  954847540 | 1992 | MFGR#1238 |\n| 1276518748 | 1992 | MFGR#1239 |\n| 1144708392 | 1992 | MFGR#124  |\n| 1480958496 | 1992 | MFGR#1240 |\n|  957554190 | 1992 | MFGR#125  |\n| 1184349232 | 1992 | MFGR#126  |\n| 1412303264 | 1992 | MFGR#127  |\n| 1084613292 | 1992 | MFGR#128  |\n| 1163974704 | 1992 | MFGR#129  |\n| 1646175404 | 1993 | MFGR#121  |\n| 1296321412 | 1993 | MFGR#1210 |\n| 1269487796 | 1993 | MFGR#1211 |\n| 1571278566 | 1993 | MFGR#1212 |\n| 1276510058 | 1993 | MFGR#1213 |\n| 1233674474 | 1993 | MFGR#1214 |\n| 1269375950 | 1993 | MFGR#1215 |\n| 1276707800 | 1993 | MFGR#1216 |\n| 1326745902 | 1993 | MFGR#1217 |\n| 1367971710 | 1993 | MFGR#1218 |\n| 1293900066 | 1993 | MFGR#1219 |\n| 1245065968 | 1993 | MFGR#122  |\n| 1061660254 | 1993 | MFGR#1220 |\n| 1086692674 | 1993 | MFGR#1221 |\n| 1513842406 | 1993 | MFGR#1222 |\n| 1067088700 | 1993 | MFGR#1223 |\n| 1831832170 | 1993 | MFGR#1224 |\n|  946014762 | 1993 | MFGR#1225 |\n| 1478072248 | 1993 | MFGR#1226 |\n| 1184357774 | 1993 | MFGR#1227 |\n| 1167014116 | 1993 | MFGR#1228 |\n| 1234906982 | 1993 | MFGR#1229 |\n| 1275727736 | 1993 | MFGR#123  |\n| 1251068620 | 1993 | MFGR#1230 |\n| 1160655270 | 1993 | MFGR#1231 |\n| 1394746196 | 1993 | MFGR#1232 |\n| 1031142832 | 1993 | MFGR#1233 |\n| 1303871516 | 1993 | MFGR#1234 |\n| 1151558960 | 1993 | MFGR#1235 |\n| 1183757334 | 1993 | MFGR#1236 |\n| 1219237152 | 1993 | MFGR#1237 |\n|  889228020 | 1993 | MFGR#1238 |\n| 1190512654 | 1993 | MFGR#1239 |\n| 1321172474 | 1993 | MFGR#124  |\n| 1577460118 | 1993 | MFGR#1240 |\n| 1232449078 | 1993 | MFGR#125  |\n| 1234253508 | 1993 | MFGR#126  |\n| 1308876648 | 1993 | MFGR#127  |\n| 1463314002 | 1993 | MFGR#128  |\n| 1096096790 | 1993 | MFGR#129  |\n| 1128811296 | 1994 | MFGR#121  |\n| 1290809698 | 1994 | MFGR#1210 |\n| 1263241270 | 1994 | MFGR#1211 |\n| 1136664696 | 1994 | MFGR#1212 |\n| 1357571714 | 1994 | MFGR#1213 |\n| 1068004660 | 1994 | MFGR#1214 |\n| 1308800484 | 1994 | MFGR#1215 |\n| 1117292682 | 1994 | MFGR#1216 |\n| 1375691282 | 1994 | MFGR#1217 |\n| 1093348694 | 1994 | MFGR#1218 |\n| 1134545884 | 1994 | MFGR#1219 |\n| 1319768124 | 1994 | MFGR#122  |\n| 1125164344 | 1994 | MFGR#1220 |\n| 1197237994 | 1994 | MFGR#1221 |\n| 1202032882 | 1994 | MFGR#1222 |\n| 1110268808 | 1994 | MFGR#1223 |\n| 1474844604 | 1994 | MFGR#1224 |\n| 1141491910 | 1994 | MFGR#1225 |\n| 1492604490 | 1994 | MFGR#1226 |\n| 1303414962 | 1994 | MFGR#1227 |\n| 1147387094 | 1994 | MFGR#1228 |\n| 1295836746 | 1994 | MFGR#1229 |\n| 1160899184 | 1994 | MFGR#123  |\n|  986540824 | 1994 | MFGR#1230 |\n| 1207092296 | 1994 | MFGR#1231 |\n| 1439730662 | 1994 | MFGR#1232 |\n| 1277964476 | 1994 | MFGR#1233 |\n| 1486495354 | 1994 | MFGR#1234 |\n| 1197361918 | 1994 | MFGR#1235 |\n| 1231452194 | 1994 | MFGR#1236 |\n| 1085139630 | 1994 | MFGR#1237 |\n| 1147021562 | 1994 | MFGR#1238 |\n| 1159711706 | 1994 | MFGR#1239 |\n| 1369146644 | 1994 | MFGR#124  |\n| 1747471474 | 1994 | MFGR#1240 |\n| 1120976608 | 1994 | MFGR#125  |\n| 1314073028 | 1994 | MFGR#126  |\n| 1245142366 | 1994 | MFGR#127  |\n| 1173691328 | 1994 | MFGR#128  |\n| 1069083050 | 1994 | MFGR#129  |\n| 1412939022 | 1995 | MFGR#121  |\n| 1205785606 | 1995 | MFGR#1210 |\n| 1290332184 | 1995 | MFGR#1211 |\n| 1226578566 | 1995 | MFGR#1212 |\n| 1199172958 | 1995 | MFGR#1213 |\n| 1125141608 | 1995 | MFGR#1214 |\n| 1345057510 | 1995 | MFGR#1215 |\n| 1338001944 | 1995 | MFGR#1216 |\n| 1450724898 | 1995 | MFGR#1217 |\n| 1314053270 | 1995 | MFGR#1218 |\n| 1039318006 | 1995 | MFGR#1219 |\n| 1449455482 | 1995 | MFGR#122  |\n| 1035912262 | 1995 | MFGR#1220 |\n| 1271482702 | 1995 | MFGR#1221 |\n| 1128736820 | 1995 | MFGR#1222 |\n| 1201330298 | 1995 | MFGR#1223 |\n| 1525400702 | 1995 | MFGR#1224 |\n| 1343339172 | 1995 | MFGR#1225 |\n| 1145137496 | 1995 | MFGR#1226 |\n| 1060722600 | 1995 | MFGR#1227 |\n| 1266714170 | 1995 | MFGR#1228 |\n| 1095920488 | 1995 | MFGR#1229 |\n| 1321422154 | 1995 | MFGR#123  |\n| 1205471716 | 1995 | MFGR#1230 |\n|  999704292 | 1995 | MFGR#1231 |\n| 1430601506 | 1995 | MFGR#1232 |\n| 1114299142 | 1995 | MFGR#1233 |\n| 1420046118 | 1995 | MFGR#1234 |\n| 1244850478 | 1995 | MFGR#1235 |\n| 1269131002 | 1995 | MFGR#1236 |\n| 1145694540 | 1995 | MFGR#1237 |\n| 1098637824 | 1995 | MFGR#1238 |\n| 1187703424 | 1995 | MFGR#1239 |\n| 1170843630 | 1995 | MFGR#124  |\n| 1414415776 | 1995 | MFGR#1240 |\n| 1076493744 | 1995 | MFGR#125  |\n| 1211598042 | 1995 | MFGR#126  |\n| 1331956224 | 1995 | MFGR#127  |\n| 1293921912 | 1995 | MFGR#128  |\n| 1017498802 | 1995 | MFGR#129  |\n| 1047758290 | 1996 | MFGR#121  |\n| 1287290106 | 1996 | MFGR#1210 |\n| 1190130678 | 1996 | MFGR#1211 |\n| 1349252880 | 1996 | MFGR#1212 |\n|  992594174 | 1996 | MFGR#1213 |\n| 1166499010 | 1996 | MFGR#1214 |\n| 1404369714 | 1996 | MFGR#1215 |\n| 1203618668 | 1996 | MFGR#1216 |\n| 1409796774 | 1996 | MFGR#1217 |\n| 1057686172 | 1996 | MFGR#1218 |\n| 1172492660 | 1996 | MFGR#1219 |\n| 1424220984 | 1996 | MFGR#122  |\n| 1036888430 | 1996 | MFGR#1220 |\n|  998638828 | 1996 | MFGR#1221 |\n| 1358938712 | 1996 | MFGR#1222 |\n| 1257525508 | 1996 | MFGR#1223 |\n| 1449689712 | 1996 | MFGR#1224 |\n| 1321241174 | 1996 | MFGR#1225 |\n| 1335349458 | 1996 | MFGR#1226 |\n|  967676170 | 1996 | MFGR#1227 |\n| 1219710782 | 1996 | MFGR#1228 |\n| 1317919114 | 1996 | MFGR#1229 |\n| 1132435704 | 1996 | MFGR#123  |\n| 1057759996 | 1996 | MFGR#1230 |\n| 1178962388 | 1996 | MFGR#1231 |\n| 1405611792 | 1996 | MFGR#1232 |\n| 1327359894 | 1996 | MFGR#1233 |\n| 1142298900 | 1996 | MFGR#1234 |\n|  957296148 | 1996 | MFGR#1235 |\n| 1136498730 | 1996 | MFGR#1236 |\n| 1185232334 | 1996 | MFGR#1237 |\n|  933352296 | 1996 | MFGR#1238 |\n| 1341387438 | 1996 | MFGR#1239 |\n| 1121335438 | 1996 | MFGR#124  |\n| 1642335900 | 1996 | MFGR#1240 |\n|  953728666 | 1996 | MFGR#125  |\n| 1116061768 | 1996 | MFGR#126  |\n| 1271747782 | 1996 | MFGR#127  |\n| 1102021236 | 1996 | MFGR#128  |\n| 1121141260 | 1996 | MFGR#129  |\n| 1174026414 | 1997 | MFGR#121  |\n| 1232575784 | 1997 | MFGR#1210 |\n| 1097177522 | 1997 | MFGR#1211 |\n| 1179187784 | 1997 | MFGR#1212 |\n|  848613340 | 1997 | MFGR#1213 |\n| 1023943820 | 1997 | MFGR#1214 |\n| 1263544492 | 1997 | MFGR#1215 |\n| 1384270280 | 1997 | MFGR#1216 |\n| 1555989914 | 1997 | MFGR#1217 |\n| 1414107440 | 1997 | MFGR#1218 |\n| 1122339054 | 1997 | MFGR#1219 |\n| 1329832490 | 1997 | MFGR#122  |\n| 1188932314 | 1997 | MFGR#1220 |\n| 1177696342 | 1997 | MFGR#1221 |\n| 1057977920 | 1997 | MFGR#1222 |\n| 1074196422 | 1997 | MFGR#1223 |\n| 1349526332 | 1997 | MFGR#1224 |\n|  900804584 | 1997 | MFGR#1225 |\n| 1402721444 | 1997 | MFGR#1226 |\n| 1012023140 | 1997 | MFGR#1227 |\n| 1171157474 | 1997 | MFGR#1228 |\n| 1245488032 | 1997 | MFGR#1229 |\n| 1293006336 | 1997 | MFGR#123  |\n| 1143601882 | 1997 | MFGR#1230 |\n| 1005203580 | 1997 | MFGR#1231 |\n| 1355849312 | 1997 | MFGR#1232 |\n| 1068911952 | 1997 | MFGR#1233 |\n| 1429869430 | 1997 | MFGR#1234 |\n| 1534302840 | 1997 | MFGR#1235 |\n| 1237754358 | 1997 | MFGR#1236 |\n| 1279276114 | 1997 | MFGR#1237 |\n|  803906838 | 1997 | MFGR#1238 |\n| 1221513428 | 1997 | MFGR#1239 |\n| 1086496174 | 1997 | MFGR#124  |\n| 1350265384 | 1997 | MFGR#1240 |\n|  958198730 | 1997 | MFGR#125  |\n| 1141393136 | 1997 | MFGR#126  |\n| 1166149184 | 1997 | MFGR#127  |\n| 1390266208 | 1997 | MFGR#128  |\n| 1311277552 | 1997 | MFGR#129  |\n|  689151850 | 1998 | MFGR#121  |\n|  834304832 | 1998 | MFGR#1210 |\n|  634136336 | 1998 | MFGR#1211 |\n|  748683032 | 1998 | MFGR#1212 |\n|  665481806 | 1998 | MFGR#1213 |\n|  609746004 | 1998 | MFGR#1214 |\n|  732202264 | 1998 | MFGR#1215 |\n|  758267796 | 1998 | MFGR#1216 |\n|  719016994 | 1998 | MFGR#1217 |\n|  641246668 | 1998 | MFGR#1218 |\n|  692365724 | 1998 | MFGR#1219 |\n|  624880054 | 1998 | MFGR#122  |\n|  696247922 | 1998 | MFGR#1220 |\n|  679690796 | 1998 | MFGR#1221 |\n|  710832322 | 1998 | MFGR#1222 |\n|  689779644 | 1998 | MFGR#1223 |\n|  793813382 | 1998 | MFGR#1224 |\n|  580417756 | 1998 | MFGR#1225 |\n|  838831414 | 1998 | MFGR#1226 |\n|  716932680 | 1998 | MFGR#1227 |\n|  503099910 | 1998 | MFGR#1228 |\n|  766277720 | 1998 | MFGR#1229 |\n|  592661122 | 1998 | MFGR#123  |\n|  874362486 | 1998 | MFGR#1230 |\n|  797888984 | 1998 | MFGR#1231 |\n|  848124910 | 1998 | MFGR#1232 |\n|  813934376 | 1998 | MFGR#1233 |\n|  857734480 | 1998 | MFGR#1234 |\n|  704555562 | 1998 | MFGR#1235 |\n|  723654172 | 1998 | MFGR#1236 |\n|  683237138 | 1998 | MFGR#1237 |\n|  489478462 | 1998 | MFGR#1238 |\n|  828303606 | 1998 | MFGR#1239 |\n|  660164742 | 1998 | MFGR#124  |\n|  830624906 | 1998 | MFGR#1240 |\n|  720579248 | 1998 | MFGR#125  |\n|  683315160 | 1998 | MFGR#126  |\n|  755014122 | 1998 | MFGR#127  |\n|  722832994 | 1998 | MFGR#128  |\n|  637539146 | 1998 | MFGR#129  |\n+------------+------+-----------+\n\n-- Q2.2\n+------------+------+-----------+\n| lo_revenue | year | p_brand   |\n+------------+------+-----------+\n| 1419049858 | 1992 | MFGR#2221 |\n| 1567692788 | 1992 | MFGR#2222 |\n| 1530104004 | 1992 | MFGR#2223 |\n| 1302977924 | 1992 | MFGR#2224 |\n| 1293057178 | 1992 | MFGR#2225 |\n| 1419301096 | 1992 | MFGR#2226 |\n| 1491112632 | 1992 | MFGR#2227 |\n| 1513803750 | 1992 | MFGR#2228 |\n| 1533042206 | 1993 | MFGR#2221 |\n| 1382951194 | 1993 | MFGR#2222 |\n| 1516441504 | 1993 | MFGR#2223 |\n| 1339325414 | 1993 | MFGR#2224 |\n| 1547708456 | 1993 | MFGR#2225 |\n| 1474175036 | 1993 | MFGR#2226 |\n| 1563935532 | 1993 | MFGR#2227 |\n| 1361760432 | 1993 | MFGR#2228 |\n| 1371555036 | 1994 | MFGR#2221 |\n| 1333049614 | 1994 | MFGR#2222 |\n| 1467987180 | 1994 | MFGR#2223 |\n| 1415738080 | 1994 | MFGR#2224 |\n| 1442503934 | 1994 | MFGR#2225 |\n| 1644991838 | 1994 | MFGR#2226 |\n| 1441674256 | 1994 | MFGR#2227 |\n| 1652450700 | 1994 | MFGR#2228 |\n| 1550874148 | 1995 | MFGR#2221 |\n| 1522709584 | 1995 | MFGR#2222 |\n| 1275665150 | 1995 | MFGR#2223 |\n| 1179531414 | 1995 | MFGR#2224 |\n| 1416580078 | 1995 | MFGR#2225 |\n| 1494712766 | 1995 | MFGR#2226 |\n| 1605005080 | 1995 | MFGR#2227 |\n| 1791873572 | 1995 | MFGR#2228 |\n| 1400020016 | 1996 | MFGR#2221 |\n| 1554620170 | 1996 | MFGR#2222 |\n| 1312190628 | 1996 | MFGR#2223 |\n| 1313719834 | 1996 | MFGR#2224 |\n| 1531641792 | 1996 | MFGR#2225 |\n| 1616355468 | 1996 | MFGR#2226 |\n| 1459126606 | 1996 | MFGR#2227 |\n| 1639331748 | 1996 | MFGR#2228 |\n| 1454684764 | 1997 | MFGR#2221 |\n| 1329067558 | 1997 | MFGR#2222 |\n| 1496576784 | 1997 | MFGR#2223 |\n| 1260844162 | 1997 | MFGR#2224 |\n| 1514782406 | 1997 | MFGR#2225 |\n| 1495778514 | 1997 | MFGR#2226 |\n| 1457715798 | 1997 | MFGR#2227 |\n| 1550625970 | 1997 | MFGR#2228 |\n|  670609008 | 1998 | MFGR#2221 |\n|  818694274 | 1998 | MFGR#2222 |\n|  918219154 | 1998 | MFGR#2223 |\n|  826636144 | 1998 | MFGR#2224 |\n|  820804190 | 1998 | MFGR#2225 |\n|  907030088 | 1998 | MFGR#2226 |\n|  781012810 | 1998 | MFGR#2227 |\n|  795878206 | 1998 | MFGR#2228 |\n+------------+------+-----------+\n\n-- Q2.3\n+------------+------+-----------+\n| lo_revenue | year | p_brand   |\n+------------+------+-----------+\n| 1452854972 | 1992 | MFGR#2239 |\n| 1410477918 | 1993 | MFGR#2239 |\n| 1328290268 | 1994 | MFGR#2239 |\n| 1427678672 | 1995 | MFGR#2239 |\n| 1456985730 | 1996 | MFGR#2239 |\n| 1467793064 | 1997 | MFGR#2239 |\n|  760511462 | 1998 | MFGR#2239 |\n+------------+------+-----------+\n\n-- Q3.1\n+-----------+-----------+------+-------------+\n| c_nation  | s_nation  | year | lo_revenue  |\n+-----------+-----------+------+-------------+\n| INDONESIA | INDONESIA | 1992 | 13811397976 |\n| CHINA     | INDONESIA | 1992 | 13232157738 |\n| CHINA     | CHINA     | 1992 | 12912862954 |\n| VIETNAM   | INDONESIA | 1992 | 12680363414 |\n| VIETNAM   | CHINA     | 1992 | 12665688780 |\n| INDONESIA | CHINA     | 1992 | 12621419066 |\n| INDIA     | INDONESIA | 1992 | 12477614708 |\n| JAPAN     | INDONESIA | 1992 | 12445131276 |\n| CHINA     | INDIA     | 1992 | 12379662702 |\n| CHINA     | JAPAN     | 1992 | 12315357786 |\n| JAPAN     | CHINA     | 1992 | 12134201310 |\n| INDIA     | CHINA     | 1992 | 12132923622 |\n| VIETNAM   | JAPAN     | 1992 | 11727572698 |\n| JAPAN     | INDIA     | 1992 | 11605499970 |\n| INDONESIA | INDIA     | 1992 | 11540406436 |\n| VIETNAM   | INDIA     | 1992 | 11397022802 |\n| INDONESIA | JAPAN     | 1992 | 11327531220 |\n| JAPAN     | JAPAN     | 1992 | 11296069422 |\n| INDIA     | JAPAN     | 1992 | 10843918562 |\n| CHINA     | VIETNAM   | 1992 | 10824644052 |\n| JAPAN     | VIETNAM   | 1992 | 10803385110 |\n| INDIA     | INDIA     | 1992 | 10722487510 |\n| INDONESIA | VIETNAM   | 1992 | 10605276744 |\n| INDIA     | VIETNAM   | 1992 | 10490661242 |\n| VIETNAM   | VIETNAM   | 1992 | 10223463556 |\n| INDONESIA | INDONESIA | 1993 | 13862726524 |\n| INDONESIA | CHINA     | 1993 | 13225782498 |\n| CHINA     | INDONESIA | 1993 | 13163026732 |\n| VIETNAM   | INDONESIA | 1993 | 13023278704 |\n| CHINA     | CHINA     | 1993 | 12889027574 |\n| CHINA     | INDIA     | 1993 | 12843388242 |\n| VIETNAM   | CHINA     | 1993 | 12827159998 |\n| INDIA     | INDONESIA | 1993 | 12662117188 |\n| JAPAN     | CHINA     | 1993 | 12584587990 |\n| INDIA     | CHINA     | 1993 | 12418707584 |\n| CHINA     | JAPAN     | 1993 | 12390933768 |\n| VIETNAM   | INDIA     | 1993 | 12322348954 |\n| INDONESIA | INDIA     | 1993 | 12303328612 |\n| INDONESIA | JAPAN     | 1993 | 12295210498 |\n| JAPAN     | INDONESIA | 1993 | 12107892626 |\n| INDIA     | JAPAN     | 1993 | 11990417970 |\n| CHINA     | VIETNAM   | 1993 | 11770046456 |\n| VIETNAM   | JAPAN     | 1993 | 11748533734 |\n| INDONESIA | VIETNAM   | 1993 | 11680575444 |\n| JAPAN     | INDIA     | 1993 | 11646686314 |\n| INDIA     | INDIA     | 1993 | 11143151598 |\n| VIETNAM   | VIETNAM   | 1993 | 11108322366 |\n| JAPAN     | JAPAN     | 1993 | 10860637166 |\n| JAPAN     | VIETNAM   | 1993 | 10813139306 |\n| INDIA     | VIETNAM   | 1993 | 10467742974 |\n| VIETNAM   | CHINA     | 1994 | 13419766884 |\n| CHINA     | CHINA     | 1994 | 13297885930 |\n| INDONESIA | CHINA     | 1994 | 12967201820 |\n| CHINA     | JAPAN     | 1994 | 12698074042 |\n| VIETNAM   | INDONESIA | 1994 | 12694883862 |\n| JAPAN     | CHINA     | 1994 | 12640018436 |\n| INDONESIA | INDONESIA | 1994 | 12630662172 |\n| CHINA     | INDIA     | 1994 | 12595165622 |\n| CHINA     | INDONESIA | 1994 | 12469575792 |\n| VIETNAM   | JAPAN     | 1994 | 12463946094 |\n| INDONESIA | INDIA     | 1994 | 12396824490 |\n| INDIA     | INDONESIA | 1994 | 12336379718 |\n| INDONESIA | JAPAN     | 1994 | 12282391938 |\n| JAPAN     | INDONESIA | 1994 | 12026069236 |\n| CHINA     | VIETNAM   | 1994 | 11770637466 |\n| INDIA     | CHINA     | 1994 | 11630045428 |\n| VIETNAM   | INDIA     | 1994 | 11578797382 |\n| JAPAN     | JAPAN     | 1994 | 11507642964 |\n| JAPAN     | INDIA     | 1994 | 11291637744 |\n| INDONESIA | VIETNAM   | 1994 | 11248692736 |\n| INDIA     | INDIA     | 1994 | 11169873030 |\n| VIETNAM   | VIETNAM   | 1994 | 10836996318 |\n| INDIA     | JAPAN     | 1994 | 10788269948 |\n| JAPAN     | VIETNAM   | 1994 | 10551643274 |\n| INDIA     | VIETNAM   | 1994 | 10502079630 |\n| CHINA     | INDONESIA | 1995 | 14149078888 |\n| INDONESIA | CHINA     | 1995 | 13857241240 |\n| CHINA     | CHINA     | 1995 | 13249333224 |\n| JAPAN     | CHINA     | 1995 | 13039778770 |\n| VIETNAM   | CHINA     | 1995 | 12665462536 |\n| INDONESIA | INDONESIA | 1995 | 12537062642 |\n| VIETNAM   | JAPAN     | 1995 | 12527914040 |\n| CHINA     | INDIA     | 1995 | 12493312748 |\n| VIETNAM   | INDIA     | 1995 | 12396883914 |\n| INDONESIA | INDIA     | 1995 | 12347610366 |\n| VIETNAM   | INDONESIA | 1995 | 12115640296 |\n| CHINA     | JAPAN     | 1995 | 12043708260 |\n| INDONESIA | JAPAN     | 1995 | 12038187742 |\n| INDIA     | CHINA     | 1995 | 12021065586 |\n| INDIA     | INDONESIA | 1995 | 11951037194 |\n| JAPAN     | JAPAN     | 1995 | 11904558258 |\n| JAPAN     | INDONESIA | 1995 | 11894001470 |\n| VIETNAM   | VIETNAM   | 1995 | 11509455214 |\n| JAPAN     | INDIA     | 1995 | 11461486252 |\n| INDONESIA | VIETNAM   | 1995 | 11149948132 |\n| INDIA     | INDIA     | 1995 | 11131991100 |\n| JAPAN     | VIETNAM   | 1995 | 11002627550 |\n| CHINA     | VIETNAM   | 1995 | 10979872126 |\n| INDIA     | JAPAN     | 1995 | 10938406854 |\n| INDIA     | VIETNAM   | 1995 | 10414126568 |\n| INDONESIA | INDONESIA | 1996 | 13500112566 |\n| CHINA     | INDONESIA | 1996 | 13314250150 |\n| INDONESIA | CHINA     | 1996 | 13226878224 |\n| CHINA     | CHINA     | 1996 | 13183395830 |\n| VIETNAM   | CHINA     | 1996 | 12857307780 |\n| VIETNAM   | INDONESIA | 1996 | 12591253464 |\n| JAPAN     | INDONESIA | 1996 | 12454895712 |\n| INDIA     | CHINA     | 1996 | 12397135638 |\n| INDIA     | INDONESIA | 1996 | 12378484116 |\n| CHINA     | INDIA     | 1996 | 12307574730 |\n| INDONESIA | INDIA     | 1996 | 12277621726 |\n| CHINA     | JAPAN     | 1996 | 12211132648 |\n| JAPAN     | CHINA     | 1996 | 12177971128 |\n| INDONESIA | JAPAN     | 1996 | 12111276444 |\n| VIETNAM   | JAPAN     | 1996 | 11839994300 |\n| VIETNAM   | VIETNAM   | 1996 | 11721684604 |\n| INDIA     | JAPAN     | 1996 | 11683329610 |\n| VIETNAM   | INDIA     | 1996 | 11614973966 |\n| JAPAN     | INDIA     | 1996 | 11289159232 |\n| JAPAN     | JAPAN     | 1996 | 11132409590 |\n| INDIA     | INDIA     | 1996 | 11064146206 |\n| INDONESIA | VIETNAM   | 1996 | 10877028774 |\n| CHINA     | VIETNAM   | 1996 | 10869545636 |\n| JAPAN     | VIETNAM   | 1996 | 10668555098 |\n| INDIA     | VIETNAM   | 1996 | 10587783062 |\n| CHINA     | INDONESIA | 1997 | 13306469392 |\n| INDONESIA | CHINA     | 1997 | 13154792628 |\n| CHINA     | CHINA     | 1997 | 12927589590 |\n| JAPAN     | INDONESIA | 1997 | 12858540252 |\n| INDONESIA | INDONESIA | 1997 | 12796855642 |\n| VIETNAM   | INDONESIA | 1997 | 12727166240 |\n| CHINA     | JAPAN     | 1997 | 12569467036 |\n| VIETNAM   | CHINA     | 1997 | 12328437446 |\n| INDIA     | CHINA     | 1997 | 12306564428 |\n| CHINA     | INDIA     | 1997 | 12168567966 |\n| INDONESIA | JAPAN     | 1997 | 12002855912 |\n| INDIA     | INDONESIA | 1997 | 11966878600 |\n| JAPAN     | CHINA     | 1997 | 11947699374 |\n| CHINA     | VIETNAM   | 1997 | 11816508352 |\n| JAPAN     | INDIA     | 1997 | 11593843984 |\n| JAPAN     | JAPAN     | 1997 | 11580900078 |\n| INDONESIA | INDIA     | 1997 | 11578734210 |\n| VIETNAM   | INDIA     | 1997 | 11460243216 |\n| INDIA     | INDIA     | 1997 | 11386057814 |\n| VIETNAM   | JAPAN     | 1997 | 11378690460 |\n| INDONESIA | VIETNAM   | 1997 | 11331356264 |\n| VIETNAM   | VIETNAM   | 1997 | 11240502648 |\n| INDIA     | JAPAN     | 1997 | 11175655826 |\n| JAPAN     | VIETNAM   | 1997 | 10499749228 |\n| INDIA     | VIETNAM   | 1997 | 10007249674 |\n+-----------+-----------+------+-------------+\n\n-- Q3.2\n+------------+------------+------+------------+\n| c_city     | s_city     | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED ST4 | UNITED ST1 | 1992 |  204054910 |\n| UNITED ST1 | UNITED ST0 | 1992 |  193978982 |\n| UNITED ST7 | UNITED ST0 | 1992 |  192156020 |\n| UNITED ST9 | UNITED ST0 | 1992 |  189626588 |\n| UNITED ST4 | UNITED ST0 | 1992 |  189288484 |\n| UNITED ST2 | UNITED ST4 | 1992 |  182361000 |\n| UNITED ST5 | UNITED ST0 | 1992 |  180864600 |\n| UNITED ST6 | UNITED ST7 | 1992 |  175316534 |\n| UNITED ST3 | UNITED ST9 | 1992 |  172284096 |\n| UNITED ST6 | UNITED ST5 | 1992 |  171765932 |\n| UNITED ST7 | UNITED ST3 | 1992 |  167531332 |\n| UNITED ST2 | UNITED ST9 | 1992 |  167411236 |\n| UNITED ST4 | UNITED ST6 | 1992 |  163772748 |\n| UNITED ST2 | UNITED ST1 | 1992 |  163678330 |\n| UNITED ST9 | UNITED ST1 | 1992 |  161590604 |\n| UNITED ST6 | UNITED ST3 | 1992 |  157556436 |\n| UNITED ST6 | UNITED ST0 | 1992 |  157393912 |\n| UNITED ST0 | UNITED ST1 | 1992 |  154534792 |\n| UNITED ST0 | UNITED ST0 | 1992 |  151244244 |\n| UNITED ST1 | UNITED ST9 | 1992 |  150734118 |\n| UNITED ST3 | UNITED ST1 | 1992 |  147274980 |\n| UNITED ST2 | UNITED ST0 | 1992 |  144420436 |\n| UNITED ST1 | UNITED ST7 | 1992 |  142945946 |\n| UNITED ST6 | UNITED ST4 | 1992 |  142173888 |\n| UNITED ST4 | UNITED ST4 | 1992 |  140222670 |\n| UNITED ST6 | UNITED ST1 | 1992 |  138817376 |\n| UNITED ST4 | UNITED ST3 | 1992 |  138003574 |\n| UNITED ST5 | UNITED ST7 | 1992 |  136667302 |\n| UNITED ST4 | UNITED ST9 | 1992 |  135675940 |\n| UNITED ST7 | UNITED ST6 | 1992 |  131026410 |\n| UNITED ST4 | UNITED ST5 | 1992 |  130115744 |\n| UNITED ST7 | UNITED ST4 | 1992 |  129801776 |\n| UNITED ST1 | UNITED ST1 | 1992 |  129338140 |\n| UNITED ST3 | UNITED ST5 | 1992 |  128478096 |\n| UNITED ST0 | UNITED ST9 | 1992 |  127959992 |\n| UNITED ST3 | UNITED ST4 | 1992 |  126289544 |\n| UNITED ST5 | UNITED ST6 | 1992 |  125256186 |\n| UNITED ST4 | UNITED ST7 | 1992 |  125058752 |\n| UNITED ST3 | UNITED ST0 | 1992 |  124883312 |\n| UNITED ST9 | UNITED ST4 | 1992 |  122979026 |\n| UNITED ST8 | UNITED ST6 | 1992 |  121080880 |\n| UNITED ST7 | UNITED ST9 | 1992 |  120652084 |\n| UNITED ST7 | UNITED ST7 | 1992 |  120242772 |\n| UNITED ST5 | UNITED ST1 | 1992 |  119890574 |\n| UNITED ST5 | UNITED ST4 | 1992 |  115251254 |\n| UNITED ST7 | UNITED ST5 | 1992 |  115133604 |\n| UNITED ST2 | UNITED ST5 | 1992 |  114042730 |\n| UNITED ST9 | UNITED ST7 | 1992 |  113766718 |\n| UNITED ST0 | UNITED ST3 | 1992 |  112718634 |\n| UNITED ST1 | UNITED ST3 | 1992 |  111454948 |\n| UNITED ST5 | UNITED ST3 | 1992 |  107927106 |\n| UNITED ST0 | UNITED ST7 | 1992 |  101166818 |\n| UNITED ST5 | UNITED ST9 | 1992 |  100382182 |\n| UNITED ST7 | UNITED ST1 | 1992 |  100334416 |\n| UNITED ST0 | UNITED ST8 | 1992 |   99465280 |\n| UNITED ST0 | UNITED ST4 | 1992 |   99353614 |\n| UNITED ST9 | UNITED ST3 | 1992 |   95362330 |\n| UNITED ST8 | UNITED ST4 | 1992 |   93514038 |\n| UNITED ST3 | UNITED ST3 | 1992 |   90174432 |\n| UNITED ST8 | UNITED ST0 | 1992 |   88737678 |\n| UNITED ST0 | UNITED ST6 | 1992 |   84943612 |\n| UNITED ST6 | UNITED ST8 | 1992 |   84927380 |\n| UNITED ST8 | UNITED ST7 | 1992 |   83795802 |\n| UNITED ST3 | UNITED ST8 | 1992 |   82551528 |\n| UNITED ST6 | UNITED ST9 | 1992 |   81183442 |\n| UNITED ST0 | UNITED ST5 | 1992 |   80241772 |\n| UNITED ST1 | UNITED ST4 | 1992 |   78652692 |\n| UNITED ST3 | UNITED ST7 | 1992 |   78057158 |\n| UNITED ST3 | UNITED ST6 | 1992 |   77597430 |\n| UNITED ST9 | UNITED ST9 | 1992 |   72096686 |\n| UNITED ST2 | UNITED ST8 | 1992 |   72092898 |\n| UNITED ST2 | UNITED ST3 | 1992 |   71963926 |\n| UNITED ST8 | UNITED ST1 | 1992 |   71361504 |\n| UNITED ST1 | UNITED ST6 | 1992 |   70809980 |\n| UNITED ST8 | UNITED ST5 | 1992 |   70375220 |\n| UNITED ST1 | UNITED ST5 | 1992 |   67942502 |\n| UNITED ST5 | UNITED ST8 | 1992 |   67756106 |\n| UNITED ST2 | UNITED ST7 | 1992 |   67405558 |\n| UNITED ST8 | UNITED ST3 | 1992 |   61898648 |\n| UNITED ST8 | UNITED ST8 | 1992 |   58618216 |\n| UNITED ST5 | UNITED ST5 | 1992 |   58559136 |\n| UNITED ST1 | UNITED ST8 | 1992 |   57131158 |\n| UNITED ST9 | UNITED ST5 | 1992 |   56150008 |\n| UNITED ST2 | UNITED ST6 | 1992 |   55627478 |\n| UNITED ST0 | UNITED ST2 | 1992 |   55437466 |\n| UNITED ST2 | UNITED ST2 | 1992 |   51487308 |\n| UNITED ST8 | UNITED ST9 | 1992 |   45368942 |\n| UNITED ST4 | UNITED ST8 | 1992 |   43856884 |\n| UNITED ST9 | UNITED ST8 | 1992 |   42772200 |\n| UNITED ST5 | UNITED ST2 | 1992 |   40991634 |\n| UNITED ST6 | UNITED ST6 | 1992 |   36274210 |\n| UNITED ST9 | UNITED ST6 | 1992 |   31759136 |\n| UNITED ST4 | UNITED ST2 | 1992 |   24123690 |\n| UNITED ST7 | UNITED ST8 | 1992 |   23791404 |\n| UNITED ST6 | UNITED ST2 | 1992 |   23641396 |\n| UNITED ST9 | UNITED ST2 | 1992 |   23246354 |\n| UNITED ST8 | UNITED ST2 | 1992 |   21943122 |\n| UNITED ST1 | UNITED ST2 | 1992 |   15413456 |\n| UNITED ST7 | UNITED ST2 | 1992 |    9886408 |\n| UNITED ST3 | UNITED ST2 | 1992 |    2194416 |\n| UNITED ST0 | UNITED ST9 | 1993 |  219668080 |\n| UNITED ST7 | UNITED ST0 | 1993 |  219576048 |\n| UNITED ST5 | UNITED ST0 | 1993 |  213645194 |\n| UNITED ST0 | UNITED ST0 | 1993 |  213485096 |\n| UNITED ST1 | UNITED ST0 | 1993 |  198611904 |\n| UNITED ST4 | UNITED ST4 | 1993 |  196300930 |\n| UNITED ST3 | UNITED ST4 | 1993 |  184987840 |\n| UNITED ST0 | UNITED ST1 | 1993 |  182393186 |\n| UNITED ST4 | UNITED ST1 | 1993 |  177042846 |\n| UNITED ST8 | UNITED ST0 | 1993 |  176712742 |\n| UNITED ST4 | UNITED ST7 | 1993 |  176344396 |\n| UNITED ST4 | UNITED ST0 | 1993 |  173836916 |\n| UNITED ST6 | UNITED ST3 | 1993 |  166834322 |\n| UNITED ST6 | UNITED ST1 | 1993 |  166691878 |\n| UNITED ST7 | UNITED ST9 | 1993 |  160621402 |\n| UNITED ST3 | UNITED ST1 | 1993 |  156460556 |\n| UNITED ST6 | UNITED ST7 | 1993 |  156394588 |\n| UNITED ST5 | UNITED ST9 | 1993 |  152573078 |\n| UNITED ST0 | UNITED ST3 | 1993 |  152342566 |\n| UNITED ST5 | UNITED ST8 | 1993 |  148718558 |\n| UNITED ST9 | UNITED ST1 | 1993 |  148118838 |\n| UNITED ST4 | UNITED ST9 | 1993 |  146593918 |\n| UNITED ST5 | UNITED ST1 | 1993 |  142909246 |\n| UNITED ST6 | UNITED ST4 | 1993 |  139293826 |\n| UNITED ST2 | UNITED ST1 | 1993 |  139263402 |\n| UNITED ST6 | UNITED ST0 | 1993 |  136495078 |\n| UNITED ST7 | UNITED ST7 | 1993 |  136219640 |\n| UNITED ST2 | UNITED ST3 | 1993 |  133944876 |\n| UNITED ST3 | UNITED ST0 | 1993 |  133253852 |\n| UNITED ST9 | UNITED ST7 | 1993 |  133250966 |\n| UNITED ST1 | UNITED ST8 | 1993 |  132292396 |\n| UNITED ST2 | UNITED ST7 | 1993 |  128370028 |\n| UNITED ST5 | UNITED ST4 | 1993 |  126831278 |\n| UNITED ST9 | UNITED ST9 | 1993 |  126521526 |\n| UNITED ST1 | UNITED ST4 | 1993 |  125768694 |\n| UNITED ST7 | UNITED ST4 | 1993 |  123313226 |\n| UNITED ST3 | UNITED ST6 | 1993 |  117169616 |\n| UNITED ST2 | UNITED ST4 | 1993 |  113300782 |\n| UNITED ST3 | UNITED ST5 | 1993 |  111814610 |\n| UNITED ST6 | UNITED ST9 | 1993 |  109801884 |\n| UNITED ST1 | UNITED ST7 | 1993 |  109702366 |\n| UNITED ST3 | UNITED ST9 | 1993 |  109525192 |\n| UNITED ST8 | UNITED ST6 | 1993 |  109266124 |\n| UNITED ST8 | UNITED ST3 | 1993 |  108099748 |\n| UNITED ST5 | UNITED ST7 | 1993 |  105491076 |\n| UNITED ST0 | UNITED ST5 | 1993 |  105402104 |\n| UNITED ST1 | UNITED ST9 | 1993 |  105029804 |\n| UNITED ST8 | UNITED ST5 | 1993 |  104475674 |\n| UNITED ST1 | UNITED ST3 | 1993 |  104195892 |\n| UNITED ST8 | UNITED ST4 | 1993 |  102838712 |\n| UNITED ST0 | UNITED ST6 | 1993 |  100864564 |\n| UNITED ST5 | UNITED ST5 | 1993 |  100714378 |\n| UNITED ST3 | UNITED ST7 | 1993 |  100270896 |\n| UNITED ST0 | UNITED ST4 | 1993 |   98520134 |\n| UNITED ST0 | UNITED ST7 | 1993 |   97592720 |\n| UNITED ST2 | UNITED ST9 | 1993 |   96377014 |\n| UNITED ST1 | UNITED ST1 | 1993 |   95077220 |\n| UNITED ST9 | UNITED ST3 | 1993 |   93887294 |\n| UNITED ST7 | UNITED ST5 | 1993 |   89527384 |\n| UNITED ST1 | UNITED ST6 | 1993 |   89457080 |\n| UNITED ST8 | UNITED ST1 | 1993 |   88830868 |\n| UNITED ST7 | UNITED ST8 | 1993 |   87805256 |\n| UNITED ST9 | UNITED ST6 | 1993 |   87734320 |\n| UNITED ST2 | UNITED ST0 | 1993 |   85690970 |\n| UNITED ST3 | UNITED ST8 | 1993 |   84503696 |\n| UNITED ST0 | UNITED ST8 | 1993 |   84005364 |\n| UNITED ST4 | UNITED ST8 | 1993 |   83315164 |\n| UNITED ST1 | UNITED ST5 | 1993 |   81387026 |\n| UNITED ST9 | UNITED ST5 | 1993 |   79370538 |\n| UNITED ST7 | UNITED ST3 | 1993 |   79047722 |\n| UNITED ST8 | UNITED ST8 | 1993 |   77580470 |\n| UNITED ST8 | UNITED ST9 | 1993 |   77032722 |\n| UNITED ST2 | UNITED ST5 | 1993 |   74813690 |\n| UNITED ST9 | UNITED ST8 | 1993 |   74369392 |\n| UNITED ST8 | UNITED ST7 | 1993 |   73804436 |\n| UNITED ST6 | UNITED ST8 | 1993 |   72913482 |\n| UNITED ST7 | UNITED ST1 | 1993 |   68782318 |\n| UNITED ST6 | UNITED ST5 | 1993 |   68458164 |\n| UNITED ST5 | UNITED ST3 | 1993 |   68063622 |\n| UNITED ST2 | UNITED ST8 | 1993 |   66890892 |\n| UNITED ST4 | UNITED ST3 | 1993 |   66258824 |\n| UNITED ST6 | UNITED ST6 | 1993 |   66101326 |\n| UNITED ST9 | UNITED ST0 | 1993 |   65306610 |\n| UNITED ST4 | UNITED ST6 | 1993 |   61398510 |\n| UNITED ST9 | UNITED ST4 | 1993 |   61289374 |\n| UNITED ST4 | UNITED ST5 | 1993 |   58239188 |\n| UNITED ST7 | UNITED ST6 | 1993 |   54201004 |\n| UNITED ST4 | UNITED ST2 | 1993 |   54025356 |\n| UNITED ST2 | UNITED ST6 | 1993 |   52964452 |\n| UNITED ST5 | UNITED ST6 | 1993 |   50715358 |\n| UNITED ST3 | UNITED ST3 | 1993 |   43554288 |\n| UNITED ST3 | UNITED ST2 | 1993 |   43118146 |\n| UNITED ST5 | UNITED ST2 | 1993 |   41220484 |\n| UNITED ST7 | UNITED ST2 | 1993 |   40438608 |\n| UNITED ST6 | UNITED ST2 | 1993 |   37628734 |\n| UNITED ST9 | UNITED ST2 | 1993 |   35436780 |\n| UNITED ST1 | UNITED ST2 | 1993 |   33689076 |\n| UNITED ST0 | UNITED ST2 | 1993 |   30084290 |\n| UNITED ST2 | UNITED ST2 | 1993 |   29043990 |\n| UNITED ST8 | UNITED ST2 | 1993 |   19968732 |\n| UNITED ST8 | UNITED ST0 | 1994 |  198441578 |\n| UNITED ST3 | UNITED ST9 | 1994 |  194952370 |\n| UNITED ST6 | UNITED ST1 | 1994 |  193874294 |\n| UNITED ST6 | UNITED ST9 | 1994 |  189366618 |\n| UNITED ST9 | UNITED ST1 | 1994 |  180881896 |\n| UNITED ST0 | UNITED ST9 | 1994 |  179730404 |\n| UNITED ST5 | UNITED ST7 | 1994 |  178179922 |\n| UNITED ST9 | UNITED ST0 | 1994 |  175341146 |\n| UNITED ST3 | UNITED ST1 | 1994 |  171047306 |\n| UNITED ST4 | UNITED ST9 | 1994 |  167644786 |\n| UNITED ST0 | UNITED ST0 | 1994 |  167053754 |\n| UNITED ST7 | UNITED ST0 | 1994 |  164531072 |\n| UNITED ST2 | UNITED ST1 | 1994 |  162600178 |\n| UNITED ST5 | UNITED ST0 | 1994 |  157296114 |\n| UNITED ST4 | UNITED ST7 | 1994 |  153908280 |\n| UNITED ST4 | UNITED ST4 | 1994 |  153674762 |\n| UNITED ST0 | UNITED ST1 | 1994 |  153226758 |\n| UNITED ST1 | UNITED ST3 | 1994 |  151984918 |\n| UNITED ST7 | UNITED ST1 | 1994 |  150641598 |\n| UNITED ST4 | UNITED ST0 | 1994 |  147438680 |\n| UNITED ST5 | UNITED ST1 | 1994 |  147016836 |\n| UNITED ST4 | UNITED ST1 | 1994 |  144439114 |\n| UNITED ST2 | UNITED ST9 | 1994 |  139342108 |\n| UNITED ST6 | UNITED ST5 | 1994 |  132923068 |\n| UNITED ST2 | UNITED ST3 | 1994 |  131241520 |\n| UNITED ST3 | UNITED ST0 | 1994 |  131045454 |\n| UNITED ST5 | UNITED ST3 | 1994 |  130669822 |\n| UNITED ST7 | UNITED ST4 | 1994 |  129557430 |\n| UNITED ST3 | UNITED ST4 | 1994 |  126824730 |\n| UNITED ST8 | UNITED ST4 | 1994 |  124283362 |\n| UNITED ST0 | UNITED ST4 | 1994 |  123039488 |\n| UNITED ST0 | UNITED ST7 | 1994 |  122961640 |\n| UNITED ST0 | UNITED ST6 | 1994 |  122577556 |\n| UNITED ST2 | UNITED ST0 | 1994 |  120364306 |\n| UNITED ST6 | UNITED ST4 | 1994 |  119659978 |\n| UNITED ST4 | UNITED ST5 | 1994 |  118794056 |\n| UNITED ST8 | UNITED ST9 | 1994 |  117333812 |\n| UNITED ST4 | UNITED ST6 | 1994 |  117266964 |\n| UNITED ST5 | UNITED ST5 | 1994 |  112470426 |\n| UNITED ST6 | UNITED ST3 | 1994 |  112246476 |\n| UNITED ST2 | UNITED ST4 | 1994 |  111358754 |\n| UNITED ST8 | UNITED ST3 | 1994 |  110407682 |\n| UNITED ST1 | UNITED ST1 | 1994 |  108766348 |\n| UNITED ST1 | UNITED ST7 | 1994 |  107706212 |\n| UNITED ST6 | UNITED ST0 | 1994 |  107457706 |\n| UNITED ST5 | UNITED ST9 | 1994 |  106734662 |\n| UNITED ST9 | UNITED ST9 | 1994 |  103961698 |\n| UNITED ST5 | UNITED ST4 | 1994 |  103599186 |\n| UNITED ST7 | UNITED ST9 | 1994 |  100288170 |\n| UNITED ST7 | UNITED ST7 | 1994 |   92892884 |\n| UNITED ST6 | UNITED ST6 | 1994 |   92399444 |\n| UNITED ST7 | UNITED ST5 | 1994 |   91790728 |\n| UNITED ST3 | UNITED ST3 | 1994 |   91254306 |\n| UNITED ST8 | UNITED ST5 | 1994 |   89106112 |\n| UNITED ST9 | UNITED ST4 | 1994 |   87821522 |\n| UNITED ST1 | UNITED ST0 | 1994 |   86450402 |\n| UNITED ST1 | UNITED ST9 | 1994 |   86000074 |\n| UNITED ST7 | UNITED ST8 | 1994 |   85552934 |\n| UNITED ST0 | UNITED ST5 | 1994 |   83616602 |\n| UNITED ST2 | UNITED ST6 | 1994 |   83052210 |\n| UNITED ST1 | UNITED ST4 | 1994 |   82763116 |\n| UNITED ST3 | UNITED ST7 | 1994 |   81870262 |\n| UNITED ST8 | UNITED ST1 | 1994 |   80304192 |\n| UNITED ST9 | UNITED ST8 | 1994 |   78557616 |\n| UNITED ST5 | UNITED ST6 | 1994 |   77316902 |\n| UNITED ST2 | UNITED ST5 | 1994 |   75280634 |\n| UNITED ST8 | UNITED ST7 | 1994 |   75201374 |\n| UNITED ST9 | UNITED ST5 | 1994 |   74293452 |\n| UNITED ST6 | UNITED ST7 | 1994 |   74115616 |\n| UNITED ST8 | UNITED ST6 | 1994 |   73553138 |\n| UNITED ST3 | UNITED ST6 | 1994 |   72580514 |\n| UNITED ST9 | UNITED ST3 | 1994 |   71693000 |\n| UNITED ST2 | UNITED ST8 | 1994 |   67535548 |\n| UNITED ST0 | UNITED ST8 | 1994 |   63690866 |\n| UNITED ST4 | UNITED ST3 | 1994 |   63198866 |\n| UNITED ST9 | UNITED ST7 | 1994 |   63172346 |\n| UNITED ST1 | UNITED ST6 | 1994 |   62574652 |\n| UNITED ST1 | UNITED ST8 | 1994 |   60490306 |\n| UNITED ST7 | UNITED ST3 | 1994 |   58849680 |\n| UNITED ST9 | UNITED ST6 | 1994 |   58425854 |\n| UNITED ST0 | UNITED ST3 | 1994 |   54655658 |\n| UNITED ST6 | UNITED ST8 | 1994 |   53185992 |\n| UNITED ST3 | UNITED ST5 | 1994 |   52395750 |\n| UNITED ST6 | UNITED ST2 | 1994 |   51618000 |\n| UNITED ST1 | UNITED ST5 | 1994 |   49878276 |\n| UNITED ST7 | UNITED ST6 | 1994 |   49263874 |\n| UNITED ST1 | UNITED ST2 | 1994 |   47113172 |\n| UNITED ST4 | UNITED ST2 | 1994 |   46071784 |\n| UNITED ST2 | UNITED ST7 | 1994 |   44365516 |\n| UNITED ST0 | UNITED ST2 | 1994 |   44035908 |\n| UNITED ST4 | UNITED ST8 | 1994 |   41370704 |\n| UNITED ST7 | UNITED ST2 | 1994 |   39310162 |\n| UNITED ST5 | UNITED ST8 | 1994 |   37863782 |\n| UNITED ST2 | UNITED ST2 | 1994 |   36137314 |\n| UNITED ST3 | UNITED ST8 | 1994 |   31872102 |\n| UNITED ST8 | UNITED ST8 | 1994 |   20046824 |\n| UNITED ST3 | UNITED ST2 | 1994 |   19990468 |\n| UNITED ST9 | UNITED ST2 | 1994 |   19401978 |\n| UNITED ST5 | UNITED ST2 | 1994 |   14325592 |\n| UNITED ST8 | UNITED ST2 | 1994 |    7579252 |\n| UNITED ST5 | UNITED ST1 | 1995 |  239587338 |\n| UNITED ST4 | UNITED ST9 | 1995 |  198980136 |\n| UNITED ST7 | UNITED ST0 | 1995 |  196062590 |\n| UNITED ST6 | UNITED ST0 | 1995 |  183436942 |\n| UNITED ST4 | UNITED ST1 | 1995 |  181757306 |\n| UNITED ST0 | UNITED ST1 | 1995 |  181527198 |\n| UNITED ST8 | UNITED ST9 | 1995 |  177710178 |\n| UNITED ST7 | UNITED ST7 | 1995 |  173143248 |\n| UNITED ST3 | UNITED ST0 | 1995 |  168925466 |\n| UNITED ST9 | UNITED ST1 | 1995 |  165877934 |\n| UNITED ST2 | UNITED ST4 | 1995 |  164864610 |\n| UNITED ST1 | UNITED ST0 | 1995 |  163353246 |\n| UNITED ST5 | UNITED ST4 | 1995 |  162033522 |\n| UNITED ST7 | UNITED ST1 | 1995 |  159928724 |\n| UNITED ST5 | UNITED ST3 | 1995 |  156198260 |\n| UNITED ST5 | UNITED ST0 | 1995 |  155231492 |\n| UNITED ST9 | UNITED ST9 | 1995 |  153031916 |\n| UNITED ST7 | UNITED ST9 | 1995 |  150635418 |\n| UNITED ST4 | UNITED ST4 | 1995 |  149174142 |\n| UNITED ST9 | UNITED ST4 | 1995 |  145051372 |\n| UNITED ST1 | UNITED ST9 | 1995 |  144941740 |\n| UNITED ST4 | UNITED ST7 | 1995 |  138528814 |\n| UNITED ST6 | UNITED ST3 | 1995 |  135026124 |\n| UNITED ST2 | UNITED ST3 | 1995 |  130436258 |\n| UNITED ST2 | UNITED ST9 | 1995 |  130110356 |\n| UNITED ST7 | UNITED ST6 | 1995 |  130041342 |\n| UNITED ST3 | UNITED ST1 | 1995 |  129525630 |\n| UNITED ST1 | UNITED ST1 | 1995 |  128398664 |\n| UNITED ST6 | UNITED ST9 | 1995 |  126914210 |\n| UNITED ST0 | UNITED ST9 | 1995 |  126506998 |\n| UNITED ST5 | UNITED ST9 | 1995 |  124729794 |\n| UNITED ST4 | UNITED ST5 | 1995 |  124163010 |\n| UNITED ST1 | UNITED ST7 | 1995 |  123031482 |\n| UNITED ST2 | UNITED ST7 | 1995 |  120000416 |\n| UNITED ST8 | UNITED ST6 | 1995 |  117980808 |\n| UNITED ST1 | UNITED ST4 | 1995 |  115071198 |\n| UNITED ST0 | UNITED ST3 | 1995 |  112721416 |\n| UNITED ST8 | UNITED ST0 | 1995 |  110463328 |\n| UNITED ST5 | UNITED ST7 | 1995 |  107481518 |\n| UNITED ST2 | UNITED ST0 | 1995 |  105121676 |\n| UNITED ST3 | UNITED ST7 | 1995 |  103159096 |\n| UNITED ST9 | UNITED ST0 | 1995 |  103097242 |\n| UNITED ST6 | UNITED ST6 | 1995 |  101909354 |\n| UNITED ST5 | UNITED ST5 | 1995 |  100788014 |\n| UNITED ST7 | UNITED ST4 | 1995 |   99799090 |\n| UNITED ST3 | UNITED ST3 | 1995 |   96316178 |\n| UNITED ST6 | UNITED ST4 | 1995 |   95394482 |\n| UNITED ST9 | UNITED ST7 | 1995 |   92929178 |\n| UNITED ST4 | UNITED ST0 | 1995 |   92285798 |\n| UNITED ST1 | UNITED ST3 | 1995 |   91646112 |\n| UNITED ST2 | UNITED ST1 | 1995 |   90874680 |\n| UNITED ST6 | UNITED ST5 | 1995 |   90856304 |\n| UNITED ST8 | UNITED ST5 | 1995 |   89989726 |\n| UNITED ST7 | UNITED ST3 | 1995 |   87399468 |\n| UNITED ST9 | UNITED ST6 | 1995 |   86964988 |\n| UNITED ST2 | UNITED ST5 | 1995 |   86764834 |\n| UNITED ST6 | UNITED ST8 | 1995 |   83947840 |\n| UNITED ST0 | UNITED ST6 | 1995 |   81437884 |\n| UNITED ST3 | UNITED ST5 | 1995 |   80115630 |\n| UNITED ST7 | UNITED ST5 | 1995 |   78030586 |\n| UNITED ST0 | UNITED ST0 | 1995 |   77969004 |\n| UNITED ST6 | UNITED ST1 | 1995 |   76656704 |\n| UNITED ST4 | UNITED ST6 | 1995 |   76219048 |\n| UNITED ST3 | UNITED ST9 | 1995 |   74729246 |\n| UNITED ST4 | UNITED ST3 | 1995 |   74712792 |\n| UNITED ST2 | UNITED ST6 | 1995 |   74292576 |\n| UNITED ST9 | UNITED ST5 | 1995 |   72019848 |\n| UNITED ST1 | UNITED ST8 | 1995 |   69837586 |\n| UNITED ST8 | UNITED ST1 | 1995 |   68435560 |\n| UNITED ST0 | UNITED ST7 | 1995 |   66790626 |\n| UNITED ST1 | UNITED ST5 | 1995 |   63714904 |\n| UNITED ST8 | UNITED ST7 | 1995 |   61836404 |\n| UNITED ST2 | UNITED ST8 | 1995 |   61008378 |\n| UNITED ST3 | UNITED ST4 | 1995 |   60844692 |\n| UNITED ST5 | UNITED ST6 | 1995 |   60409474 |\n| UNITED ST8 | UNITED ST3 | 1995 |   58699876 |\n| UNITED ST0 | UNITED ST4 | 1995 |   58340076 |\n| UNITED ST1 | UNITED ST6 | 1995 |   54278806 |\n| UNITED ST7 | UNITED ST8 | 1995 |   52888980 |\n| UNITED ST6 | UNITED ST7 | 1995 |   47667954 |\n| UNITED ST4 | UNITED ST8 | 1995 |   46106472 |\n| UNITED ST4 | UNITED ST2 | 1995 |   45574006 |\n| UNITED ST3 | UNITED ST8 | 1995 |   45010478 |\n| UNITED ST9 | UNITED ST8 | 1995 |   42585054 |\n| UNITED ST8 | UNITED ST4 | 1995 |   38574622 |\n| UNITED ST8 | UNITED ST2 | 1995 |   36565980 |\n| UNITED ST9 | UNITED ST3 | 1995 |   35078204 |\n| UNITED ST3 | UNITED ST6 | 1995 |   33477060 |\n| UNITED ST0 | UNITED ST8 | 1995 |   32786498 |\n| UNITED ST5 | UNITED ST2 | 1995 |   29902046 |\n| UNITED ST2 | UNITED ST2 | 1995 |   26910062 |\n| UNITED ST5 | UNITED ST8 | 1995 |   26693864 |\n| UNITED ST3 | UNITED ST2 | 1995 |   25773658 |\n| UNITED ST9 | UNITED ST2 | 1995 |   25306724 |\n| UNITED ST0 | UNITED ST5 | 1995 |   22907418 |\n| UNITED ST6 | UNITED ST2 | 1995 |   22727102 |\n| UNITED ST8 | UNITED ST8 | 1995 |   22571734 |\n| UNITED ST1 | UNITED ST2 | 1995 |   15983352 |\n| UNITED ST0 | UNITED ST2 | 1995 |    9552920 |\n| UNITED ST7 | UNITED ST2 | 1995 |    7947130 |\n| UNITED ST6 | UNITED ST0 | 1996 |  264573526 |\n| UNITED ST4 | UNITED ST0 | 1996 |  213795126 |\n| UNITED ST5 | UNITED ST0 | 1996 |  209003958 |\n| UNITED ST0 | UNITED ST4 | 1996 |  206457498 |\n| UNITED ST9 | UNITED ST1 | 1996 |  203967654 |\n| UNITED ST1 | UNITED ST0 | 1996 |  189723108 |\n| UNITED ST0 | UNITED ST1 | 1996 |  183897554 |\n| UNITED ST6 | UNITED ST1 | 1996 |  179411740 |\n| UNITED ST2 | UNITED ST1 | 1996 |  176512310 |\n| UNITED ST1 | UNITED ST1 | 1996 |  174531696 |\n| UNITED ST4 | UNITED ST7 | 1996 |  167355628 |\n| UNITED ST6 | UNITED ST3 | 1996 |  164336458 |\n| UNITED ST2 | UNITED ST7 | 1996 |  160936954 |\n| UNITED ST8 | UNITED ST1 | 1996 |  157943512 |\n| UNITED ST7 | UNITED ST4 | 1996 |  155882022 |\n| UNITED ST1 | UNITED ST3 | 1996 |  155221810 |\n| UNITED ST9 | UNITED ST9 | 1996 |  154603480 |\n| UNITED ST0 | UNITED ST9 | 1996 |  151870418 |\n| UNITED ST7 | UNITED ST0 | 1996 |  151204890 |\n| UNITED ST3 | UNITED ST1 | 1996 |  149493398 |\n| UNITED ST7 | UNITED ST7 | 1996 |  148081288 |\n| UNITED ST4 | UNITED ST1 | 1996 |  145639734 |\n| UNITED ST5 | UNITED ST9 | 1996 |  145228228 |\n| UNITED ST1 | UNITED ST9 | 1996 |  139647538 |\n| UNITED ST9 | UNITED ST4 | 1996 |  139233228 |\n| UNITED ST6 | UNITED ST4 | 1996 |  138592010 |\n| UNITED ST2 | UNITED ST0 | 1996 |  134190244 |\n| UNITED ST5 | UNITED ST1 | 1996 |  130692778 |\n| UNITED ST6 | UNITED ST9 | 1996 |  126512364 |\n| UNITED ST4 | UNITED ST6 | 1996 |  124378656 |\n| UNITED ST0 | UNITED ST0 | 1996 |  123057710 |\n| UNITED ST8 | UNITED ST9 | 1996 |  120933382 |\n| UNITED ST3 | UNITED ST0 | 1996 |  120453680 |\n| UNITED ST8 | UNITED ST6 | 1996 |  119493310 |\n| UNITED ST2 | UNITED ST3 | 1996 |  119297196 |\n| UNITED ST0 | UNITED ST5 | 1996 |  115525790 |\n| UNITED ST8 | UNITED ST7 | 1996 |  115047850 |\n| UNITED ST2 | UNITED ST4 | 1996 |  114974114 |\n| UNITED ST6 | UNITED ST7 | 1996 |  114181238 |\n| UNITED ST3 | UNITED ST4 | 1996 |  109676518 |\n| UNITED ST4 | UNITED ST9 | 1996 |  108269680 |\n| UNITED ST1 | UNITED ST6 | 1996 |  108112732 |\n| UNITED ST3 | UNITED ST7 | 1996 |  107974436 |\n| UNITED ST2 | UNITED ST9 | 1996 |  106982830 |\n| UNITED ST4 | UNITED ST8 | 1996 |  106071324 |\n| UNITED ST9 | UNITED ST5 | 1996 |  105651844 |\n| UNITED ST7 | UNITED ST3 | 1996 |  104713772 |\n| UNITED ST6 | UNITED ST8 | 1996 |  104273568 |\n| UNITED ST1 | UNITED ST5 | 1996 |  102379298 |\n| UNITED ST8 | UNITED ST4 | 1996 |  102066108 |\n| UNITED ST1 | UNITED ST4 | 1996 |  100271094 |\n| UNITED ST3 | UNITED ST9 | 1996 |   99224608 |\n| UNITED ST9 | UNITED ST0 | 1996 |   99181402 |\n| UNITED ST3 | UNITED ST3 | 1996 |   98527592 |\n| UNITED ST9 | UNITED ST7 | 1996 |   97597518 |\n| UNITED ST7 | UNITED ST1 | 1996 |   97568350 |\n| UNITED ST9 | UNITED ST6 | 1996 |   97370126 |\n| UNITED ST2 | UNITED ST5 | 1996 |   94057952 |\n| UNITED ST9 | UNITED ST3 | 1996 |   94042036 |\n| UNITED ST2 | UNITED ST8 | 1996 |   93730226 |\n| UNITED ST4 | UNITED ST3 | 1996 |   92921880 |\n| UNITED ST6 | UNITED ST5 | 1996 |   92060208 |\n| UNITED ST2 | UNITED ST6 | 1996 |   90833298 |\n| UNITED ST8 | UNITED ST5 | 1996 |   86960946 |\n| UNITED ST5 | UNITED ST5 | 1996 |   86041444 |\n| UNITED ST6 | UNITED ST6 | 1996 |   85846064 |\n| UNITED ST4 | UNITED ST5 | 1996 |   85616824 |\n| UNITED ST3 | UNITED ST6 | 1996 |   83763256 |\n| UNITED ST1 | UNITED ST7 | 1996 |   83443012 |\n| UNITED ST5 | UNITED ST7 | 1996 |   81892660 |\n| UNITED ST8 | UNITED ST0 | 1996 |   79690854 |\n| UNITED ST8 | UNITED ST3 | 1996 |   79071880 |\n| UNITED ST1 | UNITED ST8 | 1996 |   78861764 |\n| UNITED ST5 | UNITED ST6 | 1996 |   76664088 |\n| UNITED ST0 | UNITED ST6 | 1996 |   74464124 |\n| UNITED ST7 | UNITED ST6 | 1996 |   73071256 |\n| UNITED ST9 | UNITED ST8 | 1996 |   72224602 |\n| UNITED ST3 | UNITED ST8 | 1996 |   67849464 |\n| UNITED ST3 | UNITED ST5 | 1996 |   67434878 |\n| UNITED ST5 | UNITED ST4 | 1996 |   66849718 |\n| UNITED ST5 | UNITED ST3 | 1996 |   65839852 |\n| UNITED ST4 | UNITED ST4 | 1996 |   65575990 |\n| UNITED ST7 | UNITED ST5 | 1996 |   65568448 |\n| UNITED ST5 | UNITED ST8 | 1996 |   64831364 |\n| UNITED ST0 | UNITED ST7 | 1996 |   62782362 |\n| UNITED ST0 | UNITED ST3 | 1996 |   59591330 |\n| UNITED ST7 | UNITED ST9 | 1996 |   50056182 |\n| UNITED ST7 | UNITED ST8 | 1996 |   48697702 |\n| UNITED ST6 | UNITED ST2 | 1996 |   40895694 |\n| UNITED ST8 | UNITED ST8 | 1996 |   32681206 |\n| UNITED ST0 | UNITED ST8 | 1996 |   30336524 |\n| UNITED ST4 | UNITED ST2 | 1996 |   24903734 |\n| UNITED ST1 | UNITED ST2 | 1996 |   20165072 |\n| UNITED ST5 | UNITED ST2 | 1996 |   17088466 |\n| UNITED ST7 | UNITED ST2 | 1996 |   16780940 |\n| UNITED ST9 | UNITED ST2 | 1996 |   16216070 |\n| UNITED ST8 | UNITED ST2 | 1996 |   14056668 |\n| UNITED ST0 | UNITED ST2 | 1996 |   13814398 |\n| UNITED ST3 | UNITED ST2 | 1996 |    8623600 |\n| UNITED ST5 | UNITED ST0 | 1997 |  242915532 |\n| UNITED ST0 | UNITED ST9 | 1997 |  239712536 |\n| UNITED ST5 | UNITED ST1 | 1997 |  213800322 |\n| UNITED ST9 | UNITED ST9 | 1997 |  212445590 |\n| UNITED ST5 | UNITED ST4 | 1997 |  206865854 |\n| UNITED ST7 | UNITED ST1 | 1997 |  202653880 |\n| UNITED ST5 | UNITED ST9 | 1997 |  194785280 |\n| UNITED ST8 | UNITED ST0 | 1997 |  178869690 |\n| UNITED ST1 | UNITED ST3 | 1997 |  170351276 |\n| UNITED ST4 | UNITED ST1 | 1997 |  169222376 |\n| UNITED ST4 | UNITED ST7 | 1997 |  169213992 |\n| UNITED ST1 | UNITED ST4 | 1997 |  166185138 |\n| UNITED ST0 | UNITED ST1 | 1997 |  160334278 |\n| UNITED ST4 | UNITED ST9 | 1997 |  159395854 |\n| UNITED ST1 | UNITED ST0 | 1997 |  155335732 |\n| UNITED ST2 | UNITED ST0 | 1997 |  155182940 |\n| UNITED ST1 | UNITED ST7 | 1997 |  154091444 |\n| UNITED ST2 | UNITED ST7 | 1997 |  152967604 |\n| UNITED ST1 | UNITED ST1 | 1997 |  152680888 |\n| UNITED ST0 | UNITED ST7 | 1997 |  145154980 |\n| UNITED ST4 | UNITED ST0 | 1997 |  139751608 |\n| UNITED ST6 | UNITED ST3 | 1997 |  139451012 |\n| UNITED ST2 | UNITED ST9 | 1997 |  139087968 |\n| UNITED ST7 | UNITED ST0 | 1997 |  138708624 |\n| UNITED ST9 | UNITED ST7 | 1997 |  138105260 |\n| UNITED ST8 | UNITED ST3 | 1997 |  133836788 |\n| UNITED ST0 | UNITED ST0 | 1997 |  132617032 |\n| UNITED ST9 | UNITED ST0 | 1997 |  132133582 |\n| UNITED ST2 | UNITED ST3 | 1997 |  130858906 |\n| UNITED ST2 | UNITED ST1 | 1997 |  130792270 |\n| UNITED ST4 | UNITED ST4 | 1997 |  125064692 |\n| UNITED ST9 | UNITED ST1 | 1997 |  124836812 |\n| UNITED ST3 | UNITED ST7 | 1997 |  122190600 |\n| UNITED ST7 | UNITED ST4 | 1997 |  120246988 |\n| UNITED ST4 | UNITED ST3 | 1997 |  119268306 |\n| UNITED ST3 | UNITED ST4 | 1997 |  116712282 |\n| UNITED ST6 | UNITED ST9 | 1997 |  116462526 |\n| UNITED ST6 | UNITED ST4 | 1997 |  114430044 |\n| UNITED ST2 | UNITED ST4 | 1997 |  114025222 |\n| UNITED ST5 | UNITED ST3 | 1997 |  113579864 |\n| UNITED ST9 | UNITED ST5 | 1997 |  112183840 |\n| UNITED ST6 | UNITED ST0 | 1997 |  111649838 |\n| UNITED ST6 | UNITED ST1 | 1997 |  110235418 |\n| UNITED ST7 | UNITED ST9 | 1997 |  110079940 |\n| UNITED ST5 | UNITED ST7 | 1997 |  109068630 |\n| UNITED ST3 | UNITED ST1 | 1997 |  108301366 |\n| UNITED ST3 | UNITED ST0 | 1997 |  108100344 |\n| UNITED ST3 | UNITED ST9 | 1997 |  102740616 |\n| UNITED ST1 | UNITED ST5 | 1997 |  102104220 |\n| UNITED ST6 | UNITED ST7 | 1997 |   99591698 |\n| UNITED ST5 | UNITED ST6 | 1997 |   98060032 |\n| UNITED ST1 | UNITED ST9 | 1997 |   97888222 |\n| UNITED ST3 | UNITED ST3 | 1997 |   96770466 |\n| UNITED ST0 | UNITED ST5 | 1997 |   95976836 |\n| UNITED ST2 | UNITED ST8 | 1997 |   92783818 |\n| UNITED ST4 | UNITED ST6 | 1997 |   92473698 |\n| UNITED ST9 | UNITED ST3 | 1997 |   92243448 |\n| UNITED ST8 | UNITED ST9 | 1997 |   91705592 |\n| UNITED ST7 | UNITED ST8 | 1997 |   90952532 |\n| UNITED ST8 | UNITED ST1 | 1997 |   86568278 |\n| UNITED ST7 | UNITED ST7 | 1997 |   85133206 |\n| UNITED ST0 | UNITED ST4 | 1997 |   82387606 |\n| UNITED ST8 | UNITED ST7 | 1997 |   81756858 |\n| UNITED ST8 | UNITED ST8 | 1997 |   81498800 |\n| UNITED ST2 | UNITED ST5 | 1997 |   81325772 |\n| UNITED ST0 | UNITED ST3 | 1997 |   80157016 |\n| UNITED ST6 | UNITED ST8 | 1997 |   75976890 |\n| UNITED ST9 | UNITED ST6 | 1997 |   75193764 |\n| UNITED ST6 | UNITED ST5 | 1997 |   75143576 |\n| UNITED ST2 | UNITED ST2 | 1997 |   74068666 |\n| UNITED ST7 | UNITED ST5 | 1997 |   73779472 |\n| UNITED ST8 | UNITED ST4 | 1997 |   73201168 |\n| UNITED ST3 | UNITED ST6 | 1997 |   72151688 |\n| UNITED ST7 | UNITED ST3 | 1997 |   70337844 |\n| UNITED ST2 | UNITED ST6 | 1997 |   68548934 |\n| UNITED ST5 | UNITED ST8 | 1997 |   65821892 |\n| UNITED ST3 | UNITED ST5 | 1997 |   65623926 |\n| UNITED ST4 | UNITED ST8 | 1997 |   65199472 |\n| UNITED ST5 | UNITED ST5 | 1997 |   65137776 |\n| UNITED ST4 | UNITED ST5 | 1997 |   63991736 |\n| UNITED ST9 | UNITED ST4 | 1997 |   63530956 |\n| UNITED ST7 | UNITED ST2 | 1997 |   62819180 |\n| UNITED ST9 | UNITED ST8 | 1997 |   62544770 |\n| UNITED ST0 | UNITED ST8 | 1997 |   60482740 |\n| UNITED ST3 | UNITED ST8 | 1997 |   58204440 |\n| UNITED ST7 | UNITED ST6 | 1997 |   55079862 |\n| UNITED ST8 | UNITED ST5 | 1997 |   53347486 |\n| UNITED ST6 | UNITED ST6 | 1997 |   49966582 |\n| UNITED ST0 | UNITED ST2 | 1997 |   47168458 |\n| UNITED ST0 | UNITED ST6 | 1997 |   45848092 |\n| UNITED ST1 | UNITED ST2 | 1997 |   41198260 |\n| UNITED ST8 | UNITED ST6 | 1997 |   40146000 |\n| UNITED ST1 | UNITED ST6 | 1997 |   36410652 |\n| UNITED ST1 | UNITED ST8 | 1997 |   30750516 |\n| UNITED ST6 | UNITED ST2 | 1997 |   29493360 |\n| UNITED ST5 | UNITED ST2 | 1997 |   27726876 |\n| UNITED ST8 | UNITED ST2 | 1997 |   24107412 |\n| UNITED ST3 | UNITED ST2 | 1997 |   15783756 |\n| UNITED ST4 | UNITED ST2 | 1997 |    5696314 |\n| UNITED ST9 | UNITED ST2 | 1997 |    5323304 |\n+------------+------------+------+------------+\n\n-- Q3.3\n+------------+------------+------+------------+\n| c_city     | s_city     | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED KI1 | UNITED KI1 | 1992 |   93471990 |\n| UNITED KI5 | UNITED KI1 | 1992 |   72554110 |\n| UNITED KI5 | UNITED KI5 | 1992 |   50710534 |\n| UNITED KI1 | UNITED KI5 | 1992 |   43835692 |\n| UNITED KI5 | UNITED KI1 | 1993 |  122035214 |\n| UNITED KI1 | UNITED KI1 | 1993 |   91339070 |\n| UNITED KI5 | UNITED KI5 | 1993 |   68198784 |\n| UNITED KI1 | UNITED KI5 | 1993 |   42888412 |\n| UNITED KI5 | UNITED KI1 | 1994 |   72564326 |\n| UNITED KI1 | UNITED KI1 | 1994 |   69736882 |\n| UNITED KI5 | UNITED KI5 | 1994 |   69014568 |\n| UNITED KI1 | UNITED KI5 | 1994 |   42443560 |\n| UNITED KI5 | UNITED KI1 | 1995 |  165911792 |\n| UNITED KI1 | UNITED KI1 | 1995 |   71762372 |\n| UNITED KI5 | UNITED KI5 | 1995 |   41079610 |\n| UNITED KI1 | UNITED KI5 | 1995 |   34353020 |\n| UNITED KI5 | UNITED KI1 | 1996 |  131534098 |\n| UNITED KI1 | UNITED KI1 | 1996 |  119846074 |\n| UNITED KI5 | UNITED KI5 | 1996 |   92154684 |\n| UNITED KI1 | UNITED KI5 | 1996 |   27400508 |\n| UNITED KI1 | UNITED KI1 | 1997 |  140686266 |\n| UNITED KI5 | UNITED KI1 | 1997 |  129956718 |\n| UNITED KI5 | UNITED KI5 | 1997 |   54664054 |\n| UNITED KI1 | UNITED KI5 | 1997 |   32821336 |\n+------------+------------+------+------------+\n\n-- Q3.4\n+------------+------------+------+------------+\n| c_city     | s_city     | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED KI5 | UNITED KI1 | 1997 |   18235692 |\n| UNITED KI5 | UNITED KI5 | 1997 |   12407602 |\n| UNITED KI1 | UNITED KI5 | 1997 |    3740140 |\n+------------+------------+------+------------+\n\n-- Q4.1\n+------+---------------+-------------+\n| year | c_nation      | profit      |\n+------+---------------+-------------+\n| 1992 | ARGENTINA     | 19317928938 |\n| 1992 | BRAZIL        | 18453966110 |\n| 1992 | CANADA        | 19286353574 |\n| 1992 | PERU          | 18821353194 |\n| 1992 | UNITED STATES | 19698855306 |\n| 1993 | ARGENTINA     | 19952665706 |\n| 1993 | BRAZIL        | 18937598458 |\n| 1993 | CANADA        | 19794604840 |\n| 1993 | PERU          | 18618891672 |\n| 1993 | UNITED STATES | 20007970172 |\n| 1994 | ARGENTINA     | 19880610430 |\n| 1994 | BRAZIL        | 18697303354 |\n| 1994 | CANADA        | 19165295192 |\n| 1994 | PERU          | 18590530026 |\n| 1994 | UNITED STATES | 19039760850 |\n| 1995 | ARGENTINA     | 20287682760 |\n| 1995 | BRAZIL        | 18312154700 |\n| 1995 | CANADA        | 19125224320 |\n| 1995 | PERU          | 19556174422 |\n| 1995 | UNITED STATES | 18621130488 |\n| 1996 | ARGENTINA     | 20003855790 |\n| 1996 | BRAZIL        | 18336970302 |\n| 1996 | CANADA        | 20123208406 |\n| 1996 | PERU          | 18710271348 |\n| 1996 | UNITED STATES | 19539424348 |\n| 1997 | ARGENTINA     | 19709120522 |\n| 1997 | BRAZIL        | 18243142094 |\n| 1997 | CANADA        | 20194743556 |\n| 1997 | PERU          | 18631051834 |\n| 1997 | UNITED STATES | 21013447758 |\n| 1998 | ARGENTINA     | 11668480814 |\n| 1998 | BRAZIL        | 10712796190 |\n| 1998 | CANADA        | 10846422392 |\n| 1998 | PERU          | 11452371940 |\n| 1998 | UNITED STATES | 12018924038 |\n+------+---------------+-------------+\n\n-- Q4.2\n+------+---------------+------------+------------+\n| year | s_nation      | p_category | profit     |\n+------+---------------+------------+------------+\n| 1997 | ARGENTINA     | MFGR#11    | 1814143132 |\n| 1997 | ARGENTINA     | MFGR#12    | 1848231124 |\n| 1997 | ARGENTINA     | MFGR#13    | 1945723642 |\n| 1997 | ARGENTINA     | MFGR#14    | 1950820690 |\n| 1997 | ARGENTINA     | MFGR#15    | 1877734750 |\n| 1997 | ARGENTINA     | MFGR#21    | 2029565148 |\n| 1997 | ARGENTINA     | MFGR#22    | 1746033566 |\n| 1997 | ARGENTINA     | MFGR#23    | 2060714604 |\n| 1997 | ARGENTINA     | MFGR#24    | 1786921158 |\n| 1997 | ARGENTINA     | MFGR#25    | 2012622806 |\n| 1997 | BRAZIL        | MFGR#11    | 2146438656 |\n| 1997 | BRAZIL        | MFGR#12    | 1979717666 |\n| 1997 | BRAZIL        | MFGR#13    | 2256960758 |\n| 1997 | BRAZIL        | MFGR#14    | 2388513444 |\n| 1997 | BRAZIL        | MFGR#15    | 2188838248 |\n| 1997 | BRAZIL        | MFGR#21    | 1820053664 |\n| 1997 | BRAZIL        | MFGR#22    | 1986284096 |\n| 1997 | BRAZIL        | MFGR#23    | 2215345748 |\n| 1997 | BRAZIL        | MFGR#24    | 2116027298 |\n| 1997 | BRAZIL        | MFGR#25    | 1989467528 |\n| 1997 | CANADA        | MFGR#11    | 1709450040 |\n| 1997 | CANADA        | MFGR#12    | 1877436328 |\n| 1997 | CANADA        | MFGR#13    | 1918531780 |\n| 1997 | CANADA        | MFGR#14    | 2005624900 |\n| 1997 | CANADA        | MFGR#15    | 1696366026 |\n| 1997 | CANADA        | MFGR#21    | 1999610544 |\n| 1997 | CANADA        | MFGR#22    | 1556839526 |\n| 1997 | CANADA        | MFGR#23    | 1856719290 |\n| 1997 | CANADA        | MFGR#24    | 1699790256 |\n| 1997 | CANADA        | MFGR#25    | 1809175930 |\n| 1997 | PERU          | MFGR#11    | 2200485754 |\n| 1997 | PERU          | MFGR#12    | 1988730700 |\n| 1997 | PERU          | MFGR#13    | 1694972210 |\n| 1997 | PERU          | MFGR#14    | 1895539366 |\n| 1997 | PERU          | MFGR#15    | 1998791356 |\n| 1997 | PERU          | MFGR#21    | 1735846788 |\n| 1997 | PERU          | MFGR#22    | 1977494918 |\n| 1997 | PERU          | MFGR#23    | 2133290172 |\n| 1997 | PERU          | MFGR#24    | 1871331450 |\n| 1997 | PERU          | MFGR#25    | 1962908258 |\n| 1997 | UNITED STATES | MFGR#11    | 2093412096 |\n| 1997 | UNITED STATES | MFGR#12    | 1818427418 |\n| 1997 | UNITED STATES | MFGR#13    | 2192557812 |\n| 1997 | UNITED STATES | MFGR#14    | 1868564222 |\n| 1997 | UNITED STATES | MFGR#15    | 1925521686 |\n| 1997 | UNITED STATES | MFGR#21    | 2001352948 |\n| 1997 | UNITED STATES | MFGR#22    | 2153895230 |\n| 1997 | UNITED STATES | MFGR#23    | 1874576204 |\n| 1997 | UNITED STATES | MFGR#24    | 2006772726 |\n| 1997 | UNITED STATES | MFGR#25    | 2107332104 |\n| 1998 | ARGENTINA     | MFGR#11    | 1135224454 |\n| 1998 | ARGENTINA     | MFGR#12    | 1054050084 |\n| 1998 | ARGENTINA     | MFGR#13    | 1165583584 |\n| 1998 | ARGENTINA     | MFGR#14    | 1047452736 |\n| 1998 | ARGENTINA     | MFGR#15    | 1044156534 |\n| 1998 | ARGENTINA     | MFGR#21    | 1009425370 |\n| 1998 | ARGENTINA     | MFGR#22    | 1012123472 |\n| 1998 | ARGENTINA     | MFGR#23    | 1120959602 |\n| 1998 | ARGENTINA     | MFGR#24    | 1049158236 |\n| 1998 | ARGENTINA     | MFGR#25    | 1095680422 |\n| 1998 | BRAZIL        | MFGR#11    | 1277156976 |\n| 1998 | BRAZIL        | MFGR#12    | 1292625362 |\n| 1998 | BRAZIL        | MFGR#13    | 1310323544 |\n| 1998 | BRAZIL        | MFGR#14    | 1105352340 |\n| 1998 | BRAZIL        | MFGR#15    | 1327625418 |\n| 1998 | BRAZIL        | MFGR#21    | 1337644896 |\n| 1998 | BRAZIL        | MFGR#22    | 1183583836 |\n| 1998 | BRAZIL        | MFGR#23    | 1381297754 |\n| 1998 | BRAZIL        | MFGR#24    | 1124724440 |\n| 1998 | BRAZIL        | MFGR#25    | 1408364752 |\n| 1998 | CANADA        | MFGR#11    | 1018172250 |\n| 1998 | CANADA        | MFGR#12    |  976179544 |\n| 1998 | CANADA        | MFGR#13    |  973066594 |\n| 1998 | CANADA        | MFGR#14    | 1055674454 |\n| 1998 | CANADA        | MFGR#15    | 1071738598 |\n| 1998 | CANADA        | MFGR#21    |  911737302 |\n| 1998 | CANADA        | MFGR#22    | 1188554616 |\n| 1998 | CANADA        | MFGR#23    | 1148250140 |\n| 1998 | CANADA        | MFGR#24    | 1017060848 |\n| 1998 | CANADA        | MFGR#25    | 1095515984 |\n| 1998 | PERU          | MFGR#11    | 1135677094 |\n| 1998 | PERU          | MFGR#12    | 1081089514 |\n| 1998 | PERU          | MFGR#13    | 1182663766 |\n| 1998 | PERU          | MFGR#14    |  962670128 |\n| 1998 | PERU          | MFGR#15    | 1140492276 |\n| 1998 | PERU          | MFGR#21    | 1067466660 |\n| 1998 | PERU          | MFGR#22    | 1055581312 |\n| 1998 | PERU          | MFGR#23    | 1272786442 |\n| 1998 | PERU          | MFGR#24    | 1178150524 |\n| 1998 | PERU          | MFGR#25    | 1086502230 |\n| 1998 | UNITED STATES | MFGR#11    | 1112552464 |\n| 1998 | UNITED STATES | MFGR#12    | 1224771964 |\n| 1998 | UNITED STATES | MFGR#13    | 1244827854 |\n| 1998 | UNITED STATES | MFGR#14    | 1110013774 |\n| 1998 | UNITED STATES | MFGR#15    | 1050239138 |\n| 1998 | UNITED STATES | MFGR#21    | 1126813672 |\n| 1998 | UNITED STATES | MFGR#22    | 1160957470 |\n| 1998 | UNITED STATES | MFGR#23    | 1312160930 |\n| 1998 | UNITED STATES | MFGR#24    | 1076890116 |\n| 1998 | UNITED STATES | MFGR#25    | 1178223904 |\n+------+---------------+------------+------------+\n\n-- Q4.3\n+------+------------+-----------+---------------+\n| year | s_city     | p_brand   | profit        |\n+------+------------+-----------+---------------+\n| 1997 | UNITED ST1 | MFGR#1414 | 10001830.0000 |\n| 1997 | UNITED ST1 | MFGR#147  | 13643806.0000 |\n| 1997 | UNITED ST9 | MFGR#144  |  4953914.0000 |\n| 1998 | UNITED ST0 | MFGR#1424 | 14202690.0000 |\n| 1998 | UNITED ST5 | MFGR#1430 |  7742358.0000 |\n+------+------------+-----------+---------------+\n5 rows in set (0.25 sec)\n
      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/","title":"Complete a TPC-C Test with MatrixOne","text":"

      By walking through this tutorial, you'll learn how to complete a TPC-C Test with MatrixOne.

      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#tpc-c-overview","title":"TPC-C Overview","text":"

      TPC-C is an industry-standard benchmark for OLTP databases. TPC-C models a warehouse-centric order processing application, and the database used in the TPC-C benchmark consists of nine tables, such as Warehouse, Customer, Order, Item, and so on (See the below ER diagram). Except for the item table, each record is populated on a per-warehouse basis, and the number of warehouses can be configurable as a scale factor.

      TPC-C has five transaction types: NewOrder, Payment, OrderStatus, Delivery, and StockLevel. The request rate of each transaction is defined in the specification, and almost 90% of transactions are NewOrder and Payment, which are write-intensive. TPC-C transactions mostly access a single (local) warehouse, but about 10% of transactions interact with another (remote) warehouse.

      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#clone-mo-tpcc-repository","title":"Clone mo-tpcc repository","text":"
      git clone https://github.com/matrixorigin/mo-tpcc.git\n
      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#steps","title":"Steps","text":""},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#introduction","title":"Introduction","text":"

      This section will teach you how to generate the TPCC data, create TPCC tables, load data to MatrixOne, and run TPCC.

      Now you can execute commands step by step as the following descriptions.

      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#1-configure-the-propsmo-file","title":"1. Configure the props.mo file","text":"

      After the mo-tpch repository is cloned, open the mo-tpcc directory, and modify the configuration items of the props.mo file. The number of warehouses can be configurable by the warehouse=XX row in this file.

      db=mo\ndriver=com.mysql.cj.jdbc.Driver\nconn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\nuser=root\npassword=111\n\n//the number of warehouse\nwarehouses=10\nloadWorkers=4\n\n//the num of terminals that will simultaneously run\n//must be less than warehouses*10\nterminals=1\n//To run specified transactions per terminal- runMins must equal zero\nrunTxnsPerTerminal=0\n//To run for specified minutes- runTxnsPerTerminal must equal zero\nrunMins=1\n//Number of total transactions per minute\nlimitTxnsPerMin=0\n

      After the modifications are complete, save the props.mo file.

      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#2-create-tpcc-database-and-tables","title":"2. Create TPCC database and tables","text":"

      Open a new terminal window, execute the following command:

      cd mo-tpcc\n./runSQL.sh props.mo tableCreates\n

      Npte: If you get an error like java:command not found while running ./runSQL.sh props.mo tableCreates, install or reinstall Java and the JDK on your computer.

      The above code means to enter the mo-tpch directory and create the TPCC database and table.

      The following is an example of the command output:

      # ------------------------------------------------------------\n# Loading SQL file ./sql/tableCreates.sql\n# ------------------------------------------------------------\ndrop database if exists tpcc;\ncreate database if not exists tpcc;\nuse tpcc;\ncreate table bmsql_config (\ncfg_name    varchar(30) primary key,\ncfg_value   varchar(50)\n);\ncreate table bmsql_warehouse (\nw_id        integer   not null,\nw_ytd       decimal(12,2),\nw_tax       decimal(4,4),\nw_name      varchar(10),\nw_street_1  varchar(20),\nw_street_2  varchar(20),\nw_city      varchar(20),\nw_state     char(2),\nw_zip       char(9),\nprimary key (w_id)\n) PARTITION BY KEY(w_id);\ncreate table bmsql_district (\nd_w_id       integer       not null,\nd_id         integer       not null,\nd_ytd        decimal(12,2),\nd_tax        decimal(4,4),\nd_next_o_id  integer,\nd_name       varchar(10),\nd_street_1   varchar(20),\nd_street_2   varchar(20),\nd_city       varchar(20),\nd_state      char(2),\nd_zip        char(9),\nprimary key (d_w_id, d_id)\n) PARTITION BY KEY(d_w_id);\ncreate table bmsql_customer (\nc_w_id         integer        not null,\nc_d_id         integer        not null,\nc_id           integer        not null,\nc_discount     decimal(4,4),\nc_credit       char(2),\nc_last         varchar(16),\nc_first        varchar(16),\nc_credit_lim   decimal(12,2),\nc_balance      decimal(12,2),\nc_ytd_payment  decimal(12,2),\nc_payment_cnt  integer,\nc_delivery_cnt integer,\nc_street_1     varchar(20),\nc_street_2     varchar(20),\nc_city         varchar(20),\nc_state        char(2),\nc_zip          char(9),\nc_phone        char(16),\nc_since        timestamp,\nc_middle       char(2),\nc_data         varchar(500),\nprimary key (c_w_id, c_d_id, c_id)\n) PARTITION BY KEY(c_w_id);\ncreate table bmsql_history (\nhist_id  integer auto_increment,\nh_c_id   integer,\nh_c_d_id integer,\nh_c_w_id integer,\nh_d_id   integer,\nh_w_id   integer,\nh_date   timestamp,\nh_amount decimal(6,2),\nh_data   varchar(24),\nprimary key (hist_id)\n);\ncreate table bmsql_new_order (\nno_w_id  integer   not null,\nno_d_id  integer   not null,\nno_o_id  integer   not null,\nprimary key (no_w_id, no_d_id, no_o_id)\n) PARTITION BY KEY(no_w_id);\ncreate table bmsql_oorder (\no_w_id       integer      not null,\no_d_id       integer      not null,\no_id         integer      not null,\no_c_id       integer,\no_carrier_id integer,\no_ol_cnt     integer,\no_all_local  integer,\no_entry_d    timestamp,\nprimary key (o_w_id, o_d_id, o_id)\n) PARTITION BY KEY(o_w_id);\ncreate table bmsql_order_line (\nol_w_id         integer   not null,\nol_d_id         integer   not null,\nol_o_id         integer   not null,\nol_number       integer   not null,\nol_i_id         integer   not null,\nol_delivery_d   timestamp,\nol_amount       decimal(6,2),\nol_supply_w_id  integer,\nol_quantity     integer,\nol_dist_info    char(24),\nprimary key (ol_w_id, ol_d_id, ol_o_id, ol_number)\n) PARTITION BY KEY(ol_w_id);\ncreate table bmsql_item (\ni_id     integer      not null,\ni_name   varchar(24),\ni_price  decimal(5,2),\ni_data   varchar(50),\ni_im_id  integer,\nprimary key (i_id)\n) PARTITION BY KEY(i_id);\ncreate table bmsql_stock (\ns_w_id       integer       not null,\ns_i_id       integer       not null,\ns_quantity   integer,\ns_ytd        integer,\ns_order_cnt  integer,\ns_remote_cnt integer,\ns_data       varchar(50),\ns_dist_01    char(24),\ns_dist_02    char(24),\ns_dist_03    char(24),\ns_dist_04    char(24),\ns_dist_05    char(24),\ns_dist_06    char(24),\ns_dist_07    char(24),\ns_dist_08    char(24),\ns_dist_09    char(24),\ns_dist_10    char(24),\nprimary key (s_w_id, s_i_id)\n) PARTITION BY KEY(s_w_id);\n
      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#3-generate-tpcc-data","title":"3. Generate TPCC data","text":"

      To generate the TPCC data execute the following command:

      ./runLoader.sh props.mo filelocation /yourpath/\n

      The following is an example of the command output:

      Starting BenchmarkSQL LoadData\n\nprops.mo\ndriver=com.mysql.cj.jdbc.Driver\nconn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\nuser=root\npassword=***********\nwarehouses=10\nloadWorkers=4\nfileLocation (not defined)\ncsvNullValue (not defined - using default '')\n\nWorker 000: Loading ITEM\nWorker 001: Loading Warehouse      1\nWorker 002: Loading Warehouse      2\nWorker 003: Loading Warehouse      3\nWorker 000: Loading ITEM done\nWorker 000: Loading Warehouse      4\nWorker 003: Loading Warehouse      3 done\nWorker 003: Loading Warehouse      5\nWorker 001: Loading Warehouse      1 done\nWorker 001: Loading Warehouse      6\nWorker 002: Loading Warehouse      2 done\nWorker 002: Loading Warehouse      7\nWorker 000: Loading Warehouse      4 done\nWorker 000: Loading Warehouse      8\nWorker 003: Loading Warehouse      5 done\nWorker 003: Loading Warehouse      9\nWorker 000: Loading Warehouse      8 done\nWorker 000: Loading Warehouse     10\nWorker 002: Loading Warehouse      7 done\nWorker 001: Loading Warehouse      6 done\nWorker 000: Loading Warehouse     10 done\nWorker 003: Loading Warehouse      9 done\n

      You will find in your designated path 10 csv files. Each csv file maps to a table created in the second step.

      config.csv\ncust-hist.csv\ncustomer.csv\ndistrict.csv\nitem.csv\nnew-order.csv\norder-line.csv\norder.csv\nstock.csv\nwarehouse.csv\n
      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#4-load-tpcc-data-to-matrixone","title":"4. Load TPCC data to MatrixOne","text":"

      Use MySQL client to connect to MatrixOne and execute the following statements to load the csv files into MatrixOne.

      mysql> load data infile '/yourpath/config.csv' INTO TABLE bmsql_config FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/cust-hist.csv' INTO TABLE bmsql_history FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/customer.csv' INTO TABLE bmsql_customer FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/district.csv' INTO TABLE bmsql_district FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/warehouse.csv' INTO TABLE bmsql_warehouse FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/item.csv' INTO TABLE bmsql_item FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/new-order.csv' INTO TABLE bmsql_new_order FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/order-line.csv' INTO TABLE bmsql_order_line FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/stock.csv' INTO TABLE bmsql_stock FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/order.csv' INTO TABLE bmsql_oorder FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
      "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#5-run-tpcc-test","title":"5. Run TPCC test","text":"

      To run the TPCC test, execute the following command:

      ./runBenchmark.sh props.mo\n

      The following is an example of the command output:

      .:./lib/*\n2022-12-22 21:15:35 INFO  jTPCC:78 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:79 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO  jTPCC:80 - Term-00,      BenchmarkSQL v5.0\n2022-12-22 21:15:35 INFO  jTPCC:81 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO  jTPCC:82 - Term-00,  (c) 2003, Raul Barbosa\n2022-12-22 21:15:35 INFO  jTPCC:83 - Term-00,  (c) 2004-2016, Denis Lussier\n2022-12-22 21:15:35 INFO  jTPCC:84 - Term-00,  (c) 2016, Jan Wieck\n2022-12-22 21:15:35 INFO  jTPCC:85 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO  jTPCC:86 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, db=mo\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, driver=com.mysql.cj.jdbc.Driver\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, conn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, user=root\n2022-12-22 21:15:35 INFO  jTPCC:93 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, warehouses=10\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, terminals=1\n2022-12-22 21:15:35 INFO  jTPCC:100 - Term-00, runMins=1\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, limitTxnsPerMin=0\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, terminalWarehouseFixed=false\n2022-12-22 21:15:35 INFO  jTPCC:108 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, newOrderWeight=45\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, paymentWeight=43\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, orderStatusWeight=4\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, deliveryWeight=4\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, stockLevelWeight=4\n2022-12-22 21:15:35 INFO  jTPCC:115 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, osCollectorScript=null\n2022-12-22 21:15:35 INFO  jTPCC:119 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:710 - Term-00, Loading database driver: 'com.mysql.cj.jdbc.Driver'...\n2022-12-22 21:15:35 INFO  jTPCC:219 - Term-00, copied props.mo to my_result_2022-12-22_211535/run.properties\n2022-12-22 21:15:35 INFO  jTPCC:239 - Term-00, created my_result_2022-12-22_211535/data/runInfo.csv for runID 1\n2022-12-22 21:15:35 INFO  jTPCC:255 - Term-00, writing per transaction results to my_result_2022-12-22_211535/data/result.csv\n2022-12-22 21:15:35 INFO  jTPCC:268 - Term-00,\n2022-12-22 21:15:36 INFO  jTPCC:324 - Term-00, C value for C_LAST during load: 28\n2022-12-22 21:15:36 INFO  jTPCC:325 - Term-00, C value for C_LAST this run:    132\n2022-12-22 21:15:36 INFO  jTPCC:326 - Term-00,\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Session started!   Memory Usage: 17MB / 245MB          \n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Creating 1 terminal(s) with -1 transaction(s) per terminal...\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Terminal Warehouse is NOT fixed\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Transaction Weights: 45% New-Order, 43% Payment, 4% Order-Status, 4% Delivery, 4% Stock-Level\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Number of Terminals      1\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Creating database connection for Term-01...\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Term-01  7\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Transaction      Weight\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % New-Order      45\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % Payment        43\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % Order-Status   4\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % Delivery       4\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % Stock-Level    4\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Transaction Number       Terminal        Type    Execution Time (ms)             Comment\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Created 1 terminal(s) successfully!\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Starting all terminals...\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, All terminals started executing 2022-12-22 21:15:36\nTerm-00, Running Average tpmTOTAL: 60000.00    Current tpmTOTAL: 12    Memory Usage: 19MB / 245MB   2022-12-22 21:15:36 INFO  jTPCCTerminal:350 - Term-01, Executing for a limited time...\n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, The time limit has been reached.: 21MB / 245MB          \n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, Signalling all terminals to stop...\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01,\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, Terminal received stop signal!\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, Finishing current transaction before exit...\n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, Waiting for all active transactions to end...\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, OTAL: 24    Memory Usage: 22MB / 245MB          \n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, Closing statement and connection...\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01,\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, Terminal 'Term-01' finished after 0 transaction(s).\n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, All terminals finished executing 2022-12-22 21:16:42\n\n2022-12-22 21:16:42 INFO  jTPCC:694 - Term-00,\n2022-12-22 21:16:42 INFO  jTPCC:695 - Term-00,\n2022-12-22 21:16:42 INFO  jTPCC:696 - Term-00, Measured tpmC (NewOrders) = 2.74\n2022-12-22 21:16:42 INFO  jTPCC:697 - Term-00, Measured tpmTOTAL = 3.66\n2022-12-22 21:16:42 INFO  jTPCC:698 - Term-00, Measured tpmE (ErrorCount) = 0.0\n2022-12-22 21:16:42 INFO  jTPCC:699 - Term-00, Session Start     = 2022-12-22 21:15:36\n2022-12-22 21:16:42 INFO  jTPCC:700 - Term-00, Session End       = 2022-12-22 21:16:42\n2022-12-22 21:16:42 INFO  jTPCC:701 - Term-00, Transaction Count = 3\n2022-12-22 21:16:42 INFO  jTPCC:702 - Term-00, Transaction Error = 0\n2022-12-22 21:16:42 INFO  jTPCC:703 - Term-00, Transaction NewOrders = 3\n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, Session finished!\n

      The value of tpmC(transactions per minute) is given in the result.

      "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/","title":"Complete a TPCH Test with MatrixOne","text":"

      The TPC-H is a decision support benchmark. It consists of a suite of business oriented ad-hoc queries and concurrent data modifications. The queries and the data populating the database have been chosen to have broad industry-wide relevance. This benchmark illustrates decision support systems that examine large volumes of data, execute queries with a high degree of complexity, and give answers to critical business questions. TPC-H is a widely used benchmark for OLAP databases.

      By walking through this tutorial, you'll learn how to complete a TPC-H Test with MatrixOne.

      "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#1-compile-tpch-dbgen","title":"1. Compile TPCH dbgen","text":"

      The tpch dbgen utility generates, by default, a set of flat files suitable for loading into the tpch schema with the size based on the \"Scale Factor\" argument. A scale factor of 1 produces a complete data set of approximately 1 GB, a scale factor of 10 produces a data set of approximately 10 GB and so on.

      git clone https://github.com/electrum/tpch-dbgen.git\ncd tpch-dbgen\nmake\n
      "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#2-generate-data","title":"2. Generate data","text":"

      Run dbgen for the appropriate database size factor (1GB in the sample).

      ./dbgen -s 1\n

      Generation may take a while. When completed, you can see the resulting files.

      total 2150000\n-rw-r--r--  1 deister  staff   24346144 13 may 12:05 customer.tbl\n-rw-r--r--  1 deister  staff  759863287 13 may 12:05 lineitem.tbl\n-rw-r--r--  1 deister  staff       2224 13 may 12:05 nation.tbl\n-rw-r--r--  1 deister  staff  171952161 13 may 12:05 orders.tbl\n-rw-r--r--  1 deister  staff   24135125 13 may 12:05 part.tbl\n-rw-r--r--  1 deister  staff  118984616 13 may 12:05 partsupp.tbl\n-rw-r--r--  1 deister  staff        389 13 may 12:05 region.tbl\n-rw-r--r--  1 deister  staff    1409184 13 may 12:05 supplier.tbl\n

      We have also prepared a 1GB dataset for downloading. You can get the data files directly:

      https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
      "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#3-create-tables-in-matrixone","title":"3. Create tables in MatrixOne","text":"

      MatrixOne does not support partition acceleration at the moment, and the creation code of the LINEITEM table has the following modifications:

      • Removed PARTITION BY KEY() for LINEITEM table.
      drop database if exists TPCH;\ncreate database if not exists TPCH;\nuse TPCH;\nCREATE TABLE NATION(\nN_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY)\n);\n\nCREATE TABLE REGION(\nR_REGIONKEY  INTEGER NOT NULL,\nR_NAME       CHAR(25) NOT NULL,\nR_COMMENT    VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY)\n);\n\nCREATE TABLE PART(\nP_PARTKEY     INTEGER NOT NULL,\nP_NAME        VARCHAR(55) NOT NULL,\nP_MFGR        CHAR(25) NOT NULL,\nP_BRAND       CHAR(10) NOT NULL,\nP_TYPE        VARCHAR(25) NOT NULL,\nP_SIZE        INTEGER NOT NULL,\nP_CONTAINER   CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT     VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY)\n);\n\nCREATE TABLE SUPPLIER(\nS_SUPPKEY     INTEGER NOT NULL,\nS_NAME        CHAR(25) NOT NULL,\nS_ADDRESS     VARCHAR(40) NOT NULL,\nS_NATIONKEY   INTEGER NOT NULL,\nS_PHONE       CHAR(15) NOT NULL,\nS_ACCTBAL     DECIMAL(15,2) NOT NULL,\nS_COMMENT     VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY)\n);\n\nCREATE TABLE PARTSUPP (\nPS_PARTKEY    INTEGER NOT NULL,\nPS_SUPPKEY    INTEGER NOT NULL,\nPS_AVAILQTY   INTEGER NOT NULL,\nPS_SUPPLYCOST DECIMAL(15,2) NOT NULL,\nPS_COMMENT    VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY)\n);\n\nCREATE TABLE CUSTOMER(\nC_CUSTKEY     INTEGER NOT NULL,\nC_NAME        VARCHAR(25) NOT NULL,\nC_ADDRESS     VARCHAR(40) NOT NULL,\nC_NATIONKEY   INTEGER NOT NULL,\nC_PHONE       CHAR(15) NOT NULL,\nC_ACCTBAL     DECIMAL(15,2)   NOT NULL,\nC_MKTSEGMENT  CHAR(10) NOT NULL,\nC_COMMENT     VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY)\n);\n\nCREATE TABLE ORDERS(\nO_ORDERKEY       BIGINT NOT NULL,\nO_CUSTKEY        INTEGER NOT NULL,\nO_ORDERSTATUS    CHAR(1) NOT NULL,\nO_TOTALPRICE     DECIMAL(15,2) NOT NULL,\nO_ORDERDATE      DATE NOT NULL,\nO_ORDERPRIORITY  CHAR(15) NOT NULL,\nO_CLERK          CHAR(15) NOT NULL,\nO_SHIPPRIORITY   INTEGER NOT NULL,\nO_COMMENT        VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY)\n);\n\nCREATE TABLE LINEITEM (\nL_ORDERKEY BIGINT NOT NULL,\nL_PARTKEY INTEGER NOT NULL,\nL_SUPPKEY INTEGER NOT NULL,\nL_LINENUMBER INTEGER NOT NULL,\nL_QUANTITY DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,\nL_DISCOUNT DECIMAL(15,2) NOT NULL,\nL_TAX DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG CHAR(1) NOT NULL,\nL_LINESTATUS CHAR(1) NOT NULL,\nL_SHIPDATE DATE NOT NULL,\nL_COMMITDATE DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE CHAR(10) NOT NULL,\nL_COMMENT VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER)\n);\n
      "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#4-load-data-into-the-created-tables","title":"4. Load data into the created tables","text":"

      Load the sigle table dataset into related tables with this command in MatrixOne:

      load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n

      Then you can query data in MatrixOne with the created table.

      "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#5-run-tpch-queries","title":"5. Run TPCH Queries","text":"
      -- Q1\nselect\nl_returnflag,\nl_linestatus,\nsum(l_quantity) as sum_qty,\nsum(l_extendedprice) as sum_base_price,\nsum(l_extendedprice * (1 - l_discount)) as sum_disc_price,\nsum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,\navg(l_quantity) as avg_qty,\navg(l_extendedprice) as avg_price,\navg(l_discount) as avg_disc,\ncount(*) as count_order\nfrom\nlineitem\nwhere\nl_shipdate <= date '1998-12-01' - interval '112' day\ngroup by\nl_returnflag,\nl_linestatus\norder by\nl_returnflag,\nl_linestatus\n;\n\n-- Q2\nselect\ns_acctbal,\ns_name,\nn_name,\np_partkey,\np_mfgr,\ns_address,\ns_phone,\ns_comment\nfrom\npart,\nsupplier,\npartsupp,\nnation,\nregion\nwhere\np_partkey = ps_partkey\nand s_suppkey = ps_suppkey\nand p_size = 48\nand p_type like '%TIN'\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'MIDDLE EAST'\nand ps_supplycost = (\nselect\nmin(ps_supplycost)\nfrom\npartsupp,\nsupplier,\nnation,\nregion\nwhere\np_partkey = ps_partkey\nand s_suppkey = ps_suppkey\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'MIDDLE EAST'\n)\norder by\ns_acctbal desc,\nn_name,\ns_name,\np_partkey\nlimit 100\n;\n\n\n-- Q3\nselect\nl_orderkey,\nsum(l_extendedprice * (1 - l_discount)) as revenue,\no_orderdate,\no_shippriority\nfrom\ncustomer,\norders,\nlineitem\nwhere\nc_mktsegment = 'HOUSEHOLD'\nand c_custkey = o_custkey\nand l_orderkey = o_orderkey\nand o_orderdate < date '1995-03-29'\nand l_shipdate > date '1995-03-29'\ngroup by\nl_orderkey,\no_orderdate,\no_shippriority\norder by\nrevenue desc,\no_orderdate\nlimit 10\n;\n\n-- Q4\nselect\no_orderpriority,\ncount(*) as order_count\nfrom\norders\nwhere\no_orderdate >= date '1997-07-01'\nand o_orderdate < date '1997-07-01' + interval '3' month\nand exists (\nselect\n*\nfrom\nlineitem\nwhere\nl_orderkey = o_orderkey\nand l_commitdate < l_receiptdate\n)\ngroup by\no_orderpriority\norder by\no_orderpriority\n;\n\n\n-- Q5\nselect\nn_name,\nsum(l_extendedprice * (1 - l_discount)) as revenue\nfrom\ncustomer,\norders,\nlineitem,\nsupplier,\nnation,\nregion\nwhere\nc_custkey = o_custkey\nand l_orderkey = o_orderkey\nand l_suppkey = s_suppkey\nand c_nationkey = s_nationkey\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'AMERICA'\nand o_orderdate >= date '1994-01-01'\nand o_orderdate < date '1994-01-01' + interval '1' year\ngroup by\nn_name\norder by\nrevenue desc\n;\n\n\n-- Q6\nselect\nsum(l_extendedprice * l_discount) as revenue\nfrom\nlineitem\nwhere\nl_shipdate >= date '1994-01-01'\nand l_shipdate < date '1994-01-01' + interval '1' year\nand l_discount between 0.03 - 0.01 and 0.03 + 0.01\nand l_quantity < 24;\n\n-- Q7\nselect\nsupp_nation,\ncust_nation,\nl_year,\nsum(volume) as revenue\nfrom\n(\nselect\nn1.n_name as supp_nation,\nn2.n_name as cust_nation,\nextract(year from l_shipdate) as l_year,\nl_extendedprice * (1 - l_discount) as volume\nfrom\nsupplier,\nlineitem,\norders,\ncustomer,\nnation n1,\nnation n2\nwhere\ns_suppkey = l_suppkey\nand o_orderkey = l_orderkey\nand c_custkey = o_custkey\nand s_nationkey = n1.n_nationkey\nand c_nationkey = n2.n_nationkey\nand (\n(n1.n_name = 'FRANCE' and n2.n_name = 'ARGENTINA')\nor (n1.n_name = 'ARGENTINA' and n2.n_name = 'FRANCE')\n)\nand l_shipdate between date '1995-01-01' and date '1996-12-31'\n) as shipping\ngroup by\nsupp_nation,\ncust_nation,\nl_year\norder by\nsupp_nation,\ncust_nation,\nl_year\n;\n\n-- Q8\nselect\no_year,\n(sum(case\nwhen nation = 'ARGENTINA' then volume\nelse 0\nend) / sum(volume)) as mkt_share\nfrom\n(\nselect\nextract(year from o_orderdate) as o_year,\nl_extendedprice * (1 - l_discount) as volume,\nn2.n_name as nation\nfrom\npart,\nsupplier,\nlineitem,\norders,\ncustomer,\nnation n1,\nnation n2,\nregion\nwhere\np_partkey = l_partkey\nand s_suppkey = l_suppkey\nand l_orderkey = o_orderkey\nand o_custkey = c_custkey\nand c_nationkey = n1.n_nationkey\nand n1.n_regionkey = r_regionkey\nand r_name = 'AMERICA'\nand s_nationkey = n2.n_nationkey\nand o_orderdate between date '1995-01-01' and date '1996-12-31'\nand p_type = 'ECONOMY BURNISHED TIN'\n) as all_nations\ngroup by\no_year\norder by\no_year\n;\n\n-- Q9\nselect\nnation,\no_year,\nsum(amount) as sum_profit\nfrom\n(\nselect\nn_name as nation,\nextract(year from o_orderdate) as o_year,\nl_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount\nfrom\npart,\nsupplier,\nlineitem,\npartsupp,\norders,\nnation\nwhere\ns_suppkey = l_suppkey\nand ps_suppkey = l_suppkey\nand ps_partkey = l_partkey\nand p_partkey = l_partkey\nand o_orderkey = l_orderkey\nand s_nationkey = n_nationkey\nand p_name like '%pink%'\n) as profit\ngroup by\nnation,\no_year\norder by\nnation,\no_year desc\n;\n\n\n-- Q10\nselect\nc_custkey,\nc_name,\nsum(l_extendedprice * (1 - l_discount)) as revenue,\nc_acctbal,\nn_name,\nc_address,\nc_phone,\nc_comment\nfrom\ncustomer,\norders,\nlineitem,\nnation\nwhere\nc_custkey = o_custkey\nand l_orderkey = o_orderkey\nand o_orderdate >= date '1993-03-01'\nand o_orderdate < date '1993-03-01' + interval '3' month\nand l_returnflag = 'R'\nand c_nationkey = n_nationkey\ngroup by\nc_custkey,\nc_name,\nc_acctbal,\nc_phone,\nn_name,\nc_address,\nc_comment\norder by\nrevenue desc\nlimit 20\n;\n\n\n-- Q11\nselect\nps_partkey,\nsum(ps_supplycost * ps_availqty) as value\nfrom\npartsupp,\nsupplier,\nnation\nwhere\nps_suppkey = s_suppkey\nand s_nationkey = n_nationkey\nand n_name = 'JAPAN'\ngroup by\nps_partkey having\nsum(ps_supplycost * ps_availqty) > (\nselect\nsum(ps_supplycost * ps_availqty) * 0.0001000000\nfrom\npartsupp,\nsupplier,nation\nwhere\nps_suppkey = s_suppkey\nand s_nationkey = n_nationkey\nand n_name = 'JAPAN'\n)\norder by\nvalue desc\n;\n\n-- Q12\nselect\nl_shipmode,\nsum(case\nwhen o_orderpriority = '1-URGENT'\nor o_orderpriority = '2-HIGH'\nthen 1\nelse 0\nend) as high_line_count,\nsum(case\nwhen o_orderpriority <> '1-URGENT'\nand o_orderpriority <> '2-HIGH'\nthen 1\nelse 0\nend) as low_line_count\nfrom\norders,\nlineitem\nwhere\no_orderkey = l_orderkey\nand l_shipmode in ('FOB', 'TRUCK')\nand l_commitdate < l_receiptdate\nand l_shipdate < l_commitdate\nand l_receiptdate >= date '1996-01-01'\nand l_receiptdate < date '1996-01-01' + interval '1' year\ngroup by\nl_shipmode\norder by\nl_shipmode\n;\n\n-- Q13\nselect\nc_count,\ncount(*) as custdist\nfrom\n(\nselect\nc_custkey,\ncount(o_orderkey)\nfrom\ncustomer left outer join orders on\nc_custkey = o_custkey\nand o_comment not like '%pending%accounts%'\ngroup by\nc_custkey\n) as c_orders (c_custkey, c_count)\ngroup by\nc_count\norder by\ncustdist desc,\nc_count desc\n;\n\n-- Q14\nselect\n100.00 * sum(case\nwhen p_type like 'PROMO%'\nthen l_extendedprice * (1 - l_discount)\nelse 0\nend) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue\nfrom\nlineitem,\npart\nwhere\nl_partkey = p_partkey\nand l_shipdate >= date '1996-04-01'\nand l_shipdate < date '1996-04-01' + interval '1' month;\n\n-- Q15\nwith q15_revenue0 as (\nselect\nl_suppkey as supplier_no,\nsum(l_extendedprice * (1 - l_discount)) as total_revenue\nfrom\nlineitem\nwhere\nl_shipdate >= date '1995-12-01'\nand l_shipdate < date '1995-12-01' + interval '3' month\ngroup by\nl_suppkey\n)\nselect\ns_suppkey,\ns_name,\ns_address,\ns_phone,\ntotal_revenue\nfrom\nsupplier,\nq15_revenue0\nwhere\ns_suppkey = supplier_no\nand total_revenue = (\nselect\nmax(total_revenue)\nfrom\nq15_revenue0\n)\norder by\ns_suppkey\n;\n\n-- Q16\nselect\np_brand,\np_type,\np_size,\ncount(distinct ps_suppkey) as supplier_cnt\nfrom\npartsupp,\npart\nwhere\np_partkey = ps_partkey\nand p_brand <> 'Brand#35'\nand p_type not like 'ECONOMY BURNISHED%'\nand p_size in (14, 7, 21, 24, 35, 33, 2, 20)\nand ps_suppkey not in (\nselect\ns_suppkey\nfrom\nsupplier\nwhere\ns_comment like '%Customer%Complaints%'\n)\ngroup by\np_brand,\np_type,\np_size\norder by\nsupplier_cnt desc,\np_brand,\np_type,\np_size\n;\n\n-- Q17\nselect\nsum(l_extendedprice) / 7.0 as avg_yearly\nfrom\nlineitem,\npart\nwhere\np_partkey = l_partkey\nand p_brand = 'Brand#54'\nand p_container = 'LG BAG'\nand l_quantity < (\nselect\n0.2 * avg(l_quantity)\nfrom\nlineitem\nwhere\nl_partkey = p_partkey\n);\n\n-- Q18\nselect\nc_name,\nc_custkey,\no_orderkey,\no_orderdate,\no_totalprice,\nsum(l_quantity)\nfrom\ncustomer,\norders,\nlineitem\nwhere\no_orderkey in (\nselect\nl_orderkey\nfrom\nlineitem\ngroup by\nl_orderkey having\nsum(l_quantity) > 314\n)\nand c_custkey = o_custkey\nand o_orderkey = l_orderkey\ngroup by\nc_name,\nc_custkey,\no_orderkey,\no_orderdate,\no_totalprice\norder by\no_totalprice desc,\no_orderdate\nlimit 100\n;\n\n-- Q19\nselect\nsum(l_extendedprice* (1 - l_discount)) as revenue\nfrom\nlineitem,\npart\nwhere\n(\np_partkey = l_partkey\nand p_brand = 'Brand#23'\nand p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')\nand l_quantity >= 5 and l_quantity <= 5 + 10\nand p_size between 1 and 5\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n)\nor\n(\np_partkey = l_partkey\nand p_brand = 'Brand#15'\nand p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')\nand l_quantity >= 14 and l_quantity <= 14 + 10\nand p_size between 1 and 10\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n)\nor\n(\np_partkey = l_partkey\nand p_brand = 'Brand#44'\nand p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')\nand l_quantity >= 28 and l_quantity <= 28 + 10\nand p_size between 1 and 15\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n);\n\n-- Q20\nselect\ns_name,\ns_address\nfrom\nsupplier,\nnation\nwhere\ns_suppkey in (\nselect\nps_suppkey\nfrom\npartsupp\nwhere\nps_partkey in (\nselect\np_partkey\nfrom\npart\nwhere\np_name like 'lime%'\n)\nand ps_availqty > (\nselect\n0.5 * sum(l_quantity)\nfrom\nlineitem\nwhere\nl_partkey = ps_partkey\nand l_suppkey = ps_suppkey\nand l_shipdate >= date '1993-01-01'\nand l_shipdate < date '1993-01-01' + interval '1' year\n)\n)\nand s_nationkey = n_nationkey\nand n_name = 'VIETNAM'\norder by s_name\n;\n\n-- Q21\nselect\ns_name,\ncount(*) as numwait\nfrom\nsupplier,\nlineitem l1,\norders,\nnation\nwhere\ns_suppkey = l1.l_suppkey\nand o_orderkey = l1.l_orderkey\nand o_orderstatus = 'F'\nand l1.l_receiptdate > l1.l_commitdate\nand exists (\nselect\n*\nfrom\nlineitem l2\nwhere\nl2.l_orderkey = l1.l_orderkey\nand l2.l_suppkey <> l1.l_suppkey\n)\nand not exists (\nselect\n*\nfrom\nlineitem l3\nwhere\nl3.l_orderkey = l1.l_orderkey\nand l3.l_suppkey <> l1.l_suppkey\nand l3.l_receiptdate > l3.l_commitdate\n)\nand s_nationkey = n_nationkey\nand n_name = 'BRAZIL'\ngroup by\ns_name\norder by\nnumwait desc,\ns_name\nlimit 100\n;\n\n-- Q22\nselect\ncntrycode,\ncount(*) as numcust,\nsum(c_acctbal) as totacctbal\nfrom\n(\nselect\nsubstring(c_phone from 1 for 2) as cntrycode,\nc_acctbal\nfrom\ncustomer\nwhere\nsubstring(c_phone from 1 for 2) in\n('10', '11', '26', '22', '19', '20', '27')\nand c_acctbal > (\nselect\navg(c_acctbal)\nfrom\ncustomer\nwhere\nc_acctbal > 0.00\nand substring(c_phone from 1 for 2) in\n('10', '11', '26', '22', '19', '20', '27')\n)\nand not exists (\nselect\n*\nfrom\norders\nwhere\no_custkey = c_custkey\n)\n) as custsale\ngroup by\ncntrycode\norder by\ncntrycode\n;\n
      "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#6-expected-results","title":"6. Expected Results","text":"

      Below are the expected results for the 22 TPCH queries. Q16's result is too long to print, please refer to the complete result in this link:

      https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch1g_result_matrixone.md\n
      Q1\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+---------+-----------+----------+-------------+\n| l_returnflag | l_linestatus | sum_qty     | sum_base_price  | sum_disc_price    | sum_charge          | avg_qty | avg_price | avg_disc | count_order |\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+---------+-----------+----------+-------------+\n| A            | F            | 37734107.00 |  56586554400.73 |  53758257134.8700 |  55909065222.827692 |   25.52 |  38273.12 |     0.04 |     1478493 |\n| N            | F            |   991417.00 |   1487504710.38 |   1413082168.0541 |   1469649223.194375 |   25.51 |  38284.46 |     0.05 |       38854 |\n| N            | O            | 76633518.00 | 114935210409.19 | 109189591897.4720 | 113561024263.013782 |   25.50 |  38248.01 |     0.05 |     3004998 |\n| R            | F            | 37719753.00 |  56568041380.90 |  53741292684.6040 |  55889619119.831932 |   25.50 |  38250.85 |     0.05 |     1478870 |\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+---------+-----------+----------+-------------+\n4 rows in set\n\nQ2\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n| s_acctbal | s_name             | n_name       | p_partkey | p_mfgr         | s_address                                | s_phone         | s_comment                                                                                           |\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n|   9973.93 | Supplier#000004194 | JORDAN       |     14193 | Manufacturer#1 | A8AoX9AK,qhf,CpEF                        | 23-944-413-2681 | t fluffily. regular requests about the regular, unusual somas play of the furiously busy            |\n|   9956.34 | Supplier#000005108 | IRAN         |    140079 | Manufacturer#5 | d3PLCdpPP3uE4GzbbAh4bWmU 7ecOifL9e1mNnzG | 20-842-882-7047 | ronic accounts. carefully bold accounts sleep beyond                                                |\n|   9836.43 | Supplier#000000489 | IRAN         |    190488 | Manufacturer#2 | y9NMoYGxDUPfrB1GwjYhLtCeV7pOt            | 20-375-500-2226 | quickly carefully pending accounts. fina                                                            |\n|   9825.95 | Supplier#000007554 | IRAQ         |     40041 | Manufacturer#5 | Huq0k qKET hByp3RcMcr                    | 21-787-637-9651 | ending, final requests thrash pending,                                                              |\n|   9806.52 | Supplier#000005276 | IRAQ         |    132762 | Manufacturer#2 | inh0KOhRfLM7WRhdRNvJJDQx                 | 21-834-496-7360 | the slyly unusual theodolites; carefully even accounts use slyly. sl                                |\n|   9796.31 | Supplier#000005847 | IRAQ         |    188292 | Manufacturer#1 | obol3bfh0zWi                             | 21-530-950-2847 | equests. blithely regular deposits should have to impress. final platelets integrate fluffily       |\n|   9775.37 | Supplier#000007245 | IRAQ         |    169696 | Manufacturer#5 | 5VOUnvxlJeOJ                             | 21-663-724-2985 | ic deposits about the slyly bold requests                                                           |\n|   9755.43 | Supplier#000002439 | EGYPT        |    172438 | Manufacturer#5 | rXxojWV0VefSK7A0dhF                      | 14-410-168-5354 | p quickly packages. carefully pending pinto beans after the                                         |\n|   9714.60 | Supplier#000007317 | EGYPT        |     29810 | Manufacturer#4 | nJGsPl2ruoq4Ydtv0fwWG385eOFV6  VUokbCZ   | 14-666-351-2592 | ons integrate furiously? slyly ironic requests sl                                                   |\n|   9557.33 | Supplier#000007367 | EGYPT        |    197366 | Manufacturer#3 | bTP8DLvaRAB0n                            | 14-234-934-5255 | ep slyly regular accounts-- regular, regular excuses dazzle furiously about the reg                 |\n|   9538.15 | Supplier#000000979 | IRAN         |     55968 | Manufacturer#1 | cdvHjrKZR7iDlmSWU2a                      | 20-151-688-1408 | ckages cajole quietly carefully regular in                                                          |\n|   9513.31 | Supplier#000004163 | SAUDI ARABIA |    109142 | Manufacturer#4 | 2VnQypC7pJPJRu6HzYRg7nAvhzckcYAQFbI      | 30-544-852-3772 | he regular requests. blithely final                                                                 |\n|   9450.15 | Supplier#000002067 | EGYPT        |      9566 | Manufacturer#3 | 9dO68x0XLMCUDuFk1J6k9hpvLoKx 4qasok4lIb  | 14-252-246-5791 | rding to the regular dolphins. quickly ir                                                           |\n|   9359.59 | Supplier#000005087 | JORDAN       |     55086 | Manufacturer#4 | q0c6r9wYVQx31IeGBZKfe                    | 23-335-392-5204 | osits. quickly regular packages haggle among the quickly silent ins                                 |\n|   9343.35 | Supplier#000006337 | IRAN         |    173819 | Manufacturer#1 | ilQgNOdCAysclt3SgODb6LeJ7d4RzYD          | 20-950-345-8173 | quickly ironic packages affix aft                                                                   |\n|   9318.47 | Supplier#000003834 | SAUDI ARABIA |     11332 | Manufacturer#5 | cxGQnW3nShks59xA5bPoaC bIvcBWUt          | 30-823-353-6520 | regular instructions. express packages run slyly pending                                            |\n|   9318.47 | Supplier#000003834 | SAUDI ARABIA |    108813 | Manufacturer#2 | cxGQnW3nShks59xA5bPoaC bIvcBWUt          | 30-823-353-6520 | regular instructions. express packages run slyly pending                                            |\n|   9315.33 | Supplier#000003009 | IRAN         |     40504 | Manufacturer#2 | oTbwfQ,Yfdcf3ysgc60NKtTpSIc              | 20-306-556-2450 | the carefully special requests. express instructions wake                                           |\n|   9296.31 | Supplier#000008213 | JORDAN       |    163180 | Manufacturer#2 | YhdN9ESxYvhJp9ngr12Bbeo4t3zLPD,          | 23-197-507-9431 | g to the blithely regular accounts! deposit                                                         |\n|   9284.57 | Supplier#000009781 | EGYPT        |      4780 | Manufacturer#4 | 49NAd1iDiY4,                             | 14-410-636-4312 | its. ironic pinto beans are blithely. express depths use caref                                      |\n|   9261.13 | Supplier#000000664 | EGYPT        |    125639 | Manufacturer#5 | ln6wISAnC8Bpj q4V                        | 14-244-772-4913 | ly special foxes cajole slyly ironic reque                                                          |\n|   9260.78 | Supplier#000001949 | IRAN         |     86932 | Manufacturer#2 | W79M2lpYiSY76Ujo6fSRUQiu                 | 20-531-767-2819 | thinly ironic excuses haggle slyly. f                                                               |\n|   9227.16 | Supplier#000009461 | EGYPT        |    126948 | Manufacturer#2 | Eweba 0sfaF,l4sAxXGTgEjzsJsNWWIGjYhFkRWV | 14-983-137-4957 | lly bold packages. carefully express deposits integrate about the unusual accounts. regular,        |\n|   9185.89 | Supplier#000007888 | EGYPT        |     27887 | Manufacturer#1 | nq06Y48amPfS8YBuduy1RYu                  | 14-462-704-3828 | ole slyly-- blithely careful foxes wake against the furiously ironic accounts. pending ideas        |\n|   9185.89 | Supplier#000007888 | EGYPT        |    190330 | Manufacturer#4 | nq06Y48amPfS8YBuduy1RYu                  | 14-462-704-3828 | ole slyly-- blithely careful foxes wake against the furiously ironic accounts. pending ideas        |\n|   9132.92 | Supplier#000007878 | IRAN         |     92859 | Manufacturer#3 | aq6T3tUVq1,                              | 20-861-274-6282 | waters cajole ironic, ironic requests. furi                                                         |\n|   9058.94 | Supplier#000002789 | IRAN         |    142788 | Manufacturer#4 | 7EkIldjP7M6psSWcJ11tf65GT7ZC7UaiCh       | 20-842-716-4307 | s. platelets use carefully. busily regular accounts cajole fluffily above the slowly final pinto be |\n|   9026.80 | Supplier#000005436 | SAUDI ARABIA |     92926 | Manufacturer#3 | 3HiusYZGYmHItExgX5VfNCdJwkW8W7R          | 30-453-280-6340 | . blithely unusual requests                                                                         |\n|   9007.16 | Supplier#000001747 | EGYPT        |    121746 | Manufacturer#3 | UyDlFjVxanP,ifej7L5jtNaubC               | 14-141-360-9722 | maintain bravely across the busily express pinto beans. sometimes                                   |\n|   8846.35 | Supplier#000005446 | EGYPT        |     57930 | Manufacturer#2 | Nusoq0ckv9SwnJZV8Rw2dUqE,V0ylm Bon       | 14-468-853-6477 | deposits. ironic, bold ideas wake. fluffily ironic deposits must have to sleep furiously pending    |\n|   8837.21 | Supplier#000007210 | JORDAN       |    144695 | Manufacturer#3 | G7MYkWkkJDVu,rr23aXjQCwNqZ2Vk6           | 23-560-295-1805 | en, express foxes use across the blithely bold                                                      |\n|   8800.91 | Supplier#000008182 | EGYPT        |    143153 | Manufacturer#5 | KGMyipBiAF00tSB99DwH                     | 14-658-338-3635 | thely even excuses integrate blithel                                                                |\n|   8788.46 | Supplier#000003437 | IRAN         |    118414 | Manufacturer#4 | JfgZDO9fsP4ljfzsi,s7431Ld3A7zXtHfrF74    | 20-547-871-1712 | ickly unusual dependencies. carefully regular dolphins ha                                           |\n|   8750.12 | Supplier#000001064 | IRAQ         |     31063 | Manufacturer#5 | QgmUIaEs5KpuW ,oREZV2b4wr3HEC1z4F        | 21-440-809-7599 | sly even deposits? furiously regular pack                                                           |\n|   8594.80 | Supplier#000007553 | IRAN         |      5052 | Manufacturer#4 | wAU2Lui w9                               | 20-663-409-7956 | old, stealthy accounts are blithely. fluffily final                                                 |\n|   8594.80 | Supplier#000007553 | IRAN         |    195033 | Manufacturer#1 | wAU2Lui w9                               | 20-663-409-7956 | old, stealthy accounts are blithely. fluffily final                                                 |\n|   8588.63 | Supplier#000008094 | SAUDI ARABIA |    148093 | Manufacturer#1 | SNS6FCscBNZBFecA                         | 30-465-665-6735 | ake quickly blithely ironic theodolites. quickly ironic ideas boost. furiously iro                  |\n|   8522.70 | Supplier#000004208 | IRAQ         |    166659 | Manufacturer#5 | x3jZYF7ZYN 8a4LY1c1kEsh                  | 21-468-998-1571 | furiously regular accounts!                                                                         |\n|   8514.86 | Supplier#000006347 | JORDAN       |    181310 | Manufacturer#5 | wwR5j4kdIAwLe33uBwo                      | 23-340-942-3641 | uests breach blithely ironic deposi                                                                 |\n|   8473.01 | Supplier#000003912 | IRAQ         |     33911 | Manufacturer#3 | Op7,1zt3MAxs34Qo4O W                     | 21-474-809-6508 | es. regular, brave instructions wa                                                                  |\n|   8405.28 | Supplier#000007886 | IRAQ         |    192847 | Manufacturer#4 | sFTj5nzc5EIVmzjXwenFTXD U                | 21-735-778-5786 | ven dependencies boost blithely ironic de                                                           |\n|   8375.58 | Supplier#000001259 | IRAQ         |     38755 | Manufacturer#2 | 32cJBGFFpGEkEjx1sF8JZAy0A72uXL5qU        | 21-427-422-4993 | ironic accounts haggle slyly alongside of the carefully ironic deposit                              |\n|   8351.75 | Supplier#000007495 | IRAQ         |    114983 | Manufacturer#4 | 3jQQGvfs,5Aryhn0Z                        | 21-953-463-7239 | requests. carefully final accounts after the qui                                                    |\n|   8230.12 | Supplier#000001058 | SAUDI ARABIA |     68551 | Manufacturer#2 | fJ8egP,xkLygXGv8bmtc9T1FJ                | 30-496-504-3341 | requests haggle? regular, regular pinto beans integrate fluffily. dependenc                         |\n|   8195.44 | Supplier#000009805 | IRAQ         |      4804 | Manufacturer#4 | dTTmLRYJNat,JbhlQlxwWp HjMR              | 21-838-243-3925 | lets. quickly even theodolites dazzle slyly even a                                                  |\n|   8175.17 | Supplier#000003172 | IRAN         |     55656 | Manufacturer#5 | 8ngbGS7BQoTDmJyMa5WV9XbaM31u5FAayd2vT3   | 20-834-374-7746 | ss deposits use furiously after the quickly final sentiments. fluffily ruthless ideas believe regu  |\n|   8159.13 | Supplier#000007486 | EGYPT        |     17485 | Manufacturer#1 | AjfdzbrrJE1                              | 14-970-643-1521 | ld accounts. enticingly furious requests cajole. final packages s                                   |\n|   8111.40 | Supplier#000007567 | IRAN         |    197566 | Manufacturer#1 | 7W4k2qEVoBkRehprGliXRSYVOQEh             | 20-377-181-7435 | gular foxes. silent attainments boost furiousl                                                      |\n|   8046.55 | Supplier#000001625 | IRAQ         |     14121 | Manufacturer#2 | yKlKMbENR6bfmIu7aCFmbs                   | 21-769-404-7617 | deposits. ideas boost blithely. slyly even Tiresias according to the platelets are q                |\n|   8040.16 | Supplier#000001925 | SAUDI ARABIA |      4424 | Manufacturer#4 | Cu5Ub AAdXT                              | 30-969-417-1108 | pending packages across the regular req                                                             |\n|   8031.68 | Supplier#000002370 | SAUDI ARABIA |    147341 | Manufacturer#5 | xGQB9xSPqRtCuMZaJavOrFuTY7km             | 30-373-388-2352 | dependencies. carefully express deposits use slyly among the slyly unusual pearls. dogge            |\n|   8031.42 | Supplier#000008216 | IRAN         |     83199 | Manufacturer#2 | jsqlyr1ViAo                              | 20-224-305-7298 | to the carefully even excuses haggle blithely against the pending pinto be                          |\n|   8007.83 | Supplier#000006266 | JORDAN       |     81249 | Manufacturer#1 | XWBf5Jd2V5SOurbn11Tt1                    | 23-363-445-7184 | as cajole carefully against the quickly special ac                                                  |\n|   7995.78 | Supplier#000006957 | IRAN         |    161924 | Manufacturer#1 | 8lvRhU5xtXv                              | 20-312-173-2216 | ly ironic accounts. stealthily regular foxes about the blithely ironic requests play blithely abo   |\n|   7913.40 | Supplier#000003148 | JORDAN       |     58137 | Manufacturer#1 | CpCJWI4PHeiwYuq0                         | 23-767-770-9172 | ove the quickly final packages boost fluffily among the furiously final platelets. carefully s      |\n|   7910.16 | Supplier#000002102 | IRAQ         |     99592 | Manufacturer#2 | 1kuyUn5q6czLOGB60fAVgpv68M2suwchpmp2nK   | 21-367-198-9930 | accounts after the blithely                                                                         |\n|   7893.58 | Supplier#000000918 | SAUDI ARABIA |     13414 | Manufacturer#1 | e0sB7xAU3,cWF7pzXrpIbATUNydCUZup         | 30-303-831-1662 | ependencies wake carefull                                                                           |\n|   7885.17 | Supplier#000004001 | JORDAN       |     38994 | Manufacturer#2 | 3M39sZY1XeQXPDRO                         | 23-109-632-6806 | efully express packages integrate across the regular pearls. blithely unusual packages mainta       |\n|   7880.20 | Supplier#000005352 | JORDAN       |       351 | Manufacturer#3 | PP9gHTn946hXqUF5E7idIPLkhnN              | 23-557-756-7951 | egular frays. final instructions sleep a                                                            |\n|   7844.31 | Supplier#000006987 | IRAQ         |     44482 | Manufacturer#5 | UH1zBxTNjTminnmHRe h YUT1eR              | 21-963-444-7397 | nag quickly carefully regular requests. ironic theo                                                 |\n|   7812.27 | Supplier#000006967 | SAUDI ARABIA |    151936 | Manufacturer#4 | S4i1HfrSM4m3di3R9Cxxp59M1                | 30-193-457-6365 | ely. dependencies cajole quickly. final warhorses across the furiously ironic foxes integr          |\n|   7767.63 | Supplier#000004306 | IRAN         |     31802 | Manufacturer#2 | SkZkJZflW5mDg9wL fJ                      | 20-911-180-1895 | uickly regular ideas. blithely express accounts along the carefully sile                            |\n|   7741.42 | Supplier#000000899 | IRAQ         |     53383 | Manufacturer#5 | oLlkiVghtro IwzcwFuzwMCG94rRpux          | 21-980-994-3905 | equests wake quickly special, express accounts. courts promi                                        |\n|   7741.42 | Supplier#000000899 | IRAQ         |    105878 | Manufacturer#3 | oLlkiVghtro IwzcwFuzwMCG94rRpux          | 21-980-994-3905 | equests wake quickly special, express accounts. courts promi                                        |\n|   7741.10 | Supplier#000001059 | IRAN         |    103528 | Manufacturer#4 | 4tBenOMokWbWVRB8i8HwENeO cQjM9           | 20-620-710-8984 | to the carefully special courts.                                                                    |\n|   7599.20 | Supplier#000006596 | SAUDI ARABIA |    184077 | Manufacturer#2 | k8qeFxfXKIGYdQ82RXAfCwddSrc              | 30-804-947-3851 | ously unusual deposits boost carefully after the enticing                                           |\n|   7598.31 | Supplier#000008857 | IRAQ         |     63844 | Manufacturer#4 | dP2th8vneyOLIUFwNBwqixkFD6               | 21-691-170-4769 | s. quickly ironic frays detect carefully                                                            |\n|   7591.79 | Supplier#000009723 | JORDAN       |    104702 | Manufacturer#2 | Q1CkkpDdlLOpCJiV,zIf,Mv86otWhxj7slGc     | 23-710-907-3873 | e fluffily even instructions. packages impress enticingly.                                          |\n|   7575.12 | Supplier#000007557 | IRAQ         |     77556 | Manufacturer#1 | udLvpjNvIx9qeRNdjL1ZAO0OZNOBo6h          | 21-629-935-9941 | ally special accounts nod; f                                                                        |\n|   7496.91 | Supplier#000005828 | IRAN         |    103317 | Manufacturer#1 | Xt0EqDCNU6X00sNsIO7nd0ws3H               | 20-435-850-8703 | furiously about the fluffily careful idea                                                           |\n|   7472.88 | Supplier#000004204 | EGYPT        |     14203 | Manufacturer#1 | 0rGZJ6VZXdH                              | 14-520-667-4690 | y pending pinto beans. even, final requests sleep care                                              |\n|   7472.88 | Supplier#000004204 | EGYPT        |    161687 | Manufacturer#3 | 0rGZJ6VZXdH                              | 14-520-667-4690 | y pending pinto beans. even, final requests sleep care                                              |\n|   7467.63 | Supplier#000003270 | IRAN         |     45757 | Manufacturer#2 | 7j4n5FnNEHVJxFhiyz                       | 20-450-599-9591 | regular, even instructions boost deposits                                                           |\n|   7465.41 | Supplier#000008686 | EGYPT        |    188685 | Manufacturer#4 | 4Onf4yxuNwHCRIC0y                        | 14-454-946-4151 | ly final ideas. bravely unusual deposits doze carefully. expr                                       |\n|   7460.80 | Supplier#000008701 | IRAQ         |     83684 | Manufacturer#3 | PLR2QehcW08                              | 21-747-984-4244 | ideas use carefully pending, final deposits. ironic, pe                                             |\n|   7447.86 | Supplier#000005877 | JORDAN       |    120852 | Manufacturer#2 | EyqOHClZZMJkq grnOX9 4alZx6P7B2fq        | 23-419-288-6451 | lar pinto beans breach carefully final pinto                                                        |\n|   7445.03 | Supplier#000009802 | IRAQ         |    164769 | Manufacturer#5 | y6wLN KiZuTf5HT9Hbm0BELn1GUTD6yl         | 21-116-708-2013 | nic requests. pinto beans across the carefully regular grouches snooze among the final pin          |\n|   7401.46 | Supplier#000008677 | IRAN         |    123652 | Manufacturer#5 | WNa780JZzivxuGBEsDszqoT1Pj               | 20-899-256-5288 | onic instructions along the furiously ironic accounts haggle fluffily silently un                   |\n|   7393.50 | Supplier#000007056 | IRAQ         |     54550 | Manufacturer#1 | M5cAJQvW9D5zwC7o2qkoe                    | 21-175-383-4727 | slyly even requests. forges haggle boldly express requests. furio                                   |\n|   7376.11 | Supplier#000003982 | IRAQ         |    118959 | Manufacturer#1 | jx9EloF33Ez                              | 21-890-236-4160 | s the furiously special warhorses affix after the car                                               |\n|   7264.42 | Supplier#000001565 | IRAQ         |     14061 | Manufacturer#4 | bOwKHdBteMkZoZcxdigk4Tnu07w1gDztmV7hvCw  | 21-791-273-8592 | to beans. express accounts nag around the                                                           |\n|   7256.46 | Supplier#000009116 | IRAQ         |      4115 | Manufacturer#3 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt       | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci                                   |\n|   7256.46 | Supplier#000009116 | IRAQ         |     99115 | Manufacturer#1 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt       | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci                                   |\n|   7256.46 | Supplier#000009116 | IRAQ         |    131576 | Manufacturer#4 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt       | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci                                   |\n|   7254.81 | Supplier#000005664 | EGYPT        |     35663 | Manufacturer#2 | b8VWuTXRt66wF9bfrgTmNGuxf1PU0x3O9e       | 14-214-171-8987 | ts across the quickly pending pin                                                                   |\n|   7186.63 | Supplier#000006958 | IRAN         |     71943 | Manufacturer#4 | 0n9BD,gRzUc3B,PsFcxDBGp4BFf4P            | 20-185-413-5590 | against the instructions. requests are. speci                                                       |\n|   7166.36 | Supplier#000003541 | EGYPT        |    116007 | Manufacturer#1 | DbwyOxoaMEdhEtIB3y045QrKCi2fQpGRu,       | 14-508-763-1850 | ages. carefully unusual requests across the pending instructions aff                                |\n|   7128.81 | Supplier#000000677 | JORDAN       |     50676 | Manufacturer#4 | 8mhrffG7D2WJBSQbOGstQ                    | 23-290-639-3315 | nder blithely. slyly unusual theod                                                                  |\n|   7051.73 | Supplier#000003349 | IRAQ         |    125812 | Manufacturer#3 | wtTK9df9kY7mQ5QUM0Xe5bHLMRLgwE           | 21-614-525-7451 | ar theodolites cajole fluffily across the pending requests. slyly final requests a                  |\n|   7023.47 | Supplier#000009543 | SAUDI ARABIA |     47038 | Manufacturer#1 | VYKinyOBNXRr Hdqn8kOxfTw                 | 30-785-782-6088 | sts. furiously pending packages sleep slyly even requests. final excuses print deposits. final pac  |\n|   6985.93 | Supplier#000006409 | IRAQ         |    131382 | Manufacturer#1 | eO8JDNM19HrlQMR                          | 21-627-356-3992 | sts. slyly final deposits around the regular accounts are along the furiously final pac             |\n|   6964.75 | Supplier#000009931 | EGYPT        |     57425 | Manufacturer#1 | peQYiRFk G0xZKfJ                         | 14-989-166-5782 | deposits according to the sometimes silent requests wake along the packages-- blithely f            |\n|   6964.04 | Supplier#000007399 | IRAQ         |     77398 | Manufacturer#2 | zdxjENOGR4QiCFP                          | 21-859-733-1999 | e blithely after the even requests. carefully ironic packages use slyly a                           |\n|   6913.81 | Supplier#000002625 | IRAQ         |     22624 | Manufacturer#3 | a4V0rWemgbsT ZMj w7DB8rUbZ4F4lqqW5VKljQF | 21-136-564-3910 | . asymptotes among the express requests cajole furiously after the ca                               |\n|   6880.18 | Supplier#000006704 | IRAN         |     26703 | Manufacturer#4 | 97rxJlAImbO1 sUlChUWoOJ0ZzvQ2NI3KI6VDOwk | 20-588-916-1286 | old accounts wake quickly. ca                                                                       |\n|   6878.62 | Supplier#000001697 | IRAQ         |    146668 | Manufacturer#5 | 37nm ODTeHy0xWTWegplgdWQqelh             | 21-377-544-4864 | ironic theodolites. furiously regular d                                                             |\n|   6790.39 | Supplier#000008703 | IRAN         |    123678 | Manufacturer#4 | wMslK1A8SEUTIIdApQ                       | 20-782-266-2552 | eep blithely regular, pending w                                                                     |\n|   6763.46 | Supplier#000007882 | EGYPT        |    137881 | Manufacturer#5 | JDv8BZiYG0UlZ                            | 14-111-252-9120 | the silent accounts wake foxes. furious                                                             |\n|   6751.81 | Supplier#000003156 | EGYPT        |    165607 | Manufacturer#2 | alRWaW4FTFERMM4vf2rHKIKE                 | 14-843-946-7775 | are furiously. final theodolites affix slyly bold deposits. even packages haggle idly slyly specia  |\n|   6702.07 | Supplier#000006276 | EGYPT        |     31269 | Manufacturer#2 | ,dE1anEjKQGZfgquYfkx2fkGcXH              | 14-896-626-7847 | ze about the carefully regular pint                                                                 |\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n100 rows in set\n\nQ3\n+------------+-------------+-------------+----------------+\n| l_orderkey | revenue     | o_orderdate | o_shippriority |\n+------------+-------------+-------------+----------------+\n|    2152675 | 431309.8065 | 1995-03-28  |              0 |\n|    4994400 | 423834.7976 | 1995-03-09  |              0 |\n|    2160291 | 401149.7805 | 1995-03-18  |              0 |\n|    2845094 | 401094.1393 | 1995-03-06  |              0 |\n|    1902471 | 400497.3847 | 1995-03-01  |              0 |\n|    5624358 | 395710.6806 | 1995-03-20  |              0 |\n|    2346242 | 392580.0394 | 1995-03-17  |              0 |\n|    2529826 | 387365.1560 | 1995-02-17  |              0 |\n|    5168933 | 385433.6198 | 1995-03-20  |              0 |\n|    2839239 | 380503.7310 | 1995-03-22  |              0 |\n+------------+-------------+-------------+----------------+\n10 rows in set\n\nQ4\n+-----------------+-------------+\n| o_orderpriority | order_count |\n+-----------------+-------------+\n| 1-URGENT        |       10623 |\n| 2-HIGH          |       10465 |\n| 3-MEDIUM        |       10309 |\n| 4-NOT SPECIFIED |       10618 |\n| 5-LOW           |       10541 |\n+-----------------+-------------+\n5 rows in set\n\nQ5\n+---------------+---------------+\n| n_name        | revenue       |\n+---------------+---------------+\n| PERU          | 56206762.5035 |\n| CANADA        | 56052846.0161 |\n| ARGENTINA     | 54595012.8076 |\n| BRAZIL        | 53601776.5201 |\n| UNITED STATES | 50890580.8962 |\n+---------------+---------------+\n5 rows in set\n\nQ6\n+---------------+\n| revenue       |\n+---------------+\n| 61660051.7967 |\n+---------------+\n\nQ7\n+-------------+-------------+--------+---------------+\n| supp_nation | cust_nation | l_year | revenue       |\n+-------------+-------------+--------+---------------+\n| ARGENTINA   | FRANCE      |   1995 | 57928886.8015 |\n| ARGENTINA   | FRANCE      |   1996 | 55535134.8474 |\n| FRANCE      | ARGENTINA   |   1995 | 52916227.7375 |\n| FRANCE      | ARGENTINA   |   1996 | 51077995.8841 |\n+-------------+-------------+--------+---------------+\n4 rows in set\n\nQ8\n+--------+----------------------+\n| o_year | mkt_share            |\n+--------+----------------------+\n|   1995 | 0.035094304475112484 |\n|   1996 |  0.03724375099464825 |\n+--------+----------------------+\n2 rows in set\n\nQ9\n+----------------+--------+---------------+\n| nation         | o_year | sum_profit    |\n+----------------+--------+---------------+\n| ALGERIA        |   1998 | 29931671.4862 |\n| ALGERIA        |   1997 | 49521023.1139 |\n| ALGERIA        |   1996 | 51283603.7356 |\n| ALGERIA        |   1995 | 50206939.3447 |\n| ALGERIA        |   1994 | 48738988.5891 |\n| ALGERIA        |   1993 | 48084070.1204 |\n| ALGERIA        |   1992 | 49725592.1793 |\n| ARGENTINA      |   1998 | 26407044.9262 |\n| ARGENTINA      |   1997 | 46224601.0785 |\n| ARGENTINA      |   1996 | 44579611.0571 |\n| ARGENTINA      |   1995 | 45081953.2540 |\n| ARGENTINA      |   1994 | 48291282.8512 |\n| ARGENTINA      |   1993 | 48063838.9130 |\n| ARGENTINA      |   1992 | 45277890.2991 |\n| BRAZIL         |   1998 | 28577022.6384 |\n| BRAZIL         |   1997 | 46808660.3688 |\n| BRAZIL         |   1996 | 47119265.0765 |\n| BRAZIL         |   1995 | 47706399.9100 |\n| BRAZIL         |   1994 | 48377469.9386 |\n| BRAZIL         |   1993 | 46933565.7471 |\n| BRAZIL         |   1992 | 47272215.5408 |\n| CANADA         |   1998 | 30500303.6521 |\n| CANADA         |   1997 | 50046257.5687 |\n| CANADA         |   1996 | 52638586.9029 |\n| CANADA         |   1995 | 50433911.3289 |\n| CANADA         |   1994 | 51605251.7124 |\n| CANADA         |   1993 | 50117218.8464 |\n| CANADA         |   1992 | 50347111.2789 |\n| CHINA          |   1998 | 26956001.9487 |\n| CHINA          |   1997 | 48311246.7866 |\n| CHINA          |   1996 | 51133929.1033 |\n| CHINA          |   1995 | 48024289.1049 |\n| CHINA          |   1994 | 50027433.6557 |\n| CHINA          |   1993 | 48240226.3801 |\n| CHINA          |   1992 | 47769117.6007 |\n| EGYPT          |   1998 | 26972573.1604 |\n| EGYPT          |   1997 | 46708654.7666 |\n| EGYPT          |   1996 | 46095050.4457 |\n| EGYPT          |   1995 | 44901908.2949 |\n| EGYPT          |   1994 | 48522762.8892 |\n| EGYPT          |   1993 | 49055807.7642 |\n| EGYPT          |   1992 | 46909796.1083 |\n| ETHIOPIA       |   1998 | 26364411.6457 |\n| ETHIOPIA       |   1997 | 44889623.0645 |\n| ETHIOPIA       |   1996 | 47554295.2892 |\n| ETHIOPIA       |   1995 | 44747639.5440 |\n| ETHIOPIA       |   1994 | 46497570.0631 |\n| ETHIOPIA       |   1993 | 43853718.5460 |\n| ETHIOPIA       |   1992 | 44005773.0397 |\n| FRANCE         |   1998 | 27033406.6353 |\n| FRANCE         |   1997 | 45763555.5515 |\n| FRANCE         |   1996 | 47178544.9301 |\n| FRANCE         |   1995 | 48821282.1929 |\n| FRANCE         |   1994 | 46444640.9397 |\n| FRANCE         |   1993 | 46602311.0590 |\n| FRANCE         |   1992 | 47769356.5113 |\n| GERMANY        |   1998 | 26165681.8305 |\n| GERMANY        |   1997 | 46600844.4431 |\n| GERMANY        |   1996 | 44873520.1979 |\n| GERMANY        |   1995 | 47761215.6058 |\n| GERMANY        |   1994 | 42283120.0209 |\n| GERMANY        |   1993 | 46954873.9820 |\n| GERMANY        |   1992 | 46263626.6361 |\n| INDIA          |   1998 | 27651103.0250 |\n| INDIA          |   1997 | 46000888.8340 |\n| INDIA          |   1996 | 43993476.7354 |\n| INDIA          |   1995 | 44015709.1914 |\n| INDIA          |   1994 | 44281439.6282 |\n| INDIA          |   1993 | 45367255.7857 |\n| INDIA          |   1992 | 45350810.5330 |\n| INDONESIA      |   1998 | 27120545.3120 |\n| INDONESIA      |   1997 | 45745362.3667 |\n| INDONESIA      |   1996 | 45347554.8232 |\n| INDONESIA      |   1995 | 45685709.4978 |\n| INDONESIA      |   1994 | 44738603.1901 |\n| INDONESIA      |   1993 | 45172063.2033 |\n| INDONESIA      |   1992 | 44623924.3942 |\n| IRAN           |   1998 | 27876287.0949 |\n| IRAN           |   1997 | 47184621.5647 |\n| IRAN           |   1996 | 47397859.7878 |\n| IRAN           |   1995 | 49579120.6991 |\n| IRAN           |   1994 | 48032316.8744 |\n| IRAN           |   1993 | 48295593.2066 |\n| IRAN           |   1992 | 50531453.3934 |\n| IRAQ           |   1998 | 29997323.2927 |\n| IRAQ           |   1997 | 52851471.1377 |\n| IRAQ           |   1996 | 53671825.6297 |\n| IRAQ           |   1995 | 53251012.1025 |\n| IRAQ           |   1994 | 50934553.4361 |\n| IRAQ           |   1993 | 51961214.1186 |\n| IRAQ           |   1992 | 50840364.3833 |\n| JAPAN          |   1998 | 26054615.4955 |\n| JAPAN          |   1997 | 43557394.2595 |\n| JAPAN          |   1996 | 46531743.0980 |\n| JAPAN          |   1995 | 41688293.4741 |\n| JAPAN          |   1994 | 45526719.0728 |\n| JAPAN          |   1993 | 45619475.4478 |\n| JAPAN          |   1992 | 44545639.3069 |\n| JORDAN         |   1998 | 24793092.4101 |\n| JORDAN         |   1997 | 42050730.7748 |\n| JORDAN         |   1996 | 42562783.8663 |\n| JORDAN         |   1995 | 42253019.5330 |\n| JORDAN         |   1994 | 45027034.7721 |\n| JORDAN         |   1993 | 44797510.9808 |\n| JORDAN         |   1992 | 41313405.2890 |\n| KENYA          |   1998 | 24550926.4693 |\n| KENYA          |   1997 | 42767120.5848 |\n| KENYA          |   1996 | 45000095.1105 |\n| KENYA          |   1995 | 43250458.0109 |\n| KENYA          |   1994 | 42891596.7158 |\n| KENYA          |   1993 | 43599201.5126 |\n| KENYA          |   1992 | 45286145.8141 |\n| MOROCCO        |   1998 | 23482053.5970 |\n| MOROCCO        |   1997 | 41503033.0020 |\n| MOROCCO        |   1996 | 45645555.9409 |\n| MOROCCO        |   1995 | 44462858.7689 |\n| MOROCCO        |   1994 | 44768368.8310 |\n| MOROCCO        |   1993 | 44611871.2477 |\n| MOROCCO        |   1992 | 43057959.1352 |\n| MOZAMBIQUE     |   1998 | 28824737.9244 |\n| MOZAMBIQUE     |   1997 | 48682746.5995 |\n| MOZAMBIQUE     |   1996 | 50816940.9909 |\n| MOZAMBIQUE     |   1995 | 50010039.0178 |\n| MOZAMBIQUE     |   1994 | 48794892.1253 |\n| MOZAMBIQUE     |   1993 | 48451128.3332 |\n| MOZAMBIQUE     |   1992 | 50113858.5449 |\n| PERU           |   1998 | 30575758.1899 |\n| PERU           |   1997 | 49323405.6808 |\n| PERU           |   1996 | 50063490.6085 |\n| PERU           |   1995 | 51272843.6555 |\n| PERU           |   1994 | 50690589.2334 |\n| PERU           |   1993 | 49086129.3668 |\n| PERU           |   1992 | 50067216.3450 |\n| ROMANIA        |   1998 | 27367992.9903 |\n| ROMANIA        |   1997 | 45668932.7094 |\n| ROMANIA        |   1996 | 46594220.7498 |\n| ROMANIA        |   1995 | 44576835.1623 |\n| ROMANIA        |   1994 | 45640971.0684 |\n| ROMANIA        |   1993 | 46374545.0712 |\n| ROMANIA        |   1992 | 47130533.3076 |\n| RUSSIA         |   1998 | 27486839.8755 |\n| RUSSIA         |   1997 | 44050712.6907 |\n| RUSSIA         |   1996 | 45604597.4983 |\n| RUSSIA         |   1995 | 48972490.6009 |\n| RUSSIA         |   1994 | 45652045.5872 |\n| RUSSIA         |   1993 | 47139548.1597 |\n| RUSSIA         |   1992 | 47159990.1221 |\n| SAUDI ARABIA   |   1998 | 29766229.7961 |\n| SAUDI ARABIA   |   1997 | 51473031.6922 |\n| SAUDI ARABIA   |   1996 | 52859666.6646 |\n| SAUDI ARABIA   |   1995 | 50946175.0229 |\n| SAUDI ARABIA   |   1994 | 53085288.9954 |\n| SAUDI ARABIA   |   1993 | 50907571.2046 |\n| SAUDI ARABIA   |   1992 | 50334063.0381 |\n| UNITED KINGDOM |   1998 | 27904712.8220 |\n| UNITED KINGDOM |   1997 | 48170994.4362 |\n| UNITED KINGDOM |   1996 | 46498116.9611 |\n| UNITED KINGDOM |   1995 | 43210619.0456 |\n| UNITED KINGDOM |   1994 | 47339709.9122 |\n| UNITED KINGDOM |   1993 | 44308436.3275 |\n| UNITED KINGDOM |   1992 | 45870809.6693 |\n| UNITED STATES  |   1998 | 25856187.3719 |\n| UNITED STATES  |   1997 | 44934753.2208 |\n| UNITED STATES  |   1996 | 44826974.2915 |\n| UNITED STATES  |   1995 | 44160425.4086 |\n| UNITED STATES  |   1994 | 43193241.6843 |\n| UNITED STATES  |   1993 | 45126307.2619 |\n| UNITED STATES  |   1992 | 44205926.3317 |\n| VIETNAM        |   1998 | 28289193.6726 |\n| VIETNAM        |   1997 | 48284585.4019 |\n| VIETNAM        |   1996 | 48360225.9084 |\n| VIETNAM        |   1995 | 48742082.6165 |\n| VIETNAM        |   1994 | 49035537.3894 |\n| VIETNAM        |   1993 | 47222674.6352 |\n| VIETNAM        |   1992 | 48628336.9011 |\n+----------------+--------+---------------+\n175 rows in set\n\nQ10\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n| c_custkey | c_name             | revenue     | c_acctbal | n_name         | c_address                                | c_phone         | c_comment                                                                                                       |\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n|     95962 | Customer#000095962 | 704336.0774 |     -9.33 | MOZAMBIQUE     | 83wOMt9iAb9OJ0HbkQ1PaX3odXVBNEIMXaE      | 26-127-693-7436 | nusual theodolites maintain furiously fluffily iro                                                              |\n|     87064 | Customer#000087064 | 684037.4349 |   5244.68 | BRAZIL         | 0xej6ldT8zi7MwLdDJ1II3YWwprkvwB1 I0kwsf  | 12-930-206-2571 | de of the ironic, silent warthogs. bold, r                                                                      |\n|     56416 | Customer#000056416 | 661218.0492 |   4303.82 | INDIA          | CEuBN,xZVmP                              | 18-212-984-8331 | al waters cajole along the slyly unusual dugouts. carefully regular deposits use slyly? packages h              |\n|     46450 | Customer#000046450 | 646205.6835 |   2400.59 | UNITED STATES  | rzWQxB9iFpd8i4KUCAPdv                    | 34-765-320-4326 | ss, final deposits cajole sly                                                                                   |\n|    128713 | Customer#000128713 | 643240.1183 |   7200.30 | ARGENTINA      | mm0kxtHFCchaZX4eYSCCyQHno7vq,SRmv4       | 11-174-994-6880 | ording to the express accounts cajole carefully across the bravely special packages. carefully regular account  |\n|    102187 | Customer#000102187 | 637493.0787 |   -896.03 | ETHIOPIA       | EAi6vcGnWHUMb6rJwn,PtUgSH74tR Aixa       | 15-877-462-6534 | gular packages. carefully regular deposits cajole carefully of the regular requests. carefully special accou    |\n|     42541 | Customer#000042541 | 634546.9756 |   8082.14 | IRAN           | IccOGHgp8g                               | 20-442-159-1337 | cross the final asymptotes. final packages wake furiously ironic dec                                            |\n|     51595 | Customer#000051595 | 611926.8265 |   7236.80 | UNITED STATES  | wQFWZk 7JCpeg50O0KCzSmUFnNNwX1aEQ7V3Q    | 34-844-269-9070 | sts. always express accounts use carefully along the quickly speci                                              |\n|     66391 | Customer#000066391 | 608385.5852 |   9404.57 | UNITED STATES  | V0XvU1Nh9NU4zsyOkm,RBa                   | 34-149-224-8119 | ages cajole carefully carefully bold deposits: fluffily unusual deposits promise slyly carefully ironic co      |\n|     48358 | Customer#000048358 | 603621.4823 |   -611.15 | ETHIOPIA       | ycg3uMG7iDdwQvJ1irr                      | 15-687-936-5181 | the slyly unusual foxes-- carefully regular                                                                     |\n|     99175 | Customer#000099175 | 602125.3304 |   2218.76 | INDONESIA      | 9wbW52xx9T84E0dZ Rvz1ozQ1                | 19-125-912-6494 | ide of the slyly ironic foxes boost silently ironic, even instructions. blithe                                  |\n|    122509 | Customer#000122509 | 601580.1203 |   2613.83 | KENYA          | ZN1sc0eJrkD8t6X5Q1d3                     | 24-421-308-3881 | brave deposits haggle across the even deposits. instr                                                           |\n|    148055 | Customer#000148055 | 601003.6812 |    455.31 | PERU           | Y,RCZ3Bislx64nTsPaRL,5gjx7xgC6y, yKYnCw  | 27-473-476-4382 | uickly final accounts wake carefully sl                                                                         |\n|    117451 | Customer#000117451 | 599792.7063 |   1090.48 | UNITED STATES  | bSwr7mNPiaf1f lNK9 uTJxWCL2sn1Lak5NIB    | 34-354-586-6011 | ding to the furiously express accounts boost carefully af                                                       |\n|    104110 | Customer#000104110 | 588194.3118 |   2762.52 | JORDAN         | mm7 ZuDX5Z5nAQbKObB 80XBCy,1nyW          | 23-639-800-5768 | urts sleep furiously alongside of the packages! slyly ironic packages sleep                                     |\n|     13666 | Customer#000013666 | 579926.1679 |   7453.98 | EGYPT          | DLRUWGcprmWqdROJvmZwpE                   | 14-316-135-4381 | ross the silent requests. special theodolit                                                                     |\n|     96202 | Customer#000096202 | 571017.3398 |   4703.04 | CANADA         | 4Vcxcx3w4zMjVYNQaqrweweQY6TJO AP9rdvQaLl | 13-194-779-9597 | en packages use. fluffily regular dependencies boost. never pending requ                                        |\n|     70279 | Customer#000070279 | 561369.3650 |   9109.34 | CHINA          | ltie8o3ihwffMrqMrkvN957KZVWmH5           | 28-842-825-1717 | theodolites sleep: blithely final requests are fur                                                              |\n|     16972 | Customer#000016972 | 560435.8065 |   6408.66 | ROMANIA        | X6T8vRKy6kSO0f2wJJt                      | 29-483-958-3347 | sts. pending deposits are across the regular, express instructions. carefully daring foxes cajol                |\n|    113443 | Customer#000113443 | 557272.6706 |    -72.67 | UNITED KINGDOM | SUHbS85cYxgVkKbfh9sUpEa6ezVSlQuCKe3CV    | 33-819-742-6112 | ic foxes cajole thinly furiously stealthy instructions. pinto beans are. quickly regular accounts integrate car |\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n20 rows in set\n\nQ11\n+------------+-------------+\n| ps_partkey | value       |\n+------------+-------------+\n|     131630 | 17882680.37 |\n|     104150 | 17613017.18 |\n|     128284 | 16502418.74 |\n|       8978 | 16470438.59 |\n|     147193 | 16462742.12 |\n|      78788 | 16010246.37 |\n|      76331 | 15776882.05 |\n|     137287 | 15770471.15 |\n|      51302 | 15730620.22 |\n|     141553 | 15333540.19 |\n|     137196 | 15035435.60 |\n|     186531 | 14818272.68 |\n|     103818 | 14690943.63 |\n|      80080 | 14626441.35 |\n|       1312 | 14330729.50 |\n|       6531 | 14267308.08 |\n|      96162 | 14154396.04 |\n|      69605 | 14018927.25 |\n|      30118 | 13854726.38 |\n|      17006 | 13731495.60 |\n|      95347 | 13716648.60 |\n|      18722 | 13707978.71 |\n|     122875 | 13640341.00 |\n|     105499 | 13532912.80 |\n|     165560 | 13509536.95 |\n|       1531 | 13337454.55 |\n|      34732 | 13304041.48 |\n|     173221 | 13038078.41 |\n|     180975 | 13038039.17 |\n|      24703 | 12957050.80 |\n|      72036 | 12939426.90 |\n|     124814 | 12849842.04 |\n|     174453 | 12814999.00 |\n|      14209 | 12814858.56 |\n|     185186 | 12657201.05 |\n|     187868 | 12647101.80 |\n|     125085 | 12639931.63 |\n|      80331 | 12625007.00 |\n|     118685 | 12515185.68 |\n|     163988 | 12484272.80 |\n|     124685 | 12432747.32 |\n|      92838 | 12410071.57 |\n|     140928 | 12396673.84 |\n|       1218 | 12362877.75 |\n|      39201 | 12328085.10 |\n|      33237 | 12180622.98 |\n|     183791 | 12150040.50 |\n|       3243 | 12136315.74 |\n|      62740 | 12131313.60 |\n|     154171 | 12105470.89 |\n|      49034 | 11982382.52 |\n|      88673 | 11925499.04 |\n|      52527 | 11923653.16 |\n|      83974 | 11871084.73 |\n|      88254 | 11870393.22 |\n|        411 | 11806670.95 |\n|      14320 | 11800136.02 |\n|     164979 | 11794760.03 |\n|     166149 | 11778499.72 |\n|      74105 | 11750224.34 |\n|     169104 | 11708532.18 |\n|      15542 | 11687293.42 |\n|     161538 | 11661769.80 |\n|      63337 | 11592505.40 |\n|     117197 | 11508165.60 |\n|     102989 | 11497056.75 |\n|      10836 | 11465875.43 |\n|     199561 | 11431793.36 |\n|     134683 | 11384564.54 |\n|     136318 | 11351893.30 |\n|     166270 | 11336004.81 |\n|      32200 | 11324838.00 |\n|      57033 | 11281026.52 |\n|      18098 | 11245398.24 |\n|     135174 | 11189782.12 |\n|     181616 | 11183947.65 |\n|      85064 | 11175761.43 |\n|     120719 | 11164342.08 |\n|      99670 | 11140257.47 |\n|      46096 | 11034143.76 |\n|     195124 | 11030197.30 |\n|      78838 | 11012446.40 |\n|     151656 | 11010376.90 |\n|     156956 | 10996384.80 |\n|      34028 | 10942671.24 |\n|      15778 | 10937778.75 |\n|     199707 | 10924333.33 |\n|     118776 | 10920609.31 |\n|      27640 | 10919693.42 |\n|      15237 | 10918145.54 |\n|     148243 | 10916765.29 |\n|     111498 | 10867707.51 |\n|     132024 | 10834280.47 |\n|      35124 | 10806898.50 |\n|     196818 | 10787371.25 |\n|     197669 | 10779504.60 |\n|     110042 | 10778828.37 |\n|     197422 | 10770092.44 |\n|      75160 | 10746976.60 |\n|     191567 | 10642430.39 |\n|      34225 | 10574664.41 |\n|     102588 | 10567012.05 |\n|      44148 | 10505249.34 |\n|     126607 | 10484944.29 |\n|     172625 | 10444857.62 |\n|     157054 | 10406203.24 |\n|      19322 | 10378704.98 |\n|     136541 | 10371536.77 |\n|     167526 | 10320346.58 |\n|     136011 | 10302146.84 |\n|     107431 | 10273992.76 |\n|      16485 | 10257703.67 |\n|      52580 | 10250264.05 |\n|        839 | 10238243.36 |\n|      31704 | 10196678.94 |\n|     122558 | 10137326.18 |\n|     180386 | 10123318.07 |\n|      97705 | 10089163.37 |\n|      96327 | 10087851.88 |\n|     136143 | 10082137.97 |\n|      15174 | 10057277.55 |\n|     193324 | 10039922.93 |\n|      33593 | 10019952.10 |\n|     126288 | 10014855.05 |\n|      64123 |  9985650.90 |\n|     183712 |  9973256.18 |\n|     138831 |  9963069.10 |\n|     123694 |  9959096.38 |\n|      51734 |  9952439.73 |\n|      11861 |  9949647.12 |\n|     119127 |  9942105.69 |\n|     173308 |  9932264.52 |\n|      40986 |  9921554.40 |\n|     176970 |  9919708.65 |\n|      54316 |  9913595.16 |\n|      62644 |  9903936.27 |\n|     185354 |  9895956.52 |\n|      81468 |  9885132.60 |\n|     104687 |  9883888.05 |\n|     198959 |  9875351.28 |\n|     179767 |  9872309.86 |\n|     102835 |  9870743.52 |\n|     163221 |  9856173.04 |\n|      32633 |  9852565.04 |\n|      19605 |  9850164.48 |\n|      47378 |  9826135.11 |\n|      44026 |  9822433.44 |\n|     126629 |  9816227.30 |\n|     199665 |  9812400.23 |\n|      30989 |  9812295.52 |\n|     102177 |  9810372.32 |\n|      25765 |  9806344.88 |\n|     110721 |  9804895.23 |\n|     159532 |  9803738.34 |\n|     101640 |  9801375.65 |\n|     151569 |  9792489.20 |\n|     180629 |  9782164.34 |\n|     165528 |  9769074.10 |\n|      23772 |  9766084.22 |\n|     149727 |  9765190.96 |\n|     189605 |  9761887.80 |\n|      74703 |  9758757.28 |\n|      83382 |  9758144.21 |\n|      93775 |  9726901.71 |\n|      56192 |  9725508.16 |\n|      50060 |  9712714.65 |\n|      15409 |  9706898.91 |\n|     139104 |  9701070.72 |\n|     177435 |  9686566.09 |\n|      31351 |  9675197.98 |\n|      20495 |  9672566.31 |\n|      24537 |  9654516.03 |\n|     160528 |  9650804.70 |\n|      34706 |  9647241.90 |\n|     149039 |  9643498.32 |\n|     147139 |  9642356.34 |\n|     118629 |  9624960.80 |\n|      35359 |  9621549.92 |\n|      33854 |  9616857.73 |\n|      33707 |  9609988.84 |\n|     149055 |  9599364.32 |\n|     127429 |  9580670.49 |\n|      67575 |  9579613.26 |\n|      80727 |  9576545.81 |\n|     181650 |  9574445.40 |\n|      50176 |  9573389.08 |\n|     171093 |  9571625.20 |\n|     151342 |  9569230.21 |\n|     123052 |  9561903.68 |\n|     132633 |  9545052.14 |\n|     130419 |  9524936.49 |\n|      89241 |  9512992.32 |\n|     138255 |  9503515.93 |\n|      31680 |  9502841.07 |\n|     151986 |  9500862.59 |\n|     146390 |  9490242.96 |\n|      62275 |  9475584.10 |\n|      33518 |  9475074.40 |\n|       5286 |  9473739.88 |\n|      39020 |  9467701.22 |\n|     113281 |  9466510.94 |\n|     138789 |  9464407.24 |\n|     165040 |  9462153.75 |\n|     150766 |  9461855.88 |\n|      54341 |  9459425.45 |\n|      33464 |  9459377.37 |\n|      15251 |  9455980.84 |\n|     145308 |  9454189.29 |\n|     192621 |  9449324.14 |\n|     175218 |  9448987.35 |\n|      58992 |  9446144.40 |\n|      24548 |  9442739.03 |\n|     177563 |  9440891.04 |\n|     184482 |  9431486.10 |\n|      78961 |  9430401.05 |\n|     174167 |  9428622.96 |\n|      88265 |  9423143.28 |\n|       6057 |  9405359.37 |\n|      85387 |  9402175.55 |\n|      47053 |  9399707.66 |\n|     128973 |  9399265.92 |\n|      65668 |  9395584.45 |\n|      50222 |  9394502.96 |\n|     116534 |  9388011.08 |\n|     140959 |  9386284.56 |\n|      46897 |  9385056.21 |\n|     141872 |  9383820.48 |\n|     177181 |  9383551.92 |\n|     168265 |  9376664.16 |\n|      48974 |  9374769.12 |\n|      46218 |  9364135.50 |\n|     104039 |  9363227.03 |\n|      61538 |  9360159.08 |\n|      94688 |  9359604.98 |\n|     122393 |  9357937.19 |\n|       7323 |  9356712.30 |\n|     197892 |  9356573.44 |\n|     194056 |  9352381.73 |\n|      61285 |  9348480.54 |\n|     180336 |  9347874.15 |\n|     121930 |  9347784.74 |\n|      80652 |  9347143.50 |\n|      18549 |  9346038.72 |\n|      23992 |  9339908.16 |\n|     136583 |  9337299.56 |\n|     156151 |  9337138.10 |\n|     160572 |  9336553.40 |\n|     113391 |  9335558.10 |\n|      48068 |  9334317.92 |\n|      20409 |  9331093.65 |\n|      39712 |  9324685.28 |\n|      59364 |  9322249.86 |\n|       1344 |  9308304.39 |\n|      60549 |  9308293.20 |\n|      83854 |  9307387.25 |\n|      92092 |  9307165.64 |\n|     193306 |  9306177.31 |\n|     118265 |  9300250.20 |\n|     107568 |  9296254.34 |\n|     109127 |  9293552.10 |\n|     184688 |  9291647.92 |\n|       8718 |  9287337.37 |\n|      80433 |  9286295.52 |\n|      26670 |  9284963.44 |\n|     139548 |  9283605.21 |\n|      14736 |  9280119.20 |\n|      97886 |  9273852.42 |\n|     181442 |  9273130.50 |\n|     172360 |  9272824.92 |\n|     192714 |  9268366.36 |\n|     106726 |  9264879.90 |\n|      72157 |  9263498.40 |\n|      70445 |  9257553.92 |\n|      75148 |  9257420.83 |\n|      26170 |  9256074.12 |\n|     116531 |  9249721.71 |\n|     133665 |  9245464.80 |\n|     129041 |  9244629.48 |\n|     136486 |  9240748.92 |\n|     198924 |  9239976.06 |\n|     115254 |  9233580.37 |\n|     168135 |  9232693.98 |\n|      22480 |  9232190.78 |\n|     192018 |  9230386.58 |\n|     111889 |  9228204.96 |\n|     151661 |  9227926.90 |\n|      96482 |  9226960.85 |\n|      49198 |  9226436.40 |\n|      41219 |  9222883.52 |\n|     113502 |  9222208.59 |\n|      84009 |  9218703.22 |\n|     192788 |  9213468.00 |\n|     160251 |  9206353.32 |\n|     188162 |  9200537.88 |\n|     167589 |  9195835.03 |\n|     132673 |  9194021.22 |\n|     191105 |  9192417.12 |\n|     128748 |  9189941.55 |\n|     130423 |  9184710.96 |\n|      22639 |  9182963.16 |\n|     199034 |  9180909.86 |\n|     187644 |  9180350.20 |\n|        970 |  9175757.70 |\n|      59070 |  9170000.64 |\n|      66568 |  9166070.04 |\n|      52715 |  9161221.80 |\n|     130276 |  9161201.57 |\n|      24189 |  9160740.15 |\n|     132402 |  9144498.48 |\n|      37799 |  9142271.24 |\n|     173337 |  9140566.68 |\n|     176552 |  9135054.51 |\n|     195714 |  9133679.77 |\n|     119363 |  9123261.90 |\n|     161160 |  9122259.60 |\n|     196968 |  9111592.20 |\n|      61943 |  9111527.33 |\n|      79766 |  9109534.89 |\n|     178082 |  9105694.92 |\n|      38800 |  9105468.72 |\n|      83608 |  9099493.68 |\n|     146346 |  9098628.00 |\n|     116690 |  9098099.93 |\n|      64690 |  9095441.10 |\n|      82061 |  9095381.18 |\n|      89015 |  9092660.48 |\n|     188457 |  9091400.40 |\n|     125177 |  9090455.55 |\n|     114776 |  9088177.68 |\n|       4486 |  9087487.20 |\n|     176940 |  9086842.84 |\n|      93157 |  9084361.81 |\n|     148624 |  9083370.78 |\n|       4441 |  9079520.58 |\n|      63590 |  9079125.44 |\n|     174189 |  9078023.39 |\n|      63054 |  9075441.98 |\n|      14950 |  9073156.19 |\n|     175646 |  9072322.47 |\n|      63712 |  9067710.48 |\n|     157197 |  9067452.77 |\n|     147196 |  9064699.80 |\n|      50551 |  9062434.72 |\n|      43035 |  9061782.03 |\n|     187679 |  9056529.40 |\n|      96673 |  9056525.94 |\n|     130148 |  9054217.06 |\n|     159007 |  9053155.29 |\n|      41544 |  9052820.94 |\n|     109476 |  9048012.09 |\n|      60092 |  9045562.44 |\n|     197490 |  9044579.88 |\n|      47311 |  9037223.52 |\n|      87230 |  9033227.61 |\n|       3860 |  9030622.02 |\n|       5466 |  9029841.66 |\n|     171537 |  9024699.30 |\n|      39707 |  9022833.12 |\n|     167048 |  9022709.18 |\n|     109006 |  9022258.40 |\n|      17910 |  9019688.45 |\n|     132826 |  9017286.74 |\n|     157502 |  9016444.08 |\n|     142309 |  9016270.60 |\n|      78891 |  9005693.25 |\n|      88301 |  9002414.82 |\n|      11496 |  9000803.97 |\n|     163633 |  8996162.06 |\n|     151809 |  8993104.95 |\n|     131555 |  8988340.68 |\n|      72812 |  8985370.68 |\n|      77047 |  8981489.79 |\n|       1553 |  8977226.10 |\n|     162531 |  8973689.92 |\n|     154026 |  8973320.24 |\n|     125499 |  8969667.84 |\n|      34547 |  8966116.43 |\n|      41301 |  8965350.42 |\n|      12853 |  8959403.59 |\n|      27736 |  8957933.23 |\n|     162817 |  8956868.20 |\n|     155389 |  8955349.85 |\n|     130360 |  8952928.25 |\n|     120878 |  8952393.10 |\n|     150671 |  8952112.72 |\n|     190365 |  8951671.57 |\n|      72364 |  8950587.82 |\n|      71615 |  8949277.07 |\n|      95277 |  8947796.58 |\n|      78180 |  8946814.80 |\n|      97062 |  8945057.46 |\n|     170013 |  8944660.40 |\n|     113426 |  8943016.29 |\n|     173751 |  8942914.28 |\n|       1478 |  8941906.24 |\n|      26061 |  8941022.48 |\n|     152527 |  8939654.10 |\n|     148360 |  8939589.40 |\n|      44057 |  8939101.36 |\n|      13595 |  8936720.10 |\n|      33337 |  8935366.48 |\n|     169698 |  8931507.20 |\n|      26155 |  8927283.11 |\n|      17185 |  8927218.40 |\n|      51996 |  8926661.08 |\n|     101869 |  8919281.70 |\n|      14561 |  8910653.92 |\n|     190047 |  8909427.90 |\n|     104143 |  8909328.40 |\n|     133330 |  8907195.90 |\n|     169144 |  8904989.34 |\n|      87067 |  8900079.44 |\n|     176075 |  8898845.64 |\n|      25076 |  8895274.12 |\n|      80838 |  8895205.30 |\n|      40387 |  8890891.55 |\n|      88004 |  8888748.80 |\n|     105527 |  8888672.72 |\n|      40741 |  8886674.24 |\n|      76690 |  8880622.61 |\n|      86485 |  8880488.57 |\n|      75736 |  8877666.06 |\n|      48704 |  8876626.52 |\n|      56450 |  8872277.59 |\n|      61683 |  8870173.93 |\n|      24067 |  8867814.12 |\n|     108012 |  8863632.38 |\n|     180971 |  8862007.20 |\n|     132986 |  8861335.20 |\n|      35839 |  8859344.64 |\n|     191553 |  8857411.14 |\n|     163492 |  8855825.91 |\n|     112101 |  8851904.10 |\n|      27050 |  8847924.19 |\n|      57481 |  8845309.59 |\n|     163252 |  8842276.65 |\n|      87958 |  8840221.67 |\n|      60162 |  8838927.08 |\n|     131928 |  8838900.48 |\n|     123514 |  8833601.14 |\n|      42891 |  8830401.37 |\n|      71547 |  8829540.72 |\n|      13975 |  8826582.48 |\n|      31577 |  8825371.40 |\n|      86165 |  8816308.38 |\n|     164646 |  8815470.18 |\n|     150176 |  8814992.11 |\n|     152464 |  8814533.82 |\n|     183434 |  8813941.24 |\n|      58839 |  8808010.20 |\n|      59952 |  8801497.32 |\n|     151038 |  8800215.80 |\n|     139523 |  8800032.57 |\n|       8828 |  8798704.66 |\n|      14080 |  8797032.12 |\n|     194080 |  8792825.27 |\n|      87199 |  8788933.64 |\n|      91747 |  8785811.64 |\n|     194429 |  8776185.03 |\n|     118998 |  8776071.00 |\n|     179467 |  8771474.74 |\n|      68715 |  8771302.80 |\n|     180572 |  8771095.68 |\n|      19821 |  8770770.82 |\n|      41702 |  8770565.71 |\n|      27916 |  8769001.47 |\n|     121302 |  8763598.50 |\n|     107013 |  8762893.37 |\n|      37287 |  8761196.43 |\n|     117050 |  8758230.00 |\n|      58547 |  8757757.40 |\n|     197088 |  8749026.12 |\n|      55839 |  8747234.02 |\n|      71829 |  8744546.91 |\n|      30961 |  8743416.92 |\n|     134548 |  8741635.28 |\n|     179833 |  8738680.00 |\n|      79721 |  8737857.70 |\n|     144577 |  8736427.08 |\n|      29051 |  8729063.28 |\n|     131481 |  8728799.64 |\n|      73271 |  8727985.25 |\n|      89553 |  8725727.19 |\n|      31306 |  8724451.12 |\n|      82181 |  8724017.16 |\n|      95549 |  8723460.30 |\n|      31507 |  8722094.40 |\n|      21302 |  8722054.95 |\n|     137953 |  8721611.83 |\n|     195768 |  8721020.99 |\n|     180105 |  8718021.20 |\n|      98241 |  8717935.36 |\n|      59431 |  8715482.28 |\n|     143694 |  8713267.63 |\n|     109020 |  8713043.36 |\n|      46732 |  8711642.04 |\n|     144172 |  8711013.10 |\n|     139056 |  8710786.50 |\n|     107543 |  8706135.75 |\n|      89127 |  8705410.56 |\n|     146544 |  8704812.86 |\n|     195524 |  8699333.14 |\n|     133563 |  8698060.14 |\n|     112707 |  8694322.84 |\n|      98951 |  8690376.70 |\n|     132635 |  8689305.24 |\n|      69056 |  8688980.25 |\n|     134143 |  8688695.26 |\n|     148150 |  8687553.16 |\n|      89122 |  8686767.31 |\n|      15085 |  8685772.26 |\n|     196686 |  8682783.57 |\n|       3076 |  8672940.78 |\n|     137428 |  8672547.80 |\n|      27263 |  8671719.36 |\n|     101561 |  8667962.72 |\n|      12597 |  8662223.52 |\n|     143329 |  8661688.72 |\n|     130813 |  8659409.04 |\n|     183679 |  8658698.30 |\n|      47449 |  8658493.58 |\n|     164677 |  8658220.00 |\n|      51437 |  8654713.02 |\n|     116162 |  8649713.36 |\n|      71889 |  8645159.67 |\n|       6486 |  8639891.76 |\n|     192102 |  8638102.72 |\n|     101660 |  8634451.80 |\n|     124703 |  8633146.86 |\n|     150469 |  8631948.60 |\n|     197467 |  8630739.78 |\n|      97621 |  8630453.32 |\n|     150354 |  8630288.15 |\n|     179544 |  8630121.63 |\n|      38972 |  8626072.00 |\n|     110732 |  8625761.16 |\n|     170791 |  8625203.06 |\n|     149414 |  8617070.17 |\n|      59527 |  8616079.20 |\n|     157580 |  8615676.04 |\n|      16268 |  8615087.46 |\n|      76464 |  8610219.38 |\n|      44474 |  8607934.92 |\n|     125527 |  8607708.08 |\n|     118076 |  8602251.65 |\n|     180362 |  8601367.05 |\n|       5808 |  8599851.04 |\n|      28703 |  8599486.36 |\n|     113373 |  8597996.36 |\n|     118918 |  8597063.80 |\n|      44868 |  8596304.52 |\n|      43419 |  8596265.35 |\n|      89763 |  8595248.64 |\n|     119232 |  8594224.56 |\n|     108649 |  8590683.68 |\n|      10396 |  8588398.05 |\n|      79536 |  8587117.83 |\n|     149800 |  8587058.86 |\n|     165839 |  8582991.20 |\n|     115397 |  8581524.77 |\n|     104394 |  8581384.42 |\n|     142569 |  8581127.40 |\n|      63676 |  8580930.08 |\n|      29029 |  8580613.53 |\n|     156604 |  8580477.00 |\n|       7310 |  8579949.50 |\n|     105381 |  8576164.24 |\n|      84306 |  8573960.40 |\n|      61217 |  8570393.04 |\n|     164438 |  8569616.36 |\n|      28073 |  8565639.60 |\n|     125743 |  8563258.90 |\n|     190032 |  8561620.55 |\n|     147122 |  8561245.68 |\n|       5384 |  8558830.08 |\n|      70172 |  8558319.64 |\n|     161966 |  8556193.38 |\n|      69530 |  8554377.60 |\n|     111243 |  8553627.55 |\n|      72590 |  8551077.51 |\n|     134423 |  8550604.77 |\n|      44509 |  8547134.31 |\n|     160707 |  8546000.68 |\n|      54123 |  8545976.26 |\n|      36547 |  8540333.04 |\n|      48715 |  8537983.35 |\n|     103078 |  8537142.60 |\n|     137613 |  8536278.96 |\n|      44995 |  8532416.72 |\n|     191159 |  8532173.37 |\n|     119345 |  8532070.56 |\n|     109941 |  8531904.79 |\n|       5449 |  8528034.35 |\n|     134116 |  8526854.95 |\n|     199268 |  8523599.58 |\n|     168520 |  8523360.67 |\n|     154189 |  8521620.13 |\n|     108771 |  8513853.87 |\n|     198651 |  8511238.80 |\n|      93681 |  8510935.14 |\n|     170680 |  8509087.68 |\n|     106409 |  8506859.19 |\n|      27110 |  8499811.75 |\n|      43224 |  8499539.52 |\n|     153225 |  8499434.28 |\n|      16681 |  8498021.66 |\n|     117983 |  8496934.32 |\n|     192158 |  8492372.03 |\n|      33900 |  8491139.64 |\n|      37006 |  8489126.28 |\n|     176554 |  8488633.92 |\n|      69234 |  8484937.26 |\n|     176652 |  8484496.02 |\n|      41660 |  8480585.65 |\n|     129104 |  8480411.17 |\n|      66960 |  8478978.86 |\n|      36296 |  8472438.75 |\n|      98665 |  8471241.57 |\n|     134173 |  8467888.57 |\n|      60496 |  8467019.22 |\n|     197520 |  8466553.20 |\n|     116746 |  8465792.60 |\n|     187394 |  8458248.24 |\n|     140377 |  8455546.68 |\n|      97326 |  8450501.67 |\n|      26770 |  8449625.64 |\n|     104884 |  8446152.26 |\n|     143109 |  8443547.19 |\n|     127361 |  8441094.08 |\n|     104754 |  8436883.50 |\n|     183676 |  8436165.76 |\n|        906 |  8434608.12 |\n|      55768 |  8433763.69 |\n|     118654 |  8433465.57 |\n|      39310 |  8433214.55 |\n|     173261 |  8432992.53 |\n|      93976 |  8432605.20 |\n|      63318 |  8432149.26 |\n|     128243 |  8424182.94 |\n|     156063 |  8422743.54 |\n|     195087 |  8421279.30 |\n|      67668 |  8417594.98 |\n|      49882 |  8417237.80 |\n|     105631 |  8412628.07 |\n|      40987 |  8406033.41 |\n|     185735 |  8404112.83 |\n|     173986 |  8403050.34 |\n|      87372 |  8402838.40 |\n|      24509 |  8398807.24 |\n|     180522 |  8394989.75 |\n|      76215 |  8394433.35 |\n|     193872 |  8390435.23 |\n|     141234 |  8390180.92 |\n|      91138 |  8386645.20 |\n|      28097 |  8385577.38 |\n|       4053 |  8384952.75 |\n|      17050 |  8380304.40 |\n|      64050 |  8377921.56 |\n|      80836 |  8375803.16 |\n|      86084 |  8373551.95 |\n|     168499 |  8373348.72 |\n|     178642 |  8372218.52 |\n|       8498 |  8370557.16 |\n|     156312 |  8366249.30 |\n|     136803 |  8361949.92 |\n|      92109 |  8359503.23 |\n|     138625 |  8358135.21 |\n|     137540 |  8358031.08 |\n|     176531 |  8355437.00 |\n|      53783 |  8352395.63 |\n|     106977 |  8352334.98 |\n|      21385 |  8351786.37 |\n|     114885 |  8351582.40 |\n|     113643 |  8350530.65 |\n|      89061 |  8349422.08 |\n|      77752 |  8348730.24 |\n|      28623 |  8348321.44 |\n|      74478 |  8348064.27 |\n|      41383 |  8347223.45 |\n|     147632 |  8346967.80 |\n|      40948 |  8346743.30 |\n|     154324 |  8346521.91 |\n|      89724 |  8346034.80 |\n|     119083 |  8338084.92 |\n|     124143 |  8335841.76 |\n|      80512 |  8335705.69 |\n|     105047 |  8332249.86 |\n|      38243 |  8329017.19 |\n|      42583 |  8328613.91 |\n|      44240 |  8327684.64 |\n|      57611 |  8321693.94 |\n|       9730 |  8319725.70 |\n|      91655 |  8318837.40 |\n|      13140 |  8316216.96 |\n|     112257 |  8315169.85 |\n|      27182 |  8314740.99 |\n|     166654 |  8314332.64 |\n|      40572 |  8312654.55 |\n|      26680 |  8311626.68 |\n|     138947 |  8311347.29 |\n|     184982 |  8310393.08 |\n|      35540 |  8308058.43 |\n|     181446 |  8304851.76 |\n|      65160 |  8299581.90 |\n|       9533 |  8299139.42 |\n|      67836 |  8294228.46 |\n|     159414 |  8293114.90 |\n|     115025 |  8291746.65 |\n|      30780 |  8291580.00 |\n|     164680 |  8290263.02 |\n|       4599 |  8288816.03 |\n|      73366 |  8286818.96 |\n|     135625 |  8284930.92 |\n|      46497 |  8284638.88 |\n|      63781 |  8284447.60 |\n|      84332 |  8283372.14 |\n|     196269 |  8276407.36 |\n|     166651 |  8275663.35 |\n|        142 |  8273960.31 |\n|      56904 |  8272891.44 |\n|      46821 |  8272603.71 |\n|      76051 |  8272300.75 |\n|      19666 |  8270192.64 |\n|      92723 |  8267074.20 |\n|     125843 |  8266816.38 |\n|     158722 |  8266634.88 |\n|      28941 |  8266245.12 |\n|      39968 |  8265605.53 |\n|      41429 |  8265317.84 |\n|      61601 |  8264074.31 |\n|     179159 |  8260137.47 |\n|      15969 |  8259835.96 |\n|     121125 |  8253912.49 |\n|      66486 |  8253743.66 |\n|     181031 |  8253570.14 |\n|      43712 |  8250825.78 |\n|      13842 |  8245765.00 |\n|      76203 |  8245412.16 |\n|      68992 |  8243081.46 |\n|     119704 |  8241363.06 |\n|      86109 |  8240377.92 |\n|      29534 |  8239914.00 |\n|      68596 |  8239825.29 |\n|     168291 |  8237626.32 |\n|     183308 |  8235947.21 |\n|      78657 |  8233481.64 |\n|     193545 |  8233037.49 |\n|      23658 |  8232306.18 |\n|     179945 |  8231365.25 |\n|      53391 |  8231252.10 |\n|      71380 |  8231125.68 |\n|      53666 |  8226715.00 |\n|     118592 |  8226181.00 |\n|      67203 |  8225355.99 |\n|       1178 |  8224625.05 |\n|     147876 |  8224189.62 |\n|      80042 |  8220826.70 |\n|      48950 |  8218611.22 |\n|      43331 |  8218448.04 |\n|     177706 |  8215723.50 |\n|     145442 |  8215706.16 |\n|     197042 |  8215536.00 |\n|     169952 |  8214698.43 |\n|      57907 |  8211740.04 |\n|     145741 |  8210316.57 |\n|      91144 |  8209855.02 |\n|     160266 |  8209468.80 |\n|      31602 |  8209366.90 |\n|      98672 |  8208412.85 |\n|     199012 |  8207897.50 |\n|     151148 |  8207645.16 |\n|     116545 |  8207573.24 |\n|     122176 |  8207508.04 |\n|      11021 |  8206766.10 |\n|      47752 |  8203436.82 |\n|        124 |  8203209.30 |\n|     148126 |  8202846.66 |\n|      15753 |  8202695.55 |\n|      50833 |  8200880.16 |\n|      11523 |  8196478.02 |\n|      71478 |  8195930.68 |\n|     129262 |  8190520.80 |\n|      43023 |  8186451.85 |\n|     119193 |  8184853.14 |\n|      85067 |  8182638.86 |\n|     164534 |  8181563.04 |\n|      82556 |  8180455.14 |\n|      31813 |  8179417.14 |\n|      81345 |  8173128.69 |\n|      38413 |  8172464.04 |\n|     106014 |  8171418.35 |\n|     191180 |  8170663.97 |\n|      43274 |  8169669.72 |\n|       5837 |  8166123.50 |\n|      63332 |  8161839.60 |\n|      47668 |  8161790.04 |\n|     112468 |  8160728.40 |\n|     132541 |  8160680.00 |\n|      59457 |  8160393.33 |\n|      71751 |  8159865.19 |\n|     118395 |  8156795.00 |\n|     132390 |  8154867.54 |\n|      44792 |  8153384.22 |\n|     128838 |  8153018.30 |\n|      87197 |  8152281.72 |\n|     187978 |  8150832.56 |\n|     147419 |  8150063.60 |\n|     149166 |  8149406.78 |\n|     196012 |  8147307.42 |\n|     190519 |  8145402.96 |\n|     151511 |  8144276.58 |\n|      88891 |  8140166.24 |\n|     168056 |  8139101.96 |\n|     189186 |  8136933.25 |\n|     117326 |  8136047.82 |\n|      60575 |  8133316.80 |\n|      75452 |  8130427.37 |\n|     194126 |  8129751.80 |\n|     130199 |  8129270.88 |\n|      41680 |  8128823.40 |\n|     107624 |  8125799.20 |\n|     135069 |  8123999.10 |\n|     119032 |  8123770.24 |\n|      27635 |  8123076.65 |\n|      14317 |  8121553.23 |\n|     148018 |  8119898.16 |\n|      51152 |  8118370.26 |\n|     112643 |  8117331.37 |\n|     119526 |  8116075.80 |\n|     192084 |  8114896.38 |\n|     151385 |  8114711.28 |\n|     160836 |  8112053.68 |\n|      91468 |  8111785.50 |\n|      58877 |  8108256.25 |\n|      41885 |  8107026.81 |\n|     155542 |  8106757.18 |\n|     149968 |  8104953.78 |\n|     168380 |  8103576.00 |\n|     134641 |  8101092.32 |\n|      92470 |  8100877.70 |\n|     113610 |  8098591.93 |\n|     198538 |  8097343.20 |\n|     122506 |  8096090.76 |\n|      29082 |  8093543.55 |\n|     161345 |  8093157.93 |\n|     105743 |  8093045.53 |\n|     103572 |  8091573.66 |\n|      59514 |  8089470.48 |\n|       8801 |  8088454.15 |\n|     129062 |  8088206.58 |\n|     155464 |  8086115.79 |\n|      86363 |  8082561.00 |\n|     180836 |  8082087.30 |\n|      92558 |  8081407.80 |\n|      85120 |  8073164.00 |\n|     149026 |  8072285.40 |\n|      51138 |  8072074.48 |\n|      36306 |  8071648.86 |\n|     102380 |  8070503.00 |\n|     147597 |  8069397.60 |\n|      41382 |  8059995.35 |\n|     121856 |  8059809.11 |\n|      86644 |  8058667.76 |\n|     108481 |  8058214.81 |\n|      41685 |  8057355.39 |\n|     175712 |  8054878.30 |\n|      72815 |  8052294.24 |\n|      58794 |  8047848.00 |\n|     118769 |  8047465.14 |\n|     157192 |  8046501.96 |\n|     195708 |  8045001.94 |\n|     163683 |  8044727.02 |\n|     189018 |  8043927.54 |\n|      62904 |  8043011.65 |\n|      80095 |  8042575.59 |\n|      90500 |  8042502.65 |\n|      73281 |  8040167.52 |\n|     150710 |  8035910.80 |\n|     139282 |  8034489.36 |\n|     172904 |  8033791.68 |\n|      38881 |  8032557.38 |\n|      53055 |  8030796.15 |\n|     105816 |  8025318.24 |\n|      88304 |  8024637.06 |\n|     115565 |  8023928.25 |\n|      55376 |  8021432.16 |\n|      56334 |  8019313.12 |\n|      58875 |  8016065.00 |\n|       4688 |  8012303.00 |\n|      49117 |  8009207.80 |\n|      57173 |  8008116.27 |\n|      48176 |  8006765.85 |\n|     112191 |  8003883.39 |\n|      33265 |  8002391.76 |\n|     181788 |  8002030.50 |\n|     172799 |  8001050.55 |\n|       2084 |  7999172.30 |\n|     174747 |  7997167.48 |\n|     171184 |  7996930.11 |\n|     113271 |  7992683.04 |\n|      68662 |  7991426.30 |\n|     179375 |  7991170.88 |\n|     188383 |  7990226.27 |\n|      50208 |  7989363.27 |\n|      23653 |  7988890.87 |\n|     159419 |  7988841.36 |\n|      74581 |  7987356.50 |\n|     133590 |  7986046.81 |\n|     195820 |  7985473.14 |\n|      87903 |  7983482.88 |\n|      69032 |  7981908.18 |\n|     113975 |  7980561.00 |\n|     178678 |  7975116.93 |\n|      52316 |  7973618.16 |\n|     135546 |  7972669.80 |\n|      89425 |  7970077.44 |\n|     115937 |  7966015.20 |\n|     151483 |  7964850.88 |\n|      73974 |  7964186.23 |\n|      39976 |  7964104.24 |\n|     130168 |  7961690.88 |\n|      58973 |  7957416.76 |\n|      16354 |  7956051.07 |\n|      23988 |  7955837.92 |\n|     138467 |  7955481.05 |\n|      26096 |  7955212.32 |\n|     192216 |  7953429.18 |\n|     112833 |  7952279.26 |\n|      60599 |  7951261.80 |\n|     129116 |  7948811.85 |\n|      79529 |  7947581.91 |\n|      71616 |  7944476.54 |\n|     136821 |  7942188.24 |\n|     116204 |  7941096.90 |\n|     165298 |  7939933.31 |\n|      44009 |  7939859.65 |\n|     194487 |  7938247.20 |\n|      11299 |  7938135.81 |\n|      76488 |  7935926.86 |\n|      58998 |  7934414.04 |\n|      25175 |  7931035.11 |\n|     136144 |  7929283.23 |\n|     132829 |  7926841.62 |\n|      84176 |  7925781.05 |\n|      68592 |  7922872.98 |\n|     139280 |  7922119.48 |\n|     160669 |  7921588.43 |\n|      42938 |  7917524.56 |\n|     183183 |  7915624.86 |\n|      95449 |  7914292.08 |\n|     115390 |  7912655.54 |\n|     173723 |  7911329.40 |\n|      48992 |  7911153.12 |\n|     173464 |  7910458.65 |\n|      26098 |  7910217.75 |\n|     141115 |  7909496.38 |\n|     195218 |  7906315.56 |\n|     116608 |  7906302.60 |\n|     163793 |  7905477.33 |\n|      10419 |  7904598.30 |\n|     106312 |  7901466.72 |\n|      48674 |  7901010.24 |\n|      35198 |  7899974.88 |\n|      88954 |  7899573.52 |\n|      41505 |  7897709.99 |\n|     115586 |  7897301.88 |\n|     167431 |  7895826.00 |\n|     158787 |  7894948.50 |\n|     161712 |  7893410.70 |\n|      46930 |  7892707.77 |\n|      58633 |  7892088.15 |\n|      10599 |  7892067.69 |\n|      99523 |  7891485.16 |\n|      70126 |  7890247.41 |\n|      32476 |  7890149.34 |\n|     152617 |  7890136.50 |\n|     162639 |  7889822.70 |\n|      82056 |  7889345.05 |\n|     186450 |  7887873.56 |\n|      39082 |  7886019.89 |\n|     183217 |  7885948.48 |\n|     192551 |  7884432.48 |\n|     164801 |  7882870.10 |\n|     112804 |  7882772.00 |\n|       5956 |  7878805.04 |\n|      73054 |  7878479.63 |\n|      62593 |  7878401.44 |\n|     137687 |  7873755.91 |\n|      80526 |  7871839.50 |\n|     195354 |  7869617.75 |\n|       4122 |  7867967.09 |\n|       4057 |  7865176.80 |\n|      63195 |  7864322.16 |\n|     143370 |  7863444.54 |\n|      41473 |  7862926.89 |\n|     155060 |  7860900.96 |\n|      76875 |  7858529.64 |\n|     135778 |  7857660.51 |\n|      30534 |  7855226.08 |\n|      99405 |  7853410.95 |\n|     161551 |  7852244.40 |\n|     185034 |  7850752.00 |\n|      17264 |  7850704.88 |\n|      23652 |  7848909.16 |\n|     123681 |  7848265.36 |\n|     186170 |  7845527.50 |\n|      81496 |  7840427.40 |\n|      25407 |  7840234.72 |\n|      96662 |  7839907.41 |\n|     156407 |  7839647.75 |\n|     165843 |  7839562.80 |\n|     153361 |  7838813.07 |\n|     149362 |  7838282.52 |\n|      46057 |  7835709.81 |\n|     114341 |  7835492.25 |\n|     154823 |  7834898.61 |\n|     139538 |  7834690.64 |\n|      42853 |  7833252.60 |\n|     177659 |  7831803.58 |\n|      29158 |  7829880.80 |\n|      85583 |  7825996.64 |\n|     165714 |  7825006.46 |\n|      58662 |  7821977.76 |\n|     185839 |  7821640.74 |\n|      93559 |  7821137.52 |\n|      58481 |  7818648.16 |\n|     162217 |  7817923.47 |\n|     130014 |  7815929.34 |\n|     125640 |  7815262.90 |\n|      83723 |  7815021.48 |\n|      54314 |  7813732.94 |\n|     146652 |  7809817.39 |\n|     189256 |  7808972.00 |\n|      87994 |  7808660.48 |\n|     157067 |  7806217.25 |\n|      56859 |  7805947.60 |\n|     118132 |  7804423.69 |\n|     189457 |  7802777.91 |\n|       1509 |  7802315.42 |\n|     129101 |  7801994.70 |\n|     162285 |  7801859.52 |\n|     182358 |  7801430.46 |\n|       6288 |  7800363.30 |\n|      68972 |  7799224.95 |\n|      51684 |  7795455.46 |\n|     148645 |  7794585.92 |\n|      94359 |  7794358.92 |\n|      40451 |  7791437.70 |\n|      44019 |  7790053.76 |\n|      81470 |  7788716.85 |\n|      12731 |  7786998.38 |\n|     114393 |  7784963.34 |\n|      69323 |  7783583.08 |\n|     169794 |  7780968.30 |\n|      25378 |  7778569.60 |\n|     104509 |  7777137.62 |\n|      81874 |  7775216.80 |\n|      70859 |  7771185.07 |\n|     135768 |  7769704.84 |\n|     181960 |  7768847.90 |\n|      28481 |  7768516.61 |\n|     191604 |  7765367.68 |\n|        754 |  7762507.02 |\n|     127702 |  7761776.05 |\n|      36488 |  7761744.00 |\n|     183906 |  7759864.80 |\n|      90365 |  7759602.50 |\n|      60725 |  7759495.78 |\n|      69436 |  7759033.52 |\n|      12963 |  7756623.52 |\n|      64571 |  7755731.04 |\n|     160111 |  7753787.70 |\n|     107970 |  7753735.88 |\n|     132036 |  7753401.36 |\n|      79965 |  7748656.15 |\n|     149862 |  7747239.10 |\n|      73218 |  7745499.42 |\n|     161036 |  7742807.45 |\n|     152467 |  7742471.40 |\n|     163358 |  7742034.00 |\n|     197951 |  7741768.84 |\n|      15820 |  7740003.00 |\n|      31444 |  7739519.60 |\n|     151208 |  7738273.85 |\n|      20410 |  7737192.99 |\n|      45462 |  7736792.55 |\n|     128966 |  7736467.65 |\n|     118945 |  7735275.00 |\n|     106458 |  7734069.72 |\n|     162706 |  7730189.88 |\n|      70528 |  7730088.25 |\n|     107998 |  7728273.45 |\n|     163110 |  7728042.40 |\n|      74591 |  7727297.76 |\n|     121454 |  7726200.56 |\n|     181252 |  7724464.38 |\n|      29154 |  7724129.66 |\n|      63854 |  7720353.88 |\n|      34157 |  7719803.30 |\n|      30684 |  7718307.84 |\n|       3985 |  7715042.96 |\n|      29387 |  7714858.80 |\n|     184703 |  7712545.12 |\n|     124679 |  7712528.72 |\n|      15606 |  7710658.46 |\n|     123814 |  7709872.95 |\n|      83760 |  7709633.92 |\n|      22084 |  7707219.79 |\n|     123210 |  7706030.42 |\n|      75066 |  7704727.51 |\n|      16337 |  7704517.80 |\n|      47109 |  7704111.51 |\n|       8232 |  7702887.50 |\n|      11222 |  7702535.62 |\n|      84961 |  7701923.72 |\n|     157118 |  7700132.88 |\n|     118362 |  7699210.20 |\n|     193755 |  7698545.20 |\n|       1520 |  7697759.37 |\n|     114599 |  7697377.50 |\n|     168842 |  7696152.00 |\n|     172245 |  7694286.06 |\n|       4584 |  7693352.79 |\n|     113651 |  7689659.67 |\n|     183207 |  7687955.66 |\n|     175802 |  7686604.70 |\n|      59066 |  7685120.43 |\n|     130726 |  7684159.25 |\n|      89672 |  7684049.50 |\n|       7224 |  7683446.40 |\n|      97533 |  7680694.62 |\n|      59941 |  7680100.80 |\n|      29298 |  7676823.42 |\n|     163962 |  7675924.96 |\n|      41086 |  7674518.14 |\n|     185483 |  7673376.60 |\n|     165010 |  7672469.70 |\n|       3708 |  7671744.18 |\n|     192994 |  7671712.00 |\n|      79968 |  7668060.48 |\n|     118494 |  7666659.00 |\n|      59236 |  7666625.98 |\n|     149509 |  7665930.67 |\n|       3793 |  7664981.28 |\n|      28979 |  7664632.93 |\n|     178389 |  7662544.96 |\n|      65315 |  7661085.88 |\n|      59710 |  7657442.00 |\n|     170276 |  7656813.89 |\n|     182707 |  7656387.06 |\n|     129170 |  7655820.48 |\n|      59765 |  7655009.92 |\n|      23337 |  7654271.94 |\n|      90396 |  7653568.35 |\n|      68842 |  7652742.72 |\n|      16315 |  7652630.70 |\n|        956 |  7652174.81 |\n|      10639 |  7651375.80 |\n|     112886 |  7649534.08 |\n|       9561 |  7648502.73 |\n|      65484 |  7647789.30 |\n|      68677 |  7646879.14 |\n|     196529 |  7645482.24 |\n|       6556 |  7642116.06 |\n|       9113 |  7640163.68 |\n|     128139 |  7638760.00 |\n|     143264 |  7635499.56 |\n|      21569 |  7634785.86 |\n|     193402 |  7633576.06 |\n|      35545 |  7632210.69 |\n|      65068 |  7632188.76 |\n|      25515 |  7630952.93 |\n|     180189 |  7630887.10 |\n|     131680 |  7629593.64 |\n|      80162 |  7629440.93 |\n|     139054 |  7629417.37 |\n|       8028 |  7629134.04 |\n|      76804 |  7626731.00 |\n|      74179 |  7624974.03 |\n|     122507 |  7623903.87 |\n|     141889 |  7623552.30 |\n|     184279 |  7623048.17 |\n|       8076 |  7620897.81 |\n|     192681 |  7619802.09 |\n|      21398 |  7617942.52 |\n|      14825 |  7617843.60 |\n|      17969 |  7617524.64 |\n|     170764 |  7616119.96 |\n|     115303 |  7615914.17 |\n|      67708 |  7615306.08 |\n|      33317 |  7613417.24 |\n|     190782 |  7613203.42 |\n|     113818 |  7612852.48 |\n|     178091 |  7611457.30 |\n|      87603 |  7611343.68 |\n|     108317 |  7610509.71 |\n|     106552 |  7609868.84 |\n|      28679 |  7609292.20 |\n|     192350 |  7609140.81 |\n|     154801 |  7607944.38 |\n|       5768 |  7607785.68 |\n|     127689 |  7606313.94 |\n|      62847 |  7605651.45 |\n|     111212 |  7605052.00 |\n|     156065 |  7603327.60 |\n|     115140 |  7601161.68 |\n|      19597 |  7601153.46 |\n|      55233 |  7600940.23 |\n|      89353 |  7600929.84 |\n|      75701 |  7600492.60 |\n|      64974 |  7599754.80 |\n|     116156 |  7597452.48 |\n|      59491 |  7596352.84 |\n|       6138 |  7594861.54 |\n|      62317 |  7594854.10 |\n|     106575 |  7594520.08 |\n|     161092 |  7594454.40 |\n|       9872 |  7593734.34 |\n|      77711 |  7593431.60 |\n|      61206 |  7593153.00 |\n|     123776 |  7592736.80 |\n|     185141 |  7592617.12 |\n|       5542 |  7592513.04 |\n|     185296 |  7591439.31 |\n|      72597 |  7591142.40 |\n+------------+-------------+\n1225 rows in set\n\nQ12\n+------------+-----------------+----------------+\n| l_shipmode | high_line_count | low_line_count |\n+------------+-----------------+----------------+\n| FOB        |            6273 |           9429 |\n| TRUCK      |            6336 |           9300 |\n+------------+-----------------+----------------+\n\nQ13\n+---------+----------+\n| c_count | custdist |\n+---------+----------+\n|       0 |    50005 |\n|      10 |     6574 |\n|       9 |     6554 |\n|      11 |     6072 |\n|       8 |     5934 |\n|      12 |     5598 |\n|      13 |     5032 |\n|      19 |     4685 |\n|       7 |     4663 |\n|      20 |     4607 |\n|      17 |     4550 |\n|      18 |     4515 |\n|      14 |     4480 |\n|      15 |     4476 |\n|      16 |     4341 |\n|      21 |     4176 |\n|      22 |     3710 |\n|       6 |     3303 |\n|      23 |     3172 |\n|      24 |     2670 |\n|      25 |     2111 |\n|       5 |     1954 |\n|      26 |     1605 |\n|      27 |     1195 |\n|       4 |     1030 |\n|      28 |      898 |\n|      29 |      620 |\n|       3 |      408 |\n|      30 |      353 |\n|      31 |      225 |\n|      32 |      135 |\n|       2 |      128 |\n|      33 |       82 |\n|      34 |       54 |\n|      35 |       33 |\n|       1 |       18 |\n|      36 |       17 |\n|      37 |        7 |\n|      41 |        3 |\n|      40 |        3 |\n|      38 |        3 |\n|      39 |        1 |\n+---------+----------+\n42 rows in set\n\n\nQ14\n+-------------------+\n| promo_revenue     |\n+-------------------+\n| 16.65118731292792 |\n+-------------------+\n\nQ15\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n| s_suppkey | s_name             | s_address                        | s_phone         | total_revenue |\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n|      7895 | Supplier#000007895 | NYl,i8UhxTykLxGJ2voIRn20Ugk1KTzz | 14-559-808-3306 |  1678635.2636 |\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n\n\nQ16\n+----------+---------------------------+--------+--------------+\n| p_brand  | p_type                    | p_size | supplier_cnt |\n+----------+---------------------------+--------+--------------+\n| Brand#55 | LARGE BURNISHED TIN       |     21 |           36 |\n| Brand#25 | PROMO BRUSHED STEEL       |     24 |           28 |\n| Brand#54 | STANDARD BRUSHED COPPER   |     14 |           27 |\n| Brand#12 | MEDIUM PLATED BRASS       |     21 |           24 |\n| Brand#14 | ECONOMY PLATED TIN        |     33 |           24 |\n| Brand#24 | ECONOMY PLATED TIN        |     33 |           24 |\n| Brand#25 | MEDIUM PLATED STEEL       |     35 |           24 |\n| Brand#32 | MEDIUM POLISHED COPPER    |     20 |           24 |\n| Brand#32 | SMALL ANODIZED BRASS      |      7 |           24 |\n| Brand#33 | ECONOMY PLATED STEEL      |      7 |           24 |\n| Brand#33 | MEDIUM PLATED COPPER      |     20 |           24 |\n| Brand#33 | PROMO POLISHED STEEL      |     14 |           24 |\n...\n| Brand#31 | PROMO ANODIZED COPPER     |     20 |            3 |\n| Brand#41 | LARGE BURNISHED STEEL     |     20 |            3 |\n| Brand#43 | SMALL BRUSHED COPPER      |      7 |            3 |\n| Brand#52 | MEDIUM POLISHED BRASS     |     21 |            3 |\n| Brand#52 | SMALL POLISHED TIN        |      2 |            3 |\n+----------+---------------------------+--------+--------------+\n18341 rows in set\n\nQ17\n+-------------------+\n| avg_yearly        |\n+-------------------+\n| 348406.0542857143 |\n+-------------------+\n\nQ18\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n| c_name             | c_custkey | o_orderkey | o_orderdate | o_totalprice | sum(l_quantity) |\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n| Customer#000128120 |    128120 |    4722021 | 1994-04-07  |    544089.09 |          323.00 |\n| Customer#000144617 |    144617 |    3043270 | 1997-02-12  |    530604.44 |          317.00 |\n| Customer#000066790 |     66790 |    2199712 | 1996-09-30  |    515531.82 |          327.00 |\n| Customer#000015619 |     15619 |    3767271 | 1996-08-07  |    480083.96 |          318.00 |\n| Customer#000147197 |    147197 |    1263015 | 1997-02-02  |    467149.67 |          320.00 |\n| Customer#000117919 |    117919 |    2869152 | 1996-06-20  |    456815.92 |          317.00 |\n| Customer#000126865 |    126865 |    4702759 | 1994-11-07  |    447606.65 |          320.00 |\n| Customer#000036619 |     36619 |    4806726 | 1995-01-17  |    446704.09 |          328.00 |\n| Customer#000119989 |    119989 |    1544643 | 1997-09-20  |    434568.25 |          320.00 |\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n9 rows in set\n\nQ19\n+--------------+\n| revenue      |\n+--------------+\n| 3083843.0578 |\n+--------------+\n\nQ20\n+--------------------+------------------------------------------+\n| s_name             | s_address                                |\n+--------------------+------------------------------------------+\n| Supplier#000000035 | QymmGXxjVVQ5OuABCXVVsu,4eF gU0Qc6        |\n| Supplier#000000068 | Ue6N50wH2CwE4PPgTGLmat,ibGYYlDoOb3xQwtgb |\n| Supplier#000000080 | cJ2MHSEJ13rIL2Wj3D5i6hRo30,ZiNUXhqn      |\n| Supplier#000000100 | rIlN li8zvW22l2slbcx ECP4fL              |\n| Supplier#000000274 | usxbl9KSW41DTE6FAglxHU                   |\n| Supplier#000000406 | zMhU58CDF4aHTeodxg9IgRZgq                |\n| Supplier#000000444 | mHr2VcUpRkvyQ9rjKMaPkeWbVZmEIhxhb8F      |\n| Supplier#000000453 | bpt98PxU5HSQt61bVB695JPjBmJKUv hNzQeHvC  |\n| Supplier#000000458 | IFNkUK1H53HwUHabiONkMFAUDb               |\n| Supplier#000000622 | gCQimU1jYHoQiglDmW1FkQM9wzi YC1P15pMy1   |\n| Supplier#000000713 | DBMIf1HiYY8OyRFcbtHpKIz                  |\n| Supplier#000000767 | bHEuqKKdmCMEKOV                          |\n| Supplier#000000776 | nklfFoSkCwf,ooSuF                        |\n| Supplier#000000823 |  gC0DrEG5U,v893fp3nj mmXa6rYhJ0tjpJ      |\n| Supplier#000000828 | 0B2aPqJ6KTEr2fqxuC7z                     |\n| Supplier#000000941 | gqG2XEnVlzUhjjfQGYGlwk,jcaNsplI8Rleg     |\n| Supplier#000000973 | 5 nhBZ 03rG6EcOEDkZXvt                   |\n| Supplier#000000984 | 6H6qqye iYbYzCmwWhj                      |\n| Supplier#000001149 | Nuno37wiZOjNGHF                          |\n| Supplier#000001201 | Seh4D7pi9UdK,XQkF46A0O2N                 |\n| Supplier#000001309 | 72RNUzKzbniUnnsSs24ZzGDvmcv2Pd           |\n| Supplier#000001344 | 6iF,zVDNTykohVKcb7FKvn82s74ez            |\n| Supplier#000001351 | zXdoBMmmRx1wOD7GKoHHBtemXGuYKLDb,U2KP    |\n| Supplier#000001391 | hkWoAM561QlLjBNk,SdFdIgFx                |\n| Supplier#000001481 | ARqVvJHMxBNKl2LrfPsR  Wq9ZUXh,14         |\n| Supplier#000001584 | gJbTkijteJxSMLmdzBSzeMAH                 |\n| Supplier#000001651 | 6rJNoWL9YL                               |\n| Supplier#000001710 | J,sdOOJwUhwPv2mrEiNEA0UZlmu5IRmgz        |\n| Supplier#000001755 | QstBVfnY,93NsbWXCqO                      |\n| Supplier#000001869 | nogoCdaFQii,ri9rs3P8f5rPt1wVOMw9I7TmypxK |\n| Supplier#000001895 | lywAGDbk37fYPDS                          |\n| Supplier#000001910 | vih,zrhclXX1O9x                          |\n| Supplier#000001930 | 2jCSw3KOLHol7y5omVO13                    |\n| Supplier#000001979 | UNW7nA,IC 5igvVsgUHA7OaLL,jOzUcT         |\n| Supplier#000002046 | BiTDgHknmvQGT6FpZXfRX,xlnR               |\n| Supplier#000002071 | zLH3QAtZuuOq8AoVNM                       |\n| Supplier#000002270 | HIscbvhw8N94djn,3UbPaY4R                 |\n| Supplier#000002350 | TWsO2iJGOl7v3vSwiscXp6X                  |\n| Supplier#000002409 | oy39SaSQ,FIP pzLqblhxj                   |\n| Supplier#000002520 | 5y55UzYQKByZP3                           |\n| Supplier#000002618 | 3UtbE1kKm29kKyx09hSEBMhRLM               |\n| Supplier#000002643 | eDN6YjGtp2dcj0IF,BKEEYjElO,sUjjcNI       |\n| Supplier#000002649 | agDQi9iCt1cUaS                           |\n| Supplier#000002655 | i6v8dkQBuK0NSCeqQCE8                     |\n| Supplier#000002812 | Q9sO3wZkBU5QBe0VITRWShv                  |\n| Supplier#000002888 | 3AtRoxBFh6HIBa9kdBX,6,Ml2SZGUA           |\n| Supplier#000002910 | nlH1gjApxHkQe5SU4iVZwi2xWk88wwhTWRkSvOBB |\n| Supplier#000002914 | fUC4IkGB8pt1S                            |\n| Supplier#000003000 | JtDvRf4iWHJkj54PYxl                      |\n| Supplier#000003011 | vfL mV0MTdyozfRIPZkJbM1Z7Lcm2NCPIj6qSgBz |\n| Supplier#000003038 | F5Tz7P juuCbABDuW8JGomRFxqVHBWyQrsLwg4i  |\n| Supplier#000003150 | XwSjsmzEnANK,wAQUp4Xf5xJDqR              |\n| Supplier#000003305 | GLZJimfuzKoQcqcv4                        |\n| Supplier#000003394 | R6D7n3WrQjWNGSQTb7eN ,X0oCMkhyuTHBOSPw   |\n| Supplier#000003452 | 7tMycIKhE,pe4OL3Du                       |\n| Supplier#000003666 | ENS fE9iSrSzw,iTwA,zGorkflw              |\n| Supplier#000003698 | lnSEu64ca4B53BfznJPg                     |\n| Supplier#000003773 | UWjSotAjkAD                              |\n| Supplier#000003837 | SYXpXaKop3                               |\n| Supplier#000003846 | wl076KfcEpYLRegb1LfIf93b3n5HBabFK2R,mEM  |\n| Supplier#000003862 | 0XXFhF1IDBh                              |\n| Supplier#000003868 | 5aP4VBn0t666NbGYB                        |\n| Supplier#000003880 | DZo80mSznrhCpb8                          |\n| Supplier#000003955 | piECPB8qbn7s3XP                          |\n| Supplier#000004007 | cvlSgCCKGOwpaB iFIPx4vU2qA5b6K hz9Z91    |\n| Supplier#000004066 | TNBnJFDScUmsjBy6pSWTS sfMg9jpfKx         |\n| Supplier#000004127 | EduKm3NcCc75Cd                           |\n| Supplier#000004174 | Bk97olQYwXmjYdQjwyt N                    |\n| Supplier#000004328 | euddbWZRcVMD3W                           |\n| Supplier#000004341 | ea8KZYvO7amq8A                           |\n| Supplier#000004360 | w 7kM5J,fqjiqBu4SU0UPEDqspaUEm           |\n| Supplier#000004375 | Cmr952zcJJuW0xAYc0W0MA7N6vMcCjy          |\n| Supplier#000004391 | pcsiJBhSEHuFHNAxR3K c                    |\n| Supplier#000004398 | khZZ0CmLip49Zncec                        |\n| Supplier#000004402 | acagGfDWzwmS,,WVBsszubFs3LOA8rDRS0I      |\n| Supplier#000004714 | IKRla2xArMmR4p3Mbn8JV8g0                 |\n| Supplier#000004717 | H,Suh5pN230Ol,ggx0QEh3rrvzyQsq050Lat     |\n| Supplier#000004740 | yM0TXkhfjpObafbQhuWU                     |\n| Supplier#000004763 | W 7kS9LLh4ZgLpk2                         |\n| Supplier#000004837 | tYHMZS4XlJjzvj34mH2PCoj                  |\n| Supplier#000004882 | e,V Bo1KZEt                              |\n| Supplier#000004913 | em,yC41xEl Fst9LwEik                     |\n| Supplier#000005005 | K6 GI4WzmbsGEOh                          |\n| Supplier#000005238 | jmtI76 8RNG8Z2BZu                        |\n| Supplier#000005289 | 62XeOur9SnXgbdjGwb9E1aJIEBr5PA9          |\n| Supplier#000005317 | lPOPHufNjwZaUJGVNHCC2DE FYQcKZBzHltL5    |\n| Supplier#000005401 | eEOlCEAaIfVexStlrgTuzwQx7vjPF6ZT dm      |\n| Supplier#000005449 | fhc8lUuZdqWUujcVaWogowEq1WVL9Y8m1efwCl3G |\n| Supplier#000005472 | LlyLSmvY9GFvMN4QhHzMokW0k5d              |\n| Supplier#000005572 | o0VYozeSbEyqck                           |\n| Supplier#000005579 | ACVEMP4IwRf                              |\n| Supplier#000005661 | pq5wuxmkIW0DyWU                          |\n| Supplier#000005676 | HInJHZisl5svSU1oKsr                      |\n| Supplier#000005815 | S6cu6cspYxHlTz2                          |\n| Supplier#000005835 | rYoXzV3EZ77Z                             |\n| Supplier#000006103 | l32l8iaPdbHgRXoq,kdjFAj3hZk2d            |\n| Supplier#000006173 | hBdratcVfL4LpWxsEpCRP g0AksN0CDhBZ       |\n| Supplier#000006226 | CKuDyeGAxPHeRHwC4a                       |\n| Supplier#000006254 | g7OY1vWNUb1vxIRgEl                       |\n| Supplier#000006348 | f2KDn2rLnadX8I DZR                       |\n| Supplier#000006359 | QyUuVHYBp8sTd7Y9WveNfsz                  |\n| Supplier#000006430 | F2RrkeaNcs6po8x2PyYvcPa1rtKd,fT2AMxP     |\n| Supplier#000006516 | 89XwFOC,hLRxGq5rL0txv0EM9F               |\n| Supplier#000006700 | BWjerJH5kbEPu 8h9                        |\n| Supplier#000006785 | lyo6PpwulTeN9ZfIkvWag5NucL,XMC  89Kn7U   |\n| Supplier#000006998 | r2i3HfkSQh9dvho, NpoabdMsPBG             |\n| Supplier#000007019 | 2GQsALzRiTt2BQum6bocdeGawkOrsjNIZ        |\n| Supplier#000007114 | s9s4YLeLWo7fLRO3rdQKFfUnZhrZUPjOC        |\n| Supplier#000007170 | 9vABqu hZaciXSCQrbTj                     |\n| Supplier#000007171 | DXerxFIhNRpqF9dWNRw hDOlLX gEJFxh0       |\n| Supplier#000007213 | 2Nrby3JJHDJyWwVNiqPtm2U JGWlZpU          |\n| Supplier#000007219 | p5Ui3IGPcmotYu                           |\n| Supplier#000007229 | iwNoWdaURFzLAsQHxK,BeOPpI5TOTo           |\n| Supplier#000007263 | malQPdYc8xiup2MiFuKHa                    |\n| Supplier#000007270 | TksERECGdYZRPUjkUdDRZv5pW26cOTaA1        |\n| Supplier#000007276 | Vi9,aBg2ychZf                            |\n| Supplier#000007334 | NPXYWdJ8L9EDr20tw9CZQsEMqXlgXzI2JC Y     |\n| Supplier#000007400 | 7r9zZj8J,,hN2GRfWtDxzuGa                 |\n| Supplier#000007442 | DzycM1,T6kh2EutfPeFpv0Ro                 |\n| Supplier#000007456 | ITYEeccPVJi0HvnAwVs2Z                    |\n| Supplier#000007559 | Wmzx1vskciC                              |\n| Supplier#000007677 | OoTYQdxQyd7NukSaSRv                      |\n| Supplier#000007712 | DyTQD 3ajuOtHQTpI4LsWSF kSd2SE6U4COgYHQ  |\n| Supplier#000007715 | gZHd7Yzbtv7yb7DYCCAQPJH8FRHTqi6T4w       |\n| Supplier#000007816 | 1ejcJ545bwLWLuY6Qq4qyEExZIsp0SG          |\n| Supplier#000007845 | agwGVTzLyRKOsZxLVi,mPWZ08Qxb             |\n| Supplier#000007875 | E0CkoBYngcIoH                            |\n| Supplier#000007908 | ghhHapj7GK                               |\n| Supplier#000007972 | WW0GuiWP2N3kUo4f                         |\n| Supplier#000008162 | XASpbn08mRV0kgHRmUSKx                    |\n| Supplier#000008235 | TjVWq6bTdGJB                             |\n| Supplier#000008249 | PwUjvlMk y72zaMRtZQ8trbCmu4j             |\n| Supplier#000008309 | 6P,FQbW6sJouqunvttVO6vEeY                |\n| Supplier#000008339 | uWw8 P6u,S                               |\n| Supplier#000008343 |  BbHngAVqj0J8                            |\n| Supplier#000008349 | 8Hkx1IDd0mZCTX                           |\n| Supplier#000008377 | ,Yk0mflw2LqQCTxMYR sU2juj5DorUAG4w6i     |\n| Supplier#000008468 | 5R4jsweitleustYlE3w,u5otW                |\n| Supplier#000008523 | C4ocdfNu5I2nnnVG2xSd3016J6KNLIg          |\n| Supplier#000008580 | t5ri71bM6Sox3riP4JUZsMMNC                |\n| Supplier#000008638 | yxj50B 8aMql                             |\n| Supplier#000008642 | qnN9N9du9Dg2arf6kjD xW0DjMT9cM           |\n| Supplier#000008651 | pfw32RGA7BPXrUiavYqE                     |\n| Supplier#000008679 | JWFVoSsCwn9p8o                           |\n| Supplier#000008704 | a6DjHp0B6mifKBtqUk,C                     |\n| Supplier#000008737 | MsdGxF9Xoq9 8s                           |\n| Supplier#000008820 | uAsBvPBNsEsO                             |\n| Supplier#000008829 | lNcY7xNLDonCw TuRYL                      |\n| Supplier#000008947 | 1Ij3T0egGHnVbLich98HzY,UeCdVbxzYa ZpKDVc |\n| Supplier#000008964 | U2YJW,Y1xCbUWbjuovtzsLfsl                |\n| Supplier#000008974 | 4JCXOJ3MyPfa51mIf,MQu                    |\n| Supplier#000008997 | KY MmMEcyQ6FEDCooFj xa uCwF2GbaeA8       |\n| Supplier#000009065 | ZELuiqWrWbJV9zAuco1OnXKTJClhR            |\n| Supplier#000009114 | nkn6bcPvlP5w,lUpO0nZTBSj                 |\n| Supplier#000009125 | IQbCXbN1mmght                            |\n| Supplier#000009131 | gDBXgWtg4rTxu0WUJhhV                     |\n| Supplier#000009149 | yKX,bKryD6YtvF,cVLIKC0Z6rN               |\n| Supplier#000009182 | z56kNgeqaWQ1kHFBp                        |\n| Supplier#000009220 | N4y,vP kdArpcmdypBh,fJVVB                |\n| Supplier#000009226 | yzT10vNTFJ                               |\n| Supplier#000009288 |  251AA4ziZ3d7TTWXLGnXjb4BnXv             |\n| Supplier#000009360 | 1NVjjX8zMjyBX2UapDTP0Sz                  |\n| Supplier#000009381 | rhCTm7QehIznqd8 Np7VT,H5J5zSGr           |\n| Supplier#000009403 | 70841REghyWBrHyyg762Jh4sjCG7CKaIc        |\n| Supplier#000009504 | Rqt07,ANI92kj1oU                         |\n| Supplier#000009598 | PnTAz7rNRLVDFO3zoo2QRTlh4o               |\n| Supplier#000009609 | LV2rJUGfr0k3dPNRqufG1IoYHzV              |\n| Supplier#000009619 | K0RwcJ9S75Xil jqKukFoDNkD                |\n| Supplier#000009626 | Nm1FnIh4asUR3EnXv2Pvy3gXqI9es            |\n| Supplier#000009738 | 15RRSVTuOzwdMP LmfCtIguMGXK              |\n| Supplier#000009770 | Ag, SZfowit580QPDdbP8kmFHdpZ9ASI         |\n| Supplier#000009865 | extcOh9ZrdDCMsHhhsFTkTUAh,HM2UQ2qa8sRo   |\n| Supplier#000009866 | Auh6aZnOnQG1pPYKZ5o9ATramJBA             |\n| Supplier#000009890 | izJXemCM Ikpgxk                          |\n| Supplier#000009937 | edZ9HQJ0KJAU6EWknTiDghKfRLHq6vtFqdey,0l  |\n| Supplier#000009954 | VzElx9ihlXFJLIQw2Hn4bC2                  |\n| Supplier#000009958 | ggiiSA4CSyvhwQUYjdJhWlKEY9PAfs           |\n+--------------------+------------------------------------------+\n177 rows in set\n\n\nQ21\n+--------------------+---------+\n| s_name             | numwait |\n+--------------------+---------+\n| Supplier#000009302 |      21 |\n| Supplier#000000342 |      20 |\n| Supplier#000000632 |      19 |\n| Supplier#000002196 |      19 |\n| Supplier#000003325 |      18 |\n| Supplier#000003915 |      18 |\n| Supplier#000005045 |      18 |\n| Supplier#000006442 |      18 |\n| Supplier#000003093 |      17 |\n| Supplier#000004498 |      17 |\n| Supplier#000000906 |      16 |\n| Supplier#000001183 |      16 |\n| Supplier#000001477 |      16 |\n| Supplier#000006043 |      16 |\n| Supplier#000000689 |      15 |\n| Supplier#000001955 |      15 |\n| Supplier#000002066 |      15 |\n| Supplier#000002146 |      15 |\n| Supplier#000003253 |      15 |\n| Supplier#000003527 |      15 |\n| Supplier#000003947 |      15 |\n| Supplier#000004915 |      15 |\n| Supplier#000005248 |      15 |\n| Supplier#000006718 |      15 |\n| Supplier#000007773 |      15 |\n| Supplier#000008121 |      15 |\n| Supplier#000008169 |      15 |\n| Supplier#000008645 |      15 |\n| Supplier#000008684 |      15 |\n| Supplier#000009079 |      15 |\n| Supplier#000009956 |      15 |\n| Supplier#000000737 |      14 |\n| Supplier#000000775 |      14 |\n| Supplier#000001474 |      14 |\n| Supplier#000001502 |      14 |\n| Supplier#000003196 |      14 |\n| Supplier#000004415 |      14 |\n| Supplier#000004940 |      14 |\n| Supplier#000005253 |      14 |\n| Supplier#000005703 |      14 |\n| Supplier#000006308 |      14 |\n| Supplier#000006789 |      14 |\n| Supplier#000007161 |      14 |\n| Supplier#000007952 |      14 |\n| Supplier#000008062 |      14 |\n| Supplier#000008414 |      14 |\n| Supplier#000008442 |      14 |\n| Supplier#000008508 |      14 |\n| Supplier#000000300 |      13 |\n| Supplier#000000727 |      13 |\n| Supplier#000000921 |      13 |\n| Supplier#000000992 |      13 |\n| Supplier#000001282 |      13 |\n| Supplier#000001582 |      13 |\n| Supplier#000001662 |      13 |\n| Supplier#000001683 |      13 |\n| Supplier#000002933 |      13 |\n| Supplier#000003177 |      13 |\n| Supplier#000003428 |      13 |\n| Supplier#000003640 |      13 |\n| Supplier#000004842 |      13 |\n| Supplier#000004951 |      13 |\n| Supplier#000005795 |      13 |\n| Supplier#000005981 |      13 |\n| Supplier#000006118 |      13 |\n| Supplier#000006433 |      13 |\n| Supplier#000006484 |      13 |\n| Supplier#000007268 |      13 |\n| Supplier#000008599 |      13 |\n| Supplier#000008675 |      13 |\n| Supplier#000009474 |      13 |\n| Supplier#000009521 |      13 |\n| Supplier#000009853 |      13 |\n| Supplier#000000021 |      12 |\n| Supplier#000000211 |      12 |\n| Supplier#000000743 |      12 |\n| Supplier#000000951 |      12 |\n| Supplier#000001654 |      12 |\n| Supplier#000001868 |      12 |\n| Supplier#000002089 |      12 |\n| Supplier#000002879 |      12 |\n| Supplier#000003060 |      12 |\n| Supplier#000003215 |      12 |\n| Supplier#000003365 |      12 |\n| Supplier#000003873 |      12 |\n| Supplier#000003985 |      12 |\n| Supplier#000004452 |      12 |\n| Supplier#000004639 |      12 |\n| Supplier#000005122 |      12 |\n| Supplier#000005633 |      12 |\n| Supplier#000005671 |      12 |\n| Supplier#000005782 |      12 |\n| Supplier#000006088 |      12 |\n| Supplier#000006477 |      12 |\n| Supplier#000006508 |      12 |\n| Supplier#000006750 |      12 |\n| Supplier#000006802 |      12 |\n| Supplier#000008236 |      12 |\n| Supplier#000009294 |      12 |\n| Supplier#000009329 |      12 |\n+--------------------+---------+\n100 rows in set\n\nQ22\n+-----------+---------+------------+\n| cntrycode | numcust | totacctbal |\n+-----------+---------+------------+\n| 10        |     882 | 6606081.31 |\n| 11        |     899 | 6702253.34 |\n| 19        |     963 | 7230776.82 |\n| 20        |     916 | 6824676.02 |\n| 22        |     894 | 6636740.03 |\n| 26        |     861 | 6404695.86 |\n| 27        |     877 | 6565078.99 |\n+-----------+---------+------------+\n7 rows in set\n
      "},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/","title":"MO-Tester Specification","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#case-specifications","title":"Case specifications","text":"Specification Description File name 1. Use .sql or .test as the suffix.2. The file name has a practical meaning. For example, if you need to write a index case, you can name the index case index.sql or index_xxxx.sql. Case 1. In the specific example content in the case, all empty lines are automatically ignored during testing. You can add blank lines to make the SQLs more readable.2. Each SQL statement contains only one line. If multiple lines are required, each line must be preceded by no space. Otherwise, the SQL in the case file and the result file cannot match each other completely.3. Add a comment indicating the purpose of the test case you are currently writing.4. Add a Tag to the case that is in need."},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#tag-specifications-in-the-cases","title":"Tag specifications in the cases","text":"Annotation Start with End with Description -- @bvt:issue -- @bvt:issue#{issueNO.}] -- @bvt:issue the SQL marked with this flag will not been executed -- @sessio -- @session:id=X{ -- @session} all the SQLs enclosed by this tag will execute in a new session with id=X -- @separator / / The specified SQL statement in its result and generated the result file using the columns of the separator. There are two values. -- @separator:table / / The column separator in the result is a TAB character. \\t -- @separator:space / / The column separator in the result is four Spaces -- @sortkey -- @sortkey:1,2,3 / The results of the SQL statement are ordered, with the first, second, and third columns (starting from 0) sorted. Under normal circumstances, the tested system returns the result of the order is not fixed, so tools in comparison, the actual results, and expected results are sorted, but for some SQL, the expected results should be ordered, such as order by statement, you need to add such SQL on the tag, The tool does not reorder these columns in sortkey when comparing them."},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#result-specifications","title":"Result specifications","text":"Specification Description Normal cases generate test results 1. If a case file is created, ensure that all SQL is debuggable and use the Mo-Tester tool to generate results automatically.2. If some SQLs are added to the existing case, ensure that all SQLs has passed debugging, and use the Mo-Tester tool to generate results automatically. Cases with tags generate test results 1. If a case contains SQL with the --bvt:issue tag, use the MO-Tester tool to generate results automatically. SQL with the --bvt:issue tag in the generated result file results as' unknown result because it is related to issue#XXX\" '.2. If the results have been automatically generated by the MO-Tester tool. When the results are automatically generated by the MO-Tester tool again, the SQL with the tag --bvt:issue will retain the original value in the generated result file, no more updates. Write results manually 1. If the result is writed manually, do not have empty lines. Otherwise, a parsing error occurs.2. If there are tabs or more than 4 consecutive spaces in the expected execution result of a certain SQL, the corresponding SQL statement in the test case file must be added with Tag -- @separator:, otherwise the parsing will fail. For example, if the SQL in the case file contains 4 consecutive spaces, you need to specify the Tag label -- @separator:space; if it contains tab characters, specify the Tag label -- @separator:table."},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#set-tags-in-case-scripts","title":"Set tags in case scripts","text":"

      Sometimes, to achieve some specific purposes, such as pausing or creating a new connection, you can add some special tags to the script file. The mo tester provides the following tags for use:

      Tags Description -- @skip:issue#{IssueNo.} If set, the whole script file will be skipped, and not be executed any more for issue{IssueNo.} -- @bvt:issue#{IssueNo.}-- @bvt:issue The sql statements between those two tags will be not executed for issue{IssueNo.} -- @sleep:{time} The mo-tester will wait for {time} s -- @session:id=2&user=root&password=111 -- @session The mo-tester will create a new connetion to execute sql statements between those two tags.Default value of id is 1, max is 10.Defualt value of user and password is configured in mo.yml. -- @sortkey: If the result is sorted, need set this tag for the sql statement. e.g. -- @sortkey:0,1: means sort keys are first column and second colum."},{"location":"MatrixOne/Test/testing-tool/mo-tester/","title":"What's in MO-Tester?","text":"

      From the 0.5.0 version, MatrixOne introduces an automatic testing framework MO-Tester.

      This tester is designed to test MatrixOne or other database functionalities with SQL.

      MO-Tester is a java-based tester suite for MatrixOne. It has built a whole toolchain to run automatic SQL tests. It contains the test cases and results. Once launched, MO-Tester runs all SQL test cases with MatrixOne, and compares all output SQL results with expected results. All successful and failed cases will be logged into reports.

      MO-Tester content locations:

      • Cases: https://github.com/matrixorigin/matrixone/tree/main/test/distributed/cases

      • Result is generated in the path of /cases, for example, /cases/auto_increment.

      • Report: once finished running, a mo-tester/report will be generated in the local directory.

      The Cases and Results are 1-1 correspondence, and they are actually git submodules from MatrixOne repository. Adding new cases and results should be in MatrixOne repo: https://github.com/matrixorigin/matrixone/tree/main/test

      "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#how-to-use-mo-tester","title":"How to use MO-Tester?","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester/#1-prepare-the-testing-environment","title":"1. Prepare the testing environment","text":"
      • Make sure you have installed jdk8.

      • Launch MatrixOne or other database instance. Please refer to more information about how to install and launch MatrixOne.

      • Clone mo-tester repository.

      git clone https://github.com/matrixorigin/mo-tester.git\n
      • Clone matrixOne repository.
      git clone https://github.com/matrixorigin/matrixone.git\n
      "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#2-configure-mo-tester","title":"2. Configure mo-tester","text":"
      • In mo.yml file, configure the server address, default database name, username, and password, and so on. MO-tester is based on java, so these parameters are required for the JDBC(JDBC,Java Database Connectivity) driver. Below is a default example for a local standalone version MatrixOne.
      #jdbc\njdbc:\n  driver: \"com.mysql.cj.jdbc.Driver\"\n  server:\n  - addr: \"127.0.0.1:6001\"\n  database:\n    default: \"test\"\n  paremeter:\n    characterSetResults: \"utf8\"\n    continueBatchOnError: \"false\"\n    useServerPrepStmts: \"true\"\n    alwaysSendSetIsolation: \"false\"\n    useLocalSessionState: \"true\"\n    zeroDateTimeBehavior: \"CONVERT_TO_NULL\"\n    failoverReadOnly: \"false\"\n    serverTimezone: \"Asia/Shanghai\"\n    socketTimeout: 30000\n#users\nuser:\n  name: \"root\"\n  passwrod: \"111\"\n
      "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#3-run-mo-tester","title":"3. Run mo-tester","text":"
      • With the simple below command, all the SQL test cases will automatically run and generate reports and error messages to report/report.txt and report/error.txt.
      > ./run.sh -p {path_name}/matrixone/test/cases\n

      If you'd like to adjust the test range, you can just change the path parameter of run.yml. And you can also specify some parameters when executing the command ./run.sh, parameters are as followings:

      Parameters Description -p set the path of test cases needed to be executed by mo-tester, the default value is configured by the path in run.yaml -m set the method that mo-tester will run with, the default value is configured by the method in run.yaml -t set the type of the format that mo-tester executes the SQL command in, the default value is configured by the type in run.yaml -r set The success rate that test cases should reach, the default value is configured by the rate in run.yaml -i set the including list, and only script files in the path whose name contains one of the lists will be executed, if more than one, separated by ,, if not specified, refers to all cases included -e set the excluding list, and script files in the path whose name contains one of the lists will not be executed, if more than one, separated by ,, if not specified, refers to none of the cases excluded -g means SQL commands which is marked with [bvt:issue] flag will not be executed,this flag starts with [-- @bvt:issue#{issueNO.}],and ends with [-- @bvt:issue],eg:-- @bvt:issue#3236select date_add(\"1997-12-31 23:59:59\",INTERVAL \"-10000:1\" HOUR_MINUTE);select date_add(\"1997-12-31 23:59:59\",INTERVAL \"-100 1\" YEAR_MONTH);-- @bvt:issueThose two sql commands are associated with issue#3236, and they will not be executed in bvt test, until the flag is removed when issue#3236 is fixed. -n means the metadata of the resultset will be ignored when comparing the result -c only check whether the case file matches the related result file

      Examples:

      ./run.sh -p {path_name}/matrixone/test/cases -m run -t script -r 100 -i select,subquery -e substring -g\n

      If you want to automatically generate SQL results for the new SQL cases, you can just change the method parameter of run.yml file to genrs, or you can just change the command -m run to -m genrs, then running the ./run.sh scripts will directly record test results in the same path of the new SQL case file. For more information on example, see Example 4.

      Note

      Every time running run.sh will overwrite the report of the error.txt file, report.txt file, and success.txt file in the mo-tester repository.

      "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#4-check-the-report","title":"4. Check the report","text":"
      • Once the test is finished, mo-tester generates error.txt file, report.txt file and success.txt file reports.

      • An example of report.txt file looks like this:

      [SUMMARY] COST : 98s, TOTAL :12702, SUCCESS : 11851, FAILED :13, IGNORED :838, ABNORAML :0, SUCCESS RATE : 99%\n[{path_name}/matrixone/test/cases/auto_increment/auto_increment_columns.sql] COST : 2.159s, TOTAL :185, SUCCESS :163, FAILED :0, IGNORED :22, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/benchmark/tpch/01_DDL/01_create_table.sql] COST : 0.226s, TOTAL :11, SUCCESS :11, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/benchmark/tpch/02_LOAD/02_insert_customer.sql] COST : 0.357s, TOTAL :16, SUCCESS :16, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
      Report Keywords Description TOTAL the total number of executed test cases (SQL) SUCCESS The total number of successfully executed test cases(SQL) FAILED the total number of failed executed test case(SQL) IGNORED the total number of ignored executed test cases (SQL), especially with the --bvt:issue tag test cases (SQL) ABNORAML the total number of abnormal executed test cases (SQL), such as the execution of MatrixOne can't determine the actual result is a system exception or .result file parsing error, etc SUCCESS RATE success rate: SUCCESS/(TOTAL - IGNORED)
      • An example of error.txt file looks like this:
      [ERROR]\n[SCRIPT   FILE]: cases/transaction/atomicity.sql\n[ROW    NUMBER]: 14\n[SQL STATEMENT]: select * from test_11 ;\n[EXPECT RESULT]:\nc   d\n1   1\n2 2\n[ACTUAL RESULT]:\nc   d\n1   1\n
      "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#5-test-examples","title":"5. Test Examples","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester/#example-1","title":"Example 1","text":"

      Example Description: Run all test cases in the /cases path of the matrixone repository.

      Steps:

      1. Get the latest matrixone code.
      cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n
      1. To run all the test cases of the matrixone repository, you need switch into the mo-tester repository first, see the following commands:
      cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases\n
      1. Check the result reports in the error.txt file, report.txt file, and success.txt file in the mo-tester/report/ path.
      "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#example-2","title":"Example 2","text":"

      Example Description: Run the test cases in the /cases/transaction/ path of the matrixone repository.

      Steps:

      1. Get the latest matrixone code.
      cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n
      1. To run the test cases in the cases/transaction/ path of the matrixone repository, you need switch into the mo-tester repository first, see the following commands:
      cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/transaction/\n
      1. Check the result reports in the error.txt file, report.txt file, and success.txt file in the mo-tester/report/ path. The example of the expected report.txt looks like this:
      [SUMMARY] COST : 5s, TOTAL :1362, SUCCESS : 1354, FAILED :0, IGNORED :8, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.575s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit.test] COST : 0.175s, TOTAL :50, SUCCESS :50, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_1.sql] COST : 1.141s, TOTAL :296, SUCCESS :288, FAILED :0, IGNORED :8, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_atomicity.sql] COST : 0.52s, TOTAL :75, SUCCESS :75, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_isolation.sql] COST : 1.607s, TOTAL :215, SUCCESS :215, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_isolation_1.sql] COST : 1.438s, TOTAL :241, SUCCESS :241, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/isolation.sql] COST : 1.632s, TOTAL :202, SUCCESS :202, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/isolation_1.sql] COST : 1.512s, TOTAL :217, SUCCESS :217, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
      "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#example-3","title":"Example 3","text":"

      Example Description: Run the single test case cases/transaction/atomicity.sql.

      Steps:

      1. Get the latest matrixone code.
      cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n
      1. To run the test cases cases/transaction/atomicity.sql, you need switch into the mo-tester repository first, see the following commands:
      cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/transaction/atomicity.sql\n
      1. Check the result reports in the error.txt file, report.txt file, and success.txt file in the mo-tester/report/ path. The example of the expected report.txt looks like this:
      [SUMMARY] COST : 0s, TOTAL :66, SUCCESS : 66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.56s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
      "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#example-4","title":"Example 4","text":"

      Example Description:

      • Create a new folder named local_test and place it in {path_name}/matrixone/test/cases
      • Add a test file named new_test.sql to {path_name}/matrixone/test/cases/local_test/
      • Only run the single test case new_test.sql*

      Steps

      1. Get the latest matrixone code.
      cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n
      1. Generate test results:

      2. Method 1: To generate the test result, you need switch into the mo-tester repository first, then, run the following command.

        cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/local_test/new_test.sql -m genrs -g\n
      3. Method 2: Open the run.yml file in the mo-tester repository, change the method parameter from the default run to genrs, and run the following command to generate the test result.

        cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/local_test/new_test.sql\n
      4. Check the result file in the test/cases,result/ path of the matrixone repository.

      5. Check the result reports in the error.txt file, report.txt file, and success.txt file in the mo-tester/report/ path. The example of the expected report.txt looks like this:

      [SUMMARY] COST : 0s, TOTAL :66, SUCCESS : 66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.56s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
      "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#reference","title":"Reference","text":"

      For more information on the annotations of MO-Tester, see MO-Tester Annotations.

      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/","title":"Common statistic data query","text":"

      Statistic data is a common query periodically performed during the operation and maintenance of a database. It helps the users intuitively and accurately grasp the current database status and health status.

      In MatrixOne, statistics include the following:

      • Metadata: data that describes the database, including database information, table information, and column information.

      • SQL Statistics: indicates whether the SQL is executed successfully, by whom, and at the start and stop time in a specific time range.

      • Role and Permission information: You can query the authorization, permission, inheritance, execution time, and authorization person of all roles in a MatrixOne.

      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#check-basic-information-on-all-databases","title":"Check basic information on all databases","text":"

      To view the basic information on all databases of the current account, execute the SQL as below:

      > select md.datname as database_name,md.created_time as created_time,mu.user_name as creator, mr.role_name as owner_role, count(mt.reldatabase) as total_tables\nfrom mo_catalog.mo_database md,mo_catalog.mo_role mr, mo_catalog.mo_user mu, mo_catalog.mo_tables mt\nwhere md.creator=mu.user_id and md.owner=mr.role_id and mt.reldatabase_id=md.dat_id\ngroup by mt.reldatabase,md.datname,md.created_time,mu.user_name,mr.role_name\norder by md.created_time asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-auto-increment-columns","title":"View the information on all auto increment columns","text":"

      To view the information on all the auto increment columns, execute the SQL as below:

      > select att_database as database_name,att_relname as table_name,attname as column_name\nfrom mo_catalog.mo_columns\nwhere att_is_auto_increment=1\norder by att_database, att_relname asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-the-views","title":"View the information on all the views","text":"

      To view the information on all the views, execute the SQL as below:

      > select mt.relname as view_name, mt.reldatabase as database_name,mu.user_name as created_user,mr.role_name as owner_role,mt.created_time\nfrom mo_catalog.mo_tables mt, mo_catalog.mo_user mu, mo_catalog.mo_role mr\nwhere mt.relkind='v' and mt.creator=mu.user_id and mt.owner=mr.role_id\norder by 1,2 asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-the-external-tables","title":"View the information on all the external tables","text":"

      To view the information on all the external tables, execute the SQL as below:

      > select mt.relname as view_name, mt.reldatabase as database_name,mu.user_name as created_user,mr.role_name as owner_role,mt.created_time\nfrom mo_catalog.mo_tables mt, mo_catalog.mo_user mu, mo_catalog.mo_role mr\nwhere mt.relkind='e' and mt.creator=mu.user_id and mt.owner=mr.role_id\norder by 1,2 asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-the-primary-keys-of-tables","title":"View the information on all the primary keys of tables","text":"

      To view the information on all the primary keys of tables, execute the SQL as below:

      > select att_database as database_name,att_relname as table_name,attname as column_name\nfrom mo_catalog.mo_columns\nwhere att_constraint_type='p' and att_relname not like '%!%'\norder by att_database, att_relname asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-the-tables-without-primary-keys","title":"View the information on all the tables without primary keys","text":"

      To view the information on all the tables without primary keys, execute the SQL as below:

      > select distinct att_database as database_name,att_relname as table_name\nfrom mo_catalog.mo_columns\nminus\nselect att_database as database_name,att_relname as table_name\nfrom mo_catalog.mo_columns\nwhere att_constraint_type='p'\norder by database_name,table_name asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-sql-statistics-of-the-last-24-hours-not-supported-for-non-sys-account","title":"View the sql statistics of the last 24 hours (not supported for non-sys account)","text":"
      > select user,host,status,count(status) as count, date_sub(now(), interval 24 hour) as start_time, now() as end_time\nfrom system.statement_info\nwhere status in ('Success','Failed') and user <> 'internal'\nand request_at between date_sub(now(), interval 24 hour) and now()\ngroup by status,user,host\norder by user,status asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-role-grant-users","title":"View the information on all role grant users","text":"

      To view the information on all role grant users, execute the SQL as below:

      > select mu.user_name as user_name,mr.role_name as role_name,mug.with_grant_option\nfrom mo_catalog.mo_user mu, mo_catalog.mo_role mr, mo_catalog.mo_user_grant mug\nwhere mu.user_id=mug.user_id and mr.role_id=mug.role_id\norder by mu.user_name,mr.role_name asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-promission-of-all-roles","title":"View the promission of all roles","text":"

      To view the promission of all roles, execute the SQL as below:

      > select mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,md.datname as object_name,with_grant_option\nfrom mo_catalog.mo_role_privs mrp, mo_catalog.mo_database md\nwhere mrp.obj_id=md.dat_id and mrp.obj_type='database'\nunion\nselect mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,'*',with_grant_option\nfrom mo_catalog.mo_role_privs mrp\nwhere obj_id=0\nunion\nselect mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,mt.relname as object_name,with_grant_option\nfrom mo_catalog.mo_role_privs mrp, mo_catalog.mo_tables mt\nwhere mrp.obj_id=mt.rel_id and mrp.obj_type='table'\norder by 1,2 asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-all-role-inheritance-information","title":"View all role inheritance information","text":"

      To view all role inheritance information, execute the SQL as below:

      > select mr1.role_name as inheritor_role,mr2.role_name as inheritee_role,mu.user_name as operator_user,mrg.granted_time,mrg.with_grant_option\nfrom mo_catalog.mo_user mu, mo_catalog.mo_role mr1, mo_catalog.mo_role mr2,mo_catalog.mo_role_grant mrg\nwhere mu.user_id=mrg.operation_user_id and mr1.role_id=mrg.grantee_id and mr2.role_id=mrg.granted_id\norder by mr1.role_name,mr2.role_name asc;\n
      "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#reference","title":"Reference","text":"

      MatrixOne system database and tables are where MatrixOne stores system information, so if you want to see more information on the system, refer MatrixOne System Database and Tables.

      "},{"location":"MatrixOne/Troubleshooting/error-code/","title":"Error Code","text":"

      In MatrixOne, the error information is classified according to the error code. A specific type of error code will be unified into a specific error code for troubleshooting. All messages sent by the MatrixOne database service are assigned a five-character error code, which contains both the type of error code and the specific category of error code.

      During actual use, you can first check the error code and use the text error message attached to the error code to determine what kind of error occurred. Error encodings do not change across versions and do not change due to the localization of error messages.

      Note

      The SQL standard defines some of the error codes generated by MatrixOne; some additional error codes for conditions not defined by the standard were invented or borrowed from other databases.

      Error encoding head Type 201 Internal Error 202 Number and function error 203 Invalid Operation 204 Unknown Error or IO Error 205 RPC Timeout 206 Transaction Error or Storage Engine Error

      For more information on the details of these errors, please refer to the following table:

      Error code Error number Description Error type 20100 ErrStart internal error code start Internal error 20101 ErrInternal Internal error Internal error 20103 ErrNYI not yet implemented Internal error 20104 ErrOOM out of memory Internal error 20105 ErrQueryInterrupted query interrupted Internal error 20106 ErrNotSupported not supported Internal error 20200 ErrDivByZero division by zero Numbers and functions 20201 ErrOutOfRange data out of range Numbers and functions 20202 ErrDataTruncated data truncated Numbers and functions 20203 ErrInvalidArg invalid argument Numbers and functions 20204 ErrTruncatedWrongValueForField truncated wrong value for column Numbers and functions 20300 ErrBadConfig invalid configuration Invalid operation 20301 ErrInvalidInput invalid input Invalid operation 20302 ErrSyntaxError SQL syntax error Invalid operation 20303 ErrParseError SQL parser error Invalid operation 20304 ErrConstraintViolation constraint violation Invalid operation 20305 ErrDuplicate tae data duplicated Invalid operation 20306 ErrRoleGrantedToSelf cannot grant role Invalid operation 20307 ErrDuplicateEntry duplicate entry for key Invalid operation 20400 ErrInvalidState invalid state Unknown status or I/O error 20401 ErrLogServiceNotReady log service not ready Unknown status or I/O error 20402 ErrBadDB invalid database Unknown status or I/O error 20403 ErrNoSuchTable no such table Unknown status or I/O error 20404 ErrEmptyVector empty vector Unknown status or I/O error 20405 ErrFileNotFound file is not found Unknown status or I/O error 20406 ErrFileAlreadyExists file alread exists Unknown status or I/O error 20407 ErrUnexpectedEOF unexpteded end of file Unknown status or I/O error 20408 ErrEmptyRange empty range of file Unknown status or I/O error 20409 ErrSizeNotMatch file size does not match Unknown status or I/O error 20410 ErrNoProgress file has no io progress Unknown status or I/O error 20411 ErrInvalidPath invalid file path Unknown status or I/O error 20412 ErrShortWrite file io short write Unknown status or I/O error 20413 ErrInvalidWrite file io invalid write Unknown status or I/O error 20414 ErrShortBuffer file io short buffer Unknown status or I/O error 20415 ErrNoDB not connect to a database Unknown status or I/O error 20416 ErrNoWorkingStore no working store Unknown status or I/O error 20417 ErrNoHAKeeper cannot locate ha keeper Unknown status or I/O error 20418 ErrInvalidTruncateLsn invalid truncate lsn, shard already truncated Unknown status or I/O error 20419 ErrNotLeaseHolder not lease holder, current lease holder ID xxx Unknown status or I/O error 20420 ErrDBAlreadyExists database already exists Unknown status or I/O error 20421 ErrTableAlreadyExists table already exists Unknown status or I/O error 20422 ErrNoService service not found Unknown status or I/O error 20423 ErrDupServiceName duplicate service name Unknown status or I/O error 20424 ErrWrongService wrong service, expecting A, got B Unknown status or I/O error 20425 ErrBadS3Config bad s3 config Unknown status or I/O error 20426 ErrBadView invalid view Unknown status or I/O error 20427 ErrInvalidTask invalid task Unknown status or I/O error 20428 ErrInvalidServiceIndex invalid service idx Unknown status or I/O error 20429 ErrDragonboatTimeout Dragonboat timeout Unknown status or I/O error 20430 ErrDragonboatTimeoutTooSmall Dragonboat timeout too small Unknown status or I/O error 20431 ErrDragonboatInvalidDeadline Dragonboat invalid deadline Unknown status or I/O error 20432 ErrDragonboatRejected Dragonboat rejected Unknown status or I/O error 20433 ErrDragonboatInvalidPayloadSize invalid payload size Unknown status or I/O error 20434 ErrDragonboatShardNotReady shard not ready Unknown status or I/O error 20435 ErrDragonboatSystemClosed Dragonboat system closed Unknown status or I/O error 20436 ErrDragonboatInvalidRange Dragonboat invalid range Unknown status or I/O error 20437 ErrDragonboatShardNotFound shard not found Unknown status or I/O error 20438 ErrDragonboatOtherSystemError other system error Unknown status or I/O error 20439 ErrDropNonExistsDB Can't drop database ; database doesn't exist Unknown status or I/O error 20500 ErrRPCTimeout rpc timeout RPC Timeout 20501 ErrClientClosed client closed RPC Timeout 20502 ErrBackendClosed backend closed RPC Timeout 20503 ErrStreamClosed stream closed RPC Timeout 20504 ErrNoAvailableBackend no available backend RPC Timeout 20600 ErrTxnClosed the transaction has been committed or aborted Transaction 20601 ErrTxnWriteConflict transaction write conflict Transaction 20602 ErrMissingTxn missing transaction Transaction 20603 ErrUnresolvedConflict unresolved conflict Transaction 20604 ErrTxnError transaction error Transaction 20605 ErrDNShardNotFound TN shard not found Transaction 20606 ErrShardNotReported TN shard not reported Transaction 20607 ErrTAEError tae error TAE Error 20608 ErrTAERead tae read error TAE Error 20609 ErrRpcError rpc error TAE Error 20610 ErrWaitTxn transaction wait error TAE Error 20611 ErrTxnNotFound transaction not found TAE Error 20612 ErrTxnNotActive transaction not active TAE Error 20613 ErrTAEWrite tae write error TAE Error 20614 ErrTAECommit tae commit error TAE Error 20615 ErrTAERollback tae rollback error TAE Error 20616 ErrTAEPrepare tae prepare error TAE Error 20617 ErrTAEPossibleDuplicate tae possible duplicate TAE Error 20618 ErrTxnRWConflict r-w conflict TAE Error 20619 ErrTxnWWConflict w-w conflict TAE Error 20620 ErrNotFound transaction not found TAE Error 20621 ErrTxnInternal transaction internal error TAE Error 20622 ErrTxnReadConflict transaction read conflict TAE Error 20623 ErrPrimaryKeyDuplicated duplicated primary key TAE Error 20624 ErrAppendableSegmentNotFound appendable segment not found TAE Error 20625 ErrAppendableBlockNotFound appendable block not found TAE Error 20626 ErrTAEDebug TAE debug TAE Error"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/","title":"MatrixOne database statistics","text":"

      MatrixOne database statistics refer to the related information of tables and columns obtained through sampling and statistics of the database, for example, the number of tables, the number of columns of tables, the storage space occupied by tables, and so on. When MatrixOne database generates an execution plan, it needs to estimate based on statistical information to calculate the optimal execution plan.

      The statistics dimensions of the MatrixOne database are as follows:

      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-number-of-tables-in-the-database","title":"The number of tables in the database","text":"

      This command shows the total number of tables in the specified database.

      Syntax:

      SHOW TABLE_NUMBER FROM {DATABASE_NAME}\n
      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example","title":"Example","text":"
      • Example 1: Check the total number of tables in the system database mo_catalog:
      mysql> show table_number from mo_catalog;\n+--------------------------------+\n| Number of tables in mo_catalog |\n+--------------------------------+\n|                             11 |\n+--------------------------------+\n\n-- Verify which tables in mo_catalog\nmysql> use mo_catalog;\nmysql> show tables;\n+----------------------------+\n| Tables_in_mo_catalog       |\n+----------------------------+\n| mo_user                    |\n| mo_account                 |\n| mo_role                    |\n| mo_user_grant              |\n| mo_role_grant              |\n| mo_role_privs              |\n| mo_user_defined_function   |\n| mo_columns                 |\n| mo_mysql_compatbility_mode |\n| mo_tables                  |\n| mo_database                |\n+----------------------------+\n11 rows in set (0.01 sec)\n
      • Example 2: Create a new database, and create new tables, check the number of tables in the specific database:
      create database demo_1;\nuse demo_1;\n-- Create three new tables\nCREATE TABLE t1(a bigint, b varchar(10), c varchar(10));\nCREATE TABLE t2(a bigint, b int);\nCREATE TABLE t3(a int, b varchar(10), c varchar(10));\n\n-- Query out that there are three tables in the database demo_1\nmysql> show table_number from demo_1;\n+----------------------------+\n| Number of tables in demo_1 |\n+----------------------------+\n|                          3 |\n+----------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-number-of-columns-in-the-table","title":"The number of columns in the table","text":"

      This command shows the total number of columns in the specified table.

      Syntax:

      SHOW COLUMN_NUMBER FROM {[DATABASE_NAME.]TABLE_NAME}\n
      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example_1","title":"Example","text":"
      use mo_catalog;\nuse mo_user;\nmysql> show column_number from mo_user;\n+------------------------------+\n| Number of columns in mo_user |\n+------------------------------+\n|                           11 |\n+------------------------------+\n\n-- Or use the following command\nmysql> show column_number from mo_catalog.mo_user;\n+------------------------------+\n| Number of columns in mo_user |\n+------------------------------+\n|                           11 |\n+------------------------------+\n\n-- Verify which columns in the table\nmysql> desc mo_catalog.mo_user;\n+-----------------------+--------------+------+------+---------+-------+---------+\n| Field                 | Type         | Null | Key  | Default | Extra | Comment |\n+-----------------------+--------------+------+------+---------+-------+---------+\n| user_id               | INT          | YES  |      | NULL    |       |         |\n| user_host             | VARCHAR(100) | YES  |      | NULL    |       |         |\n| user_name             | VARCHAR(300) | YES  |      | NULL    |       |         |\n| authentication_string | VARCHAR(100) | YES  |      | NULL    |       |         |\n| status                | VARCHAR(8)   | YES  |      | NULL    |       |         |\n| created_time          | TIMESTAMP    | YES  |      | NULL    |       |         |\n| expired_time          | TIMESTAMP    | YES  |      | NULL    |       |         |\n| login_type            | VARCHAR(16)  | YES  |      | NULL    |       |         |\n| creator               | INT          | YES  |      | NULL    |       |         |\n| owner                 | INT          | YES  |      | NULL    |       |         |\n| default_role          | INT          | YES  |      | NULL    |       |         |\n+-----------------------+--------------+------+------+---------+-------+---------+\n11 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-maximum-and-minimum-values-contained-in-all-columns-in-the-table","title":"The maximum and minimum values \u200b\u200bcontained in all columns in the table","text":"

      This command shows the maximum and minimum values \u200b\u200bof each column in the specified table.

      Note: If the data types of the column values \u200b\u200bin the specified table are inconsistent, the sorting rules are: numbers are sorted according to the size of numbers; dates are sorted according to time; characters are sorted according to ASCII code; when several data types are mixed, then First convert to character type, and then sort according to ASCII code.

      Syntax:

      SHOW TABLE_VALUES FROM {[DATABASE_NAME.]TABLE_NAME}\n
      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example_2","title":"Example","text":"
      create table t1(\ncol1 int,\ncol2 float,\ncol3 varchar\n);\ninsert into t1 values(1,1.11,'1.111'),(2,2.22,'1.222'),(3,0,'abc');\n\nmysql> show table_values from t1;\n+-----------+-----------+-----------+-----------+-----------+-----------+\n| max(col1) | min(col1) | max(col2) | min(col2) | max(col3) | min(col3) |\n+-----------+-----------+-----------+-----------+-----------+-----------+\n|         3 |         1 |      2.22 |         0 | abc       | 1.111     |\n+-----------+-----------+-----------+-----------+-----------+-----------+\n
      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-total-number-of-rows-of-data-in-the-table","title":"The total number of rows of data in the table","text":"

      This command shows the total number of rows of data in a table in the database.

      Syntax:

      SELECT MO_TABLE_ROWS({DATABASE_NAME},{TABLE_NAME})\n
      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example_3","title":"Example","text":"
      -- Query the total number of rows of mo_tables in mo_catalog\nmysql> select mo_table_rows('mo_catalog','mo_tables');\n+--------------------------------------+\n| mo_table_rows(mo_catalog, mo_tables) |\n+--------------------------------------+\n|                                   64 |\n+--------------------------------------+\n
      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-space-occupied-by-the-table-in-storage","title":"The space occupied by the table in storage","text":"

      This command shows the storage space occupied by a specific table in the database can be obtained, and the unit is the number of bytes.

      Syntax:

      SELECT MO_TABLE_SIZE({DATABASE_NAME},{TABLE_NAME})\n
      "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example_4","title":"Example","text":"
      -- Query the storage space occupied by the table mo_tables in the database mo_catalog\nmysql> select mo_table_size('mo_catalog','mo_tables');\n+--------------------------------------+\n| mo_table_size(mo_catalog, mo_tables) |\n+--------------------------------------+\n|                                16128 |\n+--------------------------------------+\n
      "},{"location":"MatrixOne/Troubleshooting/slow-queries/","title":"Slow Query","text":"

      Slow query: record the SQL statement that runs slowly in the log. Slow queries are recorded in the slow query log. Through the slow query log, you can find out which query statements have low execution efficiency for optimization.

      Currently, the slow queries on a MatrixOne are longer than 1000 milliseconds and cannot be directly output to corresponding log files. You need to create a view to filter the query information.

      "},{"location":"MatrixOne/Troubleshooting/slow-queries/#enable-slow-query","title":"Enable Slow Query","text":"

      The slow query log is disabled by default. To use the slow query log function, you must first enable the slow query log function.

      MatrixOne slow query feature is available with the following basic information:

      • statement: indicates the SQL text that provides the complete SQL statement.
      • request_at: indicates the start time of the SQL statement.
      • duration_second: indicates the actual execution time of the SQL statement.
      • exec_plan: indicates the detailed execution plan of the SQL statement.

      To enable the slow query, execute the following SQL statements:

      drop database if exists mo_ts;\ncreate database mo_ts;\nuse mo_ts;\ncreate view slow_query as select statement,request_at,duration/1000000000 as duration_second from system.statement_info where statement like 'select%' and duration/1000000000>1  order by request_at desc;\ncreate view slow_query_with_plan as select statement,request_at,duration/1000000000 as duration_second,exec_plan from system.statement_info where statement like 'select%' and duration/1000000000>1  order by request_at desc;\n

      For all queries longer than 1 second, execute the following SQL statement to view them:

      > select * from mo_ts.slow_query;\n> select * from mo_ts.slow_query_with_plan;\n

      Explanations

      • select * from mo_ts.slow_query;: slow query without plan.

      • select * from mo_ts.slow_query_with_plan;: slow query with plan..

      "},{"location":"MatrixOne/Troubleshooting/slow-queries/#error-log","title":"Error Log","text":"

      When slow query is enabled, you can enable error logs, check logs, and locate error information.

      "},{"location":"MatrixOne/Troubleshooting/slow-queries/#enable-error-log","title":"Enable Error Log","text":"

      To enable the error log, , execute the following SQL statements:

      create database mo_ts if not exists mo_ts;\nuse mo_ts;\ncreate view error_message as select timestamp,message from system.log_info where level in ('error','panic','faltal');\ncreate view error_sql as select si.request_at time_stamp,si.statement,si.error as SQL from system.statement_info si where si.user<>'internal' and si.status='Failed' ;\n
      "},{"location":"MatrixOne/Troubleshooting/slow-queries/#query-the-error-message-of-database","title":"Query the error message of database","text":"

      To query the error message of database, execute the following SQL statements:

      > select * from mo_ts.error_message;\n

      The query result example is as follows:

      +----------------------------+-------------------------------------------------------------------------+\n| timestamp                  | message                                                                 |\n+----------------------------+-------------------------------------------------------------------------+\n| 2022-11-28 14:47:31.324762 | error: SQL parser error: table \"error_sql\" does not exist               |\n| 2022-11-28 14:47:31.324837 | SQL parser error: table \"error_sql\" does not exist                      |\n| 2022-11-28 14:47:31.324872 | query trace status                                                      |\n| 2022-11-28 14:40:06.579795 | read loop stopped                                                       |\n| 2022-11-28 14:40:06.585220 | gc inactive backends task stopped                                       |\n| 2022-11-28 14:40:06.591082 | error: cannot locate ha keeper                                          |\n| 2022-11-28 14:40:08.442515 | failed to propose initial cluster info                                  |\n| 2022-11-28 14:40:08.442667 | failed to set initial cluster info                                      |\n| 2022-11-28 14:40:09.411286 | error: timeout, converted to code 20429                                 |\n| 2022-11-28 14:40:09.411508 | read loop stopped                                                       |\n| 2022-11-28 14:40:09.416557 | gc inactive backends task stopped                                       |\n| 2022-11-28 14:40:10.052585 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:10.052630 | failed to create init tasks                                             |\n| 2022-11-28 14:40:11.053926 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:11.054059 | failed to create init tasks                                             |\n| 2022-11-28 14:40:12.054578 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:12.054630 | failed to create init tasks                                             |\n| 2022-11-28 14:40:13.055828 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:13.055896 | failed to create init tasks                                             |\n| 2022-11-28 14:40:14.057102 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:14.057208 | failed to create init tasks                                             |\n| 2022-11-28 14:40:15.058425 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:15.058563 | failed to create init tasks                                             |\n| 2022-11-28 14:40:16.059867 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:16.060031 | failed to create init tasks                                             |\n| 2022-11-28 14:40:16.443234 | read loop stopped                                                       |\n| 2022-11-28 14:40:16.443162 | read from backend failed                                                |\n| 2022-11-28 14:40:16.448858 | gc inactive backends task stopped                                       |\n| 2022-11-28 14:40:16.457276 | error: file tnservice/dd4dccb4-4d3c-41f8-b482-5251dc7a41bf is not found |\n| 2022-11-28 14:40:17.061260 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:17.061323 | failed to create init tasks                                             |\n| 2022-11-28 14:40:18.062165 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:18.062249 | failed to create init tasks                                             |\n| 2022-11-28 14:40:18.642097 | error: TN shard uuid , id 2 not reported                                |\n| 2022-11-28 14:40:19.062775 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:19.062937 | failed to create init tasks                                             |\n| 2022-11-28 14:40:20.063237 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:20.063252 | failed to create init tasks                                             |\n| 2022-11-28 14:40:21.064529 | failed to create init tasks                                             |\n| 2022-11-28 14:40:21.064457 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:21.463193 | read loop stopped                                                       |\n| 2022-11-28 14:40:21.468423 | gc inactive backends task stopped                                       |\n| 2022-11-28 14:40:21.474688 | error: file cnservice/dd1dccb4-4d3c-41f8-b482-5251dc7a41bf is not found |\n| 2022-11-28 15:24:56.210577 | error: SQL parser error: table \"error_sql\" does not exist               |\n| 2022-11-28 15:24:56.210773 | SQL parser error: table \"error_sql\" does not exist                      |\n| 2022-11-28 15:24:56.210898 | query trace status                                                      |\n| 2022-11-28 14:40:22.065723 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:22.065838 | failed to create init tasks                                             |\n| 2022-11-28 14:40:22.478229 | error: invalid state no cn in the cluster                               |\n| 2022-11-28 14:40:22.478846 | failed to refresh task storage                                          |\n| 2022-11-28 14:40:23.090160 | error: invalid database mo_task                                         |\n| 2022-11-28 14:40:23.090274 | invalid database mo_task                                                |\n| 2022-11-28 14:40:23.090604 | query trace status                                                      |\n| 2022-11-28 15:32:30.354364 | error: SQL parser error: table \"slow_query\" does not exist              |\n| 2022-11-28 15:32:30.354485 | SQL parser error: table \"slow_query\" does not exist                     |\n| 2022-11-28 15:32:30.354605 | query trace status                                                      |\n| 2022-11-28 15:26:59.639892 | error: SQL parser error: table \"error_sql\" does not exist               |\n| 2022-11-28 15:26:59.640039 | SQL parser error: table \"error_sql\" does not exist                      |\n| 2022-11-28 15:26:59.640208 | query trace status                                                      |\n| 2022-11-28 15:37:29.289457 | error: table slow_query already exists                                  |\n| 2022-11-28 15:37:29.289486 | table slow_query already exists                                         |\n| 2022-11-28 15:37:29.289518 | query trace status                                                      |\n| 2022-11-28 15:37:45.773829 | error: table slow_query_with_plan already exists                        |\n| 2022-11-28 15:37:45.773856 | table slow_query_with_plan already exists                               |\n| 2022-11-28 15:37:45.773888 | query trace status                                                      |\n| 2022-11-28 14:45:48.821324 | error: not supported: function or operator 'interval'                   |\n| 2022-11-28 14:45:48.823261 | error: not supported: function or operator 'interval'                   |\n| 2022-11-28 14:45:48.823426 | error: not supported: function or operator 'interval'                   |\n| 2022-11-28 14:45:48.823525 | error: not supported: function or operator 'interval'                   |\n| 2022-11-28 14:47:14.513831 | error: SQL parser error: table \"statement_info\" does not exist          |\n| 2022-11-28 14:47:14.513929 | SQL parser error: table \"statement_info\" does not exist                 |\n| 2022-11-28 14:47:14.513962 | query trace status                                                      |\n+----------------------------+-------------------------------------------------------------------------+\n72 rows in set (0.13 sec)\n
      "},{"location":"MatrixOne/Troubleshooting/slow-queries/#query-the-error-of-sql","title":"Query the error of SQL","text":"

      To query the error of SQL, execute the following SQL statements:

      > select * from mo_ts.error_sql;\n

      The query result example is as follows:

      +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n| time_stamp                 | statement                                                                                                                                                                                                                              | sql                                                     |\n+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n| 2022-11-28 14:40:23.073188 | use mo_task                                                                                                                                                                                                                            | invalid database mo_task                                |\n| 2022-11-28 15:26:59.637130 | select * from mo_ts.error_sql                                                                                                                                                                                                          | SQL parser error: table \"error_sql\" does not exist      |\n| 2022-11-28 15:37:29.283683 | create view slow_query as select statement, request_at, duration / 1000000000 as duration_second from system.statement_info where statement like \"select%\" and duration / 1000000000 > 1 order by request_at desc                      | table slow_query already exists                         |\n| 2022-11-28 15:37:45.765394 | create view slow_query_with_plan as select statement, request_at, duration / 1000000000 as duration_second, exec_plan from system.statement_info where statement like \"select%\" and duration / 1000000000 > 1 order by request_at desc | table slow_query_with_plan already exists               |\n| 2022-11-28 15:32:30.351695 | select * from mo_ts.slow_query                                                                                                                                                                                                         | SQL parser error: table \"slow_query\" does not exist     |\n| 2022-11-28 14:47:14.510060 | create view error_sql as select si.request_at as time_stamp, si.statement as sql, el.err_code from statement_info as si cross join error_info as el where si.statement_id = el.statement_id and user != \"internal\"                     | SQL parser error: table \"statement_info\" does not exist |\n| 2022-11-28 14:47:31.323884 | select * from mo_ts.error_sql                                                                                                                                                                                                          | SQL parser error: table \"error_sql\" does not exist      |\n| 2022-11-28 15:24:56.208171 | select * from mo_ts.error_sql                                                                                                                                                                                                          | SQL parser error: table \"error_sql\" does not exist      |\n+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n8 rows in set (0.14 sec)\n
      "},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/","title":"Golang CRUD demo","text":""},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/#setup-your-environment","title":"Setup your environment","text":"
      1. Make sure you have already installed and launched MatrixOne.
      2. Make sure you have already installed Golang 1.18 and plus.

        #To check with Golang installation and its version\ngo version\n
      3. Make sure you have already installed MySQL client.

      4. Download and install Go-MySQL-Driver tool.
      "},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/#develop-your-code","title":"Develop your code","text":"
      1. Connect to MatrixOne by MySQL client. Create a new database named test.

        mysql> create database test;\n
      2. Create a plain text file golang_crud_matrixone.go and put the code below.

        package main\n\nimport (\n    \"database/sql\"\n    \"fmt\"\n    \"log\"\n    _ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc main() {\n    //Open a new connection to MatrixOne\n    db, err := sql.Open(\"mysql\", \"root:111@tcp(127.0.0.1:6001)/test\")\n    checkErr(err)\n\n    //Create a table\n    _, err2 := db.Exec(\"CREATE TABLE `userinfo` (`uid` INT(10) NOT NULL AUTO_INCREMENT,`username` VARCHAR(64) NULL DEFAULT NULL,`department` VARCHAR(64) NULL DEFAULT NULL,`created` DATETIME NULL DEFAULT NULL, PRIMARY KEY (`uid`));\")\n    if err2 != nil {\n        log.Fatal(err2)\n    }\n    fmt.Print(\"Successfully Created\\n\")\n\n    // Insert a record\n    stmt, err := db.Prepare(\"INSERT userinfo SET username=?,department=?,created=?\")\n    checkErr(err)\n\n    res, err := stmt.Exec(\"Alex\", \"r&d\", \"2023-01-01\" 12:00:00\")\n    checkErr(err)\n\n    id, err := res.LastInsertId()\n    checkErr(err)\n\n    fmt.Println(id)\n    //Update a record\n    stmt, err = db.Prepare(\"update userinfo set username=? where uid=?\")\n    checkErr(err)\n\n    res, err = stmt.Exec(\"Mark\", id)\n    checkErr(err)\n\n    affect, err := res.RowsAffected()\n    checkErr(err)\n\n    fmt.Println(affect)\n\n    // Query all records\n    rows, err := db.Query(\"SELECT * FROM userinfo\")\n    checkErr(err)\n\n    for rows.Next() {\n        var uid int\n        var username string\n        var department string\n        var created string\n        err = rows.Scan(&uid, &username, &department, &created)\n        checkErr(err)\n        fmt.Println(uid)\n        fmt.Println(username)\n        fmt.Println(department)\n        fmt.Println(created)\n    }\n\n    // Delete a record\n    stmt, err = db.Prepare(\"delete from userinfo where uid=?\")\n    checkErr(err)\n\n    res, err = stmt.Exec(id)\n    checkErr(err)\n\n    affect, err = res.RowsAffected()\n    checkErr(err)\n\n    fmt.Println(affect)\n\n    db.Close()\n\n}\n\nfunc checkErr(err error) {\n    if err != nil {\n        panic(err)\n    }\n}\n
      3. Execute this Golang file in the command line terminal.

        > go run golang_crud_matrixone.go\nSuccessfully Created\n1\n1\n1\nMark\nr&d\n2023-01-01\n1\n
      "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/","title":"Java CRUD demo","text":"

      Note

      The source code of this demo can be downloaded at Java CRUD Example.

      "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#setup-your-environment","title":"Setup your environment","text":"

      Before you start, make sure you have downloaded and installed the following software.

      • Install and deployed standalone MatrixOne. Create a database by MySQL client.
      mysql> create database test;\n
      • lntelliJ IDEA(2022.2.1 or later version).
      • JDK 8+ version: Choose the version according to your OS.
      • MySQL JDBC connector 8.0+ version: It's recommanded to download the platform independent version, and unzip the downloaded file.

      Note

      We take IDEA as an IDE example to demonstrate the process, you are free to choose Eclipse or other IDE tools for the same purpose.

      "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#initialize-a-new-java-project","title":"Initialize a new Java project","text":"

      Launch IDEA, and create a new Java project as below:

      In your Project Setting > Libraries, import the mysql-connector-java-8.0.30.jar file.

      "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#write-java-code-to-connect-with-matrixone","title":"Write Java code to connect with MatrixOne","text":"

      Firstly we create a Java class named as JDBCUtils as a connection utility. This class will serve as a tool to connect with MatrixOne and execute SQL queries.

      Under the src directory, create a file named JDBCUtils.java, and edit this file with the following code.

      import java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.SQLException;\n\npublic class JDBCUtils {\n    private static String jdbcURL = \"jdbc:mysql://127.0.0.1:6001/test\";\n    private static String jdbcUsername = \"root\";\n    private static String jdbcPassword = \"111\";\n\n    public static Connection getConnection() {\n        Connection connection = null;\n        try {\n            connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);\n        } catch (SQLException e) {\n            // TODO Auto-generated catch block\n            e.printStackTrace();\n        }\n        return connection;\n    }\n\n    public static void printSQLException(SQLException ex) {\n        for (Throwable e : ex) {\n            if (e instanceof SQLException) {\n                e.printStackTrace(System.err);\n                System.err.println(\"SQLState: \" + ((SQLException) e).getSQLState());\n                System.err.println(\"Error Code: \" + ((SQLException) e).getErrorCode());\n                System.err.println(\"Message: \" + e.getMessage());\n                Throwable t = ex.getCause();\n                while (t != null) {\n                    System.out.println(\"Cause: \" + t);\n                    t = t.getCause();\n                }\n            }\n        }\n    }\n}\n

      Secondly we write example code for Create/Insert/Update/Delete operations with MatrixOne.

      We need to create corresponding java source code files as Create.java, Insert.java, Select.java, Update.java under the src directory, and put the code below in these files.

      "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#create","title":"Create","text":"
      import java.sql.Connection;\nimport java.sql.SQLException;\nimport java.sql.Statement;\n\npublic class Create {\n    private static final String createTableSQL = \"create table student (\\r\\n\" + \"  id int primary key,\\r\\n\" +\n            \"  name varchar(20),\\r\\n\" + \"  email varchar(20),\\r\\n\" + \"  country varchar(20),\\r\\n\" +\n            \"  age int\\r\\n\" + \"  );\";\n\n    public static void main(String[] argv) throws SQLException {\n        Create createTable = new Create();\n        createTable.createTable();\n    }\n\n    public void createTable() throws SQLException {\n\n        System.out.println(createTableSQL);\n        // Step 1: Establishing a Connection\n        try (Connection connection = JDBCUtils.getConnection();\n             // Step 2:Create a statement using connection object\n             Statement statement = connection.createStatement();) {\n\n            // Step 3: Execute the query or update query\n            statement.execute(createTableSQL);\n        } catch (SQLException e) {\n\n            // print SQL exception information\n            JDBCUtils.printSQLException(e);\n        }\n\n        // Step 4: try-with-resource statement will auto close the connection.\n    }\n}\n

      Executing this code will create a table in the test database, then we verify in mysql client to check if the table is created.

      mysql> show create table student;\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table   | Create Table                                                                                                                                                                                        |\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| student | CREATE TABLE `student` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(20) DEFAULT NULL,\n`email` VARCHAR(20) DEFAULT NULL,\n`country` VARCHAR(20) DEFAULT NULL,\n`age` INT DEFAULT NULL,\nPRIMARY KEY (`id`)\n) |\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#insert","title":"Insert","text":"
      import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.SQLException;\n\npublic class Insert {\n    private static final String INSERT_STUDENT_SQL = \"INSERT INTO student\" +\n            \"  (id, name, email, country, age) VALUES \" +\n            \" (?, ?, ?, ?, ?);\";\n\n    public static void main(String[] argv) throws SQLException {\n        Insert insertTable = new Insert();\n        insertTable.insertRecord();\n    }\n\n    public void insertRecord() throws SQLException {\n        System.out.println(INSERT_STUDENT_SQL);\n        // Step 1: Establishing a Connection\n        try (Connection connection = JDBCUtils.getConnection();\n             // Step 2:Create a statement using connection object\n             PreparedStatement preparedStatement = connection.prepareStatement(INSERT_STUDENT_SQL)) {\n            preparedStatement.setInt(1, 1);\n            preparedStatement.setString(2, \"Tony\");\n            preparedStatement.setString(3, \"tony@gmail.com\");\n            preparedStatement.setString(4, \"US\");\n            preparedStatement.setString(5, \"20\");\n\n            System.out.println(preparedStatement);\n            // Step 3: Execute the query or update query\n            preparedStatement.executeUpdate();\n        } catch (SQLException e) {\n\n            // print SQL exception information\n            JDBCUtils.printSQLException(e);\n        }\n\n        // Step 4: try-with-resource statement will auto close the connection.\n    }\n\n}\n

      Execution result:

      mysql> select * from student;\n+------+------+----------------+---------+------+\n| id   | name | email          | country | age  |\n+------+------+----------------+---------+------+\n|    1 | Tony | tony@gmail.com | US      |   20 |\n+------+------+----------------+---------+------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#update","title":"Update","text":"
      import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.SQLException;\n\npublic class Update {\n    private static final String UPDATE_STUDENT_SQL = \"update student set name = ? where id = ?;\";\n\n    public static void main(String[] argv) throws SQLException {\n        Update updateTable = new Update();\n        updateTable.updateRecord();\n    }\n\n    public void updateRecord() throws SQLException {\n        System.out.println(UPDATE_STUDENT_SQL);\n        // Step 1: Establishing a Connection\n        try (Connection connection = JDBCUtils.getConnection();\n             // Step 2:Create a statement using connection object\n             PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_STUDENT_SQL)) {\n            preparedStatement.setString(1, \"Ram\");\n            preparedStatement.setInt(2, 1);\n\n            // Step 3: Execute the query or update query\n            preparedStatement.executeUpdate();\n        } catch (SQLException e) {\n\n            // print SQL exception information\n            JDBCUtils.printSQLException(e);\n        }\n\n        // Step 4: try-with-resource statement will auto close the connection.\n    }\n}\n

      Execution result:

      mysql> select * from student;\n+------+------+----------------+---------+------+\n| id   | name | email          | country | age  |\n+------+------+----------------+---------+------+\n|    1 | Ram  | tony@gmail.com | US      |   20 |\n+------+------+----------------+---------+------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#select","title":"SELECT","text":"
      import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n\npublic class Select {\n    private static final String QUERY = \"select id,name,email,country,age from student where id =?\";\n\n    public static void main(String[] args) {\n\n        // using try-with-resources to avoid closing resources (boiler plate code)\n\n        // Step 1: Establishing a Connection\n        try (Connection connection = JDBCUtils.getConnection();\n\n             // Step 2:Create a statement using connection object\n             PreparedStatement preparedStatement = connection.prepareStatement(QUERY);) {\n            preparedStatement.setInt(1, 1);\n            System.out.println(preparedStatement);\n            // Step 3: Execute the query or update query\n            ResultSet rs = preparedStatement.executeQuery();\n\n            // Step 4: Process the ResultSet object.\n            while (rs.next()) {\n                int id = rs.getInt(\"id\");\n                String name = rs.getString(\"name\");\n                String email = rs.getString(\"email\");\n                String country = rs.getString(\"country\");\n                String password = rs.getString(\"age\");\n                System.out.println(id + \",\" + name + \",\" + email + \",\" + country + \",\" + password);\n            }\n        } catch (SQLException e) {\n            JDBCUtils.printSQLException(e);\n        }\n        // Step 4: try-with-resource statement will auto close the connection.\n    }\n}\n

      Execution result:

      "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/","title":"Python CRUD demo","text":""},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#before-you-start","title":"Before you start","text":""},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#setup-your-environment","title":"Setup your environment","text":"

      Before you start, make sure you have downloaded and installed the following software.

      1. Make sure you have already installed and launched MatrixOne.
      2. Make sure you have already installed Python 3.8(or plus) version.

        #To check with Python installation and its version\npython3 -V\n
      3. Make sure you have already installed MySQL.

      4. Download and install pymysql and cryptography tool.

        pip3 install pymysql\npip3 install cryptography\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\n

      As we have explained how to connect to MatrixOne by pymysql in the other tutorial, we will focus on the CRUD(Create, Read, Update, Delete) implementations in this tutorial.

      "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#create-table","title":"Create Table","text":"

      Firstly we create a text file named create.py, and put the following code:

      #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n    port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"CREATE TABLE cars (id INT NOT NULL AUTO_INCREMENT, car_model VARCHAR(45) NULL,car_brand VARCHAR(45) NULL,PRIMARY KEY (`id`))\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        print(\"Table created\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

      Execute this python file by a terminal with the command line below. This will create a table cars in MatrixOne inside database test.

      > python3 create.py\nTable created\n

      We can verify the table creation with MySQL client.

      mysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| cars           |\n+----------------+\n1 row in set (0.03 sec)\nmysql> show create table cars;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                             |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| cars  | CREATE TABLE `cars` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`car_model` VARCHAR(45) DEFAULT NULL,\n`car_brand` VARCHAR(45) DEFAULT NULL,\nPRIMARY KEY (`id`)\n) |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.03 sec)\n
      "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#insert","title":"Insert","text":"

      Secondly we create a text file named insert.py, and put the following code:

      #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"INSERT INTO cars(car_model, car_brand) VALUES ('accord', 'honda')\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        if sql_exec:\n            print(sql_exec)\n            print(\"Record Added\")\n        else:\n            print(sql_exec)\n            print(\"Not Added\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

      Executing the following code will insert a record in the cars table, then we verify in mysql client to check if the record is inserted.

      > python3 insert.py\n1\nRecord Added\n
      mysql> select * from cars;\n+------+-----------+-----------+\n| id   | car_model | car_brand |\n+------+-----------+-----------+\n|    1 | accord    | honda     |\n+------+-----------+-----------+\n1 row in set (0.03 sec)\n
      "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#select","title":"Select","text":"

      Thirdly we create a text file named read.py, and put the following code:

      #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"SELECT * FROM cars\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        if sql_exec:\n            print(sql_exec)\n            print(cursor.fetchall())\n        else:\n            print(sql_exec)\n            print(\"No Record\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

      Executing this code will select and return all records in the cars table.

      > python3 read.py\n1\n[{'id': 1, 'car_model': 'accord', 'car_brand': 'honda'}]\n
      "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#update","title":"Update","text":"

      Fourthly we create a text file named update.py, and put the following code:

      #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"UPDATE cars SET car_model = 'explorer', car_brand = 'ford' WHERE id = '1'\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        if sql_exec:\n            print(sql_exec)\n            print(\"Record Updated\")\n        else:\n            print(sql_exec)\n            print(\"Not Updated\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

      Executing this code will update the record with id 1, then we verify in mysql client to check if the record is updated.

      > python3 update.py\n1\nRecord Updated\n
      mysql> select * from cars;\n+------+-----------+-----------+\n| id   | car_model | car_brand |\n+------+-----------+-----------+\n|    1 | explorer  | ford      |\n+------+-----------+-----------+\n1 row in set (0.02 sec)\n
      "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#delete","title":"Delete","text":"

      Finally we create a text file named delete.py, and put the following code:

      #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"DELETE FROM cars WHERE id = '1'\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        if sql_exec:\n            print(sql_exec)\n            print(\"Record Deleted\")\n        else:\n            print(sql_exec)\n            print(\"Not Deleted\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

      Executing this code will delete the record with id 1, then we verify in mysql client to check if the record is updated.

      > python3 delete.py\n1\nRecord Deleted\n
      mysql> select * from cars;\nEmpty set (0.03 sec)\n
      "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/","title":"Gorm CRUD demo","text":"

      This tutorial shows you how to build a simple GO+Gorm CRUD(Create, Read, Update, Delete) application with MatrixOne. Gorm is one of the most popular ORM tools in GO language.

      "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#before-you-start","title":"Before you start","text":"

      A brief introduction about these softwares concerned:

      • Gorm: The fantastic ORM library for Golang aims to be developer friendly. gorm.io/gorm and gorm.io/driver/mysql will vbe used to make Go connect to MYSQL.
      "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#setup-your-environment","title":"Setup your environment","text":"

      Before you start, make sure you have downloaded and installed the following software.

      1. Make sure you have already installed and launched MatrixOne. Connect to MatrixOne and create a database by MySQL client.

        mysql> create database test;\n
      2. Make sure you have already installed Golang 1.18 (or plus) version.

        #To check with Golang installation and its version\ngo version\n
      3. Make sure you have already installed MySQL.

      4. Use command go get to install gorm.io/gorm and gorm.io/driver/mysql.

        go get -u gorm.io/gorm\ngo get -u gorm.io/driver/mysql\n

      As we have explained how to connect to MatrixOne by Gorm in the other tutorial, we will focus on the CRUD(Create, Read, Update, Delete) implementations in this tutorial.

      "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#create","title":"Create","text":"

      As an Object Relational Mapper(ORM) tool, Gorm allows developers to create go class to map the table in relational database. In the example below, we will create a User class. The class name and the attribute name must starts with a capital letter to make public access.

      Create a go file gorm_create.go and put the code below.

      package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{\n// Logger: logger.Default.LogMode(logger.Info), //print SQL\n})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n}\n

      To enable the logging of converted SQL output, you can uncomment the following line:Logger: logger.Default.LogMode(logger.Info)

      To run the Go file, open a terminal and use the following command:

      go run gorm_create.go\n

      You can use a MySQL client to verify if the table has been successfully created.

      mysql> show tables;\n+----------------+\n| Tables_in_test |\n+----------------+\n| users          |\n+----------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#inserting-data","title":"Inserting Data","text":"

      In the following example, you will be guided on how to insert two records into the users table that was created earlier. The ID column is assumed to be auto-incremented, but you can also specify a fixed value.

      Create a new text file named gorm_insert.go and copy the following code into the file:

      package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Insert users**\nusers := []USER{\n{\n// ID: 1, //autoincrement\nCNAME:    \"lili\",\nCADDRESS: \"Shanghai\"},\n{\nID:       111,\nCNAME:    \"zhang\",\nCADDRESS: \"Biejing\",\n},\n}\n\ndb.Create(users)\n\n}\n

      Open your terminal and execute the following command to run the go file:

      go run gorm_insert.go\n

      Similarly, you can use a MySQL client to verify if the data has been successfully inserted into the table.

      mysql> select * from users;\n+------+-------+----------+\n| id   | cname | caddress |\n+------+-------+----------+\n|    1 | lili  | Shanghai |\n|  111 | zhang | Biejing  |\n+------+-------+----------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#querying-data","title":"Querying Data","text":"

      In the following example, you will be guided on how to query a subset of data based on a condition, specifically querying data where CNAME=zhang .

      Create a new text file named gorm_query.go and copy the following code into the file:

      package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Query\u2014\u2014 String condition** \nres := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&res)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nfmt.Println(res)\n\n}\n

      Open your terminal and execute the following command to run the go file:

      go run gorm_query.go\n

      The output of the terminal will include the following data.

      {111 zhang Biejing}\n
      "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#updating-data","title":"Updating Data","text":"

      In the following demonstration, you will be guided on how to update data. Create a text file named gorm_update.go and copy-paste the following code into the file:

      package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Update** \naUser := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&aUser)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nres:=db.Model(&aUser).Update(\"CADDRESS\", \"HongKong\")\nif res.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\n\n}\n

      Open your terminal and execute the following command to run the go file:

      go run gorm_update.go\n

      You can use the MySQL client to verify if the table has been updated successfully:

      mysql> select * from users;\n+------+-------+----------+\n| id   | cname | caddress |\n+------+-------+----------+\n|  111 | zhang | HongKong |\n|    1 | lili  | Shanghai |\n+------+-------+----------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#deleting-data","title":"Deleting Data","text":"

      In the following demonstration, you will be guided on how to delete a single data record. It is important to note that when deleting a single record, you need to specify the primary key, otherwise it may trigger a batch delete. Create a text file named gorm_delete.go and copy-paste the following code into the file:

      package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Delete** \naUser := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&aUser)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nres := db.Delete(&aUser)\nif res.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\n\n}\n

      Open your terminal and execute the following command to run the go file:

      go run gorm_delete.go\n

      You can use the MySQL client to verify if the table has been deleted successfully:

      mysql> select * from users;\n+------+-------+----------+\n| id   | cname | caddress |\n+------+-------+----------+\n|    1 | lili  | Shanghai |\n+------+-------+----------+\n1 row in set (0.00 sec)\n

      The above is just a partial demonstration of CRUD operations in GORM. For more usage and examples, please refer to the GORM Official Guides.

      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/","title":"SpringBoot and JPA CRUD demo","text":"

      This tutorial completes a simple Demo based on SpringBoot+Spring Data JPA+MatrixOne+Intellij IDEA , and realizes the basic CRUD function.

      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#before-you-start","title":"Before you start","text":"

      A brief introduction about these softwares concerned:

      • Spring Data JPA: JPA is a specification that defines an API for object-relational mappings and for managing persistent objects. Spring Data JPA is an object\u2013relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain model to a relational database.
      • Intellij IDEA: IntelliJ IDEA is a popular IDE for Java developers. It has a lot of plugins that can enhance our efficiency.
      • Maven: Maven is a powerful management tool in Java that can automatically download and import Jar file according to the configuration in the pom.xml file. This feature reduces the conflicts between different versions of Jar files.
      • Spring: Spring is one of the most popular frameworks in Java and more and more enterprise is using the Spring framework to build their project. Spring Boot is built on top of the conventional spring framework. So, it provides all the features of spring and is yet easier to use than spring.
      • Postman: Postman is an application used for API testing. It is an HTTP client that tests HTTP requests, utilizing a graphical user interface, through which we obtain different types of responses that need to be subsequently validated.
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#set-up-environment","title":"Set up environment","text":""},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-install-and-launch-matrixone","title":"1. Install and Launch MatrixOne","text":"

      Follow the installation instruction and launch MatrixOne. Create a database test by MySQL client.

      mysql> create database test;\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-create-a-new-spring-boot-project-using-intellij-idea","title":"2. Create a new Spring Boot Project Using IntelliJ IDEA","text":"

      Choose Spring Initializer, and name the project as you want.

      Choose Spring Web, JDBC API, Spring Data JPA, and MySQL Driver as dependencies for this project.

      Click Create, the project will be created. The dependencies are listed in the pom.xml file. Usually you don't need to modify anything.

      <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n    <groupId>com.example</groupId>\n    <artifactId>jpademo</artifactId>\n    <version>0.0.1-SNAPSHOT</version>\n    <name>jpademo</name>\n    <description>jpademo</description>\n\n    <properties>\n        <java.version>1.8</java.version>\n        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n        <spring-boot.version>2.3.7.RELEASE</spring-boot.version>\n    </properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-data-jpa</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-jdbc</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-web</artifactId>\n        </dependency>\n\n        <dependency>\n            <groupId>mysql</groupId>\n            <artifactId>mysql-connector-java</artifactId>\n            <scope>runtime</scope>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-test</artifactId>\n            <scope>test</scope>\n            <exclusions>\n                <exclusion>\n                    <groupId>org.junit.vintage</groupId>\n                    <artifactId>junit-vintage-engine</artifactId>\n                </exclusion>\n            </exclusions>\n        </dependency>\n    </dependencies>\n\n    <dependencyManagement>\n        <dependencies>\n            <dependency>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-dependencies</artifactId>\n                <version>${spring-boot.version}</version>\n                <type>pom</type>\n                <scope>import</scope>\n            </dependency>\n        </dependencies>\n    </dependencyManagement>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <version>3.8.1</version>\n                <configuration>\n                    <source>1.8</source>\n                    <target>1.8</target>\n                    <encoding>UTF-8</encoding>\n                </configuration>\n            </plugin>\n            <plugin>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-maven-plugin</artifactId>\n                <version>2.3.7.RELEASE</version>\n                <configuration>\n                    <mainClass>com.example.jpademo.JpademoApplication</mainClass>\n                </configuration>\n                <executions>\n                    <execution>\n                        <id>repackage</id>\n                        <goals>\n                            <goal>repackage</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n        </plugins>\n    </build>\n\n</project>\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-modify-the-applicationproperties-file","title":"3. Modify the application.properties file","text":"

      Under resources folder, the MatrixOne connection and Hibernate need to be configured in application.properties file.

      # Application Name\nspring.application.name=jpademo\n# Database driver\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\n# Data Source name\nspring.datasource.name=defaultDataSource\n\n# Database connection url, modify to MatrixOne address and port, with parameters\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\n# Database username and password\nspring.datasource.username=root\nspring.datasource.password=111\n# Web application port\nserver.port=8080\n\n# Hibernate configurations\nspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect\nspring.jpa.properties.hibernate.id.new_generator_mappings = false\nspring.jpa.properties.hibernate.format_sql = true\nspring.jpa.hibernate.ddl-auto = validate\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-create-table-and-insert-some-data-in-matrixone","title":"4. Create table and insert some data in MatrixOne","text":"

      Connect to MatrixOne with MySQL client and execute the following SQL statements. You can save these SQL statements in a book.sql under /resource/database/.

      mysql> USE test;\nmysql> CREATE TABLE IF NOT EXISTS `book` (\n    `id` int(11) NOT NULL AUTO_INCREMENT,\n    `author` varchar(255) DEFAULT NULL,\n    `category` varchar(255) DEFAULT NULL,\n    `name` varchar(255) DEFAULT NULL,\n    `pages` int(11) DEFAULT NULL,\n    `price` int(11) DEFAULT NULL,\n    `publication` varchar(255) DEFAULT NULL,\n    PRIMARY KEY (`id`)\n    );\nmysql> INSERT INTO `book` (`id`, `author`, `category`, `name`, `pages`, `price`, `publication`) VALUES\n(1, 'Antoine de Saint-Exupery', 'Fantancy', 'The Little Prince', 100, 50, 'Amazon'),\n(2, 'J. K. Rowling', 'Fantancy', 'Harry Potter and the Sorcerer''s Stone', 1000, 200, 'Amazon'),\n(3, 'Lewis Carroll', 'Fantancy', 'Alice''s Adventures in Wonderland', 1500, 240, 'Amazon');\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#write-code","title":"Write Code","text":"

      After setting up the environment, we write code to implement a simple CRUD application. After finishing coding, you'll have a project structure as below. You can create these packages and java class in advance. We will code the Create, Update, Insert, Delete, Select operations for this demo application.

      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-bookstorecontrollerjava","title":"1. BookStoreController.java","text":"
      package com.example.jpademo.controller;\n\nimport com.example.jpademo.entity.Book;\nimport com.example.jpademo.services.IBookStoreService;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\n\n@Controller\n@RequestMapping(\"bookservice\")\npublic class BookStoreController {\n\n    @Autowired\n    private IBookStoreService service;\n\n    @GetMapping(\"books\")\n    public ResponseEntity<List<Book>> getBooks(){\n\n        List<Book> books = service.getBooks();\n        return new ResponseEntity<List<Book>>(books, HttpStatus.OK);\n\n    }\n\n    @GetMapping(\"books/{id}\")\n    public ResponseEntity<Book> getBook(@PathVariable(\"id\") Integer id){\n        Book book = service.getBook(id);\n        return new ResponseEntity<Book>(book, HttpStatus.OK);\n    }\n\n    @PostMapping(\"books\")\n    public ResponseEntity<Book> createBook(@RequestBody Book book){\n        Book b = service.createBook(book);\n        return new ResponseEntity<Book>(b, HttpStatus.OK);\n\n    }\n\n    @PutMapping(\"books/{id}\")\n    public ResponseEntity<Book> updateBook(@PathVariable(\"id\") int id, @RequestBody Book book){\n\n        Book b = service.updateBook(id, book);\n        return new ResponseEntity<Book>(b, HttpStatus.OK);\n    }\n\n    @DeleteMapping(\"books/{id}\")\n    public ResponseEntity<String> deleteBook(@PathVariable(\"id\") int id){\n        boolean isDeleted = service.deleteBook(id);\n        if(isDeleted){\n            String responseContent = \"Book has been deleted successfully\";\n            return new ResponseEntity<String>(responseContent,HttpStatus.OK);\n        }\n        String error = \"Error while deleting book from database\";\n        return new ResponseEntity<String>(error,HttpStatus.INTERNAL_SERVER_ERROR);\n    }\n\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-boostoredaojava","title":"2. BooStoreDAO.java","text":"
      package com.example.jpademo.dao;\n\nimport com.example.jpademo.entity.Book;\nimport org.springframework.stereotype.Repository;\nimport org.springframework.transaction.annotation.Transactional;\n\nimport javax.persistence.EntityManager;\nimport javax.persistence.PersistenceContext;\nimport javax.persistence.Query;\nimport java.util.List;\n\n@Transactional\n@Repository\npublic class BookStoreDAO implements IBookStoreDAO {\n\n    @PersistenceContext\n    private EntityManager entityManager;\n\n    /**\n     * This method is responsible to get all books available in database and return it as List<Book>\n     */\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public List<Book> getBooks() {\n\n        String hql = \"FROM Book as atcl ORDER BY atcl.id\";\n        return (List<Book>) entityManager.createQuery(hql).getResultList();\n    }\n\n    /**\n     * This method is responsible to get a particular Book detail by given book id\n     */\n    @Override\n    public Book getBook(int bookId) {\n\n        return entityManager.find(Book.class, bookId);\n    }\n\n    /**\n     * This method is responsible to create new book in database\n     */\n    @Override\n    public Book createBook(Book book) {\n        entityManager.persist(book);\n        Book b = getLastInsertedBook();\n        return b;\n    }\n\n    /**\n     * This method is responsible to update book detail in database\n     */\n    @Override\n    public Book updateBook(int bookId, Book book) {\n\n        //First We are taking Book detail from database by given book id and\n        // then updating detail with provided book object\n        Book bookFromDB = getBook(bookId);\n        bookFromDB.setName(book.getName());\n        bookFromDB.setAuthor(book.getAuthor());\n        bookFromDB.setCategory(book.getCategory());\n        bookFromDB.setPublication(book.getPublication());\n        bookFromDB.setPages(book.getPages());\n        bookFromDB.setPrice(book.getPrice());\n\n        entityManager.flush();\n\n        //again i am taking updated result of book and returning the book object\n        Book updatedBook = getBook(bookId);\n\n        return updatedBook;\n    }\n\n    /**\n     * This method is responsible for deleting a particular(which id will be passed that record)\n     * record from the database\n     */\n    @Override\n    public boolean deleteBook(int bookId) {\n        Book book = getBook(bookId);\n        entityManager.remove(book);\n\n        //we are checking here that whether entityManager contains earlier deleted book or not\n        // if contains then book is not deleted from DB that's why returning false;\n        boolean status = entityManager.contains(book);\n        if(status){\n            return false;\n        }\n        return true;\n    }\n\n    /**\n     * This method will get the latest inserted record from the database and return the object of Book class\n     * @return book\n     */\n    private Book getLastInsertedBook(){\n        String hql = \"from Book order by id DESC\";\n        Query query = entityManager.createQuery(hql);\n        query.setMaxResults(1);\n        Book book = (Book)query.getSingleResult();\n        return book;\n    }\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-ibookstoredaojava","title":"3. IBookStoreDAO.java","text":"
      package com.example.jpademo.dao;\n\nimport com.example.jpademo.entity.Book;\n\nimport java.util.List;\n\npublic interface IBookStoreDAO {\n\n    List<Book> getBooks();\n    Book getBook(int bookId);\n    Book createBook(Book book);\n    Book updateBook(int bookId,Book book);\n    boolean deleteBook(int bookId);\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-bookjava","title":"4. Book.java","text":"
      package com.example.jpademo.entity;\n\nimport javax.persistence.*;\nimport java.io.Serializable;\n\n@Entity\n@Table(name=\"book\")\npublic class Book implements Serializable {\n\n    private static final long serialVersionUID = 1L;\n    @Id\n    @GeneratedValue(strategy= GenerationType.AUTO)\n    @Column(name=\"id\")\n    private int id;\n\n    @Column(name=\"name\")\n    private String name;\n\n    @Column(name=\"author\")\n    private String author;\n\n    @Column(name=\"publication\")\n    private String publication;\n\n    @Column(name=\"category\")\n    private String category;\n\n    @Column(name=\"pages\")\n    private int pages;\n\n    @Column(name=\"price\")\n    private int price;\n\n    public int getId() {\n        return id;\n    }\n\n    public void setId(int id) {\n        this.id = id;\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    public String getAuthor() {\n        return author;\n    }\n\n    public void setAuthor(String author) {\n        this.author = author;\n    }\n\n    public String getPublication() {\n        return publication;\n    }\n\n    public void setPublication(String publication) {\n        this.publication = publication;\n    }\n\n    public String getCategory() {\n        return category;\n    }\n\n    public void setCategory(String category) {\n        this.category = category;\n    }\n\n    public int getPages() {\n        return pages;\n    }\n\n    public void setPages(int pages) {\n        this.pages = pages;\n    }\n\n    public int getPrice() {\n        return price;\n    }\n\n    public void setPrice(int price) {\n        this.price = price;\n    }\n\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#5-bookstoreservicejava","title":"5. BookStoreService.java","text":"
      package com.example.jpademo.services;\n\nimport com.example.jpademo.dao.IBookStoreDAO;\nimport com.example.jpademo.entity.Book;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\n\nimport java.util.List;\n\n@Service\npublic class BookStoreService implements IBookStoreService {\n\n    @Autowired\n    private IBookStoreDAO dao;\n\n    @Override\n    public List<Book> getBooks() {\n        return dao.getBooks();\n    }\n\n    @Override\n    public Book createBook(Book book) {\n        return dao.createBook(book);\n    }\n\n    @Override\n    public Book updateBook(int bookId, Book book) {\n        return dao.updateBook(bookId, book);\n    }\n\n    @Override\n    public Book getBook(int bookId) {\n        return dao.getBook(bookId);\n    }\n\n    @Override\n    public boolean deleteBook(int bookId) {\n        return dao.deleteBook(bookId);\n    }\n\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#6-ibookstoreservicejava","title":"6. IBookStoreService.java","text":"
      package com.example.jpademo.services;\n\nimport com.example.jpademo.entity.Book;\n\nimport java.util.List;\n\npublic interface IBookStoreService {\n\n    List<Book> getBooks();\n    Book createBook(Book book);\n    Book updateBook(int bookId, Book book);\n    Book getBook(int bookId);\n    boolean deleteBook(int bookId);\n\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#7-jpademoapplication","title":"7. JpademoApplication","text":"
      package com.example.jpademo;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@SpringBootApplication\npublic class JpademoApplication {\n\n    public static void main(String[] args) {\n        SpringApplication.run(JpademoApplication.class, args);\n    }\n\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#test","title":"Test","text":"

      Build and test this project.

      When you see the following example messages, the application is well launched; we can call REST endpoints using POSTMAN.

      2022-10-27 11:16:16.793  INFO 93488 --- [           main] com.example.jpademo.JpademoApplication   : Starting JpademoApplication on username-macbookpro.local with PID 93488 (/Users/username/IdeaProjects/jpademo/target/classes started by username in /Users/username/IdeaProjects/jpademo)\n2022-10-27 11:16:16.796  INFO 93488 --- [           main] com.example.jpademo.JpademoApplication   : No active profile set, falling back to default profiles: default\n2022-10-27 11:16:18.022  INFO 93488 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.\n2022-10-27 11:16:18.093  INFO 93488 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 50ms. Found 0 JPA repository interfaces.\n2022-10-27 11:16:18.806  INFO 93488 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)\n2022-10-27 11:16:18.814  INFO 93488 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]\n2022-10-27 11:16:18.814  INFO 93488 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]\n2022-10-27 11:16:18.886  INFO 93488 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext\n2022-10-27 11:16:18.886  INFO 93488 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2005 ms\n2022-10-27 11:16:19.068  INFO 93488 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]\n2022-10-27 11:16:19.119  INFO 93488 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.25.Final\n2022-10-27 11:16:19.202  INFO 93488 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}\n2022-10-27 11:16:19.282  INFO 93488 --- [           main] com.zaxxer.hikari.HikariDataSource       : defaultDataSource - Starting...\n2022-10-27 11:16:20.025  INFO 93488 --- [           main] com.zaxxer.hikari.HikariDataSource       : defaultDataSource - Start completed.\n2022-10-27 11:16:20.035  INFO 93488 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect\n2022-10-27 11:16:21.929  INFO 93488 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]\n2022-10-27 11:16:21.937  INFO 93488 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'\n2022-10-27 11:16:22.073  WARN 93488 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning\n2022-10-27 11:16:22.221  INFO 93488 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'\n2022-10-27 11:16:22.415  INFO 93488 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''\n2022-10-27 11:16:22.430  INFO 93488 --- [           main] com.example.jpademo.JpademoApplication   : Started JpademoApplication in 6.079 seconds (JVM running for 8.765)\n2022-10-27 11:16:40.180  INFO 93488 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'\n2022-10-27 11:16:40.183  INFO 93488 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'\n2022-10-27 11:16:40.249  INFO 93488 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 66 ms\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-to-get-list-of-books-call-following-endpoint-with-get-request","title":"1. To get list of books call following endpoint with GET Request","text":"
       http://localhost:8080/bookservice/books\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-to-create-new-book-use-following-url-with-post-request","title":"2. To Create New Book use following url with POST Request","text":"
      http://localhost:8080/bookservice/books\n

      Set content type as in header as application/json, set request body as raw with JSON payload

        {\n    \"name\": \"The Lion, the Witch and the Wardrobe\",\n    \"author\": \"C. S. Lewis\",\n    \"publication\": \"Amazon\",\n    \"category\": \"Fantancy\",\n    \"pages\": 123,\n    \"price\": 10\n  }\n

      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-to-get-a-particular-book-use-following-url-with-get-request-type-in-postman","title":"3. To get a particular book, use following url with GET request type in postman","text":"
        http://localhost:8080/bookservice/books/<id>\n
      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-to-update-book-in-database-use-following-url-with-put-request-type-in-postman","title":"4. To update Book in database, use following url with PUT request type in postman","text":"
          http://localhost:8080/bookservice/books/<id>\n
      • Set content type as in header as application/json

      • Set request body as raw with JSON payload

       {\n    \"name\": \"Black Beauty\",\n    \"author\": \"Anna Sewell\",\n    \"publication\": \"Amazon\",\n    \"category\": \"Fantancy\",\n    \"pages\": 134,\n    \"price\": 12\n  }\n

      "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#5-to-delete-a-particular-book-from-database-use-following-url-with-delete-request-type-in-postman","title":"5. To delete a particular Book from database, use following url with DELETE request type in postman","text":"
        http://localhost:8080/bookservice/books/<id>\n
      mysql> select * from book;\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n| id | author                   | category | name                             | pages | price | publication |\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n|  1 | Antoine de Saint-Exupery | Fantancy | The Little Prince                |   100 |    50 | Amazon      |\n|  2 | Anna Sewell              | Fantancy | Black Beauty                     |   134 |    12 | Amazon      |\n|  3 | Lewis Carroll            | Fantancy | Alice's Adventures in Wonderland |  1500 |   240 | Amazon      |\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n3 rows in set (0.02 sec)\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/","title":"SpringBoot and MyBatis CRUD demo","text":"

      This tutorial completes a simple Demo based on SpringBoot+Mybatis+MatrixOne+Intellij IDEA , and realizes the basic CRUD function.

      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#before-you-start","title":"Before you start","text":"

      A brief introduction about these softwares concerned:

      • MyBatis: It is a popular persistence framework that can customize SQL and support for complex reports and advanced mappings. We only need to focus on the SQL itself in our project.
      • Intellij IDEA: IntelliJ IDEA is a popular IDE for Java developers. It has a lot of plugins that can enhance our efficiency.
      • Maven: Maven is a powerful management tool in Java that can automatically download and import Jar file according to the configuration in the pom.xml file. This feature reduces the conflicts between different versions of Jar files.
      • Spring: Spring is one of the most popular frameworks in Java and more and more enterprise is using the Spring framework to build their project. Spring Boot is built on top of the conventional spring framework. So, it provides all the features of spring and is yet easier to use than spring.
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#set-up-environment","title":"Set up environment","text":""},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1-install-and-launch-matrixone","title":"1. Install and Launch MatrixOne","text":"

      Follow the installation instruction and launch MatrixOne. Create a database test by MySQL client.

      mysql> create database test;\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-create-a-new-spring-boot-project-using-intellij-idea","title":"2. Create a new Spring Boot Project Using IntelliJ IDEA","text":"

      Choose Spring Initializer, and name the project as you want.

      Choose Spring Web, MyBatis Framework, JDBC API and MySQL Driver as dependencies for this project.

      Click Create, the project will be created. The dependencies are listed in the pom.xml file. Usually you don't need to modify anything.

      <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n    <groupId>com.example</groupId>\n    <artifactId>mybatis-demo</artifactId>\n    <version>0.0.1-SNAPSHOT</version>\n    <name>mybatis-demo</name>\n    <description>mybatis-demo</description>\n\n    <properties>\n        <java.version>1.8</java.version>\n        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n        <spring-boot.version>2.3.7.RELEASE</spring-boot.version>\n    </properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-jdbc</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-web</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.mybatis.spring.boot</groupId>\n            <artifactId>mybatis-spring-boot-starter</artifactId>\n            <version>2.1.4</version>\n        </dependency>\n\n        <dependency>\n            <groupId>mysql</groupId>\n            <artifactId>mysql-connector-java</artifactId>\n            <scope>runtime</scope>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-test</artifactId>\n            <scope>test</scope>\n            <exclusions>\n                <exclusion>\n                    <groupId>org.junit.vintage</groupId>\n                    <artifactId>junit-vintage-engine</artifactId>\n                </exclusion>\n            </exclusions>\n        </dependency>\n    </dependencies>\n\n    <dependencyManagement>\n        <dependencies>\n            <dependency>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-dependencies</artifactId>\n                <version>${spring-boot.version}</version>\n                <type>pom</type>\n                <scope>import</scope>\n            </dependency>\n        </dependencies>\n    </dependencyManagement>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <version>3.8.1</version>\n                <configuration>\n                    <source>1.8</source>\n                    <target>1.8</target>\n                    <encoding>UTF-8</encoding>\n                </configuration>\n            </plugin>\n            <plugin>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-maven-plugin</artifactId>\n                <version>2.3.7.RELEASE</version>\n                <configuration>\n                    <mainClass>com.example.mybatisdemo.MybatisDemoApplication</mainClass>\n                </configuration>\n                <executions>\n                    <execution>\n                        <id>repackage</id>\n                        <goals>\n                            <goal>repackage</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n        </plugins>\n    </build>\n\n</project>\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-modify-the-applicationproperties-file","title":"3. Modify the application.properties file","text":"

      Under resources folder, the MatrixOne connection need to be configured in application.properties file.

      # Application Name\nspring.application.name=MyBatisDemo\n# Database driver\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\n# Data Source name\nspring.datasource.name=defaultDataSource\n\n# Database connection url, modify to MatrixOne address and port, with paratemers\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\n# Database username and password\nspring.datasource.username=root\nspring.datasource.password=111\n\n# Mybatis mapper location\nmybatis.mapper-locations=classpath:mapping/*xml\n# Mybatis entity package\nmybatis.type-aliases-package=com.example.mybatisdemo.entity\n# Web application port\nserver.port=8080\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#write-code","title":"Write Code","text":"

      After setting up the environment, we write code to implement a simple CRUD application. After finishing coding, you'll have a project structure as below. You can create these packages and java class in advance. We will code the Create, Update, Insert, Delete, Select operations for this demo application.

      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1-usercontrollerjava","title":"1. UserController.java","text":"
      package com.example.mybatisdemo.controller;\n\nimport com.example.mybatisdemo.entity.User;\nimport com.example.mybatisdemo.service.UserService;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.ResponseBody;\nimport org.springframework.web.bind.annotation.RestController;\n\n@RestController\n@RequestMapping(\"/test\")\npublic class UserController {\n\n    String tableName = \"user\";\n    @Autowired\n    private UserService userService;\n\n    @RequestMapping(value = \"/create\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    @ResponseBody\n    public String createTable(){\n        return userService.createTable(tableName);\n    }\n\n    @RequestMapping(value = \"/selectUserByid\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    @ResponseBody\n    public String GetUser(User user){\n        return userService.Sel(user).toString();\n    }\n\n    @RequestMapping(value = \"/add\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    public String Add(User user){\n        return userService.Add(user);\n    }\n\n    @RequestMapping(value = \"/update\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    public String Update(User user){\n        return userService.Update(user);\n    }\n\n    @RequestMapping(value = \"/delete\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    public String Delete(User user){\n        return userService.Delete(user);\n    }\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-userjava","title":"2. User.java","text":"
      package com.example.mybatisdemo.entity;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\n\npublic class User {\n    private Integer id;\n    private String username;\n    private String password;\n    private String address;\n\n    public User(Integer id, String username, String password, String address) {\n        this.id = id;\n        this.username = username;\n        this.password = password;\n        this.address = address;\n    }\n\n    public Integer getId() {\n        return id;\n    }\n\n    public String getUsername() {\n        return username;\n    }\n\n    public String getPassword() {\n        return password;\n    }\n\n    public String getAddress() {\n        return address;\n    }\n\n    public void setId(Integer id) {\n        this.id = id;\n    }\n\n    public void setUsername(String username) {\n        this.username = username;\n    }\n\n    public void setPassword(String password) {\n        this.password = password;\n    }\n\n    public void setAddress(String address) {\n        this.address = address;\n    }\n\n    @Override\n    public String toString() {\n        return \"User{\" +\n                \"id=\" + id +\n                \", username='\" + username + '\\'' +\n                \", password='\" + password + '\\'' +\n                \", address='\" + address + '\\'' +\n                '}';\n    }\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-usermapperjava","title":"3. UserMapper.java","text":"
      package com.example.mybatisdemo.mapper;\n\nimport com.example.mybatisdemo.entity.User;\nimport org.apache.ibatis.annotations.Param;\nimport org.springframework.stereotype.Repository;\n\n@Repository\npublic interface UserMapper {\n\n    int createTable(@Param(\"tableName\") String tableName);\n\n    User Sel(@Param(\"user\")User user);\n\n    int Add(@Param(\"user\")User user);\n\n    int Update(@Param(\"user\")User user);\n\n    int Delete(@Param(\"user\")User user);\n\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#4-userservicejava","title":"4. UserService.java","text":"
      package com.example.mybatisdemo.service;\n\nimport com.example.mybatisdemo.entity.User;\nimport com.example.mybatisdemo.mapper.UserMapper;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\n\n@Service\npublic class UserService {\n    @Autowired\n    UserMapper userMapper;\n\n    public String createTable(String table){\n        int a = userMapper.createTable(table);\n        if (a == 1) {\n            return \"Create table failed\";\n        } else {\n            return \"Create table successfully\";\n        }\n    }\n\n    public User Sel(User user) {\n        return userMapper.Sel(user);\n    }\n\n    public String Add(User user) {\n        int a = userMapper.Add(user);\n        if (a == 1) {\n            return \"Add user successfully\";\n        } else {\n            return \"Add user failed\";\n        }\n    }\n\n    public String Update(User user) {\n        int a = userMapper.Update(user);\n        if (a == 1) {\n            return \"Update user successfully\";\n        } else {\n            return \"Update user failed\";\n        }\n    }\n\n    public String Delete(User user) {\n        int a = userMapper.Delete(user);\n        if (a == 1) {\n            return \"Delete user successfully\";\n        } else {\n            return \"Delete user failed\";\n        }\n    }\n\n};\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#5-mybatisdemoapplicationjava","title":"5. MyBatisDemoApplication.java","text":"
      package com.example.mybatisdemo;\n\nimport org.mybatis.spring.annotation.MapperScan;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@MapperScan(\"com.example.mybatisdemo.mapper\")\n@SpringBootApplication\npublic class MyBatisDemoApplication {\n    public static void main(String[] args) {\n        SpringApplication.run(MyBatisDemoApplication.class, args);\n    }\n}\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#6-usermapperxml","title":"6. UserMapper.xml","text":"
      <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">\n\n<mapper namespace=\"com.example.mybatisdemo.mapper.UserMapper\">\n\n    <resultMap id=\"BaseResultMap\" type=\"com.example.mybatisdemo.entity.User\">\n        <result column=\"id\" jdbcType=\"INTEGER\" property=\"id\"/>\n        <result column=\"userName\" jdbcType=\"VARCHAR\" property=\"username\"/>\n        <result column=\"passWord\" jdbcType=\"VARCHAR\" property=\"password\"/>\n        <result column=\"realName\" jdbcType=\"VARCHAR\" property=\"address\"/>\n    </resultMap>\n\n    <update id=\"createTable\" parameterType=\"string\">\n        CREATE TABLE ${tableName} (\n            `id` int(11) NOT NULL AUTO_INCREMENT,\n            `username` varchar(255) DEFAULT NULL,\n            `password` varchar(255) DEFAULT NULL,\n            `address` varchar(255) DEFAULT NULL,\n            PRIMARY KEY (`id`)\n        );\n    </update>\n\n    <select id=\"Sel\" resultType=\"com.example.mybatisdemo.entity.User\">\n        select * from user where 1=1\n        <if test=\"user.id != null\">\n            AND id = #{user.id}\n        </if>\n    </select>\n\n    <insert id=\"Add\" parameterType=\"com.example.mybatisdemo.entity.User\">\n        INSERT INTO user\n        <trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">\n            <if test=\"user.username != null\">\n                username,\n            </if>\n            <if test=\"user.password != null\">\n                password,\n            </if>\n            <if test=\"user.address != null\">\n                address,\n            </if>\n        </trim>\n        <trim prefix=\"VALUES (\" suffix=\")\" suffixOverrides=\",\">\n            <if test=\"user.username != null\">\n                #{user.username,jdbcType=VARCHAR},\n            </if>\n            <if test=\"user.password != null\">\n                #{user.password,jdbcType=VARCHAR},\n            </if>\n            <if test=\"user.address != null\">\n                #{user.address,jdbcType=VARCHAR},\n            </if>\n        </trim>\n    </insert>\n\n    <update id=\"Update\" parameterType=\"com.example.mybatisdemo.entity.User\">\n        UPDATE user\n        <set>\n            <if test=\"user.username != null\">\n                username = #{user.username},\n            </if>\n            <if test=\"user.password != null\">\n                password = #{user.password},\n            </if>\n            <if test=\"user.address != null\">\n                address = #{user.address},\n            </if>\n        </set>\n        WHERE\n        id=#{user.id}\n    </update>\n\n    <delete id=\"Delete\"  parameterType=\"com.example.mybatisdemo.entity.User\">\n        DELETE FROM user WHERE id = #{user.id}\n    </delete>\n\n</mapper>\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#test","title":"Test","text":"

      Build and launch this project.

      When you see the following example messages, the application is well-launched, and you can open your browser and send HTTP requests.

      2022-10-26 16:13:24.030  INFO 60253 --- [           main] c.e.mybatisdemo.MyBatisDemoApplication   : Starting MyBatisDemoApplication on username-macbookpro.local with PID 60253 (/Users/username/IdeaProjects/MyBatisDemo/target/classes started by username in /Users/username/IdeaProjects/MyBatisDemo)\n2022-10-26 16:13:24.035  INFO 60253 --- [           main] c.e.mybatisdemo.MyBatisDemoApplication   : No active profile set, falling back to default profiles: default\n2022-10-26 16:13:25.415  INFO 60253 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)\n2022-10-26 16:13:25.421  INFO 60253 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]\n2022-10-26 16:13:25.421  INFO 60253 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]\n2022-10-26 16:13:25.476  INFO 60253 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext\n2022-10-26 16:13:25.477  INFO 60253 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1390 ms\n2022-10-26 16:13:26.020  INFO 60253 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'\n2022-10-26 16:13:26.248  INFO 60253 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''\n2022-10-26 16:13:26.272  INFO 60253 --- [           main] c.e.mybatisdemo.MyBatisDemoApplication   : Started MyBatisDemoApplication in 2.669 seconds (JVM running for 3.544)\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1-test-create-table","title":"1. Test Create Table","text":"

      Launch your browser and type the following url:

      http://localhost:8080/test/create\n

      In MySQL client, we can verify if the table has been successfully created.

      mysql> use test;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nmysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| user           |\n+----------------+\n1 row in set (0.00 sec)\n\nmysql> show create table user;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                                                  |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| user  | CREATE TABLE `user` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`username` VARCHAR(255) DEFAULT null,\n`password` VARCHAR(255) DEFAULT null,\n`address` VARCHAR(255) DEFAULT null,\nPRIMARY KEY (`id`)\n) |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-test-add-user","title":"2. Test Add User","text":"

      Launch your browser and type the following url:

      http://localhost:8080/test/add?username=tom&password=123456&address=shanghai\n

      In MySQL client, we can verify if the record is added.

      mysql> select * from user;\n+------+----------+----------+----------+\n| id   | username | password | address  |\n+------+----------+----------+----------+\n|    1 | tom      | 123456   | shanghai |\n+------+----------+----------+----------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-test-select-user","title":"3. Test Select User","text":"

      Launch your browser and type the following url:

      http://localhost:8080/test/selectUserByid?id=1\n

      We can directly get the queried result from the browser.

      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#4-test-update-user","title":"4. Test Update User","text":"

      Launch your browser and type the following url:

      http://localhost:8080/test/update/username=tom&password=654321&address=beijing\n

      In MySQL client, we can verify if the record is updated.

      mysql> select * from user;\n+------+----------+----------+---------+\n| id   | username | password | address |\n+------+----------+----------+---------+\n|    1 | tom      | 654321   | beijing |\n+------+----------+----------+---------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#5-test-delete-user","title":"5. Test Delete User","text":"

      Launch your browser and type the following url:

      http://localhost:8080/test/delete?id=1\n

      In MySQL client, we can verify if the record is deleted.

      mysql> select * from user;\nEmpty set (0.00 sec)\n
      "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/","title":"SQLAlchemy CRUD demo","text":"

      This tutorial shows you how to build a simple Python+SQLAlchemy CRUD(Create, Read, Update, Delete) application with MatrixOne. SQLAlchemy is one of the most popular ORM tools in python language.

      "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#before-you-start","title":"Before you start","text":"

      A brief introduction about these softwares concerned:

      • SQLAlchemy: SQLAlchemy is a python library that facilitates the communication between Python programs and databases. Most of the times, this library is used as an Object Relational Mapper (ORM) tool that translates Python classes to tables on relational databases and automatically converts function calls to SQL statements.
      • Faker: Faker is a Python library that generates fake data. Fake data is often used for testing or filling databases with some dummy data.
      "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#setup-your-environment","title":"Setup your environment","text":"

      Before you start, make sure you have downloaded and installed the following software.

      1. Make sure you have already installed and launched MatrixOne. Connect to MatrixOne and create a database by MySQL client.

        mysql> create database test;\n
      2. Make sure you have already installed Python 3.8(or plus) version.

        #To check with Python installation and its version\npython3 -V\n
      3. Make sure you have already installed MySQL.

      4. Download and install sqlalchemy, pymysql, cryptography and faker tool.

        pip3 install sqlalchemy\npip3 install pymysql\npip3 install cryptography\npip3 install faker\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install sqlalchemy -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install faker -i https://pypi.tuna.tsinghua.edu.cn/simple\n

      As we have explained how to connect to MatrixOne by SQLAlchemy in the other tutorial, we will focus on the CRUD(Create, Read, Update, Delete) implementations in this tutorial.

      "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#create","title":"Create","text":"

      As an Object Relational Mapper(ORM) tool, SQLAlchemy allows developers to create python class to map the table in relational database. In the example below, we will create a User class which is a representation of User table in MatrixOne, the code which defines User is equal to a SQL statement as:

      CREATE TABLE `User` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`cname` VARCHAR(64) DEFAULT NULL,\n`caddress` VARCHAR(512) DEFAULT NULL,\nPRIMARY KEY (`id`)\n)\n

      Let's now create this example in a text file named sqlalchemy_create.py, and put the following code:

      from faker import Factory\nfrom sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nfaker = Factory.create()\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\n\nclass Customer(Base):\n    __tablename__ = \"Customer\"\n    id = Column(Integer, primary_key=True,autoincrement=True)\n    cname = Column(String(64))\n    caddress = Column(String(512))\n\n    def __init__(self,name,address):\n        self.cname = name\n        self.caddress = address\n\n    def __str__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n    def __repr__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# Generate 10 Customer records\nCustomers = [Customer(name= faker.name(),address = faker.address()) for i in range(10)]\n\n# Create the table\nBase.metadata.create_all(engine)\n\n# Insert all customer records to Customer table\nsession.add_all(Customers)\n\nsession.commit()\n

      Execute this file in a terminal with such command:

      > python3 sqlalchemy_create.py\n

      Then we verify the table creation in MySQL client:

      mysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| Customer       |\n+----------------+\n1 row in set (0.04 sec)\nmysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id   | cname            | caddress                                            |\n+------+------------------+-----------------------------------------------------+\n|    1 | Wendy Luna       | 002 Brian Plaza\nAndrewhaven, SC 88456               |\n|    2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249                            |\n|    3 | Angela Ramos     | 029 Todd Curve Apt. 352\nMooreville, FM 15950        |\n|    4 | Lisa Bruce       | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853     |\n|    5 | Julie Moore      | Unit 1117 Box 1029\nDPO AP 87468                     |\n|    6 | David Massey     | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549    |\n|    7 | David Mccann     | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n|    8 | Morgan Price     | 57463 Lisa Drive\nThompsonshire, NM 88077            |\n|    9 | Samuel Griffin   | 186 Patel Crossing\nNorth Stefaniechester, WV 08221  |\n|   10 | Tristan Pierce   | 593 Blankenship Rapids\nNew Jameshaven, SD 89585     |\n+------+------------------+-----------------------------------------------------+\n10 rows in set (0.03 sec)\n
      "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#read","title":"Read","text":"

      In the following example, we read data from the Customer table by two ways.

      The first one is a full scan, which equals to a query as:

      select * from `Customer`\n

      The second one is a point query, which equals to a query as:

      select * from `Customer` where `cname` = 'David Mccann';\n

      We create this example in a text file named sqlalchemy_read.py, and put the following code:

      from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n    __tablename__ = \"Customer\"\n    id = Column(Integer, primary_key=True,autoincrement=True)\n    cname = Column(String(64))\n    caddress = Column(String(512))\n\n    def __init__(self,name,address):\n        self.cname = name\n        self.caddress = address\n\n    def __str__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n    def __repr__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# query all data\ncustomers = session.query(Customer).all()\n\nfor customer in customers:\n     print(customer.__str__() +\"\\n--------------------------\\n\")\n\n# query with a filter condition\nMccann = session.query(Customer).filter_by(cname='David Mccann').first()\nprint(Mccann)\nprint(\"\\n------------------------\\n\")\n

      Execute this file in a terminal with such command and we will see the query result:

      > python3 sqlalchemy_read.py\ncname:Wendy Luna caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n--------------------------\n\ncname:Meagan Rodriguez caddress:USCGC Olson\nFPO AP 21249\n--------------------------\n\ncname:Angela Ramos caddress:029 Todd Curve Apt. 352\nMooreville, FM 15950\n--------------------------\n\ncname:Lisa Bruce caddress:68103 Mackenzie Mountain\nNorth Andrew, UT 29853\n--------------------------\n\ncname:Julie Moore caddress:Unit 1117 Box 1029\nDPO AP 87468\n--------------------------\n\ncname:David Massey caddress:207 Wayne Groves Apt. 733\nVanessashire, NE 34549\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n--------------------------\n\ncname:Morgan Price caddress:57463 Lisa Drive\nThompsonshire, NM 88077\n--------------------------\n\ncname:Samuel Griffin caddress:186 Patel Crossing\nNorth Stefaniechester, WV 08221\n--------------------------\n\ncname:Tristan Pierce caddress:593 Blankenship Rapids\nNew Jameshaven, SD 89585\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n\n------------------------\n
      "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#update","title":"Update","text":"

      In the following example, we update the first cname column of Customer table by another value. We create this example in a text file named sqlalchemy_update.py, and put the following code:

      from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n    __tablename__ = \"Customer\"\n    id = Column(Integer, primary_key=True,autoincrement=True)\n    cname = Column(String(64))\n    caddress = Column(String(512))\n\n    def __init__(self,name,address):\n        self.cname = name\n        self.caddress = address\n\n    def __str__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n    def __repr__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\ncustomer = session.query(Customer).first()\nprint(customer)\nprint(\"\\n---------------------\\n\")\n\n# Rename customer\ncustomer.cname = \"Coby White\"\n\n\nsession.commit()\n\n# See the updated result\ncustomer = session.query(Customer).first()\nprint(customer)\n

      Execute this file in a terminal with such command and we will see the query result:

      > python3 sqlalchemy_update.py     \ncname:Wendy Luna caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n\n---------------------\n\ncname:Coby White caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n

      Then we verify the record being updated in MySQL client:

      mysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id   | cname            | caddress                                            |\n+------+------------------+-----------------------------------------------------+\n|    1 | Coby White       | 002 Brian Plaza\nAndrewhaven, SC 88456               |\n|    2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249                            |\n|    3 | Angela Ramos     | 029 Todd Curve Apt. 352\nMooreville, FM 15950        |\n|    4 | Lisa Bruce       | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853     |\n|    5 | Julie Moore      | Unit 1117 Box 1029\nDPO AP 87468                     |\n|    6 | David Massey     | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549    |\n|    7 | David Mccann     | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n|    8 | Morgan Price     | 57463 Lisa Drive\nThompsonshire, NM 88077            |\n|    9 | Samuel Griffin   | 186 Patel Crossing\nNorth Stefaniechester, WV 08221  |\n|   10 | Tristan Pierce   | 593 Blankenship Rapids\nNew Jameshaven, SD 89585     |\n+------+------------------+-----------------------------------------------------+\n10 rows in set (0.02 sec)\n
      "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#delete","title":"Delete","text":"

      In the following example, we delete the first record of the Customer table. We create this example in a text file named sqlalchemy_detele.py, and put the following code:

      from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n    __tablename__ = \"Customer\"\n    id = Column(Integer, primary_key=True,autoincrement=True)\n    cname = Column(String(64))\n    caddress = Column(String(512))\n\n    def __init__(self,name,address):\n        self.cname = name\n        self.caddress = address\n\n    def __str__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n    def __repr__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# delete the first record\ncustomer = session.query(Customer).first()\n\nsession.delete(customer)\nsession.commit()\n\n# query all data\ncustomers = session.query(Customer).all()\n\nfor customer in customers:\n     print(customer.__str__() +\"\\n--------------------------\\n\")\n

      Execute this file in a terminal with such command and we will see the query result:

      > python3 sqlalchemy_delete.py         \ncname:Meagan Rodriguez caddress:USCGC Olson\nFPO AP 21249\n--------------------------\n\ncname:Angela Ramos caddress:029 Todd Curve Apt. 352\nMooreville, FM 15950\n--------------------------\n\ncname:Lisa Bruce caddress:68103 Mackenzie Mountain\nNorth Andrew, UT 29853\n--------------------------\n\ncname:Julie Moore caddress:Unit 1117 Box 1029\nDPO AP 87468\n--------------------------\n\ncname:David Massey caddress:207 Wayne Groves Apt. 733\nVanessashire, NE 34549\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n--------------------------\n\ncname:Morgan Price caddress:57463 Lisa Drive\nThompsonshire, NM 88077\n--------------------------\n\ncname:Samuel Griffin caddress:186 Patel Crossing\nNorth Stefaniechester, WV 08221\n--------------------------\n\ncname:Tristan Pierce caddress:593 Blankenship Rapids\nNew Jameshaven, SD 89585\n--------------------------\n

      Then we verify the record being deleted in MySQL client:

      mysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id   | cname            | caddress                                            |\n+------+------------------+-----------------------------------------------------+\n|    2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249                            |\n|    3 | Angela Ramos     | 029 Todd Curve Apt. 352\nMooreville, FM 15950        |\n|    4 | Lisa Bruce       | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853     |\n|    5 | Julie Moore      | Unit 1117 Box 1029\nDPO AP 87468                     |\n|    6 | David Massey     | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549    |\n|    7 | David Mccann     | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n|    8 | Morgan Price     | 57463 Lisa Drive\nThompsonshire, NM 88077            |\n|    9 | Samuel Griffin   | 186 Patel Crossing\nNorth Stefaniechester, WV 08221  |\n|   10 | Tristan Pierce   | 593 Blankenship Rapids\nNew Jameshaven, SD 89585     |\n+------+------------------+-----------------------------------------------------+\n9 rows in set (0.04 sec)\n
      "}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-,:!=\\[\\]()\"/]+|(?!\\b)(?=[A-Z][a-z])|\\.(?!\\d)|&[lg]t;","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"MatrixOne Documentation","text":"

      Welcome to the MatrixOne documentation center!

      This center holds related concepts and technical architecture introductions, product features, user guides, and reference manuals to help you work with MatrixOne.

      "},{"location":"#recommended-articles","title":"Recommended articles","text":"

      Select one of the articles below to begin your MatrixOne journey. If you ...

      • Are new to MatrixOne, start with Overview to learn about basic concepts, key features and architecture.

      • Are Want to jump to the quickstart to build a standalone MatrixOne and learn the basic knowledge of SQL, start with Getting Started.

      • Are applicators and want to try out MatrixOne as a basic database, select Developing Guide for the tutorial and developing guide.

      • An experienced MatrixOne coder looking for SQL statements, data types functions, or catalog, go to Reference.

      Overview Get Started Developing Guide Reference MatrixOne Introduction Install MatrixOne Java CRUD demo SQL Reference MatrixOne Architecture Basic SQL Python CRUD demo Data Types"},{"location":"#continuous-improvement","title":"Continuous Improvement","text":"

      Whether you're seeking fundamental concepts, step-by-step procedures, curated guides, or handy references, we're crafting content to accommodate your needs.

      We warmly welcome contributions to MatrixOne documentation from everyone. Our community aims to streamline the contribution process, making it simple. Additionally, we'll provide updates every month.

      You'll find an Edit button at the top of each page. Click on it to access a landing page with instructions for suggesting published document changes. These resources are yours for you to use. Your participation is not only encouraged but also crucial!

      If you encounter any documentation issues, please feel free to create an Issue to inform us or directly submit a Pull Request to help us fix or update the content.

      Note

      For how to make contributions to documentation, see Contributing to MatrixOne Documentation.

      "},{"location":"#join-us","title":"Join us!","text":"

      The MatrixOne community on GitHub is dynamic, enthusiastic, and well-informed. Engage in discussions, express your viewpoints, propose features, and delve into the code.

      A similarly passionate community awaits you in the MatrixOne Slack and MatrixOne channel.

      "},{"location":"MatrixOne/glossary/","title":"Glossary","text":""},{"location":"MatrixOne/glossary/#terms","title":"Terms","text":"

      It's helpful to understand a few terms before reading our architecture documentation.

      Term Definition A AST (Abstract syntax tree) Abstract Syntax Trees or ASTs are tree representations of code. They are a fundamental part of the way a compiler works. C Cluster A distributed MatrixOne deployment, which acts as a single logical application. E Explicit Transactions Explicit Transaction has the beginning, ending and rollback of transactions with the command Begin Transaction, Commit Transaction and Rollback Transaction. I Implicit Transactions Implicit Transaction is the auto commit. There is no beginning or ending of the transaction. O Optimistic transaction Optimistic transaction, the optimistic transaction means that when the transaction starts, no conflict detection or lock will be performed, the current relevant data will be cached in the corresponding memory area, and the data will be added, deleted, or modified. P Pessimistic transaction Pessimistic transaction, the default transaction mode of MatrixOne, that is, when the transaction starts, it will assume that the transaction-related tables are in a state where write conflicts will occur and lock the corresponding data table or a data row in advance to complete the locking action Finally, the insertion, modification, or deletion of data is cached in memory. After committing or rolling back, the data is placed on the disk, and the lock is released. S Snapshot Isolation (SI) Snapshot Isolation is a multi-version concurrency control approach that is widely used in practice. MatrixOne supports distributed transaction of snapshot isolation level."},{"location":"MatrixOne/glossary/#concepts","title":"Concepts","text":"

      MatrixOne relies heavily on the following concepts. Being familiar with them will help you understand what our architecture achieves.

      Term Definition A Auto-Rebalance A modern distributed database should do more than just split data amongst a number of servers. The automatic process of storage and workload distribution among servers is called an Auto-Rebalance. C Consistency MatrixOne supports a strong consistency. It is guaranted that after any successful data write, the reading afterwards will get the latest value, no matter from which store. E Execution Plan An execution plan in a database is a simple graphical representation of the operations that the query optimizer generates to calculate the most efficient way to return a set of results. F Fault-Tolerance Fault-Tolerance simply means a system's ability to continue operating uninterrupted despite the failure of one or more of its components. M Monolithic Engine A monolithic database engine is designed to support hybrid workloads: transactional, analytical, streaming, time-series, machine learning, and so on. Materialized View A materialized view is a pre-computed data set derived from a query specification (the SELECT in the view definition) and stored for later use. Materialized view is usually used for increasing performance and efficiency. Metadata Metadata is the data that describes the structure and creation method of data in a database. P Paxos Paxos is an algorithm that is used to achieve consensus among a distributed set of computers that communicate via an asynchronous network. R Raft Raft is a consensus algorithm that is designed to be easy to understand. It's equivalent to Paxos in fault-tolerance and performance. The difference is that it's decomposed into relatively independent subproblems, and it cleanly addresses all major pieces needed for practical systems. Raft Group and Leader Raft defines a strong, single leader and number of followers in a group of peers. The group represents a replicated state machine. Only the leader may service client requests. The leader replicates actions to the followers. S SIMD instruction SIMD is short for Single Instruction/Multiple Data, while the term SIMD operations refers to a computing method that enables processing of multiple data with a single instruction. T Transaction A set of operations performed on your database that satisfy the requirements of ACID semantics. TAE Transactional Analytic Engine. The storage engine is the main public interface of the storage layer, which can support both row and column storage and transaction processing capabilities. V Vectorized Execution Vectorized data processing helps with developing faster analytical query engines by making efficient utilization of CPU cache. Arrow's columnar format allows to use lightweight schemes like dictionary encoding, bit packing, and run length encoding, which favor query performance over compression ratio."},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/","title":"Make Your First Contribution","text":"

      Thank you for your interest in contributing to MatrixOne. Contributions are welcome from everyone.

      This document will help you get started on your first contribution to MatrixOne.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#how-to-contribute","title":"How to Contribute?","text":"

      Before setting out contributions, you need to figure out what area you are trying to help us in. You can see Types of contributions for more details.

      As your first-ever contribution, it can be selected from the following categories which require little technical background of the contributor:

      • To report a bug in the code

      • To improve the MatrixOne documentation

      File an issue to describe the problem before working on it. In addition, you will also find issues labeled with good-first-issue, which represents issues suitable for new contributors. Such Issues contain clear steps and expected output. You may start your first contribution based on these issues.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#assign-your-issue","title":"Assign Your Issue","text":"

      It's difficult to report an issue when you are just a newcomer on account of little knowledge of MatrixOne or relative contents, so we list good-first-issues suitable for new contributors to work with and be easy to fix. After deciding on a suitable issue to work on, you can comment /assign on the issue you would like to work on, and you will be automatically assigned to the issue. You can then find yourself listed under the Assignees section.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#prerequisite","title":"Prerequisite","text":"

      Before working on the issue you are assigned, please make sure you have set up a development environment and installed MatrixOne. You can see Preparation for more details.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#workflow","title":"Workflow","text":""},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-1-fork-the-repository","title":"Step 1: Fork the Repository","text":"

      Visit our Github Repository. On the top right of the page, click the Fork button (top right) to create a cloud-based fork of the repository.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-2-clone-fork-to-local-storage","title":"Step 2: Clone fork to local storage","text":"

      Open the repository you forked from MatrixOne. Click on the Code button and then the Copy to Clipboard icon. Next, move to the working directory you expect in local and launch your terminal. Run the following Git command:

      git clone <content you just copied>\n

      For example:

      git clone git@github.com:<yourname>/matrixone.git\n

      <yourname> is the ID you signed in at GitHub. This Git command downloads the content of MatrixOne repository you forked on GitHub to your local device.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-3-add-matrixone-repo-as-a-remote-repository","title":"Step 3: Add MatrixOne repo as a remote repository","text":"

      You can add MatrixOrigin/MatrixOne repository as a remote repository in local with:

      git remote add upstream https://github.com/matrixorigin/matrixone.git  \n

      upstream is the designation of this remote repository. If you want to replace it with other words you want, don't forget to replace it as well in the next steps, or some errors will happen.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-4-develop","title":"Step 4: Develop","text":""},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#make-some-changes","title":"Make some changes","text":"

      Now you can edit the code, modify the documents, and make whatever changes you want about your issue in the branch you just created.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#run-matrixone-in-a-standalone-mode","title":"Run MatrixOne in a standalone mode","text":"

      If you want to demonstrate whether the changes you made are valid or produce an issue, you need to run MatrixOne in a standalone mode. Before running, make sure you have deployed MatrixOne according to our Deploy standalone MatrixOne.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-5-commit-to-your-local-repo","title":"Step 5: Commit to your local repo","text":"

      Having completed your modification, you can add the files you just modified using the git add command:

      git add <filename>\n

      <filename> is the name of the file you just modified. And you can use the following command to add all the files in the current folder:

      git add .\n

      Next, you can commit these changes using the git commit command:

      git commit -m \"<commit message>\"  -s\n

      Summarize and describe your modification briefly in the place of <commit message>. -s adds your sign-off message to your commit message.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-6-push-to-your-remote-repo","title":"Step 6: Push to your remote repo","text":"

      After committing your modification, you should push your local branch to GitHub using the git push command, and we recommend you to push to a new branch:

      git push origin main:NEW_BRANCH\n

      NEW_BRANCH is the name of the new branch you created and push to. Also, you can replace it with another name you want.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-7-create-a-pull-request","title":"Step 7: Create a pull request","text":"

      Having pushed your changes, you can visit your folk at https://github.com/$user/matrixone, and click the Compare & Pull Request button to create a pull request in NEW_BRANCH for your modification to the MatrixOne repository.

      Note

      You should fill in the required information based on the PR template.

      Once your PR is opened, it will be assigned to reviewers. These reviewers will check your contribution and do a detailed review according to the correctness, bugs, style, sand so on.

      "},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#step-8-after-merging-keep-your-repo-in-sync","title":"Step 8: After merging, Keep your repo in sync","text":"

      Congratulations that your contributions are accepted and merged into the project! And there are some operations left to do, which help keep project committing history clean and keep your local and remote repo synchronized with MatrixOne repo. Overrides local committing history with the following command:

      git pull --force upstream main:main\n

      Lastly, upgrade the main branch of your folk in Github:

      git push --force origin main:main\n
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/","title":"Code Comment Style","text":"

      This document describes the code comment style applied to MatrixOne style. When you are ready to commit, please follow the style to write good code comments.

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#why-does-a-good-comment-matter","title":"Why does a good comment matter?","text":"
      • To speed up the reviewing process
      • To help maintain the code
      • To improve the API document readability
      • To improve the development efficiency of the whole team
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#wherewhen-to-comment","title":"Where/When to comment?","text":"

      Write a comment where/when:

      • For important code
      • For obscure code
      • For tricky or interesting code
      • For a complex code block
      • If a bug exists in the code but you cannot fix it or you just want to ignore it for the moment
      • If the code is not optimal but you don't have a smarter way now
      • To remind yourself or others of missing functionality or upcoming requirements not present in the code

      A comment is generally required for:

      • Package (Go)
      • File
      • Type
      • Constant
      • Function
      • Method
      • Variable
      • Typical algorithm
      • Exported name
      • Test case
      • TODO
      • FIXME
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#how-to-comment","title":"How to comment?","text":""},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#format-of-a-good-comment","title":"Format of a good comment","text":"
      • Go

        • Use // for a single-line comment and trailing comment
        • Use /* ... */ for a block comment (used only when needed)
        • Use gofmt to format your code
      • Place the single-line and block comment above the code it's annotating

      • Fold long lines of comments
      • Each line of text in your code and comment should be at most 100 characters long
      • For a comment containing a URL

        • Use a relative URL if the text is linked to a file within the same GitHub repository
        • Use an absolute URL in docs and docs-cn repositories if the code with this comment is copied from another repository
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#language-for-a-good-comment","title":"Language for a good comment","text":"
      • Word

        • Use American English rather than British English

          • color, canceling, synchronize (Recommended)
          • colour, cancelling, synchronise (Not recommended)
        • Use correct spelling

        • Use standard or official capitalization

          • MatrixOne, Raft, SQL (Right)
          • matrixone, RAFT, sql (Wrong)
        • Use words and expressions consistently

          • \"dead link\" vs. \"broken link\" (Only one of them can appear in a single document)
        • Do not use lengthy compound words

        • Do not abbreviate unless it is absolutely necessary

        • We should be used only when it means the code writer and the reader

      • Sentence

        • Use standard grammar and correct punctuation
        • Use relatively short sentences
      • Capitalize the first letter of sentences and end them with periods

        • If a lower-case identifier comes at the beginning of a sentence, don't capitalize it

          // enterGame causes Players to enter the\n// video game, which is about a romantic\n// story in ancient China.\nfunc enterGame() os.Error {\n    ...\n}\n
      • When used for description, comments should be descriptive rather than imperative

        • Opens the file (Right)
        • Open the file (Wrong)
      • Use \"this\" instead of \"the\" to refer to the current thing

        • Gets the toolkit for this component (Recommended)
        • Gets the toolkit for the component (Not recommended)
      • The Markdown format is allowed

        • Opens the log file
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#tips-for-a-good-comment","title":"Tips for a good comment","text":"
      • Comment code while writing it
      • Do not assume the code is self-evident
      • Avoid unnecessary comments for simple code
      • Write comments as if they were for you
      • Make sure the comment is up-to-date
      • Let the code speak for itself

      Thanks for your contribution!

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/","title":"MatrixOne Code of Conduct","text":""},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#our-pledge","title":"Our Pledge","text":"

      In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity, and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#our-standards","title":"Our Standards","text":"

      Examples of behavior that contributes to creating a positive environment include:

      • Using welcoming and inclusive language
      • Being respectful of differing viewpoints and experiences
      • Gracefully accepting constructive criticism
      • Focusing on what is best for the community
      • Showing empathy towards other community members

      Examples of unacceptable behavior by participants include:

      • The use of sexualized language or imagery and unwelcome sexual attention or advances
      • Trolling, insulting/derogatory comments, and personal or political attacks
      • Public or private harassment
      • Publishing others' private information, such as a physical or electronic address, without explicit permission
      • Other conduct which could reasonably be considered inappropriate in a professional setting
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#our-responsibilities","title":"Our Responsibilities","text":"

      Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

      Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#scope","title":"Scope","text":"

      This Code of Conduct applies within all project spaces, and when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#enforcement","title":"Enforcement","text":"

      Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hai.jin@matrixorigin.io. All complaints will be reviewed and investigated and resulting in a response deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

      Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other the project leadership members.

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#attribution","title":"Attribution","text":"

      This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

      For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/","title":"Commit Message and Pull Request Style","text":"

      This document describes the commit message and Pull Request style applied to all MatrixOrigin repositories. When you are ready to commit, be sure to follow the style guide to write a good commit message, a good Pull Request title, and a description.

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#why-a-good-commit-message-matters","title":"Why a good commit message matters","text":"
      • To speed up the reviewing process
        • Help the reviewers better understand the PR
        • Allow ignoring unimportant commits
      • To help us write good Release Notes
      • To help the future maintainers establish the context
        • Provide better information when browsing the history
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#what-is-a-good-commit-message","title":"What is a good commit message","text":"

      Elements of a good commit message:

      1. What is your change? (mandatory)

        It can be fixing a specific bug, adding a feature, improving performance, reliability, and stability, or just being a change for the sake of correctness.

      2. Why was this change made? (mandatory)

        For short and obvious patches, this part can be omitted, but it should be a clear description of what the approach was.

      3. What effect does the commit have? (optional)

        In addition to the obvious effects, this may include benchmarks, side effects, and so on. For short and obvious patches, this part can be omitted.

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#how-to-write-a-good-commit-message","title":"How to write a good commit message","text":"

      To write a good commitment message, we suggest following a good format, cultivating good habits, and using good language.

      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#format-of-a-good-commit-message","title":"Format of a good commit message","text":"

      Please follow the following style for all your commits:

      <subsystem>: <what changed>\n<BLANK LINE>\n<why this change was made>\n<BLANK LINE>\n<footer>(optional)\n
      • For the first subject line:

        • Use no more than 70 characters.
        • If the changes affect two subsystems, use a comma (and whitespace) to separate them like util/codec, util/types:.
        • If the changes affect three or more subsystems, you can use * instead, like *:.
        • Use a lowercase letter on the text that immediately follows the colon. For example: \"media: update the DM architecture image\"
        • Do not add a period at the end of a commit message.
      • For the second line, always leave it blank.

      • For the why part, if there is no specific reason for the change, you can use one of the generic reasons like \"Improve performance\", \"Improve test coverage.\"
      • For other lines, use no more than 80 characters.
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#habits-for-a-good-commit-message","title":"Habits for a good commit message","text":"
      • Summarize your change
      • Describe clearly one logical change and avoid lazy messages as misc fixes
      • Describe any limitations of the current code
      • Do not end the subject with a period \".\"
      • Do not assume the code is self-evident
      • Do not assume reviewers understand the original issue
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#language-for-a-good-commit-message","title":"Language for a good commit message","text":"
      • Use the imperative mood for the first subject line
      • Use simple verb tenses (eg. use \"add\" not \"added\")
      • Use correct and standard grammar
      • Use words and expressions consistently
      • Use relatively short sentences
      • Do not use lengthy compound words
      • Do not abbreviate unless it's absolutely necessary
      "},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#pull-request-description-style","title":"Pull Request description style","text":"

      For the Pull Request description in the Conversation box, please refer to the following Pull Request description template and include the necessary information:

      **What type of PR is this?**\n\n- [ ] API-change\n- [ ] BUG\n- [ ] Improvement\n- [ ] Documentation\n- [ ] Feature\n- [ ] Test and CI\n- [ ] Code Refactoring\n\n**Which issue(s) this PR fixes:**\n\nissue #\n\n**What this PR does / why we need it:**\n\n\n**Special notes for your reviewer:**\n\n\n**Additional documentation (e.g. design docs, usage docs, and so on.):**\n

      You may also use the checklist style to list contents if needed. The Markdown syntax is as follows:

      - [x] A checked line, something already done or fulfilled\n- [ ] An unchecked line, something not finished yet\n

      For short and obvious Pull Requests, you can omit some of the above information.

      Thanks for your contribution\uff01

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/","title":"Contribute Code","text":"

      MatrixOne is an open-source project maintained, improved, and extended by code contributors. This document describes the conventions of development workflow, and some styles and templates you need while contributing code to MatrixOne. If you encounter any problems or find some mistakes in participating in contribution to MatrixOne, please file an issue on GitHub or contact us on other platforms we support.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#before-contributions","title":"Before Contributions","text":"

      Before you start developing, make sure you have read Preparation where you can follow the instructions to learn more about MatrixOne, development knowledge, and how to set up the development environment.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#get-familiar-with-the-style","title":"Get familiar with the style","text":"

      It's necessary to keep a consistent style for code, code comments, commit messages, and pull requests when contributing to MatrixOne. When you put together your pull request, we highly recommend you comply with the following style guides which make MatrixOne easy to review, maintain, and develop.

      • Code Style

      The coding style suggested by the Golang community is used in MatrixOne. See the style doc for details.

      • Code Comment Style

      See the code comment style for details.

      • Commit Message & Pull Request Style

      See the Commit Message & Pull Request Style for details.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#workflow","title":"Workflow","text":"

      You can follow the workflow to operate development, and you can see Make Your First Contribution if you are a newcomer and need more detailed instructions about workflow.

      1. Fork the matrixOne repository on GitHub.

      2. Clone your fork to your local machine with:

      git clone git@github.com:<yourname>/matrixone.git\n

      And add MatrixOne repo as a remote repository with:

      git remote add upstream https://github.com/matrixorigin/matrixone.git\n

      3. Create a new branch. The branch name is up to you.

      git checkout -b topic-branch\n

      4. Commit changes to your own branch locally, add necessary unit tests.

      5. Push to a new branch in your own fork.

      git push origin main:NEW_BRANCH\n

      6. Go back to GitHub, and submit a pull request in NEW_BRANCH so that we can review your changes. Add some labels if needed, and don't forget to refer to the related issue.

      7. Once your PR gets approved, it will be merged sooner. After merging, synchronize your local repository.

      git pull --force upstream main:main\n

      8. Synchronized the main branch of your remote repository in Github.

      git push --force origin main:main\n

      If you still have some trouble, please refer to GitHub Docs for help.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#code-review","title":"Code review","text":"

      When you open a pull request, you can assign some reviewers, or just leave it blank. And you can add some related labels to make it easier to recognize the PR's type/priority/and so on. During the review, reviewers would comment on your code snippet, and you can modify the code on your topic branch locally, commit the changes, and push it to GitHub where the new commits would be attached to the PR automatically.

      For detailed code review tips, See Review a pull request for details.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/","title":"Contributing to MatrixOne Documentation","text":"

      Contributions to the MatrixOne documentation are welcome from everyone. The MatrixOne community strives to make the contribution process simple and straightforward. To do that, we create this page to walk you through the whole process step by step.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#before-you-start","title":"Before you start","text":"

      Before you contribute, please take a minute to familiarize yourself with basic Markdown syntax and look at our Code of Conduct and the Google Developer Documentation Style Guide for some guidance on writing accessible, consistent, and inclusive documentation.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#how-is-matrixone-documentation-project-organized","title":"How is MatrixOne documentation project organized?","text":"

      The MatrixOne documentation is managed in 3 repositories:

      • The english markdown contents are in the matrixorigin.io repo.

      • The chinese markdown contents are in the matrixorigin.io.cn repo.

      • The images and unstructured data are located in the artwork repo.

      The images are referred to as web image links from artwork repo. The matrixorigin.io and matrixorigin.io.cn have implemented a CI&CD project, which will be triggered by a new code merge and manual launch. This CI&CD workflow publishes the documentation to https://docs.matrixorigin.cn/en/.

      The documentation project is based on the mkdocs-material. You can find the corresponding syntax and commands with this project.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#matrixone-documentation-structure","title":"MatrixOne Documentation Structure","text":"

      The MatrixOne documentation content is planned with 6 main modules.

      • Overview: MatrixOne's introduction, features and architecture.

      • Getting Started: How to quickly deploy and run a standalone MatrixOne.

      • Developing Guide: How to develop some applications based on MatrixOne using different programming languages.

      • Deploying: How to quickly deploy and run MatrixOne cluster.

      • Tutorials: Examples of developing application demos.

      • Maintenance: How to maintain MatrixOne, including backing up and restoring data.

      • Migrating: How to migrate data from other databases to MatrixOne.

      • Testing: How to perform a self-test or MatrixOne performance test using the test tool.

      • Performance Tuning: How to tune the MatrixOne performance in a stand-alone or distributed environment.

      • Privilege: Multi-account management, account lifecycle management, and authorization in MatrixOne clusters.

      • Reference: SQL reference, Configuration parameters.

      • Troubleshooting: Introduce common errors and debugging tools.

      • FAQs: Product, Technical Design, SQL, Deployment FAQs.

      • Release Notes: Release notes of all versions.

      • Contribution Guide: How to contribute to MatrixOne project.

      • Glossary: Table of noun definitions.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#lift-a-finger","title":"Lift a finger","text":"

      If you are correcting a typo or grammatical error, feel free to go ahead and create a pull request for English docs or create a pull request for Chinese docs.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#contribute-workflow","title":"Contribute Workflow","text":"

      When you need to change the specific content of the document but do not involve the adjustment of the chapter order and structure organization, you need to modify matrixorigin.io/tree/main/docs/MatrixOne or matrixorigin.io.cn/tree/main/docs/MatrixOne to operate.

      If you need to adjust the chapter order and structure organization, you must modify the matrixorigin.io/blob/main/mkdocs.yml or matrixorigin.io.cn/blob/main/mkdocs.yml.

      The following process shows the case of modifying both, and the actual situation can be simplified according to your needs.

      1. File an English doc issue or File an Chinese doc issue and assign it to yourself by commenting /assign.

      2. Fork matrixorigin.io and matrixorigin.io.cn repos. 3. Clone the matrixorigin.io and matrixorigin.io.cn repos.

      • Clone matrixorigin.io:
      git clone git@github.com:yourusername/matrixorigin.io.git\n
      • Clone the matrixorigin.io.cn:
      git clone git@github.com:yourusername/matrixorigin.io.cn.git\n

      4. Add matrixorigin.io and matrixorigin.io.cn repos as the remote repository in your local folder with:

      • Add matrixorigin.io repo as a remote repository in your local matrixorigin.io folder with:
      git remote add upstream https://github.com/matrixorigin/matrixorigin.io.git\n
      • Add matrixorigin.io.cn repo as a remote repository in your local matrixorigin.io.cn folder with:
      git remote add upstream https://github.com/matrixorigin/matrixorigin.io.cn.git\n

      5. As the local repo has the full documentation project code, you can run mkdocs serve under matrixorigin.io or matrixorigin.io.cn folder, and check http://localhost:8000 to check if this project runs well.

      mkdocs serve\n

      6. Make your modification. If the modification concerns the project settings, update the sitemap with new pages, or update the CI&CD workflow code. You can always check http://localhost:8000 to see if your modification is effective.

      7. Push your git commits to your remote Github matrixorigin.io and matrixone repos. We recommend you push to a new branch using the following commands:

      git push origin main:NEW_BRANCH\n

      8. Go back to GitHub, and submit a pull request in NEW_BRANCH so that we can review your changes.

      9. Once your code for both repositories is merged, you'll wait for a CI&CD workflow to restart running until the documentation website being updated.

      Note

      So once your pull requests are merged, the update to the website is not immediate. We'll need to run a manual launch to update it.

      10. At last, you should update your local and remote repo to help keep committing history clean. Override your local committing repo with:

      git pull --force upstream main:main\n

      Update the main branch of your remote repo in Github:

      git push --force origin main:main\n

      Note

      Most processes should be implemented in both matrixorigin.io and matrixorigin.io.cn.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#contribute-a-blog-article","title":"Contribute a blog article","text":"

      If you would like to write an article for our blog, please file an issue or send it to dengnan@matrixorigin.io. Feel free to submit either a completed draft or any article ideas. All submissions will be reviewed as quickly as possible. If your article or idea seems like a good fit for the blog, we will reach out to you directly.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/","title":"Make a Design Proposal","text":"

      Many changes including bug fixes and documentation improvements, can be implemented and reviewed via the normal GitHub pull request workflow, which we have already introduced in the previous chapter. However, when you come up with a new feature you need or expect MatrixOne to achieve, we encourage you to propose your idea and express it as a technical design document. Therefore, this page is intended to guide you to provide a consistent and controlled path for new features to enter the MatrixOne projects, so that all stakeholders can fully understand the direction the project is evolving towards. This page defines the best practices procedure for making a proposal in MatrixOne projects.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/#before-writing-a-design-document","title":"Before writing a design document","text":"

      Making enough preparations ahead of the design document can promote your working efficiency and increase the likelihood of it being accepted. Oppositely, a rough and casual design document may be rejected quickly. We motivate you to ask for help from experienced developers in order to obtain valuable suggestions to frame your design architecture or fill in details, which undoubtedly will upgrade the document to be desirable.

      The most common channel for preparing for writing a design document is the Github issue. You can file a Feature Request or Refactoring Request to discuss your ideas.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/#process","title":"Process","text":"

      Generally, you can follow these steps to finish the whole process:

      • Create an issue describing the problem, goal, and solution.
      • Get responses from other contributors to see if your proposal is generally acceptable and whether or not you should make some modifications.
      • Create a pull request with a design document based on the design template.
      • Make conversation with reviewers, and revise the text in response.
      • The design document is accepted or rejected when at least two committers reach a consensus and there is no objection from the committer.
      • If accepted, create a tracking issue for the design document or convert one from a previous discussion issue. The tracking issue basically tracks subtasks and progress. And refer to the tracking issue in the design document replacing the placeholder in the template.
      • Merge the pull request of design.
      • Start the implementation.

      Please refer to the tracking issue from subtasks to track the progress.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/","title":"Preparation","text":"

      Before contributing, it's necessary to make some preparations to learn more about MatrixOne and other prerevalant information which can improve developing and reviewing efficiency.

      Thanks for understanding that this repository uses English as a shared language. Maintainers do not use machine translation to avoid miscommunication due to errors in translation. If the description of an issue / PR is written in non-English languages, it may be closed. If English is not your native language and you aren't sure about any of these, don't hesitate to ask for help in your pull request!

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#what-is-matrixone","title":"What is MatrixOne","text":""},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#basic-information","title":"Basic Information","text":"

      You can see MatrixOne Introduction for key features of MatrixOne, MatrixOne Architecture for MatrixOne architecture, and operational logic.

      Besides, you can browse SQL Reference and Custom Functions to know more about our interactive details.

      These introductions will help you go through you the key concepts and user details to understand the project.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#roadmap","title":"Roadmap","text":"

      MatrixOne v1.0.0-rc1 has been released, you can see Release Notes know more information.

      For the long-term project roadmap, please refer to MatrixOne roadmap for a more general overview.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#what-contributions-can-i-make","title":"What Contributions Can I Make","text":"

      Contributions to MatrixOne are not limited to writing code. What follows are different ways to participate in the MatrixOne project and engage with our vibrant open-source community. See Types of Contributions for more details.

      • To report a bug or a problem with the documentation, please file an issue providing the details of the problem. Don't forget to add a proper label for your issue, and follow the issue templates.
      • To propose a new feature, please file a new feature request. Describe the intended feature and discuss the design and implementation with the team and community. Once the team agrees on the plan, you can follow the Contribution Workflow to implement it.
      • To implement a feature or bug-fix for an existing outstanding issue, follow the Contribution workflow. If you need more context on a particular issue, comment on the issue to let people know.
      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#working-directories-and-files","title":"Working Directories and Files","text":"

      For contributing code, matrixone is the main repository you'll be working on. The main working directories are listed below:

      Directory Working Files /LICENSES The license of dependant libraries /cmd The binary entry of Go executables optools The test and deployment utilities pkg The main codebase of MatrixOne project

      For different technical modules, a code structure under /pkg is as shown in the following table.

      Directory Modules frontend/ SQL Frontend sql/ MPP SQL Execution sql/parser SQL Parser sql/vectorize Vectorization of SQL Execution catalog/ Catalog for storing metadata vm/engine Storage engine vm/engine/aoe Analytics Optimized Engine vm/engine/tpe Transaction Processing Engine buildin/ System builtin functions

      For contributing documentation, matrixorigin.io , matrixorigin.io.cn and artwork are all the main repositories you'll be working on. For more details, please refer to Contribute Documentation.

      Directory Working Files matrixone/docs/rfcs The design docs of MatrixOne project matrixorigin.io/docs/MatrixOne The content files of the English MatrixOne documentation website matrixorigin.io.cn/docs/MatrixOne The content files of the Chinese MatrixOne documentation website matrixorigin.io/mkdocs.yml The configuration file of the English documentation website matrixorigin.io.cn/mkdocs.yml The configuration file of the Chinese documentation website artwork/docs The images, screenshots and diagrams of documentation webstie"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#set-up-your-development-environment","title":"Set up your Development Environment","text":""},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#go-environment","title":"Go Environment","text":"

      MatrixOne is written in Go. Before you start contributing code to MatrixOne, you need to set up your GO development environment.

      1. Install Go version 1.19. You can see How to Write Go Code for more information.
      2. Define GOPATH environment variable and modify PATH to access your Go binaries. A common setup is as follows. You could always specify it based on your own flavor.
      export GOPATH=$HOME/go  export PATH=$PATH:$GOPATH/bin\n

      Note

      MatrixOne uses Go Modules to manage dependencies.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#github-git","title":"Github & Git","text":"

      MatrixOne is an open-source project built on Github, providing project maintainers and contributors with a platform to work together. Thus, in order to start working with MatrixOne repository, you will need a GitHub account and learn basic git commands. If you don't have a Github account, please register at https://github.com. In case you do not have SSH keys, you should generate them and then upload them on GitHub. It is required for sending over your patches. It is also possible to use the same SSH keys that you use with any other SSH servers - probably you already have those. For detailed information about Github, you can see Github Docs.

      To work with git repositories, please install git. And you can learn how to use it throuth following introduction:

      • A brief manual can be found here.
      • A detailed manual can be found here.
      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#install-and-run-matrixone","title":"Install and Run MatrixOne","text":"

      See Install Standalone MatrixOne for more details.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/","title":"Report Issues","text":"

      Any problem is encouraged to be published when you participate in MatrixOne, and you can report issues about this problem on GitHub with templates and labels we suggest. This page is intended to introduce templates, labels, and precautions you will follow when you report issues.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#avoid-duplicated-issues","title":"Avoid Duplicated Issues","text":"

      Before reporting an issue, you should see whether the problem has already been reported. You can use the search bar to search for existing issues.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#issue-templates","title":"Issue Templates","text":"

      If the problem you're reporting is not already in the issue tracker, you can file an issue with your GitHub account. MatrixOne uses issue templates for different kinds of issues. Issue templates are a bundle of questions to collect necessary information about the problem to make it easy for other contributors to participate. MatrixOne suggests 6 types of issue templates:

      A Bug report issue template consists of the information below:

      • Detail Environment Describe the details about the operating environment including version, hardware parameters, OS type, and so on.
      • Steps to Reproduce List steps to reproduce what you encountered.
      • Actual & Expected Behavior Describe what's the observed and your expected behavior respectively.

      A Feature Request consists of the information below:

      • Is your feature request related to a problem? A clear and concise description of the problem and state why you need this feature.
      • Describe the feature you'd like: A clear and concise description of what you want to happen.
      • Describe alternatives you've considered: A clear and concise description of any alternative solutions or features you've considered.
      • Teachability, Documentation, Adoption, Migration Strategy: If you can, explain some scenarios in how users might use this, and situations it would be helpful. Any API designs, mockups, or diagrams are also helpful.

      A Documentation Issue consists of the information below:

      • Describe the issue A clear and concise description of what's wrong in the documentation.
      • Additional context Add any other context about the problem here.

      A Performance Question consists of the information below:

      • Detail Environment Describe the details about the operating environment including version, hardware parameters, OS type, and so on.
      • Steps to Reproduce List steps detailedly to reproduce the operations to test performance.
      • Expected & Actual Performance Describe what's the observed and your expected performance respectively.
      • Additional context Add any other context about the problem here. For example:
        • Have you compared MatrixOne with other databases? If yes, what's their difference?

      An Enhancement consists of the information below:

      • What would you like to be added A concise description of what you're expecting/suggesting.
      • Why is this needed A concise description of the reason/motivation.
      • Anything else Anything that will give us more details about your issue!

      A Refactoring Request consists of the information below:

      • Is your refactoring request related to a problem? A clear and concise description of what the problem is.
      • Describe the solution you'd like A clear and concise description of the refactoring you want to do.
      • Describe alternatives you've considered A clear and concise description of any alternative solutions or refactoring methods you've considered.
      • Additional context Add any other context or screenshots about the refactoring request here.

      A General Question:

      If the previous templates don't fit with what you'd like to report or ask, please use this general question template to file the issue.

      Before asking a question, make sure you have:

      • Searched open and closed GitHub issues
      • Read the documentation:
        • MatrixOne Readme
        • MatrixOne Doc
      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#issue-labels","title":"Issue Labels","text":"

      Once your issue is submitted, it will automatically be labeled with needs-triage, a MatrixOne maintainer will look at the issue, tag it with more suitable labels, and assign it to a suitable developer. If you'd like to work on the issue by yourself, you can comment /assign on the issue you would like to work on, and you will be automatically assigned to the issue. You can then find yourself listed under the Assignees section.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#good-first-issues","title":"Good First Issues","text":"

      When you make the first contribution to MatrixOne, you can select one of the issues labeled good-first-issues each of which is relatively approachable for first-time contributors. For detailed suggestions, you need when you make the first contribution, you can see Make Your First Contribution.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/","title":"Reviews","text":"

      For MatrixOne, any type of review for a pull request is crucial, where you can classify the pull request to help look for more suitable experts to solve related problems or propose your suggestions to code for not only content but style. It's not necessary to doubt whether your review is constructive and useful enough because no matter how tiny, a suggestion may profoundly influence MatrixOne. Certainly, before reviewing we ask that you browse this page to learn basic requirements and relative methods.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#principles-of-the-code-review","title":"Principles of the code review","text":"

      When you review a pull request, there are several rules and suggestions you should take to propose better comments. Regardless of the specifics, we suggest you stay friendly first:

      • Be respectful Be respectful to every pull request author and other reviewers. Code review is a part of community activities so you should follow the community requirements.
      • Be careful with tone Try to frame your comments as suggestions or questions instead of commands. If the tone is softer, your reviews will be easier to accept.
      • Be generous with your compliments We recommend you offer encouragement and appreciation to the authors for their good practices in the code segments. In many cases, telling the authors what they did is right is even more valuable than telling them what they did is wrong.

      Additionally, here are some suggestions in terms of content:

      • Provide more We encourage you to provide additional details and context of your review process as much as you can. Undoubtedly, the more detailed your review, the more useful it will be to others. If you test the pull request, please report the result and your test environment details. If you request some changes, try to suggest how.
      • Keep objective Avoid individual biased opinions and subjective emotions. Of course, everyone will comment with more or less subjective opinions. However, as a good reviewer, you should consider the technique and data facts rather than your own personal preferences.
      • Case by case It's difficult to decide whether it's more reasonable to accept or reject when you are faced with a complex problem. Regrettably, we can't provide a certain answer because it always depends on the specific situation, which asks you to balance the pros and cons.
      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#classifying-pull-requests","title":"Classifying pull requests","text":"

      Some pull request authors may not be familiar with MatrixOne, the MatriOne development workflow, or the MatrixOne community. They don't know what labels should be added to the pull requests or which expert could be asked for a review. If you are able to, it would be great for you to triage the pull requests, add suitable labels to the pull requests, and request corresponding experts to review the pull requests. These actions could help more contributors notice the pull requests and make quick responses.

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#checking-pull-requests","title":"Checking pull requests","text":"

      There are some basic aspects to check when you review a pull request:

      • Concentration One pull request should only do one thing. No matter how small it is, the change does exactly one thing and gets it right. Don't mix other changes into it.
      • Tests A pull request should be test covered, whether the tests are unit tests, integration tests, or end-to-end tests. Tests should be sufficient, correct, and don't slow down the CI pipeline largely.
      • Functionality The pull request should implement what the author intends to do, fit well in the existing code base, and resolve a real problem for users. Thus you should check whether or not the pull request achieves the intention and you could follow the discussions in the corresponding GitHub issue.
      • Style Code in the pull request should follow a common programming style. However, sometimes the existing code is inconsistent with the style guide. You should maintain consistency with the existing code or file a new issue to fix the existing code style first.
      • Documentation If a pull request changes how users build, test, interact with, or release code, you must check whether it also updates the related documentation such as README.md and any generated reference docs. Similarly, if a pull request deletes or deprecates code, you must check whether or not the corresponding documentation should also be deleted.
      • Performance If you find the pull request may affect performance, you could ask the author to provide a benchmark result.
      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/","title":"Types of Contributions","text":"

      Contributions to MatrixOne are not limited to writing code. What follows are different ways to participate in the MatrixOne project and engage with our vibrant open-source community:

      "},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#contribute-code","title":"Contribute Code","text":"Contribution type Description Report a bug To report a problem with MatrixOne, file an issue on GitHub. Include detailed information about the problem you've encountered. Contribute code You can fix a bug for any outstanding issues on GitHub, improve the code, or propose a design or implementation for a new MatrixOne feature. See Contribute Code for the contribution conventions and best practices. Review or approve pull requests Review or approve pull requests for the MatrixOne project as a reviewer or maintainer."},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#contribute-to-matrixone-documentation","title":"Contribute to MatrixOne Documentation","text":"Contribution type Description Report or fix a technical documentation issue You can either click edit the page directly on the target page of MatrixOne, or file an English document issue/file an Chinese document issue on MatrixOne repository with detailed information, and, if possible, propose changes by creating an English document pull request/creating a Chinese document pull request. Contribute a new piece of technical document Before contributing a full-length technical document, read Contribution Documentation."},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#other-contributions","title":"Other Contributions","text":"Contribution type Description Share your demos and solutions Show MatrixOne users how to leverage the platform in specific scenarios. Send your use case to dengnan@matrixorigin.io and we'll post it in the community. Author a blog article, user story, or whitepapers Write high-quality content that clearly and accurately explains technical details about MatrixOne. Give a tech talk or host a live broadcast Give talks or host live broadcasts that help raise awareness around MatrixOne. Support MatrixOne users Help users on GitHub solve the problems they meet while using MatrixOne. Issue triage Adding descriptive labels to our GitHub issues speeds up routing issues to the right person in charge. It is a great contribution to the operation of the MatrixOne project. Contribute otherwise Any contribution that plays a positive role in the development of MatrixOne and its open-source community will be considered for eligibility."},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/","title":"MatrixOne Operator Management","text":""},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#matrixone-operator-overview","title":"MatrixOne Operator overview","text":"

      MatrixOne Operator is used to define and manage the resource requirements of MatrixOne clusters in Kubernetes, consisting of a set of Kubernetes custom resources (CustomResourceDefinitions, CRD), a set of Kubernetes controllers and a set of WebHook services:

      • CRD: In Kubernetes, CRD is an object that registers a new custom resource type into Kubernetes APIServer. The CRDs contained in MatrixOne Operator register various custom resources, including MatrixOneCluster resources used to describe MatrixOne clusters and resources such as CNSet, TNSet, and LogSet used to describe components in the cluster. After the registration, the client can read and write these resources on the Kubernetes APIServer.

      • Controller: The controller is a long-running automation program responsible for monitoring the desired state of resources in Kubernetes, collecting the actual state of these resources, and automatically operating and maintaining them to drive the actual state to the desired state. The controller in matrixone-operator monitors resources such as MatrixOneCluster, CNSet, TNSet, LogSet, etc., and is responsible for realizing the desired state declared by the user through these resources.

      • Webhook service: A webhook service is a long-running HTTP service. When Kubernetes APIServer receives a request from a user to read and write resources such as MatrixOneCluster, CNSet, TNSet, and LogSet, it will forward the request to the Webhook service, and the Webhook service will perform logic such as request verification and default value filling.

      When using Helm chart to install Matrixone-Operator, it will automatically submit the required CRDs to Kubernetes APIServer, complete the registration of custom resources, and deploy a long-running Matrixone-Operator application. The controller mentioned above, and webhook services are packaged in this application.

      "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#cluster-management","title":"Cluster Management","text":"

      MatrixOne Operator provides users with declarative cluster management capabilities through MatrixOneCluster resources. Specifically, when deploying a MatrixOne cluster on Kubernetes, the user can declare a MatrixOneCluster object in YAML format to describe the cluster, and the controller of the operator will realize the orchestration of the cluster according to the description and update the cluster status to the .status of the MatrixOneCluster object field.

      A MatrixOneCluster cluster consists of components such as Compute Node (CN), Transaction Node (TN), and Log Service, which correspond to sub-resources such as CNSet, TNSet, and LogSet. Therefore, the controller of the MatrixOneCluster resource orchestrates these sub-resources and relies on the controllers of these sub-resources to complete their orchestration.

      "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#deployment-operation-maintenance","title":"Deployment, Operation, Maintenance","text":"

      The deployment, operation, and maintenance environment introduced in this chapter will be based on the environment of MatrixOne Distributed Cluster Deployment.

      The following operations are performed on the master0 node.

      "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#deployment","title":"Deployment","text":"

      Please look at the MatrixOne-Operator deployment chapter of MatrixOne Distributed Cluster Deployment.

      "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#check-status","title":"Check Status","text":"

      We use the Helm tool to deploy MatrixOne Operator. Helm is a Kubernetes application package management tool for managing charts, pre-configured installation package resources, similar to Ubuntu's APT and CentOS YUM. You can use the helm list command to check the deployment status of the Operator.

      [root@master0 ~]# NS=\"matrixone-operator\"\n[root@master0 ~]# helm list -n${NS}\nNAME                    NAMESPACE               REVISION        UPDATED                                 STATUS          CHART                                   APP VERSION\nmatrixone-operator      matrixone-operator      1               2023-05-09 15:19:38.363683192 +0800 CST deployed        matrixone-operator-0.8.0-alpha.2        0.1.0\n
      "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#update","title":"Update","text":"

      The MatrixOne-Operator project is a long-term maintenance and update project; please update to the latest version. You can download the new version of Operator on Github, for example: matrixone-operator-0.8.0-alpha.2.

      Unzip the file with the following command:

      tar xvf ./matrixone-operator-0.8.0-alpha.2.tgz\ncd matrixone-operator\n

      You can use the helm upgrade command to upgrade Matrixone-Operator. You can get the mirror version with the following command:

      cd matrixone-operator\nNS=\"matrixone-operator\"\nhelm upgrade -n \"${NS}\" matrixone-operator ./ --dependency-update\n

      After the upgrade is successful, the code display is as follows:

      Release \"matrixone-operator\" has been upgraded. Happy Helming!\nNAME: matrixone-operator\nLAST DEPLOYED: Tue May  9 17:59:06 2023\nNAMESPACE: matrixone-operator\nSTATUS: deployed\nREVISION: 2\nTEST SUITE: None\n

      After the upgrade is complete, you can view the current version with the following command:

      #Get mirror version\nNS=\"matrixone-operator\"\nkubectl get pod -n${NS} `kubectl get pod -n${NS}  | grep operator | head -1 | awk '{print $1}'` -ojsonpath='{.spec.containers[0].image}'\nmatrixorigin/matrixone-operator:0.8.0-alpha.2\n

      After upgrading Matrixone-Operator, a new Pod of matrixone-operator-xxxx-xxx will be regenerated under the matrixone-operator namespace, and then the old Pod will be deleted.

      Note

      After the upgrade is complete, if the changes brought about by the Matrixone-Operator upgrade will also update the default .spec, then it is possible to roll over the related services or configurations of the MatrixOne cluster so that the MatrixOne service may be restarted. You can monitor the upgrade process with the command: watch -e \"kubectl get pod -nmo-hn -owide\".

      NS=\"matrixone-operator\"\nwatch -e \"kubectl get pod -n${NS} -owide\"\n
      NAME                                 READY   STATUS    RESTARTS   AGE    IP              NODE    NOMINATED NODE   READINESS GATES\nmatrixone-operator-f8496ff5c-s2lr6   1/1     Running   0          164m   10.234.168.43   node1   <none>           <none>\n
      "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#scaling","title":"Scaling","text":"

      Since Operators often use limited resources, there are relatively few scenarios for vertical scaling. Generally speaking, we only need to consider horizontal scaling, increasing or decreasing the number of replicas. Usually, the Operator has a single copy. If we need to enhance the high availability of the Operator, consider expanding it, for example, to two copies. This way, even if the first replica fails (for example, pulling an image fails on its node), the other replica can still function normally. We can expand and shrink the number of Operator replicas by using the Helm Upgrade command and specifying the number of replicaCount in the deployment directory of the current Operator version. This is very important for the deployment and O&M management operations of MO clusters.

      Before scaling up, we can use the following command to view the number of Operators:

      NS=\"matrixone-operator\"\nwatch -e \"kubectl get pod -n${NS} -owide\"\n
      NAME                                 READY   STATUS    RESTARTS   AGE    IP              NODE    NOMINATED NODE   READINESS GATES\nmatrixone-operator-f8496ff5c-s2lr6   1/1     Running   0          164m   10.234.168.43   node1   <none>           <none>\n
      • Expansion: Use the following command line to expand capacity:
      # number of replicas\ncd matrixone-operator\nNUM=2\nNS=\"matrixone-operator\"\nhelm upgrade -n${NS} matrixone-operator ./ --dependency-update --set replicaCount=${NUM}\n

      The expansion is successful, and the printing code example is as follows:

      Release \"matrixone-operator\" has been upgraded. Happy Helming!\nNAME: matrixone-operator\nLAST DEPLOYED: Tue May  9 18:07:03 2023\nNAMESPACE: matrixone-operator\nSTATUS: deployed\nREVISION: 3\nTEST SUITE: None\n

      You can continue to observe the number of operators with the following command:

      watch -e \"kubectl get pod -nmo-hn -owide\"\nNAME                                 READY   STATUS    RESTARTS   AGE    IP              NODE    NOMINATED NODE   READINESS GATES\nmatrixone-operator-f8496ff5c-nt8qs   1/1     Running   0          9s     10.234.60.126   node0   <none>           <none>\nmatrixone-operator-f8496ff5c-s2lr6   1/1     Running   0          167m   10.234.168.43   node1   <none>           <none>\n

      If you need to scale down horizontally, you can use helm upgrade to reduce the number of replicaCount to complete the reduction of the number of replicas of the operator.

      "},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#uninstall","title":"Uninstall","text":"

      Warning

      Before uninstalling Matrixone-Operator, confirm clearly, because the uninstallation operation will directly uninstall the resources related to the Matrixone cluster, including SVC, Pod, etc. (but not including the PVC resources used by the log service).

      Uninstall Matrixone-Operator with the following command:

      helm uninstall matrixone-operator -n mo-hn\n
      "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/","title":"Scaling MatrixOne Cluster","text":"

      This document will introduce how to scale the MatrixOne cluster, including the Kubernetes cluster and scaling of individual MatrixOne services.

      The environment introduced in this document will be based on the environment of MatrixOne Distributed Cluster Deployment.

      "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#when-is-it-necessary-to-scale","title":"When is it necessary to scale","text":"

      To determine whether the MatrixOne service needs to be scaled up or down, users need to monitor the nodes where the MatrixOne cluster resides and the resources used by the Pods corresponding to related components. You can do this with the kubectl top command. For more detailed operation steps, please refer to Health Check and Resource Monitoring.

      In general, if the resource usage of a node or Pod exceeds 60% and lasts for some time, consider expanding capacity to cope with the peak load. In addition, capacity expansion operations must also be considered if a high TPS request volume is observed according to business indicators.

      "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#scaling-kubernetes","title":"Scaling Kubernetes","text":"

      Kubernetes manages and allocates essential hardware resources in the distributed MatrixOne cluster. Kubernetes can expand or contract the hardware nodes in the cluster using the kuboard spray graphical management page. For more information on tutorials, see kuboard spray official documents.

      You need to add a working node to the cluster, and the overall hardware configuration resources are shown in the following table:

      Host Internal IP External IP mem CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker node1 10.206.134.16 129.211.211.29 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#scaling-matrixone-services","title":"Scaling MatrixOne Services","text":"

      Scaling of services refers to expanding or contracting the core component services within the MatrixOne cluster, such as Log Service, TN, and CN. Based on the architectural characteristics of MatrixOne, the following conditions apply to these service nodes:

      • Log Service has only 3 nodes.
      • TN has only 1 node.
      • The number of CN nodes is flexible.

      Therefore, scaling of Log Service and TN nodes is possible only through vertical scaling. However, CN nodes can be scaled both vertically and horizontally.

      "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#horizontal-scaling","title":"Horizontal scaling","text":"

      Horizontal scaling refers to the increase or decrease in the number of copies of a service. You can change the number of service replicas by modifying the value of the .spec.[component].replicas field in the MatrixOne Operator startup yaml file.

      1. Use the following command to activate the value of the .spec.[component].replicas field in the yaml file:

        kubectl edit matrixonecluster ${mo_cluster_name} -n ${mo_ns}\n
      2. Enter edit mode:

        tp:\n    replicas: 2 #Changed from 1 CN to 2 CNs\n#Other content is ignored\n

        Note

        You can also refer to the above steps to change the field value of replicas for scaling down.

      3. After editing the number of replicas, saving, and exiting, MatrixOne Operator will automatically start a new CN. You can observe the new CN status with the following command:

        [root@master0 ~]# kubectl get pods -n mo-hn      \nNAME                                  READY   STATUS    RESTARTS     AGE\nmatrixone-operator-6c9c49fbd7-lw2h2   1/1     Running   2 (8h ago)   9h\nmo-tn-0                               1/1     Running   0            11m\nmo-log-0                              1/1     Running   0            12m\nmo-log-1                              1/1     Running   0            12m\nmo-log-2                              1/1     Running   0            12m\nmo-tp-cn-0                            1/1     Running   0            11m\nmo-tp-cn-1                            1/1     Running   0            63s\n

      In addition, Kubernetes' SVC will automatically ensure CN load balancing and user connections will be evenly distributed to different CNs. You can view the number of connections on each CN through the built-in system_metrics.server_connections table of MatrixOne.

      "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#vertical-scaling","title":"Vertical scaling","text":"

      Vertical scaling refers to the resources required to serve a copy of a single component, such as adjusting CPU or memory.

      1. Use the following command to modify the configuration of requests and limits in the corresponding component's .spec.[component].resources. The example is as follows:

        kubectl edit matrixonecluster ${mo_cluster_name} -n ${mo_ns}\n
      2. Enter edit mode:

        metadata:\n  name: mo\n  # content omitted\nspec:\n  tp:\n        resources:\n      requests:\n        cpu: 1\n        memory: 2Gi\n      limits:\n        cpu: 1\n        memory: 2Gi\n...\n# content omitted\n
      "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#node-scheduling","title":"Node Scheduling","text":"

      By default, Matrixone-operator does not configure topology rules for each component's Pod but uses Kubernetes' default scheduler to schedule according to each Pod's resource request. If you need to set specific scheduling rules, such as scheduling the cn component to two specific nodes, node0, and node1, you can follow the steps below:

      1. Set labels for node0 and node1.

      2. Set nodeSelector in the MatrixOne cluster so the service can be scheduled to the corresponding node.

      3. (Optional) Set the TopologySpread field in the MatrixOne cluster to achieve an even distribution of services across nodes.

      4. Set the number of replicas replicas in the MatrixOne cluster.

      "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#set-node-label","title":"Set node label","text":"
      1. Execute the following command to view the status of the cluster nodes:

        [root@master0 ~]# kubectl get node\nNAME      STATUS   ROLES                  AGE   VERSION\nmaster0   Ready    control-plane,master   47h   v1.23.17\nnode0     Ready    <none>                 47h   v1.23.17\nnode1     Ready    <none>                 65s   v1.23.17\n
      2. According to the above-returned results and actual needs, you can label the nodes; see the following code example:

        NODE=\"[node to be labeled]\" # According to the above results, it may be IP, hostname, or alias, such as 10.0.0.1, host-10-0-0-1, node01, then set NODE = \"node0\"\nLABEL_K=\"mo-role\" # The key of the label, which can be defined on demand, or can be directly used as an example\nLABEL_V=\"mo-cn\" # The value of the label, which can be defined as needed, or can be directly used as an example\n\nkubectl label node ${NODE} ${LABEL_K}=${LABEL_V}\n
      3. In this case, you can also write the following two statements:

        kubectl label node node0 \"mo-role\"=\"mo-cn\"\nkubectl label node node1 \"mo-role\"=\"mo-cn\"\n
      4. Use the following command to confirm that the node label is printed:

        [root@master0 ~]# kubectl get node node0 --show-labels | grep mo_role     \nnode0   Ready    <none>   47h   v1.23.17   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node0,kubernetes.io/os=linux,mo_role=mo_cn\n[root@master0 ~]# kubectl get node node1 --show-labels | grep mo_role\nnode1   Ready    <none>   7m25s   v1.23.17   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node1,kubernetes.io/os=linux,mo_role=mo_cn\n
      5. Execute the following command to delete tags as needed:

        kubectl label node ${NODE} ${LABEL_K}-\n
      "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#set-service-scheduling-rules-uniform-distribution-and-number-of-copies","title":"Set service scheduling rules, uniform distribution, and number of copies","text":"
      1. Execute the following command to view the current distribution of Pods on multiple nodes:

        [root@master0 mo]# kubectl get pod -nmo-hn -owide\nNAME         READY   STATUS    RESTARTS   AGE   IP              NODE    NOMINATED NODE   READINESS GATES\nmo-tn-0      1/1     Running   0          34m   10.234.60.120   node0   <none>           2/2\nmo-log-0     1/1     Running   0          34m   10.234.168.72   node1   <none>           2/2\nmo-log-1     1/1     Running   0          34m   10.234.60.118   node0   <none>           2/2\nmo-log-2     1/1     Running   0          34m   10.234.168.73   node1   <none>           2/2\nmo-tp-cn-0   1/1     Running   0          33m   10.234.168.75   node1   <none>           2/2\n
      2. According to the above output and actual requirements, it can be seen that there is only one CN at present, and we need to set the scheduling rules for the CN component. We will modify it in the properties of the MatrixOne cluster object. The new CN will be scheduled to node0 under the rule of uniform distribution within the scheduling scope. Execute the following command to enter edit mode:

        mo_ns=\"mo-hn\"\nmo_cluster_name=\"mo\" # The general name is mo, specified by the name in the yaml file of the matrixonecluster object during deployment, or confirmed by kubectl get matrixonecluster -n${mo_ns}\nkubectl edit matrixonecluster ${mo_cluster_name} -n ${mo_ns}\n
      3. In edit mode, according to the above scenario, we will set the number of copies of CN to 2 and schedule on nodes labeled mo-role:mo-cn to achieve uniform distribution within the scheduling range. We will use spec.[component].nodeSelector to specify the tag selector for a specific component. Here is the edited content of the example:

        metadata:\n  name: mo\n# Intermediate content omitted\nspec:\n# Intermediate content omitted\n  tp:\n    # Set the number of replicas\n    replicas: 2\n    # Set scheduling rules\n    nodeSelector:\n      mo-role: mo-cn\n    # Set the uniform distribution within the scheduling range\n    topologySpread:\n      - topology.kubernetes.io/zone\n      - kubernetes.io/hostname\n#Other content omitted\n
      4. After the change takes effect, execute the following command to check that the two CNs are already on the two nodes:

        [root@master0 ~]# kubectl get pod -nmo-hn -owide      \nNAME         READY   STATUS    RESTARTS        AGE     IP              NODE    NOMINATED NODE   READINESS GATES\nmo-tn-0      1/1     Running   1 (2m53s ago)   3m6s    10.234.168.80   node1   <none>           2/2\nmo-log-0     1/1     Running   0               3m40s   10.234.168.78   node1   <none>           2/2\nmo-log-1     1/1     Running   0               3m40s   10.234.60.122   node0   <none>           2/2\nmo-log-2     1/1     Running   0               3m40s   10.234.168.77   node1   <none>           2/2\nmo-tp-cn-0   1/1     Running   0               84s     10.234.60.125   node0   <none>           2/2\nmo-tp-cn-1   1/1     Running   0               86s     10.234.168.82   node1   <none>           2/2\n

      It should be noted that the configuration in the above example will make the Pods in the cluster evenly distributed on the two dimensions topology.kubernetes.io/zone and kubernetes.io/hostname. The tag keys specified in topologySpread are ordered. In the example above, Pods is first distributed evenly across the Availability Zones dimension, and then Pods within each Availability Zone are evenly distributed across the nodes within that zone.

      Using the topologySpread function can increase the availability of the cluster and reduce the possibility of destroying the majority of replicas in the cluster due to a single point or regional failure. But this also increases the scheduling requirements and the need to ensure that the cluster has enough resources available in each region.

      "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/","title":"Starting and stopping MatrixOne distributed Cluster","text":"

      This document will introduce how to start and stop the MatrixOne distributed cluster.

      The upgraded environment introduced in this document will be based on the environment of MatrixOne Distributed Cluster Deployment.

      "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#cluster-shutdown","title":"Cluster Shutdown","text":"

      To shut down a MatrixOne cluster, stop the read-write operations and then shut down the servers directly. The shutdown sequence is as follows: first, shut down the node0 node, then shut down the master0 node, and finally, shut down the Kuboard-Spray node.

      "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#cluster-restart","title":"Cluster Restart","text":"

      To restart a MatrixOne cluster, following the following hardware startup sequence is recommended: start the Kuboard-Spray node, then start the master0 node, and finally start the node0 node.

      After the hardware startup is complete, k8s will automatically recover. At the same time, MatrixOne and MinIO-related services will be automatically restored without manual intervention. However, it should be noted that the Docker of the Kuboard-Spray node will not be automatically restored, and the Kuboard-Spray service needs to be manually started.

      "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-k8s-status","title":"Check K8s Status","text":"

      On the master0 node that operates k8s, you can check the status of the k8s cluster nodes.

      In normal circumstances, the status of all nodes should be Ready. If the status of some nodes is abnormal, further investigation is required to determine the reason.

      kubectl get node\n# If the status is not \"Ready\", further investigation into the node's situation is necessary.\n# kubectl describe node ${NODE_NAME}\n

      Here is an example of a diagram for codes:

      "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-minio-status","title":"Check MinIO status","text":"

      On the master0 node operating k8s, you can check the status of MinIO.

      After the hardware starts, MinIO will automatically resume. You can use the following command to check the status of MinIO.

      NS=\"mostorage\"\nkubectl get pod -n${NS}\n

      Here is an example of a diagram for codes:

      "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-the-status-of-the-matrixone-cluster-and-components","title":"Check the status of the MatrixOne cluster and components","text":""},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-matrixonecluster-status","title":"Check MatrixOneCluster status","text":"

      First, check whether the MatrixOne cluster is standard. The MatrixOne cluster corresponds to the custom resource type MatrixOneCluster.You can use the following command to check the status of MatrixOneCluster:

      MO_NAME=\"mo\"\nNS=\"mo-hn\"\nkubectl get matrixonecluster -n${NS} ${MO_NAME}\n

      Under normal circumstances, the status should be Ready. If the status is NotReady, further troubleshooting is required.

      Here is an example of a diagram for codes:

      "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#view-matrixone-cluster-status-details","title":"View MatrixOne cluster status details","text":"

      If the MatrixOne cluster status is not normal, you can use the following command to view the details:

      kubectl describe matrixonecluster -n${NS} ${MO_NAME}\n

      "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-the-status-of-tnsetcnsetlogset","title":"Check the status of TNSet/CNSet/LogSet","text":"

      The main components of the current MatrixOne cluster are TN, CN, Log Service, and corresponding custom resource types TNSet, CNSet, and LogSet.These objects are generated by the MatrixOneCluster controller.

      You can use the following command to check the status of each component; take TN as an example:

      SET_TYPE=\"tnset\"\nNS=\"mo-hn\"\nkubectl get ${SET_TYPE} -n${NS}\n

      Here is an example of a diagram for codes:

      "},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#check-pod-status","title":"Check Pod status","text":"

      You can directly check the native k8s objects generated in the MO cluster to confirm the cluster's health.Under normal circumstances, you can confirm the status of the pod:

      NS=\"mo-hn\"\nkubectl get pod -n${NS}\n

      Here is an example of a diagram for codes:

      Generally speaking, the running state is the normal state. However, there are a few exceptions, such as the status is running, but the MO cluster is abnormal, such as the inability to connect to the MO cluster through the MySQL Client. At this time, you can further check whether the Pod's log has abnormal information output:

      NS=\"mo-hn\"\nPOD_NAME=\"[The name of the pod returned above]\" # For example, mo-tp-cn-3\nkubectl logs ${POD_NAME} -n${NS}\n

      If the status is non-running, such as Pending, you can confirm the cause of the exception by looking at the event in the Pod status. For example, because the cluster resources cannot meet the application of mo-tp-cn-3, this pod cannot be scheduled and is pending. In this example, it can be solved by expanding the node's resources.

      kubectl describe pod ${POD_NAME} -n${NS}\n

      Here is an example of a diagram for codes:

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/","title":"MatrixOne Distributed Cluster Deployment","text":"

      This document will mainly describe how to deploy MatrixOne distributed database, based on a private Kubernetes cluster that separates computing and storage resources in a cloud-native manner, starting from scratch.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#main-steps","title":"Main Steps","text":"
      1. Deploy Kubernetes cluster
      2. Deploy object storage MinIO
      3. Create and connect MatrixOne cluster
      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#key-concepts","title":"Key Concepts","text":"

      As this document involves many Kubernetes-related terms, to help everyone understand the deployment process, we will provide brief explanations of important terms related to Kubernetes. If you need to know more about Kubernetes-related content, see Kubernetes Documentation

      • Pod

      Pod is the smallest resource management component in Kubernetes and the smallest resource object for running containerized applications. A Pod represents a process running in the cluster. In simple terms, we can consider a group of applications that provide specific functions as a pod containing one or more container objects that work together to provide services to the outside world.

      • Storage Class

      Storage Class, abbreviated as SC, marks the characteristics and performance of storage resources. According to the description of SC, we can intuitively understand the aspects of various storage resources and then apply storage resources according to the application's requirements. Administrators can define storage resources as a specific category, just as storage devices describe their configuration profiles.

      • CSI

      Kubernetes provides the CSI interface (Container Storage Interface, Container Storage Interface). Based on this set of CSI interfaces, custom CSI plug-ins can be developed to support specific storage and achieve the purpose of decoupling.

      • PersistentVolume

      PersistentVolume, abbreviated as PV, mainly includes setting key information such as storage capacity, access mode, storage type, recycling strategy, and backend storage type as a storage resource.

      • PersistentVolumeClaim

      PersistentVolumeClaim, or PVC, is used as a user's request for storage resources, mainly including the setting of information such as storage space request, access mode, PV selection conditions, and storage category.

      • Service

      Also called SVC, it matches a group of Pods to external access services through label selection. Each svc can be understood as a microservice.

      • Operator

      Kubernetes Operator is a way to package, deploy and manage Kubernetes applications. We use the Kubernetes API (Application Programming Interface) and the Kubectl tool to deploy and manage Kubernetes applications on Kubernetes.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#deployment-architecture","title":"Deployment Architecture","text":""},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#dependent-components","title":"Dependent components","text":"

      MatrixOne distributed system depends on the following components:

      • Kubernetes: As a resource management platform for the entire MatrixOne cluster, components such as Logservice, CN, and TN all run in Pods managed by Kubernetes. In the event of a failure, Kubernetes will cull the failed Pod and start a new one to replace it.

      • Minio: Provides object storage services for the entire MatrixOne cluster, and all MatrixOne data is stored in the object storage provided by Minio.

      Additionally, for container management and orchestration on Kubernetes, we need the following plugins:

      • Helm: Helm is a package management tool for managing Kubernetes applications, similar to APT for Ubuntu and YUM for CentOS. It is used to manage pre-configured installation package resources called Charts.

      • local-path-provisioner: As a plug-in that implements the CSI (Container Storage Interface) interface in Kubernetes, local-path-provisioner is responsible for creating persistent volumes (PVs) for Pods and Minios of MatrixOne components to achieve data persistence storage.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#overall-structure","title":"Overall structure","text":"

      The overall deployment architecture is shown in the following figure:

      The overall architecture consists of the following components:

      • The bottom layer is three server nodes: the first host1 is the springboard machine for installing Kubernetes, the second is the master node (master) of Kubernetes, and the third is Kubernetes' working node (node).

      • The installed Kubernetes and Docker environment is the upper layer, which constitutes the cloud-native platform layer.

      • A Kubernetes plugin layer for management based on Helm, including the local-path-storage plugin implementing the CSI interface, Minio, and the MatrixOne Operator.

      • The topmost layer is several Pods and Services generated by these component configurations.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#pod-and-storage-architecture-of-matrixone","title":"Pod and storage architecture of MatrixOne","text":"

      MatrixOne creates a series of Kubernetes objects according to the rules of the Operator, and these objects are classified according to components and classified into resource groups, namely CNSet, TNSet, and LogSet.

      • Service: The services in each resource group must be provided externally through the Service. Service hosts the external connection function to ensure the service can still be provided when the Pod crashes or is replaced. External applications connect through the Service's exposed ports, and the Service forwards connections to the corresponding Pods through internal forwarding rules.

      • Pod: A containerized instance of MatrixOne components in which MatrixOne's core kernel code runs.

      • PVC: Each Pod declares the storage resources it needs through PVC (Persistent Volume Claim). In our architecture, CN and TN must apply for a storage resource as a cache, and LogService requires corresponding S3 resources. These requirements are declared through PVCs.

      • PV: PV (Persistent Volume) is an abstract representation of storage media, which can be regarded as a storage unit. After applying for a PVC, create a PV through software that implements the CSI interface and binds it to the PVC used for resources.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#1-deploying-a-kubernetes-cluster","title":"1. Deploying a Kubernetes Cluster","text":"

      As MatrixOne's distributed deployment relies on a Kubernetes cluster, we need to have one in place. This article will guide you through setting up a Kubernetes cluster using Kuboard-Spray.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#preparing-the-cluster-environment","title":"Preparing the Cluster Environment","text":"

      To prepare the cluster environment, you need to do the following:

      • Have three virtual machines

      • Use CentOS 7.9 as the operating system (by default, it does allow root account remote login). Two machines will be used for deploying Kubernetes and other dependencies for MatrixOne, while the third will act as a jump host to set up the Kubernetes cluster.

      • External network access conditions. The three servers all need to pull the external network image.

      The specific distribution of the machines is shown below:

      Host Intranet IP Extranet IP mem CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#deploying-kuboard-spray-on-a-jump-server","title":"Deploying Kuboard Spray on a Jump Server","text":"

      Kuboard Spray is a tool used for visualizing the deployment of Kubernetes clusters. It uses Docker to quickly launch a web application that can visualize the deployment of a Kubernetes cluster. Once the Kubernetes cluster environment has been deployed, the Docker application can be stopped.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#preparing-the-jump-server-environment","title":"Preparing the Jump Server Environment","text":"
      1. Install Docker: A Docker environment is required. Install and start Docker on the springboard machine with the following commands:

        curl -sSL https://get.docker.io/ | sh\n#If you are in a domestic network restricted environment, you can change the following domestic mirror address\ncurl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun\n
      2. Start Docker:

        [root@VM-0-6-centos ~]# systemctl start docker\n[root@VM-0-6-centos ~]# systemctl status docker\n\u25cf docker.service - Docker Application Container Engine\n   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)\n   Active: active (running) since Sun 2023-05-07 11:48:06 CST; 15s ago\n     Docs: https://docs.docker.com\n Main PID: 5845 (dockerd)\n    Tasks: 8\n   Memory: 27.8M\n   CGroup: /system.slice/docker.service\n           \u2514\u25005845 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock\n\nMay 07 11:48:06 VM-0-6-centos systemd[1]: Starting Docker Application Container Engine...\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.391166236+08:00\" level=info msg=\"Starting up\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.421736631+08:00\" level=info msg=\"Loading containers: start.\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.531022702+08:00\" level=info msg=\"Loading containers: done.\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.544715135+08:00\" level=info msg=\"Docker daemon\" commit=94d3ad6 graphdriver= overlay2 version=23.0.5\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.544798391+08:00\" level=info msg=\"Daemon has completed initialization\"\nMay 07 11:48:06 VM-0-6-centos systemd[1]: Started Docker Application Container Engine.\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.569274215+08:00\" level=info msg=\"API listen on /run/docker. sock\"\n

      Once the environment is prepared, Kuboard Spray can be deployed.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#deploying-kuboard-spray","title":"Deploying Kuboard Spray","text":"

      Execute the following command to install Kuboard Spray:

      docker run -d \\\n  --privileged \\\n  --restart=unless-stopped \\\n  --name=kuboard-spray \\\n  -p 80:80/tcp \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -v ~/kuboard-spray-data:/data \\\n  eipwork/kuboard-spray:latest-amd64\n

      If the image pull fails due to network issues, use the backup address below:

      docker run -d \\\n  --privileged \\\n  --restart=unless-stopped \\\n  --name=kuboard-spray \\\n  -p 80:80/tcp \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -v ~/kuboard-spray-data:/data \\\n  swr.cn-east-2.myhuaweicloud.com/kuboard/kuboard-spray:latest-amd64\n

      After executing the command, open the Kuboard Spray web interface by entering http://1.13.2.100 (jump server IP address) in a web browser, then log in to the Kuboard Spray interface using the username admin and the default password Kuboard123, as shown below:

      After logging in, the Kubernetes cluster deployment can be started.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#visual-deployment-of-kubernetes-cluster","title":"Visual Deployment of Kubernetes Cluster","text":"

      After logging into the Kuboard-Spray interface, you can begin visually deploying a Kubernetes cluster.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#importing-kubernetes-related-resource-packages","title":"Importing Kubernetes-related Resource Packages","text":"

      The installation interface will download the Kubernetes cluster's corresponding resource package via online downloading to achieve offline installation of the Kubernetes cluster.

      1. Click Resource Package Management and select the appropriate version of the Kubernetes resource package to download:

        Download spray-v2.18.0b-2_k8s-v1.23.17_v1.24-amd64 \u7248\u672c

      2. Click Import > Load Resource Package, select the appropriate download source, and wait for the resource package to finish downloading.

        Note

        We recommend choosing Docker as the container engine for your K8s cluster. Once Docker is selected as the container engine for K8s, Kuboard-Spray will automatically utilize Docker to run various components of the K8s cluster, including containers on both Master and Worker nodes.

      3. This will pull the related image dependencies:

      4. After the image resource package is successfully pulled, return to the Kuboard-Spray web interface. You can see that the corresponding version of the resource package has been imported.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#installing-a-kubernetes-cluster","title":"Installing a Kubernetes Cluster","text":"

      This chapter will guide you through the installation of a Kubernetes cluster.

      1. Select Cluster Management and choose Add Cluster Installation Plan:

      2. In the pop-up dialog box, define the name of the cluster, select the version of the resource package that was just imported, and click OK, as shown in the following figure:

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#cluster-planning","title":"Cluster Planning","text":"

      Based on the predefined roles, the Kubernetes cluster is deployed with a pattern of 1 master + 1 worker + 1 etcd.

      After defining the cluster name and selecting the resource package version, click OK, and then proceed to the cluster planning stage.

      1. Select the corresponding node roles and names:

        • Master node: Select the etcd and control node and name it master0. (If you want the master node to participate in the work, you can select the worker node simultaneously. This method can improve resource utilization but will reduce the high availability of Kubernetes.)
        • Worker node: Select only the worker node and name it node0.
      2. After filling in the roles and node names for each node, please fill in the corresponding connection information on the right, as shown in the following figure:

      3. After filling in all the roles, click Save. You can now prepare to install the Kubernetes cluster.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#installing-kubernetes-cluster","title":"Installing Kubernetes Cluster","text":"

      After completing all roles and saving in the previous step, click Execute to start installing the Kubernetes cluster.

      1. Click OK as shown in the figure below to start installing the Kubernetes cluster:

      2. When installing the Kubernetes cluster, the ansible script will be executed on the corresponding node to install the Kubernetes cluster. The overall installation time will vary depending on the machine configuration and network. Generally, it takes 5 to 10 minutes.

        Note: If an error occurs, you can check the log to confirm whether the version of Kuboard-Spray is mismatched. If the version is mismatched, please replace it with a suitable version.

      3. After the installation is complete, execute kubectl get node on the master node of the Kubernetes cluster:

        [root@master0 ~]# kubectl get node\nNAME      STATUS   ROLES                  AGE   VERSION\nmaster0   Ready    control-plane,master   52m   v1.23.17\nnode0     Ready    <none>                 52m   v1.23.17\n
      4. The command result shown in the figure above indicates that the Kubernetes cluster has been successfully installed.

      5. Adjust the DNS routing table on each node in Kubernetes. Please execute the following command on each machine to find the nameserver containing 169.254.25.10 and delete the record. (This record may affect the communication efficiency between Pods, if this record does not exist, there is no need to change it)

        vim /etc/resolve.conf\n

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#2-deploying-helm","title":"2. Deploying Helm","text":"

      Helm is a package management tool for managing Kubernetes applications. Similar to APT for Ubuntu and YUM for CentOS, Helm provides a convenient way to install, upgrade, and manage Kubernetes applications. It simplifies the application deployment and management process using charts (preconfigured installation package resources).

      Before installing Minio, we need to install Helm first because the installation process of Minio depends on Helm. Here are the steps to install Helm:

      Note: All operations in this section are performed on the master0 node.

      1. Download the Helm installation package:

        wget https://get.helm.sh/helm-v3.10.2-linux-amd64.tar.gz\n#You can use the following domestic mirror address if the trained network is limited.\nwget https://mirrors.huaweicloud.com/helm/v3.10.2/helm-v3.10.2-linux-amd64.tar.gz\n
      2. Extract and install:

        tar -zxf helm-v3.10.2-linux-amd64.tar.gz\nmv linux-amd64/helm /usr/local/bin/helm\n
      3. Verify the version to check if it is installed:

        [root@k8s01 home]# helm version\nversion.BuildInfo{Version:\"v3.10.2\", GitCommit:\"50f003e5ee8704ec937a756c646870227d7c8b58\", GitTreeState:\"clean\", GoVersion:\"go1.18.8\"}\n

        The version information shown above indicates that the installation is complete.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#3-csi-deployment","title":"3. CSI Deployment","text":"

      CSI is a storage plugin for Kubernetes that provides storage services for MinIO and MatrixOne. This section will guide you through the use of the local-path-provisioner plugin.

      Note: All the commands in this section should be executed on the master0 node.

      1. Install CSI using the following command line:

        wget https://github.com/rancher/local-path-provisioner/archive/refs/tags/v0.0.23.zip\nunzip v0.0.23.zip\ncd local-path-provisioner-0.0.23/deploy/chart/local-path-provisioner\nhelm install --set nodePathMap[0].paths[0]=\"/opt/local-path-provisioner\",nodePathMap[0].node=DEFAULT_PATH_FOR_NON_LISTED_NODES  --create-namespace --namespace local-path-storage local-path-storage ./\n
      2. After a successful installation, the command line should display as follows:

        root@master0:~# kubectl get pod -n local-path-storage\nNAME                                                        READY   STATUS    RESTARTS   AGE\nlocal-path-storage-local-path-provisioner-57bf67f7c-lcb88   1/1     Running   0          89s\n

        Note: After installation, this storageClass will provide storage services in the \"/opt/local-path-provisioner\" directory on the worker node. You can modify it to another path.

      3. Set the default storageClass:

        kubectl patch storageclass local-path -p '{\"metadata\": {\"annotations\":{\"storageclass.kubernetes.io/is-default-class\":\"true\"}}}'\n
      4. After setting the default, the command line should display as follows:

        root@master0:~# kubectl get storageclass\nNAME                   PROVISIONER                                               RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE\nlocal-path (default)   cluster.local/local-path-storage-local-path-provisioner   Delete          WaitForFirstConsumer   true                   115s\n
      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#4-minio-deployment","title":"4. MinIO Deployment","text":"

      MinIO is used to provide object storage for MatrixOne. This section will guide you through the deployment of a single-node MinIO.

      Note: All the commands in this section should be executed on the master0 node.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#installation-and-startup","title":"Installation and Startup","text":"
      1. The command line for installing and starting MinIO is as follows:

        helm repo add minio https://charts.min.io/\nmkdir minio_ins && cd minio_ins\nhelm fetch minio/minio\nls -lth\ntar -zxvf minio-5.0.9.tgz # This version may change; the actual download shall prevail\ncd ./minio/\n\nkubectl create ns mostorage\n\nhelm install minio \\\n--namespace mostorage \\\n--set resources.requests.memory=512Mi \\\n--set replicas=1 \\\n--set persistence.size=10G \\\n--set mode=standalone \\\n--set rootUser=rootuser,rootPassword=rootpass123 \\\n--set consoleService.type=NodePort \\\n--set image.repository=minio/minio \\\n--set image.tag=latest \\\n--set mcImage.repository=minio/mc \\\n--set mcImage.tag=latest \\\n-f values.yaml minio/minio\n

        Note

        • --set resources.requests.memory=512Mi sets the minimum memory consumption of MinIO

          • --set persistence.size=1G sets the storage size of MinIO to 1G
          • --set rootUser=rootuser,rootPassword=rootpass123 the parameters set for rootUser and rootPassword are required for creating the secrets file for the Kubernetes cluster later, so use something that you can remember.
        • If it is repeatedly executed due to network or other reasons, it needs to be uninstalled first:

          helm uninstall minio --namespace most storage\n
      2. After a successful installation and start, the command line should display as follows:

        NAME: minio\nLAST DEPLOYED: Sun May 7 14:17:18 2023\nNAMESPACE: most storage\nSTATUS: deployed\nREVISION: 1\nTEST SUITE: None\nNOTES:\nMinIO can be accessed via port 9000 on the following DNS name from within your cluster:\nminio.mostorage.svc.cluster.local\n\nTo access MinIO from localhost, run the following commands:\n\n  1. export POD_NAME=$(kubectl get pods --namespace moststorage -l \"release=minio\" -o jsonpath=\"{.items[0].metadata.name}\")\n\n  2. kubectl port-forward $POD_NAME 9000 --namespace most storage\n\nRead more about port forwarding here: http://kubernetes.io/docs/user-guide/kubectl/kubectl_port-forward/\n\nYou can now access MinIO server on http://localhost:9000. Follow the below steps to connect to MinIO server with mc client:\n\n  1. Download the MinIO mc client - https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart\n\n  2. export MC_HOST_minio-local=http://$(kubectl get secret --namespace most storage minio -o jsonpath=\"{.data.rootUser}\" | base64 --decode):$(kubectl get secret --namespace most storage minio -o jsonpath=\"{.data.rootPassword}\" | base64 --decode)@localhost:9000\n\n  3. mc ls minio-local\n

        So far, Minio has been successfully installed. During the subsequent installation of MatrixOne, MatrixOne will communicate with Minio directly through the Kubernetes Service (SVC) without additional configuration.

        However, if you want to connect to Minio from localhost, you can execute the following command line to set the POD_NAME variable and connect mostorage to port 9000:

        export POD_NAME=$(kubectl get pods --namespace mostorage -l \"release=minio\" -o jsonpath=\"{.items[0].metadata.name}\")\nnohup kubectl port-forward --address 0.0.0.0 $POD_NAME -n mostorage 9000:9000 &\n
      3. After startup, use http://118.195.255.252:32001/ to log in to the MinIO page and create object storage information. As shown in the figure below, the account password is the rootUser and rootPassword set by --set rootUser=rootuser,rootPassword=rootpass123 in the above steps:

      4. After logging in, you need to create object storage related information:

        Fill in the Bucket Name with minio-mo under Bucket > Create Bucket. After filling it in, click the Create Bucket button at the bottom right.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#5-deploying-a-matrixone-cluster","title":"5. Deploying a MatrixOne Cluster","text":"

      This section will guide you through the process of deploying a MatrixOne cluster.

      Note: All steps in this section are performed on the master0 node.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#installing-the-matrixone-operator","title":"Installing the MatrixOne-Operator","text":"

      MatrixOne Operator is a standalone software tool for deploying and managing MatrixOne clusters on Kubernetes. You can install the latest Operator Release installation package from the project's Release List.

      Follow the steps below to install MatrixOne Operator on master0. We will create a separate namespace, matrixone-operator for the Operator.

      1. Download the latest MatrixOne Operator installation package:

        wget https://github.com/matrixorigin/matrixone-operator/releases/download/chart-0.8.0-alpha.7/matrixone-operator-0.8.0-alpha.7.tgz\n
      2. Unzip the installation package:

        tar -xvf matrixone-operator-0.8.0-alpha.7.tgz\ncd /root/matrixone-operator/\n
      3. Define the namespace variable:

        NS=\"matrixone-operator\"\n
      4. Use Helm to install MatrixOne Operator and create a namespace:

        helm install --create-namespace --namespace ${NS} matrixone-operator ./ --dependency-update\n
      5. After the installation is successful, use the following command to confirm the installation status:

        kubectl get pod -n matrixone-operator\n

        Ensure all pods have a running status in the above command output.

        [root@master0 matrixone-operator]# kubectl get pod -n matrixone-operator\nNAME                                 READY   STATUS    RESTARTS   AGE\nmatrixone-operator-f8496ff5c-fp6zm   1/1     Running   0          3m26s\n

      As shown in the above line of code, the status of the corresponding Pods is normal.

      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#create-a-matrixone-cluster","title":"Create a MatrixOne cluster","text":"
      1. First, create the namespace of MatrixOne:

        NS=\"mo-hn\"\nkubectl create ns ${NS}\n
      2. Customize the yaml file of the MatrixOne cluster, and write the following mo.yaml file:

        apiVersion: core.matrixorigin.io/v1alpha1\nkind: MatrixOneCluster\nmetadata:\n  name: mo\n  namespace: mo-hn\nspec:\n  # 1. Configuration for tn\n  Tn:\n    cacheVolume: # Disk cache for tn\n      size: 5Gi # Modify according to actual disk size and requirements\n      storageClassName: local-path # If not specified, the default storage class of the system will be used\n    resources:\n      requests:\n        cpu: 100m #1000m=1c\n        memory: 500Mi # 1024Mi\n      limits: # Note that limits should not be lower than requests and should not exceed the capacity of a single node. Generally allocate based on actual circumstances, usually set limits and requests to be consistent.\n        cpu: 200m\n        memory: 1Gi\n    config: |  # Configuration for tn\n      [dn.Txn.Storage]\n      backend = \"TAE\"\n      log-backend = \"logservice\"\n      [dn.Ckp]\n      flush-interval = \"60s\"\n      min-count = 100\n      scan-interval = \"5s\"\n      incremental-interval = \"60s\"\n      global-interval = \"100000s\"\n      [log]\n      level = \"error\"\n      format = \"json\"\n      max-size = 512\n    replicas: 1 # The number of copies of TN, which cannot be modified. The current version only supports a setting of 1.\n  # 2. Configuration for logservice\n  logService:\n    replicas: 3 # Number of logservice replicas\n    resources:\n      requests:\n        cpu: 100m #1000m=1c\n        memory: 500Mi # 1024Mi\n      limits: # Note that limits should not be lower than requests and should not exceed the capacity of a single node. Generally allocate based on actual circumstances, usually set limits and requests to be consistent.\n        cpu: 200m\n        memory: 1Gi\n    sharedStorage: # Configuration for logservice to connect to s3 storage\n      s3:\n        type: minio # Type of s3 storage to connect to is minio\n        path: minio-mo # Path to the minio bucket used by mo, previously created through the console or mc command\n        endpoint: http://minio.mostorage:9000 # The svc address and port of the minio service\n        secretRef: # Configuration for accessing minio, the secret name is minio\n          name: minio\n    pvcRetentionPolicy: Retain # Configuration for the lifecycle policy of the pvc bucket after the cluster is destroyed, Retain means to keep, Delete means to delete\n    volume:\n      size: 1Gi # Configuration for the size of S3 object storage, modify according to actual disk size and requirements\n    config: | # Configuration for logservice\n      [log]\n      level = \"error\"\n      format = \"json\"\n      max-size = 512\n  # 3. Configuration for cn\n  tp:\n    cacheVolume: # Disk cache for cn\n      size: 5Gi # Modify according to actual disk size and requirements\n      storageClassName: local-path # If not specified, the default storage class of the system will be used\n    resources:\n      requests:\n        cpu: 100m #1000m=1c\n        memory: 500Mi # 1024Mi\n      limits: # Note that limits should not be lower than requests and should not exceed the capacity of a single node. Generally allocate based on actual circumstances, usually set limits and requests to be consistent.\n        cpu: 200m\n        memory: 2Gi\n    serviceType: NodePort # cn needs to provide access entry to the outside, so its svc is set to NodePort\n    nodePort: 31429 # NodePort port setting\n    config: | # Configuration for cn\n      [cn.Engine]\n      type = \"distributed-tae\"\n      [log]\n      level = \"debug\"\n      format = \"json\"\n      max-size = 512\n    replicas: 1\n  version: nightly-54b5e8c # The version of the MO image. You can check it on Docker Hub. Generally, cn, TN, and logservice are packaged in the same image, so the same field can be used to specify it. It also supports specifying separately in each section, but unless there are special circumstances, use a unified image version.\n  # https://hub.docker.com/r/matrixorigin/matrixone/tags\n  imageRepository: matrixorigin/matrixone # Image repository address. If it is pulled locally and the tag has been modified, you can adjust this configuration item.\n  imagePullPolicy: IfNotPresent # Image pull policy, consistent with the configurable values of k8s official.\n
      3. Execute the following command to create a Secret service for accessing MinIO in the namespace mo-hn:

        kubectl -n mo-hn create secret generic minio --from-literal=AWS_ACCESS_KEY_ID=rootuser --from-literal=AWS_SECRET_ACCESS_KEY=rootpass123\n

        The username and password use the rootUser and rootPassword set when creating the MinIO cluster.

      4. Execute the following command to deploy the MatrixOne cluster:

        kubectl apply -f mo.yaml\n
      5. Please wait patiently for about 10 minutes. If the Pod restarts, please continue to wait. Until you see the following information, the deployment is successful:

        [root@master0 mo]# kubectl get pods -n mo-hn      \nNAME                                 READY   STATUS    RESTARTS      AGE\nmo-tn-0                              1/1     Running   0             74s\nmo-log-0                             1/1     Running   1 (25s ago)   2m2s\nmo-log-1                             1/1     Running   1 (24s ago)   2m2s\nmo-log-2                             1/1     Running   1 (22s ago)   2m2s\nmo-tp-cn-0                           1/1     Running   0             50s\n
      "},{"location":"MatrixOne/Deploy/deploy-MatrixOne-cluster/#6-connect-to-matrixone-cluster","title":"6. Connect to MatrixOne cluster","text":"

      To connect to the MatrixOne cluster, you need to map the port of the corresponding service to the MatrixOne node. Here are the instructions for connecting to a MatrixOne cluster using kubectl port-forward:

      • Only allow local access:
      nohup kubectl port-forward -nmo-hn svc/mo-tp-cn 6001:6001 &\n
      • Specify a specific machine or all machines to access:
      nohup kubectl port-forward -nmo-hn --address 0.0.0.0 svc/mo-tp-cn 6001:6001 &\n

      After specifying Allow local access or Specify a specific machine or all machines to access, you can use the MySQL client to connect to MatrixOne:

      # Connect to the MySQL server using the 'mysql' command line tool\n# Use 'kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}' ' to get the cluster IP address of the service in the Kubernetes cluster\n# The '-h' parameter specifies the hostname or IP address of the MySQL service\n# The '-P' parameter specifies the port number of the MySQL service, here is 6001\n# '-uroot' means log in with root user\n# '-p111' means the initial password is 111\nmysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 163\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

      After explicit mysql>, the distributed MatrixOne cluster is established and connected.

      Info

      The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

      "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/","title":"Health check and resource monitoring","text":"

      In the MatrixOne distributed cluster, there are multiple components and objects. To ensure its regular operation and troubleshooting, we must perform a series of health checks and resource monitoring.

      The health check and resource monitoring environment introduced in this document will be based on the MatrixOne Distributed Cluster Deployment environment.

      The upgraded environment introduced in this document will be based on the environment of MatrixOne Distributed Cluster Deployment.

      "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#objects-to-check","title":"Objects to check","text":"
      • Physical resource layer: including the three virtual machines' CPU, memory, and disk resources. For a mature solution to monitor these resources, see Monitoring Solution.

      • Logical resource layer: including the capacity usage of MinIO, the CPU and memory resource usage of each node and Pod of Kubernetes, the overall status of MatrixOne, and the status of each component (such as LogService, CN, TN).

      "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#resource-monitoring","title":"Resource monitoring","text":""},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#minio-capacity-usage-monitoring","title":"MinIO capacity usage monitoring","text":"

      MinIO has a management interface through which we can visually monitor its capacity usage, including the remaining space. For more information, see official documentation.

      "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#nodepod-resource-monitoring","title":"Node/Pod resource monitoring","text":"

      To determine whether the MatrixOne service needs to be scaled up or down, users often need to monitor the resources used by the Node where the MatrixOne cluster resides and the pods corresponding to the components.

      You can use the kubectl top command to complete it. For more information, see Kubernetes official website document of

      "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#node-monitoring","title":"Node Monitoring","text":"
      1. Use the following command to view the details of MatrixOne cluster nodes:

        kubectl get node\n
        [root@master0 ~]# kubectl get node\nNAME      STATUS   ROLES                  AGE   VERSION\nmaster0   Ready    control-plane,master   22h   v1.23.17\nnode0     Ready    <none>                 22h   v1.23.17\n
      2. According to the above-returned results, use the following command to view the resource usage of a specific node. According to the previous deployment scheme, it can be seen that the MatrixOne cluster is located on the node named node0:

        NODE=\"[node to be monitored]\" # According to the above results, it may be IP, hostname, or alias, such as 10.0.0.1, host-10-0-0-1, node01\nkubectl top node ${NODE}\n
        [root@master0 ~]# kubectl top node\nNAME      CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   \nmaster0   179m         9%     4632Mi          66%       \nnode0     292m         15%    4115Mi          56%  \n[root@master0 ~]# kubectl top node node0\nNAME    CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   \nnode0   299m         15%    4079Mi          56%  \n
      3. You can also view the node's resource allocation and upper limit. Note that allocated resources are not equal to used resources.

      [root@master0 ~]# kubectl describe node node0\nName:               master0\nRoles:              control-plane,master\nLabels:             beta.kubernetes.io/arch=amd64\n                    beta.kubernetes.io/os=linux\n                    kubernetes.io/arch=amd64\n                    kubernetes.io/hostname=master0\n                    kubernetes.io/os=linux\n                    node-role.kubernetes.io/control-plane=\n                    node-role.kubernetes.io/master=\n                    node.kubernetes.io/exclude-from-external-load-balancers=\nAnnotations:        kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock\n                    node.alpha.kubernetes.io/ttl: 0\n                    projectcalico.org/IPv4Address: 10.206.134.8/24\n                    projectcalico.org/IPv4VXLANTunnelAddr: 10.234.166.0\n                    volumes.kubernetes.io/controller-managed-attach-detach: true\nCreationTimestamp:  Sun, 07 May 2023 12:28:57 +0800\nTaints:             node-role.kubernetes.io/master:NoSchedule\nUnschedulable:      false\nLease:\n  HolderIdentity:  master0\n  AcquireTime:     <unset>\n  RenewTime:       Mon, 08 May 2023 10:56:08 +0800\nConditions:\n  Type                 Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message\n  ----                 ------  -----------------                 ------------------                ------                       -------\n  NetworkUnavailable   False   Sun, 07 May 2023 12:30:08 +0800   Sun, 07 May 2023 12:30:08 +0800   CalicoIsUp                   Calico is running on this node\n  MemoryPressure       False   Mon, 08 May 2023 10:56:07 +0800   Sun, 07 May 2023 12:28:55 +0800   KubeletHasSufficientMemory   kubelet has sufficient memory available\n  DiskPressure         False   Mon, 08 May 2023 10:56:07 +0800   Sun, 07 May 2023 12:28:55 +0800   KubeletHasNoDiskPressure     kubelet has no disk pressure\n  PIDPressure          False   Mon, 08 May 2023 10:56:07 +0800   Sun, 07 May 2023 12:28:55 +0800   KubeletHasSufficientPID      kubelet has sufficient PID available\n  Ready                True    Mon, 08 May 2023 10:56:07 +0800   Sun, 07 May 2023 20:47:39 +0800   KubeletReady                 kubelet is posting ready status\nAddresses:\n  InternalIP:  10.206.134.8\n  Hostname:    master0\nCapacity:\n  cpu:                2\n  ephemeral-storage:  51473868Ki\n  hugepages-1Gi:      0\n  hugepages-2Mi:      0\n  memory:             7782436Ki\n  pods:               110\nAllocatable:\n  cpu:                1800m\n  ephemeral-storage:  47438316671\n  hugepages-1Gi:      0\n  hugepages-2Mi:      0\n  memory:             7155748Ki\n  pods:               110\nSystem Info:\n  Machine ID:                 fb436be013b5415799d27abf653585d3\n  System UUID:                FB436BE0-13B5-4157-99D2-7ABF653585D3\n  Boot ID:                    552bd576-56c8-4d22-9549-d950069a5a77\n  Kernel Version:             3.10.0-1160.88.1.el7.x86_64\n  OS Image:                   CentOS Linux 7 (Core)\n  Operating System:           linux\n  Architecture:               amd64\n  Container Runtime Version:  docker://20.10.23\n  Kubelet Version:            v1.23.17\n  Kube-Proxy Version:         v1.23.17\nPodCIDR:                      10.234.0.0/23\nPodCIDRs:                     10.234.0.0/23\nNon-terminated Pods:          (12 in total)\n  Namespace                   Name                               CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age\n  ---------                   ----                               ------------  ----------  ---------------  -------------  ---\n  default                     netchecker-agent-7xnwb             15m (0%)      30m (1%)    64M (0%)         100M (1%)      22h\n  default                     netchecker-agent-hostnet-bw85f     15m (0%)      30m (1%)    64M (0%)         100M (1%)      22h\n  kruise-system               kruise-daemon-xvl8t                0 (0%)        50m (2%)    0 (0%)           128Mi (1%)     20h\n  kube-system                 calico-node-sbzfc                  150m (8%)     300m (16%)  64M (0%)         500M (6%)      22h\n  kube-system                 dns-autoscaler-7874cf6bcf-l55q4    20m (1%)      0 (0%)      10Mi (0%)        0 (0%)         22h\n  kube-system                 kube-apiserver-master0             250m (13%)    0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 kube-controller-manager-master0    200m (11%)    0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 kube-proxy-lfkhk                   0 (0%)        0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 kube-scheduler-master0             100m (5%)     0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 metrics-server-7bd47f88c4-knh9b    100m (5%)     100m (5%)   200Mi (2%)       200Mi (2%)     22h\n  kube-system                 nodelocaldns-dcffl                 100m (5%)     0 (0%)      70Mi (1%)        170Mi (2%)     14h\n  kuboard                     kuboard-v3-master0                 0 (0%)        0 (0%)      0 (0%)           0 (0%)         22h\nAllocated resources:\n  (Total limits may be over 100 percent, i.e., overcommitted.)\n  Resource           Requests        Limits\n  --------           --------        ------\n  cpu                950m (52%)      510m (28%)\n  memory             485601280 (6%)  1222190848 (16%)\n  ephemeral-storage  0 (0%)          0 (0%)\n  hugepages-1Gi      0 (0%)          0 (0%)\n  hugepages-2Mi      0 (0%)          0 (0%)\nEvents:              <none>\n\n\nName:               node0\nRoles:              <none>\nLabels:             beta.kubernetes.io/arch=amd64\n                    beta.kubernetes.io/os=linux\n                    kubernetes.io/arch=amd64\n                    kubernetes.io/hostname=node0\n                    kubernetes.io/os=linux\nAnnotations:        kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock\n                    node.alpha.kubernetes.io/ttl: 0\n                    projectcalico.org/IPv4Address: 10.206.134.14/24\n                    projectcalico.org/IPv4VXLANTunnelAddr: 10.234.60.0\n                    volumes.kubernetes.io/controller-managed-attach-detach: true\nCreationTimestamp:  Sun, 07 May 2023 12:29:46 +0800\nTaints:             <none>\nUnschedulable:      false\nLease:\n  HolderIdentity:  node0\n  AcquireTime:     <unset>\n  RenewTime:       Mon, 08 May 2023 10:56:06 +0800\nConditions:\n  Type                 Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message\n  ----                 ------  -----------------                 ------------------                ------                       -------\n  NetworkUnavailable   False   Sun, 07 May 2023 12:30:08 +0800   Sun, 07 May 2023 12:30:08 +0800   CalicoIsUp                   Calico is running on this node\n  MemoryPressure       False   Mon, 08 May 2023 10:56:12 +0800   Sun, 07 May 2023 12:29:46 +0800   KubeletHasSufficientMemory   kubelet has sufficient memory available\n  DiskPressure         False   Mon, 08 May 2023 10:56:12 +0800   Sun, 07 May 2023 12:29:46 +0800   KubeletHasNoDiskPressure     kubelet has no disk pressure\n  PIDPressure          False   Mon, 08 May 2023 10:56:12 +0800   Sun, 07 May 2023 12:29:46 +0800   KubeletHasSufficientPID      kubelet has sufficient PID available\n  Ready                True    Mon, 08 May 2023 10:56:12 +0800   Sun, 07 May 2023 20:48:36 +0800   KubeletReady                 kubelet is posting ready status\nAddresses:\n  InternalIP:  10.206.134.14\n  Hostname:    node0\nCapacity:\n  cpu:                2\n  ephemeral-storage:  51473868Ki\n  hugepages-1Gi:      0\n  hugepages-2Mi:      0\n  memory:             7782444Ki\n  pods:               110\nAllocatable:\n  cpu:                1900m\n  ephemeral-storage:  47438316671\n  hugepages-1Gi:      0\n  hugepages-2Mi:      0\n  memory:             7417900Ki\n  pods:               110\nSystem Info:\n  Machine ID:                 a6600151884b44fb9f0bc9af490e44b7\n  System UUID:                A6600151-884B-44FB-9F0B-C9AF490E44B7\n  Boot ID:                    b7f3357f-44e6-425e-8c90-6ada14e92703\n  Kernel Version:             3.10.0-1160.88.1.el7.x86_64\n  OS Image:                   CentOS Linux 7 (Core)\n  Operating System:           linux\n  Architecture:               amd64\n  Container Runtime Version:  docker://20.10.23\n  Kubelet Version:            v1.23.17\n  Kube-Proxy Version:         v1.23.17\nPodCIDR:                      10.234.2.0/23\nPodCIDRs:                     10.234.2.0/23\nNon-terminated Pods:          (20 in total)\n  Namespace                   Name                                                         CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age\n  ---------                   ----                                                         ------------  ----------  ---------------  -------------  ---\n  default                     netchecker-agent-6v8rl                                       15m (0%)      30m (1%)    64M (0%)         100M (1%)      22h\n  default                     netchecker-agent-hostnet-fb2jn                               15m (0%)      30m (1%)    64M (0%)         100M (1%)      22h\n  default                     netchecker-server-645d759b79-v4bqm                           150m (7%)     300m (15%)  192M (2%)        512M (6%)      22h\n  kruise-system               kruise-controller-manager-74847d59cf-295rk                   100m (5%)     200m (10%)  256Mi (3%)       512Mi (7%)     20h\n  kruise-system               kruise-controller-manager-74847d59cf-854sq                   100m (5%)     200m (10%)  256Mi (3%)       512Mi (7%)     20h\n  kruise-system               kruise-daemon-rz9pj                                          0 (0%)        50m (2%)    0 (0%)           128Mi (1%)     20h\n  kube-system                 calico-kube-controllers-74df5cd99c-n9qsn                     30m (1%)      1 (52%)     64M (0%)         256M (3%)      22h\n  kube-system                 calico-node-brqrk                                            150m (7%)     300m (15%)  64M (0%)         500M (6%)      22h\n  kube-system                 coredns-76b4fb4578-9cqc7                                     100m (5%)     0 (0%)      70Mi (0%)        170Mi (2%)     14h\n  kube-system                 kube-proxy-rpxb5                                             0 (0%)        0 (0%)      0 (0%)           0 (0%)         22h\n  kube-system                 nginx-proxy-node0                                            25m (1%)      0 (0%)      32M (0%)         0 (0%)         22h\n  kube-system                 nodelocaldns-qkxhv                                           100m (5%)     0 (0%)      70Mi (0%)        170Mi (2%)     14h\n  local-path-storage          local-path-storage-local-path-provisioner-d5bb7f8c9-qfp8h    0 (0%)        0 (0%)      0 (0%)           0 (0%)         21h\n  mo-hn                       matrixone-operator-f8496ff5c-fp6zm                           0 (0%)        0 (0%)      0 (0%)           0 (0%)         20h\n  mo-hn                       mo-tn-0                                                      0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mo-hn                       mo-log-0                                                     0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mo-hn                       mo-log-1                                                     0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mo-hn                       mo-log-2                                                     0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mo-hn                       mo-tp-cn-0                                                   0 (0%)        0 (0%)      0 (0%)           0 (0%)         13h\n  mostorage                   minio-674ccf54f7-tdglh                                       0 (0%)        0 (0%)      512Mi (7%)       0 (0%)         20h\nAllocated resources:\n  (Total limits may be over 100 percent, i.e., overcommitted.)\n  Resource           Requests          Limits\n  --------           --------          ------\n  cpu                785m (41%)        2110m (111%)\n  memory             1700542464 (22%)  3032475392 (39%)\n  ephemeral-storage  0 (0%)            0 (0%)\n  hugepages-1Gi      0 (0%)            0 (0%)\n  hugepages-2Mi      0 (0%)            0 (0%)\nEvents:              <none>\n
      "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#pod-monitoring","title":"Pod Monitoring","text":"
      1. Use the following command to view the Pods of the MatrixOne cluster:

        NS=\"mo-hn\"\nkubectl get pod -n ${NS}\n
      2. According to the above-returned results, use the following command to view the resource usage of a specific Pod:

        POD=\"[pod name to be monitored]\" # According to the above results, for example: TN is mo-tn-0, cn is mo-tp-cn-0, mo-tp-cn-1, ..., logservice is mo -log-0, mo-log-1, ...\nkubectl top pod ${POD} -n ${NS}\n

        The command will display the CPU and memory usage for the specified Pod, similar to the following output:

        [root@master0 ~]# kubectl top pod mo-tp-cn-0 -nmo-hn\nNAME         CPU(cores)   MEMORY(bytes)   \nmo-tp-cn-0   20m          214Mi\n[root@master0 ~]# kubectl top pod mo-tn-0 -nmo-hn     \nNAME      CPU(cores)   MEMORY(bytes)   \nmo-tn-0   36m          161Mi  \n
      3. you can also view the resource declaration of a specific Pod to compare it with the actual resource usage.

      kubectl describe pod ${POD_NAME} -n${NS}\nkubectl get pod ${POD_NAME} -n${NS} -oyaml\n
      [root@master0 ~]# kubectl describe pod mo-tp-cn-0 -nmo-hn\nName:         mo-tp-cn-0\nNamespace:    mo-hn\nPriority:     0\nNode:         node0/10.206.134.14\nStart Time:   Sun, 07 May 2023 21:01:50 +0800\nLabels:       controller-revision-hash=mo-tp-cn-8666cdfb56\n              lifecycle.apps.kruise.io/state=Normal\n              matrixorigin.io/cluster=mo\n              matrixorigin.io/component=CNSet\n              matrixorigin.io/instance=mo-tp\n              matrixorigin.io/namespace=mo-hn\n              statefulset.kubernetes.io/pod-name=mo-tp-cn-0\nAnnotations:  apps.kruise.io/runtime-containers-meta:\n                {\"containers\":[{\"name\":\"main\",\"containerID\":\"docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\",\"restartCount\":0,\"...\n              cni.projectcalico.org/containerID: 80b286789a2d6fa9e615c3edee79b57edb452eaeafddb9b7b82ec5fb2e339409\n              cni.projectcalico.org/podIP: 10.234.60.53/32\n              cni.projectcalico.org/podIPs: 10.234.60.53/32\n              kruise.io/related-pub: mo\n              lifecycle.apps.kruise.io/timestamp: 2023-05-07T13:01:50Z\n              matrixone.cloud/cn-label: null\n              matrixone.cloud/dns-based-identity: False\nStatus:       Running\nIP:           10.234.60.53\nIPs:\n  IP:           10.234.60.53\nControlled By:  StatefulSet/mo-tp-cn\nContainers:\n  main:\n    Container ID:  docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\n    Image:         matrixorigin/matrixone:nightly-144f3be4\n    Image ID:      docker-pullable://matrixorigin/matrixone@sha256:288fe3d626c6aa564684099e4686a9d4b28e16fdd16512bd968a67bb41d5aaa3\n    Port:          <none>\n    Host Port:     <none>\n    Command:\n      /bin/sh\n      /etc/matrixone/config/start.sh\n    Args:\n      -debug-http=:6060\n    State:          Running\n      Started:      Sun, 07 May 2023 21:01:54 +0800\n    Ready:          True\n    Restart Count:  0\n    Environment:\n      POD_NAME:               mo-tp-cn-0 (v1:metadata.name)\n      NAMESPACE:              mo-hn (v1:metadata.namespace)\n      HEADLESS_SERVICE_NAME:  mo-tp-cn-headless\n      AWS_ACCESS_KEY_ID:      <set to the key 'AWS_ACCESS_KEY_ID' in secret 'minio'>      Optional: false\n      AWS_SECRET_ACCESS_KEY:  <set to the key 'AWS_SECRET_ACCESS_KEY' in secret 'minio'>  Optional: false\n      AWS_REGION:             us-west-2\n    Mounts:\n      /etc/matrixone/config from config (ro)\n      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-ngpcs (ro)\nReadiness Gates:\n  Type                 Status\n  InPlaceUpdateReady   True\n  KruisePodReady       True\nConditions:\n  Type                 Status\n  KruisePodReady       True\n  InPlaceUpdateReady   True\n  Initialized          True\n  Ready                True\n  ContainersReady      True\n  PodScheduled         True\nVolumes:\n  config:\n    Type:      ConfigMap (a volume populated by a ConfigMap)\n    Name:      mo-tp-cn-config-5abf454\n    Optional:  false\n  kube-api-access-ngpcs:\n    Type:                    Projected (a volume that contains injected data from multiple sources)\n    TokenExpirationSeconds:  3607\n    ConfigMapName:           kube-root-ca.crt\n    ConfigMapOptional:       <nil>\n    DownwardAPI:             true\nQoS Class:                   BestEffort\nNode-Selectors:              <none>\nTolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s\n                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s\nEvents:                      <none>\n[root@master0 ~]# kubectl get pod  mo-tp-cn-0 -nmo-hn -oyaml\napiVersion: v1\nkind: Pod\nmetadata:\n  annotations:\n    apps.kruise.io/runtime-containers-meta: '{\"containers\":[{\"name\":\"main\",\"containerID\":\"docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\",\"restartCount\":0,\"hashes\":{\"plainHash\":1670287891}}]}'\n    cni.projectcalico.org/containerID: 80b286789a2d6fa9e615c3edee79b57edb452eaeafddb9b7b82ec5fb2e339409\n    cni.projectcalico.org/podIP: 10.234.60.53/32\n    cni.projectcalico.org/podIPs: 10.234.60.53/32\n    kruise.io/related-pub: mo\n    lifecycle.apps.kruise.io/timestamp: \"2023-05-07T13:01:50Z\"\n    matrixone.cloud/cn-label: \"null\"\n    matrixone.cloud/dns-based-identity: \"False\"\n  creationTimestamp: \"2023-05-07T13:01:50Z\"\n  generateName: mo-tp-cn-\n  labels:\n    controller-revision-hash: mo-tp-cn-8666cdfb56\n    lifecycle.apps.kruise.io/state: Normal\n    matrixorigin.io/cluster: mo\n    matrixorigin.io/component: CNSet\n    matrixorigin.io/instance: mo-tp\n    matrixorigin.io/namespace: mo-hn\n    statefulset.kubernetes.io/pod-name: mo-tp-cn-0\n  name: mo-tp-cn-0\n  namespace: mo-hn\n  ownerReferences:\n  - apiVersion: apps.kruise.io/v1beta1\n    blockOwnerDeletion: true\n    controller: true\n    kind: StatefulSet\n    name: mo-tp-cn\n    uid: 891e0453-89a5-45d5-ad12-16ef048c804f\n  resourceVersion: \"72625\"\n  uid: 1e3e2df3-f1c2-4444-8694-8d23e7125d35\nspec:\n  containers:\n  - args:\n    - -debug-http=:6060\n    command:\n    - /bin/sh\n    - /etc/matrixone/config/start.sh\n    env:\n    - name: POD_NAME\n      valueFrom:\n        fieldRef:\n          apiVersion: v1\n          fieldPath: metadata.name\n    - name: NAMESPACE\n      valueFrom:\n        fieldRef:\n          apiVersion: v1\n          fieldPath: metadata.namespace\n    - name: HEADLESS_SERVICE_NAME\n      value: mo-tp-cn-headless\n    - name: AWS_ACCESS_KEY_ID\n      valueFrom:\n        secretKeyRef:\n          key: AWS_ACCESS_KEY_ID\n          name: minio\n    - name: AWS_SECRET_ACCESS_KEY\n      valueFrom:\n        secretKeyRef:\n          key: AWS_SECRET_ACCESS_KEY\n          name: minio\n    - name: AWS_REGION\n      value: us-west-2\n    image: matrixorigin/matrixone:nightly-144f3be4\n    imagePullPolicy: Always\n    name: main\n    resources: {}\n    terminationMessagePath: /dev/termination-log\n    terminationMessagePolicy: File\n    volumeMounts:\n    - mountPath: /etc/matrixone/config\n      name: config\n      readOnly: true\n    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount\n      name: kube-api-access-ngpcs\n      readOnly: true\n  dnsPolicy: ClusterFirst\n  enableServiceLinks: true\n  hostname: mo-tp-cn-0\n  nodeName: node0\n  preemptionPolicy: PreemptLowerPriority\n  priority: 0\n  readinessGates:\n  - conditionType: InPlaceUpdateReady\n  - conditionType: KruisePodReady\n  restartPolicy: Always\n  schedulerName: default-scheduler\n  securityContext: {}\n  serviceAccount: default\n  serviceAccountName: default\n  subdomain: mo-tp-cn-headless\n  terminationGracePeriodSeconds: 30\n  tolerations:\n  - effect: NoExecute\n    key: node.kubernetes.io/not-ready\n    operator: Exists\n    tolerationSeconds: 300\n  - effect: NoExecute\n    key: node.kubernetes.io/unreachable\n    operator: Exists\n    tolerationSeconds: 300\n  volumes:\n  - configMap:\n      defaultMode: 420\n      name: mo-tp-cn-config-5abf454\n    name: config\n  - name: kube-api-access-ngpcs\n    projected:\n      defaultMode: 420\n      sources:\n      - serviceAccountToken:\n          expirationSeconds: 3607\n          path: token\n      - configMap:\n          items:\n          - key: ca.crt\n            path: ca.crt\n          name: kube-root-ca.crt\n      - downwardAPI:\n          items:\n          - fieldRef:\n              apiVersion: v1\n              fieldPath: metadata.namespace\n            path: namespace\nstatus:\n  conditions:\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:50Z\"\n    status: \"True\"\n    type: KruisePodReady\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:50Z\"\n    status: \"True\"\n    type: InPlaceUpdateReady\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:50Z\"\n    status: \"True\"\n    type: Initialized\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:54Z\"\n    status: \"True\"\n    type: Ready\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:54Z\"\n    status: \"True\"\n    type: ContainersReady\n  - lastProbeTime: null\n    lastTransitionTime: \"2023-05-07T13:01:50Z\"\n    status: \"True\"\n    type: PodScheduled\n  containerStatuses:\n  - containerID: docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\n    image: matrixorigin/matrixone:nightly-144f3be4\n    imageID: docker-pullable://matrixorigin/matrixone@sha256:288fe3d626c6aa564684099e4686a9d4b28e16fdd16512bd968a67bb41d5aaa3\n    lastState: {}\n    name: main\n    ready: true\n    restartCount: 0\n    started: true\n    state:\n      running:\n        startedAt: \"2023-05-07T13:01:54Z\"\n  hostIP: 10.206.134.14\n  phase: Running\n  podIP: 10.234.60.53\n  podIPs:\n  - ip: 10.234.60.53\n  qosClass: BestEffort\n  startTime: \"2023-05-07T13:01:50Z\"\n
      "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#matrixone-monitoring","title":"MatrixOne Monitoring","text":""},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#view-cluster-status","title":"View cluster status","text":"

      During Operator deployment, we defined matrixOnecluster as the custom resource name for the entire cluster. By checking MatrixOneCluster, we can tell if the cluster is functioning correctly. You can check with the following command:

      MO_NAME=\"mo\"\nNS=\"mo-hn\"\nkubectl get matrixonecluster -n ${NS} ${MO_NAME}\n

      If the status is \"Ready\", the cluster is healthy. If the status is \"NotReady\", further troubleshooting is required.

      [root@master0 ~]# MO_NAME=\"mo\"\n[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get matrixonecluster -n${NS} ${MO_NAME}\nNAME   LOG   TN    TP    AP    VERSION            PHASE   AGE\nmo     3     1     1           nightly-144f3be4   Ready   13h\n

      To view details of the MatrixOne cluster status, you can run the following command:

      kubectl describe matrixonecluster -n${NS} ${MO_NAME}\n
      [root@master0 ~]# kubectl describe matrixonecluster -n${NS} ${MO_NAME}\nName:         mo\nNamespace:    mo-hn\nLabels:       <none>\nAnnotations:  <none>\nAPI Version:  core.matrixorigin.io/v1alpha1\nKind:         MatrixOneCluster\nMetadata:\n  Creation Timestamp:  2023-05-07T12:54:17Z\n  Finalizers:\n    matrixorigin.io/matrixonecluster\n  Generation:  2\n  Managed Fields:\n    API Version:  core.matrixorigin.io/v1alpha1\n    Fields Type:  FieldsV1\n    fieldsV1:\n      f:metadata:\n        f:annotations:\n          .:\n          f:kubectl.kubernetes.io/last-applied-configuration:\n      f:spec:\n        .:\n        f:Tn:\n          .:\n          f:config:\n          f:replicas:\n        f:imagePullPolicy:\n        f:imageRepository:\n        f:logService:\n          .:\n          f:config:\n          f:pvcRetentionPolicy:\n          f:replicas:\n          f:sharedStorage:\n            .:\n            f:s3:\n              .:\n              f:endpoint:\n              f:secretRef:\n              f:type:\n          f:volume:\n            .:\n            f:size:\n        f:tp:\n          .:\n          f:config:\n          f:nodePort:\n          f:replicas:\n          f:serviceType:\n        f:version:\n    Manager:      kubectl-client-side-apply\n    Operation:    Update\n    Time:         2023-05-07T12:54:17Z\n    API Version:  core.matrixorigin.io/v1alpha1\n    Fields Type:  FieldsV1\n    fieldsV1:\n      f:metadata:\n        f:finalizers:\n          .:\n          v:\"matrixorigin.io/matrixonecluster\":\n    Manager:      manager\n    Operation:    Update\n    Time:         2023-05-07T12:54:17Z\n    API Version:  core.matrixorigin.io/v1alpha1\n    Fields Type:  FieldsV1\n    fieldsV1:\n      f:spec:\n        f:logService:\n          f:sharedStorage:\n            f:s3:\n              f:path:\n    Manager:      kubectl-edit\n    Operation:    Update\n    Time:         2023-05-07T13:00:53Z\n    API Version:  core.matrixorigin.io/v1alpha1\n    Fields Type:  FieldsV1\n    fieldsV1:\n      f:status:\n        .:\n        f:cnGroups:\n          .:\n          f:desiredGroups:\n          f:readyGroups:\n          f:syncedGroups:\n        f:conditions:\n        f:credentialRef:\n        f:Tn:\n          .:\n          f:availableStores:\n          f:conditions:\n        f:logService:\n          .:\n          f:availableStores:\n          f:conditions:\n          f:discovery:\n            .:\n            f:address:\n            f:port:\n        f:phase:\n    Manager:         manager\n    Operation:       Update\n    Subresource:     status\n    Time:            2023-05-07T13:02:12Z\n  Resource Version:  72671\n  UID:               be2355c0-0c69-4f0f-95bb-9310224200b6\nSpec:\n  Tn:\n    Config:  \n[dn]\n\n[dn.Ckp]\nflush-interval = \"60s\"\nglobal-interval = \"100000s\"\nincremental-interval = \"60s\"\nmin-count = 100\nscan-interval = \"5s\"\n\n[dn.Txn]\n\n[dn.Txn.Storage]\nbackend = \"TAE\"\nlog-backend = \"logservice\"\n\n[log]\nformat = \"json\"\nlevel = \"error\"\nmax-size = 512\n\n    Replicas:  1\n    Resources:\n    Service Args:\n      -debug-http=:6060\n    Shared Storage Cache:\n      Memory Cache Size:  0\n  Image Pull Policy:      Always\n  Image Repository:       matrixorigin/matrixone\n  Log Service:\n    Config:  \n[log]\nformat = \"json\"\nlevel = \"error\"\nmax-size = 512\n\n    Initial Config:\n      TN Shards:           1\n      Log Shard Replicas:  3\n      Log Shards:          1\n    Pvc Retention Policy:  Retain\n    Replicas:              3\n    Resources:\n    Service Args:\n      -debug-http=:6060\n    Shared Storage:\n      s3:\n        Endpoint:           http://minio.mostorage:9000\n        Path:               minio-mo\n        s3RetentionPolicy:  Retain\n        Secret Ref:\n          Name:             minio\n        Type:               minio\n    Store Failure Timeout:  10m0s\n    Volume:\n      Size:  1Gi\n  Tp:\n    Config:  \n[cn]\n\n[cn.Engine]\ntype = \"distributed-tae\"\n\n[log]\nformat = \"json\"\nlevel = \"debug\"\nmax-size = 512\n\n    Node Port:  31474\n    Replicas:   1\n    Resources:\n    Service Args:\n      -debug-http=:6060\n    Service Type:  NodePort\n    Shared Storage Cache:\n      Memory Cache Size:  0\n  Version:                nightly-144f3be4\nStatus:\n  Cn Groups:\n    Desired Groups:  1\n    Ready Groups:    1\n    Synced Groups:   1\n  Conditions:\n    Last Transition Time:  2023-05-07T13:02:14Z\n    Message:               the object is synced\n    Reason:                empty\n    Status:                True\n    Type:                  Synced\n    Last Transition Time:  2023-05-07T13:02:14Z\n    Message:               \n    Reason:                AllSetsReady\n    Status:                True\n    Type:                  Ready\n  Credential Ref:\n    Name:  mo-credential\n  Tn:\n    Available Stores:\n      Last Transition:  2023-05-07T13:01:48Z\n      Phase:            Up\n      Pod Name:         mo-tn-0\n    Conditions:\n      Last Transition Time:  2023-05-07T13:01:48Z\n      Message:               the object is synced\n      Reason:                empty\n      Status:                True\n      Type:                  Synced\n      Last Transition Time:  2023-05-07T13:01:48Z\n      Message:               \n      Reason:                empty\n      Status:                True\n      Type:                  Ready\n  Log Service:\n    Available Stores:\n      Last Transition:  2023-05-07T13:01:25Z\n      Phase:            Up\n      Pod Name:         mo-log-0\n      Last Transition:  2023-05-07T13:01:25Z\n      Phase:            Up\n      Pod Name:         mo-log-1\n      Last Transition:  2023-05-07T13:01:25Z\n      Phase:            Up\n      Pod Name:         mo-log-2\n    Conditions:\n      Last Transition Time:  2023-05-07T13:01:25Z\n      Message:               the object is synced\n      Reason:                empty\n      Status:                True\n      Type:                  Synced\n      Last Transition Time:  2023-05-07T13:01:25Z\n      Message:               \n      Reason:                empty\n      Status:                True\n      Type:                  Ready\n    Discovery:\n      Address:  mo-log-discovery.mo-hn.svc\n      Port:     32001\n  Phase:        Ready\nEvents:\n  Type    Reason            Age                From              Message\n  ----    ------            ----               ----              -------\n  Normal  ReconcileSuccess  29m (x2 over 13h)  matrixonecluster  object is synced\n
      "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#view-component-status","title":"View component status","text":"

      The current MatrixOne cluster includes the following components: TN, CN, and Log Service, which correspond to the custom resource types TNSet, CNSet, and LogSet, respectively, and these objects are generated by the MatrixOneCluster controller.

      To check whether each component is standard, take TN as an example; you can run the following command:

      SET_TYPE=\"tnset\"\nNS=\"mo-hn\"\nkubectl get ${SET_TYPE} -n ${NS}\n

      This will display status information for the TN component as follows:

      [root@master0 ~]# SET_TYPE=\"tnset\"\n[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME   IMAGE                                     REPLICAS   AGE\nmo     matrixorigin/matrixone:nightly-144f3be4   1          13h\n[root@master0 ~]# SET_TYPE=\"cnset\"\n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME    IMAGE                                     REPLICAS   AGE\nmo-tp   matrixorigin/matrixone:nightly-144f3be4   1          13h\n[root@master0 ~]# SET_TYPE=\"logset\"                 \n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME   IMAGE                                     REPLICAS   AGE\nmo     matrixorigin/matrixone:nightly-144f3be4   3          13h\n
      "},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#view-pod-status","title":"View Pod Status","text":"

      In addition, you can directly check the native k8s objects generated in the MO cluster to confirm the cluster's health, usually by querying the pod.

      NS=\"mo-hn\"\nkubectl get pod -n ${NS}\n

      This will display status information for the Pod.

      [root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get pod -n${NS}\nNAME                                 READY   STATUS    RESTARTS   AGE\nmatrixone-operator-f8496ff5c-fp6zm   1/1     Running   0          19h\nmo-tn-0                              1/1     Running   0          13h\nmo-log-0                             1/1     Running   0          13h\nmo-log-1                             1/1     Running   0          13h\nmo-log-2                             1/1     Running   0          13h\nmo-tp-cn-0                           1/1     Running   0          13h\n

      Typically, the Running state indicates that the Pod is functioning normally. But there are also some special cases where the Pod status may be Running, but the MatrixOne cluster is abnormal. For example, connecting to a MatrixOne cluster through a MySQL client is impossible. In this case, you can look further into the Pod's logs to check for unusual output.

      NS=\"mo-hn\"\nPOD_NAME=\"[the name of the pod returned above]\" # For example, mo-tp-cn-0\nkubectl logs ${POD_NAME} -n ${NS}\n

      If the Pod status is not Running, such as Pending, you can check the Pod events (Events) to confirm the cause of the exception. Taking the previous example, because the cluster resources cannot satisfy the request of mo-tp-cn-3, the Pod cannot be scheduled and is Pending. In this case, you can solve it by expanding node resources.

      kubectl describe pod ${POD_NAME} -n${NS}\n

      "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/","title":"Import data from local Minio to MatrixOne","text":"

      In a distributed MatrixOne cluster, in addition to importing data locally and from public cloud object storage to MatrixOne, data can be imported through the local Minio component. This method is also feasible to import data to MatrixOne if there is no public network access or the imported file is too large to exceed the local disk space.

      This article will guide you on importing CSV files using local Minio. And the environment introduced in this document will be based on MatrixOne Distributed Cluster Deployment; ensure the entire MatrixOne has been installed.

      "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#steps","title":"steps","text":""},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#import-data","title":"Import Data","text":"

      You can log in to the Minio GUI by visiting http://192.168.56.10:32001. For the account and password, refer the rootUser and rootPassword created during the installation and deployment of Minio in MatrixOne Distributed Cluster Deployment. After logging in, you need to create a dedicated bucket load-from-minio, and upload the corresponding CSV file into the bucket.

      The example we use here is a simple addresses.csv example containing only 6 rows of data.

      "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#get-minios-endpoint","title":"Get Minio's Endpoint","text":"

      The principle of loading data from local Minio to MatrixOne cluster is the same as Import the data from S3 Compatible object storage are precisely the same, and their grammatical structure is the same. However, the public cloud vendor will give the parameters in the public cloud method, while the parameters in the local Minio need to be set by yourself.

      LOAD DATA\n    | URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"role_arn\"='xxxx', \"external_id\"='yyy', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>', \"provider\"='<string>'}\n    INTO TABLE tbl_name\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY 'string']\n        [[OPTIONALLY] ENCLOSED BY 'char']\n        [ESCAPED BY 'char']\n    ]\n    [IGNORE number {LINES | ROWS}]\n    [PARALLEL {'TRUE' | 'FALSE'}]\n

      To load data from the local Minio, you first need to find the Minio endpoint. Before the actual operation, let's understand the architecture of the entire call link.

      "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#minio-access-architecture","title":"Minio Access Architecture","text":"

      Logically speaking, MatrixOne communicates with Minio through Minio's access port endpoint and obtains data from it, as shown in the following figure:

      Minio is managed in Kubernetes (K8s), and external services must be accessed through the Service (SVC) of K8s. The actual execution of tasks is done in K8s Pods. SVC can ensure that the same port is always maintained for external applications no matter how the Pod changes. The association between SVC and Pod needs to establish rules through the Endpoint (EP) in K8s. Therefore, MatrixOne is connected to the Minio service through SVC and the specific architecture is shown in the following figure:

      "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#actual-command","title":"Actual command","text":"

      When we installed Minio, we created a namespace named mostorage. We can find this endpoint through the following K8s commands.

      • kubectl get svc -n ${ns}: List all SVCs under this namespace.
      • kubectl get pod -n${ns}: List all Pods under this namespace.
      • kubectl get ep -n ${ns}: List all forwarding rule relationships under this namespace.

      Examples are as follows:

      root@VM-32-16-debian:~# ns=\"mostorage\"\nroot@VM-32-16-debian:~# kubectl get svc -n${ns}\nNAME             TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE\nminio            ClusterIP   10.96.1.65   <none>        80/TCP           127d\nminio1-console   NodePort    10.96.3.53   <none>        9090:30869/TCP   127d\nminio1-hl        ClusterIP   None         <none>        9000/TCP         127d\nroot@VM-32-16-debian:~# kubectl get pod -n${ns}\nkubectl get ep -n${ns}NAME            READY   STATUS    RESTARTS   AGE\nminio1-ss-0-0   1/1     Running   0          106d\nminio1-ss-0-1   1/1     Running   0          106d\nminio1-ss-0-2   1/1     Running   0          106d\nminio1-ss-0-3   1/1     Running   0          106d\nroot@VM-32-16-debian:~# kubectl get ep -n${ns}\nNAME             ENDPOINTS                                                                 AGE\nminio            100.92.250.195:9000,100.92.250.200:9000,100.92.250.201:9000 + 1 more...   127d\nminio1-console   100.92.250.195:9090,100.92.250.200:9090,100.92.250.201:9090 + 1 more...   127d\nminio1-hl        100.92.250.195:9000,100.92.250.200:9000,100.92.250.201:9000 + 1 more...   127d\n

      The access address of SVC is the terminal address that needs to be added to the Load statement. To construct the SVC address, you can use ${service_name}.{namespace}.svc.cluster.local (the last three digits can be omitted). The results of the following commands show that the SVC of minio1-hl uses 9000 as the external forwarding port, and the SVC of minio uses 80 as the external forwarding port. Therefore, the final endpoint of Minio connected to Mostorage is: http://minio1-hl.mostorage:9000 or http://minio.mostorage:80.

      "},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#build-and-execute-the-load-statement","title":"Build and execute the Load statement","text":"
      1. Build the corresponding table according to the data structure of addresses.csv:

        create table address (firstname varchar(50), lastname varchar(50), address varchar(500), city varchar(20), state varchar(10), postcode varchar(20));\n
      2. Referring to the syntax structure of Load S3, fill in the parameter information in the Load statement:

        • endpoint, access_key_id: the login account of minio
        • secret_access_key: the login password of minio)
        • bucket: the name of the bucket
        • filepath: the path to the imported file

        It should be noted that from the local Minio, a \"provider\"=\"minio\" needs to be added to the parameter string to indicate that the underlying storage source is the local Minio, and finally form the following SQL statement.

        MySQL [stock]> load data url s3option{\"endpoint\"='http://minio.mostorage:80',\"access_key_id\"='rootuser', \"secret_access_key\"='rootpass123',\"bucket\"='load-from-minio', \"filepath\"='/addresses.csv', \"compression\"='none', \"provider\"=\"minio\"} INTO TABLE address FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n' PARALLEL 'TRUE';\nQuery OK, 6 rows affected (2.302 sec)\n

      Note

      \"provider\"=\"minio\" is only valid in the local Minio environment. If you import data from the object storage of the public cloud, you don't need to add this parameter.

      "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/","title":"Managing CN Groups with Proxy","text":"

      Proxy is a new system component introduced in MatrixOne's 0.8 version. It can achieve account and load isolation, among other functionalities, through traffic proxying and forwarding. For the technical design of the Proxy, refer to Detailed Proxy Architecture.

      This document primarily explains using Proxy to establish different CN groups for independent resource management of accounts and loads.

      "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#system-architecture","title":"System Architecture","text":"

      As illustrated below, users first connect to the Proxy module. Based on the identity and label information in the user connection string, the Proxy component distributes the user's database connection to the corresponding CN group. Other CN groups will not receive this user connection nor participate in the computation process related to this connection.

      A CN group is a logical CN group composed of CN nodes with the same attributes and size. It is a unit in the MatrixOne cluster used to isolate different resource groups. Each CN group can contain from 1 to infinite CN nodes and can use a series of labels to define its attributes. For example, determining the Account label corresponding to an account and forwarding the connection to a CN group with corresponding labels can realize account resource and business load isolation. With the feature that CN nodes in a CN group can scale horizontally indefinitely, an independent expansion for accounts or specified loads can be achieved.

      To ensure the high availability of Proxy, at least 2 replicas should be set up in the cluster.

      When performing CN (Compute Node) downsizing, Proxy behaves as follows in the YAML file:

      • Session Migration with the Same Label: When the number of CN replicas decreases, sessions with the same label will be migrated to other downsized CN nodes. This ensures the continuity and availability of sessions associated with specific labels.

      • Session Migration with Different Labels: If a CN replica with a particular label is set to 0 or removed, based on label matching rules, sessions associated with that label will be migrated to idle labels in future sessions.

      • Label Cancellation without Matching Labels: If a label is cancelled and no matching label exists, related sessions will be closed because there are no target CNs to receive these sessions.

      Proxy manages session migration and closure during CN downsizing to ensure the isolation between workloads and tenants, as well as the continuity of business operations.

      "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#steps","title":"Steps","text":"

      The environment discussed in this document for managing CN groups using Proxy is based on the environment of MatrixOne Distributed Cluster Deployment.

      To help you understand resource isolation and allocation, you can refer to the table below, which illustrates the distribution of each hardware node in the environment of MatrixOne Distributed Cluster Deployment, as follows:

      Host Internal IP External IP Memory CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G Jump server master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#step-one-enable-proxy","title":"Step One: Enable Proxy","text":"

      To enable the Proxy component in the MatrixOne distributed cluster, you need to specify the required Proxy topology when creating the cluster, or after adding the Proxy topology to the existing cluster, execute kubectl apply to enable the Proxy component. The detailed steps are as follows:

      1. Modify the mo.yaml file of the MatrixOne cluster:

        metadata:\n  name: mo\n  namespace: mo-hn\nspec:\n+ proxy:\n+   replicas: 2 # For high availability, at least 2 replicas are required for the Proxy\n
      2. After the modifications, run the mo.yaml file using the command below:

        kubectl apply -f mo.yaml\n
      3. Run kubectl get pod -nmo-hn to check if the Proxy has started properly:

        root@HOST-10-206-134-16:~# kubectl get pod -nmo-hn\nNAME             READY   STATUS    RESTARTS   AGE\nmo-tn-0          1/1     Running   0          2m51s\nmo-log-0         1/1     Running   0          3m25s\nmo-log-1         1/1     Running   0          3m25s\nmo-log-2         1/1     Running   0          3m25s\nmo-proxy-69zjf   1/1     Running   0          2m51s\nmo-proxy-fpn2g   1/1     Running   0          2m51s\nmo-tp-cn-0       1/1     Running   0          2m25s\n
      4. The code example for a successful start is shown above. This completes the start of the minimized Proxy component. You can use kubectl get svc -nmo-hn to connect to the cluster via the Proxy's SVC address.

        root@HOST-10-206-134-16:~# kubectl get svc -nmo-hn\nNAME                TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE\nmo-tn-headless      ClusterIP   None          <none>        <none>           70m\nmo-log-discovery    ClusterIP   10.96.3.186   <none>        32001/TCP        71m\nmo-log-headless     ClusterIP   None          <none>        <none>           71m\nmo-proxy            NodePort    10.96.1.153   <none>        6001:31429/TCP   70m\nmo-tp-cn            ClusterIP   10.96.1.43    <none>        6001/TCP         70m\nmo-tp-cn-headless   ClusterIP   None          <none>        <none>           70m\nroot@HOST-10-206-134-16:~# mysql -h 10.96.1.153 -P6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 2064\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective owners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

      If multiple CNs exist in the entire cluster, Proxy will automatically implement connection-level load balancing and evenly distribute the user's connections to different CNs. You can query the system table system_metrics.server_connections to view the number of user connections on each CN.

      "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#step-two-set-up-cn-groups","title":"Step Two: Set Up CN Groups","text":"

      In the mo.yaml file of the MatrixOne cluster, you need to configure CN groups by setting the cnGroups field and configure the cnLabels field in each cnGroups to set the labels of all CNs in the CN group. The Proxy will route and forward according to the connection labels. For example, you have set up two CN groups named cn-set1 and cn-set2 in the following example. Each CN group can have an independent number of replicas, log levels, CN parameter configurations, and CN labels.

      The labels of CN groups adopt one-to-many groups of Key/value formats, in which there is a one-to-many relationship between each group of Key and value, i.e., each Key can have multiple values.

      The detailed steps are as follows:

      1. Refer to the configuration parameter example below to configure the labels of the CN group:

        metadata:\n  name: mo\n  namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+   replicas: 1\n+   cnLabels:\n+   - key: \"cn-set1\"\n+     values: [\"1\", \"high\"]\n+   - key: \"account\"\n+     values: [\"acc1\"]\n+\n+ - name: cn-set2\n+   replicas: 1\n+   cnLabels:\n+   - key: \"cn-set2\"\n+           values: [\"2\", \"medium\"]\n+   - key: \"account\"\n+     values: [\"acc2\"]  \n
      2. After the modifications, run the mo.yaml file using the command below:

        kubectl apply -f mo.yaml\n
      3. Run kubectl get pod -nmo-hn to check if the Proxy has adequately started:

      root@HOST-10-206-134-16:~# kubectl get pod -nmo-hn\nNAME              READY   STATUS    RESTARTS   AGE\nmo-cn-set1-cn-0   1/1     Running   0          6s\nmo-cn-set2-cn-0   1/1     Running   0          6s\nmo-tn-0           1/1     Running   0          97m\nmo-log-0          1/1     Running   0          97m\nmo-log-1          1/1     Running   0          97m\nmo-log-2          1/1     Running   0          97m\nmo-proxy-69zjf    1/1     Running   0          97m\nmo-proxy-fpn2g    1/1     Running   0          97m\n

      The code example for a successful start is shown above.

      The label setting of CN groups is very flexible, but it is most commonly used for account and load isolation.

      For how to achieve account isolation and load isolation, continue to the following sections.

      "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#implementing-account-isolation","title":"Implementing account Isolation","text":"

      MatrixOne 0.7 version supports About MatrixOne Privilege Management data isolation. If account load isolation is to be implemented, it must be done by configuring Proxy and CN groups.

      "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#ordinary-accounts","title":"Ordinary accounts","text":"

      In the label setting of CN groups, the account label is a reserved field used to match accounts.

      In this chapter, assuming that account load isolation needs to be implemented for acc1 and acc2, you can refer to the detailed steps below:

      Note

      Only users with system account permissions can configure load isolation for ordinary accounts.

      1. Log into the MatrixOne cluster using the system account. For the username and password, please look at your company's Database Administrator. After logging into the MatrixOne cluster, create two new accounts, acc1 and acc2:

        -- Create a new account acc1 with a password of 123456 (a simple password is set here, which is only used as an example)\nmysql> create account acc1 admin_name 'admin' identified by '123456';\n-- Create a new account acc2 with a password of 123456 (a simple password is set here, which is only used as an example)\nmysql> create account acc2 admin_name 'admin' identified by '123456';\n
      2. Modify the mo.yaml file of the MatrixOne cluster, and label the two CN groups with account:acc1 and account:acc2 respectively, corresponding to tenants named acc1 and acc2 respectively:

        metadata:\n  name: mo\n  namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+   replicas: 1\n+   cnLabels:\n+   - key: \"account\"\n+     values: [\"acc1\"]\n+\n+ - name: cn-set2\n+   replicas: 1\n+   cnLabels:\n+   - key: \"account\"\n+     values: [\"acc2\"]  \n
      3. Modify the mo.yaml file of the MatrixOne cluster, and label the two CN groups with account:acc1 and account:acc2 respectively, corresponding to the accounts named acc1 and acc2 respectively:

      -- acc1 account login MatrixOne\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc1:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 32309\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n-- acc1 checks which CN groups are used for login\nmysql> show backend servers;\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n| UUID                                 | Address                                               | Work State | Labels                       |\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n| 32333337-3966-3137-3032-613035306561 | mo-cn-set1-cn-0.mo-cn-set1-cn-headless.mo-hn.svc:6001 | Working    | account:acc1;cn-set1:1,high; |\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n1 row in set (0.00 sec)\n
      -- acc2 account login MatrixOne\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc2:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 32640\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n-- acc2 checks which CN groups are used for login\nmysql> show backend servers;\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n| UUID                                 | Address                                               | Work State | Labels                         |\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n| 33663265-3234-3365-3737-333030613535 | mo-cn-set2-cn-0.mo-cn-set2-cn-headless.mo-hn.svc:6001 | Working    | account:acc2;cn-set2:2,medium; |\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n1 row in set (0.00 sec)\n

      If an ordinary account does not have a corresponding CN group, then the account cannot log in successfully. For example, if you create a account acc3 that does not correspond to a CN group label and try to log in, you will get a no available CN server error.

      mysql> create account acc3 admin_name 'admin' identified by '123456';\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc3:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nERROR 1045 (28000): internal error: no available CN server\n
      "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#system-account","title":"System account","text":"

      For system accounts, MatrixOne will automatically select an appropriate CN group to connect in the following order:

      • Highest priority: Select the CN group configuring the account label as sys.
      • Second highest priority: Select the CN group configuring other labels but not the account label.
      • Medium priority: Select the CN group that has not configured labels.
      • Low priority: If none of the above CN groups exist, then choose randomly from the existing CN groups.

      Based on this principle, system accounts will prioritize the CN groups specifically reserved for themselves or not for other accounts. However, suppose the above conditions are not met. In that case, the system account might share a CN group with other accounts and thus cannot ensure load isolation between the system account and ordinary accounts.

      "},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#implementing-load-isolation","title":"Implementing Load Isolation","text":"

      The use case for the Proxy agent is load isolation. In many standard business environments, such as high-concurrency writes, report generation, backup, and significant data export, traditional database solutions often require the deployment of specific instances to achieve load isolation. This approach also results in an additional burden of data synchronization.

      MatrixOne uses a Proxy to implement resource group division, which can flexibly combine CN groups with user-specified load labels. In the event of load changes, MatrixOne can adjust the scale of the resource group through software configuration, thus better adapting to changes.

      Using the above example, you can set the load labels of two CNs to olap and oltp, respectively. Then, use SSB to simulate the OLTP load and TPCH to simulate the OLAP load.

      Note

      When performing performance testing, you must first scale out the entire cluster.

      metadata:\n  name: mo\n  namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+   replicas: 1\n+   cnLabels:\n+   - key: \"workload\"\n+     # The load label is set to olap\n+     values: [\"olap\"]\n+\n+ - name: cn-set2\n+   replicas: 1\n+   cnLabels:\n+   - key: \"workload\"\n+     # The load label is set to oltp\n+           values: [\"oltp\"]\n

      After configuring the load of the cluster, you can connect to the cluster for load testing:

      1. Connect via JDBC:

        Specify connection attributes in the JDBC connection string, and set the corresponding key and value. A colon separates the key and value :, and a comma separates multiple key-values ,. Examples are as follows:

        jdbc:mysql://localhost:6001/test_db1?serverTimezone=UTC&connectionAttributes=workload:olap,another_key:test_value\n
      2. Connect via MySQL client:

        Use the MySQL client to connect by extending the username field. Add ? after the username (username), and the subsequent writing method follows the connectionAttributes format in JDBC. The difference from the connectionAttributes format in JDBC is that the key and value are separated by =, and between multiple key-values, Use commas , to separate them; examples are as follows:

        mysql -h127.0.0.1 -uuser1?workload=olap,another_key=test_value -P6001 -pxxx\n
      "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/","title":"MatrixOne Distributed Cluster Upgrade","text":"

      This document will introduce how to Rolling upgrade or Reinstall upgrade MatrixOne clusters.

      The upgraded environment introduced in this document will be based on the environment of MatrixOne Distributed Cluster Deployment.

      "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#rolling-upgrade","title":"Rolling upgrade","text":"

      Rolling upgrade is an online upgrade method; the MatrixOne cluster completes the software upgrade while ensuring that some or all services are available.

      According to the introduction in MatrixOne Distributed Cluster Deployment, the overall installation of MatrixOne is based on Kubernetes and MatrixOne Operator. Therefore, the rolling upgrade process is to realize automatic version updates by dynamically modifying the MatrixOne image version number in MatrixOne Operator.

      "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#steps","title":"Steps","text":"
      1. Execute the following command on the terminal on the master0 node to enter the interface for dynamically modifying the yaml configuration file the operator uses.

        mo_ns=\"mo-hn\" #the namespace of matrixone cluster\nmo_cluster_name=\"mo\" # The cluster name of matrixone, generally mo, is specified according to the name in the YAML file of the matrixonecluster object during deployment or can be confirmed by kubectl get matrixonecluster -n${mo_ns}\n# mo-hn and mo have been set in the mo.yaml file of the installation and deployment\nkubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
      2. After entering edit mode, modify the value of spec.version; the parameters are as below:

        • ${TAG}: corresponds to the image tag of Matrixone on dockerhub, for example: nightly-f0d52530

        • ${REPO_URL}: public mirror repository for Matrixone, the default is matrixorigin/matrixone. If the target version does not exist in the public mirror warehouse of MatrixOne, you also need to modify the URL of the mirror warehouse to the existing warehouse:

      3. After completing the modification, press :wq to save. MatrixOne Operator will automatically pull the new version of the image and restart the component services, including Log Service, TN, and CN. You can also observe its running status through the following commands.

        watch -e \"kubectl get pod -n${mo_ns}\"\n
        NAME                                 READY   STATUS    RESTARTS      AGE\nmatrixone-operator-f8496ff5c-fp6zm   1/1     Running   0             24h\nmo-tn-0                              1/1     Running   1 (51s ago)   18h\nmo-log-0                             1/1     Running   0             18h\nmo-log-1                             1/1     Running   1 (5s ago)    18h\nmo-log-2                             1/1     Running   1 (53s ago)   18h\nmo-tp-cn-0                           1/1     Running   1 (53s ago)   18h\n

        If an error, crashbackoff, etc., occurs, you can further troubleshoot the problem by viewing the component log.

        #pod_name is the name of the pod, such as mo-tn-0, mo-tp-cn-0\npod_name=mo-tn-0\nkubectl logs ${pod_name} -nmo-hn > /tmp/tn.log\nvim /tmp/tn.log\n
      4. After the Restart of the components in the MatrixOne cluster is completed, you can use the MySQL Client to connect to the cluster. The upgrade is successful if the connection is successful and the user data is complete.

        # Connect to the MySQL server using the 'mysql' command line tool\n# Use 'kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}' ' to get the cluster IP address of the service in the Kubernetes cluster\n# The '-h' parameter specifies the hostname or IP address of the MySQL service\n# The '-P' parameter specifies the port number of the MySQL service, here is 6001\n# '-uroot' means log in with root user\n# '-p111' means the initial password is 111\nmysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nroot@master0 ~]# mysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 1005\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\nMySQL [(none)]> show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| mo_task            |\n| information_schema |\n| mysql              |\n| system_metrics     |\n| system             |\n| test               |\n| mo_catalog         |\n+--------------------+\n7 rows in set (0.01 sec)\n

        Info

        The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

      5. The rolling update may be suspended due to incorrect configuration (such as specifying a non-existing version when upgrading). At this point, you can re-modify the dynamic configuration of the operator, reset the version number, roll back the changes, and the failed Pods will be re-updated.

      6. You can check the version number of the current MatrixOne deployment with the following command:

        [root@master0 matrixone-operator]# kubectl get matrixoneclusters -n mo-hn -o yaml | grep version\n        {\"apiVersion\":\"core.matrixorigin.io/v1alpha1\",\"kind\":\"MatrixOneCluster\",\"metadata\":{\"annotations\":{},\"name\":\"mo\",\"namespace\":\"mo-hn\"},\"spec\":{\"tn\":{\"cacheVolume\":{\"size\":\"5Gi\",\"storageClassName\":\"local-path\"},\"config\":\"[dn.Txn.Storage]\\nbackend = \\\"TAE\\\"\\nlog-backend = \\\"logservice\\\"\\n[dn.Ckp]\\nflush-interval = \\\"60s\\\"\\nmin-count = 100\\nscan-interval = \\\"5s\\\"\\nincremental-interval = \\\"60s\\\"\\nglobal-interval = \\\"100000s\\\"\\n[log]\\nlevel = \\\"error\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"replicas\":1,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"1Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}}},\"imagePullPolicy\":\"IfNotPresent\",\"imageRepository\":\"matrixorigin/matrixone\",\"logService\":{\"config\":\"[log]\\nlevel = \\\"error\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"pvcRetentionPolicy\":\"Retain\",\"replicas\":3,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"1Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}},\"sharedStorage\":{\"s3\":{\"endpoint\":\"http://minio.mostorage:9000\",\"path\":\"minio-mo\",\"secretRef\":{\"name\":\"minio\"},\"type\":\"minio\"}},\"volume\":{\"size\":\"1Gi\"}},\"tp\":{\"cacheVolume\":{\"size\":\"5Gi\",\"storageClassName\":\"local-path\"},\"config\":\"[cn.Engine]\\ntype = \\\"distributed-tae\\\"\\n[log]\\nlevel = \\\"debug\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"nodePort\":31429,\"replicas\":1,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"2Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}},\"serviceType\":\"NodePort\"},\"version\":\"nightly-54b5e8c\"}}\n    version: nightly-54b5e8c\n
      "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#reinstall-and-upgrade","title":"Reinstall and upgrade","text":"

      Reinstalling and upgrading mean all MatrixOne clusters will be deleted and the data discarded and reinstalled.

      Applicable scene:

      • no need for old data
      • The versions before and after the upgrade are not compatible with each other due to special reasons

      Note

      Before the operation, please ensure the data has been backed up (see modump backup tool) and the business knows that the database has stopped.

      "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#steps_1","title":"Steps","text":""},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#1-delete-the-old-version-cluster","title":"1. Delete the old version cluster","text":"

      In master0, the old version cluster can be deleted in any of the following ways:

      # Method 1: Delete through the YAML file of the mo cluster during deployment, for example:\nkubectl delete -f /root/deploy/mo.yaml\n# Method 2: By deleting the matrixonecluster object, where mo is the name\nkubectl delete matrixonecluster.core.matrixorigin.io mo -nmo-hn\n

      Confirm that mo-related resources have been deleted by checking the pod status:

      kubectl get pod -nmo-hn\n

      In addition, if the PVC used by mo has not been deleted, use the following command to delete it manually:

      kubectl get pvc -nmo-hn\n# For example, the PVC used by the log service has not been deleted, delete it manually\nkubectl delete pvc mo-data-mo-log-0 -nmo-hn\nkubectl delete pvc mo-data-mo-log-1 -nmo-hn\nkubectl delete pvc mo-data-mo-log-2 -nmo-hn\n
      "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#2-empty-bucket-data","title":"2. Empty bucket data","text":"

      On the MinIO control page, delete the data in the bucket used by MinIO used by MO, including subdirectories such as mo-data, etc.

      Or operate through the MinIO client mc:

      mc rb --force minio/minio-mo/data/\nmc rb --force minio/minio-mo/etl\n

      In addition, if you do not want to delete old data, you can create a new MinIO bucket and specify a unique bucket name in the YAML file for deploying the MatrixOne cluster.

      "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#3-deploy-the-new-version-cluster","title":"3. Deploy the new version cluster","text":"

      Edit the yaml file that defines the MO cluster, refer to the Rolling Upgrade chapter, modify the .spec.version field to the latest version, and redeploy the MatrixOne cluster:

      vi mo.yaml\n# content omitted\n...\nkubectl apply -f mo.yaml\n
      "},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#4-check-if-the-upgrade-is-successful","title":"4. Check if the upgrade is successful","text":"

      Please check if MatrixOne has started successfully with the following command.

      As shown in the following code example, when the Log Service, TN, and CN are all running normally, the MatrixOne cluster starts successfully. Connecting through the MySQL Client can also check if the database functions correctly.

      [root@master0 ~]# kubectl get pods -n mo-hn      \nNAME                                  READY   STATUS    RESTARTS     AGE\nmatrixone-operator-6c9c49fbd7-lw2h2   1/1     Running   2 (8h ago)   9h\nmo-tn-0                               1/1     Running   0            2m13s\nmo-log-0                              1/1     Running   0            2m47s\nmo-log-1                              1/1     Running   0            2m47s\nmo-log-2                              1/1     Running   0            2m47s\nmo-tp-cn-0                            1/1     Running   0            111s\n
      "},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/","title":"Experience Environment Deployment Plan","text":"

      This document introduces the deployment plan for the MatrixOne experience environment, which can be used to experience the basic distributed capabilities of MatrixOne. You can simply experience the database's essential development, operation, and maintenance functions. Still, it is unsuitable for deploying production environments, performing performance stress tests, conducting high availability tests, etc.

      "},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#hardware-configuration","title":"Hardware Configuration","text":"

      The hardware configuration requirements for the deployment plan of the experience environment are as follows:

      Hardware Environment Requirements Physical/Virtual Machine Number of Devices 3 CPU Configuration 2 cores or more Memory Configuration 8GB or more Disk Configuration 200GB or more Network Card Configuration Not limited"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#software-configuration","title":"Software Configuration","text":"

      The software configuration requirements for the deployment plan of the experience environment include operating system and platform requirements and deployment software module requirements:

      "},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#operating-system-and-platform-requirements","title":"Operating System and Platform Requirements","text":"Operating System Supported CPU Architecture CentOS 7.3 or above 7.x version X86_64"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#deployment-software-module-requirements","title":"Deployment Software Module Requirements","text":"Software Module Number of Deployments Function Description Kubernetes 3 Provides container management for the entire cluster Minio 1 Provides storage services for the MatrixOne cluster MatrixOne 1 Core of the database

      The deployment guide for the MatrixOne distributed environment experience environment can refer to MatrixOne Distributed Cluster Deployment.

      "},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/","title":"Minimum Production Environment Deployment Plan","text":"

      The MatrixOne distributed cluster's minimum production configuration introduced in this article can be used for production environments. It can support tens of millions of data and hundreds of concurrent OLTP or OLAP businesses with tens of GB of data volume. At the same time, it provides a certain level of high availability guarantee. Even if one of the 3 nodes goes offline, it works normally.

      "},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#hardware-configuration","title":"Hardware Configuration","text":"

      The hardware configuration requirements for the minimum production environment deployment plan are as follows:

      Hardware Environment Requirements Both Physical and Virtual Machines are acceptable Number of Devices 3 CPU Configuration 8 cores or more Memory Configuration 32GB or more Disk Configuration Each node has 1 system disk of 100G and 4-7 data disks of 100G, all requiring PCIe NVME SSD 3.0 Network Card Configuration Dual 10GbE ports, 10GbE network card and switch"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#software-configuration","title":"Software Configuration","text":"

      The software configuration requirements for the minimum production environment deployment plan include operating system and platform requirements and deployment software module requirements:

      "},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#operating-system-and-platform-requirements","title":"Operating System and Platform Requirements","text":"Operating System Supported CPU Architecture Debian 11 or higher version (Kernel required 5.0 or higher) X86_64"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#deployment-software-module-requirements","title":"Deployment Software Module Requirements","text":"Node Name Resource Node Role Deployment Modules Disk Deployment node0 8c32g Control/Storage/Compute Deployment and O&M tool mo-ctl, Kubernetes master/node, Minio, MatrixOne Proxy, Logservice, TN, Load Balancer Kubernetes requires 1 data disk, Minio requires 1 to 4 data disks (physical partitioning recommended, logical partitioning is also possible), Logservice requires 1 data disk, TN requires 1 data disk node1 8c32g Control/Storage/Compute Deployment and O&M tool mo-ctl, Kubernetes master/node, Minio, MatrixOne Proxy, Logservice, CN, Load Balancer Kubernetes requires 1 data disk, Minio requires 1 to 4 data disks (physical partitioning recommended, logical partitioning is also possible), Logservice requires 1 data disk, CN requires 1 data disk node2 8c32g Control/Storage/Compute Deployment and O&M tool mo-ctl, Kubernetes master/node, Minio, MatrixOne Proxy, Logservice, CN, Load Balancer Kubernetes requires 1 data disk, Minio requires 1 to 4 data disks (physical partitioning recommended, logical partitioning is also possible), Logservice requires 1 data disk, CN requires 1 data disk"},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/","title":"Recommended Production Environment Deployment Plan","text":"

      The recommended configuration of the MatrixOne distributed cluster described in this document is suitable for production environments and possesses robust performance and reliability. This configuration can support billions of data with thousands of concurrent OLTP operations or handle OLAP operations with tens of TB data volume.

      This configuration provides a high degree of availability guarantee. Whether it is Kubernetes, Minio, or MatrixOne, the system can operate normally when a node goes offline. This means the system has strong fault tolerance and can maintain business continuity in node failure.

      Below are the details for the recommended production environment deployment plan:

      "},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/#software-and-hardware-configuration-requirements","title":"Software and Hardware Configuration Requirements","text":"Module Kubernetes master Minio LogService TN (mixed proxy and load balancing) CN (mixed proxy and load balancing) Number of machines (both physical machines and virtual machines) 3 machines 4 machines 3 machines 1 machine y machines Node Role Kubernetes Management Storage Service MatrixOne Work Node MatrixOne Work Node MatrixOne Work Node CPU configuration 4 cores or above 4 cores or above 4 cores or above 16 cores or above 16 cores or above Memory configuration 8GB or more 8GB or more 8GB or more 64GB or more 32GB or more Network Card Dual 10 Gigabit Ethernet ports, 10 Gigabit Ethernet Ditto Ditto Ditto Ditto System disk configuration Each node PCIe NVME SSD 3.0 \u00d7 1 block 100GB, it is recommended to do Raid 1 Same as above Same as above Same as above Same as above Kubernetes disk configuration PCIe NVME SSD 3.0 \u00d7 1 piece of 100GB per node, Raid 1 is recommended Same as above Same as above Same as above Same as above Disk Configuration N/A PCIe NVME SSD 3.0 \u00d7 4 x a G/block per node, no requirement for raid, physical partitioning is recommended, logical partitioning is recommended. Each node NVME SSD 3.0/4.0 (read rate above 1G/s) \u00d7 1 block \u00d7 b G/block. NVME SSD 3.0/4.0 \u00d7 2 blocks \u00d7 c G/block NVME SSD 3.0/4.0 \u00d7 2 blocks \u00d7 d G/block per node. Remarks a is related to the volume of business data, a = volume of business data \u00d7 2/16. b is related to the amount of business data; the closer, the better. c is related to the amount of business data; the closer, the better. One of them is reserved for TN/CN failure recovery. d is related to the amount of business data; the closer, the better. One of them is reserved for TN/CN failure recovery. y is related to the business load."},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/#other-configuration","title":"Other configuration","text":"Operating System Supported CPU Architectures Debian 11 or above (Kernel 5.0 or above) X86_64

      Since each privatized production environment's deployment scenarios are different, please contact MatrixOne's customer support team for specific deployment solutions and deployment details.

      "},{"location":"MatrixOne/Deploy/deployment-topology/topology-overview/","title":"Cluster Topology Planning Overview","text":"

      MatrixOne database cluster is an architecture for distributed deployment of database systems on multiple physical or virtual servers, aiming to provide high availability and scalability. By distributing the database to multiple servers, the cluster can realize data redundancy backup, load balancing, and fault recovery, thereby providing higher performance and reliability.

      The database cluster topology can choose a suitable architecture for business and performance requirements. Understanding the advantages and disadvantages of different topologies and applicable scenarios will help you design a stable and efficient database cluster architecture.

      "},{"location":"MatrixOne/Deploy/deployment-topology/topology-overview/#topology-deployment-document","title":"Topology deployment document","text":"

      We recommend deployment documents for three environments, refer to:

      • Experience Environment Deployment Plan
      • Minimum Production Environment Deployment Plan
      • Recommended Production Environment Deployment Plan
      "},{"location":"MatrixOne/Develop/develop-overview/","title":"Overview","text":"

      This article and subsequent sections mainly aim to introduce how to perform application development using MatrixOne. We will show how to connect to MatrixOne, create databases and tables, and build applications based on standard programming languages such as Java, Python, and Golang.

      "},{"location":"MatrixOne/Develop/develop-overview/#interaction-between-matrixone-and-applications","title":"Interaction between MatrixOne and Applications","text":"

      MatrixOne is generally highly compatible with MySQL 8.0 regarding communication protocol, SQL syntax, connection tools, or development modes. If this manual does not explicitly explain specific usage, you can refer to the MySQL 8.0 manual. Most application frameworks or programming languages can use MySQL's client library.

      For significant differences between MatrixOne and MySQL, see MySQL Compatibility section.

      "},{"location":"MatrixOne/Develop/develop-overview/#matrixone-transaction-mechanism","title":"MatrixOne Transaction Mechanism","text":"

      MatrixOne supports both Optimistic Transaction and Pessimistic Transaction. In the current version of MatrixOne, the default is the Pessimistic Transaction mode. You can switch to Optimistic Transaction mode by modifying the startup configuration file.

      You can start a transaction with BEGIN, commit the transaction with COMMIT, or roll back the transaction with ROLLBACK. MatrixOne ensures the atomicity of all statements from the beginning of BEGIN to the end of COMMIT or ROLLBACK. All statements during this period are either entirely successful or entirely failed, thereby ensuring the data consistency required in application development.

      If you choose to use optimistic transactions, please add error handling and retry mechanisms in the application, as MatrixOne does not guarantee the success of each transaction. If you use pessimistic transactions, you don't need to consider this. Optimistic transactions will have superior concurrent performance compared to pessimistic transactions.

      "},{"location":"MatrixOne/Develop/develop-overview/#reference","title":"Reference","text":"
      • Connect to MatrixOne
      • Schema Design
      • Import Data
      • Read Data
      • Transactions
      • Application Developing Tutorials
      "},{"location":"MatrixOne/Develop/Ecological-Tools/dolphinScheduler/","title":"Connecting MatrixOne with DolphinScheduler","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/dolphinScheduler/#overview","title":"Overview","text":"

      Apache DolphinScheduler is a distributed, highly scalable open-source system for visual DAG (Directed Acyclic Graph) workflow task scheduling. It provides a solution for visually orchestrating tasks, workflows, and the entire data processing lifecycle.

      The main goal of Apache DolphinScheduler is to address complex dependencies in large-scale data tasks. It assembles tasks streamingly using DAGs, allowing real-time monitoring of task execution status and supporting operations such as task retries, specifying node recovery for failures, and pausing, resuming, and terminating tasks.

      MatrixOne supports integration with DolphinScheduler, a visual DAG workflow task scheduling system. This document will guide you on connecting MatrixOne to DolphinScheduler and creating task workflows.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/dolphinScheduler/#before-you-start","title":"Before you start","text":"
      • Completed MatrixOne installation and setup.

      • Installed DolphinScheduler installation.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/dolphinScheduler/#operating-steps","title":"Operating Steps","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/dolphinScheduler/#step-1-configure-the-mysql-driver","title":"Step 1: Configure the MySQL Driver","text":"
      1. Download the MySQL driver and copy it to the libs directory:

        After installation, you need to manually download the mysql-connector-java driver (version 8.0.16). Then, copy it to four directories in the DolphinScheduler installation directory: api-server/libs, alert-server/libs, master-server/libs, and worker-server/libs.

        Note

        It is recommended to use mysql-connector-java-8.0.16.jar as the MySQL driver package.

      2. Restart DolphinScheduler:

        After copying the driver package, you need to restart the DolphinScheduler service. First, go to the DolphinScheduler installation directory and then execute the following command to restart the DolphinScheduler service:

        # Stop the Standalone Server service\nbash ./bin/dolphinscheduler-daemon.sh stop standalone-server\n# Start the Standalone Server service\nbash ./bin/dolphinscheduler-daemon.sh start standalone-server\n
      3. Log in to DolphinScheduler:

        Use the default username admin and password dolphinscheduler123. Access the DolphinScheduler web user interface by visiting http://ip:12345/dolphinscheduler/ui, as shown below:

      4. Create a Data Source:

        Click on Data Source Center > Create Data Source and enter the MatrixOne data connection information. Afterward, click on Test Connection; if the connection is successful, click OK to save it:

      "},{"location":"MatrixOne/Develop/Ecological-Tools/dolphinScheduler/#step-2-create-a-project-workflow","title":"Step 2: Create a Project Workflow","text":"
      1. Create a Tenant:

        In the Security Center, click on Create Tenant and enter the tenant name, as shown below:

        Note

        In a production environment, it is not recommended to use root as the tenant.

      2. Create a Project:

        In Project Management, click on Create Project and enter the project name, as shown below:

      3. Create a Workflow and Add Nodes:

        Click on the Project Name created in the previous step and then click on Create Workflow. Drag the SQL node from the left to the canvas on the right. Fill in the Node Name, Data Source Information, SQL Type, and SQL Statement, then click OK. As shown below:

        The node created in this step is for creating a table, and the SQL statement is used to create a table.

        Next, create Insert Data and Query Data nodes in a similar way. The dependency relationship between these three nodes is shown below, and you can manually connect them:

        The SQL statements for these three nodes are as follows:

        #create_table\n\nCREATE TABLE IF NOT EXISTS test_table (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL)\n\n#insert_data\n\nINSERT INTO test_table (name) VALUES ('John Doe')\n\n#select_data\n\nSELECT * FROM test_table\n

        Connect these three nodes based on their dependency relationship, then click Save. Enter the Workflow Name, select the previously created Tenant, choose Parallel as the execution policy, and click OK.

        Once the workflow is created, you can see it in the Workflow Relations page with the status \"Workflow Offline\":

        Similarly, you can also see the defined workflow in the Workflow Definitions page with the status \"Offline\":

      4. Publish and Run the Workflow:

        A workflow must be published before it can be run. Click the Publish button to publish the workflow created earlier:

        After publishing, the workflow status will appear as follows:

        Next, click the Run button, set the configuration parameters before starting, and then click OK:

        Finally, return to the Project Overview to check whether the workflow and the three tasks below it have run successfully, as shown below:

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/","title":"Visualizing MatrixOne Data with FineBI","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/#overview","title":"Overview","text":"

      FineBI is a next-generation big data analytics tool that empowers business professionals to gain deep insights and leverage their data. In FineBI, users can easily create diverse visualizations, analyze data freely, and explore their datasets. FineBI boasts various data connectivity features and can be used to build complex reports constructing data-driven decision analysis systems. It finds wide application in corporate management, production control, financial intelligence, and sales operations.

      MatrixOne supports integration with the data visualization tool FineBI. This article will guide you on connecting to the standalone version of MatrixOne using FineBI and creating various visual data reports, assembling them into dashboards for data analysis and exploration.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/#before-you-start","title":"Before you start","text":"
      • Completed the installation and startup of MatrixOne.

      • Installed FineBI and performed FineBI initial setup.

      Note

      The FineBI version used in the operations shown in this document is FineBI Linux 6.0. You can choose to install the Linux_unix_FineBI6_0-CN.sh package.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/#connecting-to-matrixone-service-via-finebi","title":"Connecting to MatrixOne Service via FineBI","text":"
      1. After logging into FineBI, select Management System > Data Connection > Data Connection Management > New Data Connection as shown below, then choose MySQL:

      2. Fill in the MatrixOne connection configuration, including the database name, host, port, username, and password. Other parameters can be left at their default settings. You can click the Test Connection button to verify if the connection is functional and then click Save :

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/#creating-visual-reports-using-matrixone-data","title":"Creating Visual Reports Using MatrixOne Data","text":"
      1. Create Demo Data:

        First, log in to the MatrixOne database and execute the following SQL statements to create the necessary data tables and views for the demo:

        create database orders;\nuse orders;\nCREATE TABLE `category` (`product_category_name` VARCHAR(255) DEFAULT NULL,\n`product_category_name_english` VARCHAR(255) DEFAULT NULL );\nCREATE TABLE `item` (`order_id` VARCHAR(255) NOT NULL, `order_item_id` INT DEFAULT null,\n`product_id` VARCHAR(255) DEFAULT null,\n`seller_id` VARCHAR(255) DEFAULT null, `shipping_limit_date` DATETIME DEFAULT null,\n`price` DECIMAL(10,2) DEFAULT null,\n`freight_value` DECIMAL(10,2) DEFAULT null\n);\nCREATE TABLE `review` (\n`review_id` VARCHAR(255) NOT NULL,\n`order_id` VARCHAR(255) DEFAULT null,\n`review_score` TINYINT DEFAULT null,\n`review_comment_title` VARCHAR(255) DEFAULT null,\n`review_comment_message` TEXT DEFAULT null,\n`review_creation_date` DATETIME DEFAULT null,\n`review_answer_timestamp` DATETIME DEFAULT null,\nPRIMARY KEY (`review_id`)\n);\nCREATE TABLE `order_time` (\n`order_id` VARCHAR(255) NOT NULL,\n`customer_id` VARCHAR(255) DEFAULT null,\n`y` INT DEFAULT null,\n`q` INT DEFAULT null,\n`m` INT DEFAULT null,\n`d` DATE DEFAULT null,\n`h` INT DEFAULT null,\n`order_purchase_timestamp` DATETIME DEFAULT null\n);\nCREATE TABLE `orders` (\n`order_id` VARCHAR(255) NOT NULL,\n`customer_id` VARCHAR(255) DEFAULT null,\n`order_status` VARCHAR(255) DEFAULT null,\n`order_purchase_timestamp` DATETIME DEFAULT null,\n`order_approved_at` DATETIME DEFAULT null,\n`order_delivered_carrier_date` DATETIME DEFAULT null,\n`order_delivered_customer_date` DATETIME DEFAULT null,\n`order_estimated_delivery_date` DATETIME DEFAULT null,\nPRIMARY KEY (`order_id`)\n);\nCREATE TABLE `product` (\n`product_id` VARCHAR(255) NOT NULL,\n`product_category_name` VARCHAR(255) DEFAULT null,\n`product_name_lenght` INT DEFAULT null,\n`product_description_lenght` INT DEFAULT null,\n`product_photos_qty` INT DEFAULT null,\n`product_weight_g` INT DEFAULT null,\n`product_length_cm` INT DEFAULT null,\n`product_height_cm` INT DEFAULT null,\n`product_width_cm` INT DEFAULT null,\nPRIMARY KEY (`product_id`)\n);\nCREATE TABLE `rfm` (\n`customer_id` VARCHAR(255) DEFAULT null,\n`user_type` VARCHAR(255) DEFAULT null,\n`shijian` DATE DEFAULT null\n);\n\nCREATE view total_order_value as select  t.order_id,product_id,seller_id,(price*total)+(freight_value*total) as order_value  from (select order_id,count(*) as total  from item group by order_id) t join item on t.order_id=item.order_id;\n\nCREATE view order_detail as select a.order_id,product_id,seller_id, customer_id,round(order_value,2) as order_value, y,q,m,d,h,order_purchase_timestamp from total_order_value a inner join order_time b on a.order_id=b.order_id;\n

        Next, use the following SQL import statements to import the prepared demo data into the respective tables of the MatrixOne database.

        Note

        Please note that the path /root/data/table_name.csv is the path to the data files for each table. You can generate your data following a similar process.

        use orders;\nload data local infile '/root/data/category.csv' into table category FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/review.csv' into table review FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/product.csv' into table product FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/item.csv' into table item FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/order_time.csv' into table order_time FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/orders.csv' into table orders FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/rfm.csv' into table rfm FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
      2. Add Data Sets:

        In FineBI, click Public Data, then click New Folder to create and select a folder. After that, click New Data Set, choose SQL Data Set, and add the SQL query to the selected folder. Enter the dataset name and input the SQL query as shown below:

        select d,\ncount(order_id) as order_num,\ncount(DISTINCT customer_id)\nfrom orders.order_detail\ngroup by d\norder by d\n

        You can click the Preview button to view the results of the SQL query and then click OK to save it:

        Below are examples of all the query SQL used in this demo:

        -- Daily active users and order count\nselect d,\ncount(order_id) as order_num,\ncount(DISTINCT customer_id)\nfrom orders.order_detail\ngroup by d\norder by d\n\n-- Monthly active users and order count\nselect count(DISTINCT customer_id),\ncount(order_id),\nconcat(y, '-', m)\nfrom orders.order_detail\ngroup by y,m\norder by y,m\n\n-- Active users and order count in different periods\nselect h,\ncount(DISTINCT customer_id),\ncount(order_id) order_num\nfrom orders.order_detail\ngroup by h\norder by h\n\n-- User count by type\nSELECT count(*),\nuser_type\nfrom orders.rfm\nGROUP BY user_type\n\n-- Monthly GMV\nselect y,m,\nsum(order_value),\nconcat(y, \"-\", m) month\nfrom orders.order_detail\ngroup by y,m\norder by y,m\n\n-- Quarterly GMV\nselect y,q,\nsum(order_value) gmv,\nconcat(y, \"\u5b63\u5ea6\", q) as quator\nfrom orders.order_detail\ngroup by y,q\norder by concat(y, \"\u5b63\u5ea6\", q) asc\n\n-- Quarterly ARPU\nselect y,q,\nround((sum(order_value)/count(DISTINCT customer_id)),2) arpu,\nconcat(y, \"\u5b63\u5ea6\", q) as quator\nfrom orders.order_detail\ngroup by y,q\norder by y,q\n\n-- Monthly ARPU\nselect y,m,\nround((sum(order_value)/count(DISTINCT customer_id)),2) arpu,\nconcat(y, \"-\", m) as month\nfrom orders.order_detail\ngroup by y,m\norder by y,m\n\n-- Important retained users' popularity index\nSELECT e.product_category_name_english good_type,\nSUM(a.order_value) ordder_total_value,\nROUND(AVG(c.review_score), 2) good_review_score,\n(0.7*SUM(a.order_value)+0.3*10000*ROUND(AVG(c.review_score), 7))\ntop_rank_rate\nFROM orders.order_detail a\nINNER JOIN\n(SELECT customer_id\nfrom orders.rfm\nWHERE user_type='\u91cd\u8981\u633d\u7559\u7528\u6237' ) as b ON a.customer_id=b.customer_id\nLEFT JOIN orders.review c ON a.order_id=c.order_id\nLEFT JOIN orders.product d ON a.product_id=d.product_id\nLEFT JOIN orders.category e ON d.product_category_name=e.product_category_name\nwhere e.product_category_name_english is not NULL\nGROUP BY e.product_category_name_english limit 50\n\n-- General retained users' popularity index\nSELECT e.product_category_name_english good_type,\nSUM(a.order_value) ordder_total_value,\nROUND(AVG(c.review_score), 2) good_review_score,\n(0.7*SUM(a.order_value)+0.3*10000*ROUND(AVG(c.review_score), 7))\ntop_rank_rate\nFROM orders.order_detail a\nINNER JOIN\n(SELECT customer_id from orders.rfm\nWHERE user_type='\u4e00\u822c\u633d\u7559\u7528\u6237' ) as b ON a.customer_id=b.customer_id\nLEFT JOIN orders.review c ON a.order_id=c.order_id\nLEFT JOIN orders.product d ON a.product_id=d.product_id\nLEFT JOIN orders.category e ON d.product_category_name=e.product_category_name\nwhere e.product_category_name_english is not NULL\nGROUP BY e.product_category_name_english limit 50\n
      3. Update Data:

        After saving the dataset, you need to click the Update Data button and wait for the data update to complete before proceeding with the analysis:

      4. Create Analytic Themes:

        The analytic theme in this example is used to visually present data for general retained users, important retained users, monthly ARPU, quarterly ARPU, active users in different periods, daily active users, monthly active users, and order counts. It assists in decision-making and improving business operations. Here are the specific steps to create an analytic theme:

        • Click My Analysis, then click New Folder to create and select a folder.
        • Click New Analytic Theme, select the dataset created in the previous step, and then click OK.

        Note: You can use the Batch Selection feature to select multiple datasets for theme analysis.

        Click the Add Component button, choose the chart type, drag the fields from the left to the right as needed, double-click to modify the field visualization name, and change the component name below to describe the content of the report analyzed by the component:

      5. Assemble Dashboards:

        Click Add Dashboard to add the components you just created to the dashboard. You can freely drag and resize the components and change the component names below to describe the report's content analyzed by the component.

      6. Publish Dashboards:

        After assembling the dashboard, click Publish, set the publication name, publication node, and display platform. Then click Confirm, and your dashboard will be successfully published.

        Now, see the newly published dashboard under Navigation and see how it looks.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/","title":"Visual Monitoring of MatrixOne with Superset","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#overview","title":"Overview","text":"

      Superset is an open-source, modern, and lightweight BI analysis tool that can connect to multiple data sources, provide rich visualizations, and support custom dashboards, making it easy for users to explore and present data.

      MatrixOne version 1.0 now supports integration with the data visualization tool Superset. This guide will walk you through the quick deployment of MatrixOne and Superset environments. Combining MatrixOne with Superset's visualization capabilities allows you to create a simple monitoring dashboard to track the 'system_metric' data within the MatrixOne database.

      If you wish to extend the functionality further, you can explore other configuration options to monitor various aspects of the entire MatrixOne database.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#before-you-start","title":"Before you start","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#recommended-hardware-requirements","title":"Recommended Hardware Requirements","text":"

      This practice does not require high hardware specifications. A small virtual machine with 2 cores and 4GB of RAM is sufficient for experiencing the functionality of this process.

      • Recommended hardware resources: 8 cores and 32GB of RAM for a virtual machine.
      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#recommended-software-environment","title":"Recommended Software Environment","text":"

      Before proceeding with this practice, you need to install and configure the following software environment:

      • Docker, with a version of 23.0.1 or higher.
      • MatrixOne
      • Superset, recommended version 2.1.0.

      You can follow the steps in the following sections to install and configure them step by step.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#installing-docker","title":"Installing Docker","text":"

      All software environments in this practice are based on Docker installation. You can refer to the official Docker documentation for installing and starting Docker.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#installing-matrixone","title":"Installing MatrixOne","text":"

      You can install and deploy MatrixOne based on your operating system environment by following these links:

      • Deploying MatrixOne using Docker in macOS environment: Installation Guide
      • Deploying MatrixOne using Docker in Linux environment: Installation Guide
      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#installing-superset","title":"Installing Superset","text":"

      Here are the steps for deploying a single-node Superset using Docker:

      1. After installing and starting Docker, use the following command to pull the Superset image from Docker Hub:

        docker pull amancevice/superset\n
      2. Start the Superset image with the following command:

        docker run -e \"SUPERSET_SECRET_KEY=your_secret_key_here\" --name superset -u 0 -d -p 8088:8088 amancevice/superset\n

        Note

        You can generate a secure secret key using openssl rand -base64 42. Alternatively, you can set it using the SUPERSET_SECRET_KEY environment variable.

      3. Initialize the Superset database with the following command:

        docker exec -it superset superset db upgrade\n
      4. Create a Superset admin user by running the following command and providing the requested registration information:

        docker exec -it superset superset fab create-admin\n
      5. Create default roles and permissions using the following command:

        docker exec -it superset superset init\n
      6. Start the Superset service with threads, auto-reloading, and debugging using the following command:

        docker exec -it superset superset run --with-threads --reload --debugger\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#connecting-matrixone-with-superset","title":"Connecting MatrixOne with Superset","text":"
      1. Access the Superset login page, typically at http://ip:8080. Then, enter your username and password to log in to Superset.

        Note: The port for Superset may be either 8080 or 8088, depending on your configuration. The username and password are the ones you set during the Superset deployment.

        After logging in, you will see the main interface of Superset.

      2. Create a database connection:

        In Superset, you first need to create a database connection to MatrixOne. Click on Settings in the top right corner and select Database Connections.

        Click the + DATABASE button on the Database Connections page and choose MySQL as the database type.

        Fill in the connection information for the MatrixOne database, including the host, port, username, and password.

        After filling in the details, click the CONNECT button and then click FINISH.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#creating-visual-monitoring-dashboards","title":"Creating Visual Monitoring Dashboards","text":"

      Now, you can use the MatrixOne database to create a monitoring dashboard.

      1. Click on SQL > SQL Lab on the page, select the MatrixOne database connection you created earlier, and write SQL queries to select the tables you want to monitor.

        You can write multiple queries to monitor different metrics. Here are example SQL statements for some queries:

        • CPU Usage:
        SELECT metric_name, collecttime, value\nFROM metric\nWHERE metric_name = 'sys_cpu_combined_percent' OR metric_name = 'sys_cpu_seconds_total'\nORDER BY collecttime DESC;\n
        • Storage Usage:
        SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'server_storage_usage'\nORDER BY collecttime DESC;\n
        • Number of Connections:
        SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'server_connections'\nORDER BY collecttime DESC;\n
        • Disk Read and Write:
        SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sys_disk_read_bytes' OR metric_name = 'sys_disk_write_bytes'\nORDER BY collecttime DESC;\n
        • Network Receive and Send:
        SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sys_net_sent_bytes' OR metric_name = 'sys_net_recv_bytes'\nORDER BY collecttime DESC;\n
        • Memory Usage:
        SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sys_memory_available' OR metric_name = 'sys_memory_used'\nORDER BY collecttime DESC;\n
      2. Transaction Errors:

        SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sql_transaction_errors' OR metric_name = 'sql_transaction_total'\nORDER BY collecttime DESC;\n
      3. SQL Errors:

        SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sql_statement_errors' OR metric_name = 'sql_statement_total'\nORDER BY collecttime DESC;\n
      4. Click SAVE > Save dataset > SAVE & EXPLORE to save each of the queries above and use them as data sources for subsequent charts.

      5. Edit the charts:

        Here, we'll use one of the queries as an example to demonstrate how to edit a visual chart. First, select the 'disk_read_write' query as the data source for the chart. In the SQL Lab, click CREATE CHART below the corresponding query, or if you've saved the query in the previous step, the page will redirect to the Chart editing page:

      6. In the chart editing page, choose chart type, time field, metric columns from the query, grouping columns, and other options. Once configured, select RUN:

      7. Click UPDATE CHART > SAVE to save the edited chart.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#organizing-dashboards","title":"Organizing Dashboards","text":"
      1. After creating multiple charts, you can assemble them in Superset to create a monitoring dashboard:

        Click on Dashboards, then click + DASHBOARD to create a new dashboard or edit an existing one.

      2. In the dashboard editing page, you can drag the charts you've created from the CHARTS list on the right onto the dashboard for assembly. You can also freely adjust the position of charts, add titles, and more.

      You have successfully connected the MatrixOne database with Superset and created a simple monitoring dashboard to visualize key metrics of the MatrixOne database.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/","title":"Visualizing MatrixOne Reports with Yonghong BI","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#overview","title":"Overview","text":"

      Yonghong BI is a comprehensive big data platform that integrates self-service data preparation, exploratory self-service analysis, in-depth analysis, enterprise-level management, and high-performance computing capabilities, providing an all-in-one big data solution. Yonghong BI aims to provide flexible and user-friendly end-to-end big data analysis tools for enterprises of all sizes, enabling users to easily uncover the value of big data and gain profound insights.

      MatrixOne supports connectivity to the intelligent data analysis tool, Yonghong BI. This article will guide you on connecting to the standalone version of MatrixOne through Yonghong BI and creating various visual data reports.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#before-you-start","title":"Before you start","text":"
      • MatrixOne installation and startup are completed. Install and Start MatrixOne.
      • Yonghong BI is installed. Yonghong BI is a free intelligent data analysis tool based on native installation, eliminating the need for complex deployment steps.
      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#connecting-matrixone-services-with-yonghong-bi","title":"Connecting MatrixOne Services with Yonghong BI","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#adding-a-data-source","title":"Adding a Data Source","text":"

      Open Yonghong BI, select Add Data Source > + (New Data Source) on the left, and choose MySQL in the pop-up database options.

      After filling in the connection information related to the MatrixOne database, you can select the Test Connection button in the upper right corner to ensure a successful connection.

      Once the connection is successful, click Save to save the data source information we just filled in.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#creating-a-dataset","title":"Creating a Dataset","text":"

      In Yonghong BI, select the Create Dataset menu on the left, then choose the data source you added just now. You will see tables and views from the MatrixOne database. To meet your business needs, add Custom SQL, then click Refresh Data. The query results will be displayed on the right. After confirming that the query results meet expectations, click Save to save the dataset.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#creating-reports","title":"Creating Reports","text":"

      First, in Yonghong BI, select the Create Report menu on the left, then choose the appropriate Chart Component from the right and drag it to the left.

      Select the dataset you just created, set the time dimension as the X-axis, and set the daily order count and active user count as the Y-axis. You can drag the measurement and dimension fields to their respective positions as needed. After editing, click Save to save the report you created.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#viewing-reports","title":"Viewing Reports","text":"

      Finally, in Yonghong BI, select View Report, then click on the report name we created in the tree menu on the left. You will be able to view the report we created above.

      You have successfully connected to the MatrixOne database using Yonghong BI and created a simple report for visualizing MatrixOne data.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/","title":"Writing Data to MatrixOne Using DataX","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#overview","title":"Overview","text":"

      This article explains using the DataX tool to write data to offline MatrixOne databases.

      DataX is an open-source heterogeneous data source offline synchronization tool developed by Alibaba. It provides stable and efficient data synchronization functions to achieve efficient data synchronization between various heterogeneous data sources.

      DataX divides the synchronization of different data sources into two main components: Reader (read data source) and Writer (write to the target data source). The DataX framework theoretically supports data synchronization work for any data source type.

      MatrixOne is highly compatible with MySQL 8.0. However, since the MySQL Writer plugin with DataX is adapted to the MySQL 5.1 JDBC driver, the community has separately modified the MatrixOneWriter plugin based on the MySQL 8.0 driver to improve compatibility. The MatrixOneWriter plugin implements the functionality of writing data to the target table in the MatrixOne database. In the underlying implementation, MatrixOneWriter connects to the remote MatrixOne database via JDBC and executes the corresponding insert into ... SQL statements to write data to MatrixOne. It also supports batch commits for performance optimization.

      MatrixOneWriter uses DataX to retrieve generated protocol data from the Reader and generates the corresponding insert into ... statements based on your configured writeMode. In the event of primary key or uniqueness index conflicts, conflicting rows are excluded, and writing continues. For performance optimization, we use the PreparedStatement + Batch method and set the rewriteBatchedStatements=true option to buffer data to the thread context buffer. The write request is triggered only when the data volume in the buffer reaches the specified threshold.

      Note

      To execute the entire task, you must have permission to execute insert into .... Whether other permissions are required depends on the preSql and postSql in your task configuration.

      MatrixOneWriter mainly aims at ETL development engineers who use MatrixOneWriter to import data from data warehouses into MatrixOne. At the same time, MatrixOneWriter can also serve as a data migration tool for users such as DBAs.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#before-you-start","title":"Before you start","text":"

      Before using DataX to write data to MatrixOne, you need to complete the installation of the following software:

      • Install JDK 8+ version.
      • Install Python 3.8 (or newer).
      • Download the DataX installation package and unzip it.
      • Download matrixonewriter.zip and unzip it to the plugin/writer/ directory in the root directory of your DataX project.
      • Install the MySQL Client.
      • Install and start MatrixOne.
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#steps","title":"Steps","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#create-a-matrixone-table","title":"Create a MatrixOne Table","text":"

      Connect to MatrixOne using the MySQL Client and create a test table in MatrixOne:

      CREATE DATABASE mo_demo;\nUSE mo_demo;\nCREATE TABLE m_user(\nM_ID INT NOT NULL,\nM_NAME CHAR(25) NOT NULL\n);\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#configure-the-data-source","title":"Configure the Data Source","text":"

      In this example, we use data generated in memory as the data source:

      \"reader\": {\n\"name\": \"streamreader\",  \"parameter\": {\n\"column\" : [ # You can write multiple columns\n{\n\"value\": 20210106,   # Represents the value of this column\n\"type\": \"long\"       # Represents the type of this column\n},\n{\n\"value\": \"matrixone\",\n\"type\": \"string\"\n}\n],\n\"sliceRecordCount\": 1000     # Indicates how many times to print\n}\n}\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#write-the-job-configuration-file","title":"Write the Job Configuration File","text":"

      Use the following command to view the configuration template:

      python datax.py -r {YOUR_READER} -w matrixonewriter\n

      Write the job configuration file stream2matrixone.json:

      {\n\"job\": {\n\"setting\": {\n\"speed\": {\n\"channel\": 1\n}\n},\n\"content\": [\n{\n\"reader\": {\n\"name\": \"streamreader\",\n\"parameter\": {\n\"column\" : [\n{\n\"value\": 20210106,\n\"type\": \"long\"\n},\n{\n\"value\": \"matrixone\",\n\"type\": \"string\"\n}\n],\n\"sliceRecordCount\": 1000\n}\n},\n\"writer\": {\n\"name\": \"matrixonewriter\",\n\"parameter\": {\n\"writeMode\": \"insert\",\n\"username\": \"root\",\n\"password\": \"111\",\n\"column\": [\n\"M_ID\",\n\"M_NAME\"\n],\n\"preSql\": [\n\"delete from m_user\"\n],\n\"connection\": [\n{\n\"jdbcUrl\": \"jdbc:mysql://127.0.0.1:6001/mo_demo\",\n\"table\": [\n\"m_user\"\n]\n}\n]\n}\n}\n}\n]\n}\n}\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#start-datax","title":"Start DataX","text":"

      Execute the following command to start DataX:

      $ cd {YOUR_DATAX_DIR_BIN}\n$ python datax.py stream2matrixone.json\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#view-the-results","title":"View the Results","text":"

      Connect to MatrixOne using the MySQL Client and use select to query the inserted results. The 1000 records in memory have been successfully written to MatrixOne.

      mysql> select * from m_user limit 5;\n+----------+-----------+\n| m_id     | m_name    |\n+----------+-----------+\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n+----------+-----------+\n5 rows in set (0.01 sec)\n\nmysql> select count(*) from m_user limit 5;\n+----------+\n| count(*) |\n+----------+\n|     1000 |\n+----------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#parameter-descriptions","title":"Parameter Descriptions","text":"

      Here are some commonly used parameters for MatrixOneWriter:

      Parameter Name Parameter Description Mandatory Default Value jdbcUrl JDBC connection information for the target database. DataX will append some attributes to the provided jdbcUrl during runtime, such as yearIsDateType=false&zeroDateTimeBehavior=CONVERT_TO_NULL&rewriteBatchedStatements=true&tinyInt1isBit=false&serverTimezone=Asia/Shanghai. Yes None username Username for the target database. Yes None password Password for the target database. Yes None table Name of the target table. Supports writing to one or more tables. If configuring multiple tables, make sure their structures are consistent. Yes None column Fields in the target table that must be written with data, separated by commas. For example: \"column\": [\"id\",\"name\",\"age\"]. To write all columns, you can use *, for example: \"column\": [\"*\"]. Yes None preSql Standard SQL statements to be executed before writing data to the target table. No None postSql Standard SQL statements to be executed after writing data to the target table. No None writeMode Controls the SQL statements used when writing data to the target table. You can choose insert or update. insert or update insert batchSize Size of records for batch submission. This can significantly reduce network interactions between DataX and MatrixOne, improving overall throughput. However, setting it too large may cause DataX to run out of memory. No 1024"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#type-conversion","title":"Type Conversion","text":"

      MatrixOneWriter supports most MatrixOne data types, but a few types still need to be supported, so you need to pay special attention to your data types.

      Here is a list of type conversions that MatrixOneWriter performs for MatrixOne data types:

      DataX Internal Type MatrixOne Data Type Long int, tinyint, smallint, bigint Double float, double, decimal String varchar, char, text Date date, datetime, timestamp, time Boolean bool Bytes blob"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#additional-references","title":"Additional References","text":"
      • MatrixOne is compatible with the MySQL protocol. MatrixOneWriter is a modified version of the MySQL Writer with adjustments for JDBC driver versions. You can still use the MySQL Writer to write to MatrixOne.

      • To add the MatrixOne Writer in DataX, you need to download matrixonewriter.zip and unzip it into the plugin/writer/ directory in the root directory of your DataX project.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#ask-and-questions","title":"Ask and Questions","text":"

      Q: During runtime, I encountered the error \"Configuration information error, the configuration file you provided /{YOUR_MATRIXONE_WRITER_PATH}/plugin.json does not exist.\" What should I do?

      A: DataX attempts to find the plugin.json file by searching for similar folders when it starts. If the matrixonewriter.zip file also exists in the same directory, DataX will try to find it in .../datax/plugin/writer/matrixonewriter.zip/plugin.json. In the MacOS environment, DataX will also attempt to see it in .../datax/plugin/writer/.DS_Store/plugin.json. In this case, you need to delete these extra files or folders.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/","title":"Writing Data to MatrixOne Using SeaTunnel","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#overview","title":"Overview","text":"

      SeaTunnel is a distributed, high-performance, and highly scalable data integration platform that focuses on synchronizing and transforming massive data, including offline and real-time data. MatrixOne supports using SeaTunnel to synchronize data from other databases and can efficiently handle hundreds of billions of records.

      This document will explain how to use SeaTunnel to write data to MatrixOne.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#before-you-start","title":"Before you start","text":"

      Before using SeaTunnel to write data to MatrixOne, make sure to complete the following preparations:

      • Install and start MatrixOne by following the steps in Install and Start MatrixOne.

      • Install SeaTunnel Version 2.3.3 by downloading it from here. After installation, you can define the installation path of SeaTunnel using a shell command:

      export SEATNUNNEL_HOME=\"/root/seatunnel\"\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#steps","title":"Steps","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#create-test-data","title":"Create Test Data","text":"
      1. Create a MySQL database named test1 and create a table named test_table within it. Store this in a file named mysql.sql under the root directory. Here's the MySQL DDL statement:

        create database test1;\nuse test1;\nCREATE TABLE `test_table` (\n`name` varchar(255) DEFAULT NULL,\n`age` int(11) DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n
      2. Use the mo_ctl tool to import the MySQL DDL statements into MatrixOne directly. Execute the following command:

        mo_ctl sql /root/mysql.sql\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#install-the-connectors-plugin","title":"Install the Connectors Plugin","text":"

      This document will explain how to use SeaTunnel's connector-jdbc connection plugin to connect to MatrixOne.

      1. In the ${SEATNUNNEL_HOME}/config/plugin_config file of SeaTunnel, add the following content:

        --connectors-v2--\nconnector-jdbc\n--end--\n
      2. SeaTunnel binary package version 2.3.3 does not provide connector dependencies by default. You need to install the connectors when using SeaTunnel for the first time by running the following command:

        sh bin/install-plugin.sh 2.3.3\n

        Note: This document uses the SeaTunnel engine to write data to MatrixOne without relying on Flink or Spark.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#define-the-task-configuration-file","title":"Define the Task Configuration File","text":"

      In this document, we use the test_table table in the MySQL database as the data source, and we write data directly to the test_table table in the MatrixOne database without data processing.

      Due to data compatibility issues, you need to configure the task configuration file ${SEATNUNNEL_HOME}/config/v2.batch.config.template, which defines how SeaTunnel handles data input, processing, and output logic after it starts.

      Edit the configuration file with the following content:

      env {\nexecution.parallelism = 2\njob.mode = \"BATCH\"\n}\n\nsource {\nJdbc {\nurl = \"jdbc:mysql://192.168.110.40:3306/test\"\ndriver = \"com.mysql.cj.jdbc.Driver\"\nconnection_check_timeout_sec = 100\nuser = \"root\"\npassword = \"123456\"\nquery = \"select * from test_table\"\n}\n}\n\ntransform {\n\n}\n\nsink {\njdbc {\nurl = \"jdbc:mysql://192.168.110.248:6001/test\"\ndriver = \"com.mysql.cj.jdbc.Driver\"\nuser = \"root\"\npassword = \"111\"\nquery = \"insert into test_table(name,age) values(?,?)\"\n}\n}\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#install-database-dependencies","title":"Install Database Dependencies","text":"

      Download mysql-connector-java-8.0.33.jar and copy the file to the ${SEATNUNNEL_HOME}/plugins/jdbc/lib/ directory.

      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#run-the-seatunnel-application","title":"Run the SeaTunnel Application","text":"

      Execute the following command to start the SeaTunnel application:

      ./bin/seatunnel.sh --config ./config/v2.batch.config.template -e local\n
      "},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#view-the-results","title":"View the Results","text":"

      After SeaTunnel finishes running, it will display statistics similar to the following, summarizing the time taken for this write operation, the total number of data read, the total number of writes, and the total number of write failures:

      ***********************************************\n           Job Statistic Information\n***********************************************\nStart Time                : 2023-08-07 16:45:02\nEnd Time                  : 2023-08-07 16:45:05\nTotal Time(s)             :                   3\nTotal Read Count          :             5000000\nTotal Write Count         :             5000000\nTotal Failed Count        :                   0\n***********************************************\n

      You have successfully synchronized data from a MySQL database into the MatrixOne database.

      "},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/","title":"Multi-Account Overview","text":"

      Unlike MySQL, MatrixOne is a database with built-in multi-tenancy capability. In a MatrixOne cluster, accounts can be created using the CREATE ACCOUNT command. Conceptually, each tenant represents a completely independent data space, with all data and operations being isolated from other accounts. When users log in with the tenant's username and password, they enter a MySQL instance where they can perform various operations such as creating databases and tables without affecting the data of other accounts.

      "},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/#introduction-to-accounts","title":"Introduction to accounts","text":"

      The Account in MatrixOne is part of the permission management system. For more information on the permission management system, see Privilege Management Overview section.

      Multi-tenancy has various use cases, including multi-tenancy design in SaaS applications, isolating accounts for subsidiaries of a corporation, and database usage for services in a microservices architecture. For more information on application scenarios, see Multi-Account section in the MatrixOne Feature Overview.

      "},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/#creating-and-using-accounts","title":"Creating and Using Accounts","text":"
      1. For developers, creating and using accounts in MatrixOne can be done through SQL statements. For more examples, see Create accounts, Verify Resource Isolation section.
      2. For operations personnel working with distributed versions of MatrixOne, it is necessary to configure resource isolation and scaling for accounts, for more information on practical guidelines, see Managing CN Groups with Proxy and Scaling MatrixOne Cluster.
      "},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/#account-to-account-publishsubscribe","title":"Account-to-Account Publish/Subscribe","text":"

      In addition to ensuring data and load isolation between accounts, MatrixOne provides a publish/subscribe capability that allows data exchange between accounts. This capability can be used to address data synchronization and large-scale data distribution scenarios. For more information, see Publish-subscribe section.

      "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/","title":"Publish-subscribe","text":"

      Publish-Subscribe (Pub/Sub for short) of a database is a messaging model in which Publisher sends messages to one or more Subscribers, and Subscribers The message is received and processed. In this mode, publishers and subscribers are loosely coupled, and no direct communication is required between them, thus improving the scalability and flexibility of the application.

      In databases, the publish-subscribe function is usually used in scenarios such as real-time data updates, cache synchronization, and business event notification. For example, when the data of a particular table in the database changes, the subscribers can be notified in real-time through the publish and subscribe function, to realize real-time data synchronization and processing. In addition, the notification of business events can also be recognized through the publish and subscribe function, such as an order being canceled, a certain inventory quantity is insufficient, and so on.

      There can be a many-to-many relationship between publishers and subscribers; one publisher can publish messages to multiple subscribers, and one subscriber can also subscribe to various messages/data. Usually, the publish-subscribe function of the database consists of two parts: Publisher and Subscriber. Publisher is responsible for publishing messages, while Subscriber subscribes to corresponding messages to achieve data synchronization.

      "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#application-scenarios","title":"Application scenarios","text":"

      The publish-subscribe function has many typical application scenarios:

      • Data Synchronization: When a database needs to be kept in sync with another database, the publish-subscribe feature can send data changes to the subscriber database. For example, when a website needs to transfer data from one geographic location to another, publish-subscribe functionality can ensure data synchronization between the two databases.

      • Business data distribution: The publish and subscribe function can distribute business data to different systems or processes. For example, when a bank needs to distribute customer account information to multiple business systems, the publish-subscribe function can distribute data to corresponding systems to ensure data consistency between various business processes.

      • Data backup: The publish-subscribe function can back up data. For example, when one database needs to be backed up to another database, the publish-subscribe part can be used to back up the data to the subscriber database so that the data can be recovered in the event of failure of the primary database.

      • Real-time data processing: The publish-subscribe function can be used to realize real-time data processing. For example, when a website needs to process data from different users, the publish-subscribe part can be used to transmit data to a processing program for processing, to realize real-time data analysis and decision-making.

      "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#concepts","title":"Concepts","text":"
      • Publication: In a database, a publication often refers to the process of setting a database object to be accessible by other accounts. It is a crucial step in data sharing and replication, where the published objects can be subscribed to by other accounts, and their data can be accessed.

      • Subscription: A subscription refers to a database choosing to receive and replicate the data of a published database object.

      • Publisher (Pub): The Publisher is the database that performs the publishing operation. The Publisher is responsible for creating and managing the published objects, as well as managing the access permissions of databases subscribing to these published objects.

      • Subscriber (Sub): The Subscriber is the account that subscribes to the published objects.

      • Published Object: A published object is a database created by the Publisher and made available for publication, namely a database. The data of these objects can be accessed and replicated by the Subscriber.

      • Subscribed Object: A subscribed object is a published object replicated and stored on the Subscriber. The data of the subscribed object is updated according to the data on the Publisher.

      "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publicationsubscription-scope-explanation","title":"Publication/Subscription Scope Explanation","text":""},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publishsubscribe-application-scope","title":"Publish/Subscribe Application Scope","text":"

      Both Publisher and Subscriber are accounts of MatrixOne.

      "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publishablesubscribable-permissions","title":"Publishable/Subscribable Permissions","text":"
      • Only ACCOUNTADMIN or MOADMIN role can create publications and subscriptions on the Publisher.
      • Subscribers are controlled by ACCOUNTADMIN or MOADMIN roles to access subscription data permissions.
      "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publicationsubscription-data-scope","title":"Publication/Subscription Data Scope","text":"
      • A single Publication can only be associated with one database.
      • Publications and subscriptions are only implemented at the database level, with no current support for direct publication and subscription at the table level.
      • The Subscriber only has read access to the Subscribed database.
      • If the Publisher adjusts the sharing scope of the publication, those accounts that are no longer within the new scope and have already created a subscribed database will find that their access to the Subscribed database is invalid.
      • If the Publisher attempts to delete a database that has been published, the deletion will fail.
      • If the Publisher deletes a Publication, but the corresponding object still exists in the subscribed database, an error will be triggered when the Subscriber attempts to access this object. The Subscriber will need to delete the corresponding Subscription.
      • If the Publisher deletes a Published object, but the corresponding object still exists in the subscribed database, an error will be triggered when the Subscriber attempts to access this object. The Subscriber must delete the corresponding Subscribed object.
      "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#examples","title":"Examples","text":"

      This chapter will give an example to introduce that there are currently three accounts in the MatrixOne cluster, sys, acc1, and acc2, and operate on the three accounts according to the order of operations:

      1. Publisher: sys account creates database sub1 and table t1, and publishes pub1:

        create database sub1;\ncreate table sub1.t1(a int,b int);\ncreate publication pub1 database sub;\n
      2. Subscriber: both acc1 and acc2 create a subscription database syssub1, and thus get the shared table t1:

        -- The SQL statements for acc1 and acc2 to create the subscription library are the same, so there will not repeat them\ncreate database syssub1 from sys publication pub1;\nuse syssub1;\nshow tables;\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub1  |\n+--------------------+\n| t1                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
      3. Publisher: sys account creates table t2:

        create table sub1.t2(a text);\n
      4. Subscribers: acc1 and acc2 get shared tables t1 and t2:

        show tables;\n+--------------------+\n| Tables_in_syssub1  |\n+--------------------+\n| t1                 |\n+--------------------+\n| t2                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
      5. Publisher: sys account creates database sub2 and table t2, and publishes pub2 to accounts acc1 and acc3:

        create database sub2;\ncreate table sub2.t1(a float);\ncreate publication pub2 database sub2 account acc1,acc3;\n
      6. Subscriber: both acc1 and acc2 create the subscription database syssub2, and acc1 gets the shared data table t1; acc2 fails to create the subscription database syssub2:

        • acc1
        create database syssub2 from sys publication pub2;\nuse syssub2;\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub2  |\n+--------------------+\n| t1                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
        • acc2
        create database syssub2 from sys publication pub2;\n> ERROR 20101 (HY000): internal error: the account acc3 is not allowed to subscribe the publication pub2\n
      7. Publisher: The sys account modifies and publishes pub2 to all accounts:

        alter publication pub2 account all;\n
      8. Subscriber: acc2 successfully created the subscription database syssub2, and got the shared data table t1:

        create database syssub2 from sys publication pub2;\nuse syssub2;\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub2  |\n+--------------------+\n| t1                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
      9. Publisher: sys account deletes publication pub1:

        drop publication pub1;\n
      10. Subscriber: acc1 failed to connect to syspub1:

        use syssub1;\nERROR 20101 (HY000): internal error: there is no publication pub1\n
      11. Subscriber: acc2 delete syspub1:

        drop database syssub1;\n
      12. Publisher: sys account recreates pub1:

        create publication pub1 database sub;\n
      13. Subscriber: acc1 connects to syspub1 successfully:

        create database syssub1 from sys publication pub1;\nuse syssub1;\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub1  |\n+--------------------+\n| t1                 |\n+--------------------+\n2 rows in set (0.02 sec)\n
      "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#reference","title":"Reference","text":""},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#publisher-reference","title":"Publisher Reference","text":"
      • CREATE PUBLICATION
      • ALTER PUBLICATION
      • DROP PUBLICATION
      • SHOW PUBLICATIONS
      • SHOW CREATE PUBLICATION
      "},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#subscriber-reference","title":"Subscriber Reference","text":"
      • CREATE...FROM...PUBLICATION...
      • SHOW SUBSCRIPTIONS
      "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/","title":"General Transaction Overview","text":""},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#why-do-you-need-transactions","title":"Why do you need transactions?","text":"

      In many large, critical applications, computers perform many tasks every second. More often than not, these tasks are themselves, but these tasks are combined to complete a business requirement called a transaction. What happens if one task is executed successfully and an error occurs in a second or third related task? This error is likely to leave system data in an inconsistent state. At this time, the transaction becomes very important; it can make the system data out of this inconsistent state.

      How to understand transaction? For example, in the banking system, if there is no transaction to control and manage the data, A likely withdraws a sum of money from the corporate account, and B and C also withdraw money from the same corporate account. Each transfer involves at least two changes in account information (for example, A's money arrives, and the company's account goes out; B's money arrives, and the company's account goes out; C's money comes, and the company's account goes out), If there are no transactions, then the exact value of the booking amount cannot be determined. After introducing the business requirement of the transaction, the essential characteristics of the transaction (ACID) ensure that the fund operation of the bank book is atomic (indivisible) and the amount seen by others is isolated. Each process is Consistent, and all operations are persistent, ensuring that the data in and out of the banking system remains consistent.

      "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#what-is-transaction","title":"What is Transaction?","text":"

      The transaction is a logical unit in the execution process of the database management system, consisting of a limited sequence of database operations. A transaction is a series of SQL statements submitted or rolled back as a logical unit.

      "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#characteristics-of-transactions","title":"Characteristics of transactions","text":"

      Usually, transactions need to have four characteristics of ACID:

      • Atomicity: The atomicity of a transaction means that a transaction is an indivisible unit, and the operations in a transaction either all or none of them occur.

      For example:

      start transaction;\ninsert into t1 values(1,2,3),(4,5,6);\nupdate t2 set c1='b' where c1='B';\ncommit;\n

      Suppose an error occurs in inserting data into t1 or modifying any data in t2. In that case, the entire transaction will be rolled back, and only when two statements succeed at the same time will the submission be successful, and one operation will not succeed while the other fails.

      • Consistency: Transactional consistency means that data must remain correct and obey all data-related constraints before and after the transaction.

      For example, create a new table in database first:

      create table t1(a int primary key,b varchar(5) not null);\n

      To ensure data consistency here, when inserting data, to ensure the data type and range of columns a and b, the primary key constraint of column a and the non-null constraint of column b must be satisfied at the same time:

      insert into t1 values(1,'abcde'),(2,'bcdef');\n
      • Isolation: The isolation of a transaction is that when multiple users access concurrently, the specified isolation level must be observed between transactions. Within the determined isolation level range, one transaction cannot be interfered with by another transaction.

      For example, in the following transaction example, the session isolation level is read committed, and the data that can be seen in session 1 is as follows:

      select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 | a    |\n|    2 | b    |\n|    3 | c    |\n+------+------+\n

      At this point in session 2, you can do the following:

      begin;\ndelete from t1 where a=3;\n

      In session 1, you can still see the data unchanged:

      select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 | a    |\n|    2 | b    |\n|    3 | c    |\n+------+------+\n

      Until the current transaction is committed in session 2:

      commit;\n

      The result of the committed transaction will only be seen in session 1:

      select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 | a    |\n|    2 | b    |\n+------+------+\n
      • Durability: Transaction durability means that when a transaction is committed in the database, its changes to the data are permanent, regardless of whether the database software is restarted.
      "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#transaction-types","title":"Transaction Types","text":"

      In a database, transactions are divided into the following categories:

      • According to whether there is a clear start and end, it is divided into explicit transaction and implicit transaction.
      • According to the use stage of the resource lock, it is divided into optimistic transaction and pessimistic transaction.

      These two types of transactions is not limited by each other. An explicit transaction can be an optimistic or pessimistic transaction, and a pessimistic transaction can be either an explicit or an implicit transaction.

      "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#explicit-transaction-and-implicit-transaction","title":"Explicit Transaction and Implicit Transaction","text":"
      • Explicit transaction: In general, you can explicitly start a transaction by executing a BEGIN statement. A transaction can be ended explicitly by executing a COMMIT or ROLLBACK. MatrixOne's displayed transaction startup and execution methods are slightly different; see Explicit Transaction.

      • Implicit transaction: The transaction can start and end implicitly, without using BEGIN TRANSACTION, COMMIT, or ROLLBACK statements to start and end. Implicit transactions behave in the same way as explicit transactions. However, the rules for determining when an implicit transaction begins differ from those for determining when an explicit transaction begins. MatrixOne's implicit transaction startup and execution methods are slightly different; see Implicit Transaction.

      "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#optimistic-transaction-and-pessimistic-transaction","title":"Optimistic Transaction and Pessimistic Transaction","text":"

      Regardless of whether it is an optimistic or pessimistic transaction, the execution results of the transaction are the same; that is, the operations in a transaction have exactly the exact requirements for the ACID level, whether it is atomicity, consistency, isolation, or persistence, there is no situation where optimistic transactions are more relaxed and pessimistic transactions are stricter.

      The difference between an optimistic transaction and a pessimistic transaction is that it is just a two-phase commit based on a different execution strategy based on the state of the business to be processed. Its choice is based on the executor's judgment, and its efficiency is based on the actual state of the business being processed (the frequency of write conflicts of concurrent transactions). That is, different assumptions are made about the state of transaction-related resources so that write locks are placed in different stages.

      At the beginning of an optimistic transaction, it is assumed that the transaction-related tables are in a state where no write conflicts will occur. The insertion, modification, or deletion of data is cached in memory. At this stage, the data will not be locked, but in the data Lock the corresponding data table or data row when submitting, and unlock it after submitting.

      At the beginning of a pessimistic transaction, it is assumed that there will be written conflicts in the tables related to the transaction, and the related tables or rows are locked in advance. Then in memory, insert, modify or delete relevant data and commit. Data is only unlocked after a commit or rollback completes.

      Optimistic transactions and pessimistic transactions have the following advantages and disadvantages during use:

      • Optimistic transactions are more friendly to systems with fewer write operations and more read operations, avoiding deadlocks.
      • Optimistic transactions may fail after repeated retries due to conflicts when larger transactions are committed.
      • Pessimistic transactions are more friendly to systems with more write operations and avoid write-write conflicts from the database level.
      • Pessimistic transactions In a scenario with large concurrency, if a transaction with a long execution time appears, the system may be blocked, and the throughput will be affected.

      For more information on optimistic transactions in MatrixOne, see Optimistic Transaction.

      For more information on optimistic transactions in MatrixOne, see Pessimistic Transaction.

      "},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#transaction-isolation","title":"Transaction Isolation","text":"

      One of the characteristics of transactions is isolation, which we usually call transaction isolation.

      Isolation is the most restrictive of the four ACID properties of database transactions. The database system usually uses a locking mechanism or a multi-version concurrency control mechanism to obtain a higher isolation level. Application software also requires additional logic to make it work properly.

      Many database management systems (DBMS) define different \"transaction isolation levels\" to control the degree of locking. In many database systems, most transactions avoid high-level isolation levels (such as serializability) to reduce locking overhead. Programmers must carefully analyze the database access part of the code to ensure that lowering the isolation level does not cause hard-to-find code bugs. On the contrary, a higher isolation level will increase the chance of deadlock, which must be avoided during programming.

      The DBMS is allowed to use a higher isolation level than the one requested because there are no operations in a higher isolation level that are prohibited by a lower isolation level.

      ANSI/ISO SQL defines four standard isolation levels:

      Isolation Level Dirty Write Dirty Read Fuzzy Read Phantom READ UNCOMMITTED Not Possible Possible Possible Possible READ COMMITTED Not Possible Not Possible Possible Possible REPEATABLE READ Not Possible Not Possible Not Possible Possible SERIALIZABLE Not Possible Not Possible Not Possible Not Possible
      • READ UNCOMMITTED: READ UNCOMMITTED is the lowest isolation level. \"Dirty reads\" are allowed, and transactions can see the \"not committed\" modifications of other transactions.

      • READ COMMITTED: At the READ COMMITTED level, the DBMS based on lock mechanism concurrency control needs to keep the write lock on the selected object until the end of the transaction, but the read lock is released immediately after the SELECT operation is completed. Like the previous isolation level, \"scope locks\" are not required.

      • REPEATABLE READS: At the REPEATABLE READS isolation level, the DBMS based on the lock mechanism concurrency control needs to keep the read locks (read locks) and write locks (write locks) of the selected objects until the transaction end but does not require a \"range lock\", so a \"phantom read\" may occur. MatrixOne has implemented Snapshot Isolation and it is also known as REPEATABLE READS to maintain consistency with the isolation level in MySQL.

      • SERIALIZABLE: SERIALIZABLE is the highest isolation level. On lock-based concurrency control DBMSs, serializability requires that read and write locks on selected objects be released at the end of the transaction. Using a \"WHERE\" clause in a SELECT query to describe a range should acquire a \"range-locks\".

      Higher levels provide stronger isolation by requiring more restrictions than lower isolation levels. The standard allows transactions to run at a stronger transaction isolation level.

      Note

      MatrixOne's transaction isolation is slightly different from the general isolation definition and isolation level division; see Isolation level in MatrixOne.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/","title":"Explicit Transactions in MatrixOne","text":"

      In MatrixOne's explicit transactions also obey the following rules:

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#explicit-transaction-rules","title":"Explicit transaction rules","text":"
      • An explicit transaction starts and ends with BEGIN...END or START TRANSACTION...COMMIT or ROLLBACK.
      • In explicit transactions, DML (Data Manipulation Language) and DDL (Data Definition Language) can exist at the same time. All DDLs are supported.
      • In an explicit transaction, other explicit transactions cannot be nested. For example, if START TANSACTIONS is encountered after START TANSACTIONS, all statements between two START TANSACTIONS will be forced to commit, regardless of the value of AUTOCOMMIT 1 or 0.
      • In an explicit transaction, only DML and DDL can be included and cannot contain modification parameter configuration or management commands, such as set [parameter] = [value], create user, and so on.
      • In an explicit transaction, if a write-write conflict occurs when a new transaction is started without an explicit commit or rollback, the previously uncommitted transaction will be rolled back, and an error will be reported.
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#differences-from-mysql-explicit-transactions","title":"Differences from MySQL explicit transactions","text":"Transaction type Turn on autocommit Turn off autocommit Explicit Transactions vs. Autocommit When AUTOCOMMIT=1, MySQL will not change the transaction, and each statement will be executed in a new auto-commit transaction. When AUTOCOMMIT=0, each statement will be executed in an explicitly opened transaction until the transaction is explicitly committed or rolled back. Explicit transactions and non-autocommit When AUTOCOMMIT=1, MySQL will automatically commit uncommitted transactions after each statement execution. When AUTOCOMMIT=0, each statement will be executed in an explicitly opened transaction until the transaction is explicitly committed or rolled back.

      MySQL and MatrixOne Explicit Transaction Behavior Example

      mysql> CREATE TABLE Accounts (account_number INT PRIMARY KEY, balance DECIMAL(10, 2));\nQuery OK, 0 rows affected (0.07 sec)\n\nmysql> INSERT INTO Accounts (account_number, balance) VALUES (1, 1000.00), (2, 500.00);\nQuery OK, 2 rows affected (0.00 sec)\n\nmysql> BEGIN;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> UPDATE Accounts SET balance = balance - 100.00 WHERE account_number = 1;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> UPDATE Accounts SET balance = balance + 100.00 WHERE account_number = 2;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> COMMIT;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> BEGIN;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> UPDATE Accounts SET balance = balance - 100.00 WHERE account_number = 1;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> UPDATE Accounts SET invalid_column = 0 WHERE account_number = 2;\nERROR 20101 (HY000): internal error: column 'invalid_column' not found in table\nPrevious DML conflicts with existing constraints or data format. This transaction has to be aborted\nmysql> ROLLBACK;\nQuery OK, 0 rows affected (0.00 sec)\nmysql> SELECT * FROM Accounts;\n+----------------+---------+\n| account_number | balance |\n+----------------+---------+\n|              1 |  900.00 |\n|              2 |  600.00 |\n+----------------+---------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#cross-database-transaction-behavior-example","title":"Cross-Database Transaction Behavior Example","text":"

      MatrixOne supports cross-database transaction behavior; here, we'll illustrate it with a simple example.

      First, let's create two databases (db1 and db2) along with their respective tables (table1 and table2):

      -- Create the db1 database\nCREATE DATABASE db1;\nUSE db1;\n\n-- Create table1 within db1\nCREATE TABLE table1 (\nid INT AUTO_INCREMENT PRIMARY KEY,\nfield1 INT\n);\n\n-- Create the db2 database\nCREATE DATABASE db2;\nUSE db2;\n\n-- Create table2 within db2\nCREATE TABLE table2 (\nid INT AUTO_INCREMENT PRIMARY KEY,\nfield2 INT\n);\n

      Now, we have created two databases and their tables. Next, let's insert some data:

      -- Insert data into table1 in db1\nINSERT INTO db1.table1 (field1) VALUES (100), (200), (300);\n\n-- Insert data into table2 in db2\nINSERT INTO db2.table2 (field2) VALUES (500), (600), (700);\n

      We now have data in both databases. Moving on, let's execute a cross-database transaction to modify data in these two databases simultaneously:

      -- Start the cross-database transaction\nSTART TRANSACTION;\n\n-- Update data in table1 within db1\nUPDATE db1.table1 SET field1 = field1 + 10;\n\n-- Update data in table2 within db2\nUPDATE db2.table2 SET field2 = field2 - 50;\n\n-- Commit the cross-database transaction\nCOMMIT;\n

      In the above cross-database transaction, we begin with START TRANSACTION;, then proceed to update data in table1 within db1 and table2 within db2. Finally, we use COMMIT; to commit the transaction. If any step fails during the transaction, the entire transaction is rolled back to ensure data consistency.

      This example demonstrates a complete cross-database transaction. Cross-database transactions can be more complex in real-world applications, but this simple example helps us understand the fundamental concepts and operations involved.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/","title":"How to use MatrixOne Transaction?","text":"

      This document will teach you how to simply start, commit, rollback a transaction, and how to automatically commit a transaction.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#start-transaction","title":"Start transaction","text":"

      To start a transaction, you can start a transaction with START TRANSACTION, or you can use the dialect command BEGIN.

      The code example is as follows:

      START TRANSACTION;\ninsert into t1 values(123,'123');\n

      Or:

      BEGIN;\ninsert into t1 values(123,'123');\n
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#commit-transaction","title":"Commit transaction","text":"

      When committing a transaction, MatrixOne accepts the COMMIT command as a commit command. The code example is as follows:

      START TRANSACTION;\ninsert into t1 values(123,'123');\ncommit;\n
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#rollback-transaction","title":"Rollback transaction","text":"

      When rolling back a transaction, MatrixOne accepts the ROLLBACK command as a commit command. The code example is as follows:

      START TRANSACTION;\ninsert into t1 values(123,'123');\nrollback;\n
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#autocommit","title":"Autocommit","text":"

      In MatrixOne, there is a parameter AUTOCOMMIT, which determines whether there is a single SQL statement to be automatically committed as an independent transaction without START TRANSACTION or BEGIN. The syntax is as follows:

      -- Set the value of this parameter\nSET AUTOCOMMIT={on|off|0|1}  SHOW VARIABLES LIKE 'AUTOCOMMIT';\n

      When this parameter is set to ON or 1, it means automatic submission. All single SQL statements not in START TRANSACTION or BEGIN will be automatically submitted when executed.

      -- Autocommit\ninsert into t1 values(1,2,3);   

      When this parameter is set to OFF or 0, it is not automatically committed. All SQL statements not in START TRANSACTION or BEGIN need to use COMMIT or ROLLBACK to perform commit or rollback.

      insert into t1 values(1,2,3);\n-- Manual submission is required here\nCOMMIT;  
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#switch-transaction-mode","title":"Switch Transaction Mode","text":"

      MatrixOne adopts pessimistic transaction and RC isolation level by default. But if you need to switch to optimistic transaction mode, the corresponding isolation level will be changed to snapshot isolation.

      Add the following configuration parameters to the configuration file cn.toml under the matrixone/etc/launch-with-proxy/ directory to switch the transaction mode:

      [cn.Txn]\nmode = \"optimistic\"\nisolation = \"SI\"\n

      Note: If you only add the transaction mode parameter mode = \"optimistic\", but do not add isolation = \"SI\", the system will default to SI isolation in the optimistic transaction mode.

      Restart MatrixOne to make the switched transaction mode take effect.

      For more information on the configuration parameters, see Distributed Common Parameters Configuration.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/","title":"Implicit Transactions in MatrixOne","text":"

      In MatrixOne's Implicit transactions also obey the following rules:

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#implicit-transaction-rules","title":"Implicit transaction rules","text":"
      • When AUTOCOMMIT changes, if the implicit transaction is not committed, MatrixOne will report an error and prompt the user to submit the change.

      • AUTOCOMMIT=0, and when there are no active transactions, DDL (Data Definition Language) and parameter configuration files can be executed.

      • In the case of AUTOCOMMIT=1, each DML (Data Manipulation Language, Data Manipulation Language) statement is a separate transaction and is committed immediately after execution.

      • In the case of AUTOCOMMIT=0, each DML statement will not be submitted immediately after execution, and COMMIT or ROLLBACK needs to be performed manually. If the client exits without committing or rolling back, then Rollback by default.

      • In the case of AUTOCOMMIT=0, DML and DDL can exist at the same time.

      • If a CREATE/DROP DATABASE or CREATE/DROP SEQUENCE operation occurs in the state of AUTOCOMMIT=0, all previously uncommitted content will be forced to be committed. Also, the CREATE/DROP DATABASE functions will be committed immediately as a separate transaction.

      • When there is uncommitted content in the implicit transaction, opening an explicit transaction will force the submission of the previously uncommitted content.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#the-difference-between-matrixone-and-mysql-implicit-transactions","title":"The difference between MatrixOne and MySQL implicit transactions","text":"

      In MatrixOne, if the implicit transaction is enabled (SET AUTOCOMMIT=0), all operations must manually execute COMMIT or ROLLBACK to end the transaction. In contrast, MySQL automatically commits when encountering a DDL or similar SET statement.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#mysql-implicit-transaction-behavior","title":"MySQL Implicit Transaction Behavior","text":"Transaction type Turn on autocommit Turn off autocommit Implicit transactions and autocommit When AUTOCOMMIT=1, MySQL will not change the transaction; each statement is a separate auto-commit transaction. When AUTOCOMMIT=0, MySQL also does not change the transaction, but subsequent statements continue to execute within the current transaction until the transaction is explicitly committed or rolled back. Implicit transactions and non-autocommit When AUTOCOMMIT=1, MySQL will automatically commit uncommitted transactions after each statement execution. When AUTOCOMMIT=0, MySQL continues to execute subsequent statements in the current transaction until the transaction is explicitly committed or rolled back.

      MySQL Implicit Transaction Behavior Example

      mysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT   |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = 1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n|                  1 |\n+--------------------+\n1 row in set (0.01 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n|                  1 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = default;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT   |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.00 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT   |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.00 sec)\n

      MatrixOne Implicit Transaction Behavior Example

      mysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT   |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = 1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1                  |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1                  |\n+--------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nERROR 20101 (HY000): internal error: Uncommitted transaction exists. Please commit or rollback first.\n
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#implicit-transactions-example","title":"Implicit Transactions Example","text":"

      For example, insert data (4,5,6) to t1, which becomes an implicit transaction. Whether the implicit transaction is committed immediately depends on the value of the AUTOCOMMIT parameter:

      CREATE TABLE t1(a bigint, b varchar(10), c varchar(10));\nSTART TRANSACTION;\nINSERT INTO t1 values(1,2,3);\nCOMMIT;\n\n-- Check the AUTOCOMMIT parameters\nmysql> SHOW VARIABLES LIKE 'AUTOCOMMIT';\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| autocommit    | 1     |\n+---------------+-------+\n1 row in set (0.00 sec)\n-- Here an implicit transaction begins, with each DML committed immediately after execution with AUTOCOMMIT=.1\ninsert into t1 values(4,5,6);\n\n-- Implicit transaction is committed automatically, and the table structure is shown below\nmysql> select * from t1;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 | 2    | 3    |\n|    4 | 5    | 6    |\n+------+------+------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/","title":"Isolation level in MatrixOne","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#read-committed","title":"Read Committed","text":"

      MatrixOne defaults to the Read Committed isolation level and its characteristics are as follows:

      • Between different transactions, only the data submitted by other transactions can be read, and the uncommitted data cannot be viewed.
      • The read-committed isolation level can effectively prevent dirty writes and dirty reads but cannot avoid non-repeatable reads and phantom reads.
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#read-committed-principles","title":"Read Committed Principles","text":"
      • When a transaction starts, the database generates a unique transaction ID.
      • When generating the timestamp of the transaction ID, TAE (Transactional Analytic Engine) automatically detects whether there is an updated timestamp in the corresponding table every time the data is added, deleted, modified, or checked. If so, the updated timestamp is the latest.
      • When operating on data, TAE caches the user data in memory. When committing a transaction, TAE writes the data in memory to the disk (the S3 path where the data is stored or the local disk path).
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#read-committed-examples","title":"Read Committed Examples","text":"

      You can participate in the following example to understand the read committed isolation level.

      First in MatrixOne, we create a database test and table t1:

      create database test;\nuse test;\nCREATE TABLE t1\n(\ntid INT NOT NULL primary key,\ntname VARCHAR(50) NOT NULL\n);\nINSERT INTO t1 VALUES(1,'version1');\nINSERT INTO t1 VALUES(2,'version2');\n

      In session 1, start a transaction:

      use test;\nbegin;\nUPDATE t1 SET tname='version3' WHERE tid=2;\nSELECT * FROM t1;\n

      In session 1, the results are as follows:

      +------+----------+\n| tid  | tname    |\n+------+----------+\n|    2 | version3 |\n|    1 | version1 |\n+------+----------+\n

      At this time, open session 2 to query t1:

      use test;\nbegin;\nSELECT * FROM t1;\n

      The result is still the original data:

      +------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version1 |\n|    2 | version2 |\n+------+----------+\n

      In session 2, modify the line for tid=1:

      UPDATE t1 SET tname='version0' WHERE tid=1;\n

      At this point, the content of query t1 in session 1 is still the modified data:

      SELECT * FROM t1;\n+------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version1 |\n|    2 | version3 |\n+------+----------+\n

      After session 2 submits its data, then query session 1, you will find that the content of session 1 has become the data after session two submits:

      • Session 2:
      -- Submit data in session 2:\nCOMMIT;\n
      • Session 1:
      -- Query whether the content of session 1 has become the data submitted by session 2:\nSELECT * FROM t1;\n+------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version0 |\n|    2 | version3 |\n+------+----------+\n
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#snapshot-isolation","title":"Snapshot isolation","text":"

      In MatrixOne, the supported isolation level is Snapshot Isolation, which is also known as REPEATABLE READS to maintain consistency with the isolation level in MySQL. The isolation implementation principle of this level is as follows:

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#snapshot-isolation-principle","title":"Snapshot isolation principle","text":"
      • When a transaction starts, the database generates a transaction ID for the transaction, which is a unique ID.
      • At the timestamp when the transaction ID is generated, a snapshot of the corresponding data is generated, and all transaction operations are performed based on the snapshot.
      • After the transaction commits to modify the data, release the transaction ID and data snapshot.
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#snapshot-isolation-example","title":"Snapshot Isolation Example","text":"

      See the example below to help you understand snapshot isolation.

      First in MatrixOne, we create a database test and table t1:

      create database test;\nuse test;\nCREATE TABLE t1\n(\ntid INT NOT NULL primary key,\ntname VARCHAR(50) NOT NULL\n);\nINSERT INTO t1 VALUES(1,'version1');\nINSERT INTO t1 VALUES(2,'version2');\n

      In session 1, start a transaction:

      use test;\nbegin;\nUPDATE t1 SET tname='version3' WHERE tid=2;\nSELECT * FROM t1;\n

      In session 1, the results are as follows, the modification results based on the snapshot data:

      +------+----------+\n| tid  | tname    |\n+------+----------+\n|    2 | version3 |\n|    1 | version1 |\n+------+----------+\n

      At this time, open session 2 to query t1:

      use test;\nSELECT * FROM t1;\n

      The result is still the original data:

      +------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version1 |\n|    2 | version2 |\n+------+----------+\n

      Commit the transaction in session 1:

      COMMIT;\n

      At this point, the result of t1 in session 2 becomes the submitted data:

      +------+----------+\n| tid  | tname    |\n+------+----------+\n|    1 | version1 |\n|    2 | version3 |\n+------+----------+\n
      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/mvcc/","title":"MVCC","text":"

      MVCC (Multiversion Concurrency Control) is applied to MatrixOne to ensure transaction snapshot and achieve transaction isolation.

      Create a Latch Free linked list based on the pointer field of the data tuple (Tuple, that is, each row in the table), called the version chain. This version chain allows the database to locate the desired version of a Tuple. Therefore, the storage mechanism of these versions of data is an essential consideration in the design of the database storage engine.

      One solution is the Append Only mechanism, where all tuple versions of a table are stored in the same storage space. This method is used in Postgre SQL. To update an existing Tuple, the database first fetches an empty slot from the table for the new version; then, it copies the current version's contents to the latest version. Finally, it applies the modifications to the Tuple in the newly allocated Slot. The critical decision of the Append Only mechanism is how to order the version chain of Tuple. Since it is impossible to maintain a lock-free doubly linked list, the version chain only points in one direction, either from Old to New (O2N) or New to Old (N2O).

      Another similar scheme is called Time Travel, which stores the information of the version chain separately, while the main table maintains the main version data.

      The third option is to maintain the main version of the tuple in the main table, and maintain a series of delta versions in a separate database comparison tool (delta) store. This storage is called a rollback segment in MySQL and Oracle. To update an existing tuple, the database fetches a contiguous space from the delta store to create a new delta version. This delta version contains the original value of the modified property, not the entire tuple. Then the database directly updates the main version in the main table (In Place Update).

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/","title":"Optimistic Transactions in MatrixOne","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#optimistic-transaction-principle","title":"Optimistic Transaction principle","text":"

      When the transaction starts, no conflict detection or lock will be performed, and the relevant data will be cached in the corresponding memory area. The data will be added, deleted, or modified.

      After completing the modification, when entering the submission stage, it will be submitted in two steps:

      Step 1: Use a column in the data to be written as the primary key column, lock the column and create a timestamp. Writes to related rows after this timestamp are judged as write conflicts.

      Step 2: Write data, record the timestamp at this time, and unlock it.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#optimistic-transaction-model","title":"Optimistic Transaction model","text":"

      MatrixOne supports an optimistic transaction model. You don't lock a row while reading it using optimistic concurrency. When you want to update a row, the application must determine whether another user has updated the row since it was read. Optimistic concurrent transactions are typically used in environments with low data contention.

      In an optimistic concurrency model, an error occurs if you receive a value from the database and another user modifies it before you attempt to modify it.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#example","title":"Example","text":"

      The following is an example of optimistic concurrency, showing how MatrixOne resolves concurrency conflicts.

      1. At 1:00 PM, User 1 reads a row from the database with the following value:

        CustID LastName FirstName\n101 Smith Bob\n
        Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Bob Bob
      2. At 1:01 PM, User 2 reads the same row from the database.

      3. At 1:03 PM, User 2 changes the FirstName row from \"Bob\" to \"Robert\" and updates the database.

        Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Robert Bob
      4. As shown in the above table, the value in the database at the time of the update matches the original value of User 2, indicating that the update was successful.

      5. At 1:05 PM, User 1 changes the FirstName row from \"Bob\" to \"James\" and attempts to update it.

        Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob James Robert
      6. At this point, user 1 encounters an optimistic concurrency violation because the value \"Robert\" in the database no longer matches the original value \"Bob\" that user 1 expected. The concurrency violation indicates that the update failed. The next step is to overwrite User 2's changes with User 1's changes or cancel User 1's changes.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/","title":"Transaction overview of MatrixOne","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#what-is-a-transaction-in-matrixone","title":"What is a transaction in MatrixOne?","text":"

      MatrixOne transactions follow the Standard Definition and Basic Characteristics (ACID) of database transactions. It aims to help users in a distributed database environment to ensure that every database data operation behavior can ensure the consistency and integrity of the results and isolate each other without interference under concurrent requests.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#transaction-type-of-matrixone","title":"Transaction type of MatrixOne","text":"

      In MatrixOne, transactions, like general transactions, are also divided into the following two categories:

      • According to whether there is a clear start and end, it is divided into explicit and implicit transactions.
      • Divided into optimistic and pessimistic transactions according to the use stage of resource locks.

      The classification of these two types of transactions is not limited by each other. An explicit transaction can be an optimistic or pessimistic transaction, and a pessimistic transaction can be either an explicit or an implicit transaction.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#explicit-transaction","title":"Explicit Transaction","text":"

      In MatrixOne, a transaction explicitly declared with START TRANSACTION becomes explicit.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#implicit-transaction","title":"Implicit Transaction","text":"

      In MatrixOne, if a transaction is not explicitly declared by START TRANSACTION or BEGIN, it is an implicit transaction.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#optimistic-transaction","title":"Optimistic Transaction","text":"

      At the beginning of an optimistic transaction, it is assumed that the transaction-related tables are in a state where no write conflicts will occur. The insertion, modification, or deletion of data is cached in memory. At this stage, the data will not be locked, but in the data Lock the corresponding data table or data row when submitting, and unlock it after submitting.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#pessimistic-transaction","title":"Pessimistic Transaction","text":"

      MatrixOne defaults to pessimistic transactions. At the beginning of a pessimistic transaction, it is assumed that the transaction-related table is in a state where write conflicts may occur, and the corresponding data table or data row is locked in advance. After the locking action is completed, the data's insertion, modification, or deletion is cached in In memory; after committing or rolling back, the data is completed, and the lock is released.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#matrixone-supports-cross-database-transactions","title":"MatrixOne Supports Cross-Database Transactions","text":"

      MatrixOne supports cross-database transactions, allowing a single transaction to access and modify multiple databases simultaneously.

      In real-world applications, specific business requirements may necessitate operations involving multiple databases. The introduction of cross-database transactions serves to address these needs. This functionality ensures that operations across different databases maintain consistency and isolation as executed within a single database. This means that when you need to perform a series of operations across multiple databases, you can wrap them within a single transaction, facilitating the completion of these operations while preserving data integrity and consistency.

      Cross-database transactions typically play a pivotal role in complex enterprise application scenarios. Different business functions or departments may use separate databases in these scenarios, yet they need to collaborate to fulfill intricate business requirements. MatrixOne's support for cross-database transactions enhances system flexibility and scalability. However, preserving data integrity and consistency also requires careful design and management.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#transaction-isolation-level-of-matrixone","title":"Transaction isolation level of MatrixOne","text":"

      MatrixOne supports two isolation levels: Read Committed and Snapshot Isolation. The default isolation level is Read Committed.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#read-committed","title":"Read Committed","text":"

      Read Committed is the default isolation level of MatrixOne after version 0.8, and it is also one of the four isolation levels in the SQL standard. Its most notable features are:

      • Between different transactions, only the data submitted by other transactions can be read, and the uncommitted data cannot be viewed.
      • The read-committed isolation level can effectively prevent dirty writes and dirty reads but cannot avoid non-repeatable reads and phantom reads.
      Isolation Level P0 Dirty Write P1 Dirty Read P4C Cursor Lost Update P4 Lost Update READ COMMITTED Not Possible Not Possible Possible Possible"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#snapshot-isolation","title":"Snapshot Isolation","text":"

      Different from the four isolation levels defined by the SQL standard, in MatrixOne, the supported isolation level is snapshot isolation (Snapshot Isolation), which is isolated in the REPEATABLE READ and SERIALIZABLE of the SQL-92 standard between. Different from other isolation levels, snapshot isolation has the following characteristics:

      • Snapshot isolation does not reflect changes made to data by other synchronized transactions for data read within a specified transaction. Specifies that the transaction uses the data rows read at the beginning of this transaction.

      • Data is not locked while being read, so snapshot transactions do not prevent other transactions from writing data.

      • Transactions that write data also do not block snapshot transactions from reading data.

      Compared with other isolation levels, snapshot isolation is also suitable for scenarios such as dirty reads (read uncommitted data), dirty writes (write uncommitted records after modification), phantom reads (multiple reads before and after, and the total amount of data is inconsistent) and other scenarios. Effective avoidance is achieved:

      Isolation Level P0 Dirty Write P1 Dirty Read P4C Cursor Lost Update P4 Lost Update P2 Fuzzy Read P3 Phantom A5A Read Skew A5B Write Skew MatrixOne's Snapshot Isolation Not Possible Not Possible Not Possible Not Possible Not Possible Not Possible Not Possible Possible"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/","title":"Pessimistic Transactions in MatrixOne","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#pessimistic-transactions-principle","title":"Pessimistic Transactions principle","text":"

      When a transaction starts, conflict detection or lock operation must be performed. When no conflict or lock is detected, a column in the data to be written will be regarded as the primary key column, the column will be locked, and a timestamp will be created. Writes to related rows after this timestamp are judged as write conflicts.

      Cache the current relevant data to the corresponding memory area, and add, delete, and modify the data. If there is a lock on the current table, it will enter the waiting state. When the waiting timeout occurs, the waiting transaction will be canceled.

      After the modification is completed, enter the commit phase, write data, record the timestamp at this time, and unlock the lock.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#pessimistic-transaction-model","title":"Pessimistic transaction model","text":"

      MatrixOne defaults to a pessimistic transaction.

      Pessimistic concurrent transactions are typically used in environments with high data contention. When you read a row using pessimistic concurrency, the row is not locked. When you want to update a row, the application must determine whether another user has locked the row.

      In the pessimistic concurrency model, if you receive a value from the database, another user will encounter a lock and enter a waiting state before you try to modify the value. After exceeding the transaction waiting time (5 minutes) set by MatrixOne, Waiting transactions will be forcibly canceled.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#deadlock","title":"Deadlock","text":"

      In a pessimistic transaction, there may be a situation where two or more transactions lock the resources needed by each other, making it impossible for each transaction to proceed. This situation is called dead. Only through human intervention in one of the transactions, for example, by manually Kill the session, can the deadlock be ended immediately; otherwise, the transaction can only wait for the maximum waiting time.

      An example of a deadlock is shown in the following figure:

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#example","title":"Example","text":"

      The following is an example of pessimistic concurrency, showing how MatrixOne resolves concurrency conflicts.

      1. At 1:00 PM, User 1 reads a row from the database with the following value:
      CustID LastName FirstName\n101 Smith Bob\n
      Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Bob Bob
      1. At 1:01 PM, User 2 reads the same row from the database.

      2. At 1:03 PM, User 2 changes the FirstName row from \"Bob\" to \"Robert\" and updates the database and the uncommitted state at this time.

        Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Robert Bob
      3. At 1:05 PM, User 1 changes the FirstName column from \"Bob\" to \"James\" and attempts to update it.

        Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob James Bob
      4. At this point, user 1 encounters a pessimistic concurrency conflict because the row where the value \"Robert\" in the database has been locked and needs to wait for user 2's next operation.

      5. At 1:06 PM, User 1 commits to the transaction. At this time, user 2 releases the waiting state and starts the transaction, but because the corresponding FirstName cannot be matched, the transaction update of user 2 fails.

      "},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/scenario/","title":"Transaction ascenarios in MatrixOne","text":"

      In a financial system, transfers between different users are prevalent scenarios. The actual operation of transfers in the database is usually two steps; first, after deducting the book value of one user and then to another, The user's account amount is increased. Only by using the atomicity of the transaction can we ensure that the total book funds have not changed. At the same time, the accounts between the two users have completed their deductions and increases. For example, user A transfers 50 to user B at this time:

      start transaction;\nupdate accounts set balance=balance-50 where name='A';\nupdate accounts set balance=balance+50 where name='B';\ncommit;\n

      When the two update are successful and finally submitted, the entire transfer is truly completed. The entire transaction must be rolled back if any step fails to ensure atomicity.

      In addition, during the transfer process of the two accounts, before committing, whether it is A or B, you see the book balance that has not been transferred, which is the transaction's isolation.

      During the transfer process, the database will check whether A's book funds are greater than 50 and whether A and B are indeed in the system. Only when these constraints are satisfied can the consistency of the transaction be guaranteed.

      After the transfer is completed, whether the system is restarted or not, the data has persisted, reflecting the persistence of the transaction.

      "},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/","title":"How to configure MatrixOne SSL connection","text":""},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#overview","title":"Overview","text":"

      This document describes how to configure your MatrixOne server to use SSL for database connections. After you secure your MatrixOne connections, malicious users cannot intercept your traffic.

      "},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#configure-matrixone-ssl-connections","title":"Configure MatrixOne SSL connections","text":""},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#create-the-directory-to-store-the-ssl-keys","title":"Create the directory to store the SSL keys","text":"

      To create the directory that will contain the SSL keys, perform the following steps:

      1. Log into your server via SSH. Check if you have the mysql_ssl_rsa_setup tool in place. Usually if you have installed MySQL, the mysql_ssl_rsa_setup binary will also be installed.

        If you try to execute this command mysql_ssl_rsa_setup and you see this following message, it means you have installed it. If not, please install MySQL first, and this mysql_ssl_rsa_setup will be installed along. You can also check the path of mysql_ssl_rsa_setup binary file with whereis mysql_ssl_rsa_setup.

        [pcusername@VM-0-12-centos matrixone]$ mysql_ssl_rsa_setup\n2022-10-19 10:57:30 [ERROR]   Failed to access directory pointed by --datadir. Please make sure that directory exists and is accessible by mysql_ssl_rsa_setup. Supplied value : /var/lib/mysql\n[pcusername@VM-0-12-centos matrixone]$ whereis mysql_ssl_rsa_setup\nmysql_ssl_rsa_setup: /usr/bin/mysql_ssl_rsa_setup /usr/share/man/man1/mysql_ssl_rsa_setup.1.gz\n
      2. Create an SSL key storage directory that MatrixOne can access. For example, run the mkdir /home/user/mo_keys command to create a mo_keys directory.

      "},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#create-the-ssl-keys","title":"Create the SSL keys","text":"

      To create the SSL keys, perform the following steps:

      1. Run the following commands to create the Certificate Authority (CA) keys:

        mysql_ssl_rsa_setup --datadir=/home/user/mo_keys\n

        You'll see in this folder a list of .pem files.

        /mo_keys \u251c\u2500\u2500 ca-key.pem \u251c\u2500\u2500 ca.pem \u251c\u2500\u2500 client-cert.pem \u251c\u2500\u2500 client-key.pem \u251c\u2500\u2500 private_key.pem \u251c\u2500\u2500 public_key.pem \u251c\u2500\u2500 server-cert.pem \u2514\u2500\u2500 server-key.pem

      2. Insert the following lines in the [cn.frontend] section of the etc /launch-with-proxy/cn.toml file in MatrixOne folder:

        [cn.frontend]\nenableTls = true\ntlsCertFile = \"/home/user/mo_keys/server-cert.pem\"\ntlsKeyFile = \"/home/user/mo_keys/server-key.pem\"\ntlsCaFile = \"/home/user/mo_keys/ca.pem\"\n

        If [cn.frontend] section doesn't exist in the MatrixOne system setting file, you can just create one with the above settings.

      "},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#test-the-ssl-configuration","title":"Test the SSL configuration","text":"

      To test the SSL configuration, perform the following steps:

      1. Launch MatrixOne service. Please refer to Deploy standalone MatrixOne.

      2. Connect to MatrixOne service by MySQL client:

        mysql -h IP_ADDRESS -P 6001 -uroot -p111\n
      3. After you connect, run the status command. The output will resemble the following example:

        mysql> status\n--------------\nmysql  Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)\n\nConnection id:      1001\nCurrent database:\nCurrent user:       root@0.0.0.0\nSSL:            Cipher in use is TLS_AES_128_GCM_SHA256\nCurrent pager:      stdout\nUsing outfile:      ''\nUsing delimiter:    ;\nServer version:     8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\nProtocol version:   10\nConnection:     127.0.0.1 via TCP/IP\nClient characterset:    utf8mb4\nServer characterset:    utf8mb4\nTCP port:       6002\nBinary data as:     Hexadecimal\n--------------\n
      "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/","title":"Connecting to MatrixOne with Golang","text":"

      MatrixOne supports Golang application connection, Go-MySQL-Driver is supported. This tutorial will walk you through how to connect MatrixOne with Golang.

      "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#before-you-start","title":"Before you start","text":"
      1. Make sure you have already installed and launched MatrixOne.
      2. Make sure you have already installed Golang 1.18 and plus.

        #To check with Golang installation and its version\ngo version\n
      3. Make sure you have already installed MySQL client.

      "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#using-golang-to-connect-to-matrixone","title":"Using Golang to connect to MatrixOne","text":"

      Go-MySQL-Driver is a MySQL driver for Go's (golang) database/sql package.

      1. Install go-mysql-driver tool. Simple install the package to your $GOPATH with the go tool from shell. Make sure Git is installed on your machine and in your system's PATH.

        > go get -u github.com/go-sql-driver/mysql\n
      2. Connect to MatrixOne by MySQL client. Create a new database named test.

        mysql> create database test;\n
      3. Create a plain text file golang_connect_matrixone.go and put the code below.

        package main\n\nimport (\n    \"database/sql\"\n    \"fmt\"\n    _ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc main() {\n    //\"username:password@[protocol](address:port)/database\"\n    db, _ := sql.Open(\"mysql\", \"root:111@tcp(127.0.0.1:6001)/test\") // Set database connection\n    defer db.Close()                                            //Close DB\n    err := db.Ping()                                            //Connect to DB\n    if err != nil {\n        fmt.Println(\"Database Connection Failed\")               //Connection failed\n        return\n    } else {\n        fmt.Println(\"Database Connection Succeed\")              //Connection succeed\n    }\n}\n
      4. Execute this golang file in the command line terminal.

        > go run golang_connect_matrixone.go\nDatabase Connection Succeed\n
      "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#using-gorm-to-connect-to-matrixone","title":"Using Gorm to connect to MatrixOne","text":"

      Gorm is the fantastic ORM library for Golang and aims to be developer-friendly. gorm.io/gorm and gorm.io/driver/mysql will make Go connect to MYSQL.

      1. Use command go get to install gorm.io/gorm and gorm.io/driver/mysql.

        go get -u gorm.io/gorm\ngo get -u gorm.io/driver/mysql\n
      2. Connect to MatrixOne by MySQL client. Create a new database named test.

        mysql> create database test;\n
      3. Create a go file golang_gorm_connect_matrixone.go and put the code below.

        package main\nimport (\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"fmt\"\n)\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO \ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ })\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\nfunc main() {\ngetDBConn()\n}\n
      4. Execute this go file in the command line terminal.

        > go run golang_gorm_connect_matrixone.go\nDatabase Connection Succeed\n
      "},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#reference","title":"Reference","text":"

      For the example about using Golang to build a simple CRUD with MatrixOne, see Build a simple Golang CRUD demo with MatrixOne.

      For the example about using Gorm to build a simple CRUD with MatrixOne, see Build a simple Gorm CRUD demo with MatrixOne.

      "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/","title":"Connecting to MatrixOne with Database Client Tool","text":"

      MatrixOne now supports the following Database client tools:

      • MySQL Client
      • Navicat
      • DBeaver
      "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#before-you-start","title":"Before you start","text":"

      Make sure you have already installed and launched MatrixOne.

      "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#connect-to-the-matrixone-server-through-mysql-client","title":"Connect to the MatrixOne Server through MySQL Client","text":"
      1. Download and install MySQL Client.

      2. Connect to the MatrixOne server.

        You can use the MySQL command-line client to connect to MatrixOne server:

        mysql -h IP -P PORT -uUsername -p\n

        The connection string is the same format as MySQL accepts. You need to provide a user name and a password.

        Use the built-in test account for example:

        • user: root
        • password: 111
        mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password:\n

        Info

        The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

        The successful result is as below:

        Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 1031\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\nCopyright (c) 2000, 2022, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n

      For more information on deployment, see Deployment FAQs.

      Note

      MatrixOne and the client use non-encrypted transmission by default. Refer to Data Transmission Encryption to enable encrypted transmission.

      "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#connect-to-the-matrixone-server-through-navicat","title":"Connect to the MatrixOne Server through Navicat","text":"
      1. Open a new terminal and enter into the following command:

        #Launch MatrixOne (Source code method)\n./mo-service -launch ./etc/launch/launch.toml\n
      2. Download and install Navicat.

      3. Open Navicat, click Connection > MySQL, and fill in the following parameters in the pop-up window:

        • Connction Name: MatrixOne
        • Host: 127.0.0.1
        • Port: 6001
        • User Name: root
        • Password: 111
        • Save password:Yes
      4. Click Save, save the configuration.

      5. To connect to the MatrixOne server, double-click MatrixOne in the database directory on the left.

      6. Once you connect to MatrixOne, you will see 6 default system databases.

        And on the right you will see the information about this connection.

      "},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#connect-to-the-matrixone-server-through-dbeaver","title":"Connect to the MatrixOne Server through DBeaver","text":"
      1. Download and install DBeaver.

      2. Open DBeaver, click Connection, select MySQL, then click Next.

        Fill in the following parameters in the pop-up window. Click Finish, save the configuration.

        • Host: 127.0.0.1
        • Port: 6001
        • Database: MatrixOne
        • User Name: root
        • Password: 111
        • Save password locally: Yes

      3. To connect to the MatrixOne server, double-click MatrixOne in the database navigation on the left. You will see the four default system databases.

      4. By default, views are not appearing in DBeaver. To show complete system databases, you need to right click on the MatrxiOne, select on Connection view and toggle on the Show system objects.

        Then you can see full 6 system databases.

      "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/","title":"Connecting to MatrixOne with Python","text":"

      MatrixOne supports Python connection, pymysql and sqlalchemy drivers are supported. This tutorial will walk you through how to connect MatrixOne by these two python drivers.

      "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#before-you-start","title":"Before you start","text":"
      1. Make sure you have already installed and launched MatrixOne.
      2. Make sure you have already installed Python 3.8(or plus) version.
      #To check with Python installation and its version\npython3 -V\n
      1. Make sure you have already installed MySQL.
      "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#using-python-pymysql-connect-to-matrixone","title":"Using Python pymysql connect to MatrixOne","text":"

      The PyMySQL is a pure-Python MySQL client library.

      1. Download and install pymysql and cryptography tool:

        pip3 install pymysql\npip3 install cryptography\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\n
      2. Connect to MatrixOne by MySQL client. Create a new database named test.

        mysql> create database test;\n
      3. Create a plain text file pymysql_connect_matrixone.py and put the code below.

        #!/usr/bin/python3\n\nimport pymysql\n\n# Open database connection\ndb = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        )\n# prepare a cursor object using cursor() method\ncursor = db.cursor()\n\n# execute SQL query using execute() method.\ncursor.execute(\"SELECT VERSION()\")\n\n# Fetch a single row using fetchone() method.\ndata = cursor.fetchone()\nprint (\"Database version : %s \" % data)\n\n# disconnect from server\ndb.close()\n
      4. Execute this python file in the command line terminal.

        > python3 pymysql_connect_matrixone.py\nDatabase version : 8.0.30-MatrixOne-v1.0.0-rc1\n
      "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#using-sqlalchemy-connect-to-matrixone","title":"Using sqlalchemy connect to MatrixOne","text":"

      SQLAlchemy is the Python SQL toolkit and Object Relational Mapper(ORM) that gives application developers the full power and flexibility of SQL.

      1. Download and install sqlalchemy tool:

        pip3 install sqlalchemy\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install sqlalchemy -i https://pypi.tuna.tsinghua.edu.cn/simple\n
      2. Connect to MatrixOne by MySQL client. Create a new database named test, a new table named student and insert two records.

        mysql> create database test;\nmysql> use test;\nmysql> create table student (name varchar(20), age int);\nmysql> insert into student values (\"tom\", 11), (\"alice\", \"10\");\n
      3. Create a plain text file sqlalchemy_connect_matrixone.py and put the code below,

        #!/usr/bin/python3\nfrom sqlalchemy import create_engine, text\n\n# Open database connection\nmy_conn = create_engine(\"mysql+mysqldb://root:111@127.0.0.1:6001/test\")\n\n# execute SQL query using execute() method.\nquery=text(\"SELECT * FROM student LIMIT 0,10\")\nmy_data=my_conn.execute(query)\n\n# print SQL result\nfor row in my_data:\n        print(\"name:\", row[\"name\"])\n        print(\"age:\", row[\"age\"])\n
      4. Execute this python file in the command line terminal.

        python3 sqlalchemy_connect_matrixone.py\nname: tom\nage: 11\nname: alice\nage: 10\n
      "},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#reference","title":"Reference","text":"

      For the example about using Python to build a simple CRUD with MatrixOne, see Build a simple Python+SQLAlchemy CRUD demo with MatrixOne and Build a simple Python CRUD demo with MatrixOne

      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/","title":"Connect MatrixOne with JDBC","text":"

      In Java, we can connect to MatrixOne with JDBC(Java Database Connectivity) through the Java code. JDBC is one of the standard APIs for database connectivity, using it we can easily run our query, statement, and also fetch data from the database.

      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/#before-you-start","title":"Before you start","text":"

      Prerequisite to understand Java Database Connectivity with MatrixOne, make sure you have installed these items as below:

      1. Make sure you have already installed and launched MatrixOne.
      2. Make sure you have already installed JDK 8+ version.
      3. Make sure you have already installed MySQL client.
      4. Make sure you have already installed JAVA IDE, this document uses IntelliJ IDEA as an example, you can also download other IDE.
      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/#steps","title":"Steps","text":"
      1. Connect to MatrixOne by MySQL client. Create a new database named test or other names you want in MatrixOne and create a new table named t1:

        create database test;\nuse test;\ncreate table t1\n(\ncode int primary key,\ntitle char(35)\n);\n
      2. Create a new Java project testJDBC in IDEA and select Maven as build system, then click on Create.

      3. Click on the File > Project Structure, enter into *Project Setting*, select and click Library, then click + button, add new project library From Maven**.

      4. Search library with mysql-connector-java, select mysql:mysql-connector-java:8.0.30, apply it to this project.

      5. Modify the default Java source code at src/main/java/org/example/Main.java. In general, the code below create a connection with the connection address and credentials, after connecting to MatrixOne, you can operate on MatrixOne database and tables by Java language.

        For a full example about how to develop a CRUD(Create, Read, Update, Delete) application in MatrixOne with JDBC, please refer to this JDBC CRUD tutorial.

        package org.example;\n\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.SQLException;\n\n\n\npublic class Main {\n\n\n    private static String jdbcURL = \"jdbc:mysql://127.0.0.1:6001/test\";\n    private static String jdbcUsername = \"root\";\n    private static String jdbcPassword = \"111\";\n\n    public static void main(String[] args) {\n\n\n        try {\n            Connection connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);\n            // Do something with the Connection\n\n        } catch (SQLException ex) {\n            // handle any errors\n            System.out.println(\"SQLException: \" + ex.getMessage());\n            System.out.println(\"SQLState: \" + ex.getSQLState());\n            System.out.println(\"VendorError: \" + ex.getErrorCode());\n        }\n    }\n}\n
      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/#reference","title":"Reference","text":"

      For a full list about MatrixOne's support for JDBC features, see JDBC supported features list in MatrixOne.

      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/","title":"Connect MatrixOne with Java ORMs","text":"

      Apart from connecting with JDBC, more typically, we'll connect to our MySQL database using an Object Relational Mapping (ORM) Framework. We will introduce how to connect to MatrixOne with Spring Data JPA and MyBatis in this article.

      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#mybatis","title":"MyBatis","text":"

      MyBatis was introduced in 2010 and is a SQL mapper framework with simplicity as its strength. We provide a full building CRUD application tutorial with MyBatis and Spring Boot. Here, we'll focus on how to configure MyBatis with MatrixOne connection.

      The below example is a typical setting with Maven build system.

      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#1-add-mybatis-spring-boot-starter-in-pomxml","title":"1. Add MyBatis-Spring-Boot-Starter in Pom.xml","text":"

      MyBatis applications are built on top of the Spring Boot. For that, you need to add this module to pom.xml which is created when you choose a Maven project.

      <dependency>\n    <groupId>org.mybatis.spring.boot</groupId>\n    <artifactId>mybatis-spring-boot-starter</artifactId>\n    <version>2.1.4</version>\n</dependency>\n
      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#2-add-configuration","title":"2. Add Configuration","text":"

      You need to store some of the given parameters inside the application.properties. Five properties usually need to be modified:

      • spring.datasource.driver-class-name : Driver name for MySQL connector.
      • spring.datasource.url: JDBC connection URL with its parameters.
      • spring.datasource.username: Database username.
      • spring.datasource.password: Database password.
      • mybatis.mapper-locations : Locations of Mapper XML config file.

      MatrixOne's recommended configuration is as below:

      spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\nspring.datasource.username=root\nspring.datasource.password=111\nmybatis.mapper-locations=classpath:mapping/*xml\n

      Note

      JDBC connection URL with recommended configuration is necessary, otherwise the connection will fail.

      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#spring-data-jpa","title":"Spring Data JPA","text":"

      Spring Data JPA is a robust framework that helps reduce boilerplate code and provides a mechanism for implementing basic CRUD operations via one of several predefined repository interfaces. We provide a full building CRUD application tutorial with Spring Data JPA and Spring Boot. We'll focus on how to configure Spring JPA with MatrixOne connection.

      The below example is a typical setting with Maven build system.

      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#1-add-spring-boot-starter-data-jpa-in-pomxml","title":"1. Add spring-boot-starter-data-jpa in Pom.xml","text":"

      Spring Data JPA applications are built on top of the Spring Boot. For that, you need to add this module to pom.xml which is created when you choose a Maven project.

      <dependency>\n    <groupId>org.springframework.boot</groupId>\n    <artifactId>spring-boot-starter-data-jpa</artifactId>\n</dependency>\n
      "},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#2-add-configuration_1","title":"2. Add Configuration","text":"

      You need to store some of the given parameters inside the application.properties. Five properties usually need to be modified:

      • spring.datasource.driver-class-name : Driver name for MySQL connector.
      • spring.datasource.url: JDBC connection URL with its parameters.
      • spring.datasource.username: Database username.
      • spring.datasource.password: Database password.
      • spring.jpa.properties.hibernate.dialect : The SQL dialect makes Hibernate generate better SQL for the chosen database. MatrixOne only supports org.hibernate.dialect.MySQLDialect.

      • spring.jpa.hibernate.ddl-auto:This property takes an enum that controls the schema generation in a more controlled way. The possible options and effects are in the following table. MatrixOne only supports none and validate.

      Option Effect none No database Schema initialization create Drops and creates the schema at the application startup. With this option, all your data will be gone on each startup. create-drop Creates schema at the startup and destroys the schema on context closure. Useful for unit tests. validate Only checks if the Schema matches the Entities. If the schema doesn't match, then the application startup will fail. Makes no changes to the database. update Updates the schema only if necessary. For example, If a new field was added in an entity, then it will simply alter the table for a new column without destroying the data.

      MatrixOne's recommended configuration is as below:

      spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\nspring.datasource.username=root\nspring.datasource.password=111\nspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect\nspring.jpa.hibernate.ddl-auto = validate\n
      "},{"location":"MatrixOne/Develop/export-data/modump/","title":"Export data by MODUMP","text":"

      There are two methods to export data with MatrixOne:

      • SELECT INTO...OUTFILE
      • mo-dump

      This document will introduce about how to export data with mo-dump.

      "},{"location":"MatrixOne/Develop/export-data/modump/#what-is-mo-dump","title":"What is mo-dump","text":"

      Like mysqldump, MatrixOne has a client utility tool called mo-dump that can perform backups of a MatrixOne database by exporting a \".sql\" file type that contains SQL statements can be executed to recreate the original database.

      To use the mo-dump tool, you must have access to a server running an instance of MatrixOne. You must also have user credentials with the required privileges for the database you want to export.

      "},{"location":"MatrixOne/Develop/export-data/modump/#syntax","title":"Syntax","text":"
      ./mo-dump -u ${user} -p ${password} -h ${host} -P ${port} -db ${database} [--local-infile=true] [-csv] [-tbl ${table}...] -net-buffer-length ${net-buffer-length} > {dumpfilename.sql}\n

      The parameters are as following:

      • -u [user]: It is a username to connect to the MatrixOne server. Only the users with database and table read privileges can use mo-dump utility. Default value: dump

      • -p [password]: The valid password of the MatrixOne user. Default value: 111

      • -h [host]: The host ip address of MatrixOne server. Default value: 127.0.0.1

      • -P [port]: The port of MatrixOne server. Default value: 6001

      • -db [database name]: Required parameter. Name of the database that you want to take backup.

      • -net-buffer-length [packet size]: Packet size, the total size of the characters in the SQL statement. The data packet is the basic unit of SQL exported data. If no parameter is set, the default is 1048576 Byte (1M), and the maximum can be set to 16777216 Byte (16M). If the parameter here is set to 16777216 Byte (16M), then when the data larger than 16M is to be exported, the data will be split into multiple 16M data packets, except for the last data packet, the size of other data packets is 16M.

      • -csv: The default value is false. The exported data is in CSV format when set to true.

      • --local-infile: The default value is true and only takes effect when the parameter -csv is set to true. Indicates support for native export of CSV files.

      • -tbl [table name]: Optional parameter. If the parameter is empty, the whole database will be exported. If you want to take the backup specific tables, then you can specify multiple -tbl and table names in the command.

      "},{"location":"MatrixOne/Develop/export-data/modump/#build-the-mo-dump-binary","title":"Build the mo-dump binary","text":"

      To use mo-dump utility, we need to build the tool first. mo-dump is embedded in the MatrixOne source code. You can build the binary from the source code.

      Tips: Same as MatrixOne mo-dump is written by Golang, building it will require a Golang installation and environment setting.

      1. Execute the following code to build the mo-dump binary from the MatrixOne source code:

        git clone https://github.com/matrixorigin/matrixone.git\ncd matrixone\nmake build modump\n
      2. Then you can find the mo-dump executable file in the MatrixOne folder.

      Note

      This built mo-dump file can also work in a same hardware platform. But a binary built in a x86 platform will not work correctly in a darwin ARM platform. The best practice is to build and use the binary file within the same operating system and hardware platform. mo-dump only supports Linux and macOS for now.

      "},{"location":"MatrixOne/Develop/export-data/modump/#steps-to-export-your-matrixone-database-using-mo-dump","title":"Steps to Export your MatrixOne Database using mo-dump","text":"

      mo-dump is easy to use with the command line. Here are the steps to take to export a complete database in the form of SQL commands:

      Open up a command line or terminal window on your computer, then verify that from this terminal you can connect to your MatrixOne instance, enter this command to export the database:

      ./mo-dump -u username -p password -h host_ip_address -P port -db database > exporteddb.sql\n

      For example, if you are launching the terminal in the same server as the MatrixOne instance, and you want to generate the backup of the single database, run the following command. The command will generate the backup of the \"t\" database with structure and data in the t.sql file. The t.sql file will be located in the same directory as your mo-dump executable.

      ./mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db t > t.sql\n

      If you want to export the tables in the database t to CSV format, refer to the following command:

      ./mo-dump -u root -p 111 -db t -csv --local-infile=false > ttt.csv\n

      If you want to generate the backup of a single table in a database, run the following command. The command will generate the backup of the t1 table of t database with structure and data in the t.sql file.

      ./mo-dump -u root -p 111 -db t -tbl t1 > t1.sql\n
      "},{"location":"MatrixOne/Develop/export-data/modump/#constraints","title":"Constraints","text":"
      • mo-dump only supports exporting the backup of a single database, if you have several databases to backup, you need to manually run mo-dump for several times.

      • mo-dump doesn't support exporting only the structure or data of databases. If you want to generate the backup of the data without the database structure or vise versa, you need to manually split the .sql file.

      "},{"location":"MatrixOne/Develop/export-data/select-into-outfile/","title":"Export data by SELECT INTO","text":"

      There are two methods to export data with MatrixOne:

      • SELECT INTO...OUTFILE
      • modump

      This document will introduce about how to export data with SELECT INTO...OUTFILE.

      SELECT...INTO OUTFILE statement exports a table data into a text file on the server host.

      "},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#syntax","title":"Syntax","text":"

      The syntax for this statement combines a regular SELECT command with INTO OUTFILE filename at the end. The default output format is the same as it is for the LOAD DATA command. So, the following statement exports the test table into /root/test as a tab-delimited, linefeed-terminated file.

      mysql> SELECT * FROM TEST\n    -> INTO OUTFILE '/root/test.csv';\n

      You can change the output format using various options to indicate how to quote and delimit columns and records. Using the following code to export the TEST table in a CSV format with CRLF-terminated lines:

      mysql> SELECT * FROM TEST INTO OUTFILE '/root/test.csv'\n   -> FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n   -> LINES TERMINATED BY '\\r\\n';\n

      The SELECT ... INTO OUTFILE has the following properties \u2212

      • The output file is created directly by the MatrixOne server, so the filename should indicate where you want the file to be written on the server host. MatrixOne doesn't support export the file to a client-side file system.
      • You must have the privilege to execute the SELECT ... INTO statement.
      • The output file must not already exist. This prevents MatrixOne from clobbering files that may be important.
      • You should have a login account on the server host or some way to retrieve the file from that host. Otherwise, the SELECT ... INTO OUTFILE command will most likely be of no value to you.
      "},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#example","title":"Example","text":""},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      Note

      If you install MatrixOne by docker, the directory is inside the docker image by default. To work with local directory, you need to bind a local directory to the container. In the following example, the local file system path ${local_data_path}/mo-data is binded to the MatrixOne docker image, with a mapping to the /mo-data path. For more information, see Docker Mount Volume tutorial.

      sudo docker run --name <name> --privileged -d -p 6001:6001 -v ${local_data_path}/mo-data:/mo-data:rw matrixorigin/matrixone:1.0.0-rc1\n
      "},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#steps","title":"Steps","text":"
      1. Create tables in MatrixOne:

        create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\ninsert into user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\nselect * from user;\n+------+-----------+------+\n| id   | user_name | sex  |\n+------+-----------+------+\n|    1 | weder     | man  |\n|    2 | tom       | man  |\n|    3 | wederTom  | man  |\n+------+-----------+------+\n
      2. For installation with source code or binary file, export the table to your local directory, for example, ~/tmp/export_demo/export_datatable.txt.

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

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

        select * from user into outfile 'mo-data/export_datatable.txt';\n
      3. Check the table in your directory export_datatable.txt, the result is as below:

        id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\n3,\"wederTom\",\"man\"\n
      "},{"location":"MatrixOne/Develop/import-data/delete-data/","title":"Delete Data","text":"

      This document describes how to delete data in MatrixOne using SQL statements.

      "},{"location":"MatrixOne/Develop/import-data/delete-data/#prerequisites","title":"Prerequisites","text":"

      Complete the Deploy standalone MatrixOne.

      "},{"location":"MatrixOne/Develop/import-data/delete-data/#sql-statements-for-deleting-data","title":"SQL Statements for Deleting Data","text":"

      You can delete data in three ways: DROP TABLE, TRUNCATE TABLE, and DELETE FROM.

      Here are the differences between them:

      • DELETE FROM: Use DELETE FROM to delete specific records.
      • TRUNCATE TABLE: Use TRUNCATE TABLE when you want to keep the table structure, indexes, and constraints intact, but delete all records.
      • DROP TABLE: Use DROP TABLE when you no longer need the table.
      "},{"location":"MatrixOne/Develop/import-data/delete-data/#delete","title":"DELETE","text":"
      DELETE FROM tbl_name [[AS] tbl_alias]\n    [WHERE where_condition]\n    [ORDER BY ...]\n    [LIMIT row_count]\n
      1. DELETE FROM tbl_name: Specifies the target table from which data will be deleted. tbl_name is the table name.

      2. [AS] tbl_alias (optional): You can use the AS keyword to assign a table alias (tbl_alias) to the target table. The alias is optional and used to simplify the query and reference the table in the statement.

      3. [WHERE where_condition] (optional): The WHERE clause specifies the conditions for deleting data. Only rows that satisfy the specified conditions will be deleted. where_condition is a logical expression that can use various comparisons and logical operators to define the conditions.

      4. [ORDER BY ...] (optional): The ORDER BY clause is used to sort the rows to be deleted based on specified columns. You can use one or more columns and specify ascending (ASC) or descending (DESC) order. The sorting affects the order of the deleted rows.

      5. [LIMIT row_count] (optional): The LIMIT clause limits the number of rows deleted from the table. It specifies the maximum number of rows (row_count) to be deleted. If the LIMIT clause is not specified, all rows satisfying the WHERE condition will be deleted.

      "},{"location":"MatrixOne/Develop/import-data/delete-data/#truncate","title":"TRUNCATE","text":"
      TRUNCATE [TABLE] table_name;\n

      The TRUNCATE statement deletes all data in a table while preserving the table structure. It quickly clears the table without deleting rows one by one.

      • [TABLE] (optional) is a keyword that provides more explicit syntax but can be omitted in most database systems.
      • table_name is the name of the target table.
      "},{"location":"MatrixOne/Develop/import-data/delete-data/#drop","title":"DROP","text":"
      DROP TABLE [IF EXISTS] [db.]name\n

      The DROP TABLE statement completely removes a table, including its structure and data, from the database.

      • [IF EXISTS] (optional) is a keyword that performs the deletion only if the table exists. An error will occur if omitted, and the table to be dropped does not exist.
      • [db.] (optional) specifies the database name where the table resides. If no database name is provided, the current database is assumed.
      • name is the name of the table to be dropped.
      "},{"location":"MatrixOne/Develop/import-data/delete-data/#garbage-collection","title":"Garbage Collection","text":"

      By default, MatrixOne does not immediately delete data from the disk after running DELETE, DROP, or TRUNCATE statements. Instead, it marks the data as deletable. Then, the GC (Garbage Collection) mechanism periodically scans and cleans up the no longer-needed old data.

      By default, the garbage collection mechanism scans every 30 minutes. During each scan, it identifies data deleted through SQL statements for over 1 hour and starts the cleanup process to release disk space. The most extended cycle to complete all deletions is 90 minutes. Therefore, it is essential to note that executing DELETE, DROP, or TRUNCATE statements do not immediately reduce disk usage. Only data marked as deletable during the garbage collection will be cleaned up, and disk space will be freed.

      "},{"location":"MatrixOne/Develop/import-data/delete-data/#examples","title":"Examples","text":"
      • Example 1
      -- Create table\nCREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ndepartment VARCHAR(50)\n);\n\n-- Insert data\nINSERT INTO employees (id, name, department)\nVALUES (1, 'John Doe', 'HR'),\n(2, 'Jane Smith', 'Marketing'),\n(3, 'Mike Johnson', 'IT'),\n(4, 'Emily Brown', 'Finance');\n\n-- View initial data\nmysql> SELECT * FROM employees;\n+------+--------------+------------+\n| id   | name         | department |\n+------+--------------+------------+\n|    1 | John Doe     | HR         |\n|    2 | Jane Smith   | Marketing  |\n|    3 | Mike Johnson | IT         |\n|    4 | Emily Brown  | Finance    |\n+------+--------------+------------+\n4 rows in set (0.01 sec)\n\n-- Delete partial data\nmysql> DELETE FROM employees WHERE department = 'IT';\nQuery OK, 1 row affected (0.01 sec)\n\n-- View data after the deletion\nmysql> SELECT * FROM employees;\n+------+-------------+------------+\n| id   | name        | department |\n+------+-------------+------------+\n|    1 | John Doe    | HR         |\n|    2 | Jane Smith  | Marketing  |\n|    4 | Emily Brown | Finance    |\n+------+-------------+------------+\n3 rows in set (0.00 sec)\n
      • Example 2
      -- Create table\nCREATE TABLE orders (\norder_id INT PRIMARY KEY,\ncustomer_name VARCHAR(50),\norder_date DATE\n);\n\n-- Insert data\nINSERT INTO orders (order_id, customer_name, order_date)\nVALUES (1, 'John Doe', '2022-01-01'),\n(2, 'Jane Smith', '2022-02-01'),\n(3, 'Mike Johnson', '2022-03-01'),\n(4, 'Emily Brown', '2022-04-01'),\n(5, 'David Wilson', '2022-05-01');\n\n-- View initial data\nmysql> SELECT * FROM orders;\n+----------+---------------+------------+\n| order_id | customer_name | order_date |\n+----------+---------------+------------+\n|        1 | John Doe      | 2022-01-01 |\n|        2 | Jane Smith    | 2022-02-01 |\n|        3 | Mike Johnson  | 2022-03-01 |\n|        4 | Emily Brown   | 2022-04-01 |\n|        5 | David Wilson  | 2022-05-01 |\n+----------+---------------+------------+\n5 rows in set (0.01 sec)\n\n-- Delete the earliest two orders\nmysql> DELETE FROM orders\nWHERE order_id IN (\nSELECT order_id\nFROM orders\nORDER BY order_date\nLIMIT 2);\nQuery OK, 2 rows affected (0.01 sec)\n\n-- View data after the deletion\nmysql> SELECT * FROM orders;\n+----------+---------------+------------+\n| order_id | customer_name | order_date |\n+----------+---------------+------------+\n|        3 | Mike Johnson  | 2022-03-01 |\n|        4 | Emily Brown   | 2022-04-01 |\n|        5 | David Wilson  | 2022-05-01 |\n+----------+---------------+------------+\n3 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Develop/import-data/insert-data/","title":"Insert Data","text":"

      This document describes how to insert data into MatrixOne by using the SQL language.

      "},{"location":"MatrixOne/Develop/import-data/insert-data/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      "},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into-statement","title":"INSERT INTO Statement","text":"

      It is possible to write the INSERT INTO statement in several ways:

      1. Specify both the column names and the values to be inserted:

        INSERT INTO tbl_name (a,b,c) VALUES (1,2,3);\n
      2. If you add values for all the table columns, you do not need to specify the column names in the SQL query. However, make sure the values' order is in the same order as the columns in the table. Here, the INSERT INTO syntax would be as follows:

        INSERT INTO tbl_name VALUES (1,2,3);\n
      3. INSERTstatements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of comma-separated column values, with lists enclosed within parentheses and separated by commas. Example:

        INSERT INTO tbl_name (a,b,c) VALUES(1,2,3), (4,5,6), (7,8,9);\n
      "},{"location":"MatrixOne/Develop/import-data/insert-data/#demo-database","title":"Demo Database","text":"

      Below is a selection from the \"Customers\" table in the Northwind sample database:

      CREATE TABLE Customers (\n  CustomerID INT AUTO_INCREMENT NOT NULL,\n  CustomerName VARCHAR(40) NOT NULL,\n  ContactName VARCHAR(30) NULL,\n  Address VARCHAR(60) NULL,\n  City VARCHAR(15) NULL,\n  PostalCode VARCHAR(10) NULL,\n  Country VARCHAR(15) NULL,\n  PRIMARY KEY (CustomerID)\n  );\n
      CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into-example","title":"INSERT INTO Example","text":"

      The following SQL statement inserts a new record in the \"Customers\" table:

      "},{"location":"MatrixOne/Develop/import-data/insert-data/#example","title":"Example","text":"
      INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)\nVALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');\n

      The selection from the \"Customers\" table will now look like this:

      CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland 92 Cardinal Tom B. Erichsen Skagen 21 Stavanger 4006 Norway"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-data-only-in-specified-columns","title":"Insert Data Only in Specified Columns","text":"

      It is also possible to only insert data in specific columns.

      "},{"location":"MatrixOne/Develop/import-data/insert-data/#example_1","title":"Example","text":"

      The following SQL statement will insert a new record, but only insert data in the \"CustomerName\", \"City\", and \"Country\" columns (CustomerID will be updated automatically):

      INSERT INTO Customers (CustomerName, City, Country)\nVALUES ('Cardinal', 'Stavanger', 'Norway');\n

      The selection from the \"Customers\" table will now look like this:

      CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland 92 Cardinal null null Stavanger null Norway"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-intoselect","title":"INSERT INTO...SELECT","text":"

      With INSERT INTO SELECT, you can quickly insert many rows into a table from the result of a SELECT statement, which can select from one or many tables. The INSERT INTO SELECT statement requires that the data types in source and target tables match.

      "},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into-select-syntax","title":"INSERT INTO SELECT Syntax","text":"

      Copy all columns from one table to another table:

      INSERT INTO *table2*\nSELECT * FROM *table1\n*WHERE *condition*;\n

      Copy only some columns from one table into another table:

      INSERT INTO *table2* (*column1*, *column2*, *column3*, ...)\nSELECT *column1*, *column2*, *column3*, ...\nFROM *table1*\nWHERE *condition*;\n
      "},{"location":"MatrixOne/Develop/import-data/insert-data/#northwind-sample-database","title":"Northwind sample database","text":"

      In this tutorial we will use the Northwind sample database.

      CREATE TABLE Customers (\n  CustomerID INT AUTO_INCREMENT NOT NULL,\n  CustomerName VARCHAR(40) NOT NULL,\n  ContactName VARCHAR(30) NULL,\n  Address VARCHAR(60) NULL,\n  City VARCHAR(15) NULL,\n  PostalCode VARCHAR(10) NULL,\n  Country VARCHAR(15) NULL,\n  PRIMARY KEY (CustomerID)\n  );\nCREATE TABLE Suppliers (\n  SupplierID INT AUTO_INCREMENT NOT NULL,\n  SupplierName VARCHAR(40) NOT NULL,\n  ContactName VARCHAR(30) NULL,\n  Address VARCHAR(60) NULL,\n  City VARCHAR(15) NULL,\n  PostalCode VARCHAR(10) NULL,\n  Country VARCHAR(15) NULL,\n  PRIMARY KEY (SupplierID)\n  );\n

      Below is a selection from the \"Customers\" table:

      CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constituci\u00f3n 2222 M\u00e9xico D.F. 05021 Mexico 3 Antonio Moreno Taquer\u00eda Antonio Moreno Mataderos 2312 M\u00e9xico D.F. 05023 Mexico

      And a selection from the \"Suppliers\" table:

      SupplierID SupplierName ContactName Address City PostalCode Country 1 Exotic Liquid Charlotte Cooper 49 Gilbert St. Londona EC1 4SD UK 2 New Orleans Cajun Delights Shelley Burke P.O. Box 78934 New Orleans 70117 USA 3 Grandma Kelly's Homestead Regina Murphy 707 Oxford Rd. Ann Arbor 48104 USA"},{"location":"MatrixOne/Develop/import-data/insert-data/#example_2","title":"Example","text":"

      The following SQL statement copies \"Suppliers\" into \"Customers\" (the columns that are not filled with data, will contain NULL):

      INSERT INTO Customers (CustomerName, City, Country)\nSELECT SupplierName, City, Country FROM Suppliers;\n

      The selection from the \"Customers\" table will now look like this:

      CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constituci\u00f3n 2222 M\u00e9xico D.F. 05021 Mexico 3 Antonio Moreno Taquer\u00eda Antonio Moreno Mataderos 2312 M\u00e9xico D.F. 05023 Mexico 4 Exotic Liquid null null Londona null UK 5 New Orleans Cajun Delights null null New Orleans null USA 6 Grandma Kelly's Homestead null null Ann Arbor null USA"},{"location":"MatrixOne/Develop/import-data/prepared/","title":"Prepared","text":"

      MatrixOne provides support for server-side prepared statements. This support takes advantage of the efficient client/server binary protocol. Using prepared statements with placeholders for parameter values has the following benefits:

      Less overhead for parsing the statement each time it is executed. Typically, database applications process large volumes of almost-identical statements, with only changes to literal or variable values in clauses such as WHERE for queries and deletes, SET for updates, and VALUES for inserts.

      Protection against SQL injection attacks. The parameter values can contain unescaped SQL quote and delimiter characters.

      "},{"location":"MatrixOne/Develop/import-data/prepared/#prepare-execute-and-deallocate-prepare-statements","title":"PREPARE, EXECUTE, and DEALLOCATE PREPARE Statements","text":"

      SQL syntax for prepared statements is based on three SQL statements:

      • PREPARE prepares a statement for execution.

      • EXECUTE executes a prepared statement.

      • DEALLOCATE PREPARE releases a prepared statement.

      "},{"location":"MatrixOne/Develop/import-data/prepared/#create-a-prepared-statement","title":"Create a prepared statement","text":"
      PREPARE stmt_name FROM preparable_stmt\n
      Arguments Description stmt_name The name of the prepared statement. preparable_stmt a string literal or a user variable that contains the text of the SQL statement. The text must represent a single statement, not multiple statements."},{"location":"MatrixOne/Develop/import-data/prepared/#executes-a-prepared-statement","title":"Executes a prepared statement","text":"
      EXECUTE stmt_name [USING @var_name [, @var_name] ...]\n
      Arguments Description stmt_name The name of the prepared statement."},{"location":"MatrixOne/Develop/import-data/prepared/#delete-a-prepared-statement","title":"Delete a prepared statement","text":"
      {DEALLOCATE | DROP} PREPARE stmt_name\n
      Arguments Description stmt_name The name of the prepared statement."},{"location":"MatrixOne/Develop/import-data/prepared/#example","title":"Example","text":"
      -- Create table\nCREATE TABLE customers (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nemail VARCHAR(50)\n);\n\n-- Insert data\nINSERT INTO customers (id, name, email)\nVALUES (1, 'John Doe', 'john@example.com'),\n(2, 'Jane Smith', 'jane@example.com'),\n(3, 'Mike Johnson', 'mike@example.com');\n\n-- Prepare statement\nmysql> PREPARE stmt FROM 'SELECT * FROM customers WHERE id = ?';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Execute prepared statement\nmysql> SET @id = 2;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> EXECUTE stmt USING @id;\n+------+------------+------------------+\n| id   | name       | email            |\n+------+------------+------------------+\n|    2 | Jane Smith | jane@example.com |\n+------+------------+------------------+\n1 row in set (0.01 sec)\n\n-- Deallocate statement\nmysql> DEALLOCATE PREPARE stmt;\nQuery OK, 0 rows affected (0.00 sec)\n

      The above example begins by creating a table named customers with three columns: id, name, and email. Next, three rows of data are inserted into the table.

      Then, the PREPARE statement is used to prepare a statement, and the SELECT * FROM customers WHERE id = ? query is stored in the stmt variable.

      When executing the prepared statement, the @id variable is set to 2, and the EXECUTE statement is used to execute the prepared statement with the @id parameter.

      Finally, the DEALLOCATE PREPARE statement is used to deallocate the prepared statement and free up the associated resources.

      "},{"location":"MatrixOne/Develop/import-data/update-data/","title":"Update Data","text":"

      This document describes how to update data in MatrixOne using SQL statements.

      "},{"location":"MatrixOne/Develop/import-data/update-data/#prerequisites","title":"Prerequisites","text":"

      Single-node deployment of MatrixOne has been completed.

      "},{"location":"MatrixOne/Develop/import-data/update-data/#sql-statements-for-updating-data","title":"SQL Statements for Updating Data","text":"

      There are two ways to update data: UPDATE and INSERT ON DUPLICATE KEY UPDATE.

      The differences between the two are as follows:

      • UPDATE:

        • The UPDATE statement is used to update existing rows of data directly.
        • You need to specify the target table, columns to be updated, their corresponding new values, and the update conditions.
        • If the update conditions are met, the data of the existing rows will be modified.
        • No changes will be made if the update conditions are not met.
      • INSERT ON DUPLICATE KEY UPDATE:

        • INSERT ON DUPLICATE KEY UPDATE is an extension of the INSERT statement, used to handle duplicate keys when inserting new rows.
        • When there are duplicate keys in the inserted data, i.e., when the values of specific column(s) or combination of columns are the same as existing rows' key values, an UPDATE operation will be performed instead of inserting a new row.
        • You can specify the data to be inserted and the update operations to be performed when duplicate key conflicts occur in a single statement.
        • The specified update operations will update the corresponding columns for rows with duplicate keys.

      Key Differences:

      • The UPDATE statement is used to directly update existing rows, while the INSERT ON DUPLICATE KEY UPDATE statement is used to handle duplicate keys when inserting data.
      • The UPDATE statement requires you to specify the target table, columns to be updated, their corresponding new values, and the update conditions. The INSERT ON DUPLICATE KEY UPDATE statement allows you to specify the data to be inserted and the update operations in a single statement.
      "},{"location":"MatrixOne/Develop/import-data/update-data/#update","title":"UPDATE","text":"
      UPDATE table_reference\n    SET assignment_list\n    [WHERE where_condition]\n    [ORDER BY ...]\n    [LIMIT row_count]\n
      1. UPDATE table_reference: Specifies the target table for updating data. The table_reference can be a single table or multiple tables joined together.

      2. SET assignment_list: Specifies the columns and values to be updated. The assignment_list lists column names and their corresponding values, separated by commas. Each column name is followed by an equal sign (=) to associate it with the new value to be updated.

      3. [WHERE where_condition] (optional): The WHERE clause is used to specify the conditions for updating data. Only rows that satisfy the specified conditions will be updated. where_condition is a logical expression that can define conditions using various comparisons and logical operators.

      4. [ORDER BY ...] (optional): The ORDER BY clause is used to sort the rows to be updated based on the specified columns. You can use one or more columns and specify ascending (ASC) or descending (DESC) order. The sorting will affect the order of the updated rows.

      5. [LIMIT row_count] (optional): The LIMIT clause limits the number of rows to be updated. It specifies the maximum number of rows (row_count) to be updated. If the LIMIT clause is not specified, all rows that satisfy the WHERE condition will be updated.

      During the data update process, specify the target table, the columns and values to be updated, the update conditions, and optionally, the sorting and limiting parameters to perform flexible data updates according to your requirements.

      "},{"location":"MatrixOne/Develop/import-data/update-data/#insert-on-duplicate-key-update","title":"INSERT ON DUPLICATE KEY UPDATE","text":"
      > INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n  [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...];\n
      1. INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...
      2. The INSERT INTO statement inserts new rows into a table.
      3. [db.] (optional) specifies the database name where the table is located. If not provided, the default is the current database.
      4. table is the name of the target table where the data will be inserted.
      5. [(c1, c2, c3)] (optional) specifies the columns to be inserted, enclosed in parentheses and separated by commas. If column names are not specified, it is assumed that all available columns in the table will be inserted.
      6. The VALUES clause specifies the values to be inserted. Each value corresponds to its respective column and is separated by commas and enclosed in parentheses. Multiple rows of data can be inserted, with each row separated by commas.

      7. [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...]

      8. The ON DUPLICATE KEY UPDATE clause handles duplicate keys when inserting data.
      9. When there are duplicate keys in the inserted data, i.e., when the values of specific column(s) or combination of columns are the same as existing rows' key values, an UPDATE operation will be performed instead of inserting a new row.
      10. column1, column2, column3 represent the column names to be updated, and value1, value2, value3 represent the corresponding values to be updated.

      This syntax allows you to insert one or multiple rows of data into the specified table.

      . If a duplicate key situation occurs, i.e., a row with the same key value already exists, an UPDATE operation is executed to update that row's data.

      When using the INSERT INTO statement, provide the corresponding column names and values based on the table structure and requirements. If duplicate keys are encountered, and the ON DUPLICATE KEY UPDATE clause is used, specify the columns to be updated and their corresponding values.

      "},{"location":"MatrixOne/Develop/import-data/update-data/#examples","title":"Examples","text":"
      • Example 1: UPDATE
      -- Create table\nCREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ndepartment VARCHAR(50),\nsalary DECIMAL(10, 2)\n);\n\n-- Insert data\nINSERT INTO employees (id, name, department, salary)\nVALUES (1, 'John Doe', 'HR', 5000),\n(2, 'Jane Smith', 'Marketing', 6000),\n(3, 'Mike Johnson', 'IT', 7000),\n(4, 'Emily Brown', 'Finance', 8000),\n(5, 'David Wilson', 'HR', 5500);\n\n-- View initial data\nmysql> SELECT * FROM employees;\n+------+--------------+------------+---------+\n| id   | name         | department | salary  |\n+------+--------------+------------+---------+\n|    1 | John Doe     | HR         | 5000.00 |\n|    2 | Jane Smith   | Marketing  | 6000.00 |\n|    3 | Mike Johnson | IT         | 7000.00 |\n|    4 | Emily Brown  | Finance    | 8000.00 |\n|    5 | David Wilson | HR         | 5500.00 |\n+------+--------------+------------+---------+\n5 rows in set (0.01 sec)\n\n-- Update data using the UPDATE statement. The salary of the first two employees in the 'HR' department is increased by 10%. The WHERE clause specifies the condition for updating the data; only rows with the department 'HR' will be updated. The ORDER BY clause sorts the rows by the id column in ascending order, and the LIMIT clause limits the update to only two rows.\nmysql> UPDATE employees\nSET salary = salary * 1.1\nWHERE department = 'HR'\nORDER BY id\nLIMIT 2;\nQuery OK, 2 rows affected (0.02 sec)\n\n-- View updated data\nmysql> SELECT * FROM employees;\n+------+--------------+------------+---------+\n| id   | name         | department | salary  |\n+------+--------------+------------+---------+\n|    2 | Jane Smith   | Marketing  | 6000.00 |\n|    3 | Mike Johnson | IT         | 7000.00 |\n|    4 | Emily Brown  | Finance    | 8000.00 |\n|    1 | John Doe     | HR         | 5500.00 |\n|    5 | David Wilson | HR         | 6050.00 |\n+------+--------------+------------+---------+\n5 rows in set (0.00 sec)\n
      • Example 2: INSERT ... ON DUPLICATE KEY UPDATE
      -- Create table\nCREATE TABLE students (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nage INT,\ngrade VARCHAR(10)\n);\n\n-- Insert data\nINSERT INTO students (id, name, age, grade)\nVALUES (1, 'John Doe', 18, 'A'),\n(2, 'Jane Smith', 17, 'B'),\n(3, 'Mike Johnson', 19, 'A'),\n(4, 'Emily Brown', 18, 'A');\n\n-- View initial data\nmysql> SELECT * FROM students;\n+------+--------------+------+-------+\n| id   | name         | age  | grade |\n+------+--------------+------+-------+\n|    1 | John Doe     |   18 | A     |\n|    2 | Jane Smith   |   17 | B     |\n|    3 | Mike Johnson |   19 | A     |\n|    4 | Emily Brown  |   18 | A     |\n+------+--------------+------+-------+\n4 rows in set (0.01 sec)\n\n-- Update data\nmysql> INSERT INTO students (id, name, age, grade)\nVALUES (2, 'Jane Smith', 18, 'A')\nON DUPLICATE KEY UPDATE age = VALUES(age), grade = VALUES(grade);\nQuery OK, 1 row affected (0.01 sec)\n\n-- View updated data\nmysql> SELECT * FROM students;\n+------+--------------+------+-------+\n| id   | name         | age  | grade |\n+------+--------------+------+-------+\n|    1 | John Doe     |   18 | A     |\n|    3 | Mike Johnson |   19 | A     |\n|    4 | Emily Brown  |   18 | A     |\n|    2 | Jane Smith   |   18 | A     |\n+------+--------------+------+-------+\n4 rows in set (0.00 sec)\n

      In the above examples, a table named students is first created with four columns: id, name, age, and grade. Then, four rows of student data are inserted using the INSERT INTO statement.

      Next, the initial data is viewed using a SELECT statement. Then, an INSERT INTO statement is used to insert a new row of student data where the student with id 2 already exists, causing a duplicate key situation. In this case, the ON DUPLICATE KEY UPDATE clause is used to update that row's data. The columns to be updated, and their corresponding values are specified using the VALUES function.

      Finally, the updated data is viewed again using a SELECT statement, showing that the age and grade of the student with id 2 have been updated.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/","title":"Load data from S3","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#overview","title":"Overview","text":"

      S3 (Simple Storage Service) object storage refers to Amazon's Simple Storage Service. You can also store almost any type and size of data with S3-compatible object storage, including data lakes, cloud-native applications, and mobile apps. If you are unfamiliar with S3 object service, you may look up some basic introductions in AWS.

      AWS S3 has been remarkably successful for over a decade, so it became the de facto standard for object storage. Thus almost every mainstream public cloud vendors provide an S3-compatible object storage service.

      MatrixOne supports loading files from S3-compatible object storage services into databases. MatrixOne supports AWS and mainstream cloud vendors in China (Alibaba Cloud, Tencent Cloud).

      In MatrixOne, there are two methods to import the data from S3-compatible object storage:

      • Use Load data with an s3option to load the file into MatrixOne. This method will load the data into MatrixOne, and all next queries will happen inside MatrixOne.
      • Create an external table with an s3option mapping to an S3 file, and query this external table directly. This method allows data access through an S3-compatible object storage service; each query's networking latency will be counted.

      When importing data from public clouds like AWS S3 or Alibaba Cloud OSS, the appropriate access permissions are required. Generally, there are two methods to choose from: role-based access and key-based access.

      • Role-Based Access: This involves creating a specific role within the public cloud account where the data is stored. This role is authorized to grant MatrixOne applications the necessary data access permissions. This approach is more secure and offers greater ease in managing and adjusting data access permissions.

      • Key-Based Access: Data can be accessed using the Access Key ID and Secret Access Key of a user with the required data access permissions. While this method is relatively straightforward, it is less secure because exposing the Access Key ID and Secret Access Key could lead to severe consequences.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#method-1-load-data","title":"Method 1: LOAD DATA","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#syntax","title":"Syntax","text":"
      LOAD DATA\n| URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"role_arn\"='xxxx', \"external_id\"='yyy', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n[ESCAPED BY 'char']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n

      Parameter Description

      Parameter Description endpoint The URL that can connect to the object storage service. For example: s3.us-west-2.amazonaws.com Note: LOAD DATA supports only URLs for AWS object storage services and Alibaba Cloud external object storage services. access_key_id Access key ID used for authentication. secret_access_key Secret access key associated with the access key ID. bucket Specifies the bucket in S3 storage. role_arn The Amazon Resource Name (ARN) of an AWS role, typically used for cross-account access. Note: It is recommended to use role-based access. If you choose role-based access, you do not need to fill in access_key_id and secret_access_key. Only the role_arn parameter needs to be provided. external_id An external ID used in conjunction with the role ARN. filepath relative file path. regex expression is supported as /files/*.csv. region object storage service region compression Compressed format of S3 files. If empty or \"none\", it indicates uncompressed files. Supported fields or Compressed format are \"auto\", \"none\", \"gzip\", \"bz2\", and \"lz4\".

      The other paramaters are identical to a ordinary LOAD DATA, see LOAD DATA for more details.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#statement-examples","title":"Statement Examples","text":"
      • Role-Based Access
      # LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"bucket\"='test-load-mo', \"role_arn\"='xxxx', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"bucket\"='test-load-data', \"role_arn\"='xxxx', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
      • Key-Based Access
      # LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-mo', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-data', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD a csv file from Tencent Cloud COS Shanghai region, test-1252279971 bucket, without bz2 compression\nLOAD DATA URL s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n

      Note

      MatrixOne provides security assurance for S3 authentication information, such as access_key_id and secret_access_key sensitive information will be hidden in the system table (statement_info) records to ensure your account security.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#tutorial-load-a-file-from-aws-s3","title":"Tutorial: Load a file from AWS S3","text":"

      In this tutorial, we will walk you through the process of loading a .csv file from AWS S3; we assume that you already have an AWS account and already have your data file ready in your S3 service. If you do not already have that, please sign up and upload your data file first; you may check on the AWS S3 official tutorial. The process for Alibaba Cloud OSS and Tencent Cloud COS is similar to AWS S3.

      Note

      This code example does not show account information such as access_key_id and secret_access_key because of account privacy. You can read this document to understand the main steps; specific data and account information will not be shown.

      1. Enter into AWS S3 > buckets > Create bucket, create a bucket test-loading with a public access and upload the file char_varchar_1.csv.

      2. Get or create your AWS api key. Enter into Your Account Name > Security Credentials.

        • Method 1 - Role-Based Access (Recommended): To obtain your ARN, navigate to Security Credentials:

        • Method 2 - Key-Based Access (Not Recommended): To get your existing Access Key or create a new one. If you can't access your AWS Access key, you can contact your AWS administrator.

        Within Security Credentials > Create access key, you can obtain the Access key and Secret access key either from the downloaded credentials or from this web page.

      3. Launch the MySQL Client, create tables in MatrixOne, for example:

        create database db;\nuse db;\ndrop table if exists t1;\ncreate table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
      4. Import the file into MatrixOne:

        • Method 1 - Role-Based Access (Recommended):
        LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"bucket\"='test-loading', \"role_arn\"='xxxx\", \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
        • Method 2 - Key-Based Access (Not Recommended)
        LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
      5. After the import is successful, you can run SQL statements to check the result of imported data:

        mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa,aa     | bb,bb     | cc,cc     | dd,dd     |\n| aa,       | bb,       | cc,       | dd,       |\n| aa,,,aa   | bb,,,bb   | cc,,,cc   | dd,,,dd   |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\",aa    | bb\",bb    | cc\",cc    | dd\",dd    |\n| aa\"\",aa   | bb\"\",bb   | cc\"\",cc   | dd\"\",dd   |\n|           |           |           |           |\n|           |           |           |           |\n| NULL      | NULL      | NULL      | NULL      |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n21 rows in set (0.03 sec)\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#method-2-specify-s3-file-to-an-external-table","title":"Method 2: Specify S3 file to an external table","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#syntax_1","title":"Syntax","text":"
      create external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}     [{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[IGNORE number {LINES | ROWS}];\n

      Note

      MatrixOne only supports select on external tables. Delete, insert, and update are not supported.

      Parameter Description

      Parameter Description endpoint A endpoint is a URL that can conncect to object storage service. For example: s3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 Bucket to access filepath relative file path. regex expression is supported as /files/*.csv. region object storage service region compression Compressed format of S3 files. If empty or \"none\", it indicates uncompressed files. Supported fields or Compressed format are \"auto\", \"none\", \"gzip\", \"bz2\", and \"lz4\".

      The other paramaters are identical to a ordinary LOAD DATA, see LOAD DATA for more details.

      For more information about External Table, see CREATE EXTERNAL TABLE.

      Statement Examples:

      ## Create a external table for a .csv file from AWS S3\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n\n## Create a external table for a .csv file compressed with BZIP2 from Tencent Cloud\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n' ignore 1 lines;\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#tutorial-create-an-external-table-with-s3-file","title":"Tutorial: Create an external table with S3 file","text":"

      This tutorial will walk you through the whole process of creating an external table with a .csv file from AWS S3.

      Note

      This code example does not show account information such as access_key_id and secret_access_key because of account privacy. You can read this document to understand the main steps; specific data and account information will not be shown.

      1. Download the data file. Enter into AWS S3 > buckets, create a bucket test-loading with a public access and upload the file char_varchar_1.csv.

      2. Get or create your AWS api key. Enter into Your Account Name > Security Credentials, get your existing Access Key or create a new one.

        You can get the access key id and secret access key from the downloaded credentials or this webpage.

      3. Launch the MySQL Client, and specify the S3 file to an external table:

        create database db;\nuse db;\ndrop table if exists t1;\ncreate external table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n
      4. After the import is successful, you can run SQL statements to check the result of the imported data. You can see that the query speed is significantly slower than querying from a local table.

        select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa,aa     | bb,bb     | cc,cc     | dd,dd     |\n| aa,       | bb,       | cc,       | dd,       |\n| aa,,,aa   | bb,,,bb   | cc,,,cc   | dd,,,dd   |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\",aa    | bb\",bb    | cc\",cc    | dd\",dd    |\n| aa\"\",aa   | bb\"\",bb   | cc\"\",cc   | dd\"\",dd   |\n|           |           |           |           |\n|           |           |           |           |\n| NULL      | NULL      | NULL      | NULL      |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n21 rows in set (1.32 sec)\n
      5. (Optional)If you need to import external table data into a data table in MatrixOne, you can use the following SQL statement:

        Create a new table t2 in MatrixOne:

        create table t2(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n

        Import the external table t1 to t2:

        insert into t2 select * from t1;\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/","title":"Bulk Load Overview","text":"

      MatrixOne supports using the LOAD DATA command to insert many rows into MatrixOne tables and the SOURCE command to import table structures and data into the entire database.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#load-data","title":"LOAD DATA","text":"

      MatrixOne supports the LOAD DATA command for importing csv and jsonline files from either the local file system or S3-compatible object storage.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#import-the-different-file-types","title":"Import the different file types","text":"

      According to the different file types, MatrixOne currently mainly supports importing .csv or jsonlines:

      • For how to import .csv format, see Load csv format data.
      • For how to import .jl format, see Load jsonlines format data.
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#import-data-from-different-data-storage-locations","title":"Import data from different data storage locations","text":"

      According to the different data storage locations, MatrixOne supports importing data from local and importing data from S3(Simple Storage Service).

      • For how to import data from local host, see Load csv format data or Load jsonlines format data.
      • For how to import data from S3, see Load data from S3.
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#source","title":"SOURCE","text":"

      MatrixOne supports using the SOURCE command to import the entire database structure (including table structures and data) by executing SQL statements from an external SQL script file. The SOURCE command may not perform as well as the LOAD DATA command when processing large amounts of data because it needs to parse and execute each SQL statement.

      • Load data by using the source
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/bulk-load-overview/#more-import-capabilities","title":"More import capabilities","text":"
      • MatrixOne supports the parallel loading of data files: when the data file is large, to improve the loading speed, MatrixOne also supports parallel loading, see the LOAD DATA parameter description for importing data.
      • In a MatrixOne distributed cluster, in addition to importing data locally and from the public cloud object storage S3 to MatrixOne, you can also import data through the local Minio component. For details, see Import data from local Minio to MatrixOne
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/","title":"Load csv format data","text":"

      This document will guide you on how to import large amounts of .csv format data to MatrixOne.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#syntax","title":"Syntax","text":"
      • Scenario 1: The data file is in the same machine with the MatrixOne server.
      LOAD DATA\nINFILE 'file_name'\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[LINES\n[STARTING BY 'string']\n[TERMINATED BY 'string']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
      • Scenario 2: The data file is in separate machines with the MatrixOne server.
      LOAD DATA LOCAL\nINFILE 'file_name'\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[LINES\n[STARTING BY 'string']\n[TERMINATED BY 'string']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed and Launched standalone MatrixOne.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#using-the-load-data-command-in-mysql-client","title":"Using the Load data command in MySQL Client","text":"

      You can use Load Data to import data from big data files.

      This section will describe how to import a .csv file.

      Note: A csv(comma-separated values) file is a delimited text file that uses a comma to separate values.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#steps","title":"Steps","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#the-data-file-is-in-the-same-machine-with-the-matrixone-server","title":"The data file is in the same machine with the MatrixOne server","text":"
      1. Before executing Load Data in MatrixOne, the table needs to be created in advance. For now, the data file is required to be at the same machine with MatrixOne server, a file transfer is necessary if they are in separate machines.

      2. Launch the MySQL Client in the MatrixOne local server for accessing the local file system.

        mysql -h 127.0.0.1 -P 6001 -uroot -p111\n

        Info

        The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

      3. Execute LOAD DATA with the corresponding file path in MySQL client.

        mysql> LOAD DATA INFILE '/tmp/xxx.csv'\nINTO TABLE xxxxxx\nFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#the-data-file-is-in-separate-machines-with-the-matrixone-server","title":"The data file is in separate machines with the MatrixOne server","text":"
      1. Before executing LOAD DATA LOCAL in MatrixOne, the table needs to be created in advance.

      2. Launch the MySQL Client in the MatrixOne local server for accessing the local file system.

        mysql -h <mo-host-ip> -P 6001 -uroot -p111 --local-infile\n
      3. Execute LOAD DATA LOCAL with the corresponding file path in MySQL client.

        mysql> LOAD DATA LOCAL INFILE '/tmp/xxx.csv'\nINTO TABLE table_name\nFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#example-using-load-data-with-docker-version","title":"Example using Load data with docker version","text":"

      If you install MatrixOne by docker, the file system is inside the docker image by default. To work with local directory, you need to bind a local directory to the container. In the following example, the local file system path ~/tmp/docker_loaddata_demo/ is binded to the MatrixOne docker image, with a mapping to the /ssb-dbgen-path path inside the docker. We will walk you through the whole process of loading data with MatrixOne 1.0.0-rc1 docker version in this example.

      1. Download the dataset file and store the data in ~/tmp/docker_loaddata_demo/:

        cd ~/tmp/docker_loaddata_demo/\nwget https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/lineorder_flat.tar.bz2\n
      2. Unzip the dataset:

        tar -jxvf lineorder_flat.tar.bz2\n
      3. Use Docker to launch MatrixOne, and mount the directory ~/tmp/docker_loaddata_demo/ that stores data files to a directory in the container. The container directory is /sb-dbgen-path as an example:

        sudo docker run --name matrixone --privileged -d -p 6001:6001 -v ~/tmp/docker_loaddata_demo/:/ssb-dbgen-path:rw matrixorigin/matrixone:1.0.0-rc1\n
      4. Connect to MatrixOne server:

        mysql -h 127.0.0.1 -P 6001 -uroot -p111\n

        Note: If your data file is on a different machine from the MatrixOne server, that is, the data file is on the client machine you are using, then you need to use the command line to connect to the MatrixOne service host: mysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile; and the imported command line needs to use LOAD DATA LOCAL INFILE syntax.

      5. Create lineorder_flat tables in MatrixOne, and import the dataset into MatriOne:

        mysql> create database if not exists ssb;\nmysql> use ssb;\nmysql> drop table if exists lineorder_flat;\nmysql> CREATE TABLE lineorder_flat(\n  LO_ORDERKEY bigint key,\n  LO_LINENUMBER int,\n  LO_CUSTKEY int,\n  LO_PARTKEY int,\n  LO_SUPPKEY int,\n  LO_ORDERDATE date,\n  LO_ORDERPRIORITY char(15),\n  LO_SHIPPRIORITY tinyint,\n  LO_QUANTITY double,\n  LO_EXTENDEDPRICE double,\n  LO_ORDTOTALPRICE double,\n  LO_DISCOUNT double,\n  LO_REVENUE int unsigned,\n  LO_SUPPLYCOST int unsigned,\n  LO_TAX double,\n  LO_COMMITDATE date,\n  LO_SHIPMODE char(10),\n  C_NAME varchar(25),\n  C_ADDRESS varchar(25),\n  C_CITY char(10),\n  C_NATION char(15),\n  C_REGION char(12),\n  C_PHONE char(15),\n  C_MKTSEGMENT char(10),\n  S_NAME char(25),\n  S_ADDRESS varchar(25),\n  S_CITY char(10),\n  S_NATION char(15),\n  S_REGION char(12),\n  S_PHONE char(15),\n  P_NAME varchar(22),\n  P_MFGR char(6),\n  P_CATEGORY char(7),\n  P_BRAND char(9),\n  P_COLOR varchar(11),\n  P_TYPE varchar(25),\n  P_SIZE int,\n  P_CONTAINER char(10)\n);\nmysql> load data infile '/ssb-dbgen-path/lineorder_flat.tbl' into table lineorder_flat FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
      6. After the import is successful, you can run SQL statements to check the rows of imported data:

        select count(*) from lineorder_flat;\n/*\n    expected results:\n */\n+----------+\n| count(*) |\n+----------+\n| 10272594 |\n+----------+\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#constraints","title":"Constraints","text":"

      The loaded csv file format supports JSON. However, you need to ensure that the JSON does not contain field termination symbols. If the JSON does contain field termination symbols, wrap the JSON with double quotation marks. For example:

      • Right csv file example: \"{\"a\":1, \"b\":2}\", 2
      • Wrong csv file example: {\"a\":1, \"b\":2}, 2
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/","title":"Load jsonlines format data","text":"

      This document will guide you on how to import JSONLines (that is .jl or .jsonl file) data to MatrixOne.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#about-jsonlines-format","title":"About JSONLines format","text":"

      JSON(JavaScript Object Notation) is a popular file format for about two decades, nowadays became de-facto of data exchange format standard, replacing XML, that was a huge buzzword in the early 2000's. If you are not familiar with JSON format, please help yourself to know about it with this official documentation.

      JSONLines text format, also called newline-delimited JSON, is a convenient format for storing structured data that may be processed one record at a time. Basically, JSONL is a file format that allows one JSON object per line with lines delimited by a newline character \\n. Each line of the file is independent, so commas are not required at the beginning or ending of lines. Nor does the entire contents of the file need to be enclosed in square or curly braces.

      JSONLines is appealing format for data streaming. Since every new line means a separate entry makes the JSON Lines formatted file streamable. It doesn't require custom parsers. Just read a line, parse as JSON, read a line, parse as JSON\u2026 and so on.

      The JSON Lines format has three requirements:

      • UTF-8 Encoding: JSON allows encoding Unicode strings with only ASCII escape sequences, however those escapes will be hard to read when viewed in a text editor. The author of the JSON Lines file may choose to escape characters to work with plain ASCII files.

      • Each Line is a Valid JSON Value: The most common values will be objects or arrays, but any JSON value is permitted.

      • Line Separator is '\\n': This means '\\r\\n' is also supported because surrounding white space is implicitly ignored when parsing JSON values.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#valid-jsonlines-format-for-matrixone","title":"Valid JSONLines format for MatrixOne","text":"

      JSONLines format only requires a valid JSON value for each line. But MatrixOne requires a more structured JSONLines format, only an JSON object or an JSON array with the same type of values and a plain structure are allowed in MatrixOne. If your JSONLines file has nested structures, MatrixOne doesn't support loading it for now.

      A valid object JSONLines example:

      {\"id\":1,\"father\":\"Mark\",\"mother\":\"Charlotte\"}\n{\"id\":2,\"father\":\"John\",\"mother\":\"Ann\"}\n{\"id\":3,\"father\":\"Bob\",\"mother\":\"Monika\"}\n

      Invalid object JSONLines example (with nested structure):

      {\"id\":1,\"father\":\"Mark\",\"mother\":\"Charlotte\",\"children\":[\"Tom\"]}\n{\"id\":2,\"father\":\"John\",\"mother\":\"Ann\",\"children\":[\"Jessika\",\"Antony\",\"Jack\"]}\n{\"id\":3,\"father\":\"Bob\",\"mother\":\"Monika\",\"children\":[\"Jerry\",\"Karol\"]}\n

      A valid array JSONLines example, it needs to look like a CSV format.

      [\"Name\", \"Session\", \"Score\", \"Completed\"]\n[\"Gilbert\", \"2013\", 24, true]\n[\"Alexa\", \"2013\", 29, true]\n[\"May\", \"2012B\", 14, false]\n[\"Deloise\", \"2012A\", 19, true]\n

      Invalid array JSONLines example (Data type and column numbers don't match): [\"Gilbert\", \"2013\", 24, true, 100] [\"Alexa\", \"2013\", \"twenty nine\", true] [\"May\", \"2012B\", 14, \"no\"] [\"Deloise\", \"2012A\", 19, true, 40]

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#syntax","title":"Syntax","text":"
      • Scenario 1: The data file is in the same machine with the MatrixOne server.
      LOAD DATA INFILE\n    {'filepath'='FILEPATH', 'compression'='COMPRESSION_FORMAT', 'format'='FILE_FORMAT', 'jsondata'='object'/'array'} INTO TABLE table_name [IGNORE x LINES/ROWS] [PARALLEL {'TRUE' | 'FALSE'}];\n
      • Scenario 2: The data file is in separate machines with the MatrixOne server.
      LOAD DATA LOCAL INFILE\n    {'filepath'='FILEPATH', 'compression'='COMPRESSION_FORMAT', 'format'='FILE_FORMAT', 'jsondata'='object'/'array'} INTO TABLE table_name [IGNORE x LINES/ROWS] [PARALLEL {'TRUE' | 'FALSE'}];\n

      Parameter Description

      Parameter Value Required/Optional Description filepath String Required The file path. compression auto/none/bz2/gzip/lz4 Optional Compression algorithm format. format csv/jsonline Optional the loading file format. default is csv. jsondata object/array Optional jsonline format. If format is jsonline, must specify jsondata. table_name String Required table name to load into x Number Optional lines to be ignored while loading

      DDL guidelines for JSONLines format data

      Before load JSONLines data into MatrixOne, we need to firstly create a table. As JSON data type is not the same as MatrixOne data type, we need a guideline for DDL.

      JSON Type MatrixOne Type String VARCHAR (with a certain length limit) String TEXT (without knowing the limit of this string) String DATETIME or TIMESTAMP (with format as \"YYYY-MM-DD HH:MM:SS.XXXXXX\") String DATE (with format as \"YYYY-MM-DD\") String TIME (with format as \"HH-MM-SS.XXXXXX\") Number INT (with interger numbers) Number FLOAT or DOUBLE (with floating numbers) Boolean BOOL(true/false) Object JSON type Array JSON type Null All types have been supported.

      For example, We can create a MatrixOne table with such a DDL for a JSONLines format file as below.

      mysql> create table t1 (name varchar(100), session varchar(100), score int, completed bool);\n
      [\"Name\", \"Session\", \"Score\", \"Completed\"]\n[\"Gilbert\", \"2013\", 24, true]\n[\"Alexa\", \"2013\", 29, true]\n[\"May\", \"2012B\", 14, false]\n[\"Deloise\", \"2012A\", 19, true]\n

      Some examples

      These are some full SQL examples to load a JSONLines file to MatrixOne.

      #Load a BZIP2 compressed jsonline object file\nload data infile {'filepath'='data.bzip2', 'compression'='bz2','format'='jsonline','jsondata'='object'} into table db.a\n\n#Load a plain jsonline array file\nload data infile {'filepath'='data.jl', 'format'='jsonline','jsondata'='array'} into table db.a\n\n#Load a gzip compressed jsonline array file and ignore the first line\nload data infile {'filepath'='data.jl.gz', 'compression'='gzip','format'='jsonline','jsondata'='array'} into table db.a ignore 1 lines;\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#tutorial","title":"Tutorial","text":"

      In this tutorial, we will guide you through loading two jsonline files with object and array jsonformat.

      1. Prepare the data files. You can also download and use the .jl file we prepared. The data directory needs to be with in the same machine as MatrixOne server. The following steps are illustrated with sample data.

        • Example data file 1:jsonline_object.jl
        • Example data file 2:jsonline_array.jl
      2. Open your terminal, enter into the directory where the .jl file resides, and run the following command line to display the contents of the file:

        > cd /$filepath\n> head jsonline_object.jl\n{\"col1\":true,\"col2\":1,\"col3\":\"var\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":121.11}\n{\"col1\":\"true\",\"col2\":\"1\",\"col3\":\"var\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":\"121.11\"}\n{\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":\"121.11\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col1\":\"true\",\"col2\":\"1\",\"col3\":\"var\"}\n{\"col2\":1,\"col3\":\"var\",\"col1\":true,\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col8\":121.11}\n> head jsonline_array.jl\n[true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\"]\n
      3. Install and Launch MatrixOne in the same machine, launch MySQL Client to connect to MatrixOne.

        mysql -h 127.0.0.1 -P 6001 -uroot -p111\n

        Note: If your data file is on a different machine from the MatrixOne server, that is, the data file is on the client machine you are using, then you need to use the command line to connect to the MatrixOne service host: mysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile; and the imported command line needs to use LOAD DATA LOCAL INFILE syntax.

        Info

        The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

      4. Create tables in MatrixOne:

        create database db1;\nuse db1;\ndrop table if exists t1;\ncreate table t1(col1 bool,col2 int,col3 varchar, col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float);\ndrop table if exists t2;\ncreate table t2(col1 bool,col2 int,col3 varchar, col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float);\n
      5. Execute LOAD DATA with the corresponding file path in MySQL client, import the jsonline_object.jl and the file jsonline_array.jl into MatrixOne:

        load data infile {'filepath'='$filepath/jsonline_object.jl','format'='jsonline','jsondata'='object'} into table t1;\nload data infile {'filepath'='$filepath/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t2;\n
      6. After the import is successful, you can run SQL statements to check the results of imported data:

        select * from t1;\ncol1    col2    col3    col4    col5    col6    col7    col8\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\nselect * from t2;\ncol1    col2    col3    col4    col5    col6    col7    col8\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\ntrue    1   var 2020-09-07  2020-09-07 00:00:00 2020-09-07 00:00:00 18  121.11\n

      Note

      If you use Docker to launch MatrixOne, when you try to import the jsonline file, please make sure that you have a data directory mounted to the container. You can check on the load csv tutorial about the loading with docker installation.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/","title":"Load data from S3","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#overview","title":"Overview","text":"

      S3 (Simple Storage Service) object storage refers to Amazon's Simple Storage Service. You can also store almost any type and size of data with S3-compatible object storage, including data lakes, cloud-native applications, and mobile apps. If you are unfamiliar with S3 object service, you may look up some basic introductions in AWS.

      AWS S3 has been remarkably successful for over a decade, so it became the de facto standard for object storage. Thus almost every mainstream public cloud vendors provide an S3-compatible object storage service.

      MatrixOne supports loading files from S3-compatible object storage services into databases. MatrixOne supports AWS and mainstream cloud vendors in China (Alibaba Cloud, Tencent Cloud).

      In MatrixOne, there are two methods to import the data from S3-compatible object storage:

      • Use Load data with an s3option to load the file into MatrixOne. This method will load the data into MatrixOne, and all next queries will happen inside MatrixOne.
      • Create an external table with an s3option mapping to an S3 file, and query this external table directly. This method allows data access through an S3-compatible object storage service; each query's networking latency will be counted.
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#method-1-load-data","title":"Method 1: LOAD DATA","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#syntax","title":"Syntax","text":"
      LOAD DATA\n| URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n

      Parameter Description

      Parameter Description endpoint A endpoint is a URL that can conncect to object storage service. For example: s3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 Bucket to access filepath relative file path. regex expression is supported as /files/*.csv. region object storage service region compression Compressed format of S3 files. If empty or \"none\", it indicates uncompressed files. Supported fields or Compressed format are \"auto\", \"none\", \"gzip\", \"bz2\", and \"lz4\".

      The other paramaters are identical to a ordinary LOAD DATA, see LOAD DATA for more details.

      Statement Examples:

      # LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-mo', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-data', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD a csv file from Tencent Cloud COS Shanghai region, test-1252279971 bucket, without bz2 compression\nLOAD DATA URL s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n

      Note

      MatrixOne provides security assurance for S3 authentication information, such as access_key_id and secret_access_key sensitive information will be hidden in the system table (statement_info) records to ensure your account security.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#tutorial-load-a-file-from-aws-s3","title":"Tutorial: Load a file from AWS S3","text":"

      In this tutorial, we will walk you through the process of loading a .csv file from AWS S3; we assume that you already have an AWS account and already have your data file ready in your S3 service. If you do not already have that, please sign up and upload your data file first; you may check on the AWS S3 official tutorial. The process for Alibaba Cloud OSS and Tencent Cloud COS is similar to AWS S3.

      Note

      This code example does not show account information such as access_key_id and secret_access_key because of account privacy. You can read this document to understand the main steps; specific data and account information will not be shown.

      1. Download the data file. Enter into AWS S3 > buckets, create a bucket test-loading with a public access and upload the file char_varchar_1.csv.

      2. Get or create your AWS api key. Enter into Your Account Name > Security Credentials, get your existing Access Key or create a new one.

        You can get the access key id and secret access key from the downloaded credentials or this webpage.

      3. Launch the MySQL Client, create tables in MatrixOne, for example:

        create database db;\nuse db;\ndrop table if exists t1;\ncreate table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
      4. Import the file into MatrixOne:

        LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
      5. After the import is successful, you can run SQL statements to check the result of imported data:

        mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa,aa     | bb,bb     | cc,cc     | dd,dd     |\n| aa,       | bb,       | cc,       | dd,       |\n| aa,,,aa   | bb,,,bb   | cc,,,cc   | dd,,,dd   |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\",aa    | bb\",bb    | cc\",cc    | dd\",dd    |\n| aa\"\",aa   | bb\"\",bb   | cc\"\",cc   | dd\"\",dd   |\n|           |           |           |           |\n|           |           |           |           |\n| NULL      | NULL      | NULL      | NULL      |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n21 rows in set (0.03 sec)\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#method-2-specify-s3-file-to-an-external-table","title":"Method 2: Specify S3 file to an external table","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#syntax_1","title":"Syntax","text":"
      create external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}     [{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[IGNORE number {LINES | ROWS}];\n

      Note

      MatrixOne only supports select on external tables. Delete, insert, and update are not supported.

      Parameter Description

      Parameter Description endpoint A endpoint is a URL that can conncect to object storage service. For example: s3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 Bucket to access filepath relative file path. regex expression is supported as /files/*.csv. region object storage service region compression Compressed format of S3 files. If empty or \"none\", it indicates uncompressed files. Supported fields or Compressed format are \"auto\", \"none\", \"gzip\", \"bz2\", and \"lz4\".

      The other paramaters are identical to a ordinary LOAD DATA, see LOAD DATA for more details.

      For more information about External Table, see CREATE EXTERNAL TABLE.

      Statement Examples:

      ## Create a external table for a .csv file from AWS S3\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n\n## Create a external table for a .csv file compressed with BZIP2 from Tencent Cloud\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n' ignore 1 lines;\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#tutorial-create-an-external-table-with-s3-file","title":"Tutorial: Create an external table with S3 file","text":"

      This tutorial will walk you through the whole process of creating an external table with a .csv file from AWS S3.

      Note

      This code example does not show account information such as access_key_id and secret_access_key because of account privacy. You can read this document to understand the main steps; specific data and account information will not be shown.

      1. Download the data file. Enter into AWS S3 > buckets, create a bucket test-loading with a public access and upload the file char_varchar_1.csv.

      2. Get or create your AWS api key. Enter into Your Account Name > Security Credentials, get your existing Access Key or create a new one.

        You can get the access key id and secret access key from the downloaded credentials or this webpage.

      3. Launch the MySQL Client, and specify the S3 file to an external table:

        create database db;\nuse db;\ndrop table if exists t1;\ncreate external table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n
      4. After the import is successful, you can run SQL statements to check the result of the imported data. You can see that the query speed is significantly slower than querying from a local table.

        select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa,aa     | bb,bb     | cc,cc     | dd,dd     |\n| aa,       | bb,       | cc,       | dd,       |\n| aa,,,aa   | bb,,,bb   | cc,,,cc   | dd,,,dd   |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\",aa    | bb\",bb    | cc\",cc    | dd\",dd    |\n| aa\"\",aa   | bb\"\",bb   | cc\"\",cc   | dd\"\",dd   |\n|           |           |           |           |\n|           |           |           |           |\n| NULL      | NULL      | NULL      | NULL      |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n21 rows in set (1.32 sec)\n
      5. (Optional)If you need to import external table data into a data table in MatrixOne, you can use the following SQL statement:

        Create a new table t2 in MatrixOne:

        create table t2(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n

        Import the external table t1 to t2:

        insert into t2 select * from t1;\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/","title":"Load data by using the source","text":"

      This document will guide you to use the source command to import data into MatrixOne in batches.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#syntax","title":"Syntax","text":"
      SOURCE /path/to/your/sql_script.sql;\n

      /path/to/your/sql_script.sql is the absolute path to the SQL script file. When executing this command, the client will read the specified SQL script file and execute all its SQL statements.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#tutorial","title":"Tutorial","text":"

      This tutorial will guide you on migrating data from MySQL to MatrixOne using the source command.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed and Launched standalone MatrixOne.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#steps","title":"Steps","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#1-dump-mysql-data","title":"1. Dump MySQL data","text":"

      We suppose you have full access to your MySQL instances.

      Firstly, we use mysqldump to dump MySQL table structures and data to a single file with the following command. You can take a look at this wonderful tutorial if you are not familiar with mysqldump. The syntax is as below:

      mysqldump -h IP_ADDRESS -uUSERNAME -pPASSWORD -d DB_NAME1 DB_NAME2 ... OUTPUT_FILE_NAME.SQL\n

      For example, this following command dumps all table structures and data of the database test to a single file named a.sql.

      mysqldump -h 127.0.0.1 -uroot -proot -d test > a.sql\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#2-import-into-matrixone","title":"2. Import into MatrixOne","text":"

      Import the whole table structures and data into MatrixOne.

      1. Open a MySQL terminal and connect to MatrixOne.
      2. Import the SQL file into MatrixOne by the source command.
      mysql> source '/YOUR_PATH/a.sql'\n

      If your SQL file is big, you can use the following command to run the import task in the background. For example:

      nohup mysql -h 127.0.0.1 -P 6001 -uroot -p111 -e 'source /YOUR_PATH/a.sql' &\n

      Info

      The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

      "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#3-check-data","title":"3. Check data","text":"

      After the import is successful, you can run the following SQL statement to check the import results:

      select * from tool;\n
      "},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#constraints","title":"Constraints","text":"

      MatrixOne 1.0.0-rc1 version already supports MySQL table creation statements, so you can smoothly migrate MySQL tables to MatrixOne. However, it should be noted that during the migration process, some keywords incompatible with MySQL, such as engine=, will be automatically ignored in MatrixOne and will not affect the migration of the table structure.

      However, it should be noted that although MatrixOne supports MySQL table creation statements, manual modification is still required if the migrated table contains incompatible data types, triggers, functions, or stored procedures. For more detailed compatibility information, see MySQL Compatibility.

      "},{"location":"MatrixOne/Develop/read-data/cte/","title":"Common Table Expression","text":"

      A CTE (Common table expression) is a named temporary result set that exists only within the execution scope of a single SQL statement (such as SELECT, INSERT, UPDATE, or DELETE).

      Like derived tables, CTEs are not stored as objects and persist only for the duration of query execution; Unlike derived tables, CTEs can be self-referenced or referenced multiple times in the same query. In addition, CTEs provide better readability and performance than derived tables.

      Use Cases:

      • CTEs can reuse the same subquery in multiple places, avoiding redundant logic.
      • They can simplify recursive queries, such as querying tree-structured data.
      • Complex queries can be broken down into smaller parts using CTEs, making the query logic clearer and more understandable.

      Common Table Expressions are divided into two types: non-recursive and recursive:

      • Non-recursive CTE refers to an expression in which the CTE does not reference itself. It is used to build a one-time temporary result set and does not involve recursion. Non-recursive CTE Statement:
      WITH <query_name> AS (\n<query_definition>\n)\nSELECT ... FROM <query_name>;\n
      • Recursive CTE refers to an expression in which the CTE references itself. It handles data with recursive structures, such as trees or graphs. A recursive CTE includes a base query (initial condition) in its definition, then performs recursive operations on the result of that base query until a stop condition is met. Recursive CTE Statement:
      WITH RECURSIVE <query_name> AS (\n<query_definition>\n)\nSELECT ... FROM <query_name>;\n
      "},{"location":"MatrixOne/Develop/read-data/cte/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      "},{"location":"MatrixOne/Develop/read-data/cte/#examples-of-using-cte-statements","title":"Examples of Using CTE Statements","text":"

      Suppose we want to create a table named EMPLOYEES that includes a hierarchical relationship among employees. We will then use non-recursive and recursive Common Table Expressions (CTEs) to query the employee hierarchy.

      First, let's create the EMPLOYEES table and insert some sample data:

      CREATE TABLE EMPLOYEES (\nEMPLOYEE_ID INT PRIMARY KEY,\nNAME VARCHAR(50),\nMANAGER_ID INT\n);\n\nINSERT INTO EMPLOYEES (EMPLOYEE_ID, NAME, MANAGER_ID) VALUES\n(1, 'Alice', NULL),\n(2, 'Bob', 1),\n(3, 'Carol', 1),\n(4, 'David', 2),\n(5, 'Eve', 2),\n(6, 'Frank', 3),\n(7, 'Grace', 3),\n(8, 'Hannah', 4),\n(9, 'Ian', 4);\n

      Next, we'll use a recursive CTE to query the employee hierarchy:

      WITH RECURSIVE EmployeeHierarchy AS (\nSELECT EMPLOYEE_ID, NAME, MANAGER_ID, 0 AS LEVEL\nFROM EMPLOYEES\nWHERE MANAGER_ID IS NULL\n\nUNION ALL\n\nSELECT e.EMPLOYEE_ID, e.NAME, e.MANAGER_ID, eh.LEVEL + 1\nFROM EMPLOYEES e\nINNER JOIN EmployeeHierarchy eh ON e.MANAGER_ID = eh.EMPLOYEE_ID\n)\nSELECT * FROM EmployeeHierarchy;\n+-------------+--------+------------+-------+\n| employee_id | name   | manager_id | level |\n+-------------+--------+------------+-------+\n|           1 | Alice  |       NULL |     0 |\n|           2 | Bob    |          1 |     1 |\n|           3 | Carol  |          1 |     1 |\n|           4 | David  |          2 |     2 |\n|           5 | Eve    |          2 |     2 |\n|           6 | Frank  |          3 |     2 |\n|           7 | Grace  |          3 |     2 |\n|           8 | Hannah |          4 |     3 |\n|           9 | Ian    |          4 |     3 |\n+-------------+--------+------------+-------+\n9 rows in set (0.01 sec)\n

      Then, we'll use a non-recursive CTE to query employee information:

      WITH EmployeeInfo AS (\nSELECT EMPLOYEE_ID, NAME, MANAGER_ID\nFROM EMPLOYEES\n)\nSELECT * FROM EmployeeInfo;\n+-------------+--------+------------+\n| employee_id | name   | manager_id |\n+-------------+--------+------------+\n|           1 | Alice  |       NULL |\n|           2 | Bob    |          1 |\n|           3 | Carol  |          1 |\n|           4 | David  |          2 |\n|           5 | Eve    |          2 |\n|           6 | Frank  |          3 |\n|           7 | Grace  |          3 |\n|           8 | Hannah |          4 |\n|           9 | Ian    |          4 |\n+-------------+--------+------------+\n9 rows in set (0.00 sec)\n

      We used a recursive CTE named EmployeeHierarchy, which first selects top-level managers (MANAGER_ID IS NULL), and then recursively joins to find each employee's direct subordinates while keeping track of the hierarchy level. This allows us to query the detailed information of the employee hierarchy using the CTE.

      The non-recursive CTE example selects basic information of all employees from the EMPLOYEES table, including EMPLOYEE_ID, NAME, and MANAGER_ID.

      The RECURSIVE keyword is needed to declare a recursive CTE.

      For more information on using CTEs, see WITH (Common Table Expressions).

      "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/","title":"Multi-table Join Queries","text":"

      In many scenarios, you need to use one query to get data from multiple tables. You can use the JOIN statement to combine the data from two or more tables.

      "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#preparation","title":"Preparation","text":"
      1. Download the dataset:

        https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
      2. Create the database and tables:

        create database d1;\nuse d1;\nCREATE TABLE NATION  ( N_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY));\n\nCREATE TABLE REGION  ( R_REGIONKEY  INTEGER NOT NULL,\nR_NAME       CHAR(25) NOT NULL,\nR_COMMENT    VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY));\n\nCREATE TABLE PART  ( P_PARTKEY     INTEGER NOT NULL,\nP_NAME        VARCHAR(55) NOT NULL,\nP_MFGR        CHAR(25) NOT NULL,\nP_BRAND       CHAR(10) NOT NULL,\nP_TYPE        VARCHAR(25) NOT NULL,\nP_SIZE        INTEGER NOT NULL,\nP_CONTAINER   CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT     VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY));\n\nCREATE TABLE SUPPLIER ( S_SUPPKEY     INTEGER NOT NULL,\nS_NAME        CHAR(25) NOT NULL,\nS_ADDRESS     VARCHAR(40) NOT NULL,\nS_NATIONKEY   INTEGER NOT NULL,\nS_PHONE       CHAR(15) NOT NULL,\nS_ACCTBAL     DECIMAL(15,2) NOT NULL,\nS_COMMENT     VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY));\n\nCREATE TABLE PARTSUPP ( PS_PARTKEY     INTEGER NOT NULL,\nPS_SUPPKEY     INTEGER NOT NULL,\nPS_AVAILQTY    INTEGER NOT NULL,\nPS_SUPPLYCOST  DECIMAL(15,2)  NOT NULL,\nPS_COMMENT     VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY));\n\nCREATE TABLE CUSTOMER ( C_CUSTKEY     INTEGER NOT NULL,\nC_NAME        VARCHAR(25) NOT NULL,\nC_ADDRESS     VARCHAR(40) NOT NULL,\nC_NATIONKEY   INTEGER NOT NULL,\nC_PHONE       CHAR(15) NOT NULL,\nC_ACCTBAL     DECIMAL(15,2)   NOT NULL,\nC_MKTSEGMENT  CHAR(10) NOT NULL,\nC_COMMENT     VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY));\n\nCREATE TABLE ORDERS  ( O_ORDERKEY       BIGINT NOT NULL,\nO_CUSTKEY        INTEGER NOT NULL,\nO_ORDERSTATUS    CHAR(1) NOT NULL,\nO_TOTALPRICE     DECIMAL(15,2) NOT NULL,\nO_ORDERDATE      DATE NOT NULL,\nO_ORDERPRIORITY  CHAR(15) NOT NULL,\nO_CLERK          CHAR(15) NOT NULL,\nO_SHIPPRIORITY   INTEGER NOT NULL,\nO_COMMENT        VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY));\n\nCREATE TABLE LINEITEM ( L_ORDERKEY    BIGINT NOT NULL,\nL_PARTKEY     INTEGER NOT NULL,\nL_SUPPKEY     INTEGER NOT NULL,\nL_LINENUMBER  INTEGER NOT NULL,\nL_QUANTITY    DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE  DECIMAL(15,2) NOT NULL,\nL_DISCOUNT    DECIMAL(15,2) NOT NULL,\nL_TAX         DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG  CHAR(1) NOT NULL,\nL_LINESTATUS  CHAR(1) NOT NULL,\nL_SHIPDATE    DATE NOT NULL,\nL_COMMITDATE  DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE     CHAR(10) NOT NULL,\nL_COMMENT      VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER));\n
      3. Load data into the created tables:

        load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n

      Then you can query data in MatrixOne with the created table.

      "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#join-types","title":"Join Types","text":""},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#inner-join","title":"INNER JOIN","text":"

      The join result of an inner join returns only rows that match the join condition.

      Statement Image SELECT FROM TableA A INNER JOIN TableB B ON A.Key=B.Key

      There are two ways of writing an inner join that are completely equivalent in results:

      mysql> SELECT   l_orderkey,\nSUM(l_extendedprice * (1 - l_discount)) AS revenue,\no_orderdate,\no_shippriority\nFROM\nCUSTOMER,\nORDERS,\nLINEITEM\nWHERE\nc_mktsegment = 'BUILDING'\nAND c_custkey = o_custkey\nAND l_orderkey = o_orderkey\nAND o_orderdate < DATE '1995-03-15'\nAND l_shipdate > DATE '1995-03-15'\nGROUP BY l_orderkey , o_orderdate , o_shippriority\nORDER BY revenue DESC , o_orderdate\nLIMIT 10;\n+------------+---------------------+-------------+----------------+\n| l_orderkey | revenue             | o_orderdate | o_shippriority |\n+------------+---------------------+-------------+----------------+\n|    2456423 | 406181.011100000000 | 1995-03-05  |              0 |\n|    3459808 | 405838.698900000000 | 1995-03-04  |              0 |\n|     492164 | 390324.061000000000 | 1995-02-19  |              0 |\n|    1188320 | 384537.935900000000 | 1995-03-09  |              0 |\n|    2435712 | 378673.055800000000 | 1995-02-26  |              0 |\n|    4878020 | 378376.795200000000 | 1995-03-12  |              0 |\n|    5521732 | 375153.921500000000 | 1995-03-13  |              0 |\n|    2628192 | 373133.309400000000 | 1995-02-22  |              0 |\n|     993600 | 371407.459500000000 | 1995-03-05  |              0 |\n|    2300070 | 367371.145200000000 | 1995-03-13  |              0 |\n+------------+---------------------+-------------+----------------+\n10 rows in set (0.20 sec)\n

      Write as Join, the syntax is as follows:

      mysql> SELECT   l_orderkey,\nSUM(l_extendedprice * (1 - l_discount)) AS revenue,\no_orderdate,\no_shippriority\nFROM\nCUSTOMER\njoin ORDERS on c_custkey = o_custkey\njoin LINEITEM on l_orderkey = o_orderkey\nWHERE\nc_mktsegment = 'BUILDING'\nAND o_orderdate < DATE '1995-03-15'\nAND l_shipdate > DATE '1995-03-15'\nGROUP BY l_orderkey , o_orderdate , o_shippriority\nORDER BY revenue DESC , o_orderdate\nLIMIT 10;\n+------------+---------------------+-------------+----------------+\n| l_orderkey | revenue             | o_orderdate | o_shippriority |\n+------------+---------------------+-------------+----------------+\n|    2456423 | 406181.011100000000 | 1995-03-05  |              0 |\n|    3459808 | 405838.698900000000 | 1995-03-04  |              0 |\n|     492164 | 390324.061000000000 | 1995-02-19  |              0 |\n|    1188320 | 384537.935900000000 | 1995-03-09  |              0 |\n|    2435712 | 378673.055800000000 | 1995-02-26  |              0 |\n|    4878020 | 378376.795200000000 | 1995-03-12  |              0 |\n|    5521732 | 375153.921500000000 | 1995-03-13  |              0 |\n|    2628192 | 373133.309400000000 | 1995-02-22  |              0 |\n|     993600 | 371407.459500000000 | 1995-03-05  |              0 |\n|    2300070 | 367371.145200000000 | 1995-03-13  |              0 |\n+------------+---------------------+-------------+----------------+\n10 rows in set (0.20 sec)\n
      "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#left-join-and-right-join","title":"LEFT JOIN and RIGHT JOIN","text":"

      Outer joins are further divided into left join and right join, and equivalent semantics can be achieved between the two:

      • LEFT JOIN

      The LEFT JOIN returns all the rows in the left table and the values \u200b\u200bin the right table that match the join condition. If no rows are matched in the right table, it will be filled with NULL.

      Statement Image SELECT FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key SELECT FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL
      • RIGHT JOIN

      A RIGHT JOIN returns all the records in the right table and the values \u200b\u200bin the left table that match the join condition. If there is no matching value, it is filled with NULL.

      Statement Image SELECT FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key SELECT FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL

      The example is as below:

      SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n|    147457 |      16 |\n|    147458 |       7 |\n|    147459 |       0 |\n|    147460 |      16 |\n|    147461 |       7 |\n|    147462 |       0 |\n|    147463 |      14 |\n|    147464 |      11 |\n|    147465 |       0 |\n|    147466 |      17 |\n+-----------+---------+\n10 rows in set (0.93 sec)\n

      Or:

      SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nORDERS\nRIGHT OUTER JOIN CUSTOMER ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n|    147457 |      16 |\n|    147458 |       7 |\n|    147459 |       0 |\n|    147460 |      16 |\n|    147461 |       7 |\n|    147462 |       0 |\n|    147463 |      14 |\n|    147464 |      11 |\n|    147465 |       0 |\n|    147466 |      17 |\n+-----------+---------+\n10 rows in set (0.93 sec)\n
      "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#full-join","title":"FULL JOIN","text":"

      A full join is the union of left and right outer joins. The join table contains all records from the joined tables or is filled with NULL if a matching record is missing.

      SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nFULL JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n|         1 |       6 |\n|         2 |       7 |\n|         4 |      20 |\n|         5 |       4 |\n|         7 |      16 |\n|         8 |      13 |\n|        10 |      20 |\n|        11 |      13 |\n|        13 |      18 |\n|        14 |       9 |\n+-----------+---------+\n10 rows in set (0.77 sec)\n

      The full join can also be rewritten to obtain the same semantics:

      SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey\nUNION\nSELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nWHERE c_custkey IS NULL\nGROUP BY c_custkey\nlimit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n|    147457 |      16 |\n|    147458 |       7 |\n|    147459 |       0 |\n|    147460 |      16 |\n|    147461 |       7 |\n|    147462 |       0 |\n|    147463 |      14 |\n|    147464 |      11 |\n|    147465 |       0 |\n|    147466 |      17 |\n+-----------+---------+\n10 rows in set (1.09 sec)\n
      "},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#implicit-join","title":"Implicit join","text":"

      Before the JOIN statement that explicitly declared a join was added to the SQL standard, it was possible to join two or more tables in a SQL statement using the FROM t1, t2 clause, and specify the conditions for the join using the WHERE t1.id = t2.id clause. You can understand it as an implicit join, which uses the inner join to join tables.

      "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/","title":"Query Data from a Single Table","text":"

      This document describes how to use SQL to query data from a single table in a database.

      "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#preparation","title":"Preparation","text":"

      Create a database named token_demo firstly:

      CREATE DATABASE token_demo;\nUSE token_demo;\n

      Create a table named token_count to prepare for querying:

      CREATE TABLE token_count (\nid int,\ntoken varchar(100) DEFAULT '' NOT NULL,\ncount int DEFAULT 0 NOT NULL,\nqty int,\nphone char(1) DEFAULT '' NOT NULL,\ntimes datetime DEFAULT '2000-01-01 00:00:00' NOT NULL\n);\nINSERT INTO token_count VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');\nINSERT INTO token_count VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21');\nINSERT INTO token_count VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04');\nINSERT INTO token_count VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53');\nINSERT INTO token_count VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53');\nINSERT INTO token_count VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24');\nINSERT INTO token_count VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12');\nINSERT INTO token_count VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12');\nINSERT INTO token_count VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24');\nINSERT INTO token_count VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36');\nINSERT INTO token_count VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05');\n
      "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#simple-query","title":"Simple query","text":"

      Execute the following SQL statement in a MySQL client:

      mysql> SELECT id, token FROM token_count;\n

      Result is as below:

      +------+----------------------------------+\n| id   | token                            |\n+------+----------------------------------+\n|   21 | e45703b64de71482360de8fec94c3ade |\n|   22 | e45703b64de71482360de8fec94c3ade |\n|   18 | 346d1cb63c89285b2351f0ca4de40eda |\n|   17 | ca6ddeb689e1b48a04146b1b5b6f936a |\n|   16 | ca6ddeb689e1b48a04146b1b5b6f936a |\n|   26 | a71250b7ed780f6ef3185bfffe027983 |\n|   24 | 4d75906f3c37ecff478a1eb56637aa09 |\n|   25 | 4d75906f3c37ecff478a1eb56637aa09 |\n|   27 | a71250b7ed780f6ef3185bfffe027983 |\n|   28 | a71250b7ed780f6ef3185bfffe027983 |\n|   29 | a71250b7ed780f6ef3185bfffe027983 |\n+------+----------------------------------+\n
      "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#filter-results","title":"Filter results","text":"

      To filter query results, you can use the WHERE statement.

      mysql> SELECT * FROM token_count WHERE id = 25;\n

      Result is as below:

      +------+----------------------------------+-------+------+-------+---------------------+\n| id   | token                            | count | qty  | phone | times               |\n+------+----------------------------------+-------+------+-------+---------------------+\n|   25 | 4d75906f3c37ecff478a1eb56637aa09 |     4 | 6500 | y     | 1999-12-23 17:29:12 |\n+------+----------------------------------+-------+------+-------+---------------------+\n
      "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#sort-results","title":"Sort results","text":"

      To sort query results, you can use the ORDER BY statement.

      For example, the following SQL statement can be used to sort the data in the token_count table in descending order (DESC) by times column.

      mysql> SELECT id, token, times FROM token_count ORDER BY times DESC;\n

      Result is as below:

      +------+----------------------------------+---------------------+\n| id   | token                            | times               |\n+------+----------------------------------+---------------------+\n|   29 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:45:05 |\n|   28 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:36 |\n|   26 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n|   27 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n|   24 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n|   25 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n|   21 | e45703b64de71482360de8fec94c3ade | 1999-12-23 17:22:21 |\n|   22 | e45703b64de71482360de8fec94c3ade | 1999-12-23 17:22:21 |\n|   18 | 346d1cb63c89285b2351f0ca4de40eda | 1999-12-23 11:58:04 |\n|   17 | ca6ddeb689e1b48a04146b1b5b6f936a | 1999-12-23 11:36:53 |\n|   16 | ca6ddeb689e1b48a04146b1b5b6f936a | 1999-12-23 11:36:53 |\n+------+----------------------------------+---------------------+\n
      "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#limit-the-number-of-query-results","title":"Limit the number of query results","text":"

      To limit the number of query results, you can use the LIMIT statement.

      mysql> SELECT id, token, times FROM token_count ORDER BY times DESC LIMIT 5;\n

      Result is as below:

      +------+----------------------------------+---------------------+\n| id   | token                            | times               |\n+------+----------------------------------+---------------------+\n|   29 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:45:05 |\n|   28 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:36 |\n|   26 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n|   27 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n|   24 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n+------+----------------------------------+---------------------+\n
      "},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#aggregate-queries","title":"Aggregate queries","text":"

      To have a better understanding of the overall data situation, you can use the GROUP BY statement to aggregate query results.

      For example, you can group basic information by id, count, and times columns and count them separately:

      mysql> SELECT id, count, times FROM token_count GROUP BY id, count, times ORDER BY times DESC LIMIT 5;\n

      Result is as below:

      +------+-------+---------------------+\n| id   | count | times               |\n+------+-------+---------------------+\n|   29 |     4 | 1999-12-27 09:45:05 |\n|   28 |     3 | 1999-12-27 09:44:36 |\n|   26 |     5 | 1999-12-27 09:44:24 |\n|   27 |     3 | 1999-12-27 09:44:24 |\n|   24 |     3 | 1999-12-23 17:29:12 |\n+------+-------+---------------------+\n
      "},{"location":"MatrixOne/Develop/read-data/subquery/","title":"Subquery","text":"

      This document describes how to use subquery statements in MatrixOne.

      "},{"location":"MatrixOne/Develop/read-data/subquery/#overview","title":"Overview","text":"

      An subquery is a query within another SQL query. With subquery, the query result can be used in another query.

      In most cases, there are five types of subqueries:

      • Scalar Subquery, such as SELECT (SELECT s1 FROM t2) FROM t1.
      • Derived Tables, such as SELECT t1.s1 FROM (SELECT s1 FROM t2) t1.
      • Existential Test, such as WHERE NOT EXISTS(SELECT ... FROM t2), WHERE t1.a IN (SELECT ... FROM t2).
      • Quantified Comparison, such as WHERE t1.a = ANY(SELECT ... FROM t2), WHERE t1.a = ANY(SELECT ... FROM t2).
      • Subquery as a comparison operator operand, such as WHERE t1.a > (SELECT ... FROM t2).

      For more information on SQL statement, see SUBQUERY.

      In addition, from the execution of SQL statements, subquery generally has the following two types:

      • Correlated Subquery: In Correlated Subquery nested in databases, the inner and outer queries would not be independent, and the inner queries would depend on the outer queries.The execution sequence is as follows:

        • Queries a record from the outer query.

        • Put the queried records into the inner query, then put the records that meet the conditions into the outer query.

        • Repeat the above steps

        For example: select * from tableA where tableA.cloumn &lt; (select column from tableB where tableA.id = tableB.id))

      • Self-contained Subquery: In a database nested query, the inner query is entirely independent of the outer query. The execution sequence is as follows:

        • Execute the inner query first.

        • The result of the inner query is carried into the outer layer, and then the outer query is executed.

        For example: select * from tableA where tableA.column = (select tableB.column from tableB)

      Key Feature:

      • Subqueries allow structured queries so that each part of a query statement can be separated.

      • Subqueries provides another way to perform operations that require complex JOIN and UNION.

      "},{"location":"MatrixOne/Develop/read-data/subquery/#example","title":"Example","text":""},{"location":"MatrixOne/Develop/read-data/subquery/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      "},{"location":"MatrixOne/Develop/read-data/subquery/#preparation","title":"Preparation","text":"
      1. Download the dataset:

        https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
      2. Create the database and tables:

        create database d1;\nuse d1;\nCREATE TABLE NATION  ( N_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY));\n\nCREATE TABLE REGION  ( R_REGIONKEY  INTEGER NOT NULL,\nR_NAME       CHAR(25) NOT NULL,\nR_COMMENT    VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY));\n\nCREATE TABLE PART  ( P_PARTKEY     INTEGER NOT NULL,\nP_NAME        VARCHAR(55) NOT NULL,\nP_MFGR        CHAR(25) NOT NULL,\nP_BRAND       CHAR(10) NOT NULL,\nP_TYPE        VARCHAR(25) NOT NULL,\nP_SIZE        INTEGER NOT NULL,\nP_CONTAINER   CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT     VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY));\n\nCREATE TABLE SUPPLIER ( S_SUPPKEY     INTEGER NOT NULL,\nS_NAME        CHAR(25) NOT NULL,\nS_ADDRESS     VARCHAR(40) NOT NULL,\nS_NATIONKEY   INTEGER NOT NULL,\nS_PHONE       CHAR(15) NOT NULL,\nS_ACCTBAL     DECIMAL(15,2) NOT NULL,\nS_COMMENT     VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY));\n\nCREATE TABLE PARTSUPP ( PS_PARTKEY     INTEGER NOT NULL,\nPS_SUPPKEY     INTEGER NOT NULL,\nPS_AVAILQTY    INTEGER NOT NULL,\nPS_SUPPLYCOST  DECIMAL(15,2)  NOT NULL,\nPS_COMMENT     VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY));\n\nCREATE TABLE CUSTOMER ( C_CUSTKEY     INTEGER NOT NULL,\nC_NAME        VARCHAR(25) NOT NULL,\nC_ADDRESS     VARCHAR(40) NOT NULL,\nC_NATIONKEY   INTEGER NOT NULL,\nC_PHONE       CHAR(15) NOT NULL,\nC_ACCTBAL     DECIMAL(15,2)   NOT NULL,\nC_MKTSEGMENT  CHAR(10) NOT NULL,\nC_COMMENT     VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY));\n\nCREATE TABLE ORDERS  ( O_ORDERKEY       BIGINT NOT NULL,\nO_CUSTKEY        INTEGER NOT NULL,\nO_ORDERSTATUS    CHAR(1) NOT NULL,\nO_TOTALPRICE     DECIMAL(15,2) NOT NULL,\nO_ORDERDATE      DATE NOT NULL,\nO_ORDERPRIORITY  CHAR(15) NOT NULL,\nO_CLERK          CHAR(15) NOT NULL,\nO_SHIPPRIORITY   INTEGER NOT NULL,\nO_COMMENT        VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY));\n\nCREATE TABLE LINEITEM ( L_ORDERKEY    BIGINT NOT NULL,\nL_PARTKEY     INTEGER NOT NULL,\nL_SUPPKEY     INTEGER NOT NULL,\nL_LINENUMBER  INTEGER NOT NULL,\nL_QUANTITY    DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE  DECIMAL(15,2) NOT NULL,\nL_DISCOUNT    DECIMAL(15,2) NOT NULL,\nL_TAX         DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG  CHAR(1) NOT NULL,\nL_LINESTATUS  CHAR(1) NOT NULL,\nL_SHIPDATE    DATE NOT NULL,\nL_COMMITDATE  DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE     CHAR(10) NOT NULL,\nL_COMMENT      VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER));\n
      3. Load data into the created tables:

        load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n

      Then you can query data in MatrixOne with the created table.

      "},{"location":"MatrixOne/Develop/read-data/subquery/#self-contained-subquery","title":"Self-contained subquery","text":"

      For a self-contained subquery that uses subquery as operand of comparison operators (>, >=, <, <=, = , or ! =), the inner subquery queries only once, and MatrixOne rewrites it as a constant during the execution plan phase.

      mysql> select p.p_name from (select * from part where p_brand='Brand#21' and p_retailprice between 1100 and 1200)  p, partsupp ps where p.p_partkey=ps.ps_partkey and p.p_name like '%pink%' limit 10;\n

      The inner subquery is executed before MatrixOne executes the above query:

      mysql> select * from part where p_brand='Brand#21' and p_retailprice between 1100 and 1200\n

      Result is as below:

      +-----------------------------------+\n| p_name                            |\n+-----------------------------------+\n| olive chartreuse smoke pink tan   |\n| olive chartreuse smoke pink tan   |\n| olive chartreuse smoke pink tan   |\n| olive chartreuse smoke pink tan   |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| honeydew orchid cyan magenta pink |\n| honeydew orchid cyan magenta pink |\n+-----------------------------------+\n10 rows in set (0.06 sec)\n

      For self-contained subqueries such as Existential Test and Quantified Comparison, MatrixOne rewrites and replaces them with equivalent queries for better performance.

      "},{"location":"MatrixOne/Develop/read-data/subquery/#correlated-subquery","title":"Correlated subquery","text":"

      For correlated subquery, because the inner subquery references the columns from the outer query, each subquery is executed once for each row of the outer query. That is, assuming that the outer query gets 10 million results, the subquery will also be executed 10 million times, which will consume more time and resources.

      Therefore, in the process of processing, MatrixOne will try to Decorrelate of Correlated Subquery to improve the query efficiency at the execution plan level.

      mysql> select p_name from part where P_PARTKEY in (select PS_PARTKEY from PARTSUPP where PS_SUPPLYCOST>=500) and p_name like '%pink%' limit 10;\n

      Rewrites it to an equivalent join query:

      select p_name from part join partsupp on P_PARTKEY=PS_PARTKEY where PS_SUPPLYCOST>=500 and p_name like '%pink%' limit 10;\n

      Result is as below:

      +------------------------------------+\n| p_name                             |\n+------------------------------------+\n| papaya red almond hot pink         |\n| turquoise hot smoke green pink     |\n| purple cornsilk red pink floral    |\n| pink cyan purple white burnished   |\n| sandy dark pink indian cream       |\n| powder cornsilk chiffon slate pink |\n| rosy light black pink orange       |\n| pink white goldenrod ivory steel   |\n| cornsilk dim pink tan sienna       |\n| lavender navajo steel sandy pink   |\n+------------------------------------+\n10 rows in set (0.23 sec)\n

      As a best practice, in actual development, it is recommended to avoid querying through a correlated subquery if you can write another equivalent query with better performance.

      "},{"location":"MatrixOne/Develop/read-data/views/","title":"Views","text":"

      This document describes how to use views in MatrixOne.

      "},{"location":"MatrixOne/Develop/read-data/views/#overview","title":"Overview","text":"

      A view acts as a virtual table, whose schema is defined by the SELECT statement that creates the view.

      Key Feature:

      • Simplified user action: The view mechanism allows users to focus on the data they care about. If the data is not directly from the base table, you can define views to make the database look simple and simplify the user's data query operation.

      • Multiple perspectives on the same data: The view mechanism enables different users to view the same data differently, which is necessary when many users share the same database.

      • Provides a degree of logical independence for refactoring the database: Physical data independence means that the user's application does not depend on the physical structure of the database. The logical independence of the data indicates that when the database is restructured, such as adding new relationships or adding new fields to existing relationships, the user's application is not affected. Hierarchical databases and mesh databases can support the physical independence of data but can not fully support logical independence.

      "},{"location":"MatrixOne/Develop/read-data/views/#before-you-start","title":"Before you start","text":"

      Make sure you have already Deployed standalone MatrixOne.

      "},{"location":"MatrixOne/Develop/read-data/views/#preparation","title":"Preparation","text":"

      Create two tables to prepare for using the VIEW:

      CREATE TABLE t00(a INTEGER);\nINSERT INTO t00 VALUES (1),(2);\nCREATE TABLE t01(a INTEGER);\nINSERT INTO t01 VALUES (1);\n

      Query the table t00:

      mysql> select * from t00;\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n+------+\n

      Query the table t01:

      mysql> select * from t01;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n
      "},{"location":"MatrixOne/Develop/read-data/views/#create-a-view","title":"Create a view","text":"

      A complex query can be defined as a view with the CREATE VIEW statement. The syntax is as follows:

      CREATE VIEW view_name AS query;\n

      you cannot create a view with the same name as an existing view or table.

      Example:

      CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\nQuery OK, 0 rows affected (0.02 sec)\n
      "},{"location":"MatrixOne/Develop/read-data/views/#query-views","title":"Query views","text":"

      Once a view is created, you can use the SELECT statement to query the view just like a normal table.

      mysql> SELECT * FROM v0;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    1 |\n|    2 | NULL |\n+------+------+\n
      "},{"location":"MatrixOne/Develop/read-data/views/#get-view-related-information","title":"Get view related information","text":"

      Use the SHOW CREATE TABLE|VIEW view_name statement:

      mysql> SHOW CREATE VIEW v0;\n+------+----------------------------------------------------------------------------+\n| View | Create View                                                                |\n+------+----------------------------------------------------------------------------+\n| v0   | CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a) |\n+------+----------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Develop/read-data/views/#drop-view","title":"Drop view","text":"

      Use the DROP VIEW view_name; statement to drop a view.

      mysql> DROP VIEW v0;\n
      "},{"location":"MatrixOne/Develop/read-data/window-function/","title":"Window Function","text":"

      Window Function (Window Function) is a unique function that can perform calculation operations on a specific window (Window) of the query result set. Window functions can be used to group, sort, and aggregate the result set and calculate the relevant value of each row of data within each window without changing the number of rows in the result set. That is, the result set can be flexibly analyzed and processed through the window function without introducing additional subqueries or join operations.

      SQL window functions have a wide range of applications in various business scenarios:

      1. Intra-row comparison: Compare a specific value of each row with other rows in the same group, such as calculating the difference between each employee's salary and the department's average salary. At this time, you can use window functions.

      2. Data ranking: The window function can quickly generate data ranking information. For example, you can use the RANK() or ROW_NUMBER() function to check the sales ranking.

      3. Rolling Calculation: Calculate the moving average. You can define the window range of the window function and then perform rolling calculations.

      "},{"location":"MatrixOne/Develop/read-data/window-function/#list-of-window-functions","title":"List of window functions","text":"
      • Most aggregate functions can also be used as window functions, for example, SUM(), AVG(), and COUNT(). These aggregate functions can be used with window functions to calculate the value of a column within a window Sum, average, or count. For aggregate functions and reference documents supported by MatrixOne that can be used as window functions, see:

        • AVG
        • COUNT
        • MAX
        • SUM
        • MIN
      • See the table below for other window functions:

      Function name description DENSE_RANK() Used to assign ranks to rows in a dataset, always assigning consecutive ranks to the next value, even if previous values \u200b\u200bhave the same rank. RANK() Assigns a rank value to each row in the query result set, rows with the same value will have the same rank, and the next rank value will skip the same number of rows. ROW_NUMBER() Assigns a unique integer value to each row in the query result set, ordered according to the specified collation."},{"location":"MatrixOne/Develop/read-data/window-function/#how-to-use-window-functions","title":"How to use window functions","text":"

      Using window functions usually requires the following steps:

      1. Define the window (Window): By using the OVER clause to define the scope of the window, you can specify the sorting rules, partition method and row range of the window, etc.

      2. Write the window function: In the SELECT statement, list the window function together with other columns, and specify the columns and operations that need to be calculated within the window.

      Here is an example of how to use window functions to calculate the total sales for each department and the sales rank for each employee within the department:

      CREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\nSELECT\nDepartment,\nEmployee,\nSales,\nSUM(Sales) OVER(PARTITION BY Department) AS DepartmentSales,\nRANK() OVER(PARTITION BY Department ORDER BY Sales DESC) AS SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------------+-----------+\n| department | employee | sales | DepartmentSales | SalesRank |\n+------------+----------+-------+-----------------+-----------+\n| HR         | Charlie  |   850 |            1650 |         1 |\n| HR         | Alice    |   800 |            1650 |         2 |\n| Marketing  | Jane     |  1200 |            2200 |         1 |\n| Marketing  | John     |  1000 |            2200 |         2 |\n| Sales      | Bob      |  1100 |            2000 |         1 |\n| Sales      | Alex     |   900 |            2000 |         2 |\n+------------+----------+-------+-----------------+-----------+\n6 rows in set (0.01 sec)\n

      In the above example, the PARTITION BY clause is used to partition the result set by the department, and then the SUM() function calculates the total sales for each department. Also, the ORDER BY clause specifies sorting in descending order by sales, and the RANK() function assigns ranks to employees within each department based on sales.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/","title":"Database Schema Design Overview","text":"

      This document provides the basics of MatrixOne database schema design. This document introduces terminology related to MatrixOne databases and subsequent data read and write examples.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#key-concept-in-matrixone","title":"Key concept in MatrixOne","text":"

      Database Schema: The database schema mentioned in this article is the same as the logical object database. It is the same as MySQL.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#database","title":"Database","text":"

      A database in MatrixOne is a collection of objects such as tables.

      To view the default database contained by MatrixOne, ues SHOW DATABASES; statment.

      To create a new database, ues CREATE DATABASE database_name; statement.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#table","title":"Table","text":"

      A table is a collection of related data in a database.

      Each table consists of rows and columns. Each value in a row belongs to a specific column. Each column allows only a single data type. To further qualify columns, you can add some constraints.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#index","title":"Index","text":"

      An index is a data structure used to find data in database tables quickly. It can be seen as a 'table of contents' that contains pointers to the data of each row in the table, making it possible for queries to locate data that meets specific conditions more quickly.

      The indexes commonly used in databases include primary key indexes, secondary indexes, etc. Among them, unique indexes are used to ensure the uniqueness of specific columns or combinations of columns, ordinary indexes are used to improve query performance, and full-text indexes are used for full-text search in text data.

      There are two common types of indexes, namely:

      • Primary Key: Primary key index, the index that identifies the primary key column. The primary key index uniquely identifies each row of data in the table.
      • Secondary index: The secondary index is identified on the non-primary key. The secondary index, a non-clustered index, is used to improve query performance and speed up data retrieval.

      Note: Currently, MatrixOne only supports Primary Key.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#vector","title":"Vector","text":"

      MatrixOne now supports storing and querying vectors. Vector is a numerical array generally produced by AI models, including Large Language Models. These vectors can be seamlessly stored and queried, allowing for tasks like finding nearest neighbors, all while accommodating relational data.

      Note: Currently, MatrixOne only supports inserting and querying vector data.

      For more information, see vector

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#other-supported-logical-objects","title":"Other supported logical objects","text":"

      MatrixOne supports the following logical objects at the same level as the table:

      • View: a view acts as a virtual table whose schema is defined by the SELECT statement that creates the view.

      • Temporary table: a table whose data is not persistent.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#access-control","title":"Access Control","text":"

      MatrixOne supports both user-based and role-based access control. To allow users to view, modify, or delete data, for more information, see Access control in MatrixOne.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#object-limitations","title":"Object limitations","text":""},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#limitations-on-identifier-length","title":"Limitations on identifier length","text":"Identifier type Maximum length (number of characters allowed) Database 64 Table 64 Column 64 Sequence 64"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#limitations-on-a-single-table","title":"Limitations on a single table","text":"Type Upper limit (default value) Columns Defaults to 1017 and can be adjusted up to 4096 Partitions 8192 Size of a single line 6 MB by default Size of a single column 6 MB"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#limitations-on-data-types","title":"Limitations on data types","text":"

      For more information on data types, see Data Types.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#number-of-rows","title":"Number of rows","text":"

      MatrixOne supports an unlimited number of rows by adding nodes to the cluster.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/","title":"Vectors","text":""},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#what-are-vectors","title":"What Are Vectors","text":"

      A vector is a numerical representation that encodes data content, such as text or audio, using embedding models. These vectors can be effectively stored and queried alongside relational data. Vector queries encompass tasks like locating nearest neighbors, which can significantly improve search retrievals, as seen in applications like facial recognition or enhancing Generative AI results.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#vector-database-use-cases","title":"Vector database Use Cases","text":"

      The database's capability to manage vectors reflects its capacity to store, retrieve, and analyze vector-based data. These vectors often play a pivotal role in complex data analysis, machine learning, and mining projects. Vector databases offer a wide range of versatile use cases:

      • Generative AI Applications: These databases can serve as a backend for Generative AI applications, enabling them to fetch the nearest neighbor results in response to user-provided queries, enhancing the output quality and relevance.

      • Advanced Object Recognition: They are invaluable for developing advanced object recognition platforms that discern similarities among diverse datasets. This has practical applications in plagiarism detection, facial recognition, and DNA matching.

      • Personalized Recommendation Systems: Vector databases can be leveraged to augment recommendation systems by incorporating user preferences and choices. This leads to more accurate and tailored recommendations, improving the user experience and engagement.

      • Anomaly Detection: Vector databases can store feature vectors representing normal behavior. Anomalies can then be detected by comparing incoming vectors to the stored ones. This is useful in cybersecurity and industrial quality control.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#before-you-start","title":"Before you start","text":"

      Before reading this document, make sure that the following tasks are completed:

      • Build a MatrixOne Cluster in MatrixOne.
      • Read the Database Schema Design Overview.
      • The database has been created.
      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#how-to-use-vectors","title":"How to Use Vectors","text":"

      The syntax for using vectors is the same as that for regular table creation, data insertion, and data querying:

      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#creating","title":"Creating","text":"

      Using the following SQL statement, you can create two vector columns, one of type Float32 and the other of type Float64. You can also set the dimensions for both vector columns to 3.

      create table t1(a int, b vecf32(3), c vecf64(3));\n
      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#inserting","title":"Inserting","text":"

      MatrixOne supports inserting vectors in two formats.

      Textual Format

      insert into t1 values(1, \"[1,2,3]\", \"[4,5,6]\");\n

      Binary Format

      Suppose you are working with Python NumPy arrays. In that case, you can directly insert the NumPy array into MatrixOne by performing hexadecimal encoding on the array instead of converting it into a comma-separated textual format. This approach is faster when inserting vectors with higher dimensions.

      insert into t1 (a, b) values\n(2, decode(\"7e98b23e9e10383b2f41133f\", \"hex\"));\n\n-- \"7e98b23e9e10383b2f41133f\" represents the hexadecimal encoding of the little-endian []float32{0.34881967, 0.0028086076, 0.5752134}\n\n-- \"hex\" represents hexadecimal encoding\n
      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#querying","title":"Querying","text":"

      Vector columns can also be read in two formats.

      Textual Format

      mysql> select a, b from t1;\n+------+---------------------------------------+\n| a    | b                                     |\n+------+---------------------------------------+\n|    1 | [1, 2, 3]                             |\n|    2 | [0.34881967, 0.0028086076, 0.5752134] |\n+------+---------------------------------------+\n2 rows in set (0.00 sec)\n

      Binary Format

      The binary format is very useful if you need to directly read the vector result set into a NumPy array with minimal conversion cost.

      mysql> select encode(b, \"hex\") from t1;\n+--------------------------+\n| encode(b, hex)           |\n+--------------------------+\n| 0000803f0000004000004040 |\n| 7e98b23e9e10383b2f41133f |\n+--------------------------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#example-top-k-queries","title":"Example - Top K Queries","text":"

      Top K queries are a database query operation that retrieves the top K data items or records from a database. These queries find application in various scenarios, including recommendation systems, search engines, and data analysis, among other fields.

      First, we create a table named t1 that contains vector data b and insert some sample data. Then, we perform top K queries using the given SQL statements for l1_distance, l2_distance, cosine similarity, and cosine distance, limiting the results to the top 5 matches.

      -- Sample table 't1' with vector data 'b'\nCREATE TABLE t1 (\nid int,\nb vecf64(3)\n);\n\n-- Insert some sample data\nINSERT INTO t1 (id,b) VALUES (1, '[1,2,3]'), (2, '[4,5,6]'), (3, '[2,1,1]'), (4, '[7,8,9]'), (5, '[0,0,0]'), (6, '[3,1,2]');\n\n-- Top K Queries using l1_distance\nSELECT * FROM t1 ORDER BY l1_norm(b - '[3,1,2]') LIMIT 5;\n\n-- Top K Queries using l2_distance\nSELECT * FROM t1 ORDER BY l2_norm(b - '[3,1,2]') LIMIT 5;\n\n-- Top K Queries using cosine similarity\nSELECT * FROM t1 ORDER BY cosine_similarity(b, '[3,1,2]') LIMIT 5;\n\n-- Top K Queries using cosine distance\nSELECT * FROM t1 ORDER BY 1 - cosine_similarity(b, '[3,1,2]') LIMIT 5;\n

      These queries demonstrate retrieving the top 5 vectors most similar to the given vector [3,1,2] using different distance and similarity measures. With these queries, you can find the data that best matches your target vector based on different measurement criteria.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#best-practices","title":"Best Practices","text":"
      • Casting between Vectors: When casting a vector from one type to another, it is also advisable to specify the dimension. For instance:

        SELECT b + CAST(\"[1,2,3]\" AS vecf32(3)) FROM t1;\n

        This practice ensures accuracy and consistency in vector-type conversions.

      • Utilizing Binary Format: To enhance overall insertion performance, consider using binary rather than textual format. Ensure the array is in little-endian format before converting it into hexadecimal encoding. Here's a sample Python code:

        import binascii\n\n# 'value' is a NumPy object\ndef to_binary(value):\n    if value is None:\n        return value\n\n   # Little-endian float array\n   value = np.asarray(value, dtype='<f')\n\n   if value.ndim != 1:\n       raise ValueError('expected ndim to be 1')\n\n   return binascii.b2a_hex(value)\n

        This approach can significantly improve data insertion efficiency.

      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#constriants","title":"Constriants","text":"
      • Currently, MatrixOne Vector type supports float32 and float64 types.
      • Vector cannot be Primary Key or Unique Key.
      • Vector maximum dimension is 65536.

      Certainly, let's refine the original text in English:

      "},{"location":"MatrixOne/Develop/schema-design/1.1-vector/#reference","title":"Reference","text":"

      For more documentation on vector functions, see:

      • inner_product()
      • l1_norm()
      • l2_norm()
      • cosine_similarity()
      • vector_dims()
      • Arithemetic Operators
      • Misc Functions
      "},{"location":"MatrixOne/Develop/schema-design/create-database/","title":"Create a Database","text":"

      This document describes how to create a database using SQL and various programming languages and lists the rules of database creation. In this document, the modatabase application is taken as an example to walk you through the steps of database creation.

      "},{"location":"MatrixOne/Develop/schema-design/create-database/#before-you-start","title":"Before you start","text":"

      Before creating a database, do the following:

      • Build a MatrixOne Cluster in MatrixOne.
      • Read the Database Schema Design Overview.
      "},{"location":"MatrixOne/Develop/schema-design/create-database/#what-is-database","title":"What is database","text":"

      Database objects in MatrixOne contain tables, views and other objects.

      "},{"location":"MatrixOne/Develop/schema-design/create-database/#create-databases","title":"Create databases","text":"

      To create a database, you can use the CREATE DATABASE statement.

      CREATE DATABASE IF NOT EXISTS `modatabase`;\n

      For more information on CREATE DATABASE statement, see CREATE DATABASE.

      "},{"location":"MatrixOne/Develop/schema-design/create-database/#view-databases","title":"View databases","text":"

      To view the databases in a cluster, use the SHOW DATABASES statement.

      SHOW DATABASES;\n

      The following is an example output:

      +--------------------+\n| Database           |\n+--------------------+\n| mo_catalog         |\n| system             |\n| system_metrics     |\n| mysql              |\n| information_schema |\n| modatabase         |\n+--------------------+\n
      "},{"location":"MatrixOne/Develop/schema-design/create-database/#rules-in-database-creation","title":"Rules in database creation","text":"
      • Follow the Database Naming Conventions and name your database meaningfully.

      • You can create your own database using the CREATE DATABASE statement and change the current database using the USE {databasename}; statement in a SQL session.

      • Use the account user or user to create objects such as database, roles, and new users. Grant only the necessary privileges to roles and users. For more information, see Access control in MatrixOne.

      "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/","title":"Create a secondary index","text":""},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#what-is-a-secondary-index","title":"What is a secondary index","text":"

      Indexes identified on non-primary keys and secondary indexes are also called non-clustered indexes, which are used to improve query performance and speed up data retrieval. The secondary index does not directly store table data. Still, it indexes a part of the data (such as a column), allowing the database system to locate the table rows containing specific values quickly.

      Secondary indexes can help speed up query operations, especially when querying large tables. Secondary indexes can also support sorting, grouping, and join operations, which usually require sorting or matching a portion of the data in the table.

      "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#before-you-start","title":"Before you start","text":"

      Before reading this document, make sure that the following tasks are completed:

      • Build a MatrixOne Cluster in MatrixOne.
      • Read the Database Schema Design Overview.
      • The database has been created.
      "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#use-secondary-index","title":"Use secondary index","text":"

      Create a secondary index. You can create a secondary index through theCREATE INDEX statement, specify the column for which the index is aimed, and other indexing options.

      The syntax structure is'CREATE INDEX index_name on table_name (column_name);

      index_name is the name of the index, table_name is the name of the table on which the index is to be created, and column_name is the name of the column used to create the index.

      For example, if you want to create a secondary index on the last_name column of a table named employees, you can use the following SQL statement:

      CREATE INDEX idx_lastname ON employees (last_name);\n

      Use a secondary index: You can use a secondary index in a query statement to locate data rows. The SQL query optimizer will automatically select the appropriate index to perform the query operation for the best performance. Such as:

      SELECT * FROM employees WHERE last_name = 'Smith';\n

      In this example, the query optimizer will use the idx_lastname index to locate the data row whose last_name is smith.

      It should be noted that creating an index will increase the storage and maintenance costs of the database, and it may also affect performance when inserting, updating, and deleting data. Therefore, when creating a secondary index, it is necessary to carefully consider its impact on database performance and make the necessary optimizations and adjustments.

      "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#examples","title":"Examples","text":"
      CREATE TABLE users (id INT PRIMARY KEY,\nname VARCHAR(50),\nage INT,\nemail VARCHAR(50)\n);\n-- create a secondary index on the table to speed up the speed of querying users by name\nCREATE INDEX idx_users_name ON users(name);\n-- Insert data\nINSERT INTO users VALUES ('1', 'John', '30', 'john@gmail.com');\nINSERT INTO users VALUES ('2', 'Tommy', '50', 'tom@gmail.com');\nINSERT INTO users VALUES ('3', 'Ann', '33', 'ann@gmail.com');\n-- Perform the following query, the database can use the secondary index to quickly find all users with the name 'John' without having to scan the entire table\nmysql> SELECT * FROM users WHERE name = 'John';\n+------+------+------+----------------+\n| id   | name | age  | email          |\n+------+------+------+----------------+\n|    1 | John |   30 | john@gmail.com |\n+------+------+------+----------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#constraints","title":"Constraints","text":"

      Currently MatrixOne only implements secondary indexes syntactically, and does not achieve performance improvements.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/","title":"Create a Table","text":"

      This document introduces how to create tables using the SQL statement and the related best practices. In the previous document, you created a database named modatabase. In this document, you will create a table in the database.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/#before-you-start","title":"Before you start","text":"

      Before reading this document, make sure that the following tasks are completed:

      • Build a MatrixOne Cluster in MatrixOne.
      • Read the Database Schema Design Overview.
      • The database has been created.
      "},{"location":"MatrixOne/Develop/schema-design/create-table/#what-is-a-table","title":"What is a table","text":"

      A table is a logical object in MatrixOne cluster that is subordinate to the database. It is used to store the data.

      Tables save data records in the form of rows and columns. A table has at least one column. If you have defined n columns, each row of data has exactly the same fields as the n columns.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/#name-a-table","title":"Name a table","text":"

      The first step for creating a table is to give your table a name. Do not use meaningless names that will cause great distress to yourself or your colleagues in the future. It is recommended that you follow your company or organization's table naming convention.

      The CREATE TABLE statement usually takes the following form:

      CREATE TABLE {table_name} ({elements});\n

      For more information on CREATE TABLE statement, see CREATE TABLE.

      Parameter description

      • {table_name}: The name of the table to be created.

      • {elements}: A comma-separated list of table elements, such as column definitions and primary key definitions.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/#define-columns","title":"Define columns","text":"

      A column is subordinate to a table. Each table has at least one column. Columns provide a structure to a table by dividing the values in each row into small cells of a single data type.

      Column definitions typically take the following form.

      {column_name} {data_type} {column_qualification}\n

      Parameter description

      • {column_name}: The column name.
      • {data_type}: The column data type.
      • {column_qualification}: Column qualifications.

      Suppose you need to create a table to store the NATION information in the modatabase database.

      CREATE TABLE NATION(\nN_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\n);\n

      Explanations

      The following table explains the fields in the above example:

      Field name Data type Function Explanation N_NATIONKEY INTEGER The unique identifier of the nation All identifiers should be of type INTEGER N_NAME CHAR Ethnic name Ethnic name is char type, and no more than 25 characters N_REGIONKEY INTEGER Region code, unique identifier All identifiers should be of type INTEGER N_COMMENT VARCHAR comment information varchar type, and no more than 152 characters

      MatrixOne supports many other column data types, including the integer types, floating-point types, date and time types. For more information, see Data Types.

      Create a complex table

      Create a new table named ORDERS.

      CREATE TABLE ORDERS(\nO_ORDERKEY       BIGINT NOT NULL,\nO_CUSTKEY        INTEGER NOT NULL,\nO_ORDERSTATUS    CHAR(1) NOT NULL,\nO_TOTALPRICE     DECIMAL(15,2) NOT NULL,\nO_ORDERDATE      DATE NOT NULL,\nO_ORDERPRIORITY  CHAR(15) NOT NULL,\nO_CLERK          CHAR(15) NOT NULL,\nO_SHIPPRIORITY   INTEGER NOT NULL,\nO_COMMENT        VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY)\n);\n

      This table contains more data types than the NATION table:

      Field name Data type Function Explanation O_TOTALPRICE DECIMAL O_TOTALPRICE is used to mark the price The precision is 15, and the scale is 2; that is, the accuracy represents the total number of digits in the field value, and the scale means how many digits there are after the decimal point, for example decimal(5,2), that is, the precision is 5 when the ratio is 2, its value ranges from -999.99 to 999.99. decimal(6,1), when the accuracy is 6, and the scale is 1, its value range is from -99999.9 to 99999.9. O_ORDERDATE DATE Date value Date of the order"},{"location":"MatrixOne/Develop/schema-design/create-table/#select-primary-key","title":"Select primary key","text":"

      A primary key is a column or a set of columns in a table whose values uniquely identify a row in the table.

      The primary key is defined in the CREATE TABLE statement. The primary key constraint requires that all constrained columns contain only non-NULL values.

      A table can be created without a primary key or with a non-integer primary key.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/#set-default-value","title":"Set default value","text":"

      To set a default value on a column, use the DEFAULT constraint. The default value allows you to insert data without specifying a value for each column.

      You can use DEFAULT together with supported SQL functions to move the calculation of defaults out of the application layer, thus saving resources of the application layer. The resources consumed by the calculation do not disappear and are moved to the MatrixOne cluster. The following exemplifies setting the default value in the t1 table:

      create table t1(a int default (1), b int);\ninsert into t1(b) values(1), (1);\n> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    1 |\n|    1 |    1 |\n+------+------+\n2 rows in set (0.01 sec)\n

      The default value of a is 1.

      You can also set the default value to the time when the value was inserted; see the simple example below:

      -- Create the table and set the default value to the current time\nCREATE TABLE t2 (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ncreated_at DATETIME DEFAULT NOW()\n);\n\nINSERT INTO t2 (id, name) VALUES\n(1, 'John'),\n(2, 'Jane'),\n(3, 'Mike');\n\n> SELECT * FROM t2;\n+------+------+---------------------+\n| id | name | created_at |\n+------+------+---------------------+\n| 1 | John | 2023-07-10 11:57:27 |\n| 2 | Jane | 2023-07-10 11:57:27 |\n| 3 | Mike | 2023-07-10 11:57:27 |\n+------+------+---------------------+\n3 rows in set (0.00 sec)\n

      After executing the above insert statement, each row's created_at column will be automatically set to the current time.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/#prevent-duplicate-values","title":"Prevent duplicate values","text":"

      If you need to prevent duplicate values in a column, you can use the UNIQUE constraint.

      For example, to make sure that N_NATIONKEY are unique, you can rewrite the table creation SQL statement for the NATION table like this:

      CREATE TABLE NATION(\nN_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nUNIQUE KEY (N_NATIONKEY)\n);\n

      If you try to insert the same value ofN_NATIONKEY in the NATION table, an error is returned.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/#prevent-null-values","title":"Prevent null values","text":"

      If you need to prevent null values in a column, you can use the NOT NULL constraint.

      Use the nation's name as an example. In addition to the unique value of the national, it is also hoped that the name of the nation cannot be empty, so here you can write the creation SQL of the NATION table as follows:

      CREATE TABLE NATION(\nN_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY)\n);\n
      "},{"location":"MatrixOne/Develop/schema-design/create-table/#execute-the-show-tables-statement","title":"Execute the SHOW TABLES statement","text":"

      To view all tables under the modatabase database, use the SHOW TABLES statement.

      SHOW TABLES IN `modatabase`;\n

      Running results:

      +----------------------+\n| tables_in_modatabase |\n+----------------------+\n| nation               |\n| orders               |\n+----------------------+\n
      "},{"location":"MatrixOne/Develop/schema-design/create-table/#guidelines-to-follow-when-creating-a-table","title":"Guidelines to follow when creating a table","text":"

      This section provides guidelines you need to follow when creating a table.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/#guidelines-to-follow-when-naming-a-table","title":"Guidelines to follow when naming a table","text":"
      • Use a fully-qualified table name (for example, CREATE TABLE {database_name}. {table_name}). If you do not specify the database name, MatrixOne uses the current database in your SQL session. If you do not use USE {databasename}; to specify the database in your SQL session, MatrixOne returns an error.

      • Use meaningful table names. For example, if you need to create a NATION table, you can use names: NATION, t_user,users, or follow your company or organization's naming convention.

      • Multiple words are separated by an underscore, and it is recommended that the name is no more than 32 characters.

      • Create a separate DATABASE for tables of different business modules and add comments accordingly.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/#guidelines-to-follow-when-defining-columns","title":"Guidelines to follow when defining columns","text":"
      • Check the data types supported.

      • Check the guidelines to follow for selecting primary keys and decide whether to use primary key columns.

      • Check adding column constraints and decide whether to add constraints to the columns.

      • Use meaningful column names. It is recommended that you follow your company or organization's table naming convention. If your company or organization does not have a corresponding naming convention, refer to the column naming convention.

      "},{"location":"MatrixOne/Develop/schema-design/create-table/#guidelines-to-follow-when-selecting-primary-key","title":"Guidelines to follow when selecting primary key","text":"
      • Define a primary key or unique index within the table.
      • Try to select meaningful columns as primary keys.
      • For performance reasons, try to avoid storing extra-wide tables. It is not recommended that the number of table fields is over 60 and that the total data size of a single row is over 64K. It is recommended to split fields with too much data length to another table.
      • It is not recommended to use complex data types.
      • For the fields to be joined, ensure that the data types are consistent and avoid implicit conversion.
      • Avoid defining primary keys on a single monotonic data column. If you use a single monotonic data column (for example, a column with the AUTO_INCREMENT attribute) to define the primary key, it might impact the write performance.
      "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/","title":"Create Temporary Table","text":""},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#what-is-a-temporary-table","title":"What is a temporary table","text":"

      A temporary table is a unique one that is only visible in the current session after creation. At the end of the current session, the database automatically drops the temporary table and frees all space; you can also use the DROP TABLE to drop the temporary table.

      You can use temporary tables to hold some intermediate results in a session; for example, you may need to query these results multiple times, or these results are a subset of other queries.

      "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#advantages-of-temporary-tables","title":"Advantages of temporary tables","text":"

      Temporary tables have several uses and advantages in database design:

      • Data Isolation: Temporary tables are independent in each session or transaction. This means that two temporary tables with the same name can exist in two different sessions without affecting each other.

      • Simplify complex queries: If a query is very complex and involves multiple joins and subqueries, you can save the query results to a temporary table and then perform operations on this temporary table, thereby simplifying the query and improving performance.

      • Improve performance: Saving data in temporary tables can significantly improve query performance for complex queries with large data sets. The access speed is fast because the temporary table is stored in memory.

      • Protect data: Use temporary tables to avoid modification of original data. When you need to perform operations that may change the original data, you can store the data in a temporary table and then perform functions on the temporary table to avoid changing the original data by mistake.

      • Save storage space: Temporary tables are automatically deleted when no longer needed, saving storage space.

      • Helpful for debugging: In complex nested queries, temporary tables can store intermediate results to help debug and verify the output of each step.

      Note that temporary tables are not omnipotent, they also have some limitations, such as being only accessible within the current session, and once the session ends, the temporary table disappears.

      "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#before-you-start","title":"Before you start","text":"

      Before reading this document, make sure that the following tasks are completed:

      • Build a MatrixOne Cluster in MatrixOne.
      • Read the Database Schema Design Overview.
      • The database has been created.
      "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#how-to-use-temporary-tables","title":"How to use temporary tables","text":"

      The syntax for using a temporary table is the same as for a regular table, except that the TEMPORARY keyword is added before the statement that creates the table:

      CREATE TEMPORARY TABLE temp_table_name (column_list);\n

      You can use the same table name for temporary and regular tables without conflicts because they are in different namespaces. However, two temporary tables cannot share the same name in the session.

      Note

      1. Even though temporary tables can have the same name as permanent tables, it is not recommended as this may result in unexpected data loss. For example, if the connection to the database server is lost and you automatically reconnect to the server, you cannot distinguish between temporary and permanent tables. Then, you issue a DROP TABLE statement. This time, the permanent table may be deleted instead of the temporary table. This result is unpredictable.
      2. When you use the 'SHOW TABLES' command to display a list of data tables, you cannot see a list of temporary tables either.
      "},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#example","title":"Example","text":"
      -- Create a temporary table 'temp_employees'\nCREATE TEMPORARY TABLE temp_employees (\nemployee_id INT AUTO_INCREMENT, -- auto-increment employee ID\nfirst_name VARCHAR(50), -- employee name\nlast_name VARCHAR(50), -- employee last name\nemail VARCHAR(100), -- employee email address\nPRIMARY KEY (employee_id) -- set 'employee_id' as the primary key\n);\n\n-- Insert some data into the 'temp_employees' table\nINSERT INTO temp_employees (first_name, last_name, email)\nVALUES ('John', 'Doe', 'john.doe@example.com'),\n('Jane', 'Doe', 'jane.doe@example.com'),\n('Jim', 'Smith', 'jim.smith@example.com'),\n('Jack', 'Johnson', 'jack.johnson@example.com'),\n('Jill', 'Jackson', 'jill.jackson@example.com');\n\n-- Query the temporary table to view all employee information\nSELECT * FROM temp_employees;\n+-------------+------------+-----------+--------------------------+\n| employee_id | first_name | last_name | email                    |\n+-------------+------------+-----------+--------------------------+\n|           1 | John       | Doe       | john.doe@example.com     |\n|           2 | Jane       | Doe       | jane.doe@example.com     |\n|           3 | Jim        | Smith     | jim.smith@example.com    |\n|           4 | Jack       | Johnson   | jack.johnson@example.com |\n|           5 | Jill       | Jackson   | jill.jackson@example.com |\n+-------------+------------+-----------+--------------------------+\n5 rows in set (0.01 sec)\n\n-- At the end of this session, the temporary table 'temp_employees' will be dropped automatically\n
      "},{"location":"MatrixOne/Develop/schema-design/create-view/","title":"Create View","text":""},{"location":"MatrixOne/Develop/schema-design/create-view/#what-is-view","title":"What is View","text":"

      View is a visual, read-only virtual table based on the result set of an SQL statement, whose content is defined by the query. Unlike ordinary tables (tables that store data), views do not contain data but are only formatted displays of query results based on the base table (the table being queried). You can think of a view as a window on a table; the data in this window is reflected on other tables. When a view is queried, the database applies its SQL query to its underlying tables.

      "},{"location":"MatrixOne/Develop/schema-design/create-view/#advantages-of-views","title":"Advantages of Views","text":"
      • Simplify queries: For complex queries, you can create views to hide the complexity of the query, and you only need to select data from the view without remembering complex query statements.

      • Add an extra layer of security: Views can restrict user's access to specific database fields and only display the fields they need to see, which can protect the security of the data.

      • Maintain data consistency: Creating a view can maintain data consistency if multiple queries need to use the same query clause.

      • Logical abstraction: Views can represent functional parts of base table data, summaries, and information from several tables.

      But Views also have disadvantages:

      • Performance: Querying data from a database view can be slow, especially if the view is created based on other views.

      • Depends on other tables: A view will be created based on the underlying tables of the database. Not all views support updating data, depending on the definition of the view and its underlying tables.

      "},{"location":"MatrixOne/Develop/schema-design/create-view/#before-you-start","title":"Before you start","text":"

      Before reading this document, make sure that the following tasks are completed:

      • Build a MatrixOne Cluster in MatrixOne.
      • Read the Database Schema Design Overview.
      • The database has been created.
      "},{"location":"MatrixOne/Develop/schema-design/create-view/#how-to-use-views","title":"How to use views","text":"

      The syntax for creating a view is as follows:

      CREATE VIEW view_name AS\nSELECT column1, column2, ...\nFROM table_name\nWHERE condition;\n

      After creating a view, you can query it like any other table:

      SELECT column1, column2, ...\nFROM view_name;\n
      "},{"location":"MatrixOne/Develop/schema-design/create-view/#example","title":"Example","text":"
      -- Create a table called 'orders'\nCREATE TABLE orders (\norder_id INT AUTO_INCREMENT,\ncustomer_id INT,\norder_date DATE,\norder_amount DOUBLE,\nPRIMARY KEY (order_id)\n);\n\n-- Insert some data into the 'orders' table\nINSERT INTO orders (customer_id, order_date, order_amount)\nVALUES (1, '2023-01-01', 99.99),\n(1, '2023-01-03', 29.99),\n(2, '2023-01-03', 49.99),\n(3, '2023-01-05', 89.99),\n(1, '2023-01-07', 59.99),\n(2, '2023-01-07', 19.99);\n\n-- Create a view called 'order_summary' that shows the total order quantity and total order amount for each customer\nCREATE VIEW order_summary AS\nSELECT customer_id, COUNT(*) as order_count, SUM(order_amount) as total_amount\nFROM orders\nGROUP BY customer_id;\n\n--  Query view\nmysql> SELECT *\nFROM order_summary;\n+-------------+-------------+--------------+\n| customer_id | order_count | total_amount |\n+-------------+-------------+--------------+\n|           1 |           3 |       189.97 |\n|           2 |           2 |        69.98 |\n|           3 |           1 |        89.99 |\n+-------------+-------------+--------------+\n3 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Develop/schema-design/overview/","title":"Database Schema Design Overview","text":"

      This document provides the basics of MatrixOne database schema design. This document introduces terminology related to MatrixOne databases and subsequent data read and write examples.

      "},{"location":"MatrixOne/Develop/schema-design/overview/#key-concept-in-matrixone","title":"Key concept in MatrixOne","text":"

      Database Schema: The database schema mentioned in this article is the same as the logical object database. It is the same as MySQL.

      "},{"location":"MatrixOne/Develop/schema-design/overview/#database","title":"Database","text":"

      A database in MatrixOne is a collection of objects such as tables.

      To view the default database contained by MatrixOne, ues SHOW DATABASES; statment.

      To create a new database, ues CREATE DATABASE database_name; statement.

      "},{"location":"MatrixOne/Develop/schema-design/overview/#table","title":"Table","text":"

      A table is a collection of related data in a database.

      Each table consists of rows and columns. Each value in a row belongs to a specific column. Each column allows only a single data type. To further qualify columns, you can add some constraints.

      "},{"location":"MatrixOne/Develop/schema-design/overview/#index","title":"Index","text":"

      An index is a data structure used to find data in database tables quickly. It can be seen as a 'table of contents' that contains pointers to the data of each row in the table, making it possible for queries to locate data that meets specific conditions more quickly.

      The indexes commonly used in databases include primary key indexes, secondary indexes, etc. Among them, unique indexes are used to ensure the uniqueness of specific columns or combinations of columns, ordinary indexes are used to improve query performance, and full-text indexes are used for full-text search in text data.

      There are two common types of indexes, namely:

      • Primary Key: Primary key index, that is, the index that identifies the primary key column. The primary key index uniquely identifies each row of data in the table.
      • Secondary index: Secondary index is the index identified on the non-primary key. The secondary index, also called a non-clustered index, is used to improve query performance and speed up data retrieval.
      "},{"location":"MatrixOne/Develop/schema-design/overview/#other-supported-logical-objects","title":"Other supported logical objects","text":"

      MatrixOne supports the following logical objects at the same level as table:

      • View: a view acts as a virtual table, whose schema is defined by the SELECT statement that creates the view.

      • Temporary table: a table whose data is not persistent.

      "},{"location":"MatrixOne/Develop/schema-design/overview/#access-control","title":"Access Control","text":"

      MatrixOne supports both user-based and role-based access control. To allow users to view, modify, or delete data, for more information, see Access control in MatrixOne.

      "},{"location":"MatrixOne/Develop/schema-design/overview/#object-limitations","title":"Object limitations","text":""},{"location":"MatrixOne/Develop/schema-design/overview/#limitations-on-identifier-length","title":"Limitations on identifier length","text":"Identifier type Maximum length (number of characters allowed) Database 64 Table 64 Column 64 Sequence 64"},{"location":"MatrixOne/Develop/schema-design/overview/#limitations-on-a-single-table","title":"Limitations on a single table","text":"Type Upper limit (default value) Columns Defaults to 1017 and can be adjusted up to 4096 Partitions 8192 Size of a single line 6 MB by default Size of a single column 6 MB"},{"location":"MatrixOne/Develop/schema-design/overview/#limitations-on-data-types","title":"Limitations on data types","text":"

      For more information on data types, see Data Types.

      "},{"location":"MatrixOne/Develop/schema-design/overview/#number-of-rows","title":"Number of rows","text":"

      MatrixOne supports an unlimited number of rows by adding nodes to the cluster.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/","title":"AUTO INCREMENT Constraint","text":"

      The Auto-Increment Constraint is a feature in MatrixOne that automatically generates a unique identifier value for a column in a table. When inserting new rows, it allows you to automatically generate an incrementing unique value for the specified auto-increment column. This feature is handy in many cases, such as for primary keys or identifiers.

      Auto-Increment Constraint Features

      The Auto-Increment Constraint simplifies the generation and management of identifiers. When using an auto-increment column, there are a few things to keep in mind:

      • Auto-increment columns are usually used as primary keys, so their uniqueness should be ensured.
      • The data type of the auto-increment column should be chosen appropriately based on the requirements, typically an integer type.
      • The values of the auto-increment column are automatically generated when inserting new rows and cannot be manually specified.
      • The auto-increment values are unique within the table and automatically increment with subsequent insert operations.
      • The auto-increment value's starting value and increment step can be customized by modifying the table definition.

      Please use the auto-increment constraint to simplify the generation and management of identifiers based on the specific table structure and requirements, ensuring data integrity and uniqueness.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#syntax","title":"Syntax","text":"

      When creating a table, you can define an auto-increment constraint for a column. Typically, the data type of the auto-increment column is an integer type such as INT or BIGINT. To add an auto-increment constraint to a column, use the AUTO_INCREMENT keyword when creating the table.

      CREATE TABLE table_name (\ncolumn_name data_type AUTO_INCREMENT,\n...\nPRIMARY KEY (primary_key_column)\n);\n
      • table_name: The name of the table.
      • column_name: The column's name to be defined as auto-increment.
      • data_type: The data type of the column, usually an integer type such as INT or BIGINT.
      • primary_key_column: The primary key column of the table.
      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#example","title":"Example","text":"

      Here is an example of creating a table with an auto-increment column:

      -- Create an employees' table with an 'id' column defined as an auto-increment column. The 'id' column has a data type of 'INT' and the auto-increment constraint is specified using the 'AUTO_INCREMENT' keyword. The 'id' column is set as the table's primary key.\nCREATE TABLE employees (\nid INT AUTO_INCREMENT,\nname VARCHAR(50),\ndepartment VARCHAR(50),\nPRIMARY KEY (id)\n);\n\n-- Insert data into the table and let the auto-increment column generate unique identifier values. No values are specified for the 'id' column, and an incrementing unique value is automatically generated for the 'id' column when inserting new rows. The value of the 'id' column will automatically increment with each new row inserted.\nINSERT INTO employees (name, department)\nVALUES ('John Doe', 'HR'),\n('Jane Smith', 'Marketing'),\n('Mike Johnson', 'IT');\n\n-- The 'id' column values will be auto-incremented, generating a unique identifier value for each new row inserted.\nmysql> SELECT * FROM employees;\n+------+--------------+------------+\n| id   | name         | department |\n+------+--------------+------------+\n|    1 | John Doe     | HR         |\n|    2 | Jane Smith   | Marketing  |\n|    3 | Mike Johnson | IT         |\n+------+--------------+------------+\n3 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#constraints","title":"Constraints","text":"
      1. MatrixOne currently does not support modifying auto-increment values' starting and increment steps using the ALTER TABLE statement.
      2. In MatrixOne, only syntax supports using the system variable set @@auto_increment_increment=n to set the incremental step size, and only syntax supports using the system variable set @@auto_increment_offset=n to set the default auto-increment column initial value, but it does not take effect; currently supports setting the initial value AUTO_INCREMENT=n of the auto-increment column, but the step size is still 1 by default.
      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/","title":"FOREIGN KEY integrity constraints","text":"

      FOREIGN KEY constraints can keep related data consistent when cross-referencing associated data across tables.

      Rules

      When defining FOREIGN KEY, the following rules need to be followed:

      • The parent table must already exist in the database or be a table currently being created. In the latter case, the parent table and the slave table are the same table, such a table is called a self-referential table, and this structure is called self-referential integrity.

      • A primary key must be defined for the parent table.

      • Primary keys cannot contain null values, but null values are allowed in foreign keys. In other words, as long as every non-null value in the foreign key appears in the specified primary key, the content of the foreign key is correct.

      • Specify the column name or combination of column names after the table name of the parent table. This column or combination of columns must be the primary or candidate key of the primary table.

      • The number of columns in the foreign key must be the same as the number of columns in the primary key of the parent table.

      • The data type of the column in the foreign key must be the same as the data type of the corresponding column in the primary key of the parent table.

      • The foreign key's value must be consistent with the primary key's value in the main table.

      Foreign Key Characteristics

      • Multi-column foreign key: This type of foreign key is when two or more columns in a table jointly reference another table's primary key. In other words, these columns together define the reference to another table. They must exist in the form of a group and need to meet the foreign key constraint simultaneously.

      • Multi-level foreign key: This situation usually involves three or more tables, and they have a dependency relationship. A table's foreign key can be another table's primary key, and this table's foreign key can be the primary key of a third table, forming a multi-level foreign key situation.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#syntax","title":"Syntax","text":"

      Foreign keys are defined in the child table, and the primary foreign key constraint syntax is as follows:

      > CREATE TABLE child_table (\n    ...,\n    foreign_key_column data_type,\n    FOREIGN KEY (foreign_key_column) REFERENCES parent_table (parent_key_column)\n    [ON DELETE reference_option]\n    [ON UPDATE reference_option]\n);\n\nreference_option:\n    RESTRICT | CASCADE | SET NULL | NO ACTION\n

      Explanation

      In the above syntax structure of a foreign key constraint, the following are explanations for each parameter:

      • child_table: The name of the child table, which contains the foreign key.
      • foreign_key_column: The column's name in the child table references the parent table.
      • data_type: The data type of the foreign key column.
      • parent_table: The name of the referenced parent table.
      • parent_key_column: The name of the primary key column in the parent table establishing the relationship.
      • [ON DELETE reference_option]: An optional parameter used to specify actions to be taken when records in the parent table are deleted.
        • RESTRICT: If related foreign key data exists in the referenced table, deletion of data in the table is not allowed. This prevents accidental deletion of related data, ensuring data consistency.
        • CASCADE: When data in the referenced table is deleted, associated foreign key data is also deleted. This is used for cascading deletion of related data to maintain data integrity.
        • SET NULL: When data in the referenced table is deleted, the value of the foreign key column is set to NULL. This is used to retain foreign key data while disconnecting it from the referenced data upon deletion.
        • NO ACTION: Indicates no action is taken; it only checks for the existence of associated data. This is similar to RESTRICT but may have minor differences in some databases.
      • [ON UPDATE reference_option]: An optional parameter used to specify actions to be taken when records in the parent table are updated. Possible values are the same as [ON DELETE reference_option].

      These parameters collectively define a foreign key constraint, ensuring the data integrity relationship between the child and parent tables.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#examples","title":"Examples","text":""},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#example-1","title":"Example 1","text":"
      -- Create a table named t1, containing two columns: a and b. The column a is of type int and is set as the primary key, while the column b is of type varchar with a length of 5.\ncreate table t1(a int primary key, b varchar(5));\n\n-- Create a table named t2, containing three columns: a, b, and c. The column a is of type int, the column b is of type varchar with a length of 5. The column c is of type int, and is set as a foreign key, establishing a relationship with the column a in table t1.\ncreate table t2(a int ,b varchar(5), c int, foreign key(c) references t1(a));\n\n-- Insert two rows of data into table t1: (101, 'abc') and (102, 'def').\nmysql> insert into t1 values(101,'abc'),(102,'def');\nQuery OK, 2 rows affected (0.01 sec)\n\n-- Insert two rows of data into table t2: (1, 'zs1', 101) and (2, 'zs2', 102), where 101 and 102 are the primary keys in table t1.\nmysql> insert into t2 values(1,'zs1',101),(2,'zs2',102);\nQuery OK, 2 rows affected (0.01 sec)\n\n-- Insert a row of data into table t2: (3, 'xyz', null), where null means that this row of data has no associated primary key in column c (the foreign key column).\nmysql> insert into t2 values(3,'xyz',null);\nQuery OK, 1 row affected (0.01 sec)\n\n-- Attempt to insert a row of data into table t2: (3, 'xxa', 103). However, 103 does not exist in the primary keys of table t1, so the insertion fails due to violation of the foreign key constraint.\nmysql> insert into t2 values(3,'xxa',103);\nERROR 20101 (HY000): internal error: Cannot add or update a child row: a foreign key constraint fails\n

      Example Explanation: In the above example, column c of t2 can only refer to the value or null value of column a in t1, so the operation of inserting row 1 and row 2 of t1 can be successfully inserted, but row 3 103 in the row is not a value in column a of t1, which violates the foreign key constraint, so the insert fails.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#example-2-multi-column-foreign-key","title":"Example 2 - Multi-column foreign key","text":"
      -- Creating a \"Student\" table to store student information\nCREATE TABLE Student (\nStudentID INT, -- Student ID field, integer\nName VARCHAR(100), -- Student name field, string with a maximum length of 100\nPRIMARY KEY (StudentID) -- Setting the StudentID as the primary key of this table\n);\n\n-- Creating a \"Course\" table to store course information\nCREATE TABLE Course (\nCourseID INT, -- Course ID field, integer\nCourseName VARCHAR(100), -- Course name field, string with a maximum length of 100\nPRIMARY KEY (CourseID) -- Setting the CourseID as the primary key of this table\n);\n\n-- Creating a \"StudentCourse\" table to store student course selection information\nCREATE TABLE StudentCourse (\nStudentID INT, -- Student ID field, integer, corresponds to the StudentID field in the Student table.\nCourseID INT, -- Course ID field, integer, corresponds to the CourseID field in the Course table.\nPRIMARY KEY (StudentID, CourseID), -- Setting the combination of StudentID and CourseID as the primary key of this table\nFOREIGN KEY (StudentID) REFERENCES Student(StudentID), -- Setting the StudentID field as the foreign key, referencing the StudentID field in the Student table\nFOREIGN KEY (CourseID) REFERENCES Course(CourseID) -- Setting the CourseID field as the foreign key, referencing the CourseID field in the Course table\n);\n

      Example Explanation: In the above example, there are three tables: the Student table, the Course table, and the StudentCourse table for recording which students have chosen which courses. In this case, the Student ID and Course ID in the course selection table can serve as foreign keys, jointly referencing the primary keys of the student table and the course table.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#example-3-multi-level-foreign-key","title":"Example 3 - Multi-level foreign key","text":"
      -- Creating a \"Country\" table to store country information\nCREATE TABLE Country (\nCountryID INT, -- Country ID field, integer\nCountryName VARCHAR(100), -- Country name field, string with a maximum length of 100\nPRIMARY KEY (CountryID) -- Setting the CountryID as the primary key of this table\n);\n\n-- Creating a \"State\" table to store state/province information\nCREATE TABLE State (\nStateID INT, -- State/province ID field, integer\nStateName VARCHAR(100), -- State/province name field, string with a maximum length of 100\nCountryID INT, -- Country ID field, integer, corresponds to the CountryID field in the Country table.\nPRIMARY KEY (StateID), -- Setting the StateID as the primary key of this table\nFOREIGN KEY (CountryID) REFERENCES Country(CountryID) -- Setting the CountryID field as the foreign key, referencing the CountryID field in the Country table\n);\n\n-- Creating a \"City\" table to store city information\nCREATE TABLE City (\nCityID INT, -- City ID field, integer\nCityName VARCHAR(100), -- City name field, string with a maximum length of 100\nStateID INT, -- State/province ID field, integer, corresponds to the StateID field in the State table\nPRIMARY KEY (CityID), -- Setting the CityID as the primary key of this table\nFOREIGN KEY (StateID) REFERENCES State(StateID) -- Setting the StateID field as the foreign key, referencing the StateID field in the State table\n);\n

      Example Explanation: In the above example, there are three tables: the Country table, the State table, and the City table. The State table has a field, CountryID, which is the primary key of the Country table and is also the foreign key of the State table. The City table has a field, StateID, which is the State table's primary key and the City table's foreign key. This forms a multi-level foreign key situation.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/","title":"NOT NULL integrity constraints","text":"

      The NOT NULL constraint can restrict a column from containing NULL values.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/#syntax","title":"Syntax","text":"
      > column_name data_type NOT NULL;\n

      You cannot insert a NULL value into a column that contains a NOT NULL constraint or update an old value to NULL.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/#examples","title":"Examples","text":"
      create table t1(a int not null,b int);\nmysql> insert into t1 values(null,1);\nERROR 3819 (HY000): constraint violation: Column 'a' cannot be null\nmysql> insert into t1 values(1,null);\nQuery OK, 1 row affected (0.01 sec)\nmysql> update t1 set a=null where a=1;\nERROR 3819 (HY000): constraint violation: Column 'a' cannot be null\n

      Example Explanation: In the above example, because there is a non-null constraint in column a, the execution of the first insert statement will fail, the second statement satisfies the non-null constraint in column a, and there is no non-null constraint in column b so that it can be inserted successfully. The update statement fails because it triggers the non-null constraint of column a.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/","title":"Data Integrity Constraints Overview","text":"

      In MatrixOne, to ensure the data's correctness, integrity, and validity, restrictions are added to specific columns in the table creation statement to ensure that the information stored in the database complies with specific rules. These restrictions are called constraints. For example, if the execution result of a DML statement violates the integrity constraint, the statement will be rolled back, and an error message will be returned.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/#integrity-constraints-types","title":"Integrity Constraints Types","text":"

      There are various constraints in MatrixOne, and different constraints have different restrictions on database behavior. Currently, supported constraints are table-level constraints:

      • NOT NULL integrity constraints:

      The non-null constraint means that the data in a specific column cannot have a null value (NULL), and the data that violates the constraint cannot be inserted or updated in the corresponding column. In MatrixOne, a table can have zero, one, or more not-null constraints.

      • UNIQUE KEY integrity constraints

      The unique key constraint means that in a specific column or a combination of multiple columns stored in a table, the value of this column (or column set) in the inserted or updated data row is unique. In MatrixOne, zero, one, or more unique key constraints are allowed in a table, but unlike other relational databases, the unique key constraints of MatrixOne must also be non-empty.

      • PRIMARY KEY integrity constraints

        The primary key constraint means that in a specific column or a combination of multiple columns stored in a table, each data row can be uniquely determined by a specific key value and is not empty. There can only be, at most, one primary key constraint in a table.

      • FOREIGN KEY integrity constraints

      A foreign key constraint means that a column or columns in another table reference a column or a combination of columns stored in one table. The referenced table is usually called the parent table, and the referenced table is called the child table. The child table refers to the data of the corresponding column of the parent table, which can only be the data or null value of the parent table. This kind of constraint is called a foreign key constraint.

      • AUTO INCREMENT constraint

      An auto-increment constraint is a feature that automatically generates a unique identifying value for a column in a table. It allows you to automatically generate an incremental unique value for a specified auto-increment column when a new row is inserted.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/","title":"PRIMARY KEY integrity constraints","text":"

      PRIMARY KEY constraints can be used to ensure that a key value uniquely identifies each data row in a table. And at most, one PRIMARY KEY constraint can be defined on each database table.

      Rules

      When defining PRIMARY KEY, the following rules need to be followed:

      • Uniqueness: The value of the primary key column must be unique; each row in the table must have a different primary key value.

      • Non-nullness: The values \u200b\u200bof the primary key columns cannot be null, i.e., they cannot contain NULL values.

      • Immutability: The value of the primary key column cannot be changed or updated after insertion. This is to keep the primary key unique. If you need to change the primary key value, you usually need to delete the original row first and then insert a new one with the new primary key value.

      • Minimality: The primary key can be composed of a single column or a combination of multiple columns. Composite primary keys can uniquely identify rows, but their composite values \u200b\u200bmust be unique and cannot have repeated combinations.

      • Referential integrity: The primary key is usually used as a reference for the foreign key (Foreign Key).

      • Automatically create indexes: Primary key columns will automatically create indexes to improve retrieval performance.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#syntax","title":"Syntax","text":"
      > column_name data_type PRIMARY KEY;\n
      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#examples","title":"Examples","text":"
      mysql> create table t1(a int primary key, b int, c int, primary key(b,c));\nERROR 20301 (HY000): invalid input: more than one primary key defined\nmysql> create table t2(a int, b int, c int, primary key(b,c));\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t3(a int, b int, c int, primary key(a));\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t2 values(1,1,1);\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> insert into t2 values(1,1,2);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert into t3 values(1,1,1);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert into t3 values(2,1,1);\nQuery OK, 1 row affected (0.01 sec)\n

      Example Explanation: In the above example, t1 contains two sets of primary keys, so the creation fails. t2 and t3 have only one set of primary keys so they can be created. None of the four insert statements violated the constraints, and all were executed successfully.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#constraints","title":"Constraints","text":"

      MatrixOne does not currently support deleting PRIMARY KEY constraints.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/","title":"UNIQUE KEY integrity constraints","text":"

      The UNIQUE KEY constraint can be used to ensure that the values \u200b\u200bof the columns or column groups of the data rows to be inserted or updated are unique and that the values \u200b\u200bof a column or a column set in any two rows of the table are not repeated. The unique key must also be non-Null.

      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/#syntax","title":"Syntax","text":"
      > column_name data_type UNIQUE KEY;\n
      "},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/#examples","title":"Examples","text":"
      create table t1(a int unique key, b int, c int, unique key(b,c));\nmysql> insert into t1 values(1,1,1);\nQuery OK, 1 row affected (0.01 sec)\nmysql> insert into t1 values(2,1,1);\nERROR 20307 (HY000): Duplicate entry '3a15013a1501' for key '__mo_index_idx_col'\nmysql> insert into t1 values(1,1,2);\nERROR 20307 (HY000): Duplicate entry '1' for key '__mo_index_idx_col'\n

      Example Explanation: In the above example, there are two unique key constraints in column a and columns (b,c). When inserting data, the second insert statement violates the unique constraint of (b,c) and duplicates the value of the first insert, so the insert fails. The third insert statement violates the constraint on column a, so the insert fails.

      "},{"location":"MatrixOne/FAQs/deployment-faqs/","title":"Deployment FAQs","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#operating-system-requirements","title":"Operating system requirements","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#what-are-the-required-operating-system-versions-for-deploying-matrixone","title":"What are the required operating system versions for deploying MatrixOne?","text":"

      MatrixOne supports the following operating system:

      Linux OS Version Debian 11.0 or later Ubuntu LTS 20.04 or later Red Hat Enterprise Linux 9.0 or later releases Oracle Enterprise Linux 9.0 or later releases

      MatrixOne also supports macOS operating system, but it's only recommended to run as a test and development environment.

      macOS Version macOS Monterey 12.3 or later"},{"location":"MatrixOne/FAQs/deployment-faqs/#hardware-requirements","title":"Hardware requirements","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#what-are-the-required-hardware-for-deploying-matrixone","title":"What are the required hardware for deploying MatrixOne?","text":"

      For standalone installation, MatrixOne can be running on the 64-bit generic hardware server platform in the Intel x86-64 and ARM architecture. The requirements and recommendations about server hardware configuration for development, testing and production environments are as follows:

      • Development and testing environments
      CPU Memory Local Storage 4 core+ 16 GB+ SSD/HDD 200 GB+

      The Macbook M1/M2 with ARM architecture is also a good fit for a development environment.

      • Production environment
      CPU Memory Local Storage 16 core+ 64 GB+ SSD/HDD 500 GB+

      For comprehensive details on deploying MatrixOne in a distributed setting, see Cluster Topology Planning Overview. This guide includes specific server hardware configuration requirements and recommendations tailored for development, testing, and production environments.

      "},{"location":"MatrixOne/FAQs/deployment-faqs/#installation-and-deployment","title":"Installation and deployment","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#what-settings-do-i-need-to-change-for-installation","title":"What settings do I need to change for installation?","text":"

      Normally you don't need to change anything for installation. A default setting of launch.toml is enough to run MatrixOne directly. But if you want to customize your listening port, ip address, stored data files path, you may modify the corresponding records of cn.toml, tn.toml or log.toml, for more details about parameter configuration in these files, see Boot Parameters for standalone installation.

      "},{"location":"MatrixOne/FAQs/deployment-faqs/#after-the-mysql-client-is-installed-i-open-the-terminal-and-run-mysql-i-got-an-error-of-command-not-found-mysql","title":"After the MySQL client is installed, I open the terminal and run mysql, I got an error of command not found: mysql.","text":"

      To solve the error, you need to set the environment variable. Open a new terminal window, run the following command:

      Linux EnvironmentMacOS Environment
      echo 'export PATH=\"/path/to/mysql/bin:$PATH\"' >> ~/.bash_profile\nsource ~/.bash_profile\n

      Replace /path/to/mysql/bin in the above code with the MySQL installation path in your system. Usually, it is /usr/local/mysql/bin; if you are not sure about the installation path of MySQL, you can use the following command to find it:

      whereis mysql\n

      After macOS 10, zsh is used as the default shell. Here, zsh is used as an example. If you use other shells, you can convert it yourself.

      echo export PATH=/path/to/mysql/bin:$PATH >> ~/.zshrc\nsource ~/.zshrc\n

      Replace /path/to/mysql/bin in the above code with the MySQL installation path in your system. Usually, it is /usr/local/mysql/bin; if you are not sure about the installation path of MySQL, you can use the following command to find it:

      whereis mysql\n
      "},{"location":"MatrixOne/FAQs/deployment-faqs/#when-i-install-matrixone-by-building-from-source-i-got-an-error-of-the-following-and-the-build-failed-how-can-i-proceed","title":"When I install MatrixOne by building from source, I got an error of the following and the build failed, how can I proceed?","text":"

      Error: Get \"https://proxy.golang.org/........\": dial tcp 142.251.43.17:443: i/o timeout

      As MatrixOne needs many go libraries as dependency, it downloads them at the time of building it. This is an error of downloading timeout, it's mostly a networking issue. If you are using a Chinese mainland network, you need to set your go environment to a Chinese image site to accelerate the go library downloading. If you check your go environment by go env, you may see GOPROXY=\"https://proxy.golang.org,direct\", you need to set it by

      go env -w GOPROXY=https://goproxy.cn,direct\n

      Then the make build should be fast enough to finish.

      "},{"location":"MatrixOne/FAQs/deployment-faqs/#when-i-want-to-save-the-matrixone-data-directory-to-my-specified-file-directory-how-should-i-do-it","title":"When I want to save the MatrixOne data directory to my specified file directory, how should I do it?","text":"
      • When you use Docker to start MatrixOne, you can mount the data directory you specify to the Docker container, see Mount directory to Docker container.

      • When you use the source code or binary package to compile and start MatrixOne, you can modify the default data directory path in the configuration file: open the MatrixOne source file directory matrixone/etc /launch-with-proxy, modify the configuration parameter data-dir = \"./mo-data\" in the three files of cn.toml, tn.toml and log.toml is data-dir = \"your_local_path\", save and restart MatrixOne It will take effect.

      "},{"location":"MatrixOne/FAQs/deployment-faqs/#when-i-was-testing-matrixone-with-mo-tester-i-got-an-error-of-too-many-open-files","title":"When I was testing MatrixOne with MO-tester, I got an error of too many open files?","text":"

      MO-tester will open and close many SQL files in a high speed to test MatrixOne, this kind of usage will easily reach the maximum open file limit of Linux and macOS, which is the reason for the too many open files error.

      • For MacOS, you can just set the open file limit by a simple command:
      ulimit -n 65536\n
      • For Linux, please refer to this detailed guide to set the ulimit to 100000.

      After setting this value, there will be no more too many open files error.

      "},{"location":"MatrixOne/FAQs/deployment-faqs/#ssb-dbgen-cannot-be-compiled-on-a-pc-with-m1-chip","title":"Ssb-dbgen cannot be compiled on a PC with M1 chip","text":"

      To complete the following configuration, then compiling 'SSB-DBgen' for a PC with M1 chip:

      1. Download and install GCC11.

      2. To ensure the gcc-11 is successful installed, run the following command:

        gcc-11 -v\n

        The successful result is as below:

        Using built-in specs.\nCOLLECT_GCC=gcc-11\nCOLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc@11/11.3.0/bin/../libexec/gcc/aarch64-apple-darwin21/11/lto-wrapper\nTarget: aarch64-apple-darwin21\nConfigured with: ../configure --prefix=/opt/homebrew/opt/gcc@11 --libdir=/opt/homebrew/opt/gcc@11/lib/gcc/11 --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-11 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 11.3.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --build=aarch64-apple-darwin21 --with-system-zlib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk\nThread model: posix\nSupported LTO compression algorithms: zlib zstd\ngcc version 11.3.0 (Homebrew GCC 11.3.0)\n
      3. Modify the bm_utils.c file in the ssb-dbgen directory:

        • Change the #include <malloc.h> in line 41 to #include <sys/malloc.h>

        • Change the open(fullpath, ((*mode == 'r')?O_RDONLY:O_WRONLY)|O_CREAT|O_LARGEFILE,0644); in line 398 to open(fullpath, ((*mode == 'r')?O_RDONLY:O_WRONLY)|O_CREAT,0644);

      4. Modify the varsub.c file in the ssb-dbgen directory:

        • Change the #include <malloc.h> in line 5 to #include <sys/malloc.h>
      5. Modify the makefile file in the ssb-dbgen directory:

        • Change the CC = gcc in line 5 to CC = gcc-11
      6. Enter into ssb-dbgen directory again and compile:

        cd ssb-dbgen\nmake\n
      7. Check the ssb-dbgen directory, when the the dbgen file is generated, indicating that the compilation is successful.

      "},{"location":"MatrixOne/FAQs/deployment-faqs/#i-built-matrixone-in-the-main-branch-initially-but-encountered-panic-when-switching-to-other-versions-for-building","title":"I built MatrixOne in the main branch initially but encountered panic when switching to other versions for building","text":"

      The storage formats between MatrixOne version 0.8.0 and its earlier versions are not compatible with each other. This means that when executing make build, the system will automatically generate a data directory file named mo-data to store data.

      In the future, if you need to switch to another branch and re-execute make build to build MatrixOne, it may cause a panic situation to occur. In this case, you need first to clean the mo-data data directory (that is, execute the rm -rf mo-data command), and then rebuild MatrixOne.

      Reference code example:

      [root ~]# cd matrixone  // Go to the matrixone directory\n[root ~]# git branch // Check the current branch\n* 0.8.0\n[root ~]# make build // Build matrixone\n...    // The build process code is omitted here. If you want to switch to another version, such as version 0.7.0,\n[root ~]# git checkout 0.7.0 // Switch to version 0.7.0\n[root ~]# rm -rf mo-data // Clean up the data directory\n[root ~]# make build // Build matrixone again\n...    // The build process code is omitted here\n[root ~]# ./mo-service --daemon --launch ./etc/launch/launch.toml &> test.log &   // Start MatrixOne service in the terminal backend\n

      Note

      The MatrixOne version 0.8.0 is compatible with the storage format of older versions. If you use version 0.8.0 or a higher version, there is no need to clean the data file directory when switching to other branches and buildings.

      "},{"location":"MatrixOne/FAQs/deployment-faqs/#password-authentication-error-when-connecting-to-the-matrixone-cluster-via-proxy-with-cn-label","title":"Password authentication error when connecting to the MatrixOne cluster via proxy with CN label","text":"
      • Issue Reason: Incorrect connection string formatting. Support for extending the username field is available when connecting to the MatrixOne cluster through the MySQL client. You can add a ? after the username and follow it with CN group labels. CN group labels consist of key-value pairs separated by = and multiple key-value pairs are separated by commas ,.

      • Solution: Please refer to the following example.

      Assuming the configuration for the CN group in your MatrixOne's mo.yaml configuration file is as shown below:

      ## Displaying partial code only\n...\n- cacheVolume:\nsize: 100Gi\ncnLabels:\n- key: workload\nvalues:\n- bk\n...\n

      When connecting to the MatrixOne cluster through the MySQL client, you can use the following command example: mysql -u root?workload=bk -p111 -h 10.206.16.10 -P 31429. In this command, workload=bk is the CN label, connected using =.

      Similarly, when using the mo-dump tool to export data, refer to the following command example: mo-dump -u \"dump?workload=bk\" -h 10.206.16.10 -P 31429 -db tpch_10g > /tmp/mo/tpch_10g.sql.

      "},{"location":"MatrixOne/FAQs/product-faqs/","title":"Product FAQs","text":"
      • What is MatrixOne?

      MatrixOne is a future-oriented hyperconverged cloud & edge native DBMS that supports transactional, analytical, and streaming workload with a simplified and distributed database engine, across multiple data centers, clouds, edges, and other heterogenous infrastructures. The all-in-one architecture of MatrixOne will significantly simplify database management and maintenance, creating a single database that can serve multiple data applications. For information about MatrixOne, you can see MatrixOne Introduction.

      • Where can I apply MatrxOne?

      MatrixOne provides users with HTAP services to support hybrid workloads. It can be used to build data warehouse or data platforms.

      • Is MatrixOne based on MySQL or some other database?

      MatrixOne is a completely redesigned database. It's compatible with part of MySQL syntax and semantics. We are currently working to support more database semantics such as PostgreSQL, Hive, Clickhouse, since we intend to develop MatrixOne as a hyperconverged database. To learn more about the compatibility with MySQL, you can visit MySQL-Compatibility.

      • Which programming language is MatrixOne developed with?

      Currently, the primary programming language used for our programming in Golang.

      • What operating system does MatrixOne support?

      MatrixOne supports Linux and macOS. Please refer to deployment FAQ for more details.

      • Which MatrixOne data types are supported?

      You can see data types in MatrixOne to learn more about the data types we support.

      • Where can I deploy MatrixOne?

      MatrixOne can be deployed on-premise, public cloud, private cloud, or Kubernetes.

      • Can I contribute to MatrixOne?

      Yes, MatrixOne is an open-source project developed on GitHub. Contribution instructions are published in Contribution Guide. We welcome developers to contribute to the MatrixOne community.

      • In addition to the MatrixOne documentation, are there any other ways to acquire MatrixOne knowledge?

      Currently, MatrixOne documentation is the most important and timely way to get MatrixOne related knowledge. In addition, we also have some technical communication groups in Slack and WeChat. If you have any needs, contact opensource@matrixorigin.io.

      "},{"location":"MatrixOne/FAQs/sql-faqs/","title":"SQL FAQs","text":"
      • Are functions and other keywords case sensitive?

      No, they are not case sensitive. Only in one case case is sensitive in MatrixOne, if user creates table and attributes with ``, the name in`` is case sensitive. To find this table name or attribute name in your query, it needs to be in `` as well.

      • How do I export data from MatrixOne to a file?

      You can use SELECT INTO OUTFILE command to export data from MatrixOne to a csv file (only to the server host, not to the remote client). For this command, you can see SELECT Reference.

      • What is the size limit of a transaction in MatrixOne?

      The transaction size is limited to the memory size you have for hardware environment.

      • What kind of character set does MatrixOne support?

      MatrixOne supports the UTF-8 character set by default and currently only supports UTF-8.

      • What is the sql_mode in MatrixOne?

      MatrixOne doesn't support modifying the sql_mode for now, the default sql_mode is as the only_full_group_by in MySQL.

      • How do I bulk load data into MatrixOne?

      MatrixOne provides two methods of bulk load data: 1. Using source filename command from shell, user can load the SQL file with all DDL and insert data statements. 2. Using load data infile...into table... command from shell, user can load an existing .csv file to MatrixOne.

      • How do I know how my query is executed?

      To see how MatrixOne executes for a given query, you can use the EXPLAIN statement, which will print out the query plan.

      EXPLAIN SELECT col1 FROM tbl1;\n
      "},{"location":"MatrixOne/Get-Started/basic-sql/","title":"Explore SQL with MatrixOne","text":"

      MatrixOne is compatible with MySQL, you can use MySQL statements directly in most of the cases. For unsupported features, see MySQL Compatibility, and for more information on connecting to MatriOne, see Using client connect to the MatrixOne server.

      "},{"location":"MatrixOne/Get-Started/basic-sql/#what-is-sql","title":"What is SQL?","text":"

      The Structured Query Language (SQL) is used to manage a relational database management system (RDBMS). The scope of SQL includes data insertion, query, update, and delete, database schema creation and modification, and data access control.

      "},{"location":"MatrixOne/Get-Started/basic-sql/#how-many-types-sql-does-matrixone-have","title":"How many types SQL does MatrixOne have?","text":"

      SQL is divided into the following 6 types according to their functions in MatrixOne:

      • DDL (Data Definition Language): It is used to define database objects, including databases, tables, and views. Such as CREATE, ALTER, and DROP.

      • DML (Data Manipulation Language): It is used to manipulate application related records. Such as SELECT, DELETE, and INSERT.

      • DQL (Data Query Language): It is used to query the records after conditional filtering. Such as SELECT...FROM...[WHERE].

      • TCL (Transaction Control Language): It is used to manage transactions. Such as COMMIT,ROLLBACK, or SET TRANSACTION.

      • DCL (Data Control Language): It is used to define access privileges and security levels. Such as CREATET ACCOUNT, DROP ACCOUNT, and GRANT.

      • Other: Other types of management languages \u200b\u200bin MatrixOne are not directly related to data and are a general term for the acquisition and modification of database parameters and resource allocation. Such as SHOW, SET variable, and KILL.

      "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-show-create-and-drop-a-database","title":"Basic SQL about SHOW, CREATE and DROP a database","text":"

      A database in MatrixOne can be considered as a collection of objects such as tables.

      • To show the list of databases, use the SHOW DATABASES statement:
      SHOW DATABASES;\n
      • To create the database named dbdemo, use the CREATE DATABASE db_name [options]; statement, for example:
      CREATE DATABASE dbdemo;\n

      or:

      CREATE DATABASE IF NOT EXISTS dbdemo;\n

      Add IF NOT EXISTS to prevent an error if the database exists.

      • To use the database named dbdemo, use the following statement:
      USE dbdemo;\n
      • To show all the tables in a database, use the SHOW TABLES statement:
      SHOW TABLES FROM dbdemo;\n
      • To delete a database, use the DROP DATABASE statement:
      DROP DATABASE dbdemo;\n
      "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-create-show-and-drop-a-table","title":"Basic SQL about CREATE, SHOW, and DROP a table","text":"
      • To create a table, use the CREATE TABLE statement:
      CREATE TABLE table_name column_name data_type constraint;\n

      For example, to create a table named person which includes fields such as number, name, and birthday, use the following statement:

      CREATE TABLE person (\nid INT(11),\nname VARCHAR(255),\nbirthday DATE\n);\n
      • To view the statement that creates the table (DDL), use the SHOW CREATE statement:
      SHOW CREATE table person;\n

      Expected result:

      +--------+-----------------------------------------------------------------------------------------------------------------+\n| Table  | Create Table                                                                                                    |\n+--------+-----------------------------------------------------------------------------------------------------------------+\n| person | CREATE TABLE `person` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`birthday` DATE DEFAULT NULL\n) |\n+--------+-----------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
      • To delete a table, use the DROP TABLE statement:
      DROP TABLE person;\n
      "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-insert-update-and-delete-data","title":"Basic SQL about INSERT, UPDATE, and DELETE data","text":"

      Common DML features are adding, modifying, and deleting table records. The corresponding commands are INSERT, UPDATE, REPLACE and DELETE.

      • To insert data into a table, use the INSERT statement:
      INSERT INTO person VALUES(1,'tom','20170912');\n
      • To insert a record containing data of some fields into a table, use the INSERT statement:
      INSERT INTO person(id,name) VALUES('2','bob');\n
      • To update some fields of a record in a table, use the UPDATE statement:
      UPDATE person SET birthday='20180808' WHERE id=2;\n
      • To replace some field data of table records in the table, use the UPDATE statement:
      REPLACE INTO person SET birthday='20180809' WHERE id=2;\n
      • To delete the data in a table, use the DELETE statement:
      DELETE FROM person WHERE id=2;\n

      Note

      The UPDATE and DELETE statements without the WHERE clause as a filter operate on the entire table.

      "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-query-data","title":"Basic SQL about Query data","text":"

      DQL is used to retrieve the desired data rows from a table or multiple tables.

      • To view the data in a table, use the SELECT statement:
      SELECT * FROM person;\n

      Expected result:

      +------+------+------------+\n| id   | name | birthday   |\n+------+------+------------+\n|    1 | tom  | 2017-09-12 |\n+------+------+------------+\n1 row in set (0.00 sec)\n
      • To query a specific column, add the column name after the SELECT keyword:
      SELECT name FROM person;\n+------+\n| name |\n+------+\n| tom  |\n+------+\n1 rows in set (0.00 sec)\n

      Use the WHERE clause to filter all records that match the conditions and then return the result:

      SELECT * FROM person where id<5;\n

      Expected result:

      +------+------+------------+\n| id   | name | birthday   |\n+------+------+------------+\n|    1 | tom  | 2017-09-12 |\n+------+------+------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Get-Started/basic-sql/#basic-sql-about-create-grant-and-drop-a-user","title":"Basic SQL about CREATE, GRANT, and DROP a user","text":"

      CREATE, GRANT, and DROP are usually used to create or delete users, and manage user privileges.

      • To create a user, use the CREATE USER statement. The following example creates a user named mouser with the password 111:
      > CREATE USER mouser IDENTIFIED BY '111';\nQuery OK, 0 rows affected (0.10 sec)\n
      • To create a role for the user:
      > CREATE ROLE role_r1;\nQuery OK, 0 rows affected (0.05 sec)\n
      • To grant mouser the role_r1:
      > GRANT role_r1 to mouser;\nQuery OK, 0 rows affected (0.04 sec)\n
      • To grant mouser the privilege to create table in the dbdemo database:
      GRANT create table on database * to role_r1;\n
      • To check the privileges of mouser:
      > SHOW GRANTS for mouser@localhost;\n+-------------------------------------------------------+\n| Grants for mouser@localhost                           |\n+-------------------------------------------------------+\n| GRANT create table ON database * `mouser`@`localhost` |\n| GRANT connect ON account  `mouser`@`localhost`        |\n+-------------------------------------------------------+\n2 rows in set (0.02 sec)\n

      You have successfully granted the permission of create table in the database to mouser.

      • To delete mouser:
      DROP USER mouser;\n

      Privilege management is a huge but very useful function. For more information, see Privilege Management.

      "},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/","title":"Deploy standalone MatrixOne","text":"

      The applicable scenario of the standalone version of MatrixOne is to use a single development machine to deploy MatrixOne and experience the essential functions of MatrixOne, which is the same as using MySQL for the standalone version.

      Recommended operating system

      MatrixOne supports Linux and MacOS. For quick start, we recommend the following hardware specifications:

      Operating System Operating System Version CPU Memory Debian 11 and later x86 / ARM CPU; 4 Cores 16 GB Ubuntu 20.04 and later x86 / ARM CPU; 4 Cores 16 GB macOS Monterey 12.3 and later x86 / ARM CPU; 4 Cores 16 GB

      For more information on the required operating system versions for deploying MatrixOne, see Hardware and Operating system requirements.

      "},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#deploy-on-macos","title":"Deploy on macOS","text":"

      You can install and connect to MatrixOne on macOS in one of three ways that work best for you:

      • Building from source code
      • Using binary package
      • Using Docker
      "},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#deploy-on-linux","title":"Deploy on Linux","text":"

      You can install and connect to MatrixOne on Linux in one of three ways that work best for you:

      • Building from source code
      • Using binary package
      • Using Docker
      "},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#reference","title":"Reference","text":"
      • For more information on the method of connecting to MatrixOne, see:

        • Connecting to MatrixOne with Database Client Tool
        • Connecting to MatrixOne with JDBC
        • Connecting to MatrixOne with Python.
      • For more information on the questions of deployment,see Deployment FAQs.

      • For more information on distributed installation, see MatrixOne Distributed Cluster Deployment.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/","title":"Building from source code in Linux","text":"

      This document will guide you to deploy a standalone MatrixOne in a Linux environment using source code. You can use the mo_ctl tool to help you deploy and manage MatrixOne.

      MatrixOne supports x86 and ARM Linux systems. This article uses the Debian11.1 x86 architecture as an example to to show the entire deployment process. If you use the Ubuntu system, it should be noted that there is no root authority by default. It is recommended to add sudo to all the commands in the process.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#pre-dependency-reference","title":"Pre-dependency Reference","text":"

      To install and use the stand-alone MatrixOne through source code, you need to depend on the following software packages.

      Dependent software Version golang 1.20 or later gcc gcc8.5 or later git 2.20 or later MySQL Client 8.0 or later"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-1-install-dependency","title":"Step 1: Install Dependency","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1-install-go","title":"1. Install Go","text":"
      1. Click Go Download and install to enter its official documentation, and follow the installation steps to complete the Go installation.

      2. To verify whether Go is installed, please execute the code go version. When Go is installed successfully, the example code line is as follows:

        go version go1.20.4 linux/amd64\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#2-install-gcc","title":"2. Install GCC","text":"
      1. Debian 11.1 generally comes with GCC version 9.0 or above. To verify whether the GCC is installed:

        gcc -v\nbash: gcc: command not found\n

        As shown in the code, the version of GCC is not displayed, the GCC environment needs to be installed.

      2. Click GCC Download and install to enter its official documentation, and follow the installation steps to complete the GCC installation.

      3. To verify whether GCC is installed, execute the code gcc -v. When GCC is installed successfully, the example code line is as follows (only part of the code is displayed):

        Using built-in specs.\nCOLLECT_GCC=gcc\n...\nThread model: posix\ngcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#3-install-git","title":"3. Install Git","text":"
      1. To verify whether Git is installed, execute the code git version. As shown in the code, if the version of git is not displayed, it means that Git needs to be installed.

        git version\n-bash: git: command not found\n
      2. Install Git with the following command:

        sudo apt install git\n
      3. To verify whether Git is installed, please execute the code git version, the code line example of a successful installation is as follows:

        git version\ngit version 2.40.0\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#4-install-mysql-client","title":"4. Install MySQL Client","text":"

      The Debian11.1 version does not have MySQL Client installed by default, so it needs to be downloaded and installed manually.

      1. To install MySQL Client, you need to use the wget download tool, wget is used to download files from the specified URL. Execute the following commands in sequence to install wget:

        ## Update the software source list cache\nsudo apt udpate\n## install wget\nsudo apt install wget\n

        After the installation is complete, please enter the following command to verify:

        wget -V\n

        The result of a successful installation (only a part of the code is displayed) is as follows:

        GNU Wget 1.21.3 built on linux-gnu.\n...\nCopyright (C) 2015 Free Software Foundation, Inc.\n...\n
      2. Execute the following commands in sequence to install MySQL Client:

        wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
      3. Execute the command mysql --version to test whether MySQL is available. The result of the successful installation is as follows:

        mysql --version\nmysql  Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-2-install-the-mo_ctl-tool","title":"Step 2: Install the mo_ctl tool","text":"

      mo_ctl is a command-line tool for deploying, installing, and managing MatrixOne. It is very convenient to perform various operations on MatrixOne. See mo_ctl Tool for complete usage details.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1-install-the-mo_ctl-tool","title":"1. Install the mo_ctl tool","text":"

      The mo_ctl tool can be installed through the following command:

      wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && bash +x ./install.sh\n

      After the installation is complete, verify whether the installation is successful through the mo_ctl command:

      root@VM-16-2-debian:~# mo_ctl\nUsage             : mo_ctl [option_1] [option_2]\n\n[option_1]      : available: connect | ddl_connect | deploy | get_branch | get_cid | get_conf | help | pprof | precheck | restart | set_conf | sql | start | status | stop | uninstall | upgrade | watchdog\n  1) connect      : connect to mo via mysql client using connection info configured\n  2) ddl_convert  : convert ddl file to mo format from other types of database\n  3) deploy       : deploy mo onto the path configured\n  4) get_branch   : upgrade or downgrade mo from current version to a target commit id or stable version\n  5) get_cid      : print mo git commit id from the path configured\n  6) get_conf     : get configurations\n  7) help         : print help information\n  8) pprof        : collect pprof information\n  9) precheck     : check pre-requisites for mo_ctl\n  10) restart     : a combination operation of stop and start\n  11) set_conf    : set configurations\n  12) sql         : execute sql from string, or a file or a path containg multiple files\n  13) start       : start mo-service from the path configured\n  14) status      : check if there's any mo process running on this machine\n  15) stop        : stop all mo-service processes found on this machine\n  16) uninstall   : uninstall mo from path MO_PATH=/data/mo//matrixone\n  17) upgrade     : upgrade or downgrade mo from current version to a target commit id or stable version\n  18) watchdog    : setup a watchdog crontab task for mo-service to keep it alive  \n  e.g.            : mo_ctl status\n\n  [option_2]        : Use \" mo_ctl [option_1] help \" to get more info\n  e.g.            : mo_ctl deploy help\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#2-set-mo_ctl-parameters-optional","title":"2. Set mo_ctl parameters (Optional)","text":"

      Some parameters in the mo_ctl tool need to be set and you can view all current parameters through mo_ctl get_conf.

      root@VM-16-2-debian:~# mo_ctl get_conf\n2023-08-23 18:23:35.444 UTC+0800    [INFO]    Below are all configurations set in conf file /root/mo_ctl/conf/env.sh\nMO_PATH=\"/data/mo/\"\nMO_LOG_PATH=\"${MO_PATH}/matrixone/logs\"\nMO_HOST=\"127.0.0.1\"\nMO_PORT=\"6001\"\nMO_USER=\"root\"\nMO_PW=\"111\"\nMO_DEPLOY_MODE=\"host\"\nMO_REPO=\"matrixorigin/matrixone\"\nMO_IMAGE_PREFIX=\"nightly\"\nMO_IMAGE_FULL=\"\"\nMO_CONTAINER_NAME=\"mo\"\nMO_CONTAINER_PORT=\"6001\"\nMO_CONTAINER_DEBUG_PORT=\"12345\"\nCHECK_LIST=(\"go\" \"gcc\" \"git\" \"mysql\" \"docker\")\nGCC_VERSION=\"8.5.0\"\nCLANG_VERSION=\"13.0\"\nGO_VERSION=\"1.20\"\nMO_GIT_URL=\"https://github.com/matrixorigin/matrixone.git\"\nMO_DEFAULT_VERSION=\"1.0.0-rc1\"\nGOPROXY=\"https://goproxy.cn,direct\"\nSTOP_INTERVAL=\"5\"\nSTART_INTERVAL=\"2\"\nMO_DEBUG_PORT=\"9876\"\nMO_CONF_FILE=\"${MO_PATH}/matrixone/etc/launch/launch.toml\"\nRESTART_INTERVAL=\"2\"\nPPROF_OUT_PATH=\"/tmp/pprof-test/\"\nPPROF_PROFILE_DURATION=\"30\"\n

      Generally, the parameters that may need to be adjusted are as follows:

      mo_ctl set_conf MO_PATH=\"/data/mo/matrixone\" # Set custom MatrixOne download path\nmo_ctl set_conf MO_GIT_URL=\"https://ghproxy.com/https://github.com/matrixorigin/matrixone.git\" # For the problem of slow downloading from the original GitHub address, set the proxy download address\nmo_ctl set_conf MO_DEFAULT_VERSION=\"1.0.0-rc1\" # Set the version of MatrixOne downloaded\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-3-get-matrixone-code","title":"Step 3: Get MatrixOne code","text":"

      Depending on your needs, choose whether you want to keep your code up to date, or if you want to get the latest stable version of the code.

      Get the MatrixOne(Develop Version) code to buildGet the MatrixOne(Stable Version) code to build

      The main branch is the default branch, the code on the main branch is always up-to-date but not stable enough.

      mo_ctl deploy main\n
      mo_ctl deploy 1.0.0-rc1\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-4-launch-matrixone-server","title":"Step 4: Launch MatrixOne server","text":"

      Launch the MatrixOne service through the mo_ctl start command.

      If the operation is regular, the following log will appear. The relevant operation logs of MatrixOne will be in /data/mo/logs/.

      root@VM-16-2-debian:~# mo_ctl start\n2023-07-07_09:55:01    [INFO]    No mo-service is running\n2023-07-07_09:55:01    [INFO]    Starting mo-service: cd /data/mo//matrixone/ && /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml >/data/mo//logs/stdout-20230707_095501.log 2>/data/mo//logs/stderr-20230707_095501.log\n2023-07-07_09:55:01    [INFO]    Wait for 2 seconds\n2023-07-07_09:55:03    [INFO]    At least one mo-service is running. Process info:\n2023-07-07_09:55:03    [INFO]    root      748128       1  2 09:55 ?        00:00:00 /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml\n2023-07-07_09:55:03    [INFO]    Pids:\n2023-07-07_09:55:03    [INFO]    748128\n2023-07-07_09:55:03    [INFO]    Start succeeded\n

      Note

      The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#step-5-connect-to-matrixone","title":"Step 5: Connect to MatrixOne","text":"

      One-click connection to MatrixOne service through mo_ctl connect command.

      This command will invoke the MySQL Client tool to connect to the MatrixOne service automatically.

      root@VM-16-2-debian:~# mo_ctl connect\n2023-07-07_10:30:20    [INFO]    Checking connectivity\n2023-07-07_10:30:20    [INFO]    Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

      Note

      The above connection and login account is the initial accounts root and the password 111; please change the initial password after logging in to MatrixOne; see MatrixOne Password Management. After changing the login username or password, you must set a new username and password through mo_ctl set_conf. For details, please refer to mo_ctl Tool.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/","title":"Using binary package in Linux","text":"

      This document will guide you to deploy a stand-alone version of MatrixOne in a Linux environment using binary packages. This installation solution does not need to install pre-dependencies and compile source packages. You can use the mo_ctl tool to help you deploy and manage MatrixOne.

      MatrixOne supports x86 and ARM Linux systems. This article uses the Debian11.1 x86 architecture as an example to to show the entire deployment process. If you use the Ubuntu system, it should be noted that there is no root authority by default. It is recommended to add sudo to all the commands in the process.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#pre-dependency-reference","title":"Pre-dependency Reference","text":"

      Only the MySQL Client tool must be installed to deploy and install MatrixOne through the binary package.

      Dependent software Version MySQL Client 8.0 or later"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-1-install-dependency","title":"Step 1: Install Dependency","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#1-install-wget-or-curl","title":"1. Install wget or curl","text":"

      We'll provide a method of Using binary package to install MatrixOne. If you prefer to use the command line, you can pre-install wget or curl.

      Tips: It is recommended that you download and install one of these two tools to facilitate future operations.

      Install wgetInstall curl

      The wget tool is used to download files from the specified URL. wget is a unique file download tool; it is very stable and has a download speed.

      Execute the following commands in sequence to install wget:

      ## Update the software source list cache\nsudo apt udpate\n## install wget\nsudo apt install wget\n

      After the installation is complete, please enter the following command to verify:

      wget -V\n

      The result of a successful installation (only a part of the code is displayed) is as follows:

      GNU Wget 1.21.3 built on linux-gnu.\n...\nCopyright (C) 2015 Free Software Foundation, Inc.\n...\n

      curl is a file transfer tool that works from the command line using URL rules. curl is a comprehensive transfer tool that supports file upload and download.

      Go to the Curl website according to the official installation guide to install curl. To verify that curl is installed successfully, use the following command line:

      curl --version\n

      The successful installation results (only part of the code is displayed) are as follows:

      curl 7.84.0 (x86_64-pc-linux-gnu) libcurl/7.84.0 OpenSSL/1.1.1k-fips zlib/1.2.11\nRelease-Date: 2022-06-27\n...\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#2-install-mysql-client","title":"2. Install MySQL Client","text":"

      The Debian11.1 version does not have MySQL Client installed by default, so it needs to be downloaded and installed manually.

      1. Execute the following commands in sequence to install MySQL Client:

        wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
      2. Execute the command mysql --version to test whether MySQL is available. The result of the successful installation is as follows:

        mysql --version\nmysql  Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-2-download-binary-packages-and-decompress","title":"Step 2: Download binary packages and decompress","text":"

      Download Method 1 and Download Method 2 need to install the download tools wget or curl first.

      Downloading method 1: Using wget to install binary packagesDownloading method 2: Using curl to install binary packagesDownloading method 3: Go to the page and download

      Binary for x86 architecture system:

      mkdir -p /root/matrixone & cd /root/\nwget https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-linux-x86_64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-linux-x86_64.zip\n

      Binary for ARM architecture system:

      mkdir -p /root/matrixone & cd /root/\nwget https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-linux-arm64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-linux-arm64.zip\n

      Binary for x86 architecture system:

      mkdir -p /root/matrixone & cd /root/\ncurl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-linux-x86_64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-linux-x86_64.zip\n

      Binary for ARM architecture system:

      mkdir -p /root/matrixone & cd /root/\ncurl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-linux-arm64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-linux-arm64.zip\n

      If you want a more intuitive way to download the page, go to the version 1.0.0-rc1, pull down to find the Assets column, and click the installation package mo-v1.0.0-rc1-linux-x86_64.zip or mo-v1.0.0-rc1-linux-arm64.zip can be downloaded.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-3-install-the-mo_ctl-tool","title":"Step 3: Install the mo_ctl tool","text":"

      mo_ctl is a command-line tool for deploying, installing, and managing MatrixOne. It is very convenient to perform various operations on MatrixOne. See mo_ctl Tool for complete usage details.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#1-install-the-mo_ctl-tool","title":"1. Install the mo_ctl tool","text":"

      The mo_ctl tool can be installed through the following command:

      wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && bash +x ./install.sh\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#2-set-mo_ctl-parameters","title":"2. Set mo_ctl parameters","text":"

      Using the following command sets the MatrixOne binary decompression file directory to the MO_PATH parameter of mo_ctl. mo_ctl will automatically look for the matrixone folder in MO_PATH.

      mo_ctl set_conf MO_PATH=\"/root\"\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-4-launch-matrixone-server","title":"Step 4: Launch MatrixOne server","text":"

      Launch the MatrixOne service through the mo_ctl start command.

      If the operation is regular, the following log will appear. The relevant operation logs of MatrixOne will be in /data/mo/logs/.

      root@VM-16-2-debian:~# mo_ctl start\n2023-07-07_09:55:01    [INFO]    No mo-service is running\n2023-07-07_09:55:01    [INFO]    Starting mo-service: cd /data/mo//matrixone/ && /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml >/data/mo//logs/stdout-20230707_095501.log 2>/data/mo//logs/stderr-20230707_095501.log\n2023-07-07_09:55:01    [INFO]    Wait for 2 seconds\n2023-07-07_09:55:03    [INFO]    At least one mo-service is running. Process info:\n2023-07-07_09:55:03    [INFO]    root      748128       1  2 09:55 ?        00:00:00 /data/mo//matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo//matrixone/etc/launch/launch.toml\n2023-07-07_09:55:03    [INFO]    Pids:\n2023-07-07_09:55:03    [INFO]    748128\n2023-07-07_09:55:03    [INFO]    Start succeeded\n

      Note

      The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#step-5-connect-to-matrixone","title":"Step 5: Connect to MatrixOne","text":"

      One-click connection to MatrixOne service through mo_ctl connect command.

      This command will invoke the MySQL Client tool to connect to the MatrixOne service automatically.

      root@VM-16-2-debian:~# mo_ctl connect\n2023-07-07_10:30:20    [INFO]    Checking connectivity\n2023-07-07_10:30:20    [INFO]    Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

      Note

      The above connection and login account is the initial accounts root and the password 111; please change the initial password after logging in to MatrixOne; see MatrixOne Password Management. After changing the login username or password, you must set a new username and password through mo_ctl set_conf. For details, please refer to mo_ctl Tool.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/","title":"Using Docker","text":"

      This document will guide you build standalone MatrixOne using Docker.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#step-1-download-and-install-docker","title":"Step 1: Download and install Docker","text":"
      1. Click Get Docker, enter into the Docker's official document page, depending on your operating system, download and install the corresponding Docker. It is recommended to choose Docker version 20.10.18 or later and strive to maintain consistency between the Docker client and Docker server versions.

      2. After the installation, you can verify the Docker version by using the following lines:

        docker --version\n

        The successful installation results are as follows:

        Docker version 20.10.18, build 100c701\n
      3. Execute the following command in your terminal, start Docker and check whether the running status is successfully:

        systemctl start docker\nsystemctl status docker\n

        The following code example indicates that Docker is running. Active: active (running) shows that Docker is running.

        docker.service - Docker Application Container Engine\n   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)\n   Active: active (running) since Sat 2022-11-26 17:48:32 CST; 6s ago\n     Docs: https://docs.docker.com\n Main PID: 234496 (dockerd)\n    Tasks: 8\n   Memory: 23.6M\n
      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#step-2-create-and-run-the-container-of-matrixone","title":"Step 2: Create and run the container of MatrixOne","text":"

      It will pull the image from Docker Hub if not exists. You can choose to pull the stable version image or the develop version image.

      Stable Version Image(1.0.0-rc1 version)Develop Version Image
      docker pull matrixorigin/matrixone:1.0.0-rc1\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.0.0-rc1\n

      If you are using the network in mainland China, you can pull the MatrixOne stable version image on Alibaba Cloud:

      docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.0.0-rc1\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.0.0-rc1\n

      If you want to pull the develop version image, see Docker Hub, get the image tag. An example as below:

      docker pull matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:nightly-commitnumber\n

      If you are using the network in mainland China, you can pull the MatrixOne develop version image on Alibaba Cloud:

      docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\n

      Note: The nightly version is updated once a day.

      Note

      If your Docker version is lower than 20.10.18 or the Docker client and server versions are inconsistent, upgrading to the latest stable version before attempting is recommended. If you choose to proceed with the current versions, you need to add the parameter --privileged=true to the docker run command, as shown below:

      docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.0.0-rc1\n

      Note

      The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

      If you need to mount data directories or customize configure files, see Mount the directory to Docker container.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#step-3-connect-to-standalone-matrixone","title":"Step 3: Connect to standalone MatrixOne","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#install-and-configure-mysql-client","title":"Install and configure MySQL Client","text":"

      The Debian11.1 version does not have MySQL Client installed by default, so it needs to be downloaded and installed manually.

      1. Execute the following commands in sequence:

        wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
      2. Execute the command mysql --version to test whether MySQL is available. The result of the successful installation is as follows:

        mysql --version\nmysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n

      Tips: Currently, MatrixOne is only compatible with the Oracle MySQL client. This means some features might not work with the MariaDB or Percona clients.

      "},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#connect-to-matrixone","title":"Connect to MatrixOne","text":"

      You can use the MySQL command-line client to connect to MatrixOne server. Open a new terminal window and enter the following command:

      ```\nmysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password:  # The default initial password is 111\n```\n

      Currently, MatrixOne only supports the TCP listener.

      Info

      The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/","title":"Building from source code in macOS","text":"

      This document will guide you to deploy a standalone version of MatrixOne in a macOS environment using source code. You can use the mo_ctl tool to help you deploy and manage MatrixOne.

      MatrixOne supports x86 and ARM macOS systems. This article uses the Macbook M1 ARM version as an example to show the entire deployment process.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#pre-dependency-reference","title":"Pre-dependency Reference","text":"

      To install and use the stand-alone MatrixOne through source code, you need to depend on the following software packages.

      Dependent software Version golang 1.20 or later gcc/clang gcc8.5 or later, clang13.0 or later git 2.20 or later MySQL Client 8.0 or later"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-1-install-dependency","title":"Step 1: Install Dependency","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#1-install-go","title":"1. Install Go","text":"
      1. Click Go Download and install to enter its official documentation, and follow the installation steps to complete the Go installation.

      2. To verify whether Go is installed, please execute the code go version. When Go is installed successfully, the example code line is as follows:

        > go version\ngo version go1.20.5 darwin/arm64\n
      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#2-install-gccclang","title":"2. Install GCC/Clang","text":"
      1. macOS generally has its own Clang compiler, which plays the same role as GCC. To verify whether the GCC is installed:

        gcc -v\nbash: gcc: command not found\n

        As shown in the code, the version of GCC is not displayed, the GCC/Clang environment needs to be installed.

      2. Click GCC Download and install to enter its official documentation, and follow the installation steps to complete the GCC installation. Or you can install Clang through Apple's official Xcode.

      3. To verify whether GCC/Clang is installed, please execute the code gcc -v. When GCC is installed successfully, the example code line is as follows:

        Apple clang version 14.0.3 (clang-1403.0.22.14.1)\nTarget: arm64-apple-darwin22.5.0\nThread model: posix\nInstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin\n
      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#3-install-git","title":"3. Install Git","text":"

      Install Git via the Official Documentation.

      Use the command git version to check whether the installation is successful. The code example of a successful installation is as follows:

      > git version\ngit version 2.40.0\n
      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#4-install-and-configure-mysql-client","title":"4. Install and configure MySQL Client","text":"
      1. Click MySQL Community Downloads to enter into the MySQL client download and installation page. According to your operating system and hardware environment, drop down to select Select Operating System > macOS, then drop down to select Select OS Version, and select the download installation package to install as needed.

      2. Configure the MySQL client environment variables:

        1. Open a new terminal window and enter the following command:

          cd ~\nsudo vim .bash_profile\n
        2. After pressing Enter on the keyboard to execute the above command, you need to enter the root user password, which is the root password you set in the installation window when you installed the MySQL client. If no password has been set, press Enter to skip the password.

        3. After entering/skiping the root password, you will enter .bash_profile, click i on the keyboard to enter the insert state, and you can enter the following command at the bottom of the file:

          export PATH=${PATH}:/usr/local/mysql/bin\n
      3. After the input is completed, click esc on the keyboard to exit the insert state, and enter :wq at the bottom to save and exit.

      4. Enter the command source .bash_profile, press Enter to execute, and run the environment variable.

      5. To test whether MySQL is available:

        Run the command mysql --version, if MySQL client is installed successfully, the example code line is as follows: mysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-2-install-the-mo_ctl-tool","title":"Step 2: Install the mo_ctl tool","text":"

      mo_ctl is a command-line tool for deploying, installing, and managing MatrixOne. It is very convenient to perform various operations on MatrixOne. See mo_ctl Tool for complete usage details.

      1. First, install the wget download tool: Go to the Homebrew page and follow the steps to install Homebrew first, then install wget. To verify whether wget is installed successfully, you can use the following command line:

        wget -V\n

        The successful installation results (only part of the code is displayed) are as follows:

        GNU Wget 1.21.3 \u5728 darwin21.3.0 \u4e0a\u7f16\u8bd1\n...\nCopyright \u00a9 2015 Free Software Foundation, Inc.\n...\n
      2. The mo_ctl tool can be installed through the following command:

        wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
      3. After the installation is complete, verify whether the installation is successful through the mo_ctl command:

        > mo_ctl\nUsage             : mo_ctl [option_1] [option_2]\n\n[option_1]      : available: connect | ddl_connect | deploy | get_branch | get_cid | get_conf | help | pprof | precheck | restart | set_conf | sql | start | status | stop | uninstall | upgrade | watchdog\n1) connect      : connect to mo via mysql client using connection info configured\n2) ddl_convert  : convert ddl file to mo format from other types of database\n3) deploy       : deploy mo onto the path configured\n4) get_branch   : upgrade or downgrade mo from current version to a target commit id or stable version\n5) get_cid      : print mo git commit id from the path configured\n6) get_conf     : get configurations\n7) help         : print help information\n8) pprof        : collect pprof information\n9) precheck     : check pre-requisites for mo_ctl\n10) restart     : a combination operation of stop and start\n11) set_conf    : set configurations\n12) sql         : execute sql from string, or a file or a path containg multiple files\n13) start       : start mo-service from the path configured\n14) status      : check if there's any mo process running on this machine\n15) stop        : stop all mo-service processes found on this machine\n16) uninstall   : uninstall mo from path MO_PATH=/data/mo//matrixone\n17) upgrade     : upgrade or downgrade mo from current version to a target commit id or stable version\n18) watchdog    : setup a watchdog crontab task for mo-service to keep it alive\ne.g.            : mo_ctl status\n[option_2]      : Use \" mo_ctl [option_1] help \" to get more info\ne.g.            : mo_ctl deploy help\n
      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#set-mo_ctl-parameters-optional","title":"Set mo_ctl parameters (Optional)","text":"

      Some parameters in the mo_ctl tool need to be set and you can view all current parameters through mo_ctl get_conf.

      > mo_ctl get_conf\n2023-07-07_15:31:24    [INFO]    Below are all configurations set in conf file /Users/username/mo_ctl/conf/env.sh\nMO_PATH=\"/Users/username/mo/matrixone\"\nMO_LOG_PATH=\"${MO_PATH}/matrixone/logs\"\nMO_HOST=\"127.0.0.1\"\nMO_PORT=\"6001\"\nMO_USER=\"root\"\nMO_PW=\"111\"\nMO_DEPLOY_MODE=\"host\"\nMO_REPO=\"matrixorigin/matrixone\"\nMO_IMAGE_PREFIX=\"nightly\"\nMO_IMAGE_FULL=\"\"\nMO_CONTAINER_NAME=\"mo\"\nMO_CONTAINER_PORT=\"6001\"\nMO_CONTAINER_DEBUG_PORT=\"12345\"\nCHECK_LIST=(\"go\" \"gcc\" \"git\" \"mysql\" \"docker\")\nGCC_VERSION=\"8.5.0\"\nCLANG_VERSION=\"13.0\"\nGO_VERSION=\"1.20\"\nMO_GIT_URL=\"https://github.com/matrixorigin/matrixone.git\"\nMO_DEFAULT_VERSION=\"1.0.0-rc1\"\nGOPROXY=\"https://goproxy.cn,direct\"\nSTOP_INTERVAL=\"5\"\nSTART_INTERVAL=\"2\"\nMO_DEBUG_PORT=\"9876\"\nMO_CONF_FILE=\"${MO_PATH}/matrixone/etc/launch/launch.toml\"\nRESTART_INTERVAL=\"2\"\nPPROF_OUT_PATH=\"/tmp/pprof-test/\"\nPPROF_PROFILE_DURATION=\"30\"\n

      Generally, the parameters that may need to be adjusted are as follows:

      mo_ctl set_conf MO_PATH=\"/Users/username/mo/matrixone\" # Set custom MatrixOne download path\nmo_ctl set_conf MO_GIT_URL=\"https://ghproxy.com/https://github.com/matrixorigin/matrixone.git\" ## For the problem of slow downloading from the original GitHub address, set the proxy download address\nmo_ctl set_conf MO_DEFAULT_VERSION=\"1.0.0-rc1\" # Set the version of MatrixOne downloaded\n
      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-3-get-matrixone-code","title":"Step 3: Get MatrixOne code","text":"

      Depending on your needs, choose whether you want to keep your code up to date, or if you want to get the latest stable version of the code.

      Get the MatrixOne(Develop Version) code to buildGet the MatrixOne(Stable Version) code to build

      The main branch is the default branch, the code on the main branch is always up-to-date but not stable enough.

      mo_ctl deploy main\n
      mo_ctl deploy 1.0.0-rc1\n
      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-4-launch-matrixone-server","title":"Step 4: Launch MatrixOne server","text":"

      Launch the MatrixOne service through the mo_ctl start command.

      If the operation is regular, the following log will appear. The relevant operation logs of MatrixOne will be in /data/mo/logs/.

      > mo_ctl start\n2023-07-07_15:33:45    [INFO]    No mo-service is running\n2023-07-07_15:33:45    [INFO]    Starting mo-service: cd /Users/username/mo/matrixone/matrixone/ && /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml >/Users/username/mo/matrixone/matrixone/logs/stdout-20230707_153345.log 2>/Users/username/mo/matrixone/matrixone/logs/stderr-20230707_153345.log\n2023-07-07_15:33:45    [INFO]    Wait for 2 seconds\n2023-07-07_15:33:48    [INFO]    At least one mo-service is running. Process info:\n2023-07-07_15:33:48    [INFO]      501 66932     1   0  3:33PM ??         0:00.27 /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml\n2023-07-07_15:33:48    [INFO]    Pids:\n2023-07-07_15:33:48    [INFO]    66932\n2023-07-07_15:33:48    [INFO]    Start succeeded\n

      Note

      The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#step-5-connect-to-matrixone","title":"Step 5: Connect to MatrixOne","text":"

      One-click connection to MatrixOne service through mo_ctl connect command.

      This command will invoke the MySQL Client tool to connect to the MatrixOne service automatically.

      > mo_ctl connect\n2023-07-07_10:30:20    [INFO]    Checking connectivity\n2023-07-07_10:30:20    [INFO]    Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

      Note

      The above connection and login account is the initial accounts root and the password 111; please change the initial password after logging in to MatrixOne; see MatrixOne Password Management. After changing the login username or password, you must set a new username and password through mo_ctl set_conf. For details, please refer to mo_ctl Tool.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/","title":"Using binary package in macOS","text":"

      This document will guide you to deploy a stand-alone version of MatrixOne in a macOS environment using binary packages. This installation solution does not need to install pre-dependencies and compile source packages. You can use the mo_ctl tool to help you deploy and manage MatrixOne.

      MatrixOne supports x86 and ARM macOS systems. This article uses the Macbook M1 ARM version as an example to show the entire deployment process.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#pre-dependency-reference","title":"Pre-dependency Reference","text":"

      Only the MySQL Client tool must be installed to deploy and install MatrixOne through the binary package.

      Dependent software Version MySQL Client 8.0 or later"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-1-install-dependency","title":"Step 1: Install Dependency","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#install-and-configure-mysql-client","title":"Install and configure MySQL Client","text":"
      1. Click MySQL Community Downloads to enter into the MySQL client download and installation page. According to your operating system and hardware environment, drop down to select Select Operating System > macOS, then drop down to select Select OS Version, and select the download installation package to install as needed.

      2. Configure the MySQL client environment variables:

        1. Open a new terminal window and enter the following command:

          cd ~\nsudo vim .bash_profile\n
        2. After pressing Enter on the keyboard to execute the above command, you need to enter the root user password, which is the root password you set in the installation window when you installed the MySQL client. If no password has been set, press Enter to skip the password.

        3. After entering/skiping the root password, you will enter .bash_profile, click i on the keyboard to enter the insert state, and you can enter the following command at the bottom of the file:

          export PATH=${PATH}:/usr/local/mysql/bin\n
      3. After the input is completed, click esc on the keyboard to exit the insert state, and enter :wq at the bottom to save and exit.

      4. Enter the command source .bash_profile, press Enter to execute, and run the environment variable.

      5. To test whether MySQL is available:

        Run the command mysql --version, if MySQL client is installed successfully, the example code line is as follows: mysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-2-download-binary-packages-and-decompress","title":"Step 2: Download binary packages and decompress","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#1-install-wget-or-curl","title":"1. Install wget or curl","text":"

      We'll provide a method of Using binary package to install MatrixOne. If you prefer to use the command line, you can pre-install wget or curl.

      Tips: It is recommended that you download and install one of these two tools to facilitate future operations.

      Install wgetInstall curl

      The wget tool is used to download files from the specified URL. wget is a unique file download tool; it is very stable and has a download speed.

      Go to the Homebrew page and follow the instructions to install Homebrew first and then install wget. To verify that wget is installed successfully, use the following command line:

      wget -V\n

      The successful installation results (only part of the code is displayed) are as follows:

      GNU Wget 1.21.3 \u5728 darwin21.3.0 \u4e0a\u7f16\u8bd1.\n...\nCopyright \u00a9 2015 Free Software Foundation, Inc.\n...\n

      curl is a file transfer tool that works from the command line using URL rules. curl is a comprehensive transfer tool that supports file upload and download.

      Go to the Curl website according to the official installation guide to install curl. To verify that curl is installed successfully, use the following command line:

      curl --version\n

      The successful installation results (only part of the code is displayed) are as follows:

      curl 7.84.0 (x86_64-apple-darwin22.0) libcurl/7.84.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.47.0\nRelease-Date: 2022-06-27\n...\n
      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#2-download-binary-packages-and-decompress","title":"2. Download binary packages and decompress","text":"

      Download Method 1 and Download Method 2 need to install the download tools wget or curl first.

      Downloading method 1: Using wget to install binary packagesDownloading method 2: Using curl to install binary packagesDownloading method 3: Go to the page and download

      Binary for x86 architecture system:

      mkdir -p /User/username/mo/matrixone & cd /User/username/mo\nwget https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-darwin-x86_64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-darwin-x86_64.zip\n

      Binary for ARM architecture system:

      mkdir -p /User/username/mo/matrixone & cd /User/username/mo\nwget https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-darwin-arm64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-darwin-arm64.zip\n

      Binary for x86 architecture system:

      mkdir -p /User/username/mo/matrixone & cd /User/username/mo\ncurl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-darwin-x86_64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-darwin-x86_64.zip\n

      Binary for ARM architecture system:

      mkdir -p /User/username/mo/matrixone & cd /User/username/mo\ncurl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.0.0-rc1/mo-v1.0.0-rc1-darwin-arm64.zip\nunzip -d matrixone/ mo-v1.0.0-rc1-darwin-arm64.zip\n

      If you want a more intuitive way to download the page, go to the version 1.0.0-rc1, pull down to find the Assets column, and click the installation package mo-v1.0.0-rc1-darwin-x86_64.zip or mo-v1.0.0-rc1-darwin-arm64.zip can be downloaded.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-3-install-the-mo_ctl-tool","title":"Step 3: Install the mo_ctl tool","text":"

      mo_ctl is a command-line tool for deploying, installing, and managing MatrixOne. It is very convenient to perform various operations on MatrixOne. See mo_ctl Tool for complete usage details.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#1-install-the-mo_ctl-tool","title":"1. Install the mo_ctl tool","text":"

      The mo_ctl tool can be installed through the following command:

      wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#2-set-mo_ctl-parameters","title":"2. Set mo_ctl parameters","text":"

      Using the following command sets the MatrixOne binary decompression file directory to the MO_PATH parameter of mo_ctl. mo_ctl will automatically look for the matrixone folder in MO_PATH.

      mo_ctl set_conf MO_PATH=\"/User/username/mo\"\n
      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-4-launch-matrixone-server","title":"Step 4: Launch MatrixOne server","text":"

      Launch the MatrixOne service through the mo_ctl start command.

      If the operation is regular, the following log will appear. The relevant operation logs of MatrixOne will be in /data/mo/logs/.

      > mo_ctl start\n2023-07-07_15:33:45    [INFO]    No mo-service is running\n2023-07-07_15:33:45    [INFO]    Starting mo-service: cd /Users/username/mo/matrixone/matrixone/ && /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml >/Users/username/mo/matrixone/matrixone/logs/stdout-20230707_153345.log 2>/Users/username/mo/matrixone/matrixone/logs/stderr-20230707_153345.log\n2023-07-07_15:33:45    [INFO]    Wait for 2 seconds\n2023-07-07_15:33:48    [INFO]    At least one mo-service is running. Process info:\n2023-07-07_15:33:48    [INFO]      501 66932     1   0  3:33PM ??         0:00.27 /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml\n2023-07-07_15:33:48    [INFO]    Pids:\n2023-07-07_15:33:48    [INFO]    66932\n2023-07-07_15:33:48    [INFO]    Start succeeded\n

      Note

      The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#step-5-connect-to-matrixone","title":"Step 5: Connect to MatrixOne","text":"

      One-click connection to MatrixOne service through mo_ctl connect command.

      This command will invoke the MySQL Client tool to connect to the MatrixOne service automatically.

      > mo_ctl connect\n2023-07-07_10:30:20    [INFO]    Checking connectivity\n2023-07-07_10:30:20    [INFO]    Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n

      Note

      The above connection and login account is the initial accounts root and the password 111; please change the initial password after logging in to MatrixOne; see MatrixOne Password Management. After changing the login username or password, you must set a new username and password through mo_ctl set_conf. For details, please refer to mo_ctl Tool.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/","title":"Using Docker","text":"

      This document will guide you build standalone MatrixOne using Docker.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#step-1-download-and-install-docker","title":"Step 1: Download and install Docker","text":"
      1. Click Get Docker, enter into the Docker's official document page, depending on your operating system, download and install the corresponding Docker. It is recommended to choose Docker version 20.10.18 or later and strive to maintain consistency between the Docker client and Docker server versions.

      2. After the installation, you can verify the Docker version by using the following lines:

        docker --version\n

        The successful installation results are as follows:

        Docker version 20.10.17, build 100c701\n
      3. Open your local Docker client and launch Docker.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#step-2-create-and-run-the-container-of-matrixone","title":"Step 2: Create and run the container of MatrixOne","text":"

      It will pull the image from Docker Hub if not exists. You can choose to pull the stable version image or the develop version image.

      Stable Version Image(1.0.0-rc1 version)Develop Version Image
      docker pull matrixorigin/matrixone:1.0.0-rc1\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.0.0-rc1\n

      If you are using the network in mainland China, you can pull the MatrixOne stable version image on Alibaba Cloud:

      docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.0.0-rc1\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.0.0-rc1\n

      If you want to pull the develop version image, see Docker Hub, get the image tag. An example as below:

      docker pull matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:nightly-commitnumber\n

      If you are using the network in mainland China, you can pull the MatrixOne develop version image on Alibaba Cloud:

      docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\n

      Note: The nightly version is updated once a day.

      Note

      If your Docker version is lower than 20.10.18 or the Docker client and server versions are inconsistent, upgrading to the latest stable version before attempting is recommended. If you choose to proceed with the current versions, you need to add the parameter --privileged=true to the docker run command, as shown below:

      docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.0.0-rc1\n

      Note

      The initial startup of MatrixOne approximately takes 20 to 30 seconds. After a brief wait, you can connect to MatrixOne using the MySQL client.

      If you need to mount data directories or customize configure files, see Mount the directory to Docker container.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#step-3-connect-to-standalone-matrixone","title":"Step 3: Connect to standalone MatrixOne","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#install-and-configure-mysql-client","title":"Install and configure MySQL Client","text":"
      1. Click MySQL Community Downloads to enter into the MySQL client download and installation page. According to your operating system and hardware environment, drop down to select Select Operating System > macOS, then drop down to select Select OS Version, and select the download installation package to install as needed.

        Note: MySQL client version 8.0.30 or later is recommended.

      2. Configure the MySQL client environment variables:

        1. Open a new terminal window and enter the following command:

          cd ~\nsudo vim .bash_profile\n
        2. After pressing Enter on the keyboard to execute the above command, you need to enter the root user password, which is the root password you set in the installation window when you installed the MySQL client. If no password has been set, press Enter to skip the password.

        3. After entering/skiping the root password, you will enter .bash_profile, click i on the keyboard to enter the insert state, and you can enter the following command at the bottom of the file:

          export PATH=${PATH}:/usr/local/mysql/bin\n
        4. After the input is completed, click esc on the keyboard to exit the insert state, and enter :wq at the bottom to save and exit.

        5. Enter the command source .bash_profile, press Enter to execute, and run the environment variable.

        6. To test whether MySQL is available:

          • Method 1: Enter mysql -u root -p, press Enter to execute, the root user password is required, if mysql> is displayed, it means that the MySQL client is enabled.

          • Method 2: Run the command mysql --version, if MySQL client is installed successfully, the example code line is as follows: mysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)

        7. If MySQL is available, close the current terminal and browse the next chapter Connect to MatrixOne Server.

      Tips: Currently, MatrixOne is only compatible with the Oracle MySQL client. This means that some features might not work with the MariaDB client or Percona client.

      "},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#connect-to-matrixone","title":"Connect to MatrixOne","text":"

      You can use the MySQL command-line client to connect to MatrixOne server. Open a new terminal window and enter the following command:

      mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: # The default initial password is 111\n

      Currently, MatrixOne only supports the TCP listener.

      Info

      The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

      "},{"location":"MatrixOne/Maintain/mo-directory-structure/","title":"MatrixOne Directory Structure","text":"

      After MatrixOne has been installed and connected, the MatrixOne automatically generates the following directories for storing data files or metadata information.

      Enter into the matrixone directory and execute ls to view the directory structure. The related directory structure and uses are as follows:

      matrixone \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//MatrixOne main directory |-- etc \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//configuration file directory \u2502\u00a0\u00a0\u00a0\u00a0 |-- quickstart \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//configration file directory |-- mo-data \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//data file directory \u2502\u00a0\u00a0\u00a0\u00a0 |-- local \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//local fileservice directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- cnservice\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//cn node information directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- dnservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//TN node information directory \u2502\u00a0\u00a0\u00a0\u00a0 |-- etl \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//external table directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- sys \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//Which account does the external table information belong to \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- logs \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//type of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 2022 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//the year of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 10 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//month of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 27 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//the number of days of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- metric \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//system indicators storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- rawlog \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//log storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- statement_info \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//information storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0 \u00a0\u00a0|-- merged \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//Merge records of past external table information \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 2022 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//the year of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 10 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//month of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 27 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//the number of days of statistics \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- metric \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//system indicators storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- rawlog \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//log storage directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- statement_info \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//information storage directory \u2502\u00a0\u00a0\u00a0\u00a0 |-- logservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//logservice directory | \u00a0\u00a0 \u00a0|-- 7c4dccb4-4d3c-41f8-b482-5251dc7a41bf \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//logservice node directory (randomly generated uuid) \u2502\u00a0\u00a0\u00a0\u00a0 |--hostname \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//MatrixOne server domain name \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 00000000000000000001 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//snapshot directory \u2502\u00a0\u00a0\u00a0\u00a0 | \u00a0\u00a0\u00a0|-- exported-snapshot \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//exporting snapshot Directory |\u00a0 \u00a0\u00a0\u00a0\u2502\u00a0\u00a0\u00a0\u00a0 |-- snapshot-part-n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//snapshot partial directory \u2502\u00a0\u00a0\u00a0\u00a0 \u2502\u00a0\u00a0\u00a0\u00a0 |-- tandb \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//bootstrap directory |-- s3 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//data storage directory

      "},{"location":"MatrixOne/Maintain/mo_ctl/","title":"mo_ctl Tool","text":"

      mo_ctl is a command-line tool that helps you deploy and install MatrixOne, start and stop control, and connect to the database.

      "},{"location":"MatrixOne/Maintain/mo_ctl/#feature-overview","title":"Feature Overview","text":"

      The operating systems that mo_ctl has adapted so far are shown in the table below:

      OS Version Debian 11 and above Ubuntu 20.04 and above macOS Monterey 12.3 and above

      The current function list of mo_ctl is shown in the table below.

      Command Function mo_ctl help See a list of statements and functions for the mo_ctl tool itself mo_ctl precheck Check dependencies required for MatrixOne source code installation, namely golang, gcc, git, MySQL Client mo_ctl deploy Download and install and compile the corresponding version of MatrixOne; the default is to install the latest stable version mo_ctl start Start MatrixOne service mo_ctl status Check if the MatrixOne service is running mo_ctl stop Stop all MatrixOne service processes mo_ctl restart Restart MatrixOne service mo_ctl connect Call MySQL Client to connect to MatrixOne service mo_ctl upgrade Upgrade/downgrade MatrixOne from the current version to a release version or commit id version mo_ctl set_conf Set various usage parameters mo_ctl get_conf View current parameters mo_ctl uninstall Uninstall MatrixOne from MO_PATH path mo_ctl watchdog Set a scheduled task to ensure the availability of MatrixOne service, check the status of MatrixOne every minute, and automatically pull up the service if the service is found to be suspended mo_ctl sql Execute SQL directly through commands or a text file composed of SQL mo_ctl ddl_convert A tool to convert MySQL DDL statements into MatrixOne statements mo_ctl get_cid View the source version of the current MatrixOne download repository mo_ctl get_branch View the branch version of the current MatrixOne download repository mo_ctl pprof Used to collect MatrixOne profiling data"},{"location":"MatrixOne/Maintain/mo_ctl/#install-mo_ctl","title":"Install mo_ctl","text":"

      Depending on whether you have internet access, you can choose to install the mo_ctl tool online or offline; you need to be careful to consistently execute commands as root or with sudo privileges (and add sudo before each command). Meanwhile, install.sh will use the unzip command to decompress the mo_ctl package; please ensure the unzip command is installed.

      "},{"location":"MatrixOne/Maintain/mo_ctl/#install-online","title":"Install Online","text":"
      wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo bash +x ./install.sh\n\n# alternate address\nwget https://ghproxy.com/https://github.com/matrixorigin/mo_ctl_standalone/blob/main/install.sh && sudo bash +x install.sh\n

      For users running this command in a macOS environment, if you are a non-root user, run install.sh with the following statement:

      sudo -u $(whoami) bash +x ./install.sh\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#install-offline","title":"Install Offline","text":"
      # 1. First, download the installation script to the local computer, and then upload it to the installation machine\nwget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh\nwget https://github.com/matrixorigin/mo_ctl_standalone/archive/refs/heads/main.zip -O mo_ctl.zip\n\n# alternate address\nwget https://ghproxy.com/https://github.com/matrixorigin/mo_ctl_standalone/blob/main/install.sh\nwget https://ghproxy.com/https://github.com/matrixorigin/mo_ctl_standalone/archive/refs/heads/main.zip -O mo_ctl.zip\n\n# 2. Install from offline package\nbash +x ./install.sh mo_ctl.zip\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#quick-start","title":"Quick Start","text":"

      You can quickly install and deploy the stand-alone version of MatrixOne through the following steps. For more information, see Deploy standalone MatrixOne.

      1. Use the mo_ctl help command to view the tool guide.

      2. Use the mo_ctl precheck command to check whether the pre-dependency conditions are met.

      3. Use the mo_ctl get_conf command to set relevant parameters, and the possible parameter configurations are as follows:

        # check default parameter values\nmo_ctl set_conf MO_PATH=\"/data/mo/matrixone\" # set your own mo path\nmo_ctl set_conf MO_GIT_URL=\"https://ghproxy.com/https://github.com/matrixorigin/matrixone.git\" # in case have network issues, you can set this conf by overwriting default value MO_GIT_URL=\"https:// github.com/matrixorigin/matrixone.git\"\n
      4. Use the mo_ctl deploycommand to install and deploy the latest stable version of MatrixOne.

      5. Use the mo_ctl start command to launch the MatrixOne service with the command .

      6. Use the mo_ctl connect command to connect to the MatrixOne service.

      "},{"location":"MatrixOne/Maintain/mo_ctl/#reference-command-guide","title":"Reference command guide","text":""},{"location":"MatrixOne/Maintain/mo_ctl/#help-print-reference-guide","title":"help - print reference guide","text":"
      mo_ctl help\nUsage             : mo_ctl [option_1] [option_2]\n\n[option_1]      : available: connect | ddl_connect | deploy | get_branch | get_cid | get_conf | help | pprof | precheck | query | restart | set_conf | sql | start | status | stop | uninstall | upgrade | watchdog\n  1) connect      : connect to mo via mysql client using connection info configured\n  2) ddl_convert  : convert ddl file to mo format from other types of database\n  3) deploy       : deploy mo onto the path configured\n  4) get_branch   : upgrade or downgrade mo from current version to a target commit id or stable version\n  5) get_cid      : print mo git commit id from the path configured\n  6) get_conf     : get configurations\n  7) help         : print help information\n  8) pprof        : collect pprof information\n  9) precheck     : check pre-requisites for mo_ctl\n  10) restart     : a combination operation of stop and start\n  11) set_conf    : set configurations\n  12) sql         : execute sql from string, or a file or a path containg multiple files\n  13) start       : start mo-service from the path configured\n  14) status      : check if there's any mo process running on this machine\n  15) stop        : stop all mo-service processes found on this machine\n  16) uninstall   : uninstall mo from path MO_PATH=/data/mo/20230712_1228//matrixone\n  17) upgrade     : upgrade or downgrade mo from current version to a target commit id or stable version\n  18) watchdog    : setup a watchdog crontab task for mo-service to keep it alive\n  e.g.            : mo_ctl status\n\n  [option_2]      : Use \" mo_ctl [option_1] help \" to get more info\n  e.g.            : mo_ctl deploy help\n

      Use mo_ctl [option_1] help for instructions on using the next-level mo_ctl [option_1] functionality.

      "},{"location":"MatrixOne/Maintain/mo_ctl/#precheck-check-pre-dependency","title":"precheck - check pre-dependency","text":"

      Before installing MatrixOne from the source code, use mo_ctl precheck to check the pre-dependency conditions. The pre-dependence depends on go/gcc/git/mysql(client).

      mo_ctl precheck help\nUsage         : mo_ctl precheck # check pre-requisites for mo_ctl\n   Check list : go gcc git mysql\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#deploy-install-matrixone","title":"deploy - install MatrixOne","text":"

      Use mo_ctl deploy [mo_version] [force] to install and deploy a stable version of MatrixOne, or a specified version. The force option can delete the existing version of MatrixOne in the same directory and force a new version to be reinstalled.

      mo_ctl deploy help\nUsage         : mo_ctl deploy [mo_version] [force] # deploy mo onto the path configured\n  [mo_version]: optional, specify an mo version to deploy\n  [force]     : optional, if specified will delete all content under MO_PATH and deploy from beginning\n  e.g.        : mo_ctl deploy             # default, same as mo_ctl deploy 1.0.0-rc1\n              : mo_ctl deploy main        # deploy development latest version\n              : mo_ctl deploy d29764a     # deploy development version d29764a\n              : mo_ctl deploy 1.0.0-rc1       # deploy stable verson 1.0.0-rc1\n              : mo_ctl deploy force       # delete all under MO_PATH and deploy verson 1.0.0-rc1\n              : mo_ctl deploy 1.0.0-rc1 force # delete all under MO_PATH and deploy stable verson 1.0.0-rc1 from beginning\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#start-launch-matrixone","title":"start - launch MatrixOne","text":"

      Use mo_ctl start to start MatrixOne service; the startup file path is located under MO_PATH.

      mo_ctl start help\nUsage         : mo_ctl start # start mo-service from the path configured\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#stop-stop-matrixone","title":"stop - stop MatrixOne","text":"

      Use mo_ctl stop [force] to stop all MatrixOne services on local machine, and if multiple MatrixOne services are running, they will also be stopped.

       mo_ctl stop help\nUsage : mo_ctl stop [force] # stop all mo-service processes found on this machine\n [force] : optional, if specified, will try to kill mo-services with -9 option, so be very carefully\n  e.g.: mo_ctl stop # default, stop all mo-service processes found on this machine\n              : mo_ctl stop force # stop all mo-services with kill -9 command\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#restart-restart-matrixone","title":"restart - restart MatrixOne","text":"

      Use mo_ctl restart [force] to stop all MatrixOne services on this machine and restart the MatrixOne services located in the path of MO_PATH.

      mo_ctl restart help\nUsage         : mo_ctl restart [force] # a combination operation of stop and start\n [force]      : optional, if specified, will try to kill mo-services with -9 option, so be very carefully\n  e.g.        : mo_ctl restart         # default, stop all mo-service processes found on this machine and start mo-serivce under path of conf MO_PATH\n              : mo_ctl restart force   # stop all mo-services with kill -9 command and start mo-serivce under path of conf MO_PATH\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#connect-using-mysql-client-to-connect-matrixone","title":"connect - using mysql-client to connect MatrixOne","text":"

      Use mo_ctl connect to connect to MatrixOne service, the connection parameters are set by mo_ctl tool.

      mo_ctl connect help\nUsage         : mo_ctl connect # connect to mo via mysql client using connection info configured\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#status-check-the-status-of-matrixone","title":"status - Check the status of MatrixOne","text":"

      Use mo_ctl status to check whether MatrixOne is running or not.

      mo_ctl status help\nUsage         : mo_ctl status # check if there's any mo process running on this machine\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#get_cid-print-matrixone-code-commit-id","title":"get_cid - print MatrixOne code commit id","text":"

      Use mo_ctl get_cid to print the MatrixOne repository commit id under the current MO_PATH path.

      mo_ctl get_cid help\nUsage : mo_ctl get_cid # print mo commit id from the path configured\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#get_branch-print-matrixone-code-commit-id","title":"get_branch - print MatrixOne code commit id","text":"

      Use mo_ctl get_branch to print the MatrixOne codebase branch under the current MO_PATH path.

      mo_ctl get_branch help\nUsage           : mo_ctl get_branch        # print which git branch mo is currently on\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#pprof-collect-performance-information","title":"pprof - Collect performance information","text":"

      Use mo_ctl pprof [item] [duration] to collect related performance information of MatrixOne, mainly for developers to debug.

      mo_ctl pprof help\nUsage         : mo_ctl pprof [item] [duration] # collect pprof information\n  [item]      : optional, specify what pprof to collect, available: profile | heap | allocs\n  1) profile  : default, collect profile pprof for 30 seconds\n  2) heap     : collect heap pprof at current moment\n  3) allocs   : collect allocs pprof at current moment\n  [duration]  : optional, only valid when [item]=profile, specifiy duration to collect profile\n  e.g.        : mo_ctl pprof\n              : mo_ctl pprof profile    # collect duration will use conf value PPROF_PROFILE_DURATION from conf file or 30 if it's not set\n              : mo_ctl pprof profile 30\n              : mo_ctl pprof heap\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#set_conf-configuration-parameters","title":"set_conf - configuration parameters","text":"

      Use mo_ctl set_conf [conf_list] to configure 1 or more usage parameters.

      mo_ctl set_conf help\nUsage         : mo_ctl setconf [conf_list] # set configurations\n [conf_list]  : configuration list in key=value format, seperated by comma\n  e.g.        : mo_ctl setconf MO_PATH=/data/mo/matrixone,MO_PW=M@trix0riginR0cks,MO_PORT=6101  # set multiple configurations\n              : mo_ctl setconf MO_PATH=/data/mo/matrixone                                       # set single configuration\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#get_conf-get-parameter-list","title":"get_conf - get parameter list","text":"

      Use mo_ctl get_conf [conf_list] to get one or more current configuration items.

      mo_ctl get_conf help\nUsage         : mo_ctl getconf [conf_list] # get configurations\n [conf_list]  : optional, configuration list in key, seperated by comma.\n              : use 'all' or leave it as blank to print all configurations\n  e.g.        : mo_ctl getconf MO_PATH,MO_PW,MO_PORT  # get multiple configurations\n              : mo_ctl getconf MO_PATH                # get single configuration\n              : mo_ctl getconf all                    # get all configurations\n              : mo_ctl getconf                        # get all configurations\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#mo_ctl-get_conf-detailed-parameter-list","title":"mo_ctl get_conf - Detailed Parameter List","text":"

      Using mo_ctl get_conf will print a list of all the parameters used by the current tool. Their meanings and value ranges are shown in the table below.

      Parameter Name Function Value Specification MO_PATH Location of MatrixOne's code repository and executables Folder path MO_LOG_PATH Location of MatrixOne's logs Folder path, default: ${MO_PATH}/matrixone/logs MO_HOST IP address for connecting to MatrixOne service IP address, default: 127.0.0.1 MO_PORT Port number for connecting to MatrixOne service Port number, default: 6001 MO_USER Username for connecting to MatrixOne service Username, default: root MO_PW Password for connecting to MatrixOne service Password, default: 111 CHECK_LIST Dependencies required for precheck Default: (\"go\" \"gcc\" \"git\" \"mysql\") GCC_VERSION gcc version to be checked in precheck Default: 8.5.0 GO_VERSION go version to be checked in precheck Default: 1.20 MO_GIT_URL Repository URL for fetching MatrixOne source code Default: https://github.com/matrixorigin/matrixone.git MO_DEFAULT_VERSION Default version of MatrixOne to be fetched Default: 1.0.0-rc1 GOPROXY Address of GOPROXY used for faster dependency retrieval in China Default: https://goproxy.cn, direct STOP_INTERVAL Interval to wait for service status check after stopping the service Default: 5 seconds START_INTERVAL Interval to wait for service status check after starting the service Default: 2 seconds MO_DEBUG_PORT Debug port for MatrixOne, usually used by developers Default: 9876 MO_CONF_FILE Launch configuration file for MatrixOne Default: ${MO_PATH}/matrixone/etc/launch/launch.toml RESTART_INTERVAL Interval to wait for service status check after restarting the service Default: 2 seconds PPROF_OUT_PATH Output path for collecting golang performance data Default: /tmp/pprof-test/ PPROF_PROFILE_DURATION Duration for collecting golang performance data Default: 30 seconds"},{"location":"MatrixOne/Maintain/mo_ctl/#ddl_convert-ddl-format-conversion","title":"ddl_convert - DDL format conversion","text":"

      Use mo_ctl ddl_convert [options] [src_file] [tgt_file] to convert a DDL file from other database syntax formats to MatrixOne's DDL format, currently only supported by mysql_to_mo mode.

      mo_ctl ddl_convert help\nUsage           : mo_ctl ddl_convert [options] [src_file] [tgt_file] # convert a ddl file to mo format from other types of database\n [options]      : available: mysql_to_mo\n [src_file]     : source file to be converted, will use env DDL_SRC_FILE from conf file by default\n [tgt_file]     : target file of converted output, will use env DDL_TGT_FILE from conf file by default\n  e.g.          : mo_ctl ddl_convert mysql_to_mo /tmp/mysql.sql /tmp/mo.sql\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#sql-execute-sql","title":"sql - Execute SQL","text":"

      Use mo_ctl sql [sql] to execute SQL text or SQL files.

      mo_ctl sql help\nUsage           : mo_ctl sql [sql]                 # execute sql from string, or a file or a path containg multiple files\n  [sql]         : a string quote by \"\", or a file, or a path\n  e.g.          : mo_ctl sql \"use test;select 1;\"  # execute sql \"use test;select 1\"\n                : mo_ctl sql /data/q1.sql          # execute sql in file /data/q1.sql\n                : mo_ctl sql /data/                # execute all sql files with .sql postfix in /data/\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#uninstall-uninstall-matrixone","title":"uninstall - Uninstall MatrixOne","text":"

      Use mo_ctl uninstall to uninstall MatrixOne from MO_PATH.

      mo_ctl uninstall help\nUsage           : mo_ctl uninstall        # uninstall mo from path MO_PATH=/data/mo//matrixone\n                                          # note: you will need to input 'Yes/No' to confirm before uninstalling\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#upgrade-upgradedowngrade-matrixone-version","title":"upgrade - upgrade/downgrade MatrixOne version","text":"

      Use mo_ctl upgrade version or mo_ctl upgrade commitid to upgrade or downgrade MatrixOne from the current version to a stable version or a commit id version.

      mo_ctl upgrade help\nUsage           : mo_ctl upgrade [version_commitid]   # upgrade or downgrade mo from current version to a target commit id or stable version\n [commitid]     : a commit id such as '38888f7', or a stable version such as '1.0.0-rc1'\n                : use 'latest' to upgrade to latest commit on main branch if you don't know the id\n  e.g.          : mo_ctl upgrade 38888f7              # upgrade/downgrade to commit id 38888f7 on main branch\n                : mo_ctl upgrade latest               # upgrade/downgrade to latest commit on main branch\n                : mo_ctl upgrade 1.0.0-rc1                # upgrade/downgrade to stable version 1.0.0-rc1\n
      "},{"location":"MatrixOne/Maintain/mo_ctl/#watchdog-keep-alive-matrixone","title":"watchdog - Keep Alive MatrixOne","text":"

      Use mo_ctl watchdog [options] to set a scheduled task to ensure the availability of MatrixOne service, check the status of MatrixOne every minute, and automatically pull up the service if it finds that the service is suspended.

      mo_ctl watchdog help\nUsage           : mo_ctl watchdog [options]   # setup a watchdog crontab task for mo-service to keep it alive\n [options]      : available: enable | disable | status\n  e.g.          : mo_ctl watchdog enable      # enable watchdog service for mo, by default it will check if mo-servie is alive and pull it up if it's dead every one minute\n                : mo_ctl watchdog disable     # disable watchdog\n                : mo_ctl watchdog status      # check if watchdog is enabled or disabled\n                : mo_ctl watchdog             # same as mo_ctl watchdog status\n
      "},{"location":"MatrixOne/Maintain/mount-data-by-docker/","title":"Mount directory to Docker container","text":"

      This document will teach you how to mount the data directory or your customized configuration file to the Docker container when you launch MatrixOne by using Docker.

      "},{"location":"MatrixOne/Maintain/mount-data-by-docker/#mount-the-data-directory","title":"Mount the data directory","text":"

      To ensure the safety of the data directory, mount the local data directory to the Docker container by the following steps:

      1. To check if MatrixOne has been running in Docker, execute the following command:

        docker ps -a\n
      2. To stop the running container if MatrixOne has been running in Docker, execute the following command:

        docker stop <containerID>\ndocker rm <containerID>\n

        Skip this step if MatrixOne is not running in Docker.

      3. Mount the local empty directory to the Docker container directory /mo-data, execute the following command:

        sudo docker run --name <name> --privileged -d -p 6001:6001 -v ${local_data_path}/mo-data:/mo-data:rw matrixorigin/matrixone:1.0.0-rc1\n
        Parameters Description ${local_data_path}/mo-data:/mo-data mount the local disk directory ${local_data_path}/mo-data to the container directory /mo-data Tips: The local data directory to be mounted must be an empty directory.
      "},{"location":"MatrixOne/Maintain/mount-data-by-docker/#mount-the-customized-configuration-file","title":"Mount the customized configuration file","text":"

      If you need to modify the configuration file. In that case, it would be best to copy the configuration file in Docker to your local directory and then mount the local directory where the configuration file is stored to the Docker container directory. Refer to the following steps to mount the configuration file to the Docker container:

      1. To check if MatrixOne has been running in Docker, execute the following command:

        docker ps -a\n
      2. To launch MatrixOne MatrixOne has not been running in Docker, execute the following command:

        docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.0.0-rc1\n
      3. Check the containerID that MatrixOne has been running in Docker, and copy the configuration file directory to the local directory:

        docker ps -a\ndocker cp <containerID>:/etc .\n
      4. To stop the MatrixOne when the copy is completed, execute the following command:

        docker stop <containerID>\ndocker rm <containerID>\n
      5. (Optional) Modify the configuration file and save it.

      6. Mount the configuration file to the Docker container directory and launch MatrixOne. Execute the following command:

        sudo docker run --name <name> --privileged -d -p 6001:6001 -v ${local_config_path}/etc:/etc:rw  --entrypoint \"/mo-service\" matrixorigin/matrixone:1.0.0-rc1 -launch /etc/launch/launch.toml\n
        Parameters Description ${local_config_path}/etc:/etc mount the local customize configration directory ${local_config_path}/etc to the container directory /etc --entrypoint \"/mo-service\" Specifies that the container starts the MatrixOne service -launch /etc/launch/launch.toml launch mode in /etc/

      For more information on the description of Docker run, run the commands docker run --help.

      "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/","title":"MatrixOne Backup and Recovery Overview","text":"

      Database backup and recovery are core operations for any database management system and are crucial for ensuring data security and availability. MatrixOne provides flexible and powerful database backup and recovery capabilities to ensure the integrity and continuity of user data. This article provides an overview of the importance of MatrixOne database backup and recovery, backup strategies, and backup methods.

      "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#backup-and-recovery-strategies","title":"Backup and Recovery Strategies","text":"

      Database backup and recovery can restore operational status in various disaster recovery scenarios.

      Here are backup and recovery methods for different situations:

      1. Operating System Crash:

        • With Physical Backup: Restore the entire database state using physical backup after a crash. Restore the backup to normal hardware conditions and apply redo logs to ensure data consistency.
        • With Logical Backup: Rebuild the database architecture and data on a new server using logical backup. First, install the database software, execute SQL statements from the logical backup to create tables, indexes, and more, and then import the data.
      2. Power (Detection) Failure:

        • With Physical Backup: Recover the database using physical backup after a failure. Restore the backup to normal hardware conditions and apply redo logs for data consistency.
        • With Logical Backup: Similarly, rebuild the database on a new server using logical backup.
      3. File System Crash:

        • With Physical Backup: Use a physical backup to recover the database, restore the backup to normal hardware conditions, and apply redo logs for data consistency.
        • With Logical Backup: After a crash, rebuild the database architecture and data on a new server.
      4. Hardware Issues (e.g., Hard Drive, Motherboard):

        • With Physical Backup: Recover the database using physical backup, restoring the backup to new hardware conditions and applying redo logs for data consistency.
        • With Logical Backup: Rebuild the database on new hardware using logical backup.

      For backup and recovery, consider the following strategies:

      1. Backup Frequency: Determine the frequency of backups, typically divided into full and incremental backups. Full backups consume more storage space and time but offer faster recovery, while incremental backups are more economical.

      2. Backup Storage: Choose a secure backup storage location to ensure backup data is not easily compromised or lost. Typically, use offline storage media or cloud storage for backups.

      3. Backup Retention Period: Determine the retention period for backup data to facilitate historical data retrieval and recovery when needed. Establish data retention policies based on regulations and business requirements.

      Regardless of the recovery scenario, follow these principles:

      1. Consider stopping database operations to prevent data changes.
      2. Choose an appropriate backup for recovery based on backup type.
      3. Restore backup files.
      4. Consider applying corresponding redo logs to ensure data consistency.
      5. Start the database and perform the necessary testing.
      "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#database-backup-methods","title":"Database Backup Methods","text":"

      MatrixOne provides multiple backup methods, considering database requirements, performance, resources, and recovery time.

      MatrixOne databases offer various backup tools to meet different scenarios and needs:

      1. modump: Used for exporting data and schemas from the database. It generates recoverable SQL scripts for logical backups.

      2. mo-backup: Used for physical backup and recovery. mo-backup is a tool for physical backup and recovery of MatrixOne enterprise services, helping protect your MatrixOne database and perform reliable recovery operations when needed.

        Note

        mo-backup is a physical backup and recovery tool for enterprise-level services. Contact your MatrixOne account manager for the tool download path and user guide.

      "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#logical-backup-and-recovery","title":"Logical Backup and Recovery","text":""},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#using-select-into-outfile-for-backup","title":"Using SELECT INTO OUTFILE for Backup","text":"

      Use the SELECT ... INTO OUTFILE command to export retrieved data in a specific format to a file. The exported file is created by the MatrixOne service and is only available on the MatrixOne server host. Exporting to the client file system is not supported. Ensure that the export directory does not have files with the same name to avoid overwriting new files.

      For more information on operational steps and examples, see Export data by SELECT INTO.

      "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#using-modump-for-backup","title":"Using modump for Backup","text":"

      MatrixOne supports logical backup using the modump tool, which generates SQL statements that can be used to recreate database objects and data.

      For more information on operational steps and examples, see Export data by MODUMP.

      "},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#using-command-line-batch-import-for-recovery","title":"Using Command-Line Batch Import for Recovery","text":"

      MatrixOne supports inserting many rows into database tables using the LOAD DATA command. It also supports importing table structures and data into the entire database using the' SOURCE' command.

      For more information, see Bulk Load Overview.

      "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/","title":"Backup and Recovery Concepts","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#physical-backup-vs-logical-backup","title":"Physical Backup vs. Logical Backup","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#physical-backup","title":"Physical Backup","text":"

      Physical backup directly copies database files to a backup medium, such as tape or disk. This method involves copying all physical data blocks of the database, including data files, control files, and redo log files. The backed-up data is the binary data stored on disk, making recovery operations typically faster.

      "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#logical-backup","title":"Logical Backup","text":"

      Logical backup involves backing up logical objects (e.g., tables, indexes, stored procedures) in the database using SQL statements. This backup method exports the definitions and data of logical objects to a backup file but does not include the binary data of database files. Although recovery may be slower, backup data is usually more readable and modifiable.

      "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#differences-between-physical-and-logical-backup","title":"Differences Between Physical and Logical Backup","text":"

      The primary difference between physical and logical backup lies in the form of the backed-up data. Physical backup copies the binary data on disk, while logical backup backs up the definitions and data of analytical objects. The two methods have differences in backup speed, data size, and backup flexibility.

      "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#full-backup-incremental-backup-and-differential-backup","title":"Full Backup, Incremental Backup, and Differential Backup","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#full-backup","title":"Full Backup","text":"

      Full backup involves backing up the entire dataset to storage devices, including all files and folders. While it is typically time-consuming and requires substantial storage space, it can restore data without relying on other backup files.

      "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#incremental-backup","title":"Incremental Backup","text":"

      Incremental backup only backs up recently changed or added files or data blocks. It backs up changes made since the last backup, typically consuming less backup time and storage space. Incremental backups are often performed between regular full backups to ensure the backup data stays up-to-date. You need all incremental backups and the latest full backup to restore data.

      "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#differential-backup","title":"Differential Backup","text":"

      Differential backup backs up data that has changed since the last full backup, resulting in more extensive backup data and longer backup times than incremental backups. When restoring data, you only need to restore the latest full and differential backups. As it does not depend on previous backup data, the recovery process is relatively simpler, and backup and restoration times are shorter.

      "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#differences-between-full-incremental-and-differential-backup","title":"Differences Between Full, Incremental, and Differential Backup","text":"
      • Full backup provides a complete data backup but requires more time and storage space.
      • Incremental backup is suitable for environments with minimal data changes, saving backup storage space and time but requiring reliance on previous backup data.
      • Differential backup suits environments with significant data changes, resulting in more extensive backup data, shorter recovery times, and a relatively straightforward backup and recovery process.
      "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#recovery","title":"Recovery","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#physical-recovery","title":"Physical Recovery","text":"

      Physical recovery involves database recovery using physical backups. It is typically used in severe failures such as disk failures, operating system failures, or file system failures. In physical recovery, specialized recovery tools or software read backup files or storage media's actual data blocks and attempt to repair damaged blocks.

      Physical recovery can quickly restore the database without executing SQL statements or other high-level operations. Additionally, physical recovery can restore all database objects, including tables, indexes, stored procedures, and more.

      "},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#complete-recovery-vs-incomplete-recovery","title":"Complete Recovery vs. Incomplete Recovery","text":"
      • Complete Recovery: Applies all redo logs from the backup set, restoring data to a point where all logs are committed.
      • Incomplete Recovery: Applies some redo logs or incremental backups, restoring data to a specific time defined by the backup redo logs.
      "},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/","title":"Backup and Restore by using mo-dump","text":"

      It is essential to back up your databases to recover your data and be up and running again in case problems occur, such as system crashes, hardware failures, or users deleting data by mistake. Backups are also essential as a safeguard before upgrading a MatrixOne installation, and they can be used to transfer a MatrixOne building to another system.

      MatrixOne currently only supports logical backup through the modump utility. modump is a command-line utility used to generate the logical backup of the MatrixOne database. It produces SQL Statements that can be used to recreate the database objects and data. You can look up the syntax and usage guide in the modump chapter.

      We will take a simple example to walk you through the backup and restore process with the modump utility.

      "},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/#steps","title":"Steps","text":""},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/#1-build-the-modump-binary","title":"1. Build the modump binary","text":"

      For more information on how to build the modump binary, see Build the modump binary.

      If the modump binary has been built, you can continue to browse the next chapter Generate the backup of a single database.

      "},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/#2-generate-the-backup-of-a-single-database","title":"2. Generate the backup of a single database","text":"

      We have a database t which is created by the following SQL.

      DROP DATABASE IF EXISTS `t`;\nCREATE DATABASE `t`;\nUSE `t`;\ncreate table t1\n(\n    c1  int primary key auto_increment,\n    c2  tinyint not null default 4,\n    c3  smallint,\n    c4  bigint,\n    c5  tinyint unsigned,\n    c6  smallint unsigned,\n    c7  int unsigned,\n    c8  bigint unsigned,\n    c9  float,\n    c10 double,\n    c11 date,\n    c12 datetime,\n    c13 timestamp on update current_timestamp,\n    c14 char,\n    c15 varchar,\n    c16 json,\n    c17 decimal,\n    c18 text,\n    c19 blob,\n    c20 uuid\n);\ninsert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2019-01-01', '2019-01-01 00:00:00', '2019-01-01 00:00:00', 'a', 'a', '{\"a\":1}','1212.1212', 'a', 'aza', '00000000-0000-0000-0000-000000000000');\n

      If you want to generate the backup of the single database, run the following command. The command will generate the backup of the t database with structure and data in the t.sql file.

      ./modump -u root -p 111 -h 127.0.0.1 -P 6001 -db t > t.sql\n

      If you want to generate the backup of a single table in a database, run the following command. The command will generate the backup of the t1 table of t database with structure and data in the t.sql file.

      ./modump -u root -p 111 -db t -tbl t1 > t1.sql\n

      Note

      If you have multiple databases, you need to run modump multiple times to generate SQLs one by one.

      "},{"location":"MatrixOne/Maintain/backup-restore/modump-backup-restore/#3-restore-the-backup-to-matrixone-server","title":"3. Restore the backup to MatrixOne server","text":"

      Restoring a MatrixOne database using the exported 'sql' file is very simple. To restore the database, you must create an empty database and use mysql client to restore.

      Connect to MatrixOne with MySQL client in the same server, and make sure the exported sql file is also in the same machine as the MySQL client.

      mysql> create database t if not exists;\nmysql> source /YOUR_SQL_FILE_PATH/t.sql\n

      Once command executes successfully, execute the following command to verify that all objects have been created on the t database.

      mysql> use t;\nmysql> show tables;\nmysql> select count(*) from t1;\n
      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/","title":"Migrate data from MySQL to MatrixOne","text":"

      This document will guide you on how to migrate data from MySQL to MatrixOne.

      MatrixOne maintains a high degree of compatibility with MySQL syntax, so no other operations are required during the migration process to achieve seamless migration.

      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#data-type-difference","title":"Data type difference","text":"

      In MatrixOne, while maintaining the same name as MySQL, there are slight differences in accuracy and range between data types and MySQL. For more information, see Data Types.

      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#online-migration","title":"Online Migration","text":"

      This chapter will guide you to use third-party tools - DBeaver to migrate data from MySQL to MatrixOne.

      • Applicable scenarios: scenarios where the amount of data is small (recommended less than 1GB), and the migration speed is not sensitive.
      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#preparation","title":"Preparation","text":"
      • Springboard machine with a graphical interface: it can connect to the source of MySQL and the target of MatrixOne.
      • Data Migration Tool: Download DBeaver on the springboard machine.
      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-1-migrate-table-structure","title":"Step 1: Migrate table structure","text":"

      Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from MySQL to MatrixOne.

      1. Open DBeaver, select the table to be migrated from MySQL, right-click and select Generate SQL > DDL Click Copy, first copy this SQL to a text editor for text editing Name the filer as tpch_ddl.sql and save it locally on the springboard machine.

      2. Connect to MatrixOne and create a new database and table in MatrixOne:

        create database tpch;\nuse tpch;\nsource '/YOUR_PATH/tpch_ddl.sql'\n
      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-2-migrate-data","title":"Step 2: Migrate data","text":"
      1. Open DBeaver, select the table to be migrated from MySQL, right-click and select Export Data:

      2. In the Conversion Target > Export Target window, select Database, click Next; in the Table Mapping window, select Target Container, and select the MatrixOne database for the target container tpch:

      3. In the Extraction Settings and Data Loading Settings windows, set the number of selected extractions and inserts. To trigger MatrixOne's direct write S3 strategy, it is recommended to fill in 5000:

      4. After completing the settings, DBeaver starts to migrate the data, and after completion, DBeaver will prompt that the migration is successful.

      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-3-check-the-data","title":"Step 3: Check the data","text":"

      After the migration is complete, the data can be inspected as follows:

      • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

      • Compare the results through related queries; you can also refer to the Complete TPCH testing query example to compare the results.

      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#offline-migration","title":"Offline Migration","text":"

      This chapter will guide you through importing to MatrixOne through offline files.

      • Applicable scenarios: scenarios with a large amount of data (more significant than 1GB) and sensitive to migration speed.
      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#preparation_1","title":"Preparation","text":"
      • Springboard machine with a graphical interface: it can be connected to the source end of MySQL and the target end of MatrixOne.
      • Data Migration Tool: Download DBeaver to the springboard machine.
      • Install mysqldump in MySQL server. If you are not familiar with how to use mysqldump, see mysqldump tutorial
      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-1-migrate-table-structure_1","title":"Step 1: Migrate table structure","text":"

      Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from MySQL to MatrixOne.

      1. Open DBeaver, select the table to be migrated from MySQL, right-click and select Generate SQL > DDL > Copy, first copy this SQL to a text editor, and name the text editor tpch_ddl.sql, saved locally on the springboard machine.

      2. Connect to MatrixOne and create a new database and table in MatrixOne:

        create database tpch;\nuse tpch;\nsource '/YOUR_PATH/tpch_ddl.sql'\n
      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-2-migrate-data_1","title":"Step 2: Migrate data","text":"

      MatrixOne has two data migration methods to choose from: INSERT and LOAD DATA. When the amount of data is greater than 1GB, it is recommended to use LOAD DATA first, followed by INSERT.

      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#load-data","title":"LOAD DATA","text":"
      1. Use mysqldump to export the MySQL data table as a CSV format file. Make sure you have write access to the file path and check the secure_file_priv configuration:

        mysqldump -u root -p -t -T /{filepath} tpch --fields-terminated-by='|'\n
      2. Connect to MatrixOne and import the exported CSV data into MatrixOne:

        mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n

      For more operation examples of LOAD DATA, see Bulk Load Overview.

      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#insert","title":"INSERT","text":"

      The INSERT statement needs to use mysqldump to export the logical statement first and then import it into MatrixOne:

      1. Use mysqldump to export data. To ensure that MatrixOne directly writes to S3 when inserting, inserting as large a batch as possible is recommended. The net_buffer_length parameter should start at 10MB:

        mysqldump -t tpch -uroot -p --net_buffer_length=10m > tpch_data.sql\n
      2. On the MatrixOne side, execute the SQL file, there will be an error message during the process, but it will not affect the data insertion:

        source '/YOUR_PATH/tpch_data.sql'\n

      For more examples of INSERT operations, see Insert Data.

      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#step-3-check-the-data_1","title":"Step 3: Check the data","text":"

      After the migration is complete, the data can be inspected as follows:

      • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

      • Compare the results through related queries; you can also refer to the Complete a TPCH Test with MatrixOne query example to compare the results.

      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#reference-example","title":"Reference example","text":"

      If you are a novice and want to migrate a small amount of data, see Import data by using the source command.

      "},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#constraints","title":"Constraints","text":"

      MatrixOne 1.0.0-rc1 version already supports MySQL table creation statements, so you can smoothly migrate MySQL tables to MatrixOne. However, it should be noted that during the migration process, some keywords incompatible with MySQL, such as engine=, will be automatically ignored in MatrixOne and will not affect the migration of the table structure.

      However, it should be noted that although MatrixOne supports MySQL table creation statements, manual modification is still required if the migrated table contains incompatible data types, triggers, functions, or stored procedures. For more detailed compatibility information, see MySQL Compatibility.

      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/","title":"Migrate data from SQL Server to MatrixOne","text":"

      This document will guide you on how to migrate data from Oracle to MatrixOne.

      Oracle is currently the most widely used commercial database in the world. Its usage scenarios and popularity rank first in DBEngine all year round. MatrixOne can also support the scenario of migrating data from Oracle. According to the size of Oracle data, this article still recommends using online and offline modes for migration.

      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#data-type-difference","title":"Data type difference","text":"

      There are many differences between MatrixOne and Oracle's built-in data types. Other types can replace some differences, and some cannot be supported temporarily. The specific list is as follows:

      Oracle MatrixOne varchar2 replace with text nchar/nvarcahr replace with char/varchar NUMBER(3,0), NUMBER(5,0) replace with smallint NUMBER(10,0) replace with int NUMBER(38,0) replace with bitint NUMBER(n,p) (p>0) replace with decimal(n,p) binary_float/binary_double replace with float/double long replace with text long raw replace with blob raw replace with varbinary clob/nclob replace with text bfile Not supported yet rowid/urowid Not Supported user-defined types Not supported yet any Not supported yet xml Not supported yet spatial Not supported yet"},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#online-migration","title":"Online Migration","text":"

      This chapter will guide you to use third-party tools - DBeaver to migrate data from Oracle to MatrixOne.

      Through DBeaver, the source data is obtained in batches, and then the data is inserted into the target database as INSERT. If an error is reported during the migration process that the heap space is insufficient, please try to adjust the size of each batch of fetched and inserted data.

      • Applicable scenarios: scenarios where the amount of data is small (recommended less than 1GB), and the migration speed is not sensitive.

      • The recommended configuration of the springboard machine where DBeaver is installed: RAM 16GB or more.

      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#preparation","title":"Preparation","text":"
      • Springboard machine with a graphical interface: it can connect to the source of Oracle and the target of MatrixOne.
      • Data Migration Tool: Download DBeaver on the springboard machine.
      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-1-migrate-table-structure","title":"Step 1: Migrate table structure","text":"

      Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from Oracle to MatrixOne.

      1. Open DBeaver, select the table to be migrated from Oracle, right-click and select Generate SQL > DDL Click Copy, first copy this SQL to a text editor for text editing Name the filer as oracle_ddl.sql and save it locally on the springboard machine.

      2. Use the following command to replace keywords not supported by MatrixOne in the oracle_ddl.sql file:

        # The commands executed by the Linux system are as follows:\nsed -i '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n\n# The commands executed by the MacOS system are as follows:\nsed -i '' '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '' '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n
      3. Connect to MatrixOne and create a new database and table in MatrixOne:

        create database tpch;\nuse tpch;\nsource '/YOUR_PATH/oracle_ddl.sql'\n
      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-2-migrate-data","title":"Step 2: Migrate data","text":"
      1. Open DBeaver, select the table to be migrated from Oracle, right-click and select Export Data:

      2. In the Conversion Target > Export Target window, select Database, click Next; in the Table Mapping window, select Target Container, and select the MatrixOne database for the target container tpch:

      3. In the Extraction Settings and Data Loading Settings windows, set the number of selected extractions and inserts. To trigger MatrixOne's direct write S3 strategy, it is recommended to fill in 5000:

      4. After completing the settings, DBeaver starts to migrate the data, and after completion, DBeaver will prompt that the migration is successful.

      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-3-check-the-data","title":"Step 3: Check the data","text":"

      After the migration is complete, the data can be inspected as follows:

      • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

      • Compare the results through related queries; you can also refer to the Complete TPCH testing query example to compare the results.

      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#offline-migration","title":"Offline Migration","text":"

      This chapter will guide you through importing to MatrixOne through offline files.

      • Applicable scenarios: scenarios with a large amount of data (more significant than 1GB) and sensitive to migration speed.
      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#preparation_1","title":"Preparation","text":"
      • Springboard machine with a graphical interface: it can be connected to the source end of Oracle and the target end of MatrixOne.
      • Data Migration Tool: Download DBeaver to the springboard machine.
      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-1-migrate-table-structure_1","title":"Step 1: Migrate table structure","text":"

      Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from Oracle to MatrixOne.

      1. Open DBeaver, select the table to be migrated from Oracle, right-click and select Generate SQL > DDL > Copy, first copy this SQL to a text editor, and name the text editor oracle_ddl.sql, saved locally on the springboard machine.

      2. Use the following command to replace keywords that MatrixOne does not support in the oracle_ddl.sql file:

        # The commands executed by the Linux system are as follows:\nsed -i '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n\n# The commands executed by the MacOS system are as follows:\nsed -i '' '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '' '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n
      3. Connect to MatrixOne and create a new database and table in MatrixOne:

        create database tpch;\nuse tpch;\nsource '/YOUR_PATH/oracle_ddl.sql'\n
      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-2-migrate-data_1","title":"Step 2: Migrate data","text":"

      MatrixOne has two data migration methods to choose from: INSERT and LOAD DATA. When the amount of data is greater than 1GB, it is recommended to use LOAD DATA first, followed by INSERT.

      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#load-data","title":"LOAD DATA","text":"

      Use DBeaver to export the Oracle data table to CSV format first, and use MatrixOne's parallel loading function to migrate the data to MatrixOne:

      1. Open DBeaver, select the table to be migrated, right-click and select Export Data to export the Oracle data table as a CSV format file:

      2. In the Conversion Goals > Export Goals window, select CSV and click Next:

      3. Connect to MatrixOne and import the exported CSV data into MatrixOne:

        mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n

      For more operation examples of LOAD DATA, see Bulk Load Overview.

      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#insert","title":"INSERT","text":"

      The INSERT statement needs to use DBeaver to export the logical statement first and then import it into MatrixOne:

      1. Use DBeaver to export data: Open DBeaver, select the table to be migrated from Oracle, right-click, and select Export Data > SQL. To ensure that MatrixOne directly writes to S3 when inserting, it is recommended to insert parameters in batches The number of data rows per statement is set to 5000:

      2. On the MatrixOne side, execute the SQL file:

        source '/YOUR_PATH/oracle_data.sql'\n

      For more examples of INSERT operations, see Insert Data.

      "},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#step-3-check-the-data_1","title":"Step 3: Check the data","text":"

      After the migration is complete, the data can be inspected as follows:

      • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

      • Compare the results through related queries; you can also refer to the Complete a TPCH Test with MatrixOne query example to compare the results.

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/","title":"Migrate data from PostgreSQL to MatrixOne","text":"

      This document will guide you in migrating data from PostgreSQL to MatrixOne.

      PostgreSQL is currently one of the world's most advanced open-source relational databases, with an extensive range of data types, object types, SQL models, and other features. It holds a significant position in various fields, such as enterprise, education, and research. Depending on the size of your PostgreSQL data, this document recommends utilizing online and offline migration methods.

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#data-type-difference","title":"Data type difference","text":"

      There are several differences in data types between MatrixOne and the ones provided by PostgreSQL. Some differences can be replaced using alternative types, while others might not be supported temporarily. Additionally, PostgreSQL supports a three-tier logical structure: Database - Schema - Table. This means you can create multiple schemas within a single database containing multiple tables. This hierarchical structure allows for better organization and data management. On the other hand, MatrixOne follows a two-tier logical structure: Database - Table. In MatrixOne, tables are directly created within the database, resulting in some differences during the migration process.

      The specific list is as follows:

      PostgreSQL MatrixOne serial replaced by auto-incrementing columns money replace with decimal bytea replace with binary or varbinary geometric Not supported yet network adress replace with char or varchar bit string Not supported yet text search Not supported yet xml Not supported yet array Not supported yet composite Not supported yet range Not supported yet domain Not supported yet object identifier Not supported yet pg_lsn Not supported yet pseudo Not supported yet"},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#online-migration","title":"Online Migration","text":"

      This chapter will guide you to use third-party tools - DBeaver to migrate data from PostgreSQL to MatrixOne.

      Through DBeaver, the source data is obtained in batches, and then the data is inserted into the target database as INSERT. If an error is reported during the migration process that the heap space is insufficient, please try to adjust the size of each batch of fetched and inserted data.

      • Applicable scenarios: scenarios where the amount of data is small (recommended less than 1GB), and the migration speed is not sensitive.

      • The recommended configuration of the springboard machine where DBeaver is installed: RAM 16GB or more.

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#preparation","title":"Preparation","text":"
      • Springboard machine with a graphical interface: it can connect to the source of Oracle and the target of MatrixOne.
      • Data Migration Tool: Download DBeaver on the springboard machine.
      • DDL translation tool: download pg2mysql on the springboard machine, and note that the springboard machine needs to have a Python environment.
      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-1-migrate-table-structure","title":"Step 1: Migrate table structure","text":"

      Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from PostgreSQL to MatrixOne.

      1. Open DBeaver, select the table to be migrated from Oracle, right-click and select Generate SQL > DDL Click Copy, first copy this SQL to a text editor for text editing Name the filer as pg_ddl.sql and save it locally on the springboard machine.

      2. Use pg2mysql translation tool to convert pg_ddl.sql file to MySQL format DDL:**

        a. First, run the following command to replace bpchar in the pg_ddl.sql file with char:

        ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/bpchar/char/g' pg_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/bpchar/char/g' pg_ddl.sql\n```\n

        b. Next, use the pg2mysql translation tool to convert the pg_ddl.sql file to MySQL format and save the output to the mysql_ddl.sql file:

        ```\n# The commands executed by both Linux and MacOS systems are as follows:\n./pg2mysql.pl < pg_ddl.sql > mysql_ddl.sql\n```\n

        c. The converted DDL retains the original Postgresql schema name. If necessary, you can execute the following command, replacing the schema name with the database name in MySQL:

        ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n```\n

        d. Finally, you may need to uniformly replace numeric in the mysql_ddl.sql file with decimal, which can be achieved by the following command:

        ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/numeric/decimal/g' mysql_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/numeric/decimal/g' mysql_ddl.sql\n```\n
      3. Connect to MatrixOne and create a new database and table in MatrixOne:

        create database tpch;\nuse tpch;\nsource '/YOUR_PATH/mysql_ddl.sql'\n
      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-2-migrate-data","title":"Step 2: Migrate data","text":"
      1. Open DBeaver, select the table to be migrated from PostgreSQL, right-click and select Export Data:

      2. In the Conversion Target > Export Target window, select Database, click Next; in the Table Mapping window, select Target Container, and select the MatrixOne database for the target container tpch:

      3. In the Extraction Settings and Data Loading Settings windows, set the number of selected extractions and inserts. To trigger MatrixOne's direct write S3 strategy, it is recommended to fill in 5000:

      4. After completing the settings, DBeaver starts to migrate the data, and after completion, DBeaver will prompt that the migration is successful.

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-3-check-the-data","title":"Step 3: Check the data","text":"

      After the migration is complete, the data can be inspected as follows:

      • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

      • Compare the results through related queries; you can also refer to the Complete TPCH testing query example to compare the results.

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#offline-migration","title":"Offline Migration","text":"

      This chapter will guide you through importing to MatrixOne through offline files.

      • Applicable scenarios: scenarios with a large amount of data (more significant than 1GB) and sensitive to migration speed.
      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#preparation_1","title":"Preparation","text":"
      • Springboard machine with a graphical interface: it can be connected to the source end of PostgreSQL and the target end of MatrixOne.
      • Data Migration Tool: Download DBeaver to the springboard machine.

      • Install pgdump in PostgreSQL server. If you are not familiar with how to use pgdump, see pgdump tutorial

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-1-migrate-table-structure_1","title":"Step 1: Migrate table structure","text":"

      Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from MySQL to MatrixOne.

      1. Open DBeaver, select the table to be migrated from PostgreSQL, right-click and select Generate SQL > DDL > Copy, first copy this SQL to a text editor, and name the text editor pg_ddl.sql, saved locally on the springboard machine.

      2. Use pg2mysql translation tool to convert pg_ddl.sql file to MySQL format DDL:**

        a. First, run the following command to replace bpchar in the pg_ddl.sql file with char:

        ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/bpchar/char/g' pg_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/bpchar/char/g' pg_ddl.sql\n```\n

        b. Next, use the pg2mysql translation tool to convert the pg_ddl.sql file to MySQL format and save the output to the mysql_ddl.sql file:

        ```\n# The commands executed by both Linux and MacOS systems are as follows:\n./pg2mysql.pl < pg_ddl.sql > mysql_ddl.sql\n```\n

        c. The converted DDL retains the original Postgresql schema name. If necessary, you can execute the following command, replacing the schema name with the database name in MySQL:

        ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n```\n

        d. Finally, you may need to uniformly replace numeric in the mysql_ddl.sql file with decimal, which can be achieved by the following command:

        ```\n# The commands executed by the Linux system are as follows:\nsed -i 's/numeric/decimal/g' mysql_ddl.sql\n\n# For MacOS systems, the commands used are as follows:\nsed -i '' 's/numeric/decimal/g' mysql_ddl.sql\n```\n
      3. Connect to MatrixOne and create a new database and table in MatrixOne:

        create database tpch;\nuse tpch;\nsource '/YOUR_PATH/mysql_ddl.sql'\n
      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-2-migrate-data_1","title":"Step 2: Migrate data","text":"

      MatrixOne has two data migration methods to choose from: INSERT and LOAD DATA. When the amount of data is greater than 1GB, it is recommended to use LOAD DATA first, followed by INSERT.

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#load-data","title":"LOAD DATA","text":"
      1. Export the PostgreSQL data table to CSV format in the PostgreSQL database command line environment:

        postgres=# \\c tpch;\npostgres=# COPY tpch.nation TO '/{filepath}/nation.tbl' DELIMITER '|';\npostgres=# COPY tpch.region TO '/{filepath}/region.tbl' DELIMITER '|';\npostgres=# COPY tpch.customer TO '/{filepath}/customer.tbl' DELIMITER '|';\npostgres=# COPY tpch.part TO '/{filepath}/part.tbl' DELIMITER '|';\npostgres=# COPY tpch.supplier TO '/{filepath}/supplier.tbl' DELIMITER '|';\npostgres=# COPY tpch.partsupp TO '/{filepath}/partsupp.tbl' DELIMITER '|';\npostgres=# COPY tpch.lineitem TO '/{filepath}/lineitem.tbl' DELIMITER '|';\npostgres=# COPY tpch.orders TO '/{filepath}/orders.tbl' DELIMITER '|';\n
      2. Connect to MatrixOne and import the exported CSV data into MatrixOne:

        mysql> load data infile '/{filepath}/lineitem.tbl' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.tbl' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.tbl' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.tbl' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.tbl' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.tbl' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.tbl' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.tbl' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n

      For more operation examples of LOAD DATA, see Bulk Load Overview.

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#insert","title":"INSERT","text":"

      The INSERT statement needs to use pgdump to export the logical statement first and then import it into MatrixOne:

      1. Use pgdump to export data. To ensure that MatrixOne directly writes to S3 when inserting, inserting as large a batch as possible is recommended. The net_buffer_length parameter should start at 10MB:

        $ pg_dump -U postgres --no-acl --no-owner --inserts --rows-per-insert 5000  --format p --data-only --schema=tpch tpch -f pg_data.sql\n
      2. On the MatrixOne side, execute the SQL file, there will be an error message during the process, but it will not affect the data insertion:

        source '/YOUR_PATH/pg_data.sql'\n

      For more examples of INSERT operations, see Insert Data.

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#step-3-check-the-data_1","title":"Step 3: Check the data","text":"

      After the migration is complete, the data can be inspected as follows:

      • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

      • Compare the results through related queries; you can also refer to the Complete a TPCH Test with MatrixOne query example to compare the results.

      "},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#reference-example","title":"Reference example","text":"

      If you are a novice and want to migrate a small amount of data, see Import data by using the source command.

      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/","title":"Migrate data from SQL Server to MatrixOne","text":"

      This document will guide you on how to migrate data from SQL Server to MatrixOne.

      SQLServer is widely used in various industries as a mature commercial database, and its functions and performance are outstanding. As a relational database, MatrixOne also supports multiple database migration modes from SQLServer.

      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#data-type-difference","title":"Data type difference","text":"

      There are many differences between MatrixOne and SQL Server's built-in data types. Other types can replace some differences, and some cannot be supported temporarily. The specific list is as follows:

      SQLServer MatrixOne real replace with double money, smallmoney replace with decimal datetimeoffset use timestampmap with timezone substitution nchar/nvarchar/ntext replace with char/varchar/text image replace with blob uniqueidentifier replace with uuid bit Not supported yet rowversion Not supported yet hierarchyid Not supported yet sql_variant Not supported yet xml Not supported yet geometry Not supported yet geography Not supported yet"},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#online-migration","title":"Online Migration","text":"

      This chapter will guide you to use third-party tools - DBeaver to migrate data from SQL Server to MatrixOne.

      Through DBeaver, the source data is obtained in batches, and then the data is inserted into the target database as INSERT. If an error is reported during the migration process that the heap space is insufficient, please try to adjust the size of each batch of fetched and inserted data.

      • Applicable scenarios: scenarios where the amount of data is small (recommended less than 1GB), and the migration speed is not sensitive.

      • The recommended configuration of the springboard machine where DBeaver is installed: RAM 16GB or more.

      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#preparation","title":"Preparation","text":"
      • Springboard machine with a graphical interface: it can connect to the source of SQL Server and the target of MatrixOne.
      • Data Migration Tool: Download DBeaver on the springboard machine.
      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-1-migrate-table-structure-and-data","title":"Step 1: Migrate table structure and data","text":"

      Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from SQL Server to MatrixOne.

      1. Open DBeaver, select the table to be migrated from SQL Server, right-click and select Export Data:

      2. In the Conversion Target > Export Target window, select Database, click Next; in the Table Mapping window, select Target Container, and select the MatrixOne database for the target container tpch:

      3. In the Extraction Settings and Data Loading Settings windows, set the number of selected extractions and inserts. To trigger MatrixOne's direct write S3 strategy, it is recommended to fill in 5000:

      4. After completing the settings, DBeaver starts to migrate the data, and after completion, DBeaver will prompt that the migration is successful.

      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-3-check-the-data","title":"Step 3: Check the data","text":"

      After the migration is complete, the data can be inspected as follows:

      • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

      • Compare the results through related queries; you can also refer to the Complete TPCH testing query example to compare the results.

      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#offline-migration","title":"Offline Migration","text":"

      This chapter will guide you through importing to MatrixOne through offline files.

      • Applicable scenarios: scenarios with a large amount of data (more significant than 1GB) and sensitive to migration speed.
      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#preparation_1","title":"Preparation","text":"
      • Springboard machine with a graphical interface: it can be connected to the source end of SQL Server and the target end of MatrixOne.
      • Data Migration Tool: Download DBeaver to the springboard machine.
      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-1-migrate-table-structure","title":"Step 1: Migrate table structure","text":"

      Here we take the TPCH dataset as an example and migrate the 8 tables of the TPCH dataset from SQL Server to MatrixOne.

      1. Open DBeaver, select the table to be migrated from SQL Server, right-click and select Generate SQL > DDL > Copy, first copy this SQL to a text editor, and name the text editor sqlserver_ddl.sql, saved locally on the springboard machine.

      2. Connect to MatrixOne and create a new database and table in MatrixOne:

        create database tpch;\nuse tpch;\nsource '/YOUR_PATH/sqlserver_ddl.sql'\n
      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-2-migrate-data","title":"Step 2: Migrate data","text":"

      MatrixOne has two data migration methods to choose from: INSERT and LOAD DATA. When the amount of data is greater than 1GB, it is recommended to use LOAD DATA first, followed by INSERT.

      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#load-data","title":"LOAD DATA","text":"

      Use DBeaver to export the SQL Server data table to CSV format first, and use MatrixOne's parallel loading function to migrate the data to MatrixOne:

      1. Open DBeaver, select the table to be migrated, right-click and select Export Data to export the SQL Server data table as a CSV format file:

      2. In the Conversion Goals > Export Goals window, select CSV and click Next:

      3. Connect to MatrixOne and import the exported CSV data into MatrixOne:

        mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n

      For more operation examples of LOAD DATA, see Bulk Load Overview.

      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#insert","title":"INSERT","text":"

      The INSERT statement needs to use DBeaver to export the logical statement first and then import it into MatrixOne:

      1. Use DBeaver to export data: Open DBeaver, select the table to be migrated from SQL Server, right-click, and select Export Data > SQL. To ensure that MatrixOne directly writes to S3 when inserting, it is recommended to insert parameters in batches The number of data rows per statement is set to 5000:

      2. Use the following command to replace keywords that MatrixOne does not support in the sqlserver_ddl.sql file:

        # The commands executed by the Linux system are as follows:\nsed -i 's/,N/,/g' mssql_data.sql\n\n# The commands executed by the MacOS system are as follows:\nsed -i '' 's/,N/,/g' mssql_data.sql\n
      3. On the MatrixOne side, execute the SQL file:

        ues tpch;\nsource '/YOUR_PATH/sqlserver_ddl.sql'\n

      For more examples of INSERT operations, see Insert Data.

      "},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#step-3-check-the-data_1","title":"Step 3: Check the data","text":"

      After the migration is complete, the data can be inspected as follows:

      • Use select count(*) from <table_name> to confirm whether the data volume of the source database and target databases' data volume is consistent.

      • Compare the results through related queries; you can also refer to the Complete a TPCH Test with MatrixOne query example to compare the results.

      "},{"location":"MatrixOne/Migrate/migrate-overview/","title":"migrating data to MatrixOne Overview","text":""},{"location":"MatrixOne/Migrate/migrate-overview/#matrixone-tools-and-functions-for-migrating-data","title":"MatrixOne tools and functions for migrating data","text":"

      When using MatrixOne, it is sometimes necessary to migrate data from other databases to MatrixOne. Due to differences between different databases, data migration requires some extra work. To facilitate users to import external data quickly, MatrixOne provides a variety of tools and functions.

      Here are some of the standard tools and functions:

      "},{"location":"MatrixOne/Migrate/migrate-overview/#load-data","title":"LOAD DATA","text":"

      Like MySQL, MatrixOne provides the LOAD DATA function, allowing users to quickly and parallelly import external CSV files or JSON files into tables that match the table structure.

      "},{"location":"MatrixOne/Migrate/migrate-overview/#source","title":"SOURCE","text":"

      In MatrixOne, you can also use the SOURCE command to migrate data and table structures to the target database.

      For more information on bulk import using LOAD DATA or SOURCE, see Bulk Load Overview.

      "},{"location":"MatrixOne/Migrate/migrate-overview/#reference","title":"Reference","text":"

      MatrixOne provides the following documents to help you quickly understand how to migrate data from other databases to MatrixOne:

      • Migrate data from MySQL to MatrixOne
      • Migrate data from Oracle to MatrixOne
      • Migrate data from SQL Server to MatrixOne
      • Migrate data from PostgreSQL to MatrixOne
      "},{"location":"MatrixOne/Overview/matrixone-feature-list/","title":"MatrixOne Features","text":"

      This document lists the features supported by the latest version of MatrixOne and features that are common and in MatrixOne's roadmap but not currently supported.

      "},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-definition-language-ddl","title":"Data definition language (DDL)","text":"Data definition Language(DDL) Supported(Y)/Not supported (N) /Experimental (E) CREATE DATABASE Y DROP DATABASE Y ALTER DATABASE N CREATE TABLE Y ALTER TABLE E, The clauses: CHANGE [COLUMN], MODIFY [COLUMN], RENAME COLUMN, ADD [CONSTRAINT [symbol]] PRIMARY KEY, DROP PRIMARY KEY, and ALTER COLUMN ORDER BY can be used in ALTER It can be freely combined in the TABLE statement. Still, it is not supported to be used with other clauses for the time being. RENAME TABLE N, Can be replaced by ALTER TABLE tbl RENAME TO new_tbl DROP TABLE Y CREATE INDEX Y, Secondary indexes have no speedup DROP INDEX Y MODIFY COLUMN N PRIMARY KEY Y CREATE VIEW Y ALTER VIEW Y DROP VIEW Y TRUNCATE TABLE Y AUTO_INCREMENT Y SEQUENCE Y TEMPORARY TABLE Y CREATE STREAM E, Only some types are supported PARTITION BY E, Only some types are supported CHARSET, COLLATION N, Only UTF8 is supported by default"},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-manipulationquery-language-dmldql","title":"Data manipulation/query language (DML/DQL)","text":"SQL Statement Supported(Y)/Not supported (N) /Experimental (E) SELECT Y INSERT Y UPDATE Y DELETE Y REPLACE Y INSERT ON DUPLICATE KEY UPDATE Y LOAD DATA Y SELECT INTO Y INNER/LEFT/RIGHT/OUTER JOIN Y UNION, UNION ALL Y EXCEPT, INTERSECT Y GROUP BY, ORDER BY Y CLUSTER BY Y SUBQUERY Y (Common Table Expressions, CTE) Y BEGIN/START TRANSACTION, COMMIT, ROLLBACK Y EXPLAIN Y EXPLAIN ANALYZE Y LOCK/UNLOCK TABLE N User-defined Variables Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#advanced-sql-features","title":"Advanced SQL Features","text":"Advanced SQL Features Supported(Y)/Not supported (N) /Experimental (E) PREPARE Y STORED PROCEDURE N TRIGGER N EVENT SCHEDULER N UDF N Materialized VIEW N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-types","title":"Data types","text":"Data type categories Data types Supported(Y)/Not supported (N) /Experimental (E) Integer Numbers TINYINT/SMALLINT/INT/BIGINT (UNSIGNED) Y BIT N Real Numbers FLOAT Y DOUBLE Y String Types CHAR Y VARCHAR Y BINARY Y VARBINARY Y TINYTEXT/TEXT/MEDIUMTEXT/LONGTEXT Y ENUM Y, Not support Filtering ENUM values and Sorting ENUM values SET N Binary Types TINYBLOB/BLOB/MEDIUMBLOB/LONGBLOB Y Time and Date Types DATE Y TIME Y DATETIME Y TIMESTAMP Y YEAR Y Boolean BOOL Y Decimal Types DECIMAL Y, up to 38 digits JSON Types JSON Y vector type VECTOR N Spatial Type SPATIAL N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#indexing-and-constraints","title":"Indexing and constraints","text":"Indexing and constraints Supported(Y)/Not supported (N) /Experimental (E) PRIMARY KEY Y Composite PRIMARY KEY Y UNIQUE KEY Y Secondary KEY Y, Syntax only implementation FOREIGN KEY Y Enforced Constraints on Invalid Data Y ENUM and SET Constraints N NOT NULL Constraint Y AUTO INCREMENT Constraint Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#transactions","title":"Transactions","text":"Transactions Supported(Y)/Not supported (N) /Experimental (E) Pessimistic transactions Y Optimistic transactions Y Distributed Transaction Y Snapshot Isolation Y READ COMMITTED Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#functions-and-operators","title":"Functions and Operators","text":"Functions and Operators Categories Supported(Y)/Not supported (N) /Experimental (E) Aggregate Functions Y Mathematical Y Datetime Y String Y CAST Y Flow Control Functions E Window Functions Y JSON Functions Y System Functions Y Other Functions Y Operators Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#partition","title":"PARTITION","text":"PARTITION Supported(Y)/Not supported (N) /Experimental (E) KEY(column_list) E HASH(expr) E RANGE(expr) N RANGE COLUMNS N LIST N LIST COLUMNS N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#import-and-export","title":"Import and Export","text":"Import and Export Supported(Y)/Not supported (N) /Experimental (E) LOAD DATA Y SOURCE Y Load data from S3 Y modump Y mysqldump N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#security-and-access-control","title":"Security and Access Control","text":"Security Supported(Y)/Not supported (N) /Experimental (E) Transport Layer Encryption TLS Y Encryption at rest Y Import from Object Storage Y Role-Based Access Control (RBAC) Y Multi-Account Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#backup-and-restore","title":"Backup and Restore","text":"Backup and Restore Supported(Y)/Not supported (N) /Experimental (E) Logical Backup and Restore Y, Only the modump tool is supported Physical Backup and Restore Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#management-tool","title":"Management Tool","text":"Management Tool Supported(Y)/Not supported (N) /Experimental (E) Stand-alone mo_ctl deployment management Y Distributed mo_ctl deployment management E, Enterprise Edition only Visual management platform E, Public cloud version only System Logging Y System indicator monitoring Y Slow query log Y SQL record Y Kubernetes operator Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#deployment-method","title":"Deployment Method","text":"Deployment Method Supported(Y)/Not supported (N) /Experimental (E) Stand-alone environment privatization deployment Y Distributed environment privatization deployment Y, self-built Kubernetes and minIO object storage Alibaba Cloud distributed self-built deployment Y, ACK+OSS Tencent Cloud Distributed Self-built Deployment Y, TKE+COS AWS distributed self-built deployment Y, EKS+S3 Public Cloud Serverless Y, MatrixOne Cloud, Support AWS, Alibaba Cloud"},{"location":"MatrixOne/Overview/matrixone-introduction/","title":"MatrixOne Introduction","text":"

      MatrixOne is a hyper-converged cloud & edge native distributed database with a structure that separates storage, computation, and transactions to form a consolidated HSTAP data engine. This engine enables a single database system to accommodate diverse business loads such as OLTP, OLAP, and stream computing. It also supports deployment and utilization across public, private, and edge clouds, ensuring compatibility with diverse infrastructures.

      MatrixOne touts significant features, including real-time HTAP, multi-tenancy, stream computation, extreme scalability, cost-effectiveness, enterprise-grade availability, and extensive MySQL compatibility. MatrixOne unifies tasks traditionally performed by multiple databases into one system by offering a comprehensive ultra-hybrid data solution. This consolidation simplifies development and operations, minimizes data fragmentation, and boosts development agility.

      MatrixOne is optimally suited for scenarios requiring real-time data input, large data scales, frequent load fluctuations, and a mix of procedural and analytical business operations. It caters to use cases such as mobile internet apps, IoT data applications, real-time data warehouses, SaaS platforms, and more.

      "},{"location":"MatrixOne/Overview/matrixone-introduction/#key-features","title":"Key Features","text":""},{"location":"MatrixOne/Overview/matrixone-introduction/#hyper-converged-engine","title":"Hyper-converged Engine","text":"
      • Monolithic Engine

        HTAP data engine that supports a mix of workloads such as TP, AP, time series, and machine learning within a single database.

      • Built-in Streaming Engine

        Built-in stream computing engine that enables real-time data inflow, transformation, and querying.

      "},{"location":"MatrixOne/Overview/matrixone-introduction/#cloud-edge-native","title":"Cloud & Edge Native","text":"
      • Storage-Computation Separation Structure

        Separates the storage, computation, and transaction layers, leveraging a containerized design for ultimate scalability.

      • Multi-Infrastructure Compatibility

        MatrixOne provides industry-leading latency control with optimized consistency protocol.

      "},{"location":"MatrixOne/Overview/matrixone-introduction/#extreme-performance","title":"Extreme Performance","text":"
      • High-Performance Execution Engine

        The flexible combination of Compute Node and Transaction node accommodates point queries and batch processing, delivering peak performance for OLTP and OLAP.

      • Enterprise-Grade High Availability

        Establishes a consistently shared log under a leading Multi-Raft replication state machine model. It ensures high cluster availability while preventing data duplication, thus achieving RTO=0.

      "},{"location":"MatrixOne/Overview/matrixone-introduction/#ease-of-use","title":"Ease of Use","text":"
      • Built-in Multi-Tenancy Capability

        Offers inherent multi-tenancy, where tenants are isolated from each other, independently scalable yet uniformly manageable. This feature simplifies the complexity of multi-tenancy design in upper-level applications.

      • High Compatibility with MySQL

        MatrixOne exhibits high compatibility with MySQL 8.0, including transmission protocol, SQL syntax, and ecosystem tools, lowering usage and migration barriers.

      "},{"location":"MatrixOne/Overview/matrixone-introduction/#cost-effective","title":"Cost-Effective","text":"
      • Efficient Storage Design

        Employs cost-effective object storage as primary storage. High availability can be achieved through erasure coding technology with only about 150% data redundancy. It also provides high-speed caching capabilities, balancing cost and performance via a multi-tiered storage strategy that separates hot and cold data.

      • Flexible Resource Allocation

        Users can adjust the resource allocation ratio for OLTP and OLAP according to business conditions, maximizing resource utilization.

      "},{"location":"MatrixOne/Overview/matrixone-introduction/#enterprise-level-security-and-compliance","title":"Enterprise-Level Security and Compliance","text":"
        MatrixOne employs Role-Based Access Control (RBAC), TLS connections, and data encryption to establish a multi-tiered security defense system, safeguarding enterprise-level data security and compliance.\n
      "},{"location":"MatrixOne/Overview/matrixone-introduction/#user-values","title":"User Values","text":"
      • Simplify Database Management and Maintenance

        With business evolution, the number of data engines and middleware enterprises employ increases. Each data engine relies on 5+ essential components and stores 3+ data replicas. Each engine must be independently installed, monitored, patched, and upgraded. This results in high and uncontrollable data engine selection, development, and operations costs. Under MatrixOne's unified architecture, users can employ a single database to serve multiple data applications, reducing the number of introduced data components and technology stacks by 80% and significantly simplifying database management and maintenance costs.

      • Reduce Data Fragmentation and Inconsistency

        Data flow and copy between databases make data sync and consistency increasingly tricky. The unified and incrementally materialized view of MatrixOne allows the downstream to support real-time upstream updates and achieve end-to-end data processing without redundant ETL processes.

      • Decoupling Data Architecture From Infrastructure

        Currently, the architecture design across different infrastructures is complicated, causing new data silos between cloud and edge, cloud and on-premise. MatrixOne is designed with a unified architecture to support simplified data management and operations across different infrastructures.

      • Extremely Fast Complex Query Performance

        Poor business agility results from slow, complex queries and redundant intermediate tables in current data warehousing solutions. MatrixOne supports blazing-fast experience even for star and snowflake schema queries, improving business agility with real-time analytics.

      • An Solid OLTP-like OLAP Experience

        Current data warehousing solutions have the following problems: high latency and absence of immediate visibility for data updates. MatrixOne brings OLTP (Online Transactional Processing) level consistency and high availability to CRUD operations in OLAP (Online Analytical Processing).

      • Seamless and Non-disruptive Scaling

        It is challenging to balance performance and scalability to achieve an optimum price-performance ratio in current data warehousing solutions. MatrixOne's disaggregated storage and compute architecture makes it fully automated and efficient to scale in/out and up/down without disrupting applications.

      "},{"location":"MatrixOne/Overview/matrixone-introduction/#scenarios","title":"Scenarios","text":"
      • Traditional Application System Scenarios Requiring Scalability and Analytical Reporting Capabilities

        With the expansion of businesses, the performance needs of traditional single-machine databases cannot meet enterprises' usual systems such as OA, ERP, CRM, etc., especially during special periods requiring business analysis. Many enterprises equip a separate analytical database system to meet statistical report needs at essential points like month-end, quarter-end, etc. Using MatrixOne; these needs can be met with a single database system, providing strong scalability that seamlessly scales with business growth.

      • Dashboard/BI Report Scenarios Requiring Real-Time Analytical Capabilities

        For typical OLAP-type applications in enterprises, such as dashboards, BI reports, etc., analyzing massive amounts of data often leads to a performance bottleneck when the data volume is significantly large, resulting in poor timeliness. MatrixOne's robust analysis performance and scalability enable the acceleration of various complex and large-scale SQL queries, providing a near-instant experience and enhancing enterprise decision-making analysis's agility.

      • Data Platform Scenarios for Real-Time Influx and Processing of Massive Heterogeneous Data Applications

        With the extensive use of sensor and network technology, numerous IoT devices generate substantial data, such as manufacturing factory production lines, new energy vehicles, city security surveillance cameras, etc. Their scale can easily reach hundreds of TB or even PB levels. The demand for digitization also requires enterprises to store and use these data increasingly. Traditional database solutions cannot meet the requirements of such massive and large-scale real-time data writing and processing applications. MatrixOne's powerful streaming data writing and processing capabilities and robust scalability can adapt to any load and data volume scale, fully meeting these requirements.

      • Data Middle-End Scenarios Where Various Internal Enterprise Data Converges

        Medium and large enterprises often have multiple business systems. To fully understand the enterprise's overall status, many enterprises build a data middle-end that connects data sources from various systems. Traditional solutions to carry the data middle-end are based on the Hadoop system, which is complex, posing high development and operation thresholds for many enterprises. MatrixOne's one-stop HTAP architecture makes using a data middle-end as convenient as using MySQL, significantly reducing costs.

      • Business Scenarios with Dramatic and Frequent Internet Business Fluctuations

        Internet applications such as games, e-commerce, entertainment, social networking, news, etc., have a massive user base, and the business fluctuates dramatically and frequently. During hot events, these applications often need many computing resources to support business needs. MatrixOne's fully cloud-native architecture has superior scalability, enabling automatic and rapid scaling with business changes, significantly reducing user operation and maintenance difficulties.

      • Enterprise SaaS Service Business Scenarios

        Enterprise SaaS applications have seen explosive growth in recent years. In developing SaaS applications, they all need to consider their multi-tenant model. Traditional schemes offer two modes of multi-tenant shared database instances and single-tenant exclusive database instances, but they face the dilemma of management cost and isolation. MatrixOne comes with multi-tenant capabilities; tenants are naturally load-isolated and can be independently scaled. At the same time, it provides unified management capabilities, balancing the enterprise's needs for cost, management simplicity, and isolation, making it an optimal choice for SaaS applications.

      "},{"location":"MatrixOne/Overview/matrixone-introduction/#learn-more","title":"Learn More","text":"

      This section describes the basic introduction of MatrixOne. If you want to learn more detailed information about MatrixOne, see the following content:

      • MatrixOne Architecture
      • Deploy standalone MatrixOne
      "},{"location":"MatrixOne/Overview/whats-new/","title":"What's New","text":"

      The lastest version of MatrixOne is 1.0.0-rc1, releases on 24th Aug, 2023. See the following:

      • v1.0.0-rc1 Release Notes
      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/","title":"MatrixOne Architecture Design","text":""},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#matrixone-overview","title":"MatrixOne Overview","text":"

      MatrixOne is a future-oriented hyperconverged cloud & edge native DBMS that supports transactional, analytical, and streaming workload with a simplified and distributed database engine working across multiple datacenters, clouds, edges, and other heterogenous infrastructures. This combination of engines is called HSTAP.

      As a redefinition of the HTAP database, HSTAP aims to meet all the needs of Transactional Processing (TP) and Analytical Processing (AP) within a single database. Compared with the traditional HTAP, HSTAP emphasizes its built-in streaming capability used for connecting TP and AP tables. This provides users with an experience that a database can be used just like a Big Data platform, with which many users are already familiar thanks to the Big Data boom. With minimal integration efforts, MatrixOne frees users from the limitations of Big Data and provides one-stop coverage for all TP and AP scenarios for enterprises.

      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#matrixone-architecture-layers","title":"MatrixOne Architecture Layers","text":"

      MatrixOne implements three independent layers, each with its object units and responsibilities. Different nodes can freely scale, no longer constrained by other layers. These three layers are:

      • Compute Layer: Based on Compute Nodes (CNs), MatrixOne enables serverless computing and transaction processing with its cache, which is capable of random restarts and scaling.
      • Transaction Layer: Based on Transaction Nodes and Log Services, MatrixOne provides complete logging services and metadata information, with built-in Logtail for recent data storage.
      • Storage Layer: Full data is stored in object storage, represented by S3, implementing a low-cost, infinitely scalable storage method. A unified File Service enables seamless operations on underlying storage by different nodes.

      After deciding on TAE as the sole storage engine, multiple design adjustments were made to the fused TAE engine, resulting in the TAE storage engine. This engine has the following advantages:

      • Columnar Storage Management: Uniform columnar storage and compression methods provide inherent performance advantages for OLAP businesses.
      • Transaction Processing: Shared logs and TN nodes jointly support transaction processing for compute nodes.
      • Hot and Cold Separation: Using S3 object storage as the target for File Service, each compute node has its cache.

      The compute engine is based on the fundamental goal of being compatible with MySQL, with higher requirements for node scheduling, execution plans, and SQL capabilities. The high-performance compute engine has both MPP (massively parallel processing) and experimental architecture:

      • MySQL Compatible: Supports MySQL protocol and syntax.
      • Fused Engine: Rebuilds execution plans based on DAG, capable of executing both TP and AP.
      • Node Scheduling: Future support for adaptive intra-node and inter-node scheduling, meeting both concurrency and parallelism requirements.
      • Comprehensive SQL Capability: Supports subqueries, window functions, CTE, and spill memory overflow processing.
      • Vector Support: Supports vector storage and querying, making it a valuable storage tool for various machine learning applications, including facial recognition, recommendation systems, and genomics analytics.
      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#matrixone-architecture-design_1","title":"MatrixOne Architecture Design","text":"

      The MatrixOne architecture is as follows:

      The architecture of MatrixOne is divided into several layers:

      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#cluster-management-layer","title":"Cluster Management Layer","text":"

      Being responsible for cluster management, it interacts with Kubernetes to obtain resources dynamically when in the cloud-native environment, while in the on-premises deployment, it gets hold of resources based on the configuration. Cluster status is continuously monitored with the role of each node allocated based on resource information. Maintenance works are carried out to ensure that all system components are up and running despite occasional node and network failures. It rebalances the loads on nodes when necessary as well. Major components in this layer are:

      • Prophet Scheduler: take charge of load balancing and node keep-alive.
      • Resource Manager: being responsible for physical resources provision.
      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#serverless-layer","title":"Serverless Layer","text":"

      Serverless Layer is a general term for a series of stateless nodes, which, as a whole, contains three categories:

      • Background tasks: the most important one is called Offload Worker, which is responsible for offloading expensive compaction tasks and flushing data to S3 storage.
      • SQL compute nodes: responsible for executing SQL requests, here divided into write nodes and read nodes. The former also provides the ability to read the freshest data.
      • Stream task processing node: responsible for executing stream processing requests.
      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#logreliability-layer","title":"Log(Reliability) Layer","text":"

      As MatrixOne's Single Source of Truth, data is considered as persistently stored in MatrixOne once it is written into the Log Layer. It is built upon our world-class expertise in the Replicated State Machine model to guarantee state-of-the-art high throughput, high availability, and strong consistency for our data. Following a fully modular and disaggregated design by itself, it is also the central component that helps to decouple the storage and compute layers. This in turn earns our architecture much higher elasticity when compared with traditional NewSQL architecture.

      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#storage-layer","title":"Storage Layer","text":"

      The storage layer transforms the incoming data from the Log Layer into an efficient form for future processing and storage. This includes cache maintenance for fast accessing data that has already been written to S3.

      In MatrixOne, TAE (Transactional Analytic Engine) is the primary interface exposed by the Storage Layer, which can support both row and columnar storage together with transaction capabilities. Besides, the Storage Layer includes other internally used storage capabilities as well, e.g. the intermediate storage for streaming.

      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#storage-provision-layer","title":"Storage Provision Layer","text":"

      As an infrastructure agnostic DBMS, MatrixOne stores data in shared storage of S3 / HDFS, or local disks, on-premise servers, hybrid, and any cloud, or even smart devices. The Storage Provision Layer hides such complexity from upper layers by just presenting them with a unified interface for accessing such diversified storage resources.

      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#matrixone-system-components","title":"MatrixOne System Components","text":"

      In MatrixOne, to achieve the integration of distributed and multi-engine, a variety of different system components are built to complete the functions of the architecture-related layers:

      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#file-service","title":"File Service","text":"

      File Service is the component of MatrixOne responsible for reading and writing all storage media. Storage media include memory, disk, object storage, and so on., which provide the following features:

      • File Service provides a unified interface so that reading and writing of different media can use the same interface.
      • The design of the interface follows the concept of immutable data. After the file is written, no further updates are allowed. The update of the data is realized by generating a new file.
      • This design simplifies operations such as data caching, migration, and verification and is conducive to improving the concurrency of data operations.
      • Based on a unified read-write interface, File Service provides a hierarchical cache and a flexible cache strategy to balance read-write speed and capacity.
      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#log-service","title":"Log Service","text":"

      Log Service is a component specially used to process transaction logs in MatrixOne, and it has the following features:

      • The Raft protocol ensures consistency, and multiple copies are used to ensure availability.
      • Save and process all transaction logs in MatrixOne, ensure that Log Service logs are read and written typically before the transaction is committed, and check and replay the log content when the instance is restarted.
      • After the transaction is submitted and placed, truncate the content of the Log Service to control the size of the Log Service. The content that remains in the Log Service after truncation is called Logtail.
      • If multiple Log Service copies are down at the same time, the entire MatrixOne will be down.
      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#transaction-node","title":"Transaction Node","text":"

      The Transaction Node (TN) is the carrier used to run MatrixOne's distributed storage engine TAE, which provides the following features:

      • Manage metadata information in MatrixOne and transaction log content saved in Log Service.
      • Receive distributed transaction requests sent by Computing Node (CN), adjudicate the read and write requests of distributed transactions, push transaction adjudication results to CN, and push transaction content to Log Service to ensure the ACID characteristics of transactions.
      • Generate a snapshot according to the checkpoint in the transaction to ensure the snapshot isolation of the transaction, and release the snapshot information after the transaction ends.
      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#computing-node","title":"Computing Node","text":"

      The computing node (CN) is a component of Matrixone that accesses user requests and processes SQL. The toolkit includes the following modules:

      • Frontend, it handles the client SQL protocol, accepts the client's message, parses it to get the executable SQL of MatrixOne, calls other modules to execute the SQL, organizes the query results into a message, and returns it to the client.
      • Plan, parse the SQL processed by Frontend, generate a logical execution plan based on MatrixOne's calculation engine and send it to Pipeline.
      • Pipeline, which parses the logical plan, converts the logical plan into an actual execution plan and then runs the execution plan through Pipeline.
      • Disttae, responsible for specific read and write tasks, including synchronizing Logtail from TN and reading data from S3, and sending the written data to TN.
      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#stream-engine","title":"Stream Engine","text":"

      Stream Engine is a new component within MatrixOne, serving as an integrated stream engine designed for real-time querying, processing, and enriching data stored in a series of incoming data points, also known as data streams. With Stream Engine, you can employ SQL to define and create streaming processing pipelines, offering real-time data backend services. Additionally, you can utilize SQL to query data within streams and establish connections with non-streaming datasets, thereby further streamlining the data stack.

      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#proxy","title":"Proxy","text":"

      The Proxy component is a powerful tool mainly used for load balancing and SQL routing. It has the following functions:

      • Through SQL routing, resource isolation between different accounts is realized, ensuring that the CNs of different accounts will not affect each other.
      • Through SQL routing, users can do a second split in the resource group of the same account, improving resource utilization.
      • The load balancing between different CNs is realized in the second split resource group, making the system more stable and efficient.
      "},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#learn-more","title":"Learn More","text":"

      This page outlines the overall architecture design of MatrixOne. For information on other options that are available when trying out MatrixOne, see the following:

      • Install MatrixOne
      • MySQL Compatibility
      • What's New
      "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/","title":"Detailed Caching and Hot-Cold Data Separation Architecture","text":"

      Data caching and hot-cold data separation are key features of MatrixOne, where data is classified into hot and cold based on the frequency of use and managed differently. This design allows MatrixOne to maintain excellent performance while keeping operating costs low.

      "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#technical-architecture","title":"Technical Architecture","text":"

      In the overall architecture of MatrixOne, two parts are responsible for persistent data storage. One is the object storage shared by the entire MatrixOne distributed cluster, which is the primary storage device of the cluster. The other is the local storage on each compute node (CN), mainly used for data caching. The primary storage contains all data of the entire cluster, while the cache only saves data extracted from the primary storage during recent queries. In addition, the memory of CN nodes is also used as part of the data cache.

      When a user initiates a query, the system first checks whether the cache of the CN to which the user is connected already contains the required data. If it exists, the system directly returns the result to the user, prioritizing memory over disk. Suppose the required data is not found in the cache of the currently connected CN. In that case, the system queries the global metadata information to see if the required data exists in the cache of other available CNs for this user, checking memory first and then disk. If it exists, the system redirects the request to the CN containing this data, processes it, and returns the result to the user. If the data searched for is not in the cache of any available CN, the system initiates a read request to the object storage and returns the result to the user.

      When a user queries data from object storage, the queried data block will be filled into the corresponding position according to the cache query order. For example, if a user queries 100M of data from object storage, this 100M of data will first be written into the memory of the CN node to which the user is connected and then written into the disk cache of this CN node. Each time a new query is generated, the data in the cache will be updated according to this rule. Whether in memory or disk, data replacement in the CN cache follows the LRU (Least Recently Used) principle. With this mechanism, the most recent data is always in the easiest-to-get position, while relatively unpopular data will gradually be removed from the cache.

      "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#product-features","title":"Product Features","text":"

      The features of data caching and hot-cold data separation bring unique advantages to the product. To show more specifically, we will show a simple example.

      "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#environment-configuration","title":"Environment Configuration","text":"

      The environment introduced in this chapter will be based on the environment of MatrixOne Distributed Cluster Deployment. Please ensure that the entire MatrixOne is installed.

      1. Prepare a table named pe and the corresponding CSV data. This CSV data table is 35.8MB, with 1,048,575 rows of data. We will use the following SQL statement to create two databases and load the same data table into the pe table in both databases.

        create database stock;\ndrop table if exists stock.pe;\ncreate table stock.pe (\nts_code VARCHAR(255) DEFAULT null,\ntrade_date VARCHAR(255) DEFAULT null,\npe FLOAT DEFAULT null,\npb FLOAT DEFAULT null\n);\nload data local infile '/XXX/pe.csv' into table stock.pe fields TERMINATED BY '\\t';\n\ncreate database stock2;\ndrop table if exists stock2.pe;\ncreate table stock2.pe (\nts_code VARCHAR(255) DEFAULT null,\ntrade_date VARCHAR(255) DEFAULT null,\npe FLOAT DEFAULT null,\npb FLOAT DEFAULT null\n);\nload data local infile '/XXX/pe.csv' into table stock.pe fields TERMINATED BY '\\t';\n
      2. Next, perform the corresponding cache configuration. In the cluster yaml settings of MatrixOne, TN, Log Service, and CN all have cache-related settings. However, you only need to focus on the CN cache directly related to the query, and the primary cache size is managed by memoryCacheSize and diskCacheSize.

        metadata:\nname: mo\nnamespace: mo-hn\nspec:\ncnGroups:\n- name: cn-set1\n# Intermediate configuration omitted\nsharedStorageCache: # Core parameters for configuring CN cache\nmemoryCacheSize: 250Mi # CN's memory cache, Mi stands for MB\ndiskCacheSize: 1Gi # CN's disk cache, Gi stands for GB\n

      When both parameters are set to \"1\", the cache is turned off, and all query requests from MatrixOne will interact directly with the underlying object storage, significantly reducing the efficiency of queries.

      To simplify the display, you can first turn off the memory cache here and only set a specific size of the disk cache. Since the original data will be compressed to a particular ratio according to the data type after being stored, you need to set the disk cache to 20MB first, which is enough to store the compressed 35.8MB data file.

      metadata:\nname: mo\nnamespace: mo-hn\nspec:\ncnGroups:\n- name: cn-set1\n## Omitted intermediate configuration\nsharedStorageCache: # Core parameters for configuring CN cache\nmemoryCacheSize: \"1\" # CN's memory cache, Mi stands for MB\ndiskCacheSize: 20Mi # CN's disk cache, Gi stands for GB\n
      "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#query-acceleration","title":"Query Acceleration","text":"

      After completing the above settings and starting the MatrixOne cluster, you can experience the effect of cache acceleration through the results of multiple queries. Here, you can run a full table scan of stock.pe multiple times in a row.

      mysql> select * from stock.pe into outfile \"test01.txt\";\nEmpty set (6.53 sec)\n\nmysql> select * from stock.pe into outfile \"test02.txt\";\nEmpty set (4.01 sec)\n\nmysql> select * from stock.pe into outfile \"test03.txt\";\nEmpty set (3.84 sec)\n\nmysql> select * from stock.pe into outfile \"test04.txt\";\nEmpty set (3.96 sec)\n

      The above results show that the first query is noticeably slower because it needs to fetch data from object storage. However, since the data has been cached to the disk in the subsequent three queries, the query speed has significantly improved.

      "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#cache-replacement","title":"Cache Replacement","text":"

      Next, you can alternate and run a full table scan of stock.pe and stock2.pe multiple times.

      mysql> select * from stock2.pe into outfile \"test05.txt\";\nEmpty set (5.84 sec)\n\nmysql> select * from stock2.pe into outfile \"test06.txt\";\nEmpty set (4.27 sec)\n\nmysql> select * from stock2.pe into outfile \"test07.txt\";\nEmpty set (4.15 sec)\n\nmysql> select * from stock.pe into outfile \"test08.txt\";\nEmpty set (6.37 sec)\n\nmysql> select * from stock.pe into outfile \"test09.txt\";\nEmpty set (4.14 sec)\n\nmysql> select * from stock.pe into outfile \"test10.txt\";\nEmpty set (3.81 sec)\n

      You might notice that each time the data table for the query is switched, the query efficiency significantly decreases. This is due to the cache replacement mechanism. You only set a small cache, which is just enough to store the complete data of a table. Therefore, when you alternate queries, the old cache data is replaced. The new query needs to fetch data from the object storage, and when queried again, since the data has been cached, the query speed is improved.

      "},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#query-preheating","title":"Query Preheating","text":"

      In many business scenarios, we often need to accelerate the queries due to a large amount of data or complex queries. The cache mechanism of MatrixOne can accelerate queries by preheating the data.

      For example, the following SQL query:

      SELECT pe1.ts_code, pe1.pe, pe1.pb\nFROM stock2.pe as pe1\nWHERE pe1.pe = (SELECT min(pe2.pe)\nFROM stock2.pe as pe2\nWHERE pe1.ts_code = pe2.ts_code)\nORDER BY trade_date\nDESC LIMIT 1;\n

      If not optimized, the execution speed is as follows:

      SELECT pe1.ts_code, pe1.pe, pe1.pb\nFROM stock2.pe as pe1\nWHERE pe1.pe = (SELECT min(pe2.pe)\nFROM stock2.pe as pe2\nWHERE pe1.ts_code = pe2.ts_code)\nORDER BY trade_date\nDESC LIMIT\n\n1;\n+-----------+------+--------+\n| ts_code   | pe   | pb     |\n+-----------+------+--------+\n| 000038.SZ |    0 | 1.2322 |\n+-----------+------+--------+\n1 row in set (5.21 sec)\n

      This SQL query only involves the query of the stock2.pe table. We can preheat the table data to the cache by pre-scanning the complete table data, so the query can significantly improve the speed of this SQL query.

      mysql> select * from stock2.pe into outfile \"test11.txt\";\nEmpty set (6.48 sec)\n\nmysql> SELECT pe1.ts_code, pe1.pe, pe1.pb FROM stock2.pe as pe1 WHERE pe1.pe = (SELECT min(pe2.pe) FROM stock2.pe as pe2 WHERE pe1.ts_code = pe2.ts_code) ORDER BY trade_date DESC LIMIT 1;\n+-----------+------+---------+\n| ts_code   | pe   | pb      |\n+-----------+------+---------+\n| 000068.SZ |    0 | 14.6959 |\n+-----------+------+---------+\n1 row in set (2.21 sec)\n

      This feature is particularly suitable for some fixed report calculation scenarios. Users can preheat the data involved in the query and then perform the query, which can significantly improve the query effect.

      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/","title":"Detailed Logservice Architecture","text":"

      Logservice plays a vital role in MatrixOne. It is an independent service used by external components through RPC for log management.

      Logservice uses the dragonboat library based on the Raft protocol (a multi-raft group's Go language open source implementation) and usually uses local disks to store logs in multiple copies, similar to the management of WAL (Write-Ahead Log). The transaction commits must only be written to the Logservice without writing the data to S3. Additional components write batches of data to S3 asynchronously. Such a design ensures low latency when the transaction commits, and multiple copies provide high data reliability.

      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#logservice-architecture","title":"Logservice Architecture","text":"

      The architecture of Logservice consists of two parts: client and server. The server includes modules such as handler, dragonboat, and RSM (Replicated State Machine), while the client includes several key interfaces. The collaborative relationship between them is shown in the figure below:

      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#client","title":"Client","text":"

      Logservice client is mainly invoked by TN (Transaction node) and provides the following key interfaces:

      • Close(): Close the client connection.
      • Config(): Get client-related configuration.
      • GetLogRecord(): returns a pb.LogRecord variable containing an 8-byte LSN (log sequence number), a 4-byte record type, and a data field of type []byte. The data field consists of 4 bytes for pb.UserEntryUpdate, 8 for the replica TN ID, and payload []byte.
      • Append(): Append pb.LogRecord to Logservice and return LSN. The parameter pb.LogRecord can be reused on the calling side.
      • Read(): Read logs starting from the specified firstLsn from the Logservice until maxSize is reached. The returned LSN is used as the starting point for the next read.
      • Truncate(): Delete the logs before the specified LSN to free up disk space.
      • GetTruncatedLsn(): Returns the LSN of the most recently deleted log.
      • GetTSOTimestamp(): Request the specified timestamps from TSO (Timestamp Oracle). The caller occupies the scope of [returned value, returned value + count]. This method currently needs to be used.

      The Logservice client sends a request to the Logservice server through MO-RPC, and the server interacts with Raft/dragonboat and returns the result.

      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#server","title":"Server","text":""},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#server-handler","title":"Server Handler","text":"

      The server side of Logservice receives requests from clients and handles them. The entry function is (*Service).handle(), and different requests are processed by calling other methods:

      • Append: Appends logs to Logservice, ultimately invoking the (*NodeHost) SyncPropose() method of Dragonboat for synchronous proposal. It waits for the log to be committed and applied before returning, and the return value is the LSN (Log Sequence Number) after a successful log write.
      • Read: Reads log entries from the log database. It first calls the (*NodeHost) SyncRead() method to perform a linear read from the state machine up to the current LSN and then calls the (*NodeHost) QueryRaftLog() method to read log entries from the log database based on the LSN.
      • Truncate: Truncates logs in the log database to free up disk space. It's important to note that here, only the latest truncatable LSN in the state machine is updated, and the actual truncation operation still needs to be performed.
      • Connect: Establishes a connection with the Logservice server and attempts to read and write the state machine for state checking.
      • Heartbeat: Includes heartbeats to Logservice, CN, and TN. This request updates the status information of each entity in the HAKeeper's state machine and synchronizes the tick of HAKeeper. When the HAKeeper performs checks, it compares the offline time based on the tick, and if it's offline, it triggers removal or shutdown operations.
      • Get XXX: Retrieves relevant information from the state machine.
      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#bootstrap","title":"Bootstrap","text":"

      Bootstrap is the process that occurs when the logservice server starts, and it is carried out through HAKeeper's shard ID 0. The entry function is (*Service) BootstrapHAKeeper. Regardless of how many replicas are configured, each logservice process starts a replica of HAKeeper during startup. Each replica sets up members (replicas) upon startup, and the HAKeeper shard starts Raft with these members as the default replica count. After completing the leader election in Raft, it executes setting the initial cluster information (set initial cluster info), sets the shard to count for logs and TNs, and sets the replica count for logs. Once the replica count is set, any excess HAKeeper replicas will be stopped.

      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#heartbeat","title":"Heartbeat","text":"

      This heartbeat is sent from Logservice, CN, and TN to HAKeeper, rather than being a heartbeat between Raft replicas. It serves two primary purposes:

      1. Sending the status information of each replica to HAKeeper through heartbeats, allowing HAKeeper's state machine to update replica information.
      2. Retrieving commands that replicas need to execute from HAKeeper upon heartbeat response.

      The heartbeat process in Logservice is illustrated in the following diagram, and the process is similar for CN and TN.

      By default, the heartbeat is executed once per second, and its mechanism is as follows:

      1. Generate heartbeat information for all shard replicas on the storage level, including shard ID, node information, term, leader, etc.
      2. Send the request to the server side of Logservice.
      3. Upon receiving the request, the server invokes the (*Service) handleLogHeartbeat() method to process it and uses propose to send the heartbeat to Raft.
      4. Upon receiving the heartbeat, the state machine of HAKeeper calls the (*stateMachine) handleLogHeartbeat() method to process it, primarily performing the following tasks:
        • Updating the LogState in the state machine: Invoking the (*LogState) Update() method to update storage and shard information.
        • Retrieving commands from the ScheduleCommands of the state machine and returning them to the initiating end for execution.

      The principles of CN and TN sending heartbeats to HAKeeper are also similar.

      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#replicated-state-machine-rsm","title":"Replicated State Machine (RSM)","text":"

      Logservice and HAKeeper have an in-memory replicated state machine model where all data is stored in memory. They both implement the IStateMachine interface, and the key methods are as follows:

      • Update(): After completing a propose and commit (i.e., when a majority of replicas have finished writing), the Update() method is called to update the data in the state machine. The user implements the Update() method and must be side-effect free, meaning that the same input must yield the same output. Otherwise, it can lead to an unstable state machine. The results of the Update() method are returned through the Result structure, and if an error occurs, the error field is not empty.
      • Lookup(): Used to retrieve data from the state machine. The data type to be retrieved is specified through the interface{} parameter, and the result is also of type interface{}. Therefore, users need to define the data in the state machine, pass the corresponding data type, and then perform type assertion. Lookup() is a read-only method and should not modify the data in the state machine.
      • SaveSnapshot(): Creates a snapshot by writing the data from the state machine to an io.Writer interface, typically a file handle. Thus, the snapshot is ultimately saved to a local disk file. ISnapshotFileCollection represents a list of files outside the state machine's file system (if any), which will also be stored in the snapshot. The third parameter is to notify the snapshot process that the Raft replica has stopped, terminating the snapshot operation.
      • RecoverFromSnapshot(): Recovers the state machine data by reading the latest snapshot data from an io.Reader. []SnapshotFile represents an additional list of files directly copied to the state machine's data directory. The third parameter controls the snapshot operation's recovery, stopping it when Raft replica operations are being performed.
      • Close(): Closes the state machine and performs any necessary cleanup tasks.
      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#read-write-process","title":"Read-Write Process","text":"

      In Logservice, the general process for a read-write request is as follows:

      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#write-process","title":"Write Process","text":"
      1. The request is forwarded to the leader node if the connected node is not the leader. Upon receiving the request, the leader node writes the log entry to its local disk.
      2. Simultaneously, the request is asynchronously sent to follower nodes. Upon receiving the request, each follower node writes the log entry to its local disk.
      3. Once most nodes have completed the write, the commit index is updated, and other follower nodes are notified through heartbeat messages.
      4. The leader node executes the state machine operations (apply) after the write is committed.
      5. The result is returned to the client after the state machine operations are completed.
      6. Each follower node independently executes its state machine operations upon receiving the commit index from the leader.
      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#read-process","title":"Read Process","text":"

      Reading data can be divided into two scenarios:

      • Reading data from the state machine.

        • The client initiates a read request, and when the request reaches the leader node, the current commit index is recorded.
        • The leader node sends heartbeat requests to all nodes to confirm its leader status. Once most nodes respond and confirm it as the leader, it can respond to the read request.
        • Wait for the apply index to be greater than or equal to the commit index.
        • Once the condition is met, the data can be read from the state machine and returned to the client.

      • Reading log entries from the log database (log db).

        • This process typically occurs during cluster restart.
        • During restart, replicas first need to recover the state machine data from the snapshot, then start reading log entries from the log database based on the index position recorded in the snapshot and apply them to the state machine.
        • After this operation is completed, replicas can participate in leader elections.
        • When a leader is elected in the cluster, the Transaction nodes (TN) connect to the Logservice cluster and start reading log entries from the last checkpoint position of a replica's log database. These log entries are replayed into the Transaction node's in-memory data.

      "},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#truncation","title":"Truncation","text":"

      As the log entries in Logservice's log database continue to grow, it can lead to insufficient disk space. Therefore, regular disk space release is needed, achieved through truncation.

      Logservice uses an in-memory-based state machine that only stores some metadata and status information, such as tick, state, and LSN (Log Sequence Number), without recording user data. User data is recorded by the Transaction nodes (TN) themselves. You can think of it as a master-slave architecture, where the state machines are separate, and the TN and Logservice maintain their respective state machines.

      In this design with separate state machines, a simple snapshot mechanism can cause issues:

      1. When a TN sends a truncation request and sets the truncation index to 100, the applied index of the Logservice's state machine is 200. This means that logs before index 200 will be deleted, and a snapshot will be generated at that position. Note: The truncation index is not equal to the applied index.
      2. The cluster restarts.
      3. The Logservice's state machine applies the snapshot with index 200, sets the first index to 200 (deleting logs before index 200), and replays logs before providing the service.
      4. When the TN reads log entries from Logservice, starting from index 100, it fails to read because the logs before index 200 have been deleted, resulting in an error.

      To address the above problem, the current truncation workflow is as follows:

      1. The TN sends a truncation request and updates the truncation LSN (truncateLsn) in the Logservice's state machine. Only the value is updated, and no snapshot/truncation operation is executed.
      2. Each Logservice server internally starts a truncation worker that periodically sends truncation requests (Truncate Request). It's important to note that the Exported parameter in this request is true, indicating that the snapshot is not visible to the system and is only exported to a specified directory.
      3. The truncation worker also checks the list of currently exported snapshots to see if there are any snapshots with an index greater than the truncation LSN in the Logservice's state machine. If there are, the snapshot closest to the truncation LSN is imported into the system to make it effective and visible to the system.
      4. All replicas perform the same operations to ensure that the snapshot LSN of both state machines is consistent. This allows reading the corresponding log entries when the cluster restarts.
      "},{"location":"MatrixOne/Overview/architecture/architecture-proxy/","title":"Detailed Proxy Architecture","text":"

      Proxy, the sole component in MatrixOne responsible for load balancing and SQL request distribution, adapts to various scenarios by implementing session-level SQL routing through CN grouping and Proxy's SQL distribution.

      The architecture diagram of its SQL request distribution is as follows:

      • The Kubernetes Library layer utilizes built-in Kubernetes features to ensure high availability and load balancing of the Proxy layer.
      • SQL Proxy implements long connections, allowlists, and SQL request distribution, achieving load balancing and request forwarding for CNs.
      • CN does not have the concept of read-only replicas and is divided only by manual grouping.
      "},{"location":"MatrixOne/Overview/architecture/architecture-proxy/#technical-implementation","title":"Technical Implementation","text":"

      Based on the multi-CN architecture of MatrixOne's storage-compute separation and the responsibilities of Proxy, the concept of CN label groups is introduced in HAKeeper and Proxy, that is, CN collections with fixed names and quantities.

      As shown in the figure above, the technical implementation process is explained as follows:

      1. Create different CN labels through configuration options in the yaml file (including configuration, replica count, and tenant).
      2. When the MatrixOne cluster starts, MatrixOne will launch the same number of Pods according to the replica count of each CN label, and HAKeeper will uniformly apply the corresponding labels.
      3. MatrixOne Operator (i.e., MatrixOne cluster resource manager in Kubernetes) is responsible for dynamically maintaining the CN quantity within the CN label group. After a CN node goes down, it launches the same number of CNs.
      4. The Proxy component determines the connection session parameters and forwards a specific session to the corresponding CN group, implementing SQL routing.

      5. If a session request does not have a matching CN label, it will search for CNs with empty labels. If found, it will connect to the CN group with blank labels; otherwise, the connection will fail.

      6. During expansion, Proxy migrates existing connections based on the session count of existing CN nodes, moving existing sessions to new CN nodes. The session count of the migrated nodes is close to being balanced, achieving load balancing.
      7. During contraction, the Proxy migrates existing sessions of CN nodes that are about to go offline to other nodes. The session count of the migrated nodes is close to being balanced, thus achieving load balancing.

      8. Proxy is responsible for intra-group load balancing within the same CN label group.

      The Proxy analyzes the parameters in the session request to determine whether the request matches the CN label. In implementing SQL routing, session parameters are used to find the CN label group matching the request. Specifically, the Proxy may examine specific fields in the CN label, such as tenant information, replica count, etc., to route the request to the appropriate CN label group. This way, the Proxy can match session requests with CN labels and ensure that requests are routed to the correct CN node.

      "},{"location":"MatrixOne/Overview/architecture/architecture-proxy/#reference","title":"Reference","text":"

      To learn more about implementing load balancing through Proxy, see Using Proxy for Tenant and Load Independent Resource Management.

      "},{"location":"MatrixOne/Overview/architecture/architecture-tae/","title":"Transactional Analytical Engine Architecture","text":"

      MatrixOne's storage engine is called the Transactional Analytical Engine (TAE).

      "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#storage-engine-architecture","title":"Storage Engine Architecture","text":"

      The Transactional Analytical Engine (TAE) organizes data into column blocks, the minor IO units. Currently, these blocks are organized with a fixed number of rows. For columns of the Blob type, special handling is performed.

      TAE organizes data in the form of tables, and the data of each table is structured as a Log-structured Merge-tree (LSM) tree. The current implementation of TAE is a three-level LSM tree, including L0, L1, and L2. L0 is relatively tiny and stored entirely in memory, while L1 and L2 are persisted on disk.

      In TAE, L0 consists of transient blocks, where data is unsorted. On the other hand, L1 consists of sorted blocks that contain sorted data. New data is permanently inserted into the latest transient block. When the number of rows in a transient block exceeds a limit due to inserted data, the block is sorted by the primary key and then flushed into L1 as a sorted block. If the number of sorted blocks exceeds the maximum limit for a segment, a merge sort method is used to sort and write them into L2.

      Both L1 and L2 store data sorted by the primary key. The main difference between the two is that L1 ensures data is sorted within a block, while L2 ensures data is sorted within each segment. A segment is a logical concept equivalent to row groups or sets in other implementations. A segment can be compressed based on the number of updates (delete) operations, resulting in a new segment. Additionally, multiple segments can be merged into a new segment. These operations are performed by background asynchronous tasks, with scheduling strategies that balance write amplification and read amplification.

      "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#key-features","title":"Key Features","text":"
      • Suitable for AP scenarios: TAE offers efficient data compression, high query efficiency, fast aggregate operations, and concurrent solid processing capabilities. Therefore, TAE performs better and is more suitable for analytics processing and data warehousing scenarios, especially with large-scale data.
      • Flexible workload adaptation: By introducing the concept of Column Families, TAE allows flexible workload adaptation. For example, if all columns belong to the same Column Family (i.e., all column data is stored together), it behaves similarly to row storage. If each column is an independent Column Family (i.e., each column is stored independently), it behaves like a column storage. Users can easily switch between row and column storage by specifying it in the DDL table definition.
      "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#indexing-and-metadata-management","title":"Indexing and Metadata Management","text":"

      Like traditional column storage engines, TAE introduces Zonemap (min/max data) information at the block and segment levels. As a transactional storage engine, TAE implements complete primary key constraint functionality, including support for multi-column primary keys and global auto-increment IDs. A primary key index is automatically created for each table to ensure data deduplication during data insertion to satisfy the primary key constraint and enable filtering based on the primary key.

      Primary key deduplication is a critical step in data insertion. TAE achieves a balance in the following aspects:

      • Query performance
      • Memory usage
      • Data layout matching

      From an indexing granularity perspective, TAE can be divided into table-level indexing and segment-level indexing. For example, there can be one table-level index or one index per segment. Since TAE's table data consists of multiple segments, each undergoing compression/merging processes from L1 to L3, transitioning from unordered to ordered, table-level indexing is unfavorable. Therefore, TAE's indexing is built at the segment level.

      In segment-level indexing, there are two segments: append-only and non-dependable. For non-appendable segments, the segment-level index is a two-tier structure consisting of a Bloom filter and a Zone map. Dependable segments are composed of at least one dependable block and multiple non-appendable blocks. The index of the dependable block is an ART-tree (Adaptive Radix Tree) structure and a Zonemap, which reside in memory. The non-appendable blocks contain a Bloom filter and a Zone map.

      "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#buffer-management","title":"Buffer Management","text":"

      In a stable storage engine, efficient memory management is crucial for buffer management. Although buffer management is theoretically just the concept of a least-recently-used (LRU) cache, databases do not directly use the operating system's page cache to replace the cache manager, especially for transactional (TP) databases.

      In MatrixOne, a cache manager is used to manage memory buffer areas. Each buffer node has a fixed size and is allocated to four areas:

      1. Mutable: A fixed-size buffer area used to store transient column blocks from L0.
      2. SST: A buffer area used to store blocks from L1 and L2.
      3. Index
      An area for storing index information. 4. Redo log: Stores uncommitted transaction data, with at least one buffer needed per transaction.

      Each buffer node can be in either the Loaded or Unloaded state. When a user requests a pin operation on a buffer node from the cache manager, the reference count of the node is increased if it is in the Loaded state. If the node is in the Unloaded state, it is read from disk or remote storage, increasing the reference count. When there is insufficient memory, the system removes some nodes from memory based on the LRU strategy to free up space. When a user unpins a node, they close the node handle. If the reference count is 0, the node becomes a candidate for removal, while it remains in memory if the reference count is greater than 0.

      "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#write-ahead-log-and-log-replay","title":"Write-Ahead Log and Log Replay","text":"

      In TAE, the handling of redo logs is optimized to make the column storage engine's Write-Ahead Log (WAL) design more efficient. Unlike a row storage engine, TAE only records redo logs during transaction commits instead of recording them for each write operation. Utilizing the cache manager reduces the usage of input/output (IO), especially for short-lived transactions that may require rollbacks, thereby avoiding IO events. Additionally, TAE can support large or long-running transactions.

      The format of the log entry header in TAE's redo log follows the structure below:

      Item Byte Size GroupID 4 LSN 8 Length 8 Type 1

      The transaction log entries include the following types:

      Type Data Type Value Description AC int8 0x10 Full write operations of a committed transaction PC int8 0x11 Partial write operations of a committed transaction UC int8 0x12 Partial write operations of an uncommitted transaction RB int8 0x13 Transaction rollback CKP int8 0x40 Checkpoint

      Most transactions have only one log entry, but larger or longer transactions may require multiple entries. Therefore, a transaction's log may contain one or more UC-type log entries, one PC-type log entry, or just one AC-type log entry. UC-type log entries are allocated to a dedicated group.

      In TAE, the payload of a transaction log entry contains multiple transaction nodes. Transaction nodes include data manipulation language (DML) operations such as delete, add, update, and data definition language (DDL) operations such as create/delete table, create/delete database, etc. Each transaction node is a sub-item of a committed log entry and can be understood as part of the transaction log. Active transaction nodes share a fixed-size memory space and are managed by the cache manager. When there is insufficient space, some transaction nodes are unloaded, and their corresponding log entries are saved in the redo log. These log entries are replayed and applied to their respective transaction nodes during loading.

      A checkpoint is a safe point where the state machine can apply log entries during a system restart. Log entries before the checkpoint are no longer needed and will be physically destroyed at the appropriate time. TAE records information about the last checkpoint through groups, allowing log replay to start from the last checkpoint during system restart.

      TAE's WAL and log replay components have been independently abstracted into a code module called log store. It provides an abstraction for low-level log storage and access operations, which can be adapted to different implementations ranging from single-node to distributed systems. At the physical level, the behavior of a store is similar to that of a message queue. Starting from version 0.6 of MatrixOne, we have evolved towards a cloud-native version, using a separate shared log service as the log service. Therefore, in future versions, TAE's log store will be appropriately modified to access the external shared log service directly, eliminating the dependency on local storage.

      "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#transaction-processing","title":"Transaction Processing","text":"

      TAE ensures transaction isolation by employing the Multi-Version Concurrency Control (MVCC) mechanism. Each transaction is equipped with a consistent read view determined by the transaction's start time, ensuring that the data read within the transaction never reflects modifications made by other concurrent transactions. TAE provides fine-grained optimistic concurrency control, and conflicts occur only when updates are made to the same row and column. Transactions use value versions that existed at the start of the transaction and do not lock them during read operations. When two transactions attempt to update the same value, the second fails due to a write-write conflict.

      In TAE's architecture, a table consists of multiple segments, each resulting from multiple transactions. Therefore, a segment can be represented as $[T{start}, T{end}]$ (\u00b7 is the commit time of the earliest transaction, \u00b7 is the commit time of the latest transaction). To compress and merge segments, an additional dimension is added to the representation of a segment: $([T{start} T{end}]$, [T{create}, T{drop}])$ where $T{create}$ is the creation time of the segment and $T{drop}$ is the deletion time of the segment. When $T{drop} = 0$, it indicates that the segment has not been dropped. The representation of blocks is the same as that of segments: $([T{start}, T{end}]$, [T{create}, T{drop}])$. When a transaction is committed, its read view is determined by the commit time: $(Txn{commit} \\geqslant T{create}) \\bigcap ((T{drop} = 0) \\bigcup (T{drop} > Txn{commit}))$.

      Background asynchronous tasks handle the generation and transformation of segments. To ensure data consistency during data reading, TAE incorporates these asynchronous tasks into the transaction processing framework, as shown in the example below:

      Block $Block1 {L0}$ in layer L0 is created at time $t1$ and contains data from $Txn1$, $Txn2$, $Txn3$, and $Txn4$. Block $Block1 {L0}$ starts sorting at $t11$; its read view is the baseline plus one uncommitted update node. Sorting and persisting blocks may take a long time. Before the committed sorted block $Block2 {L1}$ is flushed, there are two committed transactions $Txn5$, $Txn6$, and one uncommitted transaction $Txn7$. When $Txn7$ is committed at $t16$, it fails because $Block1 {L0}$ has already been terminated. The update nodes $Txn5$ and $Txn6$ committed during the period $(t11, t16)$ will be merged into a new update node, which will be committed together with $Block2 {L1}$ at `$t16

      $`.

      The compaction process terminates a series of blocks or segments and atomically creates a new block or segment (or builds an index). Unlike regular transactions, this process often takes longer, and we do not want to block, update, or delete transactions involving the blocks or segments in question. Therefore, we extend the read view to include the metadata of blocks and segments. During the execution of a transaction, each write operation checks for write-write conflicts. If a conflict occurs, the transaction is terminated prematurely.

      "},{"location":"MatrixOne/Overview/architecture/architecture-tae/#mvcc-multi-version-concurrency-control","title":"MVCC (Multi-Version Concurrency Control)","text":"

      The version storage mechanism of a database determines how the system stores different versions of tuples and the information contained in each version. TAE creates a lock-free linked list called the version chain based on the pointer fields of data tuples. The version chain allows the database to locate the desired version of a tuple accurately. Therefore, the storage mechanism for version data is an essential consideration in the design of a database storage engine.

      One solution is to use an append-only mechanism to store all tuple versions of a table in the same storage space. Due to the inability to maintain a lock-free bidirectional linked list, the version chain can only point in one direction: from old to new (O2N) or from new to old (N2O).

      Another similar solution is time travel, which keeps the information of the version chain separate while maintaining the primary version of tuples in the main table.

      The third solution is to maintain the primary version of tuples in the main table and a series of incremental versions in separate storage. When updating existing tuples, the database acquires a continuous space from the incremental storage to create a new incremental version that only contains the original values of the modified attributes rather than the entire tuple. The database then directly updates the primary version in the main table.

      Each of the above solutions has characteristics that impact its performance in OLTP workloads. For LSM trees, due to their inherent append-only structure, they are closer to the first solution. However, the linked list of the version chain may need to be made apparent.

      TAE currently chooses a variant of the third solution:

      In heavy updates, the old version data of LSM tree structures can lead to significant read amplification. The cache manager maintains the version chain in TAE, and when it needs to be replaced, it is merged with the primary table data to generate new blocks. Thus, it is semantically in-place updates but implemented as copy-on-write, which is necessary for cloud storage. The newly generated blocks have less read amplification, which is advantageous for frequent AP queries after updates.

      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/","title":"MatrixOne Architecture Design","text":""},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone-overview","title":"MatrixOne Overview","text":"

      MatrixOne is a future-oriented hyperconverged cloud & edge native DBMS that supports transactional, analytical, and streaming workload with a simplified and distributed database engine working across multiple datacenters, clouds, edges, and other heterogenous infrastructures. This combination of engines is called HSTAP.

      As a redefinition of the HTAP database, HSTAP aims to meet all the needs of Transactional Processing (TP) and Analytical Processing (AP) within a single database. Compared with the traditional HTAP, HSTAP emphasizes its built-in streaming capability used for connecting TP and AP tables. This provides users with an experience that a database can be used just like a Big Data platform, with which many users are already familiar thanks to the Big Data boom. With minimal integration efforts, MatrixOne frees users from the limitations of Big Data and provides one-stop coverage for all TP and AP scenarios for enterprises.

      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone-architecture-layers","title":"MatrixOne Architecture Layers","text":"

      MatrixOne implements three independent layers, each with its object units and responsibilities. Different nodes can freely scale, no longer constrained by other layers. These three layers are:

      • Compute Layer: Based on Compute Nodes (CNs), MatrixOne enables serverless computing and transaction processing with its cache, which is capable of random restarts and scaling.
      • Transaction Layer: Based on Transaction Nodes and Log Services, MatrixOne provides complete logging services and metadata information, with built-in Logtail for recent data storage.
      • Storage Layer: Full data is stored in object storage, represented by S3, implementing a low-cost, infinitely scalable storage method. A unified File Service enables seamless operations on underlying storage by different nodes.

      After deciding on TAE as the sole storage engine, multiple design adjustments were made to the fused TAE engine, resulting in the TAE storage engine. This engine has the following advantages:

      • Columnar Storage Management: Uniform columnar storage and compression methods provide inherent performance advantages for OLAP businesses.
      • Transaction Processing: Shared logs and TN nodes jointly support transaction processing for compute nodes.
      • Hot and Cold Separation: Using S3 object storage as the target for File Service, each compute node has its cache.

      The compute engine is based on the fundamental goal of being compatible with MySQL, with higher requirements for node scheduling, execution plans, and SQL capabilities. The high-performance compute engine has both MPP (massively parallel processing) and experimental architecture:

      • MySQL Compatible: Supports MySQL protocol and syntax. Fused Engine: Rebuilds execution plans based on DAG, capable of executing both TP and AP.
      • Node Scheduling: Future support for adaptive intra-node and inter-node scheduling, meeting both concurrency and parallelism requirements.
      • Comprehensive SQL Capability: Supports subqueries, window functions, CTE, and spill memory overflow processing.
      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone-architecture-design_1","title":"MatrixOne Architecture Design","text":"

      The MatrixOne architecture is as follows:

      The architecture of MatrixOne is divided into several layers:

      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#cluster-management-layer","title":"Cluster Management Layer","text":"

      Being responsible for cluster management, it interacts with Kubernetes to obtain resources dynamically when in the cloud-native environment, while in the on-premises deployment, it gets hold of resources based on the configuration. Cluster status is continuously monitored with the role of each node allocated based on resource information. Maintenance works are carried out to ensure that all system components are up and running despite occasional node and network failures. It rebalances the loads on nodes when necessary as well. Major components in this layer are:

      • Prophet Scheduler: take charge of load balancing and node keep-alive.
      • Resource Manager: being responsible for physical resources provision.
      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#serverless-layer","title":"Serverless Layer","text":"

      Serverless Layer is a general term for a series of stateless nodes, which, as a whole, contains three categories:

      • Background tasks: the most important one is called Offload Worker, which is responsible for offloading expensive compaction tasks and flushing data to S3 storage.
      • SQL compute nodes: responsible for executing SQL requests, here divided into write nodes and read nodes. The former also provides the ability to read the freshest data.
      • Stream task processing node: responsible for executing stream processing requests.
      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#logreliability-layer","title":"Log(Reliability) Layer","text":"

      As MatrixOne's Single Source of Truth, data is considered as persistently stored in MatrixOne once it is written into the Log Layer. It is built upon our world-class expertise in the Replicated State Machine model to guarantee state-of-the-art high throughput, high availability, and strong consistency for our data. Following a fully modular and disaggregated design by itself, it is also the central component that helps to decouple the storage and compute layers. This in turn earns our architecture much higher elasticity when compared with traditional NewSQL architecture.

      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#storage-layer","title":"Storage Layer","text":"

      The storage layer transforms the incoming data from the Log Layer into an efficient form for future processing and storage. This includes cache maintenance for fast accessing data that has already been written to S3.

      In MatrixOne, TAE (Transactional Analytic Engine) is the primary interface exposed by the Storage Layer, which can support both row and columnar storage together with transaction capabilities. Besides, the Storage Layer includes other internally used storage capabilities as well, e.g. the intermediate storage for streaming.

      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#storage-provision-layer","title":"Storage Provision Layer","text":"

      As an infrastructure agnostic DBMS, MatrixOne stores data in shared storage of S3 / HDFS, or local disks, on-premise servers, hybrid, and any cloud, or even smart devices. The Storage Provision Layer hides such complexity from upper layers by just presenting them with a unified interface for accessing such diversified storage resources.

      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone-system-components","title":"MatrixOne System Components","text":"

      In MatrixOne, to achieve the integration of distributed and multi-engine, a variety of different system components are built to complete the functions of the architecture-related layers:

      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#file-service","title":"File Service","text":"

      File Service is the component of MatrixOne responsible for reading and writing all storage media. Storage media include memory, disk, object storage, and so on., which provide the following features:

      • File Service provides a unified interface so that reading and writing of different media can use the same interface.
      • The design of the interface follows the concept of immutable data. After the file is written, no further updates are allowed. The update of the data is realized by generating a new file.
      • This design simplifies operations such as data caching, migration, and verification and is conducive to improving the concurrency of data operations.
      • Based on a unified read-write interface, File Service provides a hierarchical cache and a flexible cache strategy to balance read-write speed and capacity.
      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#log-service","title":"Log Service","text":"

      Log Service is a component specially used to process transaction logs in MatrixOne, and it has the following features:

      • The Raft protocol ensures consistency, and multiple copies are used to ensure availability.
      • Save and process all transaction logs in MatrixOne, ensure that Log Service logs are read and written typically before the transaction is committed, and check and replay the log content when the instance is restarted.
      • After the transaction is submitted and placed, truncate the content of the Log Service to control the size of the Log Service. The content that remains in the Log Service after truncation is called Logtail.
      • If multiple Log Service copies are down at the same time, the entire MatrixOne will be down.
      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#transaction-node","title":"Transaction Node","text":"

      The Transaction Node (TN) is the carrier used to run MatrixOne's distributed storage engine TAE, which provides the following features:

      • Manage metadata information in MatrixOne and transaction log content saved in Log Service.
      • Receive distributed transaction requests sent by Computing Node (CN), adjudicate the read and write requests of distributed transactions, push transaction adjudication results to CN, and push transaction content to Log Service to ensure the ACID characteristics of transactions.
      • Generate a snapshot according to the checkpoint in the transaction to ensure the snapshot isolation of the transaction, and release the snapshot information after the transaction ends.
      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#computing-node","title":"Computing Node","text":"

      The computing node (CN) is a component of Matrixone that accesses user requests and processes SQL. The toolkit includes the following modules:

      • Frontend, it handles the client SQL protocol, accepts the client's message, parses it to get the executable SQL of MatrixOne, calls other modules to execute the SQL, organizes the query results into a message, and returns it to the client.
      • Plan, parse the SQL processed by Frontend, generate a logical execution plan based on MatrixOne's calculation engine and send it to Pipeline.
      • Pipeline, which parses the logical plan, converts the logical plan into an actual execution plan and then runs the execution plan through Pipeline.
      • Disttae, responsible for specific read and write tasks, including synchronizing Logtail from TN and reading data from S3, and sending the written data to TN.
      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#stream-engine","title":"Stream Engine","text":"

      Stream Engine is a new component within MatrixOne, serving as an integrated stream engine designed for real-time querying, processing, and enriching data stored in a series of incoming data points, also known as data streams. With Stream Engine, you can employ SQL to define and create streaming processing pipelines, offering real-time data backend services. Additionally, you can utilize SQL to query data within streams and establish connections with non-streaming datasets, thereby further streamlining the data stack.

      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#proxy","title":"Proxy","text":"

      The Proxy component is a powerful tool mainly used for load balancing and SQL routing. It has the following functions:

      • Through SQL routing, resource isolation between different accounts is realized, ensuring that the CNs of different accounts will not affect each other.
      • Through SQL routing, users can do a second split in the resource group of the same account, improving resource utilization.
      • The load balancing between different CNs is realized in the second split resource group, making the system more stable and efficient.
      "},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#learn-more","title":"Learn More","text":"

      This page outlines the overall architecture design of MatrixOne. For information on other options that are available when trying out MatrixOne, see the following:

      • Install MatrixOne
      • MySQL Compatibility
      • What's New
      "},{"location":"MatrixOne/Overview/architecture/streaming/","title":"Detailed Stream Engine Architecture","text":"

      MatrixOne incorporates a built-in stream engine designed for real-time querying, processing, and enriching data stored in a series of incoming data points, known as data streams. Developers can now use SQL to define and create stream processing pipelines as a real-time data backend service. Furthermore, developers can utilize SQL to query data within streams and establish connections with non-streaming datasets, thereby further simplifying the data stack.

      "},{"location":"MatrixOne/Overview/architecture/streaming/#technical-architecture","title":"Technical Architecture","text":"

      The technical architecture of the MatrixOne stream engine is illustrated as follows:

      MatrixOne introduced the ability to create streaming tables and implemented a Kafka connector to fulfill the streaming data ingestion requirements of numerous time-series scenarios.

      "},{"location":"MatrixOne/Overview/architecture/streaming/#connectors","title":"Connectors","text":"

      Connectors facilitate connecting with external data sources, such as the Kafka connector introduced in MatrixOne 1.0.

      MatrixOne supports the use of the following statement to establish a connection between connectors and external data sources:

      CREATE SOURCE | SINK CONNECTOR [IF NOT EXISTS] connector_name CONNECTOR_TYPE WITH (property_name = expression [, ...]);\n

      Here, the parameter CONNECTOR_TYPE is used to specify the target.

      "},{"location":"MatrixOne/Overview/architecture/streaming/#streams","title":"Streams","text":"

      A stream represents an append-only data flow akin to an unbounded table with infinite events. Each stream maps to an event group in the storage layer, such as Kafka topics or MatrixOne tables.

      • External stream: A stream using an external storage layer via connectors.
      • Internal stream: A stream that utilizes MatrixOne tables as the event storage.

      MatrixOne supports the use of the following statement to create streams:

      CREATE [OR REPLACE] [EXTERNAL] STREAM [IF NOT EXISTS] stream_name\n({ column_name data_type [KEY | HEADERS | HEADER(key)] } [, ...])\nWITH (property_name = expression [, ...]);\n

      For example, you can refer to the following examples:

      CREATE EXTERNAL STREAM STUDENTS (ID STRING KEY, SCORE INT)\nWITH (kafka_topic = 'students_topic', value_format = 'JSON', partitions = 4);\n

      Or:

      CREATE STREAM STUDENTS (ID STRING KEY, SCORE INT)\n

      You can also query streams and connect them with other tables and materialized views, as shown below:

      SELECT * FROM STUDENTS WHERE rank > 5;\n

      Additionally, you can insert new events, as demonstrated below:

      INSERT INTO foo (ROWTIME, KEY_COL, COL_A) VALUES (1510923225000, 'key', 'A');\n
      "},{"location":"MatrixOne/Overview/feature/cost-effective/","title":"Cost-Effective","text":"

      MatrixOne is a newly designed database, the architectural design philosophy emphasizing high-cost performance. The high cost-performance of MatrixOne is mainly reflected in the following aspects:

      "},{"location":"MatrixOne/Overview/feature/cost-effective/#single-cluster-supports-mixed-load-htap","title":"Single Cluster Supports Mixed Load HTAP","text":"

      With the rapid popularization and diversified development of big data applications, traditional data processing solutions are increasingly unable to meet the demand for real-time analysis of massive data. Modern data application requirements tend to consider both high-concurrent OLTP transactional business and large-scale data OLAP analytical business simultaneously.

      MatrixOne is specifically designed to solve the problem of mixed loads. MatrixOne can support OLTP and OLAP in the same cluster, achieving Hybrid Transaction and Analytical Processing (HTAP). Users no longer need to build two separate database systems for OLTP and OLAP, a single database can support mixed loads. This avoids the cost of building and maintaining two systems and the ETL process of synchronizing data from the OLTP system to the OLAP system. Users can easily handle business and analysis in the same cluster.

      "},{"location":"MatrixOne/Overview/feature/cost-effective/#single-storage-engine-achieves-htap","title":"Single Storage Engine Achieves HTAP","text":"

      In databases, achieving HTAP usually requires encapsulating an OLTP engine and an OLAP engine into a single database product. Although the conversion process between the two storage engines is hidden from the user, who only sees a unified SQL interface, the data is stored twice, once in each machine, and the cost of hardware and storage is not reduced.

      Different from the engine mentioned above encapsulation method, MatrixOne achieves HTAP using a single storage engine. As shown below, MatrixOne achieves single-engine HTAP by grouping other computing nodes (CN) and distinguishing between load-running links. When a user's application request enters the MatrixOne cluster, the Proxy module distributes OLAP-like requests to the CN group designed explicitly for OLAP. These requests usually need to read or write data on a large scale and interact directly with object storage via the CN nodes. For OLTP-like requests, such as small amounts of INSERT, UPDATE, and DELETE, these go through another group of CN designed explicitly for OLTP, and the TN nodes handle transaction information and write shared logs to LogService. TN also constantly compresses and merges small transactional data from LogService and writes them back to object storage.

      In summary, the data written into MatrixOne by users only exists once and is processed by a single storage engine, significantly reducing the cost of storage and computing hardware.

      "},{"location":"MatrixOne/Overview/feature/cost-effective/#flexible-resource-allocation-increases-utilization","title":"Flexible Resource Allocation Increases Utilization","text":"

      The system primarily serves transactional business based on CRUD in actual data application business scenarios. However, at specific points in time, such as at night, at the end of the month, or at the end of the year, it is necessary to analyze the overall data over a period of time. At this time, if the user only has one database system, they will need to temporarily reduce the business load or conduct OLAP analytical tasks when the business load is low. However, in such cases, there are often problems like long analysis time and cannot affect the long running time of business. If users deploy a separate database system for OLAP analytical business, the actual analytical business is often difficult to maximize, leading to a specific waste of resources.

      As introduced in the previous section, MatrixOne achieves HTAP by grouping stateless computing nodes and supporting OLTP and OLAP business at the underlying layer through different links. This architecture allows MatrixOne to adjust resources flexibly.

      Allocation according to actual business needs increases machine utilization and achieves true cost-effectiveness. When CRUD-type business requirements are high, you can allocate more CN nodes to OLTP. In addition, when analytical business requirements increase, you can give more CN nodes to OLAP. These adjustments are fully dynamic and configurable.

      Take the following diagram as an example; suppose that the user needs 3 computing nodes to handle OLTP business and 3 computing nodes to handle OLAP business. And these hardware resources are fully bound, i.e., nodes serving OLTP cannot provide services for OLAP and vice versa. Moreover, users' planning for machine resources often exceeds the upper limit of actual demand. However, the time to reach the total peak demand is quite limited in real business. If you plan to use the MatrixOne cluster to support these businesses, you can adjust to 4 computing nodes; typically, 3 nodes handle OLTP business, and 1 node takes OLAP business. Then, at the end of the month or other periods when the demand for analysis is high, you can adjust to 1 computing node to handle the OLTP business and 3 computing nodes to run the OLAP business; after the peak period, you can return to the original configuration, thereby improving machine resource utilization by 40%.

      "},{"location":"MatrixOne/Overview/feature/cost-effective/#efficient-and-low-cost-object-storage","title":"Efficient and Low-Cost Object Storage","text":"

      At the storage level, MatrixOne mainly uses object storage. This storage uses the principle of erasure coding and only needs a redundancy as low as 33% to ensure the high availability of data. Compared with the standard method of providing high availability through multiple copies, erasure coding has a higher space utilization rate under the same reliability.

      In the MatrixOne cluster, take the minimum configuration recommended by the official Minio for private deployment (4 nodes \u00d7 4 disks) as an example; MatrixOne can support at least 4 disks as erasure coding disks and 12 disks as data disk architecture, with redundancy of 1.33.

      In addition, object storage also supports low-cost storage media such as HDD disks. In usage scenarios where the demand for cluster computing performance is not high, and storage is the main focus, it can further reduce the usage cost.

      "},{"location":"MatrixOne/Overview/feature/cost-effective/#high-data-compression-ratio-brought-by-column-storage","title":"High data compression ratio brought by column storage","text":"

      When structured data is stored, the data structure of each column is the same. In the MatrixOne storage layer, data is stored in column format. This feature gives the data better compression characteristics:

      • Free compression algorithm: Each column is stored separately, and different columns can choose the most suitable compression algorithm for their data structure. These algorithms can use column data characteristics such as duplicate values, ordering, and data type-specific compression techniques to achieve better results. In contrast, the compression algorithms used by traditional row-store databases are often more general and fail to take full advantage of the characteristics of column data.
      • High redundancy of intra-column data: Column storage databases store data in the same column together so that similar values \u200b\u200bwill be clustered together, resulting in higher redundancy, allowing the compression algorithm to more effectively identify and compress the same or Similar data items, thus improving the compression ratio.

      The overall data compression rate of MatrixOne can be as low as 1%. The specific compression rate is affected by many factors, such as the data structure of the actual data and the degree of data redundancy.

      MatrixOne's columnar storage method will significantly compress your actual storage space and greatly reduce your storage costs.

      "},{"location":"MatrixOne/Overview/feature/cost-effective/#compatibility-with-mysql","title":"Compatibility with MySQL","text":"

      MatrixOne maintains compatibility with MySQL, the most popular open-source database on the market, regarding syntax, protocol, and ecological tools. This allows users familiar with MySQL or who have used MySQL to migrate and learn at a meager cost.

      For detailed information on MatrixOne's compatibility with MySQL, please look at the MySQL Compatibility Section.

      "},{"location":"MatrixOne/Overview/feature/feature-overview/","title":"MatrixOne Features Overview","text":""},{"location":"MatrixOne/Overview/feature/feature-overview/#features","title":"Features","text":"

      In MatrixOne, it has the following features to make you more efficient in the process of using MatrixOne:

      "},{"location":"MatrixOne/Overview/feature/feature-overview/#distributed-architecture","title":"Distributed Architecture","text":"

      In MatrixOne, the distributed storage and computing separation architecture is adopted. The separation of the storage, data, and computing layers enables MatrixOne to flexibly realize node expansion when encountering system resource bottlenecks. At the same time, resources can be allocated more efficiently under the multi-node architecture, avoiding hotspots and resource requisition to a certain extent.

      "},{"location":"MatrixOne/Overview/feature/feature-overview/#transactions-and-isolation","title":"Transactions and Isolation","text":"

      In MatrixOne, transactions are isolated using optimistic transactions and snapshots.

      Optimistic transactions can achieve better performance in a distributed architecture with fewer conflicts. At the same time, snapshot isolation with a higher isolation level can be achieved in terms of implementation. In order to ensure the ACID four elements of the transaction, MatrixOne currently supports and only supports one snapshot isolation level. Compared with the ordinary read-committed isolation level, this is stricter, which can effectively prevent dirty reads and better adapt to distributed optimistic transactions.

      "},{"location":"MatrixOne/Overview/feature/feature-overview/#cloud-native","title":"Cloud Native","text":"

      MatrixOne is a cloud-native database. From the storage layer, it adapts to various storage methods such as local disks, AWS S3, and NFS and realizes non-aware management of multiple types of storage through File service. MatrixOne clusters can run stably in a variety of infrastructure environments, can adapt to private enterprise clouds, and provide services in different public cloud vendor environments.

      "},{"location":"MatrixOne/Overview/feature/feature-overview/#load-balancing","title":"Load Balancing","text":"

      Under the distributed database architecture, load differences inevitably exist between different nodes, which may lead to performance bottlenecks in specific business scenarios or idle computing resources. Therefore, to ensure that other nodes are kept as close as possible in resource allocation, MatrixOne implements the load-balancing function of computing resources.

      "},{"location":"MatrixOne/Overview/feature/feature-overview/#sql-routing","title":"SQL Routing","text":"

      SQL routing is often used in early sub-database and sub-table database scenarios. It determines which instance/library/table to send the request to according to the data distribution after receiving an SQL request.

      In MatrixOne, although the capacity of the storage engine no longer limits the size of the database, under the multi-CN architecture, there are still scenarios for load balancing between multiple CNs and resource isolation between different accounts. Therefore, in MatrixOne, SQL routing is implemented to send SQL requests to other CN nodes for execution according to predefined rules. This solves the situation that a database instance cannot load many data access requirements.

      "},{"location":"MatrixOne/Overview/feature/feature-overview/#allowlist","title":"Allowlist","text":"

      Allowlist is a security policy that controls access to restricted resources, systems, or networks. It is based on a core idea that only authorized and trusted entities are allowed to access, while other unauthorized access attempts are denied. These authorized entities may include specific users, IP addresses, programs, or others. The opposite of an allowlist is a blocklist, a policy that specifies a list of prohibited entities that will be prevented from accessing a restricted resource, system, or network. Under the blocklist policy, entities outside the blocklist can access.

      The allowlist has the following characteristics:

      • Only users or systems on the pre-defined list are allowed to access; other users or systems not included in the allowlist are denied access.
      • Using an allowlist policy can improve security but may limit access for legitimate users. Therefore, a trade-off exists between security and user convenience when implementing an allowlist policy.
      • In the database system, the allowlist is mainly used to restrict user access, only allowing specific users to access the database of a particular server or network segment, thereby improving the security of the database.
      "},{"location":"MatrixOne/Overview/feature/feature-overview/#multi-account","title":"Multi-Account","text":"

      The multi-account mode of a single cluster can provide benefits such as resource sharing, simplified management, improved scalability, and security isolation. It is precious for scenarios needing database services for multiple accounts simultaneously.

      MatrixOne's multi-account mode can provide independent database instances for different accounts and adopts a logical isolation method to ensure the security and independence of each account's data, effectively preventing the risk of data leakage and tampering.

      "},{"location":"MatrixOne/Overview/feature/feature-overview/#matrixone-key-performance","title":"MatrixOne Key Performance","text":""},{"location":"MatrixOne/Overview/feature/feature-overview/#efficient-storage","title":"Efficient Storage","text":"

      MatrixOne chooses AWS S3 as an efficient storage solution, meeting the two core requirements of low cost and hot-cold data separation. Its reliable availability ensures low risk in public clouds and provides a compatible version for private deployment.

      • Low cost: Reducing redundancy to achieve lower costs with acceptable performance.
      • Hot-cold data separation: A necessary condition for fine-grained data management.
      "},{"location":"MatrixOne/Overview/feature/feature-overview/#clear-transaction-division-of-labor","title":"Clear Transaction Division of Labor","text":"
      • CN is responsible for all calculations and transaction logic, while TN is responsible for storing metadata, log information, and transaction adjudication.
      • The Logtail object is introduced in the logs to save associated data from recent logs. Logtail data is regularly written to S3. When CN scales out, Logtail data can be synchronized to the cache in real-time to achieve partial data sharing.
      • Set a threshold for transaction size. Transactions that exceed the threshold are directly written to S3 and logs only record write records. Transactions that do not exceed the threshold are still written by TN, significantly increasing throughput.
      "},{"location":"MatrixOne/Overview/feature/feature-overview/#htap-workload-isolation","title":"HTAP Workload Isolation","text":"

      As an HTAP database, it achieves isolation of different types of workloads:

      • Server-level isolation: When hardware resources are sufficient, each component runs on a different physical machine and accesses the same object storage.
      • Container-level isolation: When hardware resources are limited, the stateless nature of all nodes is utilized, and containers are used as isolation measures for each node.
      "},{"location":"MatrixOne/Overview/feature/feature-overview/#flexible-resource-allocation","title":"Flexible Resource Allocation","text":"

      As an HTAP database, the ratio of different business scenarios constantly changes, and there are higher requirements for resource allocation. The resource allocation pattern under the old architecture is doomed to be unable to achieve flexible adjustment, and more refined management of each node is needed, including but not limited to the following:

      • CN node division of labor: Users can divide CN for TP or AP business. When a business resource bottleneck occurs, CN is horizontally scaled out. Dynamically judge the workload of different business CN groups and automatically allocate idle resources to busy groups.
      • Complete isolation of analytical resources is achieved through the logical concept of accounts (accounts). Different accounts can use specified CN resources in a dedicated or shared manner.
      "},{"location":"MatrixOne/Overview/feature/high-availability/","title":"High Availability","text":"

      The high availability of a database is a critical enterprise demand, ensuring the continuous availability of the system, data security, and business continuity. MatrixOne is a highly available distributed database that can meet enterprise demands. This document aims to introduce the high availability features of MatrixOne, including critical functions such as fault recovery, data redundancy, load balancing, and so on.

      "},{"location":"MatrixOne/Overview/feature/high-availability/#business-requirements","title":"Business Requirements","text":"

      The business demands high database availability mainly reflect the following aspects:

      • Continuous Availability: Enterprises need to ensure the continuous operation of their critical business databases to prevent long-term system interruptions or unavailability of services, thus ensuring business continuity and user satisfaction.

      • Fault Recovery: When a database failure occurs, it should quickly and automatically perform fault detection and switch to reduce the system downtime, ensuring the continuity and reliability of the service.

      • Data Protection and Recovery: Data is a vital enterprise asset, so regular database backups are needed, and quick data recovery is required to cope with accidental data loss or damage.

      • Cross-Regional Disaster Recovery: For critical businesses, it may be necessary to set up data centers in different geographical regions, implementing cross-regional disaster recovery to cope with natural disasters, network interruptions, or regional faults.

      "},{"location":"MatrixOne/Overview/feature/high-availability/#advantages","title":"Advantages","text":"

      MatrixOne uses erasure coding for data redundancy checks and synchronizes transaction logs using the Raft protocol. Only when a majority of nodes write successfully can the transaction be committed, ensuring the strong consistency of data and availability even when a minority of replicas fail. MatrixOne's high availability meets the level 4 standard in the finance industry (RPO=0, RTO<30min).

      "},{"location":"MatrixOne/Overview/feature/high-availability/#architecture","title":"Architecture","text":"

      The overall technical architecture of MatrixOne is shown in the figure below. We will introduce their high availability according to different component modules.

      "},{"location":"MatrixOne/Overview/feature/high-availability/#resource-scheduling-layer","title":"Resource Scheduling Layer","text":"

      The technical architecture of MatrixOne is completely cloud-native. All technical components run on Kubernetes in a containerized form. The Kubernetes cluster can ensure continuous availability by adopting a multi-master and multi-slave deployment scheme. Specific deployment topology and system can refer to the Kubernetes official scheme.

      "},{"location":"MatrixOne/Overview/feature/high-availability/#storage-layer","title":"Storage Layer","text":"

      MatrixOne uses object storage in the storage layer and recommends deploying with Minio. MinIO, as a mature distributed object storage solution, needs to ensure the high availability of data services and the completeness and consistency of data files. The architecture of the MinIO cluster is distributed, storing data on multiple nodes, and providing high availability and fault tolerance. At the same time, the MinIO cluster uses Erasure Coding technology to ensure the reliability and availability of data. When a node fails, other nodes can use these coded replicas to recover lost data.

      "},{"location":"MatrixOne/Overview/feature/high-availability/#shared-logs","title":"Shared Logs","text":"

      The shared log component LogService is the only component in MatrixOne that holds distributed transaction status. This is a three-node architecture following the Raft protocol. Even if one node fails, it can still work typically. It is responsible for ensuring the final consistency of services for the entire MatrixOne cluster.

      "},{"location":"MatrixOne/Overview/feature/high-availability/#transaction-layer","title":"Transaction Layer","text":"

      The transaction layer component Transaction node is responsible for conflict detection and arbitration of transaction operations. It is a stateless node. If a failure occurs, Kubernetes can pull it up at any time, and it can generally recover in seconds, ensuring continuous availability. The current version of Transaction node only supports single-node operation, and subsequent versions will add multiple Transaction node schemes to improve availability further.

      "},{"location":"MatrixOne/Overview/feature/high-availability/#computation-layer","title":"Computation Layer","text":"

      The computation layer component Compute Node is responsible for parsing front-end Queries, generating, and executing execution plans. It is also a stateless node. If a failure occurs, Kubernetes can pull it up at any time and generally recover in seconds, ensuring continuous availability.

      "},{"location":"MatrixOne/Overview/feature/high-availability/#proxy","title":"Proxy","text":"

      The Proxy component in the resource scheduling layer is responsible for grouping computation nodes CN to achieve load isolation and implement user connection level load balancing within the CN group. Proxy also runs in the form of multiple replicas backing each other up to ensure high availability.

      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/","title":"HTAP","text":"

      MatrixOne is a database capable of supporting Hybrid Transaction Analytical Processing (HTAP), aiming to provide a solution that fulfills all the requirements for transaction processing (TP) and analytical processing (AP) within a single database. With its decoupled architecture for storage and transaction computations, MatrixOne can support online transactions and real-time statistical analysis in the same data engine while providing an efficient resource isolation mechanism. This design dramatically preserves data freshness, eliminating the need for building real-time data warehouses in many business scenarios, thus helping customers realize their business value.

      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#business-requirements","title":"Business Requirements","text":"

      With the expansion of business scale, the continuous growth of data volume, and the increasing complexity of business systems, traditional online databases have to face the issue of splitting. However, the architecture after splitting cannot meet some needs for associated statistics and real-time analysis. At this time, products like real-time data warehouses come into play. However, due to the complex architecture and high cost of real-time data warehouses, not all enterprises can build a complete ecological link. MatrixOne's HTAP mode was born in response to this situation. It can use one engine to support high concurrent online throughput while providing real-time online analysis capability for massive data. This provides momentum for enterprises to improve efficiency and continuous innovation.

      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#advantages","title":"Advantages","text":"
      • One-stop experience: Satisfy all the needs for transaction processing (TP) and analytical processing (AP) within a single database, and users can enjoy a one-stop experience covering all TP and AP scenarios.
      • Simplified integration work: Users using MatrixOne only need to do a small amount of integration work to achieve extensive use of TP and AP scenarios, especially significantly reducing the complex ETL work from TP database synchronization to AP database.
      • Cost-effective: MatrixOne uses a single storage engine to implement HTAP; compared with traditional multi-engine solutions, users only need to maintain a set of clusters and store one set of data, which can significantly reduce hardware investment.
      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#architecture","title":"Architecture","text":"

      MatrixOne implements HTAP through modular storage, calculation, transaction architecture, a multi-level storage system, and load processing link isolation mode.

      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#modular-separation-of-storage-computation-and-transaction","title":"Modular Separation of Storage, Computation, and Transaction","text":"

      The overall technical architecture of MatrixOne adopts a separate architecture of storage and computation. The modular design separates the database's computation, storage, and transaction processing into independent modules, thus forming a database system with independent scalability for each component. As shown in the following figure, MatrixOne is composed of three independent layers:

      • Computation layer, with Compute Node as the unit, realizes serverless computation and transaction processing. It has its Cache, supporting random restarts and scaling; multiple Compute Nodes can calculate parallel to improve query efficiency.
      • Transaction layer, composed of Transaction Node and Log Service, provides complete log service and metadata information, with built-in Logtail for storing recently written new data.
      • Storage layer, all data are saved in object storage represented by S3, which achieves low-cost, infinitely expandable storage method. Through a unified file operation service named File Service, it realizes the invisible operation of different nodes on the underlying storage.
      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#multi-level-storage-system","title":"Multi-level Storage System","text":"

      As illustrated in the previous section, the storage system of MatrixOne is composed of shared storage for all data, a small number of shared logs, and a stateless cache on the computing nodes.

      • All data are stored in object storage, the primary storage for the entire database and the only location for data persistence. Object storage has the characteristics of being low-cost and nearly infinitely scalable.
      • The LogService provides shared log services for saving state information of transactions such as writes/updates across the entire cluster. It is the only component in the entire cluster with a state. Therefore, LogService must ensure high availability through three nodes using the distributed Raft protocol. However, it only retains transaction logs for a certain period, which we call Longtail. After some time, there will be TN to help compress historical logs and store them in S3. Therefore, Logtail can maintain a very slim data size, generally a few GB.
      • Each computing node CN has a cache. When a user queries for the first time, it will read related data from object storage and put it into the cache as hot data. When the customer queries the same content again, if the cache is hit, the query result will be returned to the user quickly. The technical feature of cold and hot data separation brought by the cache can refer to Detailed Explanation of Data Caching and Cold-Hot Data Separation Architecture. In addition to reading data from object storage, CN nodes will also subscribe to Logtail data from LogService, and new updates in LogService will be pushed to CN immediately.
      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#load-processing-link-isolation","title":"Load Processing Link Isolation","text":""},{"location":"MatrixOne/Overview/feature/key-feature-htap/#custom-load-isolation","title":"Custom Load Isolation","text":"

      User requests first enter the MatrixOne cluster and go through the Proxy module. Proxy is a module used to implement the grouping and isolation of computing nodes. This module groups computing nodes CN into several groups through configuration and uses tags to distinguish various tenants or loads, allowing users to set different CN groups to handle other businesses according to different business needs.

      For specific operations of Proxy using CN groups, refer to Manage CN Groups Using Proxy.

      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#isolation-of-tpap-load-links","title":"Isolation of TP/AP Load Links","text":"

      At the execution level, MatrixOne will route it to different processing links according to the request type, thus realizing the isolation of OLTP and OLAP. Below we will explain how to implement load isolation based on the processing methods of read and write requests.

      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#write-request-processing","title":"Write Request Processing","text":"

      As shown in the figure, when processing write requests (INSERT/UPDATE/DELETE):

      1. CN node will start a transaction and check whether there are primary key conflicts or other transaction-related issues in the write request. If so, it will return an error to the user directly.

      2. Next, CN will decide on the operation link based on the data size of the write request. If the data size does not exceed the set threshold (usually 10MB), the CN node will send the data to the TN node. The TN node will perform operations like write conflict detection and transaction arbitration. After confirming no mistakes, these data will be written into LogService as logs to form Longtail.

      3. The updated Logtail will be immediately pushed to the CN nodes that have subscribed to Logtail data for queries. If the data size exceeds the threshold, the CN node will directly write the data into object storage and send the commit information to TN. The TN node will perform operations like write conflict detection and transaction arbitration. After confirming no errors, the transaction will be committed.

      From the figure above, it is known that small data volume OLTP-type write requests will go through the processing link from CN to TN and then to LogService, while large data volume write requests, such as Load, etc., will mainly go through CN to S3, and a small amount from CN to TN.

      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#read-request-processing","title":"Read Request Processing","text":"

      As shown in the figure, the CN node will first check the subscribed Logtail data when handling read requests. If the data directly hits Logtail, it is in the latest part of the written data and can be directly returned. If it does not hit Logtail, CN will check its cache and other visible CNs. If it hits the cache, it will directly return the result. If it does not hit the cache, CN will judge whether a large amount of data needs to be read through the execution plan. Multiple CN nodes will read in parallel from the object storage if it exceeds a certain threshold (such as 200 block sizes). A single CN node will read from object storage if it does not exceed the threshold.

      As shown above, OLTP and OLAP read requests will go through the processing link from CN to S3. Through the isolation of CN nodes by Proxy, further isolation of CN can be achieved.

      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#scenarios","title":"Scenarios","text":"

      Whether in finance, telecommunications, manufacturing, or emerging industries like the internet and technology, HTAP has many application scenarios.

      For example, in the financial field, HTAP databases can meet the needs of high-speed transaction processing and real-time risk management, support high throughput and low latency requirements of financial transactions, and provide real-time data analysis functions to support decision-making and risk monitoring.

      In the telecommunications industry, HTAP databases can be used for real-time billing and network optimization. They can handle much real-time data, track user communication and network activities, and support real-time analysis and intelligent decision-making to improve service quality, network performance, and user experience.

      In the Internet of Things field, HTAP databases can be used for device management and real-time monitoring. They can handle many sensor data and device status information and provide real-time device monitoring and management functions. This is significant for real-time decision-making, remote fault diagnosis, and predictive maintenance of IoT systems.

      "},{"location":"MatrixOne/Overview/feature/key-feature-htap/#real-time-financial-risk-control-system","title":"Real-time Financial Risk Control System","text":"

      As a leading city commercial bank, a specific bank has a real-time risk control system for its credit card business. This system is mainly responsible for monitoring and evaluating credit card transactions, identifying transaction risks, and taking restrictive measures promptly.

      The following table shows the core business requirements of this system and how MatrixOne's HTAP can meet these needs:

      Core Business Requirements Business Type HTAP Capabilities of MatrixOne Real-time acquisition of transaction data Fast and low-latency data writing MatrixOne can efficiently write massive amounts of data concurrently, further enhancing performance by expanding multiple CN nodes and object storage. Offline calculation of a large amount of data indicators, analysis of user behavior and risk factors Complex analytical queries, needing to process data at the TB level MatrixOne can handle massive star and snowflake data analysis and parallel computation across multiple CN nodes can linearly enhance analytical capabilities. Real-time analysis of transaction data, computation of risk indicators Typical AP business, needing to calculate data results within a specified time MatrixOne's parallel computing capabilities of multiple CN nodes can meet the calculation needs of large-scale data reports while providing fast data reading performance. Facing frequent and drastic business fluctuations Need for a flexible, scalable architecture to cope with large load fluctuations MatrixOne's storage and calculation separation architecture has strong scalability. It can quickly scale up and down during business fluctuations to match business needs."},{"location":"MatrixOne/Overview/feature/key-feature-htap/#telecommunications-business-management-system","title":"Telecommunications Business Management System","text":"

      A specific company is a provincial telecommunications operator serving tens of millions of users, mainly providing telephone communication services, and needs to support the use and statistical analysis of many users.

      The following table shows the core business scenarios of this system and how MatrixOne's HTAP can meet these needs:

      Core Business Scenarios Business Type MatrixOne's HTAP Solution Query user call charge deposit status and real-time shutdown High-concurrent short transactions, requiring low latency MatrixOne has OLTP capabilities, and its distributed architecture across multiple CN nodes ensures stable performance under high concurrency while achieving load balancing. Real-time account balance update after user recharge High-concurrent short transactions, requiring low latency MatrixOne's TP capabilities can meet the high-concurrent and low-latency TP requirements, and the distributed architecture across multiple CN nodes provides load balancing features. Bulk adjustment of user packages and effect in the next month Super large transaction, requiring high performance MatrixOne can write directly to S3, avoiding contention in Logservice under high concurrency, thus achieving fast batch data writing. Perform daily, weekly, monthly, quarterly, and annual statistics on user data Typical AP business, needing to calculate data results within a specified time MatrixOne's parallel computing capabilities of multiple CN nodes can meet the calculation needs of large-scale data reports while providing fast data reading performance."},{"location":"MatrixOne/Overview/feature/key-feature-htap/#manufacturing-execution-system","title":"Manufacturing Execution System","text":"

      A specific company is an electronic product manufacturer with dozens of production lines for various consumer electronic products. Its Manufacturing Execution System (MES) must manage personnel, machines, materials, and processes on the production line and regularly analyze production efficiency and energy consumption issues.

      The following table shows the core business scenarios of this system and how MatrixOne's HTAP can meet these needs:

      Core Business Scenarios Business Type MatrixOne's HTAP Solution Manage production, warehousing, and quality High-concurrent short transactions, requiring low latency MatrixOne has OLTP capabilities, distributed across multiple CN nodes to ensure stable performance under high concurrency while achieving load balancing. Real-time collection of a large amount of machine production data High-concurrent multi-data type data writing MatrixOne can efficiently write massive amounts of data concurrently, further enhancing performance by expanding multiple CN nodes and object storage. Analysis of the origin of a large number of historical production records Need for multidimensional query analysis of massive"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/","title":"Multi-Account","text":"

      MatrixOne is designed in a single-cluster multi-account approach. In this design, account (Account) is a logical concept as a unit of resource allocation and database management. MatrixOne's multi-account mode can provide independent database instances for different accounts and adopts an analytical isolation method to ensure the security and independence of each account's data, effectively preventing the risk of data leakage and tampering.

      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#business-requirements","title":"Business Requirements","text":"

      As an enterprise's business scales up and data volume continues to grow, alongside the increase in business departments or project teams, the enterprise can perform flexible tenant management according to its individual business needs and scale. This satisfies the independence requirements of different business departments or project teams. Under the multi-tenant mode of MatrixOne, enterprises can easily manage the data resources of each tenant, making the business processes such as data analysis and reporting smoother and more accurate. At the same time, this approach also helps the enterprise improve business efficiency, reduce management costs, and maximize enterprise resource utilization.

      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#advantages","title":"Advantages","text":"
      • Reduce operating costs: Multiple users can share a database cluster, avoiding deploying and managing multiple sets of clusters, thereby reducing the investment cost of hardware and software.

      • Resource and load isolation: The multi-account mode improves data security and reliability, and the data and load of different users are isolated from each other. Even if a user's data has problems or the load is too high, it will not affect other users.

      • Dynamic Resource Allocation: multi-account can also improve the scalability of the database. Each account can expand or shrink its resources independently and maximize resource usage in the face of different load levels.

      • account Unified Management: Although each account is isolated and operates independently, administrators can still manage other accounts through the system account, such as quickly creating new accounts and deleting old accounts in batches.

      • account data sharing: Data sharing between accounts is required in specific federal statistical query scenarios. MatrixOne provides a complete account data sharing and subscription mechanism to meet the more flexible business analysis needs.

      • Cross-Regional Deployment: When some services span many regions, accounts must associate with areas to provide nearby services. MatrixOne supports different accounts under the same cluster to be distributed in other areas to serve the business nearby.

      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#architecture","title":"Architecture","text":"

      The MatrixOne system contains two accounts: system (sys) and common accounts. The system account is built into the MatrixOne cluster, and the system will log in to this account by default after the cluster starts. The primary responsibilities of this account include:

      • Store and manage system tables related to the cluster.
      • Manage cluster-level functions, such as creating/deleting accounts, modifying system configuration, etc.

      In contrast, common accounts are created by system accounts. A common account can be regarded as a database instance, and the account name needs to be specified to connect. Common accounts have the following characteristics:

      • Possibility to create your user.
      • Can create databases, tables, and all other objects.
      • Have independent information_schema and other system databases.
      • Has independent system variables.
      • Possess other characteristics that a database instance should have.
      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#multi-account-resource-isolation","title":"Multi-account resource isolation","text":"

      MatrixOne's distributed cluster adopts a Proxy module and CN resource group technology architecture to realize multi-account resource isolation.

      When a user connects, the connection will pass through the Proxy module. The Proxy will forward the connection to a CN in the corresponding CN resource group according to the account label information of the CN and select the CN with the lightest load according to the principle of load balancing. In the MatrixOne cluster architecture, CNs are deployed in containers, so CNs are isolated. A CN resource group a account, uses is a set of CNs tagged with the account. If resources are insufficient and need to be expanded, the CN resource group can be expanded horizontally to meet the demand without preempting the resources of other CN resource groups.

      The architecture diagram is as follows:

      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#scenarios","title":"Scenarios","text":"

      The multi-account capability of MatrixOne can show advantages in the following application scenarios.

      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#multi-account-saas","title":"Multi-account SaaS","text":"

      Multi-account model design is critical in a SaaS application that serves many enterprise customers.

      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#traditional-architecture","title":"Traditional architecture","text":"

      Traditional multi-account architectures store and manage data for each account at the database level. There are usually multiple design patterns, such as a shared database pattern (each account shares a database but has its data tables/columns) or an independent database pattern (each account has its database).

      Both traditional models have specific challenges:

      • The account-shared database mode relies on the application layer to distinguish account logic by SQL and application layer code, and the isolation degree of data and resources is low. It is straightforward to seize the resources of other accounts when the load of a account suddenly increases significantly, resulting in a decline in the entire system's performance. However, only one set of database clusters is used in the account-shared database mode. The resource cost and operation and maintenance management difficulty are relatively low, and the upgrade/expansion/application change only needs to be done once to complete the global change.
      • The account-independent database mode supports each account with an independent database instance. The isolation of resources and data is very high, but resource costs and O&M difficulties are increased. Unifying upgrades and other operation and maintenance actions will be very time-consuming when accounts exceed one hundred.
      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#matrixone-architecture","title":"MatrixOne Architecture","text":"

      The multi-account capability of MatrixOne brings a new architectural approach. accounts still share a MatrixOne cluster, and unified account O&M and management can be performed through system accounts. In addition, the isolation of data and resources is realized through the built-in multi-account capability. Each account can independently expand and contract resources, further reducing the difficulty of operation and maintenance. This approach meets not only the requirements for isolation but also the requirements for low resource and operation and maintenance costs.

      Multi-account mode Data isolation degree Resource cost Resource isolation Operation and maintenance complexity account Shared Database Mode Low Low Low Low account Independent Database Mode High High High High MatrixOne Mode High Low High Low"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#microservice-application-architecture","title":"Microservice Application Architecture","text":"

      Microservice application architecture is a software architectural pattern that implements an application by developing small services. Each small service typically runs in its process and communicates via a lightweight HTTP API. These services are usually bounded by business modules, which can be developed, deployed independently, and released using automated deployment tools. A microservices approach can help businesses launch new products and services faster, aligning development teams with business goals.

      Unlike SaaS applications, microservice applications also face the problem of database sharing or independence. It is usually recommended to prepare a separate database for each microservice; this pattern is more suitable for microservice architecture because each service is developed, deployed, and scaled independently. Other services will not be affected when there is a need to upgrade or change the data schema. When a service needs to be expanded, the service can also be partially developed. In addition, if some services require unique database capabilities, such as Elastic Search or vector search, etc., this mode provides more flexible possibilities.

      However, microservices ultimately serve the same business, and data must be shared between different services, so they will also encounter the same dilemma as SaaS application multi-account.

      The multi-account capability provided by MatrixOne can well balance these two contradictions, which can not only ensure the independence of data and resource expansion of each microservice but also maintain a certain degree of sharing.

      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#group-subsidiariesbusiness-units","title":"Group Subsidiaries/Business Units","text":"

      Many group companies separate operations with regional subsidiaries or business units, which often operate independently, with total production, sales, and technical support teams, and use their IT systems. However, the group company needs to fully grasp the business status of the subsidiaries, so the subsidiaries need to report a large amount of business data regularly.

      This IT architecture faces precisely the same problem in terms of database design as the previous two scenarios, namely the trade-off between sharing and isolation. In addition, geographical location also needs to be considered in this scenario. Subsidiaries usually have their regional attributes and need to provide services nearby. For example, manufacturing companies are generally located in big cities such as Beijing, Shanghai, Guangzhou, and Shenzhen, but various factories may be scattered in second-and third-tier cities. These factories need to cooperate closely with systems such as ERP and MES. Therefore, these systems often need to be deployed locally in the factory, and the headquarters needs to grasp the situation of each factory, so these systems need to report data to the group company. The traditional deployment architecture usually adopts the method of independently deploying databases, while the application layer implements data synchronization and reporting.

      The multi-account capability of MatrixOne can well solve the database sharing/isolation dilemma. Since the CN nodes required by the accounts can be deployed to the nearest location of the subsidiary company, a cluster can be naturally formed with other components of the group company under the condition of network connectivity, which is not only convenient for localized business use, but also meets the requirements of efficient data reporting and statistics need.

      "},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#reference","title":"Reference","text":"

      For more information on multi-account, see:

      • Multi-Account Application Scenario
      • Quick Start: Create accounts, Verify Resource Isolation
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/","title":"MySQL Compatibility","text":"

      This documentation primarily introduces the compatibility comparison information between the MySQL mode of MatrixOne database and the native MySQL database.

      MatrixOne is highly compatible with the MySQL 8.0 protocol and commonly used features and syntax of MySQL 8.0. Additionally, MatrixOne provides support for commonly used MySQL-related tools, including Navicat, MySQL Workbench, JDBC, etc. However, due to the different technical architecture of MatrixOne and its ongoing development and improvement, some functionalities are not yet supported. This section will mainly discuss the differences between the MySQL mode of MatrixOne database and the native MySQL database from the following aspects:

      • DDL Statements
      • DCL Statements
      • DML Statements
      • Advanced SQL Features
      • Data Types
      • Indexes and Constraints
      • Partition
      • Functions and Operators
      • Storage Engine
      • Transaction
      • Security and Permissions
      • Backup and Restore
      • System Variables
      • Programming Language
      • Peripheral Tools
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#ddl-statements","title":"DDL statements","text":""},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-database","title":"About DATABASE","text":"
      • A database with a Chinese name is not supported.
      • ENCRYPTION are currently supported but do not work.
      • ALTER DATABASE is not supported.
      • Only the utf8mb4 character set and utf8mb4_bin collation are supported by default and cannot be changed.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-table","title":"About TABLE","text":"
      • The CREATE TABLE .. AS SELECT statement is not supported.
      • Support AUTO_INCREMENT in the column definition, but not the AUTO_INCREMENT custom start value in a table definition.
      • CHARACTER SET/CHARSET and COLLATE in column definitions are not supported.
      • ENGINE= in the table definition is not supported.
      • The clauses: CHANGE [COLUMN], MODIFY [COLUMN], RENAME COLUMN, ADD [CONSTRAINT [symbol]] PRIMARY KEY, DROP PRIMARY KEY, and ALTER COLUMN ORDER BY can be freely combined in ALTER TABLE, these are not supported to be used with other clauses for the time being.
      • Temporary tables currently do not support using ALTER TABLE to modify the table structure.
      • Tables created using CREATE TABLE ... CLUSTER BY... do not allow modifications to the table structure using ALTER TABLE.
      • ALTER TABLE does not support PARTITION related operations.
      • Support defining Cluster by column clauses to pre-sort a column to speed up queries.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-view","title":"About VIEW","text":"
      • CREATE OR REPLACE VIEW is not supported.
      • The with check option clause is not supported, but MatrixOne simply ignores' ENGINE= '.
      • The DEFINER and SQL SECURITY clauses are not supported.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-sequence","title":"About SEQUENCE","text":"
      • MySQL does not support SEQUENCE objects, but MatrixOne can create a sequence through CREATE SEQUENCE, and the syntax of MatrixOne is the same as PostgreSQL.
      • When using SEQUENCE in a table, you must pay attention to the auto_increment and sequence cannot be used together; otherwise, an error will be occured.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#dcl-statement","title":"DCL Statement","text":""},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-account","title":"About ACCOUNT","text":"
      • Multi Account is a unique function of MatrixOne, including related statements such as CREATE/ALTER/DROP ACCOUNT.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-permission","title":"About Permission","text":"
      • GRANT, authorization logic is different from MySQL.

      • REVOLE, the recovery logic is different from MySQL.

      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-show","title":"About SHOW","text":"
      • MatrixOne does not support performing SHOW operations on certain objects, including TRIGGER, FUNCTION, EVENT, PROCEDURE, ENGINE, and so on.
      • Due to architectural differences, MatrixOne has implemented some SHOW commands solely for syntactic compatibility; these commands will not produce any output, such as SHOW STATUS/PRIVILEGES, etc.
      • Although some commands have the same syntax as MySQL, their results differ significantly from MySQL due to different implementations. These commands include SHOW GRANTS, SHOW ERRORS, SHOW PROCESSLIST, SHOW VARIABLES.
      • For the purpose of its own management, MatrixOne offers several unique SHOW commands such as SHOW BACKEND SERVERS, SHOW ACCOUNTS, SHOW ROLES, SHOW NODE LIST, and others.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-set","title":"About SET","text":"
      • The system variables in MatrixOne differ significantly from MySQL, with most only providing syntactic compatibility. The parameters that can be set at present include: ROLE, SQL_MODE, and TIME_ZONE.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#dml-statements","title":"DML Statements","text":""},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-select","title":"About SELECT","text":"
      • SELECT...FOR UPDATE only supports single-table queries.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-insert","title":"About INSERT","text":"
      • MatrixOne does not support modifiers such as LOW_PRIORITY, DELAYED, HIGH_PRIORITY, IGNORE.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-update","title":"About UPDATE","text":"
      • MatrixOne does not support the use of LOW_PRIORITY and IGNORE modifiers.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-delete","title":"About DELETE","text":"
      • MatrixOne does not support modifiers such as LOW_PRIORITY, QUICK, or IGNORE.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-subqueries","title":"About Subqueries","text":"
      • MatrixOne does not support multi-level associated subqueries in IN.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-load","title":"About LOAD","text":"
      • MatrixOne supports SET, but only in the form of SET columns_name=nullif(expr1,expr2).
      • MatrixOne does not support ESCAPED BY.
      • MatrixOne supports LOAD DATA LOCAL on the client side, but the --local-infle parameter must be added when connecting.
      • MatrixOne supports the import of JSONlines files but requires some unique syntax.
      • MatrixOne supports importing files from object storage but requires some unique syntax.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#about-explain","title":"About EXPLAIN","text":"
      • MatrixOne's Explain and Explain Analyze printing formats refer to PostgreSQL, which differs from MySQL.
      • JSON-type output is not supported.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#other","title":"other","text":"
      • The REPLACE statement does not currently support rows of values \u200b\u200binserted using the VALUES row_constructor_list parameter.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#advanced-sql-features","title":"Advanced SQL Features","text":"
      • Triggers are not supported.
      • Stored procedures are not supported.
      • Event dispatchers are not supported.
      • Custom functions are not supported.
      • Materialized views are not supported.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#data-types","title":"Data Types","text":"
      • BOOL: Different from MySQL's Boolean value type, which is int, MatrixOne's Boolean value is a new type whose value can only be True or False.
      • DECIMAL: DECIMAL(P, D), the maximum precision of the effective number P and the number of digits after the decimal point D of MatrixOne is 38 digits, and MySQL is 65 and 30, respectively.
      • Float numbers: The usage of Float(M,D) and Double(M,D) is discarded after MySQL 8.0.17, but MatrixOne still retains this usage.
      • DATETIME: The maximum value range of MySQL is '1000-01-01 00:00:00' to '9999-12-31 23:59:59', and the maximum range of MatrixOne is '0001-01 -01 00:00:00' to '9999-12-31 23:59:59'.
      • TIMESTAMP: The maximum value range of MySQL is '1970-01-01 00:00:01.000000' UTC to '2038-01-19 03:14:07.999999' UTC, the maximum range of MatrixOne is '0001- 01-01 00:00:00' UTC to '9999-12-31 23:59:59' UTC.
      • MatrixOne supports UUID type.
      • Spatial types are not supported.
      • BIT and SET types are not supported.
      • MEDIUMINT type is not supported.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#indexes-and-constraints","title":"Indexes and Constraints","text":"
      • Secondary indexes only implement syntax and have no speedup effect.
      • Foreign keys do not support the ON CASCADE DELETE cascade delete.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#partition-support","title":"Partition Support","text":"
      • Only support KEY, HASH two partition types.
      • Subpartitions implement only syntax, not functionality.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#functions-and-operators","title":"Functions and Operators","text":""},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#aggregate-functions","title":"Aggregate Functions","text":"
      • Support MatrixOne-specific Median function.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#date-and-time-functions","title":"Date and Time Functions","text":"
      • MatrixOne's TO_DATE function is the same as MySQL's STR_TO_DATE function.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#cast-function","title":"CAST Function","text":"
      • The type conversion rules are pretty different from MySQL; see CAST.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#window-functions","title":"Window functions","text":"
      • Only RANK, DENSE_RANK, ROW_NUMBER are supported.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#json-functions","title":"JSON functions","text":"
      • Only JSON_UNQUOTE, JSON_QUOTE, JSON_EXTRACT are supported.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#system-management-functions","title":"System Management functions","text":"
      • CURRENT_ROLE_NAME(), CURRENT_ROLE(), CURRENT_USER_NAME(), CURRENT_USER(), PURGE_LOG() are supported.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#tae-storage-engine","title":"TAE Storage Engine","text":"
      • MatrixOne's TAE storage engine is independently developed and does not support MySQL's InnoDB, MyISAM, or other engines.
      • There is only a TAE storage engine in MatrixOne; there is no need to use ENGINE=XXX to change the engine.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#security-and-permissions","title":"Security and Permissions","text":"
      • Only using ALTER USER can change the password.
      • Does not support modifying the upper limit of user connections.
      • Connection IP whitelisting is not supported.
      • Does not support LOAD file authorization management.
      • Can support SELECT INTO file authorization management through the CREATE STAGE section.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#transaction","title":"Transaction","text":"
      • MatrixOne defaults to optimistic transactions.
      • different from MySQL, DDL statements in MatrixOne are transactional, and DDL operations can be rolled back within a transaction.
      • Table-level lock LOCK/UNLOCK TABLE is not supported.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#backup-and-restore","title":"Backup and Restore","text":"
      • The mysqldump backup tool is not supported; only the modump tool is supported.
      • Physical backups are supported.
      • Does not support binlog log backup.
      • Incremental backups are not supported.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#system-variables","title":"System variables","text":"
      • MatrixOne's lower_case_table_names has 5 modes; the default is 1.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#programming-language","title":"Programming language","text":"
      • Java, Python, Golang connectors, and ORM are basically supported, and connectors and ORMs in other languages \u200b\u200bmay encounter compatibility issues.
      "},{"location":"MatrixOne/Overview/feature/mysql-compatibility/#other-support-tools","title":"Other support tools","text":"
      • Navicat, DBeaver, MySQL Workbench, and HeidiSQL are basically supported, but the support for table design functions could be better due to the incomplete ability of ALTER TABLE.
      • The xtrabackup backup tool is not supported.
      "},{"location":"MatrixOne/Overview/feature/scalability/","title":"Scalability","text":"

      MatrixOne is a superior integration of heterogeneous cloud-native databases. Its structure is based on a storage, computing, and transaction separation architecture, which boasts impressive elastic scalability that quickly adapts to user workload changes. As data volumes and businesses expand, enterprises' demand for database scalability is ever-increasing.

      Generally, whether user data grows from 0 to 100TB or concurrent operations increase from several hundred to hundreds of thousands, MatrixOne can meet performance demands through its unparalleled scalability.

      "},{"location":"MatrixOne/Overview/feature/scalability/#business-requirements","title":"Business Requirements","text":"

      The demand for database scalability in enterprises primarily originates from the following pain points:

      • Growth in Data Volume: With business development, an enterprise's data volume will continue to grow. Suppose the scalability of the database could be better. In that case, it might not be able to effectively process a large amount of data, leading to a decline in query speed and affecting the regular operation of the business.
      • Increase in Concurrent Requests: As the number of users grows, the number of concurrent requests a database needs to handle also increases. Suppose the scalability of the database could be better. In that case, it might not effectively process many concurrent requests, leading to an extension in response time and affecting the user experience.
      • Change in Business Needs: The business needs of an enterprise may change over time. Suppose the scalability of the database could be better. In that case, it might be unable to flexibly adapt to these changes, causing the enterprise to invest more resources to adjust and optimize the database.
      • System Availability: If the scalability of the database could be better, it might not effectively handle hardware or network failures, resulting in lower system availability, which affects business continuity.

      If a database has good scalability, it can help enterprises improve data processing capabilities, thus effectively coping with the growth of data volume, handling the increase in concurrent requests, and ensuring system availability.

      "},{"location":"MatrixOne/Overview/feature/scalability/#architecture","title":"Architecture","text":"

      MatrixOne adopts a comprehensive cloud-native architecture. All components exist in the form of containers and are uniformly managed by Kubernetes. Kubernetes itself has strong container orchestration and management capabilities. In MatrixOne, the manual expansion only requires modifying the Kubernetes configuration.

      "},{"location":"MatrixOne/Overview/feature/scalability/#advantages","title":"Advantages","text":"

      From the technical architecture perspective, the unparalleled scalability of MatrixOne mainly manifests in the following aspects:

      • Flexible Expansion of Distributed Architecture: MatrixOne adopts a storage and computing-separated architecture. The separation of the storage, transaction, and computing layers allows MatrixOne to expand nodes when encountering system resource bottlenecks flexibly. The storage layer is mainly based on object storage and partly based on the cache on the computing nodes (CN). The transaction layer is based on stateless transaction nodes (TN). The computing layer is based on stateless computing nodes (CN). The multi-node architecture can more effectively distribute resources and avoid hot spots and resource contention.

      • Infinite Expansion Capability of S3 Object Storage: The core storage of MatrixOne is completely based on S3 object storage. S3 object storage has naturally high availability and infinite scalability, making MatrixOne highly scalable in data storage. No matter how the data scale grows, MatrixOne can meet the demand by expanding S3 storage. In a private deployment environment, MatrixOne builds S3 services based on the open-source MinIO component. MatrixOne can seamlessly utilize the object storage service provided by the public cloud in a public cloud environment.

      • Stateless Computing and Transaction Nodes: MatrixOne's computing nodes (CN) and transaction nodes (TN) are stateless, meaning they can be horizontally expanded anytime. Stateless design means that computing and transaction nodes do not need to store any persistent data

      They can be easily added or deleted to cope with different load requirements. This design makes MatrixOne extremely scalable and flexible when dealing with large-scale concurrent requests. (The current 1.0 version TN node does not yet have expansion capabilities, but the TN mainly handles transaction submission information, and the load is lower, so a single TN is enough to take a large-scale cluster, and subsequent versions will improve TN's scalability.)

      • Independent Scaling for Different Workloads and Accounts: MatrixOne utilizes the Proxy module to group multiple compute nodes (CN) into managed sets known as CN Sets, achieved through labeling. This enables the independent scaling of each CN Set. Users can assign different CN Sets to distinct tenants, ensuring load isolation and separate scaling between tenants. It's also possible to give various CN Sets to diverse workloads, such as read and write workloads, or transactional and analytical workloads, thereby achieving isolation and separate scaling between them.
      "},{"location":"MatrixOne/Performance-Tuning/performance-tuning-overview/","title":"SQL Performance Tuning Methods Overview","text":"

      SQL performance tuning optimizes database queries and operations to improve performance and response time. Several standard performance tuning methods include:

      • Index optimization: Indexes can speed up queries and improve database performance. By using the correct index type, selecting the right index columns, avoiding excessive indexing, and regularly rebuilding indexes, you can maximize the use of indexes to improve performance.

      • Query optimization: By optimizing the structure of queries, avoiding unnecessary subqueries, using more efficient JOIN statements, and avoiding using OR operators, you can reduce the time and resources required for queries.

      • Table structure optimization: Optimizing table structure, such as selecting the correct data types, avoiding NULL values, using appropriate constraints and default values, normalization, and denormalization, can reduce storage space and query time.

      • Data volume control: By limiting the amount of data returned, paging, caching, using stored procedures, and other methods, you can reduce the time and resources required for queries.

      • Server configuration optimization: By increasing server memory, adjusting database parameters, regularly cleaning logs and caches, and other methods, you can improve database performance and response time.

      • Monitoring and debugging: Using database performance monitoring tools, debugging SQL queries, viewing database logs and error messages, and other methods can help identify and resolve performance issues.

      It should be noted that SQL performance tuning is a complex process that requires comprehensive consideration of multiple factors such as database structure, data volume, and query patterns. Continuous testing and validation of optimization results are also necessary to ultimately improve database performance and response time.

      When executing SQL statements in MatrixOne, the system automatically plans and selects the optimal execution plan rather than simply querying according to the SQL statements. Currently, MatrixOne supports performance tuning through EXPLAIN interpretation of the execution plan and optimizing the physical arrangement of tables. To help you better tune SQL queries in MatrixOne, you can refer to the following documents on execution plans:

      • MatrixOne Query Execution Plan Overview: Describes the concepts of MatrixOne execution plans.
      • Using EXPLAIN to learn the execution plan: Describes how to use the EXPLAIN statement to understand how MatrixOne executes a query.
      • Performance Tuning Best Practices: Describes the best practices of using Cluster by in MatrixOne for performance tuning and learning how to improve query performance.
      "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/","title":"Optimizer Hints","text":"

      When you determine the problems in the execution plan, such as when the optimizer chooses a query plan that is not optimal, you can use Optimizer Hints to control the generation of the execution plan.

      The Hint hint command tells the query optimizer how to execute the query statement. By using hints, you can provide queries with information about how to access data to improve query performance. The Hint hint directive often tunes large or complex queries.

      Hints can be used to modify the execution plan of a query, including choosing a different index, using a different JOIN algorithm, changing the join order, etc.

      Hints in SQL use comment syntax, and specific comments can be added to query statements to specify hints.

      "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#syntax","title":"Syntax","text":"
      {DELETE|INSERT|SELECT|UPDATE} /*+ hint [text] [hint[text]]... */\n
      "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#explanations","title":"Explanations","text":"
      • DELETE, INSERT, SELECT, UPDATE are keywords of SQL statements.

      • /*+ */ is a comment symbol in the SQL statement.

      • hint is the specific instruction for hinting.

      • text is the argument to the prompt command.

      Here are some commonly used SQL hints:

      /*+ INDEX (table index) */: Specifies to use a specific index to execute the query.

      /*+ FULL (table) */: Specifies to perform a full table scan instead of using an index.

      "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#scenarios","title":"Scenarios","text":"
      • When the query optimizer chooses an inappropriate execution plan, you can use the hint hint to specify a better execution plan. For example, when a query involves multiple tables, the optimizer may choose the wrong join algorithm or join order, resulting in degraded query performance. In this case, hints can be used to specify a better join algorithm or join order.

      • When a query contains complex subqueries or aggregate functions, the hint hint can be used to optimize the execution plan of the query. Because the optimizer cannot analyze complex subqueries or aggregate functions, it may choose the wrong execution plan, resulting in degraded query performance.

      • When the amount of data accessed by the query is vast, the hint hint can be used to optimize the query execution plan. In this case, hints can be used to specify the use of a specific index or join algorithm to improve query performance.

      MatrixOne supports the use of hint hints to choose between full table scans or index scans and to optimize the order of multi-table joins.

      • Select full table scan or use index scan:

      An index scan can speed up queries, but in some cases, a full table scan might be faster than an index scan. For example, using indexes can become slow when query conditions are too broad. In this case, the following hint syntax can be used to choose to use a full table scan or an index scan:

      SELECT /*+ INDEX(table_name index_name) */ column_name FROM table_name WHERE ...\n

      Among them, table_name is the table name, index_name is the index name, and column_name is the column name. If an index name is specified, the query will scan that index. The query will use a full table scan if no index name is specified.

      • Optimize the order of multi-table joins:

      When a query involves multiple tables, the query optimizer will try to choose the optimal join order. However, in some cases, the optimizer may be unable to select the optimal join order, resulting in degraded query performance. In this case, the following hint syntax can be used to optimize the order of multi-table joins:

      SELECT /*+ ORDERED */ column_name FROM table1, table2 WHERE table1.column1 = table2.column2;\n

      Among them, ORDERED specifies that the query should be connected in the order of the tables, that is, connect table1 first and then join table2. This prevents the optimizer from choosing the wrong join order, improving query performance.

      "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#example","title":"Example","text":"
      -- Create a new table called orders\nCREATE TABLE order (\norder_id INT PRIMARY KEY,\ncustomer_id INT,\norder_date DATE,\norder_total DECIMAL(10, 2)\n);\n-- insert datas\nINSERT INTO order (order_id, customer_id, order_date, order_total)\nVALUES\n(1, 101, '2022-05-10', 100.00),\n(2, 102, '2022-05-09', 150.00),\n(3, 103, '2022-05-08', 200.00),\n(4, 104, '2022-05-07', 50.00);\n-- Query all orders of a customer and sort them in descending order by order date\nSELECT order_id, order_date, order_total\nFROM orders\nWHERE customer_id = 123\nORDER BY order_date DESC;\n

      To optimize this query, we can use the following hint hints:

      -- Execute the query using an index called idx_customer_id created on the customer_id field\nSELECT /*+ INDEX(orders idx_customer_id) */ order_id, order_date, order_total\nFROM orders\nWHERE customer_id = 123\nORDER BY order_date DESC;\n
      "},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#constraints","title":"Constraints","text":"

      Currently /*+ HINT_NAME(t1, t2) */ only implements the syntax, and cannot control the execution plan for now.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/","title":"Explain Statements Using Aggregation","text":"

      The aggregation may be used in SQL, and the execution plan of the aggregate query can be interpreted through EXPLAIN statements.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/#example","title":"Example","text":"

      We have prepared a simple example to help you understand the execution plan for interpreting the Aggregation using EXPLAIN.

      > drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/#hash-aggregation","title":"Hash Aggregation","text":"

      The Hash Aggregation algorithm uses a hash table to store intermediate results while performing aggregation. It executes in parallel using multiple threads but consumes more memory than Stream Aggregation.

      The following is an example of the Hash Aggregation operator:

      > SELECT /*+ HASH_AGG() */ count(*) FROM t1;\n+----------+\n| count(*) |\n+----------+\n|        9 |\n+----------+\n1 row in set (0.01 sec)\n\nmysql> EXPLAIN SELECT /*+ HASH_AGG() */ count(*) FROM t1;\n+-------------------------------------------+\n| QUERY PLAN                                |\n+-------------------------------------------+\n| Project                                   |\n|   ->  Aggregate                           |\n|         Aggregate Functions: starcount(1) |\n|         ->  Table Scan on db1.t1          |\n+-------------------------------------------+\n4 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/","title":"Explain Statements Using JOIN","text":"

      The SQL Optimizer needs to decide in which order tables should be joined and what is the most efficient join algorithm for a particular SQL statement.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/#example","title":"Example","text":"

      We have prepared a simple example to help you understand the execution plan for interpreting the JOIN using EXPLAIN.

      > drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/#hash-join","title":"Hash Join","text":"

      In the Hash Join operation, MatrixOne first reads the smaller tables in t1 and t2 and uses a hash function for each value to be joined to obtain a hash table. Then each row of the other table is scanned, and the hash value is calculated and compared with the hash table generated in the previous step. A new join table is generated based on the joinif any values meet the join criteria.

      The hash join operator is multi-threaded in MatrixOne and executes in parallel.

      An example of hash join is as below:

      > SELECT /*+ HASH_JOIN(t1, t2) */ * FROM t1, t2 WHERE t1.id = t2.id;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  | id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    1 |    1 |    4 |    3 |  1113.32 |  111332 | 1113 | hello        | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |    1 |    1 |    4 |    3 |  1113.32 |  111332 | 1113 | hello        | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    2 |    2 |    5 |    2 |  2252.05 |  225205 | 2252 | bye          | sub query      | 2022-04-28 | 2022-04-28 22:40:11 |    2 |    2 |    5 |    2 |  2252.05 |  225205 | 2252 | bye          | sub query      | 2022-04-28 | 2022-04-28 22:40:11 |\n|    3 |    6 |    6 |    3 |  3663.21 |  366321 | 3663 | hi           | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |    3 |    6 |    6 |    3 |  3663.21 |  366321 | 3663 | hi           | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    4 |    7 |    1 |    5 |  4715.22 |  471522 | 4715 | good morning | my subquery    | 2022-04-28 | 2022-04-28 22:40:11 |    4 |    7 |    1 |    5 |  4715.22 |  471522 | 4715 | good morning | my subquery    | 2022-04-28 | 2022-04-28 22:40:11 |\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n9 rows in set (0.00 sec)\n\nmysql> EXPLAIN SELECT /*+ HASH_JOIN(t1, t2) */ * FROM t1, t2 WHERE t1.id = t2.id;\n+------------------------------------+\n| QUERY PLAN                         |\n+------------------------------------+\n| Project                            |\n|   ->  Join                         |\n|         Join Type: INNER           |\n|         Join Cond: (t1.id = t2.id) |\n|         ->  Table Scan on db1.t1   |\n|         ->  Table Scan on db1.t2   |\n+------------------------------------+\n6 rows in set (0.01 sec)\n

      MatrixOne executes the Hash Join operator in the following order:

      1. Scan table t2 and t1 in parallel.

      2. Execute the JOIN filter query: (t1.id = t2.id).

      3. Execute INNER JOIN.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/","title":"MatrixOne Query Execution Plan Overview","text":""},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/#what-is-query-execution-plan","title":"What is Query Execution Plan?","text":"

      Execution plan is the specific steps for the database to execute SQL statements, such as accessing data in the table through index or full table scan, connection query implementation method and connection sequence, etc.; the execution plan is based on The details of your tables, columns, indexes, and conditions in the WHERE clause can tell you how the query will be executed or how it has been executed, which can be performed without reading all rows. Huge Queries of tables; joins involving multiple tables can be performed without comparing every combination of rows. If the performance of a SQL statement is not satisfactory, the first thing you should look at is its execution plan. Like most mature database products, MatrixOne database also provides the function of analyzing query statement performance.

      The MatrixOne query optimizer selects the most efficient execution plan by \"calculating\" the input SQL statement, and this execution plan is the execution plan.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/#use-explain-to-query-the-execution-plan","title":"Use EXPLAIN to query the execution plan","text":"

      The EXPLAIN statement shows the MatrixOne query execution plan for the SQL statement.

      EXPLAIN works with SELECT, DELETE, INSERT, REPLACE, and UPDATE statements.

      When EXPLAIN is used with an explainable statement, MatrixOne displays information from the optimizer about the statement execution plan. That is, MatrixOne explains how it would process the statement, including information about how tables are joined and in which order.

      Note

      When you use the MatrixOne client to connect to MatrixOne, to read the output result in a clearer way without line wrapping, you can use the pager less -S command. Then, after the EXPLAIN result is output, you can press the right arrow \u2192 button on your keyboard to horizontally scroll through the output.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/#explain-example","title":"EXPLAIN Example","text":"

      You can see the EXPLAIN example to understand the query execution plan:

      Data preparation:

      CREATE TABLE t (id INT NOT NULL PRIMARY KEY auto_increment, a INT NOT NULL, pad1 VARCHAR(255), INDEX(a));\nINSERT INTO t VALUES (1, 1, 'aaa'),(2,2, 'bbb');\nEXPLAIN SELECT * FROM t WHERE a = 1;\n

      Return result:

      +------------------------------------------------+\n| QUERY PLAN                                     |\n+------------------------------------------------+\n| Project                                        |\n|   ->  Table Scan on aab.t                      |\n|         Filter Cond: (CAST(t.a AS BIGINT) = 1) |\n+------------------------------------------------+\n

      EXPLAIN does not execute the actual query. EXPLAIN ANALYZE can be used to execute the query and show EXPLAIN information. This can be useful in diagnosing cases where the execution plan selected is suboptimal.

      EXPLAIN output analysis

      • QUERY PLAN: the name of an operator.

        • Filter Cond:Filter conditions
        • Table Scan:scans the table
      • Project is the parent node of the executive order in the query process. The structure of the Project is tree-like, and the child node \"flows into\" the parent node after the calculation is completed. The parent, child, and sibling nodes may execute parts of the query in parallel.

      Range query

      In the WHERE/HAVING/ON conditions, the MatrixOne optimizer analyzes the result returned by the primary key query. For example, these conditions might include comparison operators of the numeric and date type, such as >, <, =, >=, <=, and the character type such as LIKE.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/","title":"Explain Statements Using Subqueries","text":"

      MatrixOne performs several optimizations to improve the performance of subqueries. This document describes some of these optimizations for common subqueries and how to interpret the output of EXPLAIN.

      From the execution of SQL statements, subquery generally has the following two types:

      • Self-contained Subquery: In a database nested query, the inner query is entirely independent of the outer query.

        For example: select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);, the execution sequence is as follows:

        • Execute the inner query first: (select t2.id from t2 where t2.id>=3).

        • The result of the inner query is carried into the outer layer, and then the outer query is executed.

      • Correlated Subquery: In Correlated Subquery nested in databases, the inner and outer queries would not be independent, and the inner queries would depend on the outer queries.

        For example: SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);, generally, the execution sequence is as follows:

        • Queries a record from the outer query: SELECT * FROM t1 WHERE id.

        • Put the queried records into the inner query, then put the records that meet the conditions into the outer query.

        • Repeat the above steps.

        However, MatrixOne will rewrite the SQL statement as an equivalent JOIN statement: select t1.* from t1 join t2 on t1.id=t2.id where t2.id>=4;

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/#example","title":"Example","text":"

      We have prepared a simple example to help you understand the execution plan for interpreting the SUBQUERY using EXPLAIN.

      > drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/#self-contained-subquery","title":"Self-contained Subquery","text":"
      > select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    3 |    6 |    6 |    3 |  3663.21 |  366321 | 3663 | hi           | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    4 |    7 |    1 |    5 |  4715.22 |  471522 | 4715 | good morning | my subquery    | 2022-04-28 | 2022-04-28 22:40:11 |\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n7 rows in set (0.02 sec)\n\n> explain select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);\n+---------------------------------------------------------------+\n| QUERY PLAN                                                    |\n+---------------------------------------------------------------+\n| Project                                                       |\n|   ->  Join                                                    |\n|         Join Type: SEMI                                       |\n|         Join Cond: (t1.id = t2.id)                            |\n|         ->  Table Scan on db1.t1                              |\n|         ->  Project                                           |\n|               ->  Table Scan on db1.t2                        |\n|                     Filter Cond: (CAST(t2.id AS BIGINT) >= 3) |\n+---------------------------------------------------------------+\n8 rows in set (0.00 sec)\n

      The execution sequence is as follows:

      1. Execute the inner query first: (select t2.id from t2 where t2.id>=3).

      2. The result of the inner query is carried into the outer layer, and then the outer query is executed.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/#correlated-subquery","title":"Correlated subquery","text":"
      > SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    4 |    7 |    1 |    5 |  4715.22 |  471522 | 4715 | good morning | my subquery    | 2022-04-28 | 2022-04-28 22:40:11 |\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n6 rows in set (0.01 sec)\n\nmysql> explain SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);\n+---------------------------------------------------------------+\n| QUERY PLAN                                                    |\n+---------------------------------------------------------------+\n| Project                                                       |\n|   ->  Join                                                    |\n|         Join Type: SEMI                                       |\n|         Join Cond: (t1.ti = t2.ti), (t1.id = t2.id)           |\n|         ->  Table Scan on db1.t1                              |\n|         ->  Project                                           |\n|               ->  Table Scan on db1.t2                        |\n|                     Filter Cond: (CAST(t2.id AS BIGINT) >= 4) |\n+---------------------------------------------------------------+\n8 rows in set (0.01 sec)\n

      MatrixOne will rewrite the SQL statement as an equivalent JOIN statement: select t1.* from t1 join t2 on t1.id=t2.id where t2.id>=4;, the execution sequence is as follows:

      1. Execute the filter query: where t2.id>=4;.

      2. Scan Table: Table Scan on db1.t2, and then the result \"flow into\" into the parent node.

      3. Scan table table scan on db1.t1.

      4. Execute JOIN.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-views/","title":"EXPLAIN Statements Using Views","text":"

      EXPLAIN displays the tables that a view references, not the name of the view itself. This is because views are only virtual tables and do not store any data themselves. The definition of the view and the rest of the statement are merged together during SQL optimization.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-views/#example","title":"Example","text":"

      We have prepared a simple example to help you understand the execution plan for interpreting the VIEW using EXPLAIN.

      > drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> create view v1 as select * from (select * from t1) sub where id > 4;\n> select * from v1;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.01 sec)\n

      As shown in the above example, a new VIEW named v1 is created, then query the result of v1. So let's learn the query plan in this VIEW:

      > explain select * from v1;\n+--------------------------------------------------------------+\n| QUERY PLAN                                                   |\n+--------------------------------------------------------------+\n| Project                                                      |\n|   ->  Project                                                |\n|         ->  Project                                          |\n|               ->  Table Scan on db1.t1                       |\n|                     Filter Cond: (CAST(t1.id AS BIGINT) > 4) |\n+--------------------------------------------------------------+\n5 rows in set (0.00 sec)\n

      You can see that Project is the parent node in the execution order of this query. It starts from the most indented child node, then \"flows into\" its upper parent node, and finally \"flow into\" the Project parent node.

      To execute firstly:

      • Filter Cond: the filter condition

      To execute secondly:

      • Table Scan: scans all tables

      The following query is executed similarly to the above:

      > explain select * from (select * from t1) sub where id > 4;\n+--------------------------------------------------------+\n| QUERY PLAN                                             |\n+--------------------------------------------------------+\n| Project                                                |\n|   ->  Project                                          |\n|         ->  Table Scan on db1.t1                       |\n|               Filter Cond: (CAST(t1.id AS BIGINT) > 4) |\n+--------------------------------------------------------+\n4 rows in set (0.03 sec)\n
      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/","title":"Using EXPLAIN to learn the execution plan","text":"

      Because SQL is a declarative language, you cannot automatically tell whether a query is executed efficiently. You must first use the EXPLAIN statement to learn the current execution plan.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#example","title":"Example","text":"

      We have prepared a simple example to help you understand how to interpret an execution plan using EXPLAIN.

      > drop table if exists a;\n> create table a(a int);\n> insert into a values(1),(2),(3),(4),(5),(6),(7),(8);\n> select count(*) from a where a>=2 and a<=8;\n+----------+\n| count(*) |\n+----------+\n|        7 |\n+----------+\n1 row in set (0.00 sec)\n\n> explain select count(*) from a where a>=2 and a<=8;\n+-----------------------------------------------------------------------------------+\n| QUERY PLAN                                                                        |\n+-----------------------------------------------------------------------------------+\n| Project                                                                           |\n|   ->  Aggregate                                                                   |\n|         Aggregate Functions: starcount(1)                                         |\n|         ->  Table Scan on aab.a                                                   |\n|               Filter Cond: (CAST(a.a AS BIGINT) >= 2), (CAST(a.a AS BIGINT) <= 8) |\n+-----------------------------------------------------------------------------------+\n5 rows in set (0.00 sec)\n

      Above are the execution plan results for this query. Starting from the Filter Cond operator, the execution process of the query is as follows:

      1. Execute the Filter condition Filter Cond first: the integer whose data type is BIGINT and is greater than or equal to 2 and less than or equal to 8 is filtered out. According to the calculation reasoning, it should be (2),(3),(4),(5),(6),(7),(8).

      2. Scan Table in database aab.

      3. The number of integers is 7.

      In the end, the query result is 7, which means count(*) = 7.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#assess-the-current-performance","title":"Assess the current performance","text":"

      EXPLAIN only returns the query execution plan but does not execute the query.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#what-is-explain-analyze","title":"What is EXPLAIN ANALYZE","text":"

      EXPLAIN ANALYZE is a profiling tool for your queries that will show you where SQL spends time on your query and why. It will plan the query, instrument it and execute it while counting rows and measuring time spent at various points in the execution plan. When execution finishes, EXPLAIN ANALYZE will print the plan and the measurements instead of the query result.

      n addition to the query plan and estimated costs, which a normal EXPLAIN will print, EXPLAIN ANALYZE also prints the actual costs of individual iterators in the execution plan.

      "},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#how-to-use-explain-analyze","title":"How to use EXPLAIN ANALYZE?","text":"

      With the above example, to get the actual execution time, you can either execute the query or use EXPLAIN ANALYZE:

      > explain analyze select count(*) from a where a>=2 and a<=8;\n+-------------------------------------------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                                                    |\n+-------------------------------------------------------------------------------------------------------------------------------+\n| Project                                                                                                                       |\n|   Analyze: timeConsumed=0us inputRows=1 outputRows=1 inputSize=8bytes outputSize=8bytes memorySize=8bytes                     |\n|   ->  Aggregate                                                                                                               |\n|         Analyze: timeConsumed=3317us inputRows=2 outputRows=2 inputSize=8bytes outputSize=16bytes memorySize=16bytes          |\n|         Aggregate Functions: starcount(1)                                                                                     |\n|         ->  Table Scan on aab.a                                                                                               |\n|               Analyze: timeConsumed=6643us inputRows=31 outputRows=24 inputSize=96bytes outputSize=64bytes memorySize=64bytes |\n|               Filter Cond: (CAST(a.a AS BIGINT) >= 2), (CAST(a.a AS BIGINT) <= 8)                                             |\n+-------------------------------------------------------------------------------------------------------------------------------+\n8 rows in set (0.00 sec)\n

      Judging from the printed execution results, when performing aggregate calculations and scanning tables respectively, the following measurements are obtained, which can be used as reference items:

      • total time consumed: timeConsumed
      • inputRows/outputRows
      • inputSize/outputSize
      • memorySize

      With this information, you can analyze queries and understand why they behave the way they do, which can be explored in the following ways:

      • How long do these queries take to execute? You'll be able to view the timeConsumed.

      • Why execute the current query plan instead of other execution plans? You can look at the row counter. When there is a significant difference (i.e., several orders of magnitude or more) between the estimated and actual number of rows, it means that the optimizer chooses a plan based on the estimate, but looking at the actual execution can give you a good idea of \u200b\u200bwhich execution plan is better.

      So using EXPLAIN ANALYZE is analyzing query execution.

      The example query above takes 0.00 seconds to execute, which is an ideal performance. Also, because the query we executed in this example is simple, it meets the high execution performance.

      For more information, see EXPLAIN ANALYZE.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/","title":"1.1 through partition pruning","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#partition-pruning","title":"Partition Pruning","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#overview","title":"Overview","text":"

      Partition pruning is a method used for query optimization, applicable only when dealing with partitioned tables. By analyzing the filtering conditions in a query statement, partition pruning selects the partitions that may satisfy the conditions, thus avoiding scanning partitions that do not match the criteria and significantly reducing the amount of data that needs to be processed.

      For example:

      CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\nPRIMARY KEY(col1, col3)\n) PARTITION BY KEY(col1, col3) PARTITIONS 4;\n\nINSERT INTO t1 VALUES\n(1, '1980-12-17', 7369),\n(2, '1981-02-20', 7499),\n(3, '1981-02-22', 7521),\n(4, '1981-04-02', 7566),\n(5, '1981-09-28', 7654),\n(6, '1981-05-01', 7698),\n(7, '1981-06-09', 7782),\n(8, '0087-07-13', 7788),\n(9, '1981-11-17', 7839),\n(10, '1981-09-08', 7844),\n(11, '2007-07-13', 7876),\n(12, '1981-12-03', 7900),\n(13, '1987-07-13', 7980),\n(14, '2001-11-17', 7981),\n(15, '1951-11-08', 7982),\n(16, '1927-10-13', 7983),\n(17, '1671-12-09', 7984),\n(18, '1981-11-06', 7985),\n(19, '1771-12-06', 7986),\n(20, '1985-10-06', 7987),\n(21, '1771-10-06', 7988),\n(22, '1981-10-05', 7989),\n(23, '2001-12-04', 7990),\n(24, '1999-08-01', 7991),\n(25, '1951-11-08', 7992),\n(26, '1927-10-13', 7993),\n(27, '1971-12-09', 7994),\n(28, '1981-12-09', 7995),\n(29, '2001-11-17', 7996),\n(30, '1981-12-09', 7997),\n(31, '2001-11-17', 7998),\n(32, '2001-11-17', 7999);\n\nmysql> EXPLAIN VERBOSE SELECT * FROM t1 WHERE (col1 = 1 AND col3 = 7369) OR (col1 = 6 AND col3 = 7698);\n+-----------------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                          |\n+-----------------------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000)                                            |\n|   Output: t1.col1, t1.col2, t1.col3                                                                 |\n|   ->  Table Scan on db2.t1 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1)              |\n|         Output: t1.col1, t1.col2, t1.col3                                                           |\n|         Table: 't1' (0:'col1', 1:'col2', 2:'col3')                                                  |\n|         Hit Partition: p0, p2                                                                       |\n|         Filter Cond: (((t1.col1 = 1) and (t1.col3 = 7369)) or ((t1.col1 = 6) and (t1.col3 = 7698))) |\n+-----------------------------------------------------------------------------------------------------+\n7 rows in set (0.00 sec)\n

      This query prunes the partitions and scans only the p0 and p2 partitions.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#usage-scenarios-of-partition-pruning-in-key-partitioned-tables","title":"Usage scenarios of Partition Pruning in KEY Partitioned Tables","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#applicable-scenarios-in-key-partitioned-tables","title":"Applicable Scenarios in KEY Partitioned Tables","text":"

      Only equality comparison query conditions that match the partition key can support partition pruning for KEY partitioned tables.

      CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT PRIMARY KEY\n) PARTITION BY KEY(col3) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM t1 WHERE col3 = 7990 OR col3 = 7988;\n+-------------------------------------------------------------------+\n| QUERY PLAN                                                        |\n+-------------------------------------------------------------------+\n| Project                                                           |\n|   ->  Table Scan on db1.t1                                        |\n|         Hit Partition: p0, p1                                     |\n|         Filter Cond: ((t1.col3 = 7990) or (t1.col3 = 7988))       |\n|         Block Filter Cond: ((t1.col3 = 7990) or (t1.col3 = 7988)) |\n+-------------------------------------------------------------------+\n5 rows in set (0.00 sec)\n

      In this SQL statement, the condition col3 = 7990 can determine that all results are located in partition p0. The condition col3 = 7988 can determine that all results are situated in partition p1. Since these two conditions are combined using OR, only partitions p0 and p1 need to be scanned, resulting in partition pruning with the outcome of p0 and p1.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#inapplicable-scenarios-in-key-partitioned-tables","title":"Inapplicable Scenarios in KEY Partitioned Tables","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#scenario-1","title":"Scenario 1","text":"

      Conditions that cannot determine if the query results are within a single partition, such as between, > < >= <=, and similar conditions, cannot benefit from partition pruning optimization.

      mysql> EXPLAIN SELECT * FROM t1 WHERE col3 >= 7782;\n+----------------------------------------------+\n| QUERY PLAN                                   |\n+----------------------------------------------+\n| Project                                      |\n|   ->  Table Scan on db1.t1                   |\n|         Hit Partition: all partitions        |\n|         Filter Cond: (t1.col3 >= 7782)       |\n|         Block Filter Cond: (t1.col3 >= 7782) |\n+----------------------------------------------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#scenario-2","title":"Scenario 2","text":"

      In scenarios where filtering conditions can only be obtained during the execution plan generation phase, partition pruning optimization cannot be utilized.

      mysql> EXPLAIN SELECT * FROM t1 WHERE col3 = (SELECT col3 FROM t2 WHERE t1.col3 = t2.col3 AND t2.col1 < 5);\n+------------------------------------------------------+\n| QUERY PLAN                                           |\n+------------------------------------------------------+\n| Project                                              |\n|   ->  Filter                                         |\n|         Filter Cond: (t1.col3 = t2.col3\n\n)             |\n|         ->  Join                                     |\n|               Join Type: SINGLE                      |\n|               Join Cond: (t1.col3 = t2.col3)         |\n|               ->  Table Scan on db1.t1               |\n|                     Hit Partition: all partitions    |\n|               ->  Table Scan on db1.t2               |\n|                     Hit Partition: all partitions    |\n|                     Filter Cond: (t2.col1 < 5)       |\n|                     Block Filter Cond: (t2.col1 < 5) |\n+------------------------------------------------------+\n12 rows in set (0.00 sec)\n

      This query retrieves results from a subquery and constructs an equality filter condition col3 = ? for each row read. However, partition pruning only takes effect during the query plan generation phase, not during execution, making it ineffective in this scenario.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#usage-scenarios-of-partition-pruning-in-hash-partitioned-tables","title":"Usage scenarios of Partition Pruning in HASH Partitioned Tables","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#applicable-scenarios-in-hash-partitioned-tables","title":"Applicable Scenarios in HASH Partitioned Tables","text":"

      HASH partitioned tables are similar to KEY partitioned tables, where only equality comparison query conditions can benefit from HASH partition pruning.

      CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH(store_id) PARTITIONS 4;\n\nINSERT INTO employees VALUES\n(10001, 'Georgi', 'Facello', '1953-09-02','1986-06-26',120, 1),\n(10002, 'Bezalel', 'Simmel', '1964-06-02','1985-11-21',150, 7),\n(10003, 'Parto', 'Bamford', '1959-12-03','1986-08-28',140, 3),\n(10004, 'Chirstian', 'Koblick', '1954-05-01','1986-12-01',150, 3),\n(10005, 'Kyoichi', 'Maliniak', '1955-01-21','1989-09-12',150, 18),\n(10006, 'Anneke', 'Preusig', '1953-04-20','1989-06-02',150, 15),\n(10007, 'Tzvetan', 'Zielinski', '1957-05-23','1989-02-10',110, 6),\n(10008, 'Saniya', 'Kalloufi', '1958-02-19','1994-09-15',170, 10),\n(10009, 'Sumant', 'Peac', '1952-04-19','1985-02-18',110, 13),\n(10010, 'Duangkaew', 'Piveteau', '1963-06-01','1989-08-24',160, 10),\n(10011, 'Mary', 'Sluis', '1953-11-07','1990-01-22',120, 8),\n(10012, 'Patricio', 'Bridgland', '1960-10-04','1992-12-18',120, 7),\n(10013, 'Eberhardt', 'Terkki', '1963-06-07','1985-10-20',160, 17),\n(10014, 'Berni', 'Genin', '1956-02-12','1987-03-11',120, 15),\n(10015, 'Guoxiang', 'Nooteboom', '1959-08-19','1987-07-02',140, 8),\n(10016, 'Kazuhito', 'Cappelletti', '1961-05-02','1995-01-27',140, 2),\n(10017, 'Cristinel', 'Bouloucos', '1958-07-06','1993-08-03',170, 10),\n(10018, 'Kazuhide', 'Peha', '1954-06-19','1987-04-03',170, 2),\n(10019, 'Lillian', 'Haddadi', '1953-01-23','1999-04-30',170, 13),\n(10020, 'Mayuko', 'Warwick', '1952-12-24','1991-01-26',120, 1),\n(10021, 'Ramzi', 'Erde', '1960-02-20','1988-02-10',120, 9),\n(10022, 'Shahaf', 'Famili', '1952-07-08','1995-08-22',130, 10),\n(10023, 'Bojan', 'Montemayor', '1953-09-29','1989-12-17',120, 5),\n(10024, 'Suzette', 'Pettey', '1958-09-05','1997-05-19',130, 4),\n(10025, 'Prasadram', 'Heyers', '1958-10-31','1987-08-17',180, 8),\n(10026, 'Yongqiao', 'Berztiss', '1953-04-03','1995-03-20',170, 4),\n(10027, 'Divier', 'Reistad', '1962-07-10','1989-07-07',180, 10),\n(10028, 'Domenick', 'Tempesti', '1963-11-26','1991-10-22',110, 11),\n(10029, 'Otmar', 'Herbst', '1956-12-13','1985-11-20',110, 12),\n(10030, 'Elvis', 'Demeyer', '1958-07-14','1994-02-17',110, 1),\n(10031, 'Karsten', 'Joslin', '1959-01-27','1991-09-01',110, 10),\n(10032, 'Jeong', 'Reistad', '1960-08-09','1990-06-20',120, 19),\n(10033, 'Arif', 'Merlo', '1956-11-14','1987-03-18',120, 14),\n(10034, 'Bader', 'Swan', '1962-12-29','1988-09-21',130, 16),\n(10035, 'Alain', 'Chappelet', '1953-02-08','1988-09-05',130, 3),\n(10036, 'Adamantios', 'Portugali', '1959-08-10','1992-01-03',130, 14),\n(10037, 'Pradeep', 'Makrucki', '1963-07-22','1990-12-05',140, 12),\n(10038, 'Huan', 'Lortz', '1960-07-20','1989-09-20',140, 7),\n(10039, 'Alejandro', 'Brender', '1959-10-01','1988-01-19',110, 20),\n(10040, 'Weiyi', 'Meriste', '1959-09-13','1993-02-14',140, 17);\n\nmysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10;\n+------------------------------------------------+\n| QUERY PLAN                                     |\n+------------------------------------------------+\n| Project                                        |\n|   ->  Table Scan on db1.employees              |\n|         Hit Partition: p0                      |\n|         Filter Cond: (employees.store_id = 10) |\n+------------------------------------------------+\n4 rows in set (0.00 sec)\n

      In this SQL statement, since the partition key for the partitioned table is store_id, the condition store_id = 10 can determine that all results are within a single partition. The value 10 is hashed to partition p0. Therefore, it is only necessary to scan partition p0, without accessing partitions p1, p2, and p3, which do not contain relevant results. As seen in the execution plan, there is only one TableScan operator, specifying Hit Partition as p0, ensuring the effectiveness of partition pruning.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#inapplicable-scenarios-in-hash-partitioned-tables","title":"Inapplicable Scenarios in HASH Partitioned Tables","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#scenario-1_1","title":"Scenario 1","text":"

      Conditions that cannot determine if the query results are within a single partition, such as between, > < >= <=, and similar conditions, cannot benefit from partition pruning optimization.

      CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH(store_id) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM employees WHERE store_id > 15;\n+------------------------------------------------+\n| QUERY PLAN                                     |\n+------------------------------------------------+\n| Project                                        |\n|   ->  Table Scan on db1.employees              |\n|         Hit Partition: all partitions          |\n|         Filter Cond: (employees.store_id > 15) |\n+------------------------------------------------+\n4 rows in set (0.00 sec)\n

      In this SQL statement, the condition store_id > 15 cannot determine the corresponding Hash partition, and therefore, partition pruning optimization cannot be used.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#scenario-2_1","title":"Scenario 2","text":"

      In scenarios where filtering conditions can only be obtained during the execution plan generation phase, partition pruning optimization cannot be utilized.

      mysql> EXPLAIN SELECT * FROM t1 WHERE col1 = (SELECT store_id FROM employees WHERE employees.store_id = t1.col1 AND employees.id = 10010);\n+---------------------------------------------------------+\n| QUERY PLAN                                              |\n+---------------------------------------------------------+\n| Project                                                 |\n|   ->  Filter                                            |\n|         Filter Cond: (t1.col1 = employees.store_id)     |\n|         ->  Join                                        |\n|               Join Type: SINGLE                         |\n|               Join Cond: (t1.col1 = employees.store_id) |\n|               ->  Table Scan on db1.t1                  |\n|                     Hit Partition: all partitions       |\n|               ->  Table Scan on db1.employees           |\n|                     Hit Partition: all partitions       |\n|                     Filter Cond: (employees.id = 10010) |\n+---------------------------------------------------------+\n11 rows in set (0.01 sec)\n

      This query retrieves results from a subquery and constructs an equality filter condition col3 = ? for each row read. However, partition pruning only takes effect during the query plan generation phase, not during execution, making it ineffective in this scenario.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#scenario-3","title":"Scenario 3","text":"

      Using function expressions as partitioning expressions for HASH partitioned tables is not supported for partition pruning.

      CREATE TABLE t3 (\ncol1 INT,\ncol2 CHAR(10),\ncol3 DATETIME\n) PARTITION BY HASH (YEAR(col3)) PARTITIONS 4;\n\nINSERT INTO t3 VALUES\n(10001, 'Georgi', '1999-04-05 11:01:02'),\n(10002, 'Bezalel', '2004-04-03 13:11:10'),\n(10003, 'Parto', '1997-04-05 11:01:02'),\n(10004, 'Chirstian', '2004-04-03 13:11:10'),\n(10005, 'Mary', '1998-04-05 11:01:02'),\n(10006, 'Patricio', '2004-04-03 13:11:10'),\n(10007, 'Eberhardt', '1953-09-02 13:11:10'),\n(10008, 'Kazuhide', '1986-06-26 19:21:10'),\n(10009, 'Tempesti', '1956-11-14 08:11:10'),\n(10010, 'Nooteboom', '1987-03-18 23:11:10');\n\nmysql> EXPLAIN SELECT * FROM t3 WHERE YEAR(col3) = 1999;\n+---------------------------------------------+\n| QUERY PLAN                                  |\n+---------------------------------------------+\n| Project                                     |\n|   ->  Table Scan on db1.t3                  |\n|         Hit Partition: all partitions       |\n|         Filter Cond: (YEAR(t3.col3) = 1999) |\n+---------------------------------------------+\n4 rows in set (0.00 sec)\n\nmysql> SELECT * FROM t3 WHERE YEAR(col3) = 1999;\n+-------+--------+---------------------+\n| col1  | col2   | col3                |\n+-------+--------+---------------------+\n| 10001 | Georgi | 1999-04-05 11:01:02 |\n+-------+--------+---------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#performance-tuning-examples-for-partition-pruning","title":"Performance Tuning Examples for Partition Pruning","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#example-1","title":"Example 1","text":"

      Equality Conditions in KEY Partitioned Table:

      CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\nPRIMARY KEY(col1, col3)\n) PARTITION BY KEY(col1, col3) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col3 = 7369;\n+------------------------------------------------+\n| QUERY PLAN                                     |\n+------------------------------------------------+\n| Project                                        |\n|   ->  Table Scan on db2.t1                     |\n|         Hit Partition: p0                      |\n|         Filter Cond: ((t1.col1 = 1) and (t1.col3 = 7369)) |\n+------------------------------------------------+\n5 rows in set (0.00 sec)\n

      In this query, only partition p0 is accessed after partition pruning because the query conditions match the data in partition p0.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#example-2","title":"Example 2","text":"

      OR Conditions in KEY Partitioned Table:

      mysql> EXPLAIN SELECT * FROM t1 WHERE (col1 = 1 AND col3 = 7369) OR (col1 = 6 AND col3 = 7698);\n+-----------------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                          |\n+-----------------------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000)                                            |\n|   Output: t1.col1, t1.col2, t1.col3                                                                 |\n|   ->  Table Scan on db2.t1 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1)              |\n|         Output: t1.col1, t1.col2, t1.col3                                                           |\n|         Table: 't1' (0:'col1', 1:'col2', 2:'col3')                                                  |\n|         Hit Partition: p0, p2                                                                       |\n|         Filter Cond: (((t1.col1 = 1) and (t1.col3 = 7369)) or ((t1.col1 = 6) and (t1.col3 = 7698))) |\n+-----------------------------------------------------------------------------------------------------+\n7 rows in set (0.00 sec)\n

      This query prunes partitions p0 and p2 because the query conditions match the data in these two partitions.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#example-3","title":"Example 3","text":"

      Equality Condition in HASH Partitioned Table:

      CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n) PARTITION BY HASH(store_id) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10;\n+------------------------------------------------+\n| QUERY PLAN                                     |\n+------------------------------------------------+\n| Project                                        |\n|   ->  Table Scan on db1.employees              |\n|         Hit Partition: p0                      |\n|         Filter Cond: (employees.store_id = 10) |\n+------------------------------------------------+\n4 rows in set (0.00 sec)\n

      In this query, only partition p0 contains data matching the condition store_id = 10, so only partition p0 is scanned.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#example-4","title":"Example 4","text":"

      Multiple Conditions in HASH Partitioned Table:

      mysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10 OR store_id = 15;\n+---------------------------------------------------+\n| QUERY PLAN                                        |\n+---------------------------------------------------+\n| Project                                           |\n|   ->  Table Scan on db1.employees                 |\n|         Hit Partition: p0, p3                     |\n|         Filter Cond: ((employees.store_id = 10) or (employees.store_id = 15)) |\n+---------------------------------------------------+\n5 rows in set (0.00 sec)\n

      This query prunes partitions p0 and p3 because these two partitions contain data matching the condition store_id = 10 OR store_id = 15.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#example-5","title":"Example 5","text":"

      Scenarios Inapplicable for Partition Pruning:

      mysql> EXPLAIN SELECT * FROM t1 WHERE col1 > 5;\n+------------------------------------------------+\n| QUERY PLAN                                     |\n+------------------------------------------------+\n| Project                                        |\n|   ->  Table Scan on db1.t1                     |\n|         Hit Partition: all partitions          |\n|         Filter Cond: (t1.col1 > 5)             |\n|         Block Filter Cond: (t1.col1 > 5)       |\n+------------------------------------------------+\n5 rows in set (0.00 sec)\n

      In this query, the condition col1 > 5 cannot determine the corresponding partition, and therefore, partition pruning cannot be used.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/1.1-through-partition-pruning/#constraints","title":"Constraints","text":"

      MatrixOne supports four partitioning methods: Key, Hash, Range, and List:

      • However, partition pruning is currently supported only for Key and Hash partitioned tables, with pruning for other types planned for future implementation.

      • List partitioning and Range partitioning currently do not accelerate query performance.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/","title":"Scaling CN for better performance","text":"

      MatrixOne is a distributed database; its most distinctive feature is that it can improve the system's overall performance through node expansion. In MatrixOne's storage-computing separation architecture, CN is a stateless computing node, and the rapid expansion of CN nodes is the core of the performance improvement of the entire cluster.

      Generally, we can extend CN in two ways:

      1. Vertically expand CN nodes: improve performance by adjusting the resources of a single CN node. This includes the improvement of the entire CN resource and cache.

      2. Horizontal expansion of CN nodes: Improve performance by increasing the number of CN nodes.

      One of the smallest MatrixOne distributed cluster architectures is shown in the following figure:

      CN mainly performs the user's query request. Therefore, the resource size of the CN node is proportional to the computing power. The most direct expansion method is to expand the resources of a single CN node vertically. At the same time, the queried data is stored in the CN cache as hot data. If the cache is hit, the query can be returned directly from the cache without obtaining cold data from the object store. After the upper capacity limit is exceeded, the cache will only replace the data with the LRU algorithm, so the cache size is also helpful for improving performance.

      In addition, we can also improve performance by horizontally expanding CN nodes. The horizontal expansion has two technical characteristics that can improve performance. First, multiple user connection requests can be dispersed to different CN nodes, spreading the load on each CN. Secondly, other CN nodes also have different caches. When the CN node that receives the query request finds that the request data is not in its cache, it will find the CN node containing the request data cache through the metadata and forward the request to it for processing to improve the cache hit rate.

      The expansion of the MatrixOne distributed cluster components can be done through the Operator. For the operation method, please look at the expansion and contraction chapter of the MatrixOne cluster. Please note that the vertical expansion of the CN node needs to be carried out on a single node, while the horizontal expansion of the CN node needs to be carried out on multiple nodes.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/#how-to-operate","title":"How to operate","text":"

      The expansion of MatrixOne distributed cluster components can be done through the Operator. For more information, see Scaling MatrixOne Cluster.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/","title":"Using Cluster by for performance tuning","text":"

      Cluster by is a commonly used performance-tuning technique that can help optimize the execution efficiency of queries. This article explains how to use Cluster by for performance tuning.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/#what-is-cluster-by","title":"What is Cluster by?","text":"

      Cluster by is a command used to optimize the physical arrangement of a table. When Cluster by is used during table creation, tables without primary keys can be physically sorted according to a specified column. The data rows will be rearranged in the same order as the values of that column. This physical sorting helps improve query performance.

      The following are some considerations when using Cluster by:

      Cluster by cannot coexist with a primary key because the primary key already specifies the sorting order. Otherwise, it will result in a syntax error.

      Cluster by can only be specified during table creation and does not support dynamic creation.

      The syntax for using Cluster by is as follows:

      • Single column syntax: create table() cluster by col;
      • Multi-column syntax: create table() cluster by (col1, col2);
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/#how-to-use-cluster-by-for-performance-tuning","title":"How to use Cluster by for performance tuning?","text":"

      The steps for using Cluster by for performance tuning are as follows:

      1. Determine the column to be sorted.

        First, it is necessary to determine the column to be sorted. Generally, columns that are frequently used for filtering can be selected. For example, if there is an order table, the orders can be sorted by time. The time column is a commonly used sorting column for data with time series characteristics.

      2. Execute the Cluster by command.

        Once the sorting column is determined, the Cluster by command can be executed during table creation to perform the sorting.

        Here is an example:

        create table t1(a int, b int, c varchar(10)) cluster by(a,b,c);\ndesc t1;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type        | Null | Key  | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| a     | INT(32)     | YES  |      | NULL    |       |         |\n| b     | INT(32)     | YES  |      | NULL    |       |         |\n| c     | VARCHAR(10) | YES  |      | NULL    |       |         |\n+-------+-------------+------+------+---------+-------+---------+\n3 rows in set (0.02 sec)\n

        In this example, we first create a table named t1. Then, we use the Cluster by command to physically sort the table according to columns a, b, and c. This way, all data rows will be arranged in the order of values of columns a, b, and c.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/#how-to-make-the-best-use-of-cluster-by-for-performance-tuning","title":"How to Make the Best Use of Cluster by for Performance Tuning?","text":"

      There are two ways to make the best use of Cluster by for performance tuning:

      1. Put the most frequently queried columns at the front.

        In the case of Cluster by with multiple columns, the first column will get the best query acceleration effect because the data distribution of the first column is ultimately ordered. Only when the first column is the same the remaining data will be sorted according to the second column. Therefore, the query acceleration effect of the second column is weaker than that of the first column, and the subsequent columns will decrease. Consequently, it is generally not recommended to specify too many columns in Cluster by; usually, 3-4 columns are sufficient.

      2. Put low cardinality columns at the front.

        Cardinality refers to the number of different values in a column. For example, gender, with only two values, is a typical low cardinality column. For example, ID card numbers are usually not duplicated, which is a high cardinality column. If the tall cardinality column is placed in the first column of Cluster by, the data distribution of the whole table has been thoroughly sorted on the first column, which leads to the subsequent columns not being effective. In this case, it is recommended to use Cluster by for a single column or to build a separate index for the high cardinality column rather than including it in Cluster by.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/#to-consider-when-using-cluster-by","title":"To consider when using Cluster by","text":"
      • Cluster by may take a long time to complete on large tables

      It may take a long time to complete when using Cluster by on a large table. This is because the operation requires reorganizing, reordering, and storing the data in the table. Therefore, when executing the Cluster by command, the table size and hardware configuration need to be considered.

      • Cluster by may affect the performance of insert and update operations

      Using Cluster by to sort data in a table physically may affect the performance of insert and update operations. When specific columns sort the data in a table, insert and update procedures may need to move many rows. Therefore, this impact must be considered when using Cluster by.

      • Cluster by needs to be regularly executed to maintain performance

      As data grows and changes, the physical sorting of data in a table may lose its effectiveness. Therefore, the Cluster by command needs to be regularly executed to ensure that the physical sorting of data remains effective.

      It is important to note that using the Cluster by command needs to be carefully considered. It is recommended first to validate its effects in a testing environment to avoid negative impacts on the data in the table.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/","title":"Performance Tuning with Partitioned Tables","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#what-is-a-partitioned-table","title":"What is a Partitioned Table?","text":"

      A partitioned table organizes data in a database, which involves dividing the table data into multiple partitions. Each partition acts as an independent sub-table.

      In MatrixOne, table data is divided into different storage objects based on the key values of one or more table columns. These key values are referred to as data partitions or ranges.

      A data partition or range is a subset of table rows stored separately from other row sets. The table data is divided into multiple data partitions or ranges based on the specifications provided in the PARTITION BY clause of the CREATE TABLE statement.

      Partitioned tables can bring many benefits, such as faster query speed, optimized data maintenance, and increased availability. Partitioned tables simplify the reading and writing of table data. When SQL is executed on a partitioned table, the system first determines which partition the data belongs to and then reads or writes only that partition, avoiding operations on all the data in the table.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#scenarios-for-partitioned-tables","title":"Scenarios for Partitioned Tables","text":"
      • Improving query performance by scanning only a portion of the table.
      • Improving write performance by inserting, updating, or deleting only a portion of the table data.
      • Batch deleting data within a specific range rather than performing an entire table operation.
      • Fine-tuning and managing data.
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#what-performance-tuning-can-be-done-with-partitioned-tables","title":"What Performance Tuning can be done with Partitioned Tables?","text":"
      • Query performance tuning: Using partitioned tables can make queries more efficient by targeting specific partitions, thus improving query efficiency. For example, if a table is partitioned by date, specific data within a certain date range can be queried without scanning the entire table.
      • Storage Space Usage Performance Tuning: Partitioned tables can better manage table data and reduce unnecessary storage space usage. For example, if a table is partitioned by time, old partitions can be quickly deleted or archived without affecting data in other partitions.
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#impact-of-partitioned-tables-on-performance","title":"Impact of Partitioned Tables on Performance","text":"

      Typically, as data increases within a table, performance gradually decreases. However, if the same data is stored in partitioned tables, data access can be optimized by partitioning data into different storage objects based on different ranges.

      Compared to full table access, the optimized access method will prioritize accessing specific partitions, making it possible for requests for data addition, deletion, and modification to be more effectively distributed to different partitions, avoiding the occurrence of IO hotspots and ultimately achieving better performance improvements.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#how-to-use-partitioned-tables-for-tuning","title":"How to Use Partitioned Tables for Tuning","text":"

      When using partitioned tables, the following prerequisites need to be considered:

      • The table has a large amount of data distributed according to some rules, such as by year or month.
      • Improved query performance is desired by scanning only a portion of the table.
      • Frequent data reads, and writes are limited to a specific range, while other fields have a lower frequency of reads and write.
      • Frequent data reads and writes typically have certain fixed filtering conditions.
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#choosing-the-partition-key","title":"Choosing the Partition Key","text":"

      The partition key is a key factor in physically dividing the table, and choosing the right partition key can significantly improve read and write performance.

      When selecting a partition key, the following factors need to be considered:

      • High cardinality: A partition key with high cardinality will result in better data distribution and scalability. For example, for a table with student gender and age attributes, age has a higher cardinality than gender and is more suitable as the partition key.
      • Uniqueness: The partition key should be as unique as possible to avoid a partition becoming a standalone hotspot. Using a composite key can achieve uniqueness. For example, in a company, if more than half of the employees in different departments are in the same city, partitioning the town as the partition key will result in that department becoming a hotspot. However, using a composite key such as department ID + city ID can significantly reduce the probability of a hot partition.
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#establishing-partitioning-strategy","title":"Establishing Partitioning Strategy","text":"

      Even if a column with high cardinality and uniqueness is selected as the partitioning key, hotspot partitions may still occur if the partitioning range is inappropriate. Therefore, more sophisticated management is required in the partitioning strategy.

      • Data distribution should be as evenly as possible to avoid extreme distribution. For example, if student age is used as the partitioning key, the company's age distribution needs to be evaluated to prevent overly concentrated age ranges in a partition. For instance, a school may have many students aged 18-22 but relatively few under 18 or over 22, so each age can be partitioned.
      • Add a random number to disperse the partition. Combine the partitioning key with a random number sequence in high-concurrency write scenarios. For example, in an order system, the number of orders for a particular item is very high. A random number sequence can be added when designing the table, with a value range of 1-10, and used as the partitioning key with the item type. Each time an order is written, a number from 1 to 10 is randomly generated, and these orders are randomly written to 10 partitions, reducing the likelihood of hotspot partitions.
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#matrixone-partitioned-table-types","title":"MatrixOne Partitioned Table Types","text":"

      In MatrixOne, multiple partitioning modes are supported for tables, each corresponding to a different partitioning method.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#range-partition","title":"Range Partition","text":"

      Range partitioning is a partitioning method based on continuous values. The partitioning key can be an integer type, DATE, or DATETIME in date type. Partitions must not overlap, and the partition definition uses the VALUES LESS THAN operator.

      Example

      The following two tables use an integer column and a date column as partitioning keys, respectively:

      CREATE TABLE members (\nfirstname VARCHAR(25) NOT NULL,\nlastname VARCHAR(25) NOT NULL,\nusername VARCHAR(16) NOT NULL,\nemail VARCHAR(35),\njoined DATE NOT NULL\n)\nPARTITION BY RANGE COLUMNS(joined) (\nPARTITION p0 VALUES LESS THAN ('1960-01-01'),\nPARTITION p1 VALUES LESS THAN ('1970-01-01'),\nPARTITION p2 VALUES LESS THAN ('1980-01-01'),\nPARTITION p3 VALUES LESS THAN ('1990-01-01'),\nPARTITION MySQL :: MySQL 8.0 Reference Manual :: 13.1.20 CREATE TABLE Statement\n)\nPARTITION BY RANGE COLUMNS(joined) (\nPARTITION p0 VALUES LESS THAN ('1960-01-01'),\nPARTITION p1 VALUES LESS THAN ('1970-01-01'),\nPARTITION p2 VALUES LESS THAN ('1980-01-01'),\nPARTITION p3 VALUES LESS THAN ('1990-01-01')\n);\n

      Note that if the value of the partition column in the data being inserted or updated does not correspond to a partition, the corresponding insert or update operation will fail. For example, if you insert a row with a \"joined\" date of 2000-01-01 but no corresponding partition, the process will fail because the partition cannot be located. So, when performing insert or update operations, you must ensure that the value of the partition column belongs to the corresponding partition.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#list-partition","title":"List Partition","text":"

      List partitioning requires each partition to be composed of a defined value list, and each partition member in the list cannot have duplicate values. List partitioning can only use an integer type as the partition key.

      Example

      CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY LIST(store_id) (\nPARTITION pNorth VALUES IN (3,5,6,9,17),\nPARTITION pEast VALUES IN (1,2,10,11,19,20),\nPARTITION pWest VALUES IN (4,12,13,14,18),\nPARTITION pCentral VALUES IN (7,8,15,16)\n);\n

      Please note that if the value of the partitioning column in the data being inserted or updated does not correspond to any partition, the insertion will fail.

      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#hash-partition","title":"Hash Partition","text":"

      Hash partitioning is commonly used to distribute data among different partitions evenly. Common types of hash partitioning include HASH function partitioning and KEY function partitioning.

      In HASH function partitioning, the column or expression used for partitioning must be explicitly specified, and its type must be an integer. It is also recommended to explicitly specify the number of partitions, which must be a positive integer.

      Example

      CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH( YEAR(hired) )\nPARTITIONS 4;\n

      Unlike HASH function partitioning, KEY function partitioning supports all types of partition keys except for large object types (TEXT/BLOB), and it is unnecessary to specify the number of partitions. When using KEY function partitioning, the database service provides its hashing method, so explicitly defining the number of partitions is unnecessary. For example, the following statement can be used to create a table with a partition key of s1:

      CREATE TABLE tm1 (\ns1 CHAR(32) PRIMARY KEY\n)\nPARTITION BY KEY(s1);\n

      It should be noted that if the partition key is the table's primary key column, the system will default to using the primary key column as the partition key if it is not explicitly specified. For example:

      CREATE TABLE tm1 (\ns1 CHAR(32) PRIMARY KEY\n)\nPARTITION BY KEY();\n
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#composite-partition","title":"Composite Partition","text":"

      Composite partitioning is a variant of range partitioning and list partitioning that allows combinations of multiple columns in the partition key. Depending on the type of partition key, composite partitioning can be divided into range and list composite partitioning.

      The types that can be used in composite partitioning include:

      • All integer types, including [UNSIGNED] SMALLINT/INT/BIGINT
      • Data types, including DATE and DATETIME
      • Character types, including CHAR, VARCHAR, BINARY, and VARBINARY.

      Range composite partitioning allows multiple types of columns to be combined, such as:

      CREATE TABLE rcx (\na INT,\nb INT,\nc CHAR(3),\nd date\n)\nPARTITION BY RANGE COLUMNS(a,d,c) (\nPARTITION p0 VALUES LESS THAN (5,'2022-01-01','ggg'),\nPARTITION p1 VALUES LESS THAN (10,'2012-01-01','mmm'),\nPARTITION p2 VALUES LESS THAN (15,'2002-01-01','sss'),\nPARTITION p3 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE)\n);\n

      List composite partitions allow users to define partitions in the same way that multiple columns can be combined, such as:

      CREATE TABLE t1 (\na INT,\nb int,\nc date\n)\nPARTITION BY LIST COLUMNS(a,floor(b),c) (\nPARTITION p0 VALUES IN( (0,0,NULL), (NULL,NULL,NULL) ),\nPARTITION p1 VALUES IN( (0,1,'2000-01-01'), (0,2,'2000-01-01'), (0,3,'2000-01-01'), (1,1,'2000-01-01'), (1,2,'2000-01-01') ),\nPARTITION p2 VALUES IN( (1,0,'2000-01-01'), (2,0,'2000-01-01'), (2,1,'2000-01-01'), (3,0,'2000-01-01'), (3,1,'2000-01-01') ),\nPARTITION p3 VALUES IN( (1,3,'2000-01-01'), (2,2,'2000-01-01'), (2,3,'2000-01-01'), (3,2,'2000-01-01'), (3,3,'2000-01-01') )\n);\n
      "},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition-by/#constraints","title":"Constraints","text":"
      1. The partition table does not support the following partitions for the time being:

        • Range partition: Only supports integer and date (date/datetime).
        • List partition: Only supports integers.
        • Hash partition: The HASH function only supports integers .
        • Composite partition: Only supports integers, dates, and strings.
      2. The partition table cannot be used for acceleration for now.

      "},{"location":"MatrixOne/Reference/1.1-System-tables/","title":"MatrixOne System Database and Tables","text":"

      MatrixOne system database and tables are where MatrixOne stores system information. We can access the system information through them. MatrixOne creates 6 system databases at initialization: mo_catalog, information_schema, system_metrcis, system, mysql, and mo_task. mo_task is under development and have no direct impact on users. The other system databases and table functions are described in this document.

      The system can only modify system databases and tables, and users can only read from them.

      "},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_catalog-database","title":"mo_catalog database","text":"

      mo_catalog stores the metadata of MatrixOne objects: databases, tables, columns, system variables, accounts, users, and roles.

      Start with MatrixOne 0.6 has introduced the concept of multi-account, the default sys account and other accounts have slightly different behaviors. The system table mo_account, which serves the multi-tenancy management, is only visible for the sys account; the other accounts don't see this table.

      "},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_database-table","title":"mo_database table","text":"Column Type comments dat_id bigint unsigned Primary key ID datname varchar(100) Database name dat_catalog_name varchar(100) Database catalog name, default as def dat_createsql varchar(100) Database creation SQL statement owner int unsigned Role id creator int unsigned User id created_time timestamp Create time account_id int unsigned Account id dat_type varchar(23) Database type, common library or subscription library"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_tables-table","title":"mo_tables table","text":"Column Type comments rel_id bigint unsigned Primary key, table ID relname varchar(100) Name of the table, index, view, and so on. reldatabase varchar(100) The database that contains this relation. reference mo_database.datname reldatabase_id bigint unsigned The database id that contains this relation. reference mo_database.datid relpersistence varchar(100) p = permanent table, t = temporary table relkind varchar(100) r = ordinary table, e = external table, i = index, S = sequence, v = view, m = materialized view rel_comment varchar(100) rel_createsql varchar(100) Table creation SQL statement created_time timestamp Create time creator int unsigned Creator ID owner int unsigned Creator's default role id account_id int unsigned Account id partitioned blob Partition by statement partition_info blob the information of partition viewdef blob View definition statement constraint varchar(5000) Table related constraints rel_version INT UNSIGNED(0) Version number of Primary key or table catalog_version INT UNSIGNED(0) Version number of the system table"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_columns-table","title":"mo_columns table","text":"Column type comments att_uniq_name varchar(256) Primary Key. Hidden, composite primary key, format is like \"${att_relname_id}-${attname}\" account_id int unsigned accountID att_database_id bigint unsigned databaseID att_database varchar(256) database Name att_relname_id bigint unsigned table id att_relname varchar(256) The table this column belongs to.(references mo_tables.relname) attname varchar(256) The column name atttyp varchar(256) The data type of this column (zero for a dropped column). attnum int The number of the column. Ordinary columns are numbered from 1 up. att_length int bytes count for the type. attnotnull tinyint(1) This represents a not-null constraint. atthasdef tinyint(1) This column has a default expression or generation expression. att_default varchar(1024) default expression attisdropped tinyint(1) This column has been dropped and is no longer valid. A dropped column is still physically present in the table, but is ignored by the parser and so cannot be accessed via SQL. att_constraint_type char(1) p = primary key constraint, n=no constraint att_is_unsigned tinyint(1) unsigned or not att_is_auto_increment tinyint(1) auto increment or not att_comment varchar(1024) comment att_is_hidden tinyint(1) hidden or not attr_has_update tinyint(1) This columns has update expression attr_update varchar(1024) update expression attr_is_clusterby tinyint(1) Whether this column is used as the cluster by keyword to create the table"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_table_partitions-table","title":"mo_table_partitions table","text":"Column Type comments table_id BIGINT UNSIGNED(64) The ID of the current partitioned table. database_id BIGINT UNSIGNED(64) The ID of the database to which the current partitioned table belongs. number SMALLINT UNSIGNED(16) The current partition number. All partitions are indexed in the order they are defined, with 1 assigned to the first partition. name VARCHAR(64) The name of the partition. partition_type VARCHAR(50) Stores the partition type information for the table. For partitioned tables, the values can be \"KEY\", \"LINEAR_KEY\", \"HASH\", \"LINEAR_KEY_51\", \"RANGE\", \"RANGE_COLUMNS\", \"LIST\", \"LIST_COLUMNS\". For non-partitioned tables, the value is an empty string. Note: MatrixOne does not currently support RANGE and LIST partitioning. partition_expression VARCHAR(2048) The expression for the partitioning function used in the CREATE TABLE or ALTER TABLE statement that created the partitioned table's partitioning scheme. description_utf8 TEXT(0) This column is used for RANGE and LIST partitions. For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be an integer or MAXVALUE. For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a comma-separated list of integer values. For partitions with partition_type other than RANGE or LIST, this column is always NULL. Note: MatrixOne does not currently support RANGE and LIST partitioning, so this column is NULL. comment VARCHAR(2048) The text of the comment, if the partition has one. Otherwise, this value is empty. options TEXT(0) Partition options information, currently set to NULL. partition_table_name VARCHAR(1024) The name of the subtable corresponding to the current partition."},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_account-table-only-visible-for-sys-account","title":"mo_account table (Only visible for sys account)","text":"Column Type comments account_id int unsigned account id, primary key account_name varchar(100) account name status varchar(100) open/suspend created_time timestamp create time comments varchar(256) comment suspended_time TIMESTAMP Time of the account's status is changed version bigint unsigned the version status of the current account"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_role-table","title":"mo_role table","text":"Column Type comments role_id int unsigned role id, primary key role_name varchar(100) role name creator int unsigned user_id owner int unsigned MOADMIN/ACCOUNTADMIN ownerid created_time timestamp create time comments text comment"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_user-table","title":"mo_user table","text":"Column Type comments user_id int user id, primary key user_host varchar(100) user host address user_name varchar(100) user name authentication_string varchar(100) authentication string encrypted with password status varchar(8) open,locked,expired created_time timestamp user created time expired_time timestamp user expired time login_type varchar(16) ssl/password/other creator int the creator id who created this user owner int the admin id for this user default_role int the default role id for this user"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_user_grant-table","title":"mo_user_grant table","text":"Column Type comments role_id int unsigned ID of the authorized role, associated primary key user_id int unsigned Obtain the user ID of the authorized role and associate the primary key granted_time timestamp granted time with_grant_option bool Whether to allow an authorized user to license to another user or role"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_role_grant-table","title":"mo_role_grant table","text":"Column Type comments granted_id int the role id being granted, associated primary key grantee_id int the role id to grant others, associated primary key operation_role_id int operation role id operation_user_id int operation user id granted_time timestamp granted time with_grant_option bool Whether to allow an authorized role to be authorized to another user or role"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_role_privs-table","title":"mo_role_privs table","text":"Column Type comments role_id int role id, associated primary key role_name varchar(100) role name: accountadmin/public obj_type varchar(16) object type: account/database/table, associated primary key obj_id bigint unsigned object id, associated primary key privilege_id int privilege id, associated primary key privilege_name varchar(100) privilege name: the list of privileges privilege_level varchar(100) level of privileges, associated primary key operation_user_id int unsigned operation user id granted_time timestamp granted time with_grant_option bool If permission granting is permitted"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_stages-table","title":"mo_stages table","text":"Column Type comments stage_id INT UNSIGNED(32) data stage ID stage_name VARCHAR(64) data stage name url TEXT(0) Path to object storage (without authentication), path to file system stage_credentials TEXT(0) Authentication information, encrypted and saved stage_status VARCHAR(64) ENABLED/DISABLED Default: DISABLED created_time TIMESTAMP(0) creation time comment TEXT(0) comment"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_user_defined_function-table","title":"mo_user_defined_function table","text":"Column Type comments function_id INT(32) ID of the function, primary key name VARCHAR(100) the name of the function owner INT UNSIGNED(32) ID of the role who created the function args TEXT(0) Argument list for the function rettype VARCHAR(20) return type of the function body TEXT(0) function body language VARCHAR(20) language used by the function db VARCHAR(100) database where the function is located definer VARCHAR(50) name of the user who defined the function modified_time TIMESTAMP(0) time when the function was last modified created_time TIMESTAMP(0) creation time of the function type VARCHAR(10) type of function, default FUNCTION security_type VARCHAR(10) security processing method, uniform value DEFINER comment VARCHAR(5000) Create a comment for the function character_set_client VARCHAR(64) Client character set: utf8mb4 collation_connection VARCHAR(64) Connection sort: utf8mb4_0900_ai_ci database_collation VARCHAR(64) Database connection collation: utf8mb4_0900_ai_ci"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_mysql_compatbility_mode-table","title":"mo_mysql_compatbility_mode table","text":"Column Type comments configuration_id INT(32) Configuration item id, an auto-increment column, used as a primary key to distinguish different configurations account_name VARCHAR(300) The name of the tenant where the configuration is located dat_name VARCHAR(5000) The name of the database where the configuration is located configuration JSON(0) Configuration content, saved in JSON format"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_pubs-table","title":"mo_pubs table","text":"Column Type comments pub_name VARCHAR(64) publication name database_name VARCHAR(5000) The name of the published data database_id BIGINT UNSIGNED(64) ID of the publishing database, corresponding to dat_id in the mo_database table all_table BOOL(0) Whether the publishing library contains all tables in the database corresponding to database_id all_account BOOL(0) Whether all accounts can subscribe to the library table_list TEXT(0) When it is not all table, publish the list of tables contained in the library, and the table name corresponds to the table under the database corresponding to database_id account_list TEXT(0) Account list that is allowed to subscribe to the publishing library when it is not all accounts created_time TIMESTAMP(0) Time when the release repository was created owner INT UNSIGNED(32) The role ID corresponding to the creation of the release library creator INT UNSIGNED(32) The ID of the user who created the release library comment TEXT(0) Remarks for creating a release library"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_indexes-table","title":"mo_indexes table","text":"Column Type comments id BIGINT UNSIGNED(64) index ID table_id BIGINT UNSIGNED(64) ID of the table where the index resides database_id BIGINT UNSIGNED(64) ID of the database where the index resides name VARCHAR(64) name of the index type VARCHAR(11) The type of index, including primary key index (PRIMARY), unique index (UNIQUE), secondary index (MULTIPLE) is_visible TINYINT(8) Whether the index is visible, 1 means visible, 0 means invisible (currently all MatrixOne indexes are visible indexes) hidden TINYINT(8) Whether the index is hidden, 1 is a hidden index, 0 is a non-hidden index comment VARCHAR(2048) Comment information for the index column_name VARCHAR(256) The column name of the constituent columns of the index ordinal_position INT UNSIGNED(32) Column ordinal in index, starting from 1 options TEXT(0) options option information for index index_table_name VARCHAR(5000) The table name of the index table corresponding to the index, currently only the unique index contains the index table"},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_sessions-view","title":"mo_sessions view","text":"Column Type comments node_id VARCHAR(65535) Unique identifier for MatrixOne nodes. Once started, it cannot be changed. conn_id INT UNSIGNED Unique identifier associated with client's TCP connections in MatrixOne, generated by Hakeeper. session_id VARCHAR(65535) Unique UUID used to identify sessions. A new UUID is generated for each new session. account VARCHAR(65535) Name of the tenant. user VARCHAR(65535) Name of the user. host VARCHAR(65535) IP address and port where the CN node receives client requests. db VARCHAR(65535) Name of the database used when executing SQL. session_start VARCHAR(65535) Timestamp when the session was created. command VARCHAR(65535) Type of MySQL command, such as COM_QUERY, COM_STMT_PREPARE, COM_STMT_EXECUTE, etc. info VARCHAR(65535) The executed SQL statement. Multiple statements may be present within a single SQL statement. txn_id VARCHAR(65535) Unique identifier for the related transaction. statement_id VARCHAR(65535) Unique identifier (UUID) for a statement within the SQL. statement_type VARCHAR(65535) Type of a statement within the SQL, such as SELECT, INSERT, UPDATE, etc. query_type VARCHAR(65535) Category of a statement within the SQL, such as DQL (Data Query Language), TCL (Transaction Control Language), etc. sql_source_type VARCHAR(65535) Source of a statement within the SQL, such as external or internal. query_start VARCHAR(65535) Timestamp when a statement within the SQL started execution. client_host VARCHAR(65535) IP address and port of the client. role VARCHAR(65535) Role name of the user."},{"location":"MatrixOne/Reference/1.1-System-tables/#mo_locks-view","title":"mo_locks view","text":"Column Type comments txn_id VARCHAR(65535) Transaction holding the lock. table_id VARCHAR(65535) The table on which the lock is placed. lock_type VARCHAR(65535) Type of lock, which can be point or range. lock_content VARCHAR(65535) Locked content, represented in hexadecimal. For range locks, it represents a range; for point locks, it represents a single value. lock_mode VARCHAR(65535) Lock mode, which can be shared or exclusive. lock_status VARCHAR(65535) Lock status can be wait, acquired, or none.wait: No transaction holds the lock, but transactions are waiting for it.acquired: A transaction holds the lock.none: No transaction holds the lock, and no transactions await it. waiting_txns VARCHAR(65535) Transactions waiting on this lock."},{"location":"MatrixOne/Reference/1.1-System-tables/#system_metrics-database","title":"system_metrics database","text":"

      system_metrics collect the status and statistics of SQL statements, CPU & memory resource usage.

      system_metrics tables have more or less same column types, fields in these tables are described as follows:

      • collecttime:Collection time
      • value: the value of the collecting metric

      • node: the MatrixOne node uuid

      • role: the MatrixOne node role, can be CN, TN or LOG.
      • account: default as \"sys\", the account who fires the SQL request.
      • type:SQL type, can be select, insert, update, delete, other types.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#metric-table","title":"metric table","text":"Column Type Comment metric_name VARCHAR(128) metric name, like: sql_statement_total, server_connections, process_cpu_percent, sys_memory_used, .. collecttime DATETIME metric data collect time value DOUBLE metric value node VARCHAR(36) MatrixOne node uuid role VARCHAR(32) MatrixOne node role account VARCHAR(128) account name, default \"sys\" Type VARCHAR(32) SQL type: like insert, select, update ...

      The other tables are all views of the metric table:

      • process_cpu_percent table: Process CPU busy percentage.
      • process_open_fs table: Number of open file descriptors.
      • process_resident_memory_bytes table: Resident memory size in bytes.
      • server_connection table: Server connection numbers.
      • sql_statement_errors table: Counter of sql statements executed with errors.
      • sql_statement_total table: Counter of executed sql statement.
      • sql_transaction_errors table: Counter of transactional statements executed with errors.
      • sql_statement_hotspot table: records the most extended SQL query executed by each tenant within each minute. Only those SQL queries whose execution time does not exceed a certain aggregation threshold will be included in the statistics.
      • sql_transaction_total table: Counter of transactional sql statement.
      • sys_cpu_combined_percent table: System CPU busy percentage, average among all logical cores.
      • sys_cpu_seconds_total table: System CPU time spent in seconds, normalized by number of cores
      • sys_disk_read_bytes table: System disk read in bytes.
      • sys_disk_write_bytes table: System disk write in bytes.
      • sys_memory_available table: System memory available in bytes.
      • sys_memory_used table: System memory used in bytes.
      • sys_net_recv_bytes table: System net received in bytes.
      • sys_net_sent_bytes table: System net sent in bytes.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#system-database","title":"system database","text":"

      System database stores MatrixOne historical SQL statements, system logs, error information.

      "},{"location":"MatrixOne/Reference/1.1-System-tables/#statement_info-table","title":"statement_info table","text":"

      It records user and system SQL statement with detailed information.

      Column Type Comments statement_id VARCHAR(36) statement unique id transaction_id VARCHAR(36) Transaction unique id session_id VARCHAR(36) session unique id account VARCHAR(1024) account name user VARCHAR(1024) user name host VARCHAR(1024) user client ip database VARCHAR(1024) what database current session stay in statement TEXT sql statement statement_tag TEXT note tag in statement(Reserved) statement_fingerprint TEXT note tag in statement(Reserved) node_uuid VARCHAR(36) node uuid, which node gen this data node_type VARCHAR(64) node type in MO, val in [TN, CN, LOG] request_at DATETIME request accept datetime response_at DATETIME response send datetime duration BIGINT exec time, unit: ns status VARCHAR(32) sql statement running status, enum: Running, Success, Failed err_code VARCHAR(1024) error code error TEXT error message exec_plan JSON statement execution plan rows_read BIGINT rows read total bytes_scan BIGINT bytes scan total stats JSON global stats info in exec_plan statement_type VARCHAR(1024) statement type, val in [Insert, Delete, Update, Drop Table, Drop User, ...] query_type VARCHAR(1024) query type, val in [DQL, DDL, DML, DCL, TCL] role_id BIGINT role id sql_source_type TEXT Type of SQL source internally generated by MatrixOne aggr_count BIGINT(64) the number of statements aggregated result_count BIGINT(64) the number of rows of sql execution results"},{"location":"MatrixOne/Reference/1.1-System-tables/#rawlog-table","title":"rawlog table","text":"

      It records very detailed system logs.

      Column Type Comments raw_item VARCHAR(1024) raw log item node_uuid VARCHAR(36) node uuid, which node gen this data. node_type VARCHAR(64) node type in MO, val in [TN, CN, LOG] span_id VARCHAR(16) span unique id statement_id VARCHAR(36) statement unique id logger_name VARCHAR(1024) logger name timestamp DATETIME timestamp of action level VARCHAR(1024) log level, enum: debug, info, warn, error, panic, fatal caller VARCHAR(1024) where it log, like: package/file.go:123 message TEXT log message extra JSON log dynamic fields err_code VARCHAR(1024) error log error TEXT error message stack VARCHAR(4096) span_name VARCHAR(1024) span name, for example: step name of execution plan, function name in code, ... parent_span_id VARCHAR(16) parent span unique id start_time DATETIME end_time DATETIME duration BIGINT exec time, unit: ns resource JSON static resource information

      The other 3 tables(log_info, span_info and error_info) are views of statement_info and rawlog table.

      "},{"location":"MatrixOne/Reference/1.1-System-tables/#information_schema-database","title":"information_schema database","text":"

      Information Schema provides an ANSI-standard way of viewing system metadata. MatrixOne also provides a number of custom information_schema tables, in addition to the tables included for MySQL compatibility.

      Many INFORMATION_SCHEMA tables have a corresponding SHOW command. The benefit of querying INFORMATION_SCHEMA is that it is possible to join between tables.

      "},{"location":"MatrixOne/Reference/1.1-System-tables/#tables-for-mysql-compatibility","title":"Tables for MySQL compatibility","text":"Table Name Description KEY_COLUMN_USAGE Describes the key constraints of the columns, such as the primary key constraint. COLUMNS Provides a list of columns for all tables. PROFILING Provides some profiling information during SQL statement execution. PROCESSLIST Provides similar information to the command SHOW PROCESSLIST. USER_PRIVILEGES Summarizes the privileges associated with the current user. SCHEMATA Provides similar information to SHOW DATABASES. CHARACTER_SETS Provides a list of character sets the server supports. TRIGGERS Provides similar information to SHOW TRIGGERS. TABLES Provides a list of tables that the current user has visibility of. Similar to SHOW TABLES. PARTITIONS Provides information about table partitions. VIEWS Provides information about views in the database. ENGINES Provides a list of supported storage engines. ROUTINES Provides some information about stored procedures. PARAMETERS Provides information about stored procedures' parameters and return values \u200b\u200b. KEYWORDS Provide information about keywords in the database; see Keywords for details."},{"location":"MatrixOne/Reference/1.1-System-tables/#character_sets-table","title":"CHARACTER_SETS table","text":"

      The description of columns in the CHARACTER_SETS table is as follows:

      • CHARACTER_SET_NAME: The name of the character set.
      • DEFAULT_COLLATE_NAME The default collation name of the character set.
      • DESCRIPTION The description of the character set.
      • MAXLEN The maximum length required to store a character in this character set.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#columns-table","title":"COLUMNS table","text":"

      The description of columns in the COLUMNS table is as follows:

      • TABLE_CATALOG: The name of the catalog to which the table with the column belongs. The value is always def.
      • TABLE_SCHEMA: The name of the schema in which the table with the column is located.
      • TABLE_NAME: The name of the table with the column.
      • COLUMN_NAME: The name of the column.
      • ORDINAL_POSITION: The position of the column in the table.
      • COLUMN_DEFAULT: The default value of the column. If the explicit default value is NULL, or if the column definition does not include the default clause, this value is NULL.
      • IS_NULLABLE: Whether the column is nullable. If the column can store null values, this value is YES; otherwise, it is NO.
      • DATA_TYPE: The type of data in the column.
      • CHARACTER_MAXIMUM_LENGTH: For string columns, the maximum length in characters.
      • CHARACTER_OCTET_LENGTH: For string columns, the maximum length in bytes.
      • NUMERIC_PRECISION: The numeric precision of a number-type column.
      • NUMERIC_SCALE: The numeric scale of a number-type column.
      • DATETIME_PRECISION: For time-type columns, the fractional seconds precision.
      • CHARACTER_SET_NAME: The name of the character set of a string column.
      • COLLATION_NAME: The name of the collation of a string column.
      • COLUMN_TYPE: The column type.
      • COLUMN_KEY: Whether this column is indexed. This field might have the following values:
        • Empty: This column is not indexed, or this column is indexed and is the second column in a multi-column non-unique index.
        • PRI: This column is the primary key or one of multiple primary keys.
        • UNI: This column is the first column of the unique index.
        • MUL: The column is the first column of a non-unique index, in which a given value is allowed to occur for multiple times.
      • EXTRA: Any additional information of the given column.
      • PRIVILEGES: The privilege that the current user has on this column.
      • COLUMN_COMMENT: Comments contained in the column definition.
      • GENERATION_EXPRESSION: For generated columns, this value displays the expression used to calculate the column value. For non-generated columns, the value is empty.
      • SRS_ID: This value applies to spatial columns. It contains the column SRID value that indicates the spatial reference system for values stored in the column.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#engines-table","title":"ENGINES table","text":"

      The description of columns in the ENGINES table is as follows:

      • ENGINES: The name of the storage engine.
      • SUPPORT: The level of support that the server has on the storage engine.
      • COMMENT: The brief comment on the storage engine.
      • TRANSACTIONS: Whether the storage engine supports transactions.
      • XA: Whether the storage engine supports XA transactions.
      • SAVEPOINTS: Whether the storage engine supports savepoints.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#partitions-table","title":"PARTITIONS table","text":"

      The description of columns in the PARTITIONS table is as follows:

      • TABLE_CATALOG: The name of the catalog to which the table belongs. This value is always def.
      • TABLE_SCHEMA: The name of the schema (database) to which the table belongs.
      • TABLE_NAME: The name of the table containing the partition.
      • PARTITION_NAME: The name of the partition.
      • SUBPARTITION_NAME: If the PARTITIONS table row represents a subpartition, the name of subpartition; otherwise NULL.
      • PARTITION_ORDINAL_POSITION: All partitions are indexed in the same order as they are defined, with 1 being the number assigned to the first partition. The indexing can change as partitions are added, dropped, and reorganized; the number shown is this column reflects the current order, taking into account any indexing changes.
      • SUBPARTITION_ORDINAL_POSITION: Subpartitions within a given partition are also indexed and reindexed in the same manner as partitions are indexed within a table.
      • PARTITION_METHOD: One of the values RANGE, LIST, HASH, LINEAR HASH, KEY, or LINEAR KEY. Note: MatrixOne does not currently support RANGE and LIST partitioning.
      • SUBPARTITION_METHOD: One of the values HASH, LINEAR HASH, KEY, or LINEAR KEY.
      • PARTITION_EXPRESSION: The expression for the partitioning function used in the CREATE TABLE or ALTER TABLE statement that created the table's current partitioning scheme.
      • SUBPARTITION_EXPRESSION: This works in the same fashion for the subpartitioning expression that defines the subpartitioning for a table as PARTITION_EXPRESSION does for the partitioning expression used to define a table's partitioning. If the table has no subpartitions, this column is NULL.
      • PARTITION_DESCRIPTION: This column is used for RANGE and LIST partitions. For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be either an integer or MAXVALUE. For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a list of comma-separated integer values. For partitions whose PARTITION_METHOD is other than RANGE or LIST, this column is always NULL. Note: MatrixOne does not currently support RANGE and LIST partitioning.
      • TABLE_ROWS: The number of table rows in the partition.
      • AVG_ROW_LENGTH: The average length of the rows stored in this partition or subpartition, in bytes. This is the same as DATA_LENGTH divided by TABLE_ROWS.
      • DATA_LENGTH: The total length of all rows stored in this partition or subpartition, in bytes; that is, the total number of bytes stored in the partition or subpartition.
      • INDEX_LENGTH: The length of the index file for this partition or subpartition, in bytes.
      • DATA_FREE: The number of bytes allocated to the partition or subpartition but not used.
      • CREATE_TIME: The time that the partition or subpartition was created.
      • UPDATE_TIME: The time that the partition or subpartition was last modified.
      • CHECK_TIME: The last time that the table to which this partition or subpartition belongs was checked.
      • CHECKSUM: The checksum value, if any; otherwise NULL.
      • PARTITION_COMMENT: The text of the comment, if the partition has one. If not, this value is empty. The maximum length for a partition comment is defined as 1024 characters, and the display width of the PARTITION_COMMENT column is also 1024, characters to match this limit.
      • NODEGROUP: This is the nodegroup to which the partition belongs.
      • TABLESPACE_NAME: The name of the tablespace to which the partition belongs. The value is always DEFAULT.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#processlist-table","title":"PROCESSLIST table","text":"

      Fields in the PROCESSLIST table are described as follows:

      • ID: The ID of the user connection.
      • USER: The name of the user who is executing PROCESS.
      • HOST: The address that the user is connecting to.
      • DB: The name of the currently connected default database.
      • COMMAND: The command type that PROCESS is executing.
      • TIME: The current execution duration of PROCESS, in seconds.
      • STATE: The current connection state.
      • INFO: The requested statement that is being processed.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#schemata-table","title":"SCHEMATA table","text":"

      The SCHEMATA table provides information about databases. The table data is equivalent to the result of the SHOW DATABASES statement. Fields in the SCHEMATA table are described as follows:

      • CATALOG_NAME: The catalog to which the database belongs.
      • SCHEMA_NAME: The database name.
      • DEFAULT_CHARACTER_SET_NAME: The default character set of the database.
      • DEFAULT_COLLATION_NAME: The default collation of the database.
      • SQL_PATH: The value of this item is always NULL.
      • DEFAULT_TABLE_ENCRYPTION: defines the default encryption setting for databases and general tablespaces.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#tables-table","title":"TABLES table","text":"

      The description of columns in the TABLES table is as follows:

      • TABLE_CATALOG: The name of the catalog which the table belongs to. The value is always def.
      • TABLE_SCHEMA: The name of the schema which the table belongs to.
      • TABLE_NAME: The name of the table.
      • TABLE_TYPE: The type of the table. The base table type is BASE TABLE, the view table type is VIEW, and the INFORMATION_SCHEMA table type is SYSTEM VIEW.
      • ENGINE: The type of the storage engine.
      • VERSION: Version. The value is 10 by default.
      • ROW_FORMAT: The row format. The value is Compact, Fixed, Dynamic, Compressed, Redundant.
      • TABLE_ROWS: The number of rows in the table in statistics. For INFORMATION_SCHEMA tables, TABLE_ROWS is NULL.
      • AVG_ROW_LENGTH: The average row length of the table. AVG_ROW_LENGTH = DATA_LENGTH / TABLE_ROWS.
      • DATA_LENGTH: Data length. DATA_LENGTH = TABLE_ROWS * the sum of storage lengths of the columns in the tuple.
      • MAX_DATA_LENGTH: The maximum data length. The value is currently 0, which means the data length has no upper limit.
      • INDEX_LENGTH: The index length. INDEX_LENGTH = TABLE_ROWS * the sum of lengths of the columns in the index tuple.
      • DATA_FREE: Data fragment. The value is currently 0.
      • AUTO_INCREMENT: The current step of the auto- increment primary key.
      • CREATE_TIME: The time at which the table is created.
      • UPDATE_TIME: The time at which the table is updated.
      • CHECK_TIME: The time at which the table is checked.
      • TABLE_COLLATION: The collation of strings in the table.
      • CHECKSUM: Checksum.
      • CREATE_OPTIONS: Creates options.
      • TABLE_COMMENT: The comments and notes of the table.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#user_privileges-table","title":"USER_PRIVILEGES table","text":"

      The USER_PRIVILEGES table provides information about global privileges.

      Fields in the USER_PRIVILEGES table are described as follows:

      • GRANTEE: The name of the granted user, which is in the format of 'user_name'@'host_name'.
      • TABLE_CATALOG: The name of the catalog to which the table belongs. This value is always def.
      • PRIVILEGE_TYPE: The privilege type to be granted. Only one privilege type is shown in each row.
      • IS_GRANTABLE: If you have the GRANT OPTION privilege, the value is YES; otherwise, the value is NO.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#view-table","title":"VIEW table","text":"
      • TABLE_CATALOG: The name of the catalog the view belongs to. The value is def.
      • TABLE_SCHEMA: The name of the database to which the view belongs.
      • TABLE_NAME: The name of the view.
      • VIEW_DEFINITION: The SELECT statement that provides the view definition. It contains most of what you see in the \"Create Table\" column generated by SHOW Create VIEW.
      • CHECK_OPTION: The value of the CHECK_OPTION property. Values are NONE, CASCADE, or LOCAL.
      • IS_UPDATABLE: Set a flag called the view updatable flag when CREATE VIEW; if UPDATE and DELETE (and similar operations) are legal for the view, the flag is set to YES(true). Otherwise, the flag is set to NO(false).
      • DEFINER: The account of the user who created the view, in the format username@hostname.
      • SECURITY_TYPE: View the SQL SECURITY attribute. Values \u200b\u200bare DEFINER or INVOKER.
      • CHARACTER_SET_CLIENT: The session value of the character_set_client system variable when the view was created.
      • COLLATION_CONNECTION: The session value of the collation_connection system variable when the view was created.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#statistics-table","title":"STATISTICS Table","text":"

      Obtain detailed information about database table indexes and statistics. For example, you can check whether an index is unique, understand the order of columns within an index, and estimate the number of unique values in an index.

      • TABLE_CATALOG: The catalog name of the table (always 'def').
      • TABLE_SCHEMA: The name of the database to which the table belongs.
      • TABLE_NAME: The name of the table.
      • NON_UNIQUE: Indicates whether the index allows duplicate values. If 0, the index is unique.
      • INDEX_SCHEMA: The database name to which the index belongs.
      • INDEX_NAME: The name of the index.
      • SEQ_IN_INDEX: The position of the column within the index.
      • COLUMN_NAME: The name of the column.
      • COLLATION: The collation of the column.
      • CARDINALITY: An estimated count of unique values in the index.
      • SUB_PART: The length of the index part. For the entire column, this value is NULL.
      • PACKED: Indicates whether compressed storage is used.
      • NULLABLE: Indicates whether the column allows NULL values.
      • INDEX_TYPE: The index type (e.g., BTREE, HASH, etc.).
      • COMMENT: Comment information about the index.
      "},{"location":"MatrixOne/Reference/1.1-System-tables/#mysql-database","title":"mysql database","text":""},{"location":"MatrixOne/Reference/1.1-System-tables/#grant-system-tables","title":"Grant system tables","text":"

      These system tables contain grant information about user accounts and their privileges:

      • user: user accounts, global privileges, and other non-privilege columns.
      • db: database-level privileges.
      • tables_priv: table-level privileges.
      • columns_priv: column-level privileges.
      • procs_priv: stored procedure and stored function privileges.
      "},{"location":"MatrixOne/Reference/System-tables/","title":"MatrixOne System Database and Tables","text":"

      MatrixOne system database and tables are where MatrixOne stores system information. We can access the system information through them. MatrixOne creates 6 system databases at initialization: mo_catalog, information_schema, system_metrcis, system, mysql, and mo_task. mo_task is under development and have no direct impact on users. The other system databases and table functions are described in this document.

      The system can only modify system databases and tables, and users can only read from them.

      "},{"location":"MatrixOne/Reference/System-tables/#mo_catalog-database","title":"mo_catalog database","text":"

      mo_catalog stores the metadata of MatrixOne objects: databases, tables, columns, system variables, accounts, users, and roles.

      Start with MatrixOne 0.6 has introduced the concept of multi-account, the default sys account and other accounts have slightly different behaviors. The system table mo_account, which serves the multi-tenancy management, is only visible for the sys account; the other accounts don't see this table.

      "},{"location":"MatrixOne/Reference/System-tables/#mo_database-table","title":"mo_database table","text":"column type comments dat_id bigint unsigned Primary key ID datname varchar(100) Database name dat_catalog_name varchar(100) Database catalog name, default as def dat_createsql varchar(100) Database creation SQL statement owner int unsigned Role id creator int unsigned User id created_time timestamp Create time account_id int unsigned Account id dat_type varchar(23) Database type, common library or subscription library"},{"location":"MatrixOne/Reference/System-tables/#mo_tables-table","title":"mo_tables table","text":"column type comments rel_id bigint unsigned Primary key, table ID relname varchar(100) Name of the table, index, view, and so on. reldatabase varchar(100) The database that contains this relation. reference mo_database.datname reldatabase_id bigint unsigned The database id that contains this relation. reference mo_database.datid relpersistence varchar(100) p = permanent table, t = temporary table relkind varchar(100) r = ordinary table, e = external table, i = index, S = sequence, v = view, m = materialized view rel_comment varchar(100) rel_createsql varchar(100) Table creation SQL statement created_time timestamp Create time creator int unsigned Creator ID owner int unsigned Creator's default role id account_id int unsigned Account id partitioned blob Partition by statement partition_info blob the information of partition viewdef blob View definition statement constraint varchar(5000) Table related constraints catalog_version INT UNSIGNED(0) Version number of the system table"},{"location":"MatrixOne/Reference/System-tables/#mo_columns-table","title":"mo_columns table","text":"column type comments att_uniq_name varchar(256) Primary Key. Hidden, composite primary key, format is like \"${att_relname_id}-${attname}\" account_id int unsigned accountID att_database_id bigint unsigned databaseID att_database varchar(256) database Name att_relname_id bigint unsigned table id att_relname varchar(256) The table this column belongs to.(references mo_tables.relname) attname varchar(256) The column name atttyp varchar(256) The data type of this column (zero for a dropped column). attnum int The number of the column. Ordinary columns are numbered from 1 up. att_length int bytes count for the type. attnotnull tinyint(1) This represents a not-null constraint. atthasdef tinyint(1) This column has a default expression or generation expression. att_default varchar(1024) default expression attisdropped tinyint(1) This column has been dropped and is no longer valid. A dropped column is still physically present in the table, but is ignored by the parser and so cannot be accessed via SQL. att_constraint_type char(1) p = primary key constraint, n=no constraint att_is_unsigned tinyint(1) unsigned or not att_is_auto_increment tinyint(1) auto increment or not att_comment varchar(1024) comment att_is_hidden tinyint(1) hidden or not attr_has_update tinyint(1) This columns has update expression attr_update varchar(1024) update expression attr_is_clusterby tinyint(1) Whether this column is used as the cluster by keyword to create the table"},{"location":"MatrixOne/Reference/System-tables/#mo_table_partitions-table","title":"mo_table_partitions table","text":"column type comments table_id BIGINT UNSIGNED(64) The ID of the current partitioned table. database_id BIGINT UNSIGNED(64) The ID of the database to which the current partitioned table belongs. number SMALLINT UNSIGNED(16) The current partition number. All partitions are indexed in the order they are defined, with 1 assigned to the first partition. name VARCHAR(64) The name of the partition. partition_type VARCHAR(50) Stores the partition type information for the table. For partitioned tables, the values can be \"KEY\", \"LINEAR_KEY\", \"HASH\", \"LINEAR_KEY_51\", \"RANGE\", \"RANGE_COLUMNS\", \"LIST\", \"LIST_COLUMNS\". For non-partitioned tables, the value is an empty string. Note: MatrixOne does not currently support RANGE and LIST partitioning. partition_expression VARCHAR(2048) The expression for the partitioning function used in the CREATE TABLE or ALTER TABLE statement that created the partitioned table's partitioning scheme. description_utf8 TEXT(0) This column is used for RANGE and LIST partitions. For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be an integer or MAXVALUE. For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a comma-separated list of integer values. For partitions with partition_type other than RANGE or LIST, this column is always NULL. Note: MatrixOne does not currently support RANGE and LIST partitioning, so this column is NULL. comment VARCHAR(2048) The text of the comment, if the partition has one. Otherwise, this value is empty. options TEXT(0) Partition options information, currently set to NULL. partition_table_name VARCHAR(1024) The name of the subtable corresponding to the current partition."},{"location":"MatrixOne/Reference/System-tables/#mo_account-table-only-visible-for-sys-account","title":"mo_account table (Only visible for sys account)","text":"column type comments account_id int unsigned account id, primary key account_name varchar(100) account name status varchar(100) open/suspend created_time timestamp create time comments varchar(256) comment suspended_time TIMESTAMP Time of the account's status is changed version bigint unsigned the version status of the current account"},{"location":"MatrixOne/Reference/System-tables/#mo_role-table","title":"mo_role table","text":"column type comments role_id int unsigned role id, primary key role_name varchar(100) role name creator int unsigned user_id owner int unsigned MOADMIN/ACCOUNTADMIN ownerid created_time timestamp create time comments text comment"},{"location":"MatrixOne/Reference/System-tables/#mo_user-table","title":"mo_user table","text":"column type comments user_id int user id, primary key user_host varchar(100) user host address user_name varchar(100) user name authentication_string varchar(100) authentication string encrypted with password status varchar(8) open,locked,expired created_time timestamp user created time expired_time timestamp user expired time login_type varchar(16) ssl/password/other creator int the creator id who created this user owner int the admin id for this user default_role int the default role id for this user"},{"location":"MatrixOne/Reference/System-tables/#mo_user_grant-table","title":"mo_user_grant table","text":"column type comments role_id int unsigned ID of the authorized role, associated primary key user_id int unsigned Obtain the user ID of the authorized role and associate the primary key granted_time timestamp granted time with_grant_option bool Whether to allow an authorized user to license to another user or role"},{"location":"MatrixOne/Reference/System-tables/#mo_role_grant-table","title":"mo_role_grant table","text":"column type comments granted_id int the role id being granted, associated primary key grantee_id int the role id to grant others, associated primary key operation_role_id int operation role id operation_user_id int operation user id granted_time timestamp granted time with_grant_option bool Whether to allow an authorized role to be authorized to another user or role"},{"location":"MatrixOne/Reference/System-tables/#mo_role_privs-table","title":"mo_role_privs table","text":"column type comments role_id int role id, associated primary key role_name varchar(100) role name: accountadmin/public obj_type varchar(16) object type: account/database/table, associated primary key obj_id bigint unsigned object id, associated primary key privilege_id int privilege id, associated primary key privilege_name varchar(100) privilege name: the list of privileges privilege_level varchar(100) level of privileges, associated primary key operation_user_id int unsigned operation user id granted_time timestamp granted time with_grant_option bool If permission granting is permitted"},{"location":"MatrixOne/Reference/System-tables/#mo_stages-table","title":"mo_stages table","text":"column type comments stage_id INT UNSIGNED(32) data stage ID stage_name VARCHAR(64) data stage name url TEXT(0) Path to object storage (without authentication), path to file system stage_credentials TEXT(0) Authentication information, encrypted and saved stage_status VARCHAR(64) ENABLED/DISABLED Default: DISABLED created_time TIMESTAMP(0) creation time comment TEXT(0) comment"},{"location":"MatrixOne/Reference/System-tables/#mo_user_defined_function-table","title":"mo_user_defined_function table","text":"column type comments function_id INT(32) ID of the function, primary key name VARCHAR(100) the name of the function owner INT UNSIGNED(32) ID of the role who created the function args TEXT(0) Argument list for the function rettype VARCHAR(20) return type of the function body TEXT(0) function body language VARCHAR(20) language used by the function db VARCHAR(100) database where the function is located definer VARCHAR(50) name of the user who defined the function modified_time TIMESTAMP(0) time when the function was last modified created_time TIMESTAMP(0) creation time of the function type VARCHAR(10) type of function, default FUNCTION security_type VARCHAR(10) security processing method, uniform value DEFINER comment VARCHAR(5000) Create a comment for the function character_set_client VARCHAR(64) Client character set: utf8mb4 collation_connection VARCHAR(64) Connection sort: utf8mb4_0900_ai_ci database_collation VARCHAR(64) Database connection collation: utf8mb4_0900_ai_ci"},{"location":"MatrixOne/Reference/System-tables/#mo_mysql_compatbility_mode-table","title":"mo_mysql_compatbility_mode table","text":"column type comments configuration_id INT(32) Configuration item id, an auto-increment column, used as a primary key to distinguish different configurations account_name VARCHAR(300) The name of the tenant where the configuration is located dat_name VARCHAR(5000) The name of the database where the configuration is located configuration JSON(0) Configuration content, saved in JSON format"},{"location":"MatrixOne/Reference/System-tables/#mo_pubs-table","title":"mo_pubs table","text":"column type comments pub_name VARCHAR(64) publication name database_name VARCHAR(5000) The name of the published data database_id BIGINT UNSIGNED(64) ID of the publishing database, corresponding to dat_id in the mo_database table all_table BOOL(0) Whether the publishing library contains all tables in the database corresponding to database_id all_account BOOL(0) Whether all accounts can subscribe to the library table_list TEXT(0) When it is not all table, publish the list of tables contained in the library, and the table name corresponds to the table under the database corresponding to database_id account_list TEXT(0) Account list that is allowed to subscribe to the publishing library when it is not all accounts created_time TIMESTAMP(0) Time when the release repository was created owner INT UNSIGNED(32) The role ID corresponding to the creation of the release library creator INT UNSIGNED(32) The ID of the user who created the release library comment TEXT(0) Remarks for creating a release library"},{"location":"MatrixOne/Reference/System-tables/#mo_indexes-table","title":"mo_indexes table","text":"column type comments id BIGINT UNSIGNED(64) index ID table_id BIGINT UNSIGNED(64) ID of the table where the index resides database_id BIGINT UNSIGNED(64) ID of the database where the index resides name VARCHAR(64) name of the index type VARCHAR(11) The type of index, including primary key index (PRIMARY), unique index (UNIQUE), secondary index (MULTIPLE) is_visible TINYINT(8) Whether the index is visible, 1 means visible, 0 means invisible (currently all MatrixOne indexes are visible indexes) hidden TINYINT(8) Whether the index is hidden, 1 is a hidden index, 0 is a non-hidden index comment VARCHAR(2048) Comment information for the index column_name VARCHAR(256) The column name of the constituent columns of the index ordinal_position INT UNSIGNED(32) Column ordinal in index, starting from 1 options TEXT(0) options option information for index index_table_name VARCHAR(5000) The table name of the index table corresponding to the index, currently only the unique index contains the index table"},{"location":"MatrixOne/Reference/System-tables/#system_metrics-database","title":"system_metrics database","text":"

      system_metrics collect the status and statistics of SQL statements, CPU & memory resource usage.

      system_metrics tables have more or less same column types, fields in these tables are described as follows:

      • collecttime:Collection time
      • value: the value of the collecting metric

      • node: the MatrixOne node uuid

      • role: the MatrixOne node role, can be CN, TN or LOG.
      • account: default as \"sys\", the account who fires the SQL request.
      • type:SQL type, can be select, insert, update, delete, other types.
      "},{"location":"MatrixOne/Reference/System-tables/#metric-table","title":"metric table","text":"Column Type Comment metric_name VARCHAR(128) metric name, like: sql_statement_total, server_connections, process_cpu_percent, sys_memory_used, .. collecttime DATETIME metric data collect time value DOUBLE metric value node VARCHAR(36) MatrixOne node uuid role VARCHAR(32) MatrixOne node role account VARCHAR(128) account name, default \"sys\" type VARCHAR(32) SQL type: like insert, select, update ...

      The other tables are all views of the metric table:

      • process_cpu_percent table: Process CPU busy percentage.
      • process_open_fs table: Number of open file descriptors.
      • process_resident_memory_bytes table: Resident memory size in bytes.
      • server_connection table: Server connection numbers.
      • sql_statement_errors table: Counter of sql statements executed with errors.
      • sql_statement_total table: Counter of executed sql statement.
      • sql_transaction_errors table: Counter of transactional statements executed with errors.
      • sql_statement_hotspot table: records the most extended SQL query executed by each tenant within each minute. Only those SQL queries whose execution time does not exceed a certain aggregation threshold will be included in the statistics.
      • sql_transaction_total table: Counter of transactional sql statement.
      • sys_cpu_combined_percent table: System CPU busy percentage, average among all logical cores.
      • sys_cpu_seconds_total table: System CPU time spent in seconds, normalized by number of cores
      • sys_disk_read_bytes table: System disk read in bytes.
      • sys_disk_write_bytes table: System disk write in bytes.
      • sys_memory_available table: System memory available in bytes.
      • sys_memory_used table: System memory used in bytes.
      • sys_net_recv_bytes table: System net received in bytes.
      • sys_net_sent_bytes table: System net sent in bytes.
      "},{"location":"MatrixOne/Reference/System-tables/#system-database","title":"system database","text":"

      System database stores MatrixOne historical SQL statements, system logs, error information.

      "},{"location":"MatrixOne/Reference/System-tables/#statement_info-table","title":"statement_info table","text":"

      It records user and system SQL statement with detailed information.

      Column Type Comments statement_id VARCHAR(36) statement unique id transaction_id VARCHAR(36) Transaction unique id session_id VARCHAR(36) session unique id account VARCHAR(1024) account name user VARCHAR(1024) user name host VARCHAR(1024) user client ip database VARCHAR(1024) what database current session stay in statement TEXT sql statement statement_tag TEXT note tag in statement(Reserved) statement_fingerprint TEXT note tag in statement(Reserved) node_uuid VARCHAR(36) node uuid, which node gen this data node_type VARCHAR(64) node type in MO, val in [TN, CN, LOG] request_at DATETIME request accept datetime response_at DATETIME response send datetime duration BIGINT exec time, unit: ns status VARCHAR(32) sql statement running status, enum: Running, Success, Failed err_code VARCHAR(1024) error code error TEXT error message exec_plan JSON statement execution plan rows_read BIGINT rows read total bytes_scan BIGINT bytes scan total stats JSON global stats info in exec_plan statement_type VARCHAR(1024) statement type, val in [Insert, Delete, Update, Drop Table, Drop User, ...] query_type VARCHAR(1024) query type, val in [DQL, DDL, DML, DCL, TCL] role_id BIGINT role id sql_source_type TEXT Type of SQL source internally generated by MatrixOne aggr_count BIGINT(64) the number of statements aggregated result_count BIGINT(64) the number of rows of sql execution results"},{"location":"MatrixOne/Reference/System-tables/#rawlog-table","title":"rawlog table","text":"

      It records very detailed system logs.

      Column Type Comments raw_item VARCHAR(1024) raw log item node_uuid VARCHAR(36) node uuid, which node gen this data. node_type VARCHAR(64) node type in MO, val in [TN, CN, LOG] span_id VARCHAR(16) span unique id statement_id VARCHAR(36) statement unique id logger_name VARCHAR(1024) logger name timestamp DATETIME timestamp of action level VARCHAR(1024) log level, enum: debug, info, warn, error, panic, fatal caller VARCHAR(1024) where it log, like: package/file.go:123 message TEXT log message extra JSON log dynamic fields err_code VARCHAR(1024) error log error TEXT error message stack VARCHAR(4096) span_name VARCHAR(1024) span name, for example: step name of execution plan, function name in code, ... parent_span_id VARCHAR(16) parent span unique id start_time DATETIME end_time DATETIME duration BIGINT exec time, unit: ns resource JSON static resource information

      The other 3 tables(log_info, span_info and error_info) are views of statement_info and rawlog table.

      "},{"location":"MatrixOne/Reference/System-tables/#information_schema-database","title":"information_schema database","text":"

      Information Schema provides an ANSI-standard way of viewing system metadata. MatrixOne also provides a number of custom information_schema tables, in addition to the tables included for MySQL compatibility.

      Many INFORMATION_SCHEMA tables have a corresponding SHOW command. The benefit of querying INFORMATION_SCHEMA is that it is possible to join between tables.

      "},{"location":"MatrixOne/Reference/System-tables/#tables-for-mysql-compatibility","title":"Tables for MySQL compatibility","text":"Table Name Description KEY_COLUMN_USAGE Describes the key constraints of the columns, such as the primary key constraint. COLUMNS Provides a list of columns for all tables. PROFILING Provides some profiling information during SQL statement execution. PROCESSLIST Provides similar information to the command SHOW PROCESSLIST. USER_PRIVILEGES Summarizes the privileges associated with the current user. SCHEMATA Provides similar information to SHOW DATABASES. CHARACTER_SETS Provides a list of character sets the server supports. TRIGGERS Provides similar information to SHOW TRIGGERS. TABLES Provides a list of tables that the current user has visibility of. Similar to SHOW TABLES. PARTITIONS Provides information about table partitions. VIEWS Provides information about views in the database. ENGINES Provides a list of supported storage engines. ROUTINES Provides some information about stored procedures. PARAMETERS Provides information about stored procedures' parameters and return values \u200b\u200b. KEYWORDS Provide information about keywords in the database; see Keywords for details."},{"location":"MatrixOne/Reference/System-tables/#character_sets-table","title":"CHARACTER_SETS table","text":"

      The description of columns in the CHARACTER_SETS table is as follows:

      • CHARACTER_SET_NAME: The name of the character set.
      • DEFAULT_COLLATE_NAME The default collation name of the character set.
      • DESCRIPTION The description of the character set.
      • MAXLEN The maximum length required to store a character in this character set.
      "},{"location":"MatrixOne/Reference/System-tables/#columns-table","title":"COLUMNS table","text":"

      The description of columns in the COLUMNS table is as follows:

      • TABLE_CATALOG: The name of the catalog to which the table with the column belongs. The value is always def.
      • TABLE_SCHEMA: The name of the schema in which the table with the column is located.
      • TABLE_NAME: The name of the table with the column.
      • COLUMN_NAME: The name of the column.
      • ORDINAL_POSITION: The position of the column in the table.
      • COLUMN_DEFAULT: The default value of the column. If the explicit default value is NULL, or if the column definition does not include the default clause, this value is NULL.
      • IS_NULLABLE: Whether the column is nullable. If the column can store null values, this value is YES; otherwise, it is NO.
      • DATA_TYPE: The type of data in the column.
      • CHARACTER_MAXIMUM_LENGTH: For string columns, the maximum length in characters.
      • CHARACTER_OCTET_LENGTH: For string columns, the maximum length in bytes.
      • NUMERIC_PRECISION: The numeric precision of a number-type column.
      • NUMERIC_SCALE: The numeric scale of a number-type column.
      • DATETIME_PRECISION: For time-type columns, the fractional seconds precision.
      • CHARACTER_SET_NAME: The name of the character set of a string column.
      • COLLATION_NAME: The name of the collation of a string column.
      • COLUMN_TYPE: The column type.
      • COLUMN_KEY: Whether this column is indexed. This field might have the following values:
        • Empty: This column is not indexed, or this column is indexed and is the second column in a multi-column non-unique index.
        • PRI: This column is the primary key or one of multiple primary keys.
        • UNI: This column is the first column of the unique index.
        • MUL: The column is the first column of a non-unique index, in which a given value is allowed to occur for multiple times.
      • EXTRA: Any additional information of the given column.
      • PRIVILEGES: The privilege that the current user has on this column.
      • COLUMN_COMMENT: Comments contained in the column definition.
      • GENERATION_EXPRESSION: For generated columns, this value displays the expression used to calculate the column value. For non-generated columns, the value is empty.
      • SRS_ID: This value applies to spatial columns. It contains the column SRID value that indicates the spatial reference system for values stored in the column.
      "},{"location":"MatrixOne/Reference/System-tables/#engines-table","title":"ENGINES table","text":"

      The description of columns in the ENGINES table is as follows:

      • ENGINES: The name of the storage engine.
      • SUPPORT: The level of support that the server has on the storage engine.
      • COMMENT: The brief comment on the storage engine.
      • TRANSACTIONS: Whether the storage engine supports transactions.
      • XA: Whether the storage engine supports XA transactions.
      • SAVEPOINTS: Whether the storage engine supports savepoints.
      "},{"location":"MatrixOne/Reference/System-tables/#partitions-table","title":"PARTITIONS table","text":"

      The description of columns in the PARTITIONS table is as follows:

      • TABLE_CATALOG: The name of the catalog to which the table belongs. This value is always def.
      • TABLE_SCHEMA: The name of the schema (database) to which the table belongs.
      • TABLE_NAME: The name of the table containing the partition.
      • PARTITION_NAME: The name of the partition.
      • SUBPARTITION_NAME: If the PARTITIONS table row represents a subpartition, the name of subpartition; otherwise NULL.
      • PARTITION_ORDINAL_POSITION: All partitions are indexed in the same order as they are defined, with 1 being the number assigned to the first partition. The indexing can change as partitions are added, dropped, and reorganized; the number shown is this column reflects the current order, taking into account any indexing changes.
      • SUBPARTITION_ORDINAL_POSITION: Subpartitions within a given partition are also indexed and reindexed in the same manner as partitions are indexed within a table.
      • PARTITION_METHOD: One of the values RANGE, LIST, HASH, LINEAR HASH, KEY, or LINEAR KEY. Note: MatrixOne does not currently support RANGE and LIST partitioning.
      • SUBPARTITION_METHOD: One of the values HASH, LINEAR HASH, KEY, or LINEAR KEY.
      • PARTITION_EXPRESSION: The expression for the partitioning function used in the CREATE TABLE or ALTER TABLE statement that created the table's current partitioning scheme.
      • SUBPARTITION_EXPRESSION: This works in the same fashion for the subpartitioning expression that defines the subpartitioning for a table as PARTITION_EXPRESSION does for the partitioning expression used to define a table's partitioning. If the table has no subpartitions, this column is NULL.
      • PARTITION_DESCRIPTION: This column is used for RANGE and LIST partitions. For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be either an integer or MAXVALUE. For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a list of comma-separated integer values. For partitions whose PARTITION_METHOD is other than RANGE or LIST, this column is always NULL. Note: MatrixOne does not currently support RANGE and LIST partitioning.
      • TABLE_ROWS: The number of table rows in the partition.
      • AVG_ROW_LENGTH: The average length of the rows stored in this partition or subpartition, in bytes. This is the same as DATA_LENGTH divided by TABLE_ROWS.
      • DATA_LENGTH: The total length of all rows stored in this partition or subpartition, in bytes; that is, the total number of bytes stored in the partition or subpartition.
      • INDEX_LENGTH: The length of the index file for this partition or subpartition, in bytes.
      • DATA_FREE: The number of bytes allocated to the partition or subpartition but not used.
      • CREATE_TIME: The time that the partition or subpartition was created.
      • UPDATE_TIME: The time that the partition or subpartition was last modified.
      • CHECK_TIME: The last time that the table to which this partition or subpartition belongs was checked.
      • CHECKSUM: The checksum value, if any; otherwise NULL.
      • PARTITION_COMMENT: The text of the comment, if the partition has one. If not, this value is empty. The maximum length for a partition comment is defined as 1024 characters, and the display width of the PARTITION_COMMENT column is also 1024, characters to match this limit.
      • NODEGROUP: This is the nodegroup to which the partition belongs.
      • TABLESPACE_NAME: The name of the tablespace to which the partition belongs. The value is always DEFAULT.
      "},{"location":"MatrixOne/Reference/System-tables/#processlist-table","title":"PROCESSLIST table","text":"

      Fields in the PROCESSLIST table are described as follows:

      • ID: The ID of the user connection.
      • USER: The name of the user who is executing PROCESS.
      • HOST: The address that the user is connecting to.
      • DB: The name of the currently connected default database.
      • COMMAND: The command type that PROCESS is executing.
      • TIME: The current execution duration of PROCESS, in seconds.
      • STATE: The current connection state.
      • INFO: The requested statement that is being processed.
      "},{"location":"MatrixOne/Reference/System-tables/#schemata-table","title":"SCHEMATA table","text":"

      The SCHEMATA table provides information about databases. The table data is equivalent to the result of the SHOW DATABASES statement. Fields in the SCHEMATA table are described as follows:

      • CATALOG_NAME: The catalog to which the database belongs.
      • SCHEMA_NAME: The database name.
      • DEFAULT_CHARACTER_SET_NAME: The default character set of the database.
      • DEFAULT_COLLATION_NAME: The default collation of the database.
      • SQL_PATH: The value of this item is always NULL.
      • DEFAULT_TABLE_ENCRYPTION: defines the default encryption setting for databases and general tablespaces.
      "},{"location":"MatrixOne/Reference/System-tables/#tables-table","title":"TABLES table","text":"

      The description of columns in the TABLES table is as follows:

      • TABLE_CATALOG: The name of the catalog which the table belongs to. The value is always def.
      • TABLE_SCHEMA: The name of the schema which the table belongs to.
      • TABLE_NAME: The name of the table.
      • TABLE_TYPE: The type of the table. The base table type is BASE TABLE, the view table type is VIEW, and the INFORMATION_SCHEMA table type is SYSTEM VIEW.
      • ENGINE: The type of the storage engine.
      • VERSION: Version. The value is 10 by default.
      • ROW_FORMAT: The row format. The value is Compact, Fixed, Dynamic, Compressed, Redundant.
      • TABLE_ROWS: The number of rows in the table in statistics. For INFORMATION_SCHEMA tables, TABLE_ROWS is NULL.
      • AVG_ROW_LENGTH: The average row length of the table. AVG_ROW_LENGTH = DATA_LENGTH / TABLE_ROWS.
      • DATA_LENGTH: Data length. DATA_LENGTH = TABLE_ROWS * the sum of storage lengths of the columns in the tuple.
      • MAX_DATA_LENGTH: The maximum data length. The value is currently 0, which means the data length has no upper limit.
      • INDEX_LENGTH: The index length. INDEX_LENGTH = TABLE_ROWS * the sum of lengths of the columns in the index tuple.
      • DATA_FREE: Data fragment. The value is currently 0.
      • AUTO_INCREMENT: The current step of the auto- increment primary key.
      • CREATE_TIME: The time at which the table is created.
      • UPDATE_TIME: The time at which the table is updated.
      • CHECK_TIME: The time at which the table is checked.
      • TABLE_COLLATION: The collation of strings in the table.
      • CHECKSUM: Checksum.
      • CREATE_OPTIONS: Creates options.
      • TABLE_COMMENT: The comments and notes of the table.
      "},{"location":"MatrixOne/Reference/System-tables/#user_privileges-table","title":"USER_PRIVILEGES table","text":"

      The USER_PRIVILEGES table provides information about global privileges.

      Fields in the USER_PRIVILEGES table are described as follows:

      • GRANTEE: The name of the granted user, which is in the format of 'user_name'@'host_name'.
      • TABLE_CATALOG: The name of the catalog to which the table belongs. This value is always def.
      • PRIVILEGE_TYPE: The privilege type to be granted. Only one privilege type is shown in each row.
      • IS_GRANTABLE: If you have the GRANT OPTION privilege, the value is YES; otherwise, the value is NO.
      "},{"location":"MatrixOne/Reference/System-tables/#view-table","title":"VIEW table","text":"
      • TABLE_CATALOG: The name of the catalog the view belongs to. The value is def.
      • TABLE_SCHEMA: The name of the database to which the view belongs.
      • TABLE_NAME: The name of the view.
      • VIEW_DEFINITION: The SELECT statement that provides the view definition. It contains most of what you see in the \"Create Table\" column generated by SHOW Create VIEW.
      • CHECK_OPTION: The value of the CHECK_OPTION property. Values are NONE, CASCADE, or LOCAL.
      • IS_UPDATABLE: Set a flag called the view updatable flag when CREATE VIEW; if UPDATE and DELETE (and similar operations) are legal for the view, the flag is set to YES(true). Otherwise, the flag is set to NO(false).
      • DEFINER: The account of the user who created the view, in the format username@hostname.
      • SECURITY_TYPE: View the SQL SECURITY attribute. Values \u200b\u200bare DEFINER or INVOKER.
      • CHARACTER_SET_CLIENT: The session value of the character_set_client system variable when the view was created.
      • COLLATION_CONNECTION: The session value of the collation_connection system variable when the view was created.
      "},{"location":"MatrixOne/Reference/System-tables/#statistics-table","title":"STATISTICS Table","text":"

      Obtain detailed information about database table indexes and statistics. For example, you can check whether an index is unique, understand the order of columns within an index, and estimate the number of unique values in an index.

      • TABLE_CATALOG: The catalog name of the table (always 'def').
      • TABLE_SCHEMA: The name of the database to which the table belongs.
      • TABLE_NAME: The name of the table.
      • NON_UNIQUE: Indicates whether the index allows duplicate values. If 0, the index is unique.
      • INDEX_SCHEMA: The database name to which the index belongs.
      • INDEX_NAME: The name of the index.
      • SEQ_IN_INDEX: The position of the column within the index.
      • COLUMN_NAME: The name of the column.
      • COLLATION: The collation of the column.
      • CARDINALITY: An estimated count of unique values in the index.
      • SUB_PART: The length of the index part. For the entire column, this value is NULL.
      • PACKED: Indicates whether compressed storage is used.
      • NULLABLE: Indicates whether the column allows NULL values.
      • INDEX_TYPE: The index type (e.g., BTREE, HASH, etc.).
      • COMMENT: Comment information about the index.
      "},{"location":"MatrixOne/Reference/System-tables/#mysql-database","title":"mysql database","text":""},{"location":"MatrixOne/Reference/System-tables/#grant-system-tables","title":"Grant system tables","text":"

      These system tables contain grant information about user accounts and their privileges:

      • user: user accounts, global privileges, and other non-privilege columns.
      • db: database-level privileges.
      • tables_priv: table-level privileges.
      • columns_priv: column-level privileges.
      • procs_priv: stored procedure and stored function privileges.
      "},{"location":"MatrixOne/Reference/access-control-type/","title":"Privilege Control Types","text":"

      The privilege control of a MatrixOne is classified into System Permission and Object Permission. You can refer to the permissions granted to roles.

      "},{"location":"MatrixOne/Reference/access-control-type/#system-permission","title":"System Permission","text":"

      System permissions are the permissions of the initial system account. The system account is the cluster system administrator root, also called the cluster administrator. The system root can create and delete other accounts, and manage accounts. A system root cannot manage other resources of other accounts.

      Permissions Description CREATE ACCOUNT Create an account. It belongs only to the SYS account. DROP ACCOUNT Delete an account. It belongs only to the SYS account. ALTER ACCOUNT Manage accounts. It belongs only to the SYS account."},{"location":"MatrixOne/Reference/access-control-type/#object-permission","title":"Object Permission","text":"

      Object permission can be classified into Account Permission, User Permission, Role Permission, Database Permission, and Table Permission.

      "},{"location":"MatrixOne/Reference/access-control-type/#account-permission","title":"Account Permission","text":"

      Objects with Account Permission can have the following permissions:

      Permissions Description CREATE USER Create a user DROP USER Delete a user ALTER USER Modify users CREATE ROLE Create a role DROP ROLE Delete a role CREATE DATABASE Create a database DROP DATABASE Delete a database SHOW DATABASES View all databases in the current account CONNECT Use use [database | role], execute SELECT which does not involve concrete object MANAGE GRANTS Permission management. You can authorize roles and inherit permission from roles ALL [PRIVILEGES] All permissions of the Account OWNERSHIP All permissions of the Account. The account can be set using WITH GRANT OPTION SHOW GRANT View the permission list of a role or user under the current account"},{"location":"MatrixOne/Reference/access-control-type/#user-permission","title":"User Permission","text":"

      Objects with User Permission can have the following permissions:

      Permissions Description Ownership You can manage all user permission, including modifying user information, passwords, and deleting users, and transfer these permissions to other roles."},{"location":"MatrixOne/Reference/access-control-type/#role-permission","title":"Role Permission","text":"

      Objects with Role Permission can have the following permissions:

      Permissions Description Ownership You can manage all rights of a role, including modifying the name, description, and deletion of a role, and transfer these rights to other roles."},{"location":"MatrixOne/Reference/access-control-type/#database-permission","title":"Database Permission","text":"

      Objects with Database Permission can have the following permissions:

      Permissions Description SHOW TABLES View all tables in the current database CREATE TABLE Create a table DROP TABLE Delete a table CREATE VIEW Create a view,A view created without the corresponding table permission cannot be queried DROP VIEW Delete a view ALTER TABLE Modify a table ALTER VIEW Modify a view. A view created without the corresponding table permission cannot be queried. ALL [PRIVILEGES] All permission of database OWNERSHIP All permission of database. The database can be set using WITH GRANT OPTION"},{"location":"MatrixOne/Reference/access-control-type/#table-permission","title":"Table Permission","text":"

      Objects with Table Permission can have the following permissions:

      Permissions Description SELECT Execute the SELECT statement INSERT Execute the INSERT statement UPDATE Execute the UPDATE statement TRUNCATE Execute the TRUNCATE TABLE statement DELETE Execute the DELETE statement REFERENCE Allows a table to be referenced as a unique/primary key table for external constraints. View the structure of the table with the DESCRIBE or SHOW command INDEX Create or drop INDEX ALL Specifies all permissions for the table OWNERSHIP Specifies all permissions for the table, append WITH GRANT OPTION"},{"location":"MatrixOne/Reference/access-control-type/#table-routine-level-permission","title":"Table Routine Level Permission","text":"

      Objects with Table Routine Level Permission can have the following permissions:

      Permissions Description EXECUTE Permission to execute a function or stored procedure"},{"location":"MatrixOne/Reference/access-control-type/#publish-and-subscribe-permission","title":"Publish and subscribe permission","text":"

      In MatrixOne, publish-subscribe is data-sharing access to the specified database.

      Note: Currently, only moadmin and accountadmin roles are supported in MatrixOne to perform publish and subscribe operations.

      • publisher

      The publisher is the party that publishes the data that needs to be shared and synchronized.

      Permissions Description CREATE PUBLICATION Create Publication ALTER PUBLICATION Modify Publication DROP PUBLICATION Delete a publication SHOW PUBLICATION View Publication SHOW CREATE PUBLICATION View create publication statement
      • Subscriber

      The subscriber is the party that obtains the shared and synchronized data.

      Permissions Description CREATE DATABASE db_name FROM account_name PUBLICATION CREATE SUBSCRIPTION SHOW SUBSCRIPTIONS View Subscriptions"},{"location":"MatrixOne/Reference/Data-Types/blob-text-type/","title":"The BLOB and TEXT Type","text":"

      BLOB

      • A BLOB is a binary large object that can hold a variable amount of data.

      • BLOB values are treated as binary strings (byte strings). They have the binary character set and collation, and comparison and sorting are based on the numeric values of the bytes in column values.

      TEXT

      • TEXT values are treated as nonbinary strings (character strings). They have a character set other than binary, and values are sorted and compared based on the collation of the character set.

      About BLOB and TEXT

      If you assign a value to a BLOB or TEXT type column that exceeds the maximum length for that column, the portion that exceeds the length will be truncated, and a warning will be generated. If a non-whitespace character is truncated, an error (rather than a warning) occurs, and insertion of the value is prohibited. For TEXT, always generate a warning when trimming excess trailing spaces in values \u200b\u200binserted into TEXT columns.

      "},{"location":"MatrixOne/Reference/Data-Types/data-type-conversion/","title":"Data Type Conversion","text":""},{"location":"MatrixOne/Reference/Data-Types/data-type-conversion/#data-type-conversion","title":"Data Type Conversion","text":"

      MatrixOne supports the conversion between different data types, the supported and unsupported conversions are listed in the following table.

      • Castable: explicit conversion with cast function.
      • Coercible: implicit conversion without cast function.
      Source Data Type Target Data Type Castable Coercible BOOLEAN INTEGER \u274c \u274c DECIMAL \u274c \u274c VARCHAR \u2714 \u2714 DATE TIMESTAMP \u2714 \u2714 DATETIME \u2714 \u2714 VARCHAR \u2714 \u2714 DATETIME TIMESTAMP \u2714 \u2714 DATE \u2714 \u2714 VARCHAR \u2714 \u2714 FLOAT(Floating-point number) INTEGER \u274c \u274c DECIMAL \u2714 \u2714 VARCHAR \u2714 \u2714 INTEGER BOOLEAN \u274c \u274c FLOAT \u2714 \u2714 TIMESTAMP \u2714 \u2714 VARCHAR \u2714 \u2714 DECIMAL \u2714 \u2714 TIMESTAMP DATE \u2714 \u2714 DATETIME \u2714 \u2714 VARCHAR \u2714 \u2714 VARCHAR BOOLEAN \u2714 \u2714 DATE \u2714 \u2714 FLOAT \u2714 \u2714 INTEGER \u2714 \u2714 DECIMAL \u2714 \u2714 TIMESTAMP \u2714 \u2714 DATETIME \u2714 \u2714"},{"location":"MatrixOne/Reference/Data-Types/data-types/","title":"Data Types Overview","text":"

      MatrixOne Data types conforms with MySQL Data types definition.

      Reference: https://dev.mysql.com/doc/refman/8.0/en/data-types.html

      "},{"location":"MatrixOne/Reference/Data-Types/data-types/#integer-numbers","title":"Integer Numbers","text":"Data Type Size Min Value Max Value TINYINT 1 byte -128 127 SMALLINT 2 bytes -32768 32767 INT 4 bytes -2147483648 2147483647 BIGINT 8 bytes -9223372036854775808 9223372036854775807 TINYINT UNSIGNED 1 byte 0 255 SMALLINT UNSIGNED 2 bytes 0 65535 INT UNSIGNED 4 bytes 0 4294967295 BIGINT UNSIGNED 8 bytes 0 18446744073709551615"},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples","title":"Examples","text":"
      • TINYINT and TINYINT UNSIGNED
      -- Create a table named \"inttable\" with 2 attributes of a \"tinyint\", a \"tinyint unsigned\",\ncreate table inttable ( a tinyint not null default 1, tinyint8 tinyint unsigned primary key);\ninsert into inttable (tinyint8) values (0),(255), (0xFE), (253);\n\nmysql> select * from inttable order by 2 asc;\n+------+----------+\n| a    | tinyint8 |\n+------+----------+\n|    1 |        0 |\n|    1 |      253 |\n|    1 |      254 |\n|    1 |      255 |\n+------+----------+\n4 rows in set (0.03 sec)\n
      • SMALLINT and SMALLINT UNSIGNED
      -- Create a table named \"inttable\" with 2 attributes of a \"smallint\", a \"smallint unsigned\",\ndrop table inttable;\ncreate table inttable ( a smallint not null default 1, smallint16 smallint unsigned);\ninsert into inttable (smallint16) values (0),(65535), (0xFFFE), (65534), (65533);\n\nmysql> select * from inttable;\n+------+------------+\n| a    | smallint16 |\n+------+------------+\n|    1 |          0 |\n|    1 |      65535 |\n|    1 |      65534 |\n|    1 |      65534 |\n|    1 |      65533 |\n+------+------------+\n5 rows in set (0.01 sec)\n
      • INT and INT UNSIGNED
      -- Create a table named \"inttable\" with 2 attributes of a \"int\", a \"int unsigned\",\ndrop table inttable;\ncreate table inttable ( a int not null default 1, int32 int unsigned primary key);\ninsert into inttable (int32) values (0),(4294967295), (0xFFFFFFFE), (4294967293), (4294967291);\n\nmysql> select * from inttable order by a desc, 2 asc;\n+------+------------+\n| a    | int32      |\n+------+------------+\n|    1 |          0 |\n|    1 | 4294967291 |\n|    1 | 4294967293 |\n|    1 | 4294967294 |\n|    1 | 4294967295 |\n+------+------------+\n5 rows in set (0.01 sec)\n
      • BIGINT and BIGINT UNSIGNED
      -- Create a table named \"inttable\" with 2 attributes of a \"bigint\", a \"bigint unsigned\",\ndrop table inttable;\ncreate table inttable ( a bigint, big bigint primary key );\ninsert into inttable values (122345515, 0xFFFFFFFFFFFFE), (1234567, 0xFFFFFFFFFFFF0);\n\nmysql> select * from inttable;\n+-----------+------------------+\n| a         | big              |\n+-----------+------------------+\n| 122345515 | 4503599627370494 |\n|   1234567 | 4503599627370480 |\n+-----------+------------------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Data-Types/data-types/#real-numbers","title":"Real Numbers","text":"Data Type Size Precision Min Value Max Value Syntax FLOAT32 4 bytes 23 bits -3.40282e+038 3.40282e+038 FLOAT(M, D) M represents the maximum length and D represents the number of decimal places displayed. The value range of M is (1=< M <=255). The value range of D is (1=< D <=30), and M >= D. Float numbers with precision show the number of bits with the required precision, and a trailing zero is added when the number of bits falls short. FLOAT64 8 bytes 53 bits -1.79769e+308 1.79769e+308 DOUBLE(M, D) M represents the maximum length and D represents the number of decimal places displayed. The value range of M is (1=< M <=255). The value range of D is (1=< D <=30), and M >= D. Float numbers with precision show the number of bits with the required precision, and a trailing zero is added when the number of bits falls short."},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_1","title":"Examples","text":"
      -- Create a table named \"floatt1\" with precision, a trailing zero is added when the number of bits falls short\ncreate table floatt1(a float(5, 2));\ninsert into floatt1 values(1), (2.5), (3.56), (4.678);\nmysql> select * from floatt1;\n+------+\n| a    |\n+------+\n| 1.00 |\n| 2.50 |\n| 3.56 |\n| 4.68 |\n+------+\n4 rows in set (0.00 sec)\n\n-- Create a table named \"floattable\" with 1 attributes of a \"float\"\ncreate table floattable ( a float not null default 1, big float(20,5) primary key);\ninsert into floattable (big) values (-1),(12345678.901234567),(92233720368547.75807);\n\nmysql> select * from floattable order by a desc, big asc;\n+------+----------------------+\n| a    | big                  |\n+------+----------------------+\n|    1 |             -1.00000 |\n|    1 |       12345679.00000 |\n|    1 | 92233718038528.00000 |\n+------+----------------------+\n3 rows in set (0.01 sec)\n\nmysql> select min(big),max(big),max(big)-1 from floattable;\n+----------+----------------------+----------------+\n| min(big) | max(big)             | max(big) - 1   |\n+----------+----------------------+----------------+\n| -1.00000 | 92233718038528.00000 | 92233718038527 |\n+----------+----------------------+----------------+\n1 row in set (0.05 sec)\n
      "},{"location":"MatrixOne/Reference/Data-Types/data-types/#string-types","title":"String Types","text":"Data Type Size Length Syntax Description char 24 bytes 0 ~ 4294967295 CHAR Fixed length string varchar 24 bytes 0 ~ 4294967295 VARCHAR Variable length string binary 255 bytes 0 ~ 65535 BINARY(M) Similar to CHAR, binary string varbinary 255 bytes 0 ~ 65535 VARBINARY(M) Similar to VARCHAR, binary string text 1 GB other types mapping TEXT Long text data, TINY TEXT, MEDIUM TEXT, and LONG TEXT are not distinguished blob 1 GB other types mapping BLOB Long text data in binary form, TINY BLOB, MEDIUM BLOB, and LONG BLOB are not distinguished enum 1 byte or 2 bytes 0 ~ 65535 enum An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special '' error value. ENUM values are represented internally as integers."},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_2","title":"Examples","text":"
      • CHAR and VARCHAR
      -- Create a table named \"names\" with 2 attributes of a \"varchar\" and a \"char\"\ncreate table names(name varchar(255),age char(255));\ninsert into names(name, age) values('Abby', '24');\ninsert into names(name, age) values(\"Bob\", '25');\ninsert into names(name, age) values('Carol', \"23\");\ninsert into names(name, age) values(\"Dora\", \"29\");\n\nmysql> select name,age from names;\n+-------+------+\n| name  | age  |\n+-------+------+\n| Abby  | 24   |\n| Bob   | 25   |\n| Carol | 23   |\n| Dora  | 29   |\n+-------+------+\n4 rows in set (0.00 sec)\n
      • BINARY and VARBINARY
      -- Create a table named \"names\" with 2 attributes of a \"varchar\" and a \"char\"\ncreate table names(name varbinary(255),age binary(255));\ninsert into names(name, age) values('Abby', '24');\ninsert into names(name, age) values(\"Bob\", '25');\ninsert into names(name, age) values('Carol', \"23\");\ninsert into names(name, age) values(\"Dora\", \"29\");\n\nmysql> select name,age from names;\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| name         | age                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| 0x41626279   | 0x323400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x426F62     | 0x323500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x4361726F6C | 0x323300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x446F7261   | 0x323900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n4 rows in set (0.01 sec)\n
      • TEXT
      -- Create a table named \"texttest\" with 1 attribute of a \"text\"\ncreate table texttest (a text);\ninsert into texttest values('abcdef');\ninsert into texttest values('_bcdef');\ninsert into texttest values('a_cdef');\ninsert into texttest values('ab_def');\ninsert into texttest values('abc_ef');\ninsert into texttest values('abcd_f');\ninsert into texttest values('abcde_');\n\nmysql> select * from texttest where a like 'ab\\_def' order by 1 asc;\n+--------+\n| a      |\n+--------+\n| ab_def |\n+--------+\n1 row in set (0.01 sec)\n
      • BLOB
      -- Create a table named \"blobtest\" with 1 attribute of a \"blob\"\ncreate table blobtest (a blob);\ninsert into blobtest values('abcdef');\ninsert into blobtest values('_bcdef');\ninsert into blobtest values('a_cdef');\ninsert into blobtest values('ab_def');\ninsert into blobtest values('abc_ef');\ninsert into blobtest values('abcd_f');\ninsert into blobtest values('abcde_');\n\nmysql> select * from blobtest where a like 'ab\\_def' order by 1 asc;\n+----------------+\n| a              |\n+----------------+\n| 0x61625F646566 |\n+----------------+\n1 row in set (0.01 sec)\n
      • ENUM
      -- Create a table named \"enumtest\" with 1 attribute of a \"enum\"\nCREATE TABLE enumtest (color ENUM('red', 'green', 'blue'));\nINSERT INTO enumtest (color) VALUES ('red');\nmysql> SELECT * FROM enumtest WHERE color = 'green';\n+-------+\n| color |\n+-------+\n| green |\n+-------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Data-Types/data-types/#json-types","title":"JSON Types","text":"JSON Data Type Syntax Object Object is enclosed by {}, separated by commas between key-value pairs, and separated by colons : between keys and values.The value/key can be String, Number, Bool, Time and date. Array Array is enclosed by [], separated by commas between key-value pairs, and separated by colons : between keys and values. The value can be String, Number, Bool, Time and date."},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_3","title":"Examples","text":"
      -- Create a table named \"jsontest\" with 1 attribute of a \"json\"\ncreate table jsontest (a json,b int);\ninsert into jsontest values ('{\"t1\":\"a\"}',1),('{\"t1\":\"b\"}',2);\n\nmysql> select * from jsontest;\n+-------------+------+\n| a           | b    |\n+-------------+------+\n| {\"t1\": \"a\"} |    1 |\n| {\"t1\": \"b\"} |    2 |\n+-------------+------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Data-Types/data-types/#time-and-date-types","title":"Time and Date Types","text":"Data Type Size Resolution Min Value Max Value Precision Time 8 bytes microsecond -2562047787:59:59.999999 2562047787:59:59.999999 hh:mm:ss.ssssss Date 4 bytes day 0001-01-01 9999-12-31 YYYY-MM-DD/YYYYMMDD DateTime 8 bytes microsecond 0001-01-01 00:00:00.000000 9999-12-31 23:59:59.999999 YYYY-MM-DD hh:mi:ssssss TIMESTAMP 8 bytes microsecond 0001-01-01 00:00:00.000000 9999-12-31 23:59:59.999999 YYYYMMDD hh:mi:ss.ssssss"},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_4","title":"Examples","text":"
      • TIME
      -- Create a table named \"timetest\" with 1 attributes of a \"time\"\ncreate table time_02(t1 time);\ninsert into time_02 values(200);\ninsert into time_02 values(\"\");\n\nmysql> select * from time_02;\n+----------+\n| t1       |\n+----------+\n| 00:02:00 |\n| NULL     |\n+----------+\n2 rows in set (0.00 sec)\n
      • DATE
      -- Create a table named \"datetest\" with 1 attributes of a \"date\"\ncreate table datetest (a date not null, primary key(a));\ninsert into datetest values ('2022-01-01'), ('20220102'),('2022-01-03'),('20220104');\n\nmysql> select * from datetest order by a asc;\n+------------+\n| a          |\n+------------+\n| 2022-01-01 |\n| 2022-01-02 |\n| 2022-01-03 |\n| 2022-01-04 |\n+------------+\n
      • DATETIME
      -- Create a table named \"datetimetest\" with 1 attributes of a \"datetime\"\ncreate table datetimetest (a datetime(0) not null, primary key(a));\ninsert into datetimetest values ('20200101000000'), ('2022-01-02'), ('2022-01-02 00:00:01'), ('2022-01-02 00:00:01.512345');\n\nmysql> select * from datetimetest order by a asc;\n+---------------------+\n| a                   |\n+---------------------+\n| 2020-01-01 00:00:00 |\n| 2022-01-02 00:00:00 |\n| 2022-01-02 00:00:01 |\n| 2022-01-02 00:00:02 |\n+---------------------+\n4 rows in set (0.02 sec)\n
      • TIMESTAMP
      -- Create a table named \"timestamptest\" with 1 attribute of a \"timestamp\"\ncreate table timestamptest (a timestamp(0) not null, primary key(a));\ninsert into timestamptest values ('20200101000000'), ('2022-01-02'), ('2022-01-02 00:00:01'), ('2022-01-02 00:00:01.512345');\n\nmysql> select * from timestamptest;\n+---------------------+\n| a                   |\n+---------------------+\n| 2020-01-01 00:00:00 |\n| 2022-01-02 00:00:00 |\n| 2022-01-02 00:00:01 |\n| 2022-01-02 00:00:02 |\n+---------------------+\n
      "},{"location":"MatrixOne/Reference/Data-Types/data-types/#bool","title":"Bool","text":"Data Type Size True 1 byte False 1 byte"},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_5","title":"Examples","text":"
      -- Create a table named \"booltest\" with 2 attribute of a \"boolean\" and b \"bool\"\ncreate table booltest (a boolean,b bool);\ninsert into booltest values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from booltest;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n| NULL  | NULL  |\n+-------+-------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Data-Types/data-types/#decimal-types","title":"Decimal Types","text":"Data Type Size Precision Syntax Decimal64 8 bytes 18 digits Decimal(N,S) N is the total number of digits, the range is(1 ~ 18). The decimal point and (for negative numbers) the - sign are not counted in N.If N is omitted, the default value of N should be the largest; that is, the value is 18. S is the number of digits after the decimal point (the scale), the range is(0 ~ N) If S is 0, values have no decimal point or fractional part. If S is omitted, the default is 0, for example, Decimal(10) is equivalent to Decimal(10, 0). For example, Decimal(10,8) represents a number with a total length of 10 and a decimal place of 8. Decimal128 16 bytes 38 digits Decimal(N,S) N is the total number of digits, the range is(18 ~ 38). The decimal point and (for negative numbers) the - sign are not counted in N.If N is omitted, the default value of N should be the largest; that is, the value is 38. S is the number of digits after the decimal point (the scale), the range is(0 ~ N) If S is 0, values have no decimal point or fractional part. If S is omitted, the default is 0, for example, Decimal(20) is equivalent to Decimal(20, 0).For example, Decimal(20,9) represents a number with a total length of 20 and a decimal place of 9."},{"location":"MatrixOne/Reference/Data-Types/data-types/#examples_6","title":"Examples","text":"
      -- Create a table named \"decimalTest\" with 2 attribute of a \"decimal\" and b \"decimal\"\ncreate table decimalTest(a decimal(6,3), b decimal(24,18));\ninsert into decimalTest values(123.4567, 123456.1234567891411241355);\n\nmysql> select * from decimalTest;\n+---------+---------------------------+\n| a       | b                         |\n+---------+---------------------------+\n| 123.457 | 123456.123456789141124136 |\n+---------+---------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Data-Types/data-types/#uuid-type","title":"UUID Type","text":"UUID type Explanation UUID A UUID value consists of 32 hexadecimal digits and 4 hyphens '-', in the form of 8-4-4-4-12, a standard UUID example: a0eebc99 -9c0b-4ef8-bb6d-6bb9bd380a11."},{"location":"MatrixOne/Reference/Data-Types/data-types/#example","title":"Example","text":"
      -- Create a new table named 't1' and set the 'a' column as UUID type, and set the 'a' column as the primary key\ncreate table t1(a uuid primary key);\n\n-- Insert a new UUID value into column 'a' of table 't1'\ninsert into t1 values \u200b\u200b(uuid());\n\n-- Query the length of the value of the 'a' column in the 't1' table converted to a string\nmysql> select length(cast(a as varchar)) from t1;\n+----------------------------+\n|length(cast(a as varchar))|\n+----------------------------+\n| 36 |\n+----------------------------+\n1 row in set (0.01 sec)\n\n-- Query all records in the t1 table, whose value is a UUID\nmysql> select * from t1;\n+----------------------------------------+\n| a |\n+----------------------------------------+\n| 948d8e4e-1b00-11ee-b656-5ad2460dea50 |\n+----------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Data-Types/enum-type/","title":"The ENUM Type","text":"

      \"ENUM\" is a list of strings used to store a set of predefined discrete values. It can define a type with discrete values, with each enumeration constant representing a specific value.

      The \"ENUM\" data type is suitable for storing data with limited fixed values, such as status and identification.

      The advantages of the \"ENUM\" data type are:

      Improved readability of column values. Compact data storage. When storing \"ENUM\" in MatrixOne, only the numerical index (1, 2, 3, ...) corresponding to the enumeration value is stored.

      "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#syntax","title":"Syntax","text":"
      ENUM ('value1', 'value2', ..., 'valuen')\n

      For example, to define an ENUM column, you can use the following syntax:

      CREATE TABLE table_name (\n...\ncol ENUM ('value1','value2','value3'),\n...\n);\n
      "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#explanations","title":"Explanations","text":"
      • ENUM is a keyword used to declare an enumeration type.
      • value1 to valuen is the optional list of choices for this ENUM type. The value of a column using the ENUM type can only be one of the values listed above.
      • Enumeration values can be of type string, int, or time.

      Note: You can have multiple enumeration values in the ENUM data type. However, it is recommended to keep the number of enumeration values below 20.

      "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#example-explanation","title":"Example Explanation","text":"

      The value of an ENUM type must be selected from a predefined list of values. The following example will help you understand:

      CREATE TABLE enumtable (\nid INT NOT NULL AUTO_INCREMENT,\ncolor ENUM('red', 'green', 'blue'),\nPRIMARY KEY (id)\n);\n

      The above statement will create a table named enumtable, which contains an enum type field named color. The value of the color field must be one of red, green, or blue. At the same time, according to the order of column definition, the indexes of red, green, and blue are 1, 2, and 3, respectively.

      "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#insert-enum-values","title":"Insert ENUM values","text":"

      When inserting data into a field of an enumeration type, only predefined enumeration values \u200b\u200bor NULL can be inserted. An error is raised if the inserted value is not in the predefined list. For example:

      INSERT INTO enumtable (id, color) VALUES ('01', 'red');\n-- 'red' is in the predefined list; the insertion was successful\nINSERT INTO enumtable (id, color) VALUES ('02', 'yellow');\n-- 'yellow' is not in the predefined list, an error will be generated\nINSERT INTO enumtable (id, color) VALUES ('03', NULL);\n-- The enumeration member does not define not null; the insertion is successful\n

      In addition to enumeration values, data can be inserted into ENUM columns using numeric indexes on enumeration members. For example:

      INSERT INTO enumtable (id, color) VALUES ('04', 2);\n-- Since the index of `green` is 2, this data is successfully inserted\n
      • NON-NULL CONSTRAINT FOR ENUM RESTRICTIONS

      If we defined the color column NOT NULL when creating the table:

      CREATE TABLE enumtable (\nid INT NOT NULL AUTO_INCREMENT,\ncolor ENUM('red', 'green', 'blue') NOT NULL,\nPRIMARY KEY (id)\n);\n

      When inserting a new row without specifying a value for the color column, MatrixOne will use the first enumeration member as the default value:

      INSERT INTO enumtable (id) VALUES ('05');\n-- Here, the first enumeration member `red` will be assigned as the default value for the column with id 05\n
      "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#features-that-are-different-from-mysql","title":"Features that are different from MySQL","text":"

      Unlike MySQL, MatrixOne's ENUM type can only be compared with the string type in the WHERE condition.

      You can see this example:

      update orders set status= 2 where status='Processing';`\n

      In this example, you must update the status to 2 for the row whose status is Processing. Due to the nature of the ENUM type, MatrixOne implicitly converts 2 to the string 2 in the WHERE condition, which is then compared with Processing.

      "},{"location":"MatrixOne/Reference/Data-Types/enum-type/#constraints","title":"Constraints","text":"
      1. Modifying ENUM enumeration members requires rebuilding the table using the ALTER TABLE statement.
      2. MatrixOne does not support Filtering ENUM values and Sorting ENUM values.
      "},{"location":"MatrixOne/Reference/Data-Types/fixed-point-types/","title":"Fixed-Point Types (Exact Value) - DECIMAL","text":"

      The DECIMAL type store exact numeric data values. These types are used when it is important to preserve exact precision, for example with monetary data, or with scientific calculations.

      In a DECIMAL column declaration, the precision and scale can be (and usually is) specified. For example:

      salary DECIMAL(5,2)\n

      In this example, 5 is the precision and 2 is the scale. The precision represents the number of significant digits that are stored for values, and the scale represents the number of digits that can be stored following the decimal point.

      Standard SQL requires that DECIMAL(5,2) be able to store any value with five digits and two decimals, so values that can be stored in the salary column range from -999.99 to 999.99.

      In MatrixOne, the syntax DECIMAL(M) is equivalent to DECIMAL(M,0). Similarly, the syntax DECIMAL is equivalent to DECIMAL(M,0), where the implementation is permitted to decide the value of M. MatrixOne supports both of these variant forms of DECIMAL syntax. The default value of M is 10.

      If the scale is 0, DECIMAL values contain no decimal point or fractional part.

      In MatrixOne, the maximum number of digits for DECIMAL is 38, but the actual range for a given DECIMAL column can be constrained by the precision or scale for a given column. When such a column is assigned a value with more digits following the decimal point than are permitted by the specified scale, the value is converted to that scale.

      "},{"location":"MatrixOne/Reference/Data-Types/fixed-point-types/#decimal-data-type-characteristics","title":"DECIMAL Data Type Characteristics","text":"

      This section discusses the characteristics of the DECIMAL data type (and its synonyms), with particular regard to the following topics:

      • Maximum number of digits

      • Storage format

      The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments are as follows:

      M is the maximum number of digits (the precision). It has a range of 1 to 38.

      D is the number of digits to the right of the decimal point (the scale). It has a range of 1 to 38 and must be no larger than M.

      If D is omitted, the default is 0. If M is omitted, the default is 10.

      The maximum value of 38 for M means that calculations on DECIMAL values are accurate up to 38 digits.

      Values for DECIMAL columns are stored using a binary format that packs decimal digits into 8 bytes or 16 bytes. The storage required for remaining digits is given by the following table.

      Digits Number of Bytes 0-18 8 bytes 19-38 16 bytes

      For a full explanation of the internal implementation of DECIMAL values, see the Feature Design.

      "},{"location":"MatrixOne/Reference/Data-Types/json-type/","title":"The JSON Data Type","text":"

      MatrixOne supports a native JSON data type defined by RFC 7159 that enables efficient access to data in JSON (JavaScript Object Notation) documents. The JSON data type provides these advantages over storing JSON-format strings in a string column:

      Automatic validation of JSON documents stored in JSON columns. Invalid documents produce an error.

      Automatically optimize storage format. JSON documents stored in JSON columns are converted to an internal format that permits quick read access to document elements. When the server later must read a JSON value stored in this binary format, the value need not be parsed from a text representation. The binary format is structured to enable the server to look up subobjects or nested values directly by key or array index without reading all values before or after them in the document.

      The space required to store a JSON document is roughly the same as for BLOB or TEXT.

      "},{"location":"MatrixOne/Reference/Data-Types/json-type/#json-types","title":"JSON Types","text":"

      JSON types contain JSON array and JSON object.

      • A JSON array contains a list of values separated by commas and enclosed within [ and ] characters:
      [\"abc\", 10, null, true, false]\n
      • A JSON object contains a set of key-value pairs separated by commas and enclosed within { and } characters:
      {\"k1\": \"value\", \"k2\": 10}\n

      As the examples illustrate, JSON arrays and objects can contain scalar values that are strings or numbers, the JSON null literal, or the JSON boolean true or false literals. Keys in JSON objects must be strings. Temporal (date, datetime) scalar values are also permitted:

      [\"12:18:29.000000\", \"2015-07-29\", \"2015-07-29 12:18:29.000000\"]\n

      Nesting is permitted within JSON array elements and JSON object key values:

      [99, {\"id\": \"HK500\", \"cost\": 75.99}, [\"hot\", \"cold\"]]\n{\"k1\": \"value\", \"k2\": [10, 20]}\n
      "},{"location":"MatrixOne/Reference/Data-Types/json-type/#normalization-of-json-values","title":"Normalization of JSON Values","text":"

      When a string is parsed and found to be a valid JSON document, it is also normalized. This means that members with keys that duplicate a key found later in the document, reading from left to right, are discarded.

      Normalization is performed when values are inserted into JSON columns, as shown here:

      CREATE TABLE t1 (c1 JSON);\nINSERT INTO t1 VALUES\n('{\"x\": 17, \"x\": \"red\"}'),\n('{\"x\": 17, \"x\": \"red\", \"x\": [3, 5, 7]}');\n\nmysql> SELECT c1 FROM t1;\n+------------------+\n| c1               |\n+------------------+\n| {\"x\": \"red\"}     |\n| {\"x\": [3, 5, 7]} |\n+------------------+\n
      "},{"location":"MatrixOne/Reference/Data-Types/uuid-type/","title":"UUID Type","text":"

      A UUID is a universally unique identifier consisting of 32 hexadecimal digits followed by 4 hyphens. UUIDs are globally unique, not unique in the database, and even performing a UUID call on two unconnected, standalone devices is expected to generate two different values. UUID is often used to generate a random value for the corresponding row to ensure the uniqueness of each record. . UUIDs are suitable as unique identifiers in a cluster environment.

      Info

      Although UUID() values \u200b\u200bare unique, they are not guessable or unpredictable. If unpredictability is desired, UUID values \u200b\u200bshould be generated in other ways.

      UUID() returns a version 1 UUID value conforming to the RFC 4122 standard, which is a 128-bit number, which represents a utf8mb3 composed of five A string of hexadecimal numbers, that is, aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee, the format is explained as follows:

      • The first three numbers are generated from the low, middle, and high parts of a timestamp. The high part also includes the UUID version number.

      • The fourth number preserves temporal uniqueness in case the timestamp value loses monotonicity (for example, due to daylight saving time).

      • The fifth number is an IEEE 802 node number that provides spatial uniqueness. A random number is substituted if the latter is not available (for example, because the host device has no Ethernet card, or it is unknown how to find the hardware address of an interface on the host operating system). In this case, spatial uniqueness cannot be guaranteed. Nevertheless, a collision should have very low probability.

      SQL statement supported by UUID type:

      • DDL - CREATE statement: Can create a table with a field of type UUID.
      • DML - INSERT/UPDATE/DELETE statement: Allows insert, update and delete operations on UUID type data.
      • DQL - SELECT statement: UUID type fields can be queried, and the query results are displayed as strings on the client side.

      SQL statement clauses supported by UUID type:

      • ORDER BY clause: UUID type fields can be used as sorting criteria.
      • WHERE clause: UUID type fields can be used in the WHERE clause, and comparison operations are supported.
      • HAVING clause: UUID type fields can be used in the HAVING clause, and comparison operations are supported.
      • GROUP BY clause: UUID type fields can be used as grouping criteria for GROUP BY.

      Other supported UUID type functions:

      • UUID type field can be set as the table's primary key.
      • UUID type fields can be used as parameters of aggregation functions (such as max, min, and count).
      • UUID type data can be converted between string types.
      "},{"location":"MatrixOne/Reference/Data-Types/uuid-type/#examples","title":"Examples","text":"
      • Example 1:
      mysql> select uuid();\n+--------------------------------------+\n| uuid()                               |\n+--------------------------------------+\n| 4aa4f4de-1b00-11ee-b656-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
      • Example 2:
      drop table if exists t1;\n-- Create a new table 't1' with two columns 'a' and 'b', column 'a' is of type INT and column 'b' is of type float\ncreate table t1(a INT, b float);\n\n-- Insert two rows into table 't1'\ninsert into t1 values(12124, -4213.413), (12124, -42413.409);\n\n-- Query the number of rows in the 't1' table, and generate the length of the uuid() function of each row. Note that the uuid() function generates a new UUID here.\n-- does not depend on any data from the 't1' table, the returned length is 36 because the UUID is a 36 character string with 32 characters and 4 dashes\nmysql> SELECT length(uuid()) FROM t1;\n\n+----------------+\n|length(uuid())|\n+----------------+\n| 36 |\n| 36 |\n+----------------+\n2 rows in set (0.00 sec)\n
      • Example 3:
      -- Create a table named 't1' with a column named 'a' of data type VARCHAR with a maximum length of 20\ncreate table t1(a varchar(20));\n\n-- Insert a row of data in the 't1' table, the value of the 'a' column is '123123sdafsdf'\ninsert into t1 values('123123sdafsdf');\n\n-- Select all rows from table 't1' and return the value of column 'a' for each row, and a newly generated UUID value\nmysql> select uuid(), a from t1;\n+-------------------------------------+---------- -----+\n| uuid() | a |\n+-------------------------------------+---------- -----+\n| 664f1a96-1981-11ee-a041-5ad2460dea50 | 123123sdafsdf |\n+-------------------------------------+---------- -----+\n1 row in set (0.01 sec)\n
      • Example 4:
      -- Create a table named namelists with two fields, id and name\nCREATE TABLE namelists (\nid UUID DEFAULT uuid() PRIMARY KEY, -- the id field is of UUID type, and the default value is the UUID value generated by the uuid() function as the primary key\nname VARCHAR NOT NULL -- the name field is of type VARCHAR and cannot be empty\n);\nINSERT INTO namelists (name) VALUES ('Tom'), ('Jane'), ('Bob');\nmysql> select * from namelists;\n+--------------------------------------+--------+\n| id                                   | name   |\n+--------------------------------------+--------+\n| 61400e9c-1bbc-11ee-b512-5ad2460dea50 | Tom    |\n| 61400ea6-1bbc-11ee-b512-5ad2460dea50 | Jane   |\n| 61400ea6-1bbc-11ee-b513-5ad2460dea50 | Bob    |\n+--------------------------------------+--------+\n3 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/timestamp-initialization/","title":"Automatic Initialization and Updating for TIMESTAMP and DATETIME","text":"

      TIMESTAMP and DATETIME columns can be automatically initialized and updated to the current date and time (that is, the current timestamp).

      For any TIMESTAMP or DATETIME column in a table, you can assign the current timestamp as the default value, the auto-update value, or both:

      • An auto-initialized column is set to the current timestamp for inserted rows that specify no value for the column.

      • An auto-updated column is automatically updated to the current timestamp when the value of any other column in the row is changed from its current value. An auto-updated column remains unchanged if all other columns are set to their current values. To prevent an auto-updated column from updating when other columns change, explicitly set it to its current value. To update an auto-updated column even when other columns do not change, explicitly set it to the value it should have (for example, set it to CURRENT_TIMESTAMP).

      To specify automatic properties, use the DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP clauses in column definitions. The order of the clauses does not matter. If both are present in a column definition, either can occur first. Any of the synonyms for CURRENT_TIMESTAMP have the same meaning as CURRENT_TIMESTAMP. These are CURRENT_TIMESTAMP(), NOW().

      Use of DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP is specific to TIMESTAMP and DATETIME. The DEFAULT clause also can be used to specify a constant (nonautomatic) default value (for example, DEFAULT 0 or DEFAULT '2000-01-01 00:00:00').

      TIMESTAMP or DATETIME column definitions can specify the current timestamp for both the default and auto-update values, for one but not the other, or for neither. Different columns can have different combinations of automatic properties. The following rules describe the possibilities:

      • With both DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP, the column has the current timestamp for its default value and is automatically updated to the current timestamp.
      CREATE TABLE t1 (\n  ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n  dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n);\n
      • With a DEFAULT clause but no ON UPDATE CURRENT_TIMESTAMP clause, the column has the given default value and is not automatically updated to the current timestamp.

      The default depends on whether the DEFAULT clause specifies CURRENT_TIMESTAMP or a constant value. With CURRENT_TIMESTAMP, the default is the current timestamp.

      CREATE TABLE t1 (\n  ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  dt DATETIME DEFAULT CURRENT_TIMESTAMP\n);\n

      With a constant, the default is the given value. In this case, the column has no automatic properties at all.

      CREATE TABLE t1 (\n  ts TIMESTAMP DEFAULT 0,\n  dt DATETIME DEFAULT 0\n);\n
      • With an ON UPDATE CURRENT_TIMESTAMP clause and a constant DEFAULT clause, the column is automatically updated to the current timestamp and has the given constant default value.
      CREATE TABLE t1 (\n  ts TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP,\n  dt DATETIME DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP\n);\n
      • With an ON UPDATE CURRENT_TIMESTAMP clause but no DEFAULT clause, the column is automatically updated to the current timestamp but does not have the current timestamp for its default value.

      The default in this case is type dependent. TIMESTAMP has a default of 0 unless defined with the NULL attribute, in which case the default is NULL.

      CREATE TABLE t1 (\n  ts1 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,     -- default 0\n  ts2 TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP -- default NULL\n);\n

      DATETIME has a default of NULL unless defined with the NOT NULL attribute, in which case the default is 0.

      CREATE TABLE t1 (\n  dt1 DATETIME ON UPDATE CURRENT_TIMESTAMP,         -- default NULL\n  dt2 DATETIME NOT NULL ON UPDATE CURRENT_TIMESTAMP -- default 0\n);\n
      "},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/year-type/","title":"YEAR Type","text":"

      The YEAR type is a 1-byte data type used to represent year values. It can be declared as YEAR with an implicit display width of 4 characters or equivalently as YEAR(4) with an explicit display width of 4.

      MatrixOne displays YEAR values in the format YYYY, ranging from the year 0001 to 9999.

      YEAR accepts input values in various formats:

      • As 4-digit strings in the range '0001' to '9999'.
      • As 4-digit numbers in the range 0001 to 9999.
      • As 1- or 2-digit strings in the range '0' to '99'. For values in the range '0' to '00' and '00' to '99', MatrixOne automatically adds '00' as the prefix, resulting in values from '0000' to '0099'.
      • The result of functions that return a value acceptable in the context of YEAR, such as the NOW() function.
      "},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/year-type/#two-digit-years-in-dates","title":"Two-Digit Years in Dates","text":"

      Due to the lack of century information, two-digit years in dates need to be sufficiently clear. To ensure internal storage consistency, MatrixOne must interpret these date values as four-digit numbers.

      For DATETIME, DATE, and TIMESTAMP types, MatrixOne follows these rules to interpret dates with ambiguous year values:

      • Year values within the range 00-99 are converted to 0000-0099.

      Below are examples of dates involving two-digit years:

      1. Interpreting dates in DATETIME type:

      Let's assume we have a column named event_date with DATETIME type, containing the following date values:

      event_date 2023-07-12 08:30 99-01-15 13:45 23-05-06 09:00

      According to the rules, the two-digit year values in these dates are interpreted as:

      • 99-01-15 is interpreted as January 15th, 0099.
      • 23-05-06 is interpreted as May 6th, 0023.

      • Interpreting dates in DATE type:

      Let's assume we have a column named birth_date with DATE type containing the following date values:

      birth_date 95-08-21 04-11-30 88-03-17

      According to the rules, the two-digit year values in these dates are interpreted as:

      • 95-08-21 is interpreted as August 21st, 0095.
      • 04-11-30 is interpreted as November 30th, 0004.
      • 88-03-17 is interpreted as March 17th, 0088.

      • Interpreting dates in YEAR type:

      Let's assume we have a column named graduation_year with YEAR type containing the following year values:

      graduation_year 65 78 03

      According to the rules, the two-digit year values in these dates are interpreted as:

      • 65 is interpreted as the year 0065.
      • 78 is interpreted as the year 0078.
      • 03 is interpreted as the year 0003.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/","title":"Arithemetic Operators","text":"

      MatrixOne supports the basic arithmetic operators like Add, Subtract, Multiply, Divide on vector. These operator performs element-wise arithemetic operation and return a new vector.

      Note

      Sub(-), Multipy(*) and Divide(/) are all similar to the Add example.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#add","title":"Add","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#description","title":"Description","text":"

      This operator is used to add two vectors element-wise by using the + operator.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#syntax","title":"Syntax","text":"
      > SELECT vector1 + vector2 AS result_vector FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#examples","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select b + \"[1,2,3]\" from vec_table;\n+-------------+\n| b + [1,2,3] |\n+-------------+\n| [2, 4, 6]   |\n+-------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#constraints","title":"Constraints","text":"
      • Both the argument vectors should be of same dimension
      • If operation is performed between vecf32 and vecf64, the result is cast to vecf64
      • If one of the argument is VECTOR in textual format, then the other argument should be of VECTOR type. If both the arguments are TEXT, then Query Engine would treat it like string operation.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#divide","title":"Divide","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#description_1","title":"Description","text":"

      This operator is used to divide two vectors element-wise by using the / operator.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#syntax_1","title":"Syntax","text":"
      > SELECT vector1 / vector2 AS result_vector FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#examples_1","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select b/b from vec_table;\n+-----------+\n| b / b     |\n+-----------+\n| [1, 1, 1] |\n+-----------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/arithmetic/#constraints_1","title":"Constraints","text":"
      • If one of the element in denominator vector is zero, then it will throw Division By Zero error. -Both the argument vectors should be of same dimension
      • If operation is performed between vecf32 and vecf64, the result is cast to vecf64
      • If one of the argument is VECTOR in textual format, then the other argument should be of VECTOR type. If both the arguments are TEXT, then Query Engine would treat it like string operation.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/cosine_similarity/","title":"cosine_similarity()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/cosine_similarity/#description","title":"Description","text":"

      Cosine similarity measures the cosine of the angle between two vectors, indicating their similarity by how closely they align in a multi-dimensional space, with 1 denoting perfect similarity and -1 indicating perfect dissimilarity. Consine similarity is calculated by dividing Inner Product of two vectors, by the product of their l2 norms.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/cosine_similarity/#syntax","title":"Syntax","text":"
      > SELECT cosine_similarity(vector1, vector2) AS similarity FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/cosine_similarity/#examples","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select cosine_similarity(b,\"[1,2,3]\") from vec_table;\n+-------------------------------+\n| cosine_similarity(b, [1,2,3]) |\n+-------------------------------+\n|                             1 |\n+-------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/cosine_similarity/#constraints","title":"Constraints","text":"
      • Both the argument vectors should have same dimensions
      • Cosine similarity value lies between -1 and 1.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/inner_product/","title":"inner_product()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/inner_product/#description","title":"Description","text":"

      The INNER PRODUCT function is used to calculate the inner/dot product between two vectors, which is the result of multiplying corresponding elements of two vectors and then adding them together.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/inner_product/#syntax","title":"Syntax","text":"
      > SELECT inner_product(vector1, vector2) AS result FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/inner_product/#examples","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select inner_product(b,\"[1,2,3]\") from vec_table;\n+---------------------------+\n| inner_product(b, [1,2,3]) |\n+---------------------------+\n|                        14 |\n+---------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/inner_product/#constraints","title":"Constraints","text":"

      Both the argument vector shoulds be of same dimensions.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l1_norm/","title":"l1_norm()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l1_norm/#description","title":"Description","text":"

      The l1_norm function is used to calculate the L1/Manhattan/TaxiCab norm. The L1 norm is obtained by summing the absolute value of vector elements.

      You can use L1 Norm to calculate L1 Distance.

      l1_distance(a,b) = l1_norm(a-b)\n

      Same is appicable for calculating L2 distance from L2_Norm.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l1_norm/#syntax","title":"Syntax","text":"
      > SELECT l1_norm(vector) AS result FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l1_norm/#examples","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select l1_norm(b) from vec_table;\n+------------+\n| l1_norm(b) |\n+------------+\n|          6 |\n+------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l2_norm/","title":"l2_norm()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l2_norm/#description","title":"Description","text":"

      The l2_norm function is used to calculate the L2/Euclidean norm. The L2 norm is obtained by taking the square root of the sum of the squares of the vector elements.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l2_norm/#syntax","title":"Syntax","text":"
      > SELECT l2_norm(vector) AS result FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/l2_norm/#examples","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select l2_norm(b) from vec_table;\n+--------------------+\n| l2_norm(b)         |\n+--------------------+\n| 3.7416573867739413 |\n+--------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/","title":"Misc Function","text":"

      Other support functions on vector include.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#sqrt","title":"SQRT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#description","title":"Description","text":"

      The sqrt function is used to calculate the square root of each element in a vector.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#syntax","title":"Syntax","text":"
      > SELECT sqrt(vector_column) FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#return-type","title":"Return Type","text":"

      Return a new vector of type vecf64 containing the square root of each element in the original vector.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#examples","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select sqrt(b) from vec_table;\n+---------------------------------------------+\n| sqrt(b)                                     |\n+---------------------------------------------+\n| [1, 1.4142135623730951, 1.7320508075688772] |\n+---------------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#constraints","title":"Constraints","text":"
      • Elements of the vector cannot have -ve.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#abs","title":"ABS","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#description_1","title":"Description","text":"

      The abs function is used to calculate the absolute value of a vector.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#syntax_1","title":"Syntax","text":"
      > SELECT ABS(vector_column) FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#return-type_1","title":"Return Type","text":"

      Return a new vector of same type, containing the absolute values of each element in the original vector.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#examples_1","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[-1,-2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-------------+-----------+\n| a    | b           | c         |\n+------+-------------+-----------+\n|    1 | [-1, -2, 3] | [4, 5, 6] |\n+------+-------------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select abs(b) from vec_table;\n+-----------+\n| abs(b)    |\n+-----------+\n| [1, 2, 3] |\n+-----------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#cast","title":"CAST","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#description_2","title":"Description","text":"

      The cast function is used to explicitly convert vector from one vector type to another.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#syntax_2","title":"Syntax","text":"
      > SELECT CAST(vector AS vector_type) FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#arguments","title":"Arguments","text":"
      • vector: input vector
      • vector_type: new vector type
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#return-type_2","title":"Return Type","text":"

      The new vector_type vector.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#examples_2","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select b + cast(\"[1,2,3]\" as vecf32(3)) from vec_table;\n+--------------------------------+\n| b + cast([1,2,3] as vecf32(3)) |\n+--------------------------------+\n| [2, 4, 6]                      |\n+--------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#summation","title":"SUMMATION","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#description_3","title":"Description","text":"

      The summation function returns the sum of all the elements in a vector.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#syntax_3","title":"Syntax","text":"
      > SELECT SUMMATION(vector_column) FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#return-type_3","title":"Return Type","text":"

      Returns a FLOAT64 value, the sum of all the elements in the vector.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/misc/#examples_3","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select summation(b) from vec_table;\n+--------------+\n| summation(b) |\n+--------------+\n|            6 |\n+--------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/vector_dims/","title":"vector_dims()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/vector_dims/#description","title":"Description","text":"

      The vector_dims function is used to determine the dimension of a vector.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/vector_dims/#syntax","title":"Syntax","text":"
      > SELECT vector_dims(vector) AS dimension_count FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/1.1-Vector/vector_dims/#examples","title":"Examples","text":"
      drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\ninsert into vec_table values(2, \"[7,8,9]\", \"[1,2,3]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a    | b         | c         |\n+------+-----------+-----------+\n|    1 | [1, 2, 3] | [4, 5, 6] |\n|    2 | [7, 8, 9] | [1, 2, 3] |\n+------+-----------+-----------+\n2 row in set (0.00 sec)\n\nmysql> select vector_dims(b) from vec_table;\n+----------------+\n| vector_dims(b) |\n+----------------+\n|              3 |\n|              3 |\n+----------------+\n2 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/","title":"ANY_VALUE","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#description","title":"Description","text":"

      The ANY_VALUE function is useful for GROUP BY queries.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#syntax","title":"Syntax","text":"
      > ANY_VALUE(arg)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#arguments","title":"Arguments","text":"Arguments Description arg Any type. When arg is NULL, the line does not participate in the calculation."},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#returned-value","title":"Returned Value","text":"

      The function return value and type are the same as the return value and type of its argument.

      note

      The execution result of ANY_VALUE is uncertain. The same input may produce different execution results.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#examples","title":"Examples","text":"
      > create table t1(\n-> a int,\n-> b int,\n-> c int\n-> );\n> create table t2(\n-> a int,\n-> b int,\n-> c int\n-> );\n> insert into t1 values(1,10,34),(2,20,14);\n> insert into t2 values(1,-10,-45);\n> select ANY_VALUE(t1.b) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a;\n+-----------------+\n| any_value(t1.b) |\n+-----------------+\n|              10 |\n|              20 |\n+-----------------+\n2 rows in set (0.01 sec)\n> select 3+(5*ANY_VALUE(t1.b)) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a;\n+---------------------------+\n| 3 + (5 * any_value(t1.b)) |\n+---------------------------+\n|                        53 |\n|                       103 |\n+---------------------------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/","title":"AVG","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#description","title":"Description","text":"

      Aggregate function.

      The AVG() function calculates the average value of the argument.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#syntax","title":"Syntax","text":"
      > AVG(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#arguments","title":"Arguments","text":"Arguments Description expr Any numerical expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#returned-value","title":"Returned Value","text":"

      The arithmetic mean, always as Double.

      NaN if the input parameter is empty.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#examples","title":"Examples","text":"
      > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select avg(col_1c) from tbl1;\n+-------------+\n| avg(col_1c) |\n+-------------+\n|      3.5000 |\n+-------------+\n\n> select sum(col_1d) as s1,avg(col_1d) as a3 from tbl1 group by col_1e order by s1 desc;\n+------+---------+\n| s1   | a3      |\n+------+---------+\n|   21 | 10.5000 |\n|   18 |  9.0000 |\n|   10 | 10.0000 |\n|    8 |  8.0000 |\n+------+---------+\n\n> select avg(col_1d) as a1 from tbl1 where col_1d < 13 group by col_1e order by a1;\n+---------+\n| a1      |\n+---------+\n|  8.0000 |\n|  9.0000 |\n| 10.0000 |\n| 10.5000 |\n+---------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/","title":"BIT_AND","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#description","title":"Description","text":"

      Aggregate function.

      The BIT_AND(expr) function returns the bitwise AND of all bits in expr.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#syntax","title":"Syntax","text":"
      > BIT_AND(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#arguments","title":"Arguments","text":"Arguments Description expr UINT data types"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_AND(number) FROM t1 GROUP BY id;\n+------+-----------------+\n| id   | bit_and(number) |\n+------+-----------------+\n| a    |               0 |\n| b    |               1 |\n+------+-----------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/","title":"BIT_OR","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#description","title":"Description","text":"

      Aggregate function.

      The BIT_OR(expr) function returns the bitwise OR of all bits in expr.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#syntax","title":"Syntax","text":"
      > BIT_OR(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#arguments","title":"Arguments","text":"Arguments Description expr UINT data types"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_OR(number) FROM t1 GROUP BY id;\n+------+----------------+\n| id   | bit_or(number) |\n+------+----------------+\n| a    |            111 |\n| b    |             11 |\n+------+----------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/","title":"BIT_XOR","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#description","title":"Description","text":"

      Aggregate function.

      The BIT_XOR(expr) function returns the bitwise XOR of all bits in expr.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#syntax","title":"Syntax","text":"
      > BIT_XOR(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#arguments","title":"Arguments","text":"Arguments Description expr UINT data types"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_XOR(number) FROM t1 GROUP BY id;\n+------+-----------------+\n| id   | bit_xor(number) |\n+------+-----------------+\n| a    |             101 |\n| b    |              10 |\n+------+-----------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/","title":"COUNT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#description","title":"Description","text":"

      Aggregate function.

      The COUNT() function calculates the number of records returned by a select query.

      note

      NULL values are not counted.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#syntax","title":"Syntax","text":"
      > COUNT(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#arguments","title":"Arguments","text":"Arguments Description expr Any expression.This may be a column name, the result of another function, or a math operation. * is also allowed, to indicate pure row counting."},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#returned-value","title":"Returned Value","text":"

      Returns a count of the number of non-NULL values of expr in the rows retrieved by a SELECT statement. The result is a BIGINT value.

      If there are no matching rows, COUNT() returns 0.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#examples","title":"Examples","text":"
      > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select count(col_1b) from tbl1;\n+---------------+\n| count(col_1b) |\n+---------------+\n|             6 |\n+---------------+\n\n> select count(*) from tbl1 where col_1d<10;\n+----------+\n| count(*) |\n+----------+\n|        3 |\n+----------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/","title":"GROUP_CONCAT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#description","title":"Description","text":"

      This function returns a string result with the concatenated non-NULL values from a group. It returns NULL if there are no non-NULL values.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#syntax","title":"Syntax","text":"
      > GROUP_CONCAT(expr)\n

      The full syntax is as follows:

      GROUP_CONCAT([DISTINCT] expr [,expr ...]\n             [ORDER BY {unsigned_integer | col_name | expr}\n                 [ASC | DESC] [,col_name ...]]\n             [SEPARATOR str_val])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#arguments","title":"Arguments","text":"Arguments Description expr Required. It specifies one or more columns or expressions to join. DISTINCT Optional. To eliminate duplicate values. ORDER BY Optional. To sort values in the result. To sort in reverse order, add the DESC (descending) keyword to the name of the column you are sorting by in the ORDER BY clause. The default is ascending order; this may be specified explicitly using the ASC keyword. SEPARATOR Optional. The default separator between values in a group is comma (,)."},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#returned-value","title":"Returned Value","text":"

      The return value is a nonbinary or binary string, depending on whether the arguments are nonbinary or binary strings.

      It returns NULL if there are no non-NULL values.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#examples","title":"Examples","text":"
      create table t1(a int,b text,c text);\ninsert into t1 values(1,\"a\",\"bc\"),(2,\"ab\",\"c\"),(3,\"aa\",\"bb\"),(3,\"aa\",\"bb\");\n\nmysql> select group_concat(distinct a,b,c separator '|') from t1;\n+-----------------------------------+\n| group_concat(distinct a, b, c, |) |\n+-----------------------------------+\n| 1abc|2abc|3aabb                   |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select group_concat(distinct b,c separator '|') from t1 group by a;\n+--------------------------------+\n| group_concat(distinct b, c, |) |\n+--------------------------------+\n| abc                            |\n| abc                            |\n| aabb                           |\n+--------------------------------+\n3 rows in set (0.01 sec)\n\nmysql> select group_concat(distinct b,c separator '|') from t1;\n+--------------------------------+\n| group_concat(distinct b, c, |) |\n+--------------------------------+\n| abc|abc|aabb                   |\n+--------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/","title":"MAX","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#description","title":"Description","text":"

      Aggregate function.

      The MAX() function calculates the maximum value across a group of values.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#syntax","title":"Syntax","text":"
      > MAX(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#arguments","title":"Arguments","text":"Arguments Description expr Any expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#returned-value","title":"Returned Value","text":"

      Returns the maximum value of expr. MAX() may take a string argument, in such cases, it returns the maximum string value.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#examples","title":"Examples","text":"
      > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select max(col_1d) from tbl1;\n+-------------+\n| max(col_1d) |\n+-------------+\n|          12 |\n+-------------+\n\n> select max(col_1c) as m1 from tbl1 where col_1d<12 group by col_1e;\n+------+\n| m1   |\n+------+\n|    5 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/","title":"MEDIAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#description","title":"Description","text":"

      MEDIAN() returns the median value of a set of values, that is, returns the value in the middle after sorting a set of values. If the argument set contains an even number of values, the function returns the average of the two numbers in the middle. It can be used as an aggregate or analytical function.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#syntax","title":"Syntax","text":"
      > MEDIAN(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#arguments","title":"Arguments","text":"Arguments Description expr Required. Specify the name of the array whose median value is required, whose argument type is a numeric data type or can be implicitly converted to a numeric data type."},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#returned-value","title":"Returned Value","text":"

      The function return value and type are the same as the return value and type of its argument.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#examples","title":"Examples","text":"
      mysql> select median(null);\n+--------------+\n| median(null) |\n+--------------+\n|         NULL |\n+--------------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\ncreate table t1 (a int,b int);\ninsert into t1 values (1,null);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n|      NULL |\n+-----------+\n1 row in set (0.01 sec)\n\ninsert into t1 values (1,1);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n|         1 |\n+-----------+\n1 row in set (0.01 sec)\n\ninsert into t1 values (1,2);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n|       1.5 |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select median(b) from t1 group by a order by a;\n+-----------+\n| median(b) |\n+-----------+\n|       1.5 |\n+-----------+\n1 row in set (0.00 sec)\n\ninsert into t1 values (2,1),(2,2),(2,3),(2,4);\n\nmysql> select median(b) from t1 group by a order by a;\n+-----------+\n| median(b) |\n+-----------+\n|       1.5 |\n|       2.5 |\n+-----------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/","title":"MIN","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#description","title":"Description","text":"

      Aggregate function.

      The MAX() function calculates the maximum value across a group of values.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#syntax","title":"Syntax","text":"
      > MIN(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#arguments","title":"Arguments","text":"Arguments Description expr Any expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#returned-value","title":"Returned Value","text":"

      Returns the minimum value of expr. MIN() may take a string argument, in such cases, it returns the minimum string value.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#examples","title":"Examples","text":"
      > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select min(col_1d) from tbl1;\n+-------------+\n| min(col_1d) |\n+-------------+\n|           7 |\n+-------------+\n\n> select min(col_1c) as m1 from tbl1 where col_1d<12 group by col_1e;\n+------+\n| m1   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/","title":"STDDEV_POP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#description","title":"Description","text":"

      Aggregate function.

      The STDDEV_POP(expr) function returns the population standard deviation of expr.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#syntax","title":"Syntax","text":"
      > STDDEV_POP(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#arguments","title":"Arguments","text":"Arguments Description expr Any numerical expressions"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#examples","title":"Examples","text":"
      > CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\n> INSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ),  ('Mitchell Starc', 0, 3);\n> SELECT STDDEV_POP(RunScored) as Pop_Standard_Deviation FROM t1;\n> SELECT  STDDEV_POP(WicketsTaken) as Pop_Std_Dev_Wickets FROM t1;\n\n\n> SELECT STDDEV_POP(RunScored) as Pop_Standard_Deviation FROM t1;\n+------------------------+\n| Pop_Standard_Deviation |\n+------------------------+\n|                16.8762 |\n+------------------------+\n1 row in set (0.02 sec)\n\n> SELECT  STDDEV_POP(WicketsTaken) as Pop_Std_Dev_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Dev_Wickets |\n+---------------------+\n|              0.9574 |\n+---------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/","title":"SUM","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#description","title":"Description","text":"

      Aggregate function.

      The SUM() function calculates the sum of a set of values.

      note

      NULL values are not counted.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#syntax","title":"Syntax","text":"
      > SUM(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#arguments","title":"Arguments","text":"Arguments Description expr Any expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#returned-value","title":"Returned Value","text":"

      Returns the sum of expr. A double if the input type is double, otherwise integer.

      If there are no matching rows, SUM() returns NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#examples","title":"Examples","text":"
      • Example 1:
      > drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select sum(col_1c) from tbl1;\n+-------------+\n| sum(col_1c) |\n+-------------+\n|          21 |\n+-------------+\n\n> select sum(col_1d) as c1 from tbl1 where col_1d < 13 group by col_1e order by c1;\n+------+\n| c1   |\n+------+\n|    8 |\n|   10 |\n|   18 |\n|   21 |\n+------+\n
      • Example 2:
      > CREATE TABLE t1(a varchar(255), b INT, c INT UNSIGNED, d DECIMAL(12,2), e REAL);\n> INSERT INTO t1 VALUES('iynfj', 1, 1, 1, 1);\n> INSERT INTO t1 VALUES('innfj', 2, 2, 2, 2);\n> SELECT SUM( DISTINCT b ) FROM t1 GROUP BY b;\n+-----------------+\n| sum(distinct b) |\n+-----------------+\n|               1 |\n|               2 |\n+-----------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/","title":"VARIANCE","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#description","title":"Description","text":"

      The VARIANCE(expr) function returns the population standard variance of expr. Variance is an essential concept in statistics, which is used to measure the degree of dispersion of a set of data values, that is, the difference between the data value and its mean value. If the variance value is large, the difference between the data values \u200b\u200bis large; conversely, if the variance value is small, the difference between the data values \u200b\u200bis slight.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#syntax","title":"Syntax","text":"
      > VARIANCE(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#arguments","title":"Arguments","text":"Arguments Description expr Any numerical expressions"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#examples","title":"Examples","text":"
      CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\nINSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ),  ('Mitchell Starc', 0, 3);\n\n-- Calculate the variance of the RunScored column\n> SELECT VARIANCE(RunScored) as Pop_Standard_Variance FROM t1;\n+-----------------------+\n| Pop_Standard_Variance |\n+-----------------------+\n|     284.8055555555555 |\n+-----------------------+\n1 row in set (0.01 sec)\n\n-- Calculate the variance of the WicketsTaken column\nmysql> SELECT VARIANCE(WicketsTaken) as Pop_Std_Var_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Var_Wickets |\n+---------------------+\n|  0.9166666666666665 |\n+---------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/","title":"CURDATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#description","title":"Description","text":"

      The CURDATE() function returns the current date as a value in YYYY-MM-DD format, depending on whether the function is used in string or numeric context.

      Note

      The difference from MySQL's behavior is: curdate()+int returns the number of days from 1970-01-01. For example, curdate()+1 means the current date minus 1970-01-01 plus 1 day.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#syntax","title":"Syntax","text":"
      > CURDATE()\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#examples","title":"Examples","text":"
      mysql> SELECT CURDATE();\n+------------+\n| curdate()  |\n+------------+\n| 2023-02-02 |\n+------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT CURDATE() + 0;\n+---------------+\n| curdate() + 0 |\n+---------------+\n|         19390 |\n+---------------+\n1 row in set (0.00 sec)\n\nmysql> select cast(now() as date)=curdate() q;\n+------+\n| q    |\n+------+\n| true |\n+------+\n1 row in set (0.01 sec)\n\ncreate table t1 (a int);\ninsert into t1 values (1),(2),(3);\n\nmysql> select cast(now() as date)=curdate() q from t1;\n+------+\n| q    |\n+------+\n| true |\n| true |\n| true |\n+------+\n3 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/","title":"CURRENT_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#description","title":"Description","text":"

      CURRENT_TIMESTAMP and CURRENT_TIMESTAMP() are synonyms for NOW().

      Returns the current date and time as a value in YYYY-MM-DD hh:mm:ss or YYYYMMDDhhmmss format, depending on whether the function is used in string or numeric context. The value is expressed in the session time zone.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#syntax","title":"Syntax","text":"
      > CURRENT_TIMESTAMP([fsp])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#arguments","title":"Arguments","text":"Arguments Description fsp Optional. If the fsp argument is given to specify a fractional seconds precision from 0 to 6, the return value includes a fractional seconds part of that many digits."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#examples","title":"Examples","text":"
      mysql> SELECT CURRENT_TIMESTAMP();\n+----------------------------+\n| current_timestamp()        |\n+----------------------------+\n| 2022-09-21 11:46:44.153777 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT NOW();\n+----------------------------+\n| now()                      |\n+----------------------------+\n| 2022-09-21 12:56:36.915961 |\n+----------------------------+\n1 row in set (0.01 sec)\n
      create table t1 (a int primary key, b int, c int, d timestamp default current_timestamp);\ninsert into t1 select 1,1,1,now();\ninsert into t1 select 2,0,0,null;\n\nmysql> select a,b,c,year(d) from t1;\n+------+------+------+---------+\n| a    | b    | c    | year(d) |\n+------+------+------+---------+\n|    1 |    1 |    1 |    2022 |\n|    2 |    0 |    0 |    NULL |\n+------+------+------+---------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#constraints","title":"Constraints","text":"

      Operator + or - is not supported for using with CURRENT_TIMESTAMP now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/","title":"DATE_ADD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#description","title":"Description","text":"

      The DATE_ADD() function adds a time/date interval to a date and then returns the date. If date is NULL, the function returns NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#syntax","title":"Syntax","text":"
      > DATE_ADD(date,INTERVAL expr unit)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the date from. expr Required. The expr is an expression specifying the interval value to be added or subtracted from the starting date. The expr is evaluated as a string; it may start with a - for negative intervals. unit Required. The unit is a keyword indicating the units in which the expression should be interpreted. The unit argument can have the following values:MICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#examples","title":"Examples","text":"
      create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT OrderId,DATE_ADD(OrderDate,INTERVAL 45 DAY) AS OrderPayDate FROM t2;\n+---------+---------------------+\n| orderid | orderpaydate        |\n+---------+---------------------+\n|       1 | 2008-12-26 13:23:45 |\n+---------+---------------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#constraints","title":"Constraints","text":"

      The date type supports only yyyy-mm-dd and yyyymmdd for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/","title":"DATE_FORMAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#description","title":"Description","text":"

      Formats the date value according to the format string. If either argument is NULL, the function returns NULL.

      DATE_FORMAT() returns a string with a character set and collation given by character_set_connection and collation_connection so that it can return month and weekday names containing non-ASCII characters.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#syntax","title":"Syntax","text":"
      > DATE_FORMAT(date,format)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#arguments","title":"Arguments","text":"Arguments Description date Required. The date to be formatted. format Required. The format to use. Can be one or a combination of the following values as the below table:"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#format-specifier","title":"Format Specifier","text":"

      Info

      The specifiers shown in the following table may be used in the format string. The % character is required before format specifier characters. The specifiers apply to other functions as well as UNIX_TIMESTAMP().

      Specifier Description %a Abbreviated weekday name (Sun..Sat) %b Abbreviated month name (Jan..Dec) %c Month, numeric (0..12) %D Day of the month with English suffix (0th, 1st, 2nd, 3rd, \u2026) %d Day of the month, numeric (00..31) %e Day of the month, numeric (0..31) %f Microseconds (000000..999999) %H Hour (00..23) %h Hour (01..12) %I Hour (01..12) %i Minutes, numeric (00..59) %j Day of year (001..366) %k Hour (0..23) %l Hour (1..12) %M Month name (January..December) %m Month, numeric (00..12) %p AM or PM %r Time, 12-hour (hh:mm:ss followed by AM or PM) %S Seconds (00..59) %s Seconds (00..59) %T Time, 24-hour (hh:mm:ss) %U Week (00..53), where Sunday is the first day of the week; WEEK() mode 0 %u Week (00..53), where Monday is the first day of the week; WEEK() mode 1 %V Week (01..53), where Sunday is the first day of the week; WEEK() mode 2; used with %X %v Week (01..53), where Monday is the first day of the week; WEEK() mode 3; used with %x %W Weekday name (Sunday..Saturday) %w Day of the week (0=Sunday..6=Saturday) %X Year for the week where Sunday is the first day of the week, numeric, four digits; used with %V %x Year for the week, where Monday is the first day of the week, numeric, four digits; used with %v %Y Year, numeric, four digits %y Year, numeric (two digits) %% A literal % character %x x, for any \"x\" not listed above"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#examples","title":"Examples","text":"
      mysql> SELECT DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y');\n+--------------------------------------------+\n| date_format(2009-10-04 22:23:00, %W %M %Y) |\n+--------------------------------------------+\n| Sunday October 2009                        |\n+--------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('2007-10-04 22:23:00', '%H:%i:%s');\n+--------------------------------------------+\n| date_format(2007-10-04 22:23:00, %H:%i:%s) |\n+--------------------------------------------+\n| 22:23:00                                   |\n+--------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT Date_format('1900-10-04 22:23:00', '%D %y %a %d %m %b %j');\n+--------------------------------------------------------+\n| date_format(1900-10-04 22:23:00, %D %y %a %d %m %b %j) |\n+--------------------------------------------------------+\n| 4th 00 Thu 04 10 Oct 277                               |\n+--------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('1997-10-04 22:23:00', '%H %k %I %r %T %S %w');\n+--------------------------------------------------------+\n| date_format(1997-10-04 22:23:00, %H %k %I %r %T %S %w) |\n+--------------------------------------------------------+\n| 22 22 10 10:23:00 PM 22:23:00 00 6                     |\n+--------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('1999-01-01', '%X %V');\n+--------------------------------+\n| date_format(1999-01-01, %X %V) |\n+--------------------------------+\n| 1998 52                        |\n+--------------------------------+\n1 row in set (0.00 sec)\n
      CREATE TABLE t2 (f1 DATETIME);\nINSERT INTO t2 (f1) VALUES ('2005-01-01');\nINSERT INTO t2 (f1) VALUES ('2005-02-01');\n\nmysql> SELECT Date_format(f1, \"%m\") AS d1,\nDate_format(f1, \"%m\") AS d2\nFROM   t2\nORDER  BY Date_format(f1, \"%m\");\n+------+------+\n| d1   | d2   |\n+------+------+\n| 01   | 01   |\n| 02   | 02   |\n+------+------+\n2 rows in set (0.00 sec)\n
      CREATE TABLE t5 (a int, b date);\nINSERT INTO t5\nVALUES    (1,\n'2000-02-05'),\n(2,\n'2000-10-08'),\n(3,\n'2005-01-03'),\n(4,\n'2007-09-01'),\n(5,\n'2022-01-01');\n\nmysql> SELECT * FROM   t5\nWHERE  b = Date_format('20000205', '%Y-%m-%d');\n+------+------------+\n| a    | b          |\n+------+------------+\n|    1 | 2000-02-05 |\n+------+------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT * FROM t5\nWHERE  b != Date_format('20000205', '%Y-%m-%d');\n+------+------------+\n| a    | b          |\n+------+------------+\n|    2 | 2000-10-08 |\n|    3 | 2005-01-03 |\n|    4 | 2007-09-01 |\n|    5 | 2022-01-01 |\n+------+------------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT(\"2009-01-01\",'%W %d %M %Y') as valid_date;\n+--------------------------+\n| valid_date               |\n+--------------------------+\n| Thursday 01 January 2009 |\n+--------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#constraints","title":"Constraints","text":"

      The date type supports only yyyy-mm-dd and yyyymmdd for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/","title":"DATE_SUB()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#description","title":"Description","text":"

      The DATE_SUB() function subtracts a time/date interval from a date and then returns the date. If date is NULL, the function returns NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#syntax","title":"Syntax","text":"
      DATE_SUB(date,INTERVAL expr unit)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the date from. expr Required. The expr is an expression specifying the interval value to be added or subtracted from the starting date. The expr is evaluated as a string; it may start with a - for negative intervals. unit Required. The unit is a keyword indicating the units in which the expression should be interpreted. The unit argument can have the following values:MICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#examples","title":"Examples","text":"
      create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT OrderId,DATE_SUB(OrderDate,INTERVAL 5 DAY) AS SubtractDate FROM t2;\n+---------+---------------------+\n| orderid | subtractdate        |\n+---------+---------------------+\n|       1 | 2008-11-06 13:23:45 |\n+---------+---------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#constraints","title":"Constraints","text":"

      The date type supports only yyyy-mm-dd and yyyymmdd for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/","title":"DATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#description","title":"Description","text":"

      Extracts the date part of the date or datetime expression expr.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#syntax","title":"Syntax","text":"
      > DATE(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#arguments","title":"Arguments","text":"Arguments Description expr Required. The date/datetime to extract the date from."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a date, b datetime);\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01');\ninsert into t1 values(20220101,'2022-01-01 01:01:01');\ninsert into t1 values('2022-01-02','2022-01-02 23:01:01');\ninsert into t1 values('2021-12-31','2021-12-30 23:59:59');\ninsert into t1 values('2022-06-30','2021-12-30 23:59:59');\n\nmysql> select date(a),date(b) from t1;\n+------------+------------+\n| date(a)    | date(b)    |\n+------------+------------+\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-02 | 2022-01-02 |\n| 2021-12-31 | 2021-12-30 |\n| 2022-06-30 | 2021-12-30 |\n+------------+------------+\n5 rows in set (0.01 sec)\n\nmysql> select date(a),date(date(a)) as dda from t1;\n+------------+------------+\n| date(a)    | dda        |\n+------------+------------+\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-02 | 2022-01-02 |\n| 2021-12-31 | 2021-12-31 |\n| 2022-06-30 | 2022-06-30 |\n+------------+------------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#constraints","title":"Constraints","text":"

      The date type supports only yyyy-mm-dd and yyyymmdd for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/","title":"DATEDIFF()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#description","title":"Description","text":"

      DATEDIFF() returns expr1 \u2212 expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#syntax","title":"Syntax","text":"
      > DATEDIFF(expr1,expr2)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#arguments","title":"Arguments","text":"Arguments Description expr1,expr2 Required. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#examples","title":"Examples","text":"
      mysql> SELECT DATEDIFF('2007-12-31 23:59:59','2007-12-30');\n+-------------------------------------------+\n| datediff(2007-12-31 23:59:59, 2007-12-30) |\n+-------------------------------------------+\n|                                         1 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATEDIFF('2010-11-30 23:59:59','2010-12-31');\n+-------------------------------------------+\n| datediff(2010-11-30 23:59:59, 2010-12-31) |\n+-------------------------------------------+\n|                                       -31 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n
      create table t1(a INT,  b date);\ninsert into t1 values(1, \"2012-10-11\");\ninsert into t1 values(2, \"2004-04-24\");\ninsert into t1 values(3, \"2008-12-04\");\ninsert into t1 values(4, \"2012-03-23\");\ninsert into t1 values(5, \"2000-03-23\");\ninsert into t1 values(6, \"2030-03-23\");\ninsert into t1 values(7, \"2040-03-23\");\n\nmysql> SELECT a, DATEDIFF('2022-10-9', b) from t1;\n+------+------------------------+\n| a    | datediff(2022-10-9, b) |\n+------+------------------------+\n|    1 |                   3650 |\n|    2 |                   6742 |\n|    3 |                   5057 |\n|    4 |                   3852 |\n|    5 |                   8235 |\n|    6 |                  -2722 |\n|    7 |                  -6375 |\n+------+------------------------+\n7 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/","title":"DAY()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#description","title":"Description","text":"

      Returns the day of the month for date, in the range 1 to 31, or 0 for dates such as 0000-00-00 or 2008-00-00 that have a zero day part. Returns NULL if date is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#syntax","title":"Syntax","text":"
      > DAY(date)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the date from."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#examples","title":"Examples","text":"
      mysql> SELECT day('2007-02-03');\n+-----------------+\n| day(2007-02-03) |\n+-----------------+\n|               3 |\n+-----------------+\n1 row in set (0.01 sec)\n
      CREATE TABLE t3(c1 TIMESTAMP NOT NULL);\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('1999-12-31');\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('2006-12-25');\nINSERT INTO t3 VALUES('2008-02-29');\n\nmysql> SELECT day(c1) from t3;\n+---------+\n| day(c1) |\n+---------+\n|       1 |\n|      31 |\n|       1 |\n|      25 |\n|      29 |\n+---------+\n5 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/","title":"DAYOFYEAR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#description","title":"Description","text":"

      Returns the day of the year for date, in the range 1 to 366.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#syntax","title":"Syntax","text":"
      > DAYOFYEAR(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#arguments","title":"Arguments","text":"Arguments Description expr Required. The date to get the day from. Must be date type."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a date, b datetime,c varchar(30));\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01','2022-01-01 01:01:01');\ninsert into t1 values(20220101,'2022-01-01 01:01:01','2022-13-13 01:01:01');\ninsert into t1 values('2022-01-02','2022-01-02 23:01:01','2022-01-01 23:01:01');\ninsert into t1 values('2021-12-31','2021-12-30 23:59:59','2021-12-30 23:59:59');\ninsert into t1 values('2022-06-30','2021-12-30 23:59:59','2021-12-30 23:59:59');\n\nmysql> select distinct dayofyear(a) as dya from t1;\n+------+\n| dya  |\n+------+\n|    1 |\n|    2 |\n|  365 |\n|  181 |\n+------+\n4 rows in set (0.00 sec)\n\nmysql> select * from t1 where dayofyear(a)>120;\n+------------+---------------------+---------------------+\n| a          | b                   | c                   |\n+------------+---------------------+---------------------+\n| 2021-12-31 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n| 2022-06-30 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n+------------+---------------------+---------------------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t1 where dayofyear(a) between 1 and 184;\n+------------+---------------------+---------------------+\n| a          | b                   | c                   |\n+------------+---------------------+---------------------+\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-01-01 01:01:01 |\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-01-01 01:01:01 |\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-13-13 01:01:01 |\n| 2022-01-02 | 2022-01-02 23:01:01 | 2022-01-01 23:01:01 |\n| 2022-06-30 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n+------------+---------------------+---------------------+\n4 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#constraints","title":"Constraints","text":"
      • DAYOFYEAR() only supports date type for now.
      • The date type supports only yyyy-mm-dd and yyyymmdd for now.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/","title":"EXTRACT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#description","title":"Description","text":"

      The EXTRACT() function uses the same kinds of unit specifiers as DATE_ADD() or DATE_SUB(), but extracts parts from the date rather than performing date arithmetic. Returns NULL if date is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#syntax","title":"Syntax","text":"
      > EXTRACT(unit FROM date)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the date from. unit Required. The unit argument can have the following values:MICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#examples","title":"Examples","text":"
      create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT EXTRACT(YEAR FROM OrderDate) AS OrderYear, EXTRACT(MONTH FROM OrderDate) AS OrderMonth   FROM t2 WHERE OrderId=1;\n+-----------+------------+\n| orderyear | ordermonth |\n+-----------+------------+\n| 2008      | 11         |\n+-----------+------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#constraints","title":"Constraints","text":"

      The date type supports only yyyy-mm-dd and yyyymmdd for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/","title":"FROM_UNIXTIME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#description","title":"Description","text":"

      The FROM_UNIXTIME() function returns a representation of unix_timestamp as a datetime or character string value. The value returned is expressed using the session time zone. For example, the return value is in 'YYYYY-MM-DD HH:MM:SS' format or YYYYMMDDHHMMSS. unix_timestamp is an internal timestamp value representing seconds since 1970-01-01 00:00:00 UTC, such as produced by the UNIX_TIMESTAMP() function.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#syntax","title":"Syntax","text":"
      > FROM_UNIXTIME(unix_timestamp[,format])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#arguments","title":"Arguments","text":"Arguments Description format Optional. A format string indicating the format of the return value. If the format is omitted, this function returns a DATETIME value. If the format is NULL, this function returns NULL.format is used to format the result in the same way as the format string used for the DATE_FORMAT() function. If format is supplied, the value returned is a VARCHAR. unix_timestamp Required. If the unix_timestamp is NULL, this function returns NULL. If the unix_timestamp is an integer, the fractional seconds precision of the DATETIME is zero. When unix_timestamp is a decimal value, the fractional seconds precision of the DATETIME is the same as the precision of the decimal value, up to a maximum of 6. When unix_timestamp is a floating point number, the fractional seconds precision of the datetime is 6."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#examples","title":"Examples","text":"
      mysql> SELECT FROM_UNIXTIME(1447430881);\n+---------------------------+\n| from_unixtime(1447430881) |\n+---------------------------+\n| 2015-11-14 00:08:01       |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FROM_UNIXTIME(1447430881,  '%Y %D %M %h:%i:%s %x');\n+-------------------------------------------------+\n| from_unixtime(1447430881, %Y %D %M %h:%i:%s %x) |\n+-------------------------------------------------+\n| 2015 14th November 12:08:01 2015                |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#constraints","title":"Constraints","text":"

      The date type supports only yyyy-mm-dd and yyyymmdd for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/","title":"HOUR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#description","title":"Description","text":"

      Returns the hour for time. The range of the return value is 0 to 23 for time-of-day values. However, the range of TIME values actually is much larger, so HOUR can return values greater than 23. Returns NULL if time is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#syntax","title":"Syntax","text":"
      > HOUR(time)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#arguments","title":"Arguments","text":"Arguments Description time Required. A value that represents time or timestamp."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select hour(a),hour(b) from t1;\n+---------+---------+\n| hour(a) | hour(b) |\n+---------+---------+\n|       0 |      12 |\n|      12 |       0 |\n|    NULL |      23 |\n|       0 |    NULL |\n|      14 |       0 |\n|       0 |      12 |\n|       0 |       0 |\n+---------+---------+\n7 rows in set (0.00 sec)\n\nmysql> select * from t1 where hour(a)>hour(b);\n+---------------------+---------------------+\n| a                   | b                   |\n+---------------------+---------------------+\n| 2011-01-31 12:32:11 | 1979-10-22 00:00:00 |\n| 2022-06-01 14:11:09 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/","title":"MINUTE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#description","title":"Description","text":"

      Returns the minute for time, in the range 0 to 59, or NULL if time is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#syntax","title":"Syntax","text":"
      > MINUTE(time)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#arguments","title":"Arguments","text":"Arguments Description time Required. A value that represents time or timestamp."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#examples","title":"Examples","text":"
      • Example 1:
      mysql> SELECT MINUTE('2008-02-03 10:05:03');\n+-----------------------------+\n| minute(2008-02-03 10:05:03) |\n+-----------------------------+\n|                           5 |\n+-----------------------------+\n1 row in set (0.00 sec)\n
      • Example 2:
      drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select minute(a),minute(b) from t1;\n+-----------+-----------+\n| minute(a) | minute(b) |\n+-----------+-----------+\n|         0 |         0 |\n|        32 |         0 |\n|      NULL |        10 |\n|         0 |      NULL |\n|        11 |         0 |\n|         0 |         0 |\n|         0 |         0 |\n+-----------+-----------+\n7 rows in set (0.00 sec)\n\nmysql> select * from t1 where minute(a)<=minute(b);\n+---------------------+---------------------+\n| a                   | b                   |\n+---------------------+---------------------+\n| 2022-07-01 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-12-31 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-06-12 00:00:00 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n3 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/","title":"MONTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#description","title":"Description","text":"

      Returns the month for date, in the range 1 to 12 for January to December, or 0 for dates such as '0000-00-00' or '2008-00-00' that have a zero month part. Returns NULL if date is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#syntax","title":"Syntax","text":"
      > MONTH(date)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#arguments","title":"Arguments","text":"Arguments Description date Required. The date to be formatted."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#examples","title":"Examples","text":"
      • Example 1:
      mysql> SELECT MONTH('2008-02-03');\n+-------------------+\n| month(2008-02-03) |\n+-------------------+\n|                 2 |\n+-------------------+\n1 row in set (0.02 sec)\n
      • Example 2:
      drop table if exists t1;\ncreate table t1 (id int,d date, dt datetime,c char(10),vc varchar(20));\ninsert into t1 values (1,\"2021-01-13\", \"2021-01-13 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (1,\"2021-01-31\", \"2021-01-31 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (2,\"2022-02-15\", \"2022-02-15 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (2,\"2022-02-28\", \"2022-02-28 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (3,\"2000-02-29\", \"2000-02-29 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (4,\"2023-03-17\", \"2021-02-17 23:54:59\", \"2021-03-17\", \"2021-03-17\");\ninsert into t1 values (5,\"1985-04-18\", \"1985-04-18 00:00:01\", \"1985-04-18\", \"1985-04-18\");\ninsert into t1 values (6,\"1987-05-20\", \"1987-05-20 22:59:59\", \"1987-05-20\", \"1987-05-20\");\ninsert into t1 values (7,\"1989-06-22\", \"1989-06-22 15:00:30\", \"1989-06-22\", \"1989-06-22\");\ninsert into t1 values (8,\"1993-07-25\", \"1987-07-25 03:04:59\", \"1993-07-25\", \"1993-07-25\");\ninsert into t1 values (9,\"1995-08-27\", \"1987-08-27 04:32:33\", \"1995-08-27\", \"1995-08-27\");\ninsert into t1 values (10,\"1999-09-30\", \"1999-09-30 10:11:12\", \"1999-09-30\", \"1999-09-30\");\ninsert into t1 values (11,\"2005-10-30\", \"2005-10-30 18:18:59\", \"2005-10-30\", \"2005-10-30\");\ninsert into t1 values (12,\"2008-11-30\", \"2008-11-30 22:59:59\", \"2008-11-30\", \"2008-11-30\");\ninsert into t1 values (13,\"2013-12-01\", \"2013-12-01 22:59:59\", \"2013-12-01\", \"2013-12-01\");\ninsert into t1 values (14,null, null, null, null);\n\nmysql> select month(d),month(dt) from t1;\n+----------+-----------+\n| month(d) | month(dt) |\n+----------+-----------+\n|        1 |         1 |\n|        1 |         1 |\n|        2 |         2 |\n|        2 |         2 |\n|        2 |         2 |\n|        3 |         2 |\n|        4 |         4 |\n|        5 |         5 |\n|        6 |         6 |\n|        7 |         7 |\n|        8 |         8 |\n|        9 |         9 |\n|       10 |        10 |\n|       11 |        11 |\n|       12 |        12 |\n|     NULL |      NULL |\n+----------+-----------+\n16 rows in set (0.01 sec)\n\nmysql> select month(c),month(vc) from t1;\n+----------+-----------+\n| month(c) | month(vc) |\n+----------+-----------+\n|       12 |        12 |\n|       12 |        12 |\n|        2 |         2 |\n|        2 |         2 |\n|        2 |         2 |\n|        3 |         3 |\n|        4 |         4 |\n|        5 |         5 |\n|        6 |         6 |\n|        7 |         7 |\n|        8 |         8 |\n|        9 |         9 |\n|       10 |        10 |\n|       11 |        11 |\n|       12 |        12 |\n|     NULL |      NULL |\n+----------+-----------+\n16 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/","title":"SECOND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#description","title":"Description","text":"

      Returns the second for time, in the range 0 to 59, or NULL if time is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#syntax","title":"Syntax","text":"
      > SECOND(time)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#arguments","title":"Arguments","text":"Arguments Description time Required. A value that represents time or timestamp."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select second(a),second(b) from t1;\n+-----------+-----------+\n| second(a) | second(b) |\n+-----------+-----------+\n|         0 |         0 |\n|        11 |         0 |\n|      NULL |        11 |\n|         0 |      NULL |\n|         9 |         0 |\n|         0 |         0 |\n|         0 |         0 |\n+-----------+-----------+\n7 rows in set (0.01 sec)\n\nmysql> select * from t1 where second(a)>=second(b);\n+---------------------+---------------------+\n| a                   | b                   |\n+---------------------+---------------------+\n| 2022-07-01 00:00:00 | 2011-01-31 12:00:00 |\n| 2011-01-31 12:32:11 | 1979-10-22 00:00:00 |\n| 2022-06-01 14:11:09 | 2022-07-01 00:00:00 |\n| 2022-12-31 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-06-12 00:00:00 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/","title":"TIME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#description","title":"Description","text":"

      Extracts the time part of the time or datetime expression expr and returns it as a string. Returns NULL if expr is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#syntax","title":"Syntax","text":"
      > TIME(expr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#arguments","title":"Arguments","text":"Arguments Description expr Required. The date/datetime to extract the time from."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#examples","title":"Examples","text":"
      mysql> SELECT TIME('2003-12-31 01:02:03');\n+---------------------------+\n| time(2003-12-31 01:02:03) |\n+---------------------------+\n| 01:02:03                  |\n+---------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/","title":"TIMEDIFF()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#description","title":"Description","text":"

      TIMEDIFF() returns expr1 \u2212 expr2 expressed as a time value.

      The result returned by TIMEDIFF() is limited to the range allowed for TIME values. Alternatively, you can use either of the functions TIMESTAMPDIFF() and UNIX_TIMESTAMP(), both of which return integers.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#syntax","title":"Syntax","text":"
      > TIMEDIFF(expr1,expr2)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#arguments","title":"Arguments","text":"Arguments Description expr1,expr2 Required. expr1 and expr2 are strings which are converted to TIME or DATETIME expressions; these must be of the same type following conversion. Returns NULL if expr1 or expr2 is NULL."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#examples","title":"Examples","text":"
      mysql> select timediff(\"22:22:22\", \"11:00:00\");\n+------------------------------+\n| timediff(22:22:22, 11:00:00) |\n+------------------------------+\n| 11:22:22.000000              |\n+------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select timediff(cast('22:22:22' as time), null);\n+--------------------------------------------+\n| timediff(cast(22:22:22 as time(26)), null) |\n+--------------------------------------------+\n| NULL                                       |\n+--------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select timediff(CAST('2017-08-08 22:22:22' as datetime), CAST('2000-01-02 11:00:00' as datetime));\n+------------------------------------------------------------------------------------------------+\n| timediff(cast(2017-08-08 22:22:22 as datetime(26)), cast(2000-01-02 11:00:00 as datetime(26))) |\n+------------------------------------------------------------------------------------------------+\n| 154283:22:22                                                                                   |\n+------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
      create table time_01(t1 time,t2 time,t3 time);\ninsert into time_01 values(\"-838:59:59.0000\",\"838:59:59.00\",\"22:00:00\");\ninsert into time_01 values(\"0:00:00.0000\",\"0\",\"0:00\");\ninsert into time_01 values(null,NULL,null);\ninsert into time_01 values(\"23\",\"1122\",\"-1122\");\ninsert into time_01 values(\"101412\",\"4\",\"-101219\");\ninsert into time_01 values(\"24:59:09.932823\",\"24:02:00.93282332424\",\"24:20:34.00000000\");\ninsert into time_01 values(\"2022-09-08 12:00:01\",\"019\",\"23403\");\n\nmysql> select * from time_01;\n+------------+-----------+-----------+\n| t1         | t2        | t3        |\n+------------+-----------+-----------+\n| -838:59:59 | 838:59:59 | 22:00:00  |\n| 00:00:00   | 00:00:00  | 00:00:00  |\n| NULL       | NULL      | NULL      |\n| 00:00:23   | 00:11:22  | -00:11:22 |\n| 10:14:12   | 00:00:04  | -10:12:19 |\n| 24:59:10   | 24:02:01  | 24:20:34  |\n| 12:00:01   | 00:00:19  | 02:34:03  |\n+------------+-----------+-----------+\n7 rows in set (0.00 sec)\n\nmysql> select timediff(t1,t2) from time_01;\n+------------------+\n| timediff(t1, t2) |\n+------------------+\n| -1677:59:58      |\n| 00:00:00         |\n| NULL             |\n| -00:10:59        |\n| 10:14:08         |\n| 00:57:09         |\n| 11:59:42         |\n+------------------+\n7 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/","title":"TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#description","title":"Description","text":"

      With a single argument, this function returns the date or datetime expression expr as a datetime value. With two arguments, it adds the time expression expr2 to the date or datetime expression expr1 and returns the result as a datetime value. Returns NULL if expr, expr1, or expr2 is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#syntax","title":"Syntax","text":"
      > TIMESTAMP(expr), TIMESTAMP(expr1,expr2)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#arguments","title":"Arguments","text":"Arguments Description expr Required. The expr is an expression specifying the interval value to be added or subtracted from the starting date. The expr is evaluated as a string; it may start with a - for negative intervals."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#examples","title":"Examples","text":"
      mysql> SELECT TIMESTAMP('2003-12-31');\n+----------------------------+\n| timestamp(2003-12-31)      |\n+----------------------------+\n| 2003-12-31 00:00:00.000000 |\n+----------------------------+\n1 row in set (0.00 sec)\n
      CREATE TABLE t1(c1 DATE NOT NULL);\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('1999-12-31');\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('2006-12-25');\nINSERT INTO t1 VALUES('2008-02-29');\n\nmysql> SELECT TIMESTAMP(c1) FROM t1;\n+----------------------------+\n| timestamp(c1)              |\n+----------------------------+\n| 2000-01-01 00:00:00.000000 |\n| 1999-12-31 00:00:00.000000 |\n| 2000-01-01 00:00:00.000000 |\n| 2006-12-25 00:00:00.000000 |\n| 2008-02-29 00:00:00.000000 |\n+----------------------------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#constraints","title":"Constraints","text":"

      TIMESTAMP() does not support double arguments for now, which means it doesn't support TIMESTAMP(expr1,expr2).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/","title":"TIMESTAMPDIFF()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#description","title":"Description","text":"

      Returns datetime_expr2 \u2212 datetime_expr1, where datetime_expr1 and datetime_expr2 are date or datetime expressions. One expression may be a date and the other a datetime; a date value is treated as a datetime having the time part '00:00:00' where necessary. The unit for the result (an integer) is given by the unit argument. The legal values for unit are the same as those listed in the description of the TIMESTAMPADD() function.

      This function returns NULL if datetime_expr1 or datetime_expr2 is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#syntax","title":"Syntax","text":"
      > TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#arguments","title":"Arguments","text":"Arguments Description unit is a string representing the unit of the time interval. This can be MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH or YEAR etc. datetime_expr1,datetime_expr2 Mandatory parameters. datetime_expr1 and datetime_expr2 expressions need to be of the same type. datetime_expr1 and datetime_expr2 are strings converted to TIME or DATETIME expressions. Returns NULL if datetime_expr1 or datetime_expr2 is NULL."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#examples","title":"Examples","text":"
      • Example 1:
      mysql> SELECT TIMESTAMPDIFF( MICROSECOND, '2017-12-01 12:15:12','2018-01-01 7:18:20');\n+---------------------------------------------------------------------+\n| timestampdiff(microsecond, 2017-12-01 12:15:12, 2018-01-01 7:18:20) |\n+---------------------------------------------------------------------+\n|                                                       2660588000000 |\n+---------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
      • Example 2:
      drop table if exists t1;\ncreate table t1(a date,  b date);\ninsert into t1 values('2019-11-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2019-10-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2020-10-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2021-11-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2022-01-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2018-01-01 12:15:12', '2019-11-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2019-10-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2020-10-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2021-11-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2022-01-01 12:15:12');\n\nmysql> SELECT a, b, TIMESTAMPDIFF(MICROSECOND, a, b) from t1;\n+------------+------------+----------------------------------+\n| a          | b          | timestampdiff(microsecond, a, b) |\n+------------+------------+----------------------------------+\n| 2019-11-01 | 2018-01-01 |                  -57801600000000 |\n| 2019-10-01 | 2018-01-01 |                  -55123200000000 |\n| 2020-10-01 | 2018-01-01 |                  -86745600000000 |\n| 2021-11-01 | 2018-01-01 |                 -120960000000000 |\n| 2022-01-01 | 2018-01-01 |                 -126230400000000 |\n| 2018-01-01 | 2019-11-01 |                   57801600000000 |\n| 2018-01-01 | 2019-10-01 |                   55123200000000 |\n| 2018-01-01 | 2020-10-01 |                   86745600000000 |\n| 2018-01-01 | 2021-11-01 |                  120960000000000 |\n| 2018-01-01 | 2022-01-01 |                  126230400000000 |\n+------------+------------+----------------------------------+\n10 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/","title":"TO_DATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#description","title":"Description","text":"

      TO_DATE() returns a DATETIME value if the format string contains both date and time parts, or a DATE or TIME value if the string contains only date or time parts.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#syntax","title":"Syntax","text":"
      > TO_DATE(str,format)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#arguments","title":"Arguments","text":"Arguments Description str Required. If the date, time, or datetime value extracted from str is illegal, STR_TO_DATE() returns NULL and produces a warning. If str is NULL, the function returns NULL. format Required. A format string indicating the format of the return value. If the format is omitted, this function returns a DATETIME value. If the format is NULL, this function returns NULL.If the format is supplied, the value returned is a VARCHAR.

      note

      The format string can contain literal characters and format specifiers beginning with %. Literal characters in format must match literally in str. Format specifiers in format must match a date or time part in str.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#examples","title":"Examples","text":"
      mysql> SELECT TO_DATE('2022-01-06 10:20:30','%Y-%m-%d %H:%i:%s') as result;\n+---------------------+\n| result              |\n+---------------------+\n| 2022-01-06 10:20:30 |\n+---------------------+\n1 row in set (0.00 sec)                 
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#constraints","title":"Constraints","text":"

      The date type supports only yyyy-mm-dd and yyyymmdd for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/","title":"TO_DAYS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#description","title":"Description","text":"

      TO_DAYS() is used to calculate the number of days between a given date and the start date of the Gregorian calendar (January 1, 0000). If the date is NULL, it returns NULL.

      Note

      The dates '0000-00-00' and '0000-01-01' are considered invalid. When querying 0000-00-00 and 0000-01-01, TO_DAYS() will return an error message:

      mysql> SELECT TO_DAYS('0000-00-00');\nERROR 20301 (HY000): invalid input: invalid datetime value 0000-00-00\nmysql> SELECT TO_DAYS('0000-01-01');\nERROR 20301 (HY000): invalid input: invalid datetime value 0000-01-01\n

      For dates with two-digit years, for example, when querying SELECT TO_DAYS('08-10-07');, MatrixOne automatically completes the year 08 to 0008, which is different from MySQL. For more information, see Two-Digit Years in Dates

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#syntax","title":"Syntax","text":"
      > TO_DAYS(date)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#examples","title":"Examples","text":"
      -- The query will return an integer representing the number of days between the date '2023-07-12' and the start date of the Gregorian calendar.\nmysql> SELECT TO_DAYS('2023-07-12');\n+---------------------+\n| to_days(2023-07-12) |\n+---------------------+\n|              739078 |\n+---------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_DAYS('2008-10-07'), TO_DAYS('08-10-07');\n+---------------------+-------------------+\n| to_days(2008-10-07) | to_days(08-10-07) |\n+---------------------+-------------------+\n|              733687 |              3202 |\n+---------------------+-------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/","title":"TO_SECONDS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/#description","title":"Description","text":"

      The TO_SECONDS(expr) function is used to calculate the number of seconds between a given date or datetime expr and the year 0, January 1, 00:00:00. If expr is NULL, it returns NULL.

      Note

      The dates 0000-00-00 and 0000-01-01 are considered invalid. MatrixOne year queries should start from 0001. When querying 0000-00-00 and 0000-01-01, TO_SECONDS() returns an error message:

      mysql> SELECT TO_SECONDS('0000-00-00');\nERROR 20301 (HY000): invalid input: invalid datetime value 0000-00-00\nmysql> SELECT TO_SECONDS('0000-01-01');\nERROR 20301 (HY000): invalid input: invalid datetime value 0000-01-01\n

      Similar to the TO_DAYS() function, for example, when querying SELECT TO_SECONDS('08-10-07');, MatrixOne automatically fills the year 08 to 0008, which is different from MySQL. For more information, see Two-Digit Years in Dates.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/#syntax","title":"Syntax","text":"
      > TO_SECONDS(expr)\n

      expr is a date or datetime value and can be of type DATETIME, DATE, or TIMESTAMP.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/#examples","title":"Examples","text":"
      mysql> SELECT TO_SECONDS('0001-01-01');\n+------------------------+\n| to_seconds(0001-01-01) |\n+------------------------+\n|               31622400 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('2023-07-12 08:30:00');\n+---------------------------------+\n| to_seconds(2023-07-12 08:30:00) |\n+---------------------------------+\n|                     63856369800 |\n+---------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('2007-10-07');\n+------------------------+\n| to_seconds(2007-10-07) |\n+------------------------+\n|            63358934400 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('97-10-07');\n+----------------------+\n| to_seconds(97-10-07) |\n+----------------------+\n|           3085257600 |\n+----------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/","title":"UNIX_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#description","title":"Description","text":"

      If UNIX_TIMESTAMP() is called with no date argument, it returns a Unix timestamp representing seconds since '1970-01-01 00:00:00' UTC.

      If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' UTC. The server interprets date as a value in the session time zone and converts it to an internal Unix timestamp value in UTC.

      If you pass an out-of-range date to UNIX_TIMESTAMP(), it returns 0. If date is NULL, it returns NULL.

      The return value is an integer if no argument is given or the argument does not include a fractional seconds part, or DECIMAL if an argument is given that includes a fractional seconds part.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#syntax","title":"Syntax","text":"
      > UNIX_TIMESTAMP([date])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#arguments","title":"Arguments","text":"Arguments Description date Optional. The date/datetime to extract the date from. The date argument may be a DATE, DATETIME, or TIMESTAMP string, or a number in YYMMDD, YYMMDDhhmmss, YYYYMMDD, or YYYYMMDDhhmmss format. If the argument includes a time part, it may optionally include a fractional seconds part. When the date argument is a TIMESTAMP column, UNIX_TIMESTAMP() returns the internal timestamp value directly, with no implicit string-to-Unix-timestamp conversion."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#convert-between-non-utc-time-zone-and-unix-timestamp-values","title":"Convert between non-UTC time zone and Unix timestamp values","text":"

      If you use UNIX_TIMESTAMP() and FROM_UNIXTIME() to convert between values in a non-UTC time zone and Unix timestamp values, the conversion is lossy because the mapping is not one-to-one in both directions. For example, due to conventions for local time zone changes such as Daylight Saving Time (DST), it is possible for UNIX_TIMESTAMP() to map two values that are distinct in a non-UTC time zone to the same Unix timestamp value. FROM_UNIXTIME() maps that value back to only one of the original values. Here is an example, using values that are distinct in the MET time zone:

      mysql> SET time_zone = 'MET';\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2005-03-27 03:00:00');\n+-------------------------------------+\n| unix_timestamp(2005-03-27 03:00:00) |\n+-------------------------------------+\n|                          1111885200 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2005-03-27 02:00:00');\n+-------------------------------------+\n| unix_timestamp(2005-03-27 02:00:00) |\n+-------------------------------------+\n|                          1111885200 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FROM_UNIXTIME(1111885200);\n+---------------------------+\n| from_unixtime(1111885200) |\n+---------------------------+\n| 2005-03-27 03:00:00       |\n+---------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#examples","title":"Examples","text":"
      mysql> SELECT UNIX_TIMESTAMP(\"2016-07-11\");\n+----------------------------+\n| unix_timestamp(2016-07-11) |\n+----------------------------+\n|                 1468188000 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2015-11-13 10:20:19');\n+-------------------------------------+\n| unix_timestamp(2015-11-13 10:20:19) |\n+-------------------------------------+\n|                          1447406419 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2015-11-13 10:20:19.012');\n+-----------------------------------------+\n| unix_timestamp(2015-11-13 10:20:19.012) |\n+-----------------------------------------+\n|                       1447406419.012000 |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#constraints","title":"Constraints","text":"

      The date type supports only yyyy-mm-dd and yyyymmdd for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/","title":"UTC_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#description","title":"Description","text":"

      Returns the current UTC date and time as a value in YYYY-MM-DD hh:mm:ss or YYYYMMDDhhmmss format, depending on whether the function is used in string or numeric context.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#syntax","title":"Syntax","text":"
      > UTC_TIMESTAMP, UTC_TIMESTAMP([fsp])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#arguments","title":"Arguments","text":"Arguments Description fsp Optional. If the fsp argument is given to specify a fractional seconds precision from 0 to 6, the return value includes a fractional seconds part of that many digits."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#examples","title":"Examples","text":"
      • Example 1:
      mysql> SELECT UTC_TIMESTAMP();\n+---------------------+\n| utc_timestamp()     |\n+---------------------+\n| 2022-09-16 03:37:40 |\n+---------------------+\n1 row in set (0.01 sec)\n\nmysql> select unix_timestamp(utc_timestamp());\n+---------------------------------+\n| unix_timestamp(utc_timestamp()) |\n+---------------------------------+\n|                      1663282842 |\n+---------------------------------+\n1 row in set (0.02 sec)\n
      • Example 2:
      create table t1 (ts timestamp);\nset time_zone='+00:00';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());\n+-------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(utc_timestamp()) |\n+-------------------------------------------------------------------+\n|                                                                 0 |\n+-------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\nset time_zone='+10:30';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());\n+-------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(utc_timestamp()) |\n+-------------------------------------------------------------------+\n|                                                                 0 |\n+-------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\nset time_zone='-10:00';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp());\n+-----------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(current_timestamp()) |\n+-----------------------------------------------------------------------+\n|                                                                 36000 |\n+-----------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\n\nmysql> select * from t1;\n+---------------------+\n| ts                  |\n+---------------------+\n| 2003-03-29 16:30:00 |\n| 2003-03-29 06:00:00 |\n| 2003-03-30 02:30:00 |\n+---------------------+\n3 rows in set (0.00 sec)\n
      • Example 3:
      DROP TABLE IF EXISTS t1;\nCREATE TABLE t1 (a TIMESTAMP);\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\n\nmysql> SELECT year(a) FROM t1 WHERE a > '2008-01-01';\n+---------+\n| year(a) |\n+---------+\n|    2022 |\n|    2022 |\n|    2022 |\n+---------+\n3 rows in set (0.04 sec)\n
      DROP TABLE if exists t1;\ncreate table t1 (a int primary key, b int, c int, d timestamp);\ninsert into t1 select 1,1,1,utc_timestamp();\ninsert into t1 select 2,0,0,null;\n\nmysql> select a,b,c,year(d) from t1;\n+------+------+------+---------+\n| a    | b    | c    | year(d) |\n+------+------+------+---------+\n|    1 |    1 |    1 |    2022 |\n|    2 |    0 |    0 |    NULL |\n+------+------+------+---------+\n2 rows in set (0.01 sec)\n
      DROP TABLE if exists t1;\nCREATE TABLE t1 (a TIMESTAMP);\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\n\nmysql> SELECT 1 FROM t1 ORDER BY 1;\n+------+\n| 1    |\n+------+\n|    1 |\n|    1 |\n+------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#constraints","title":"Constraints","text":"

      Operator + or - with parameters DATETIME BIGINT is not supported now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/","title":"WEEK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#description","title":"Description","text":"

      Used to calculate the week number for a given date. This function returns an integer representing the week number of the specified date. If date is NULL, return NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#syntax","title":"Syntax","text":"
      > WEEK(date)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#arguments","title":"Arguments","text":"Arguments Description date Required. date represents the date to calculate the week number. MatrixOne defaults the start day of the week to Monday, and the return value ranges from 0 to 53."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#examples","title":"Examples","text":"
      • Example 1:
      mysql> SELECT WEEK('2008-02-20');\n+------------------+\n| week(2008-02-20) |\n+------------------+\n|                8 |\n+------------------+\n1 row in set (0.01 sec)\n
      • Example 2:
      drop table if exists t1;\nCREATE TABLE t1(c1 DATETIME NOT NULL);\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('1999-12-31');\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('2006-12-25');\nINSERT INTO t1 VALUES('2008-02-29');\n\nmysql> SELECT WEEK(c1) FROM t1;\n+----------+\n| week(c1) |\n+----------+\n|       52 |\n|       52 |\n|       52 |\n|       52 |\n|        9 |\n+----------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#constraints","title":"Constraints","text":"

      The WEEK() function of MatrixOne only supports the date parameter, and does not support the optional parameter [, mode], which is different from MySQL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/","title":"WEEKDAY()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#description","title":"Description","text":"

      Returns the weekday index for date (0 = Monday, 1 = Tuesday, \u2026 6 = Sunday). Returns NULL if date is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#syntax","title":"Syntax","text":"
      > WEEKDAY(date)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#arguments","title":"Arguments","text":"Arguments Description date Required. The date to be formatted."},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#examples","title":"Examples","text":"
      • Example 1:
      mysql> SELECT WEEKDAY('2008-02-03 22:23:00');\n+------------------------------+\n| weekday(2008-02-03 22:23:00) |\n+------------------------------+\n|                            6 |\n+------------------------------+\n1 row in set (0.03 sec)\n
      • Example 2:
      drop table if exists t1;\ncreate table t1 (id int,d date, dt datetime,c char(10),vc varchar(20));\ninsert into t1 values (1,\"2021-01-13\", \"2021-01-13 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (1,\"2021-01-31\", \"2021-01-31 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (2,\"2022-02-15\", \"2022-02-15 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (2,\"2022-02-28\", \"2022-02-28 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (3,\"2000-02-29\", \"2000-02-29 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (4,\"2023-03-17\", \"2021-02-17 23:54:59\", \"2021-03-17\", \"2021-03-17\");\ninsert into t1 values (5,\"1985-04-18\", \"1985-04-18 00:00:01\", \"1985-04-18\", \"1985-04-18\");\ninsert into t1 values (6,\"1987-05-20\", \"1987-05-20 22:59:59\", \"1987-05-20\", \"1987-05-20\");\ninsert into t1 values (7,\"1989-06-22\", \"1989-06-22 15:00:30\", \"1989-06-22\", \"1989-06-22\");\ninsert into t1 values (8,\"1993-07-25\", \"1987-07-25 03:04:59\", \"1993-07-25\", \"1993-07-25\");\ninsert into t1 values (9,\"1995-08-27\", \"1987-08-27 04:32:33\", \"1995-08-27\", \"1995-08-27\");\ninsert into t1 values (10,\"1999-09-30\", \"1999-09-30 10:11:12\", \"1999-09-30\", \"1999-09-30\");\ninsert into t1 values (11,\"2005-10-30\", \"2005-10-30 18:18:59\", \"2005-10-30\", \"2005-10-30\");\ninsert into t1 values (12,\"2008-11-30\", \"2008-11-30 22:59:59\", \"2008-11-30\", \"2008-11-30\");\ninsert into t1 values (13,\"2013-12-01\", \"2013-12-01 22:59:59\", \"2013-12-01\", \"2013-12-01\");\ninsert into t1 values (14,null, null, null, null);\n\nmysql> select weekday(d),weekday(dt) from t1;\n+------------+-------------+\n| weekday(d) | weekday(dt) |\n+------------+-------------+\n|          2 |           2 |\n|          6 |           6 |\n|          1 |           1 |\n|          0 |           0 |\n|          1 |           1 |\n|          4 |           2 |\n|          3 |           3 |\n|          2 |           2 |\n|          3 |           3 |\n|          6 |           5 |\n|          6 |           3 |\n|          3 |           3 |\n|          6 |           6 |\n|          6 |           6 |\n|          6 |           6 |\n|       NULL |        NULL |\n+------------+-------------+\n16 rows in set (0.01 sec)\n\nmysql> select weekday(c),weekday(vc) from t1;\n+------------+-------------+\n| weekday(c) | weekday(vc) |\n+------------+-------------+\n|          2 |           3 |\n|          2 |           3 |\n|          0 |           0 |\n|          0 |           0 |\n|          0 |           0 |\n|          2 |           2 |\n|          3 |           3 |\n|          2 |           2 |\n|          3 |           3 |\n|          6 |           6 |\n|          6 |           6 |\n|          3 |           3 |\n|          6 |           6 |\n|          6 |           6 |\n|          6 |           6 |\n|       NULL |        NULL |\n+------------+-------------+\n16 rows in set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/","title":"YEAR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#description","title":"Description","text":"

      The YEAR() or TOYEAR() function returns the year part for a given date (a number from 1000 to 9999).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#syntax","title":"Syntax","text":"
      > YEAR(date)\n> TOYEAR(date)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#arguments","title":"Arguments","text":"Arguments Description date Required. The date/datetime to extract the year from"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a date, b datetime);\ninsert into t1 values('20211223','2021-10-22 09:23:23');\ninsert into t1 values('2021-12-23','2021-10-22 00:23:23');\n\nmysql> select year(a) from t1;\n+---------+\n| year(a) |\n+---------+\n|    2021 |\n|    2021 |\n+---------+\n2 rows in set (0.00 sec)\n
      DROP TABLE IF EXISTS t3;\nCREATE TABLE t3(c1 DATE NOT NULL);\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('1999-12-31');\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('2006-12-25');\nINSERT INTO t3 VALUES('2008-02-29');\nmysql> SELECT YEAR(c1) FROM t3;\n+----------+\n| year(c1) |\n+----------+\n|     2000 |\n|     1999 |\n|     2000 |\n|     2006 |\n|     2008 |\n+----------+\n5 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#constraints","title":"Constraints","text":"

      The date type supports only yyyy-mm-dd and yyyymmdd for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/","title":"JSON Functions","text":"

      MatrixOne supports the following JSON functions:

      Name Description JSON_EXTRACT() Return data from JSON document JSON_QUOTE() Quote JSON document JSON_UNQUOTE() Unquote JSON value"},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_extract","title":"JSON_EXTRACT()","text":"

      A JSON path expression selects a value within a JSON document.

      Path expressions are useful with functions that extract parts of or modify a JSON document, to specify where within that document to operate. For example, the following query extracts from a JSON document the value of the member with the name key:

      mysql> SELECT JSON_EXTRACT('{\"id\": 14, \"name\": \"Aztalan\"}', '$.name');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"id\": 14, \"name\": \"Aztalan\"}', '$.name') |\n+---------------------------------------------------------+\n| \"Aztalan\"                                               |\n+---------------------------------------------------------+\n

      Path syntax uses a leading $ character to represent the JSON document under consideration, optionally followed by selectors that indicate successively more specific parts of the document:

      • A period followed by a key name names the member in an object with the given key. The key name must be specified within double quotation marks if the name without quotes is not legal within path expressions (for example, if it contains a space).

      • [N] appended to a path that selects an array names the value at position N within the array. Array positions are integers beginning with zero. If the array is negative, an error is generated.

      • Paths can contain * or ** wildcards:

        • .[*] evaluates to the values of all members in a JSON object.

        • [*] evaluates to the values of all elements in a JSON array.

        • prefix**suffix evaluates to all paths that begin with the named prefix and end with the named suffix.

      • A path that does not exist in the document (evaluates to nonexistent data) evaluates to NULL.

      Example:

      [3, {\"a\": [5, 6], \"b\": 10}, [99, 100]]\n
      • $[0] evaluates to 3.

      • $[1] evaluates to {\"a\": [5, 6], \"b\": 10}.

      • $[2] evaluates to [99, 100].

      • $[3] evaluates to NULL (it refers to the fourth array element, which does not exist).

      Because $[1] and $[2] evaluate to nonscalar values, they can be used as the basis for more-specific path expressions that select nested values. Examples:

      • $[1].a evaluates to [5, 6].

      • $[1].a[1] evaluates to 6.

      • $[1].b evaluates to 10.

      • $[2][0] evaluates to 99.

      As mentioned previously, path components that name keys must be quoted if the unquoted key name is not legal in path expressions. Let $ refer to this value:

      {\"a fish\": \"shark\", \"a bird\": \"sparrow\"}\n

      The keys both contain a space and must be quoted:

      • $.\"a fish\" evaluates to shark.

      • $.\"a bird\" evaluates to sparrow.

      Paths that use wildcards evaluate to an array that can contain multiple values:

      mysql> SELECT JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.*');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.*') |\n+---------------------------------------------------------+\n| [1, 2, [3, 4, 5]]                                       |\n+---------------------------------------------------------+\n\nmysql> SELECT JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.c[*]');\n+------------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.c[*]') |\n+------------------------------------------------------------+\n| [3, 4, 5]                                                  |\n+------------------------------------------------------------+\n

      In the following example, the path $**.b evaluates to multiple paths ($.a.b and $.c.b) and produces an array of the matching path values:

      mysql> SELECT JSON_EXTRACT('{\"a\": {\"b\": 1}, \"c\": {\"b\": 2}}', '$**.b');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": {\"b\": 1}, \"c\": {\"b\": 2}}', '$**.b') |\n+---------------------------------------------------------+\n| [null, 1, 2]                                                  |\n+---------------------------------------------------------+\n

      In the following example, showes the querying JSON values from columns:

      CREATE table t1 (a json,b int);\nINSERT into t1(a,b) values ('{\"a\":1,\"b\":2,\"c\":3}',1);\n\nmysql> SELECT json_extract(t1.a,'$.a') from t1 where t1.b=1;\n+-------------------------+\n| json_extract(t1.a, $.a) |\n+-------------------------+\n| 1                       |\n+-------------------------+\n1 row in set (0.00 sec)\n\nINSERT into t1(a,b) values ('{\"a\":4,\"b\":5,\"c\":6}',2);\n\nmysql> SELECT json_extract(t1.a,'$.b') from t1 where t1.b=2;\n+-------------------------+\n| json_extract(t1.a, $.b) |\n+-------------------------+\n| 5                       |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT json_extract(t1.a,'$.a') from t1;\n+-------------------------+\n| json_extract(t1.a, $.a) |\n+-------------------------+\n| 1                       |\n| 4                       |\n+-------------------------+\n2 rows in set (0.00 sec)\n\nINSERT into t1(a,b) values ('{\"a\":{\"q\":[1,2,3]}}',3);\n\nmysql> SELECT json_extract(t1.a,'$.a.q[1]') from t1 where t1.b=3;\n+------------------------------+\n| json_extract(t1.a, $.a.q[1]) |\n+------------------------------+\n| 2                            |\n+------------------------------+\n1 row in set (0.01 sec)\n\nINSERT into t1(a,b) values ('[{\"a\":1,\"b\":2,\"c\":3},{\"a\":4,\"b\":5,\"c\":6}]',4);\n\nmysql> SELECT json_extract(t1.a,'$[1].a') from t1 where t1.b=4;\n+----------------------------+\n| json_extract(t1.a, $[1].a) |\n+----------------------------+\n| 4                          |\n+----------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_quote","title":"JSON_QUOTE()","text":"

      The JSON_QUOTE function converts a string value into a string in JSON format. It wraps the string with double quotes, escapes inner quotes and other characters, quotes the string as a JSON value, and then returns the result as a utf8mb4 string. If the parameter is NULL, it returns NULL.

      The JSON_QUOTE function is commonly used to generate valid JSON strings to include in JSON documents.

      The syntax structure is: select JSON_QUOTE(string_value);

      string_value is the string to be converted to a JSON string. The function returns a string in JSON format, where the original string is surrounded by quotes and properly escaped.

      Example:

      mysql> SELECT JSON_QUOTE('null'), JSON_QUOTE('\"null\"');\n+------------------+--------------------+\n| json_quote(null) | json_quote(\"null\") |\n+------------------+--------------------+\n| \"null\"           | \"\\\"null\\\"\"         |\n+------------------+--------------------+\n1 row in set (0.00 sec)\nmysql> SELECT JSON_QUOTE('[1, 2, 3]');\n+-----------------------+\n| json_quote([1, 2, 3]) |\n+-----------------------+\n| \"[1, 2, 3]\"           |\n+-----------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT JSON_QUOTE('hello world');\n+-------------------------+\n| json_quote(hello world) |\n+-------------------------+\n| \"hello world\"           |\n+-------------------------+\n1 row in set (0.00 sec)\n

      As we can see, the original string is surrounded by quotes, and the double quotes within the string are escaped. This allows it to be used in JSON format, such as as a property value in a JSON object.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_unquote","title":"JSON_UNQUOTE()","text":"

      The JSON_UNQUOTE() function extracts an unquoted JSON value from a JSON string and returns it as a string.

      Specifically, the JSON_UNQUOTE() function takes a JSON string as input, extracts a JSON value from it, and returns it as a string. If the input JSON string does not contain a valid JSON value or the parameter is NULL, the function returns NULL. An error occurs if the value begins and ends with double quotes but is not a valid JSON string literal.

      The syntax structure: select JSON_UNQUOTE(string_value);

      In the string, specific sequences have special meanings and start with a backslash (), known as escape characters, with the following rules. For example, \\b is interpreted as backspace, while \\B is interpreted as B. For all other escape sequences, the backslash is ignored. That is, the escape character is interpreted as unescaped. For example, \\x is just x. These sequences are case-sensitive.

      Escape Sequence Character Represented by Sequence \\\" A double quote (\") character \\b A backspace character \\f A formfeed character \\n A newline (linefeed) character \\r A carriage return character \\t A tab character \\ A backslash () character \\uXXXX UTF-8 bytes for Unicode value XXXX

      Example:

      mysql> SET @j = '\"abc\"';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT @j, JSON_UNQUOTE(@j);\n+-------+------------------+\n| @j    | json_unquote(@j) |\n+-------+------------------+\n| \"abc\" | abc              |\n+-------+------------------+\n1 row in set (0.00 sec)\n\nmysql> SET @j = '[1, 2, 3]';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT @j, JSON_UNQUOTE(@j);\n+-----------+------------------+\n| @j        | json_unquote(@j) |\n+-----------+------------------+\n| [1, 2, 3] | [1, 2, 3]        |\n+-----------+------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT JSON_UNQUOTE('\"\\\\t\\\\u0032\"');\n+----------------------------+\n| json_unquote(\"\\\\t\\\\u0032\") |\n+----------------------------+\n|       2                         |\n+----------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/","title":"ABS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#description","title":"Description","text":"

      ABS(X) Returns the absolute value of X, or NULL if X is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#syntax","title":"Syntax","text":"
      > ABS(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now.

      The result type is derived from the argument type.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,-3.1416);\ninsert into t1 values(-1,1.57);\n\nmysql> select abs(a),abs(b) from t1;\n+--------+--------------------+\n| abs(a) | abs(b)             |\n+--------+--------------------+\n|      1 | 3.1415998935699463 |\n|      1 | 1.5700000524520874 |\n+--------+--------------------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/","title":"ACOS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#description","title":"Description","text":"

      The ACOS() function returns the arccosine(given in radians) of the input number.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#syntax","title":"Syntax","text":"
      > ACOS(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a float,b int);\ninsert into t1 values(0.5,1);\ninsert into t1 values(-0.5,-1);\n\nmysql> select acos(a),acos(b) from t1;\n+--------------------+-------------------+\n| acos(a)            | acos(b)           |\n+--------------------+-------------------+\n| 1.0471975511965976 |                 0 |\n| 2.0943951023931957 | 3.141592653589793 |\n+--------------------+-------------------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/","title":"ATAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#description","title":"Description","text":"

      The ATAN() function returns the arctangent(given in radians) of the input number.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#syntax","title":"Syntax","text":"
      > ATAN(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(0,1);\n\nmysql> select atan(a),atan(tan(b)) from t1;\n+--------------------+--------------------------+\n| atan(a)            | atan(tan(b))             |\n+--------------------+--------------------------+\n| 0.7853981633974483 | -0.000002535181590113463 |\n|                  0 |                        1 |\n+--------------------+--------------------------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/","title":"CEIL()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#description","title":"Description","text":"

      The CEIL(X) function returns the smallest integer value not less than X.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#syntax","title":"Syntax","text":"
      > CEIL(X)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#arguments","title":"Arguments","text":"Arguments Description X Required. Any numeric data type supported now.

      For exact-value numeric arguments, the return value has an exact-value numeric type. For floating-point arguments, the return value has a floating-point type.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,ceil(b) from t1;\n+------+---------+\n| a    | ceil(b) |\n+------+---------+\n|    1 |       1 |\n|    2 |       1 |\n|    3 |       1 |\n|    4 |      21 |\n|    5 |      21 |\n|    6 |      14 |\n|    7 |      -0 |\n|    8 |      -0 |\n|    9 |      -0 |\n|   10 |     -20 |\n|   11 |     -20 |\n|   12 |     -13 |\n+------+---------+\n12 rows in set (0.01 sec)\n\nmysql> select sum(ceil(b)) from t1;\n+--------------+\n| sum(ceil(b)) |\n+--------------+\n|            6 |\n+--------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/","title":"COS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#description","title":"Description","text":"

      The COS() function returns the cosine of input number(given in radians).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#syntax","title":"Syntax","text":"
      > COS(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,1.57);\n\nmysql> select cos(a),cos(b) from t1;\n+--------------------+----------------------+\n| cos(a)             | cos(b)               |\n+--------------------+----------------------+\n| 0.5403023058681398 |  -0.9999999999967865 |\n| 0.5403023058681398 | 0.000796274258662553 |\n+--------------------+----------------------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/","title":"COT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#description","title":"Description","text":"

      The COT() function returns the cotangent of input number(given in radians).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#syntax","title":"Syntax","text":"
      > COT(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#examples","title":"Examples","text":"
      mysql> SELECT COT(12);\n+---------------------+\n| cot(12)             |\n+---------------------+\n| -1.5726734063976895 |\n+---------------------+\n1 row in set (0.00 sec)\n
      drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,12);\n\nmysql> select cot(a), cot(b) from t1;\n+---------------------+---------------------+\n| cot(a)              | cot(b)              |\n+---------------------+---------------------+\n|  0.6420926159343306 |  -394449.0619219334 |\n| -0.6420926159343308 | -1.5726734063976895 |\n+---------------------+---------------------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/","title":"EXP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#description","title":"Description","text":"

      The EXP() function returns the value of e (the base of natural logarithms) raised to the power of X.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#syntax","title":"Syntax","text":"
      > EXP(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(-4, 2.45);\ninsert into t1 values(6, -3.62);\n\nmysql> select exp(a), exp(b) from t1;\n+---------------------+----------------------+\n| exp(a)              | exp(b)               |\n+---------------------+----------------------+\n| 0.01831563888873418 |   11.588347271798835 |\n|   403.4287934927351 | 0.026782679557672436 |\n+---------------------+----------------------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/","title":"FLOOR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#description","title":"Description","text":"

      The FLOOR() function returns the largest round number that is less than or equal to the number.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#syntax","title":"Syntax","text":"
      > FLOOR(number, decimals)\n> FLOOR(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now. decimals Optional. An integer that represents the number of decimal places. By default it is zero, which means to round to an integer.decimals may also be negative."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,floor(b) from t1;\n+------+----------+\n| a    | floor(b) |\n+------+----------+\n|    1 |        0 |\n|    2 |        0 |\n|    3 |        0 |\n|    4 |       20 |\n|    5 |       20 |\n|    6 |       13 |\n|    7 |       -1 |\n|    8 |       -1 |\n|    9 |       -1 |\n|   10 |      -21 |\n|   11 |      -21 |\n|   12 |      -14 |\n+------+----------+\n12 rows in set (0.01 sec)\n\nmysql> select sum(floor(b)) from t1;\n+---------------+\n| sum(floor(b)) |\n+---------------+\n|            -6 |\n+---------------+\n1 row in set (0.00 sec)\n\nmysql> select a,sum(floor(b)) from t1 group by a order by a;\n+------+---------------+\n| a    | sum(floor(b)) |\n+------+---------------+\n|    1 |             0 |\n|    2 |             0 |\n|    3 |             0 |\n|    4 |            20 |\n|    5 |            20 |\n|    6 |            13 |\n|    7 |            -1 |\n|    8 |            -1 |\n|    9 |            -1 |\n|   10 |           -21 |\n|   11 |           -21 |\n|   12 |           -14 |\n+------+---------------+\n12 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/","title":"LN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/#description","title":"Description","text":"

      LN(X) returns the natural logarithm of X. This function is synonymous with LOG(X).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/#syntax","title":"Syntax","text":"
      > LN(X)\n

      Reference to LOG(X).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/","title":"LOG()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#description","title":"Description","text":"

      LOG(X) returns the natural logarithm of X.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#syntax","title":"Syntax","text":"
      > LOG(X)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#arguments","title":"Arguments","text":"Arguments Description X Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a float, b float);\ninsert into t1 values(2,8);\n\nmysql> select log(a), log(b) from t1;\n+--------------------+--------------------+\n| log(a)             | log(b)             |\n+--------------------+--------------------+\n| 0.6931471805599453 | 2.0794415416798357 |\n+--------------------+--------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#constraints","title":"Constraints","text":"

      LOG(X) only support one parameter input for now.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/","title":"PI()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#description","title":"Description","text":"

      PI() returns the value of \u03c0 (pi).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#syntax","title":"Syntax","text":"
      > PI()\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(0,0),(-15,-20),(-22,-12.5);\ninsert into t1 values(0,360),(30,390),(90,450),(180,270),(180,180);\n\nmysql> select acos(a*pi()/180) as acosa,acos(b*pi()/180) acosb from t1;\n+--------------------+--------------------+\n| acosa              | acosb              |\n+--------------------+--------------------+\n| 1.5707963267948966 | 1.5707963267948966 |\n| 1.8356824738191324 |  1.927370391646567 |\n| 1.9648910192076245 | 1.7907312931992256 |\n| 1.5707963267948966 |               NULL |\n| 1.0197267436954502 |               NULL |\n|               NULL |               NULL |\n|               NULL |               NULL |\n|               NULL |               NULL |\n+--------------------+--------------------+\n8 rows in set (0.01 sec)\n\nmysql> select acos(a*pi()/180)*acos(b*pi()/180) as acosab,acos(acos(a*pi()/180)) as c from t1;\n+--------------------+------+\n| acosab             | c    |\n+--------------------+------+\n| 2.4674011002723395 | NULL |\n| 3.5380400485035204 | NULL |\n|  3.518591835821214 | NULL |\n|               NULL | NULL |\n|               NULL | NULL |\n|               NULL | NULL |\n|               NULL | NULL |\n|               NULL | NULL |\n+--------------------+------+\n8 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/","title":"POWER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#description","title":"Description","text":"

      POWER(X, Y) returns the value of X raised to the power of Y.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#syntax","title":"Syntax","text":"
      > POWER(X, Y)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#arguments","title":"Arguments","text":"Arguments Description X Required. Any numeric data type supported now. Y Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int,b int);\ninsert into t1 values(5,-2),(10,3),(100,0),(4,3),(6,-3);\n\nmysql> select power(a,b) from t1;\n+----------------------+\n| power(a, b)          |\n+----------------------+\n|                 0.04 |\n|                 1000 |\n|                    1 |\n|                   64 |\n| 0.004629629629629629 |\n+----------------------+\n5 rows in set (0.01 sec)\n\nmysql> select power(a,2) as a1, power(b,2) as b1 from t1 where power(a,2) > power(b,2) order by a1 asc;\n+-------+------+\n| a1    | b1   |\n+-------+------+\n|    16 |    9 |\n|    25 |    4 |\n|    36 |    9 |\n|   100 |    9 |\n| 10000 |    0 |\n+-------+------+\n5 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/","title":"RAND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#description","title":"Description","text":"

      The RAND() function is used to generate a Float64 type random number between 0 and 1. It does not accept any arguments and generates a random number that is unpredictable and non-repeating each time it is called.

      If you need to randomly select data from a table, you can use the RAND() function to generate a random number, and then use ORDER BY to sort the data in the table according to this random number. For example:

      -- Randomly retrieve all data from the table and sort it in a random order, the order of the query results may differ each time.\nSELECT * FROM table ORDER BY RAND();\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#syntax","title":"Syntax","text":"
      > RAND([seed])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#arguments","title":"Arguments","text":"Arguments Description seed Optional argument. It is an integer value used to specify the seed when generating random numbers. If the seed parameter is not specified, the current time is used as the seed value by default. The return value type is consistent with the input type.MatrixOne does not currently support specifying seed."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#examples","title":"Examples","text":"
      • Example 1
      mysql> SELECT RAND();\n+---------------------+\n| rand()              |\n+---------------------+\n| 0.25193285156620004 |\n+---------------------+\n1 row in set (0.00 sec)\n
      • Example 2
      CREATE TABLE Users (\nID INT PRIMARY KEY AUTO_INCREMENT,\nUserName VARCHAR(255) NOT NULL,\nEmail VARCHAR(255));\n\nINSERT INTO Users (UserName, Email) VALUES\n('John', 'john@example.com'),\n('Jane', 'jane@example.com'),\n('Alice', 'alice@example.com'),\n('Bob', 'bob@example.com');\n\n-- Select a user's information randomly from the Users table.\nmysql> SELECT * FROM Users ORDER BY RAND() LIMIT 1;\n+------+----------+-----------------+\n| id   | username | email           |\n+------+----------+-----------------+\n|    4 | Bob      | bob@example.com | -- Bob's information is randomly selected.\n+------+----------+-----------------+\n1 row in set (0.01 sec)\n\n-- Execute the above query again, and another user may be selected.\nmysql> SELECT * FROM Users  ORDER BY RAND() LIMIT 1;\n+------+----------+-------------------+\n| id   | username | email             |\n+------+----------+-------------------+\n|    3 | Alice    | alice@example.com | -- Alice's information is randomly selected.\n+------+----------+-------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#constraints","title":"Constraints","text":"

      MatrixOne does not currently support specifying the seed value for the RAND(seed) function (i.e., the seed parameter).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/","title":"ROUND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#description","title":"Description","text":"

      The ROUND() function rounds a number to a specified number of decimal places. The function returns the nearest number of the specified order. In case when given number has equal distance to surrounding numbers, the function uses banker's rounding for float number types and rounds away from zero for the other number types (Decimal).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#syntax","title":"Syntax","text":"
      > ROUND(number, decimals)\n> ROUND(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#arguments","title":"Arguments","text":"Arguments Description number Required. The number to round, including any numeric data type supported now. decimals Optional. An integer that represents the number of decimal places you want to round to. Default value is 0. decimals>0 then the function rounds the value to the right of the decimal point. decimals<0 then the function rounds the value to the left of the decimal point. decimals=0 then the function rounds the value to integer."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,round(b) from t1;\n+------+----------+\n| a    | round(b) |\n+------+----------+\n|    1 |        0 |\n|    2 |        0 |\n|    3 |        1 |\n|    4 |       20 |\n|    5 |       20 |\n|    6 |       14 |\n|    7 |       -0 |\n|    8 |       -0 |\n|    9 |       -1 |\n|   10 |      -20 |\n|   11 |      -20 |\n|   12 |      -14 |\n+------+----------+\n12 rows in set (0.00 sec)\n\nmysql> select a,round(b,-1) from t1;\n+------+--------------+\n| a    | round(b, -1) |\n+------+--------------+\n|    1 |            0 |\n|    2 |            0 |\n|    3 |            0 |\n|    4 |           20 |\n|    5 |           20 |\n|    6 |           10 |\n|    7 |           -0 |\n|    8 |           -0 |\n|    9 |           -0 |\n|   10 |          -20 |\n|   11 |          -20 |\n|   12 |          -10 |\n+------+--------------+\n12 rows in set (0.01 sec)\n\nmysql> select round(a*b) from t1;\n+--------------+\n| round(a * b) |\n+--------------+\n|            0 |\n|            1 |\n|            2 |\n|           82 |\n|          102 |\n|           81 |\n|           -4 |\n|           -4 |\n|           -5 |\n|         -205 |\n|         -226 |\n|         -162 |\n+--------------+\n12 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/","title":"SIN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#description","title":"Description","text":"

      The SIN() function returns the sine of input number(given in radians).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#syntax","title":"Syntax","text":"
      > SIN(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,1.57);\n\nmysql> select sin(a),sin(b) from t1;\n+---------------------+--------------------------+\n| sin(a)              | sin(b)                   |\n+---------------------+--------------------------+\n|  0.8414709848078965 | 0.0000025351815901107472 |\n| -0.8414709848078965 |       0.9999996829736023 |\n+---------------------+--------------------------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/","title":"SINH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#description","title":"Description","text":"

      The SINH() function returns the hyperbolic sine of the input number(given in radians).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#syntax","title":"Syntax","text":"
      > SINH(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159), (-1,-3.14159);\n\nmysql> select sinh(a), sinh(b) from t1;\n+---------------------+---------------------+\n| sinh(a)             | sinh(b)             |\n+---------------------+---------------------+\n|  1.1752011936438014 |  11.548709969588323 |\n| -1.1752011936438014 | -11.548709969588323 |\n+---------------------+---------------------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/","title":"TAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#description","title":"Description","text":"

      The TAN() function returns the tangent of input number(given in radians).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#syntax","title":"Syntax","text":"
      > TAN(number)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#arguments","title":"Arguments","text":"Arguments Description number Required. Any numeric data type supported now."},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,-3.14159);\n\nmysql> select tan(a),tan(b) from t1;\n+--------------------+--------------------------+\n| tan(a)             | tan(b)                   |\n+--------------------+--------------------------+\n|  1.557407724654902 | -0.000002535181590118894 |\n| -1.557407724654902 |  0.000002535181590118894 |\n+--------------------+--------------------------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/","title":"SLEEP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#description","title":"Description","text":"

      Sleeps (pauses) for the number of seconds given by the duration argument, then returns 0.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#syntax","title":"Syntax","text":"
      >\nSLEEP(duration)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#arguments","title":"Arguments","text":"Arguments Description duration Required. The number of seconds. The duration may have a fractional part. The duration is not allowed NULL or negative."},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#returned-value","title":"Returned Value","text":"
      • When sleep returns normally (without interruption), it returns 0.

      • When SLEEP() returns 1 (with interruption or time out), the query returns no error.

        For example:

        1. In session 1, execute the following command to query the current connection_id and execute the SLEEP() function:

          mysql> select connection_id();\n+-----------------+\n| connection_id() |\n+-----------------+\n|            1476 |\n+-----------------+\n1 row in set (0.03 sec)\nmysql> select sleep(200);\n
        2. At this point, open a new session, interrupt session 1, and run the following command.

          mysql> kill 1463;\nQuery OK, 0 rows affected (0.00 sec)\n
        3. Check the query result of session 1:

          mysql> select sleep(200);\n+------------+\n| sleep(200) |\n+------------+\n|          1 |\n+------------+\n1 row in set (26.50 sec)\n
      • When SLEEP() returns an error (part of a query is uninterrupted). For example:

        mysql> SELECT 1 FROM t1 WHERE SLEEP(1000);\nERROR 20101 (HY000): internal error: pipeline closed unexpectedly\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#examples","title":"Examples","text":"
      -- without interruption\nmysql> SELECT SLEEP(1);\n+----------+\n| sleep(1) |\n+----------+\n|        0 |\n+----------+\n1 row in set (1.01 sec)\n\n-- without interruption\nmysql> SELECT SLEEP(1000);\n+-------------+\n| sleep(1000) |\n+-------------+\n|           0 |\n+-------------+\n1 row in set (18 min 20.87 sec)\n\ncreate table t1 (a int,b int);\ninsert into t1 values (1,1),(1,null);\nmysql> select sleep(a) from t1;\n+----------+\n| sleep(a) |\n+----------+\n|        0 |\n|        0 |\n+----------+\n2 rows in set (2.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/","title":"UUID()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#description","title":"Description","text":"

      Returns a Universal Unique Identifier (UUID) generated according to RFC 4122, \"A Universally Unique IDentifier (UUID) URN Namespace\".

      A UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate devices not connected to each other.

      Info

      Although UUID() values are intended to be unique, they are not necessarily unguessable or unpredictable. If unpredictability is required, UUID values should be generated some other way.

      UUID() returns a value that conforms to UUID version 1 as described in RFC 4122. The value is a 128-bit number represented as a utf8mb3 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format:

      • The first three numbers are generated from the low, middle, and high parts of a timestamp. The high part also includes the UUID version number.

      • The fourth number preserves temporal uniqueness in case the timestamp value loses monotonicity (for example, due to daylight saving time).

      • The fifth number is an IEEE 802 node number that provides spatial uniqueness. A random number is substituted if the latter is not available (for example, because the host device has no Ethernet card, or it is unknown how to find the hardware address of an interface on the host operating system). In this case, spatial uniqueness cannot be guaranteed. Nevertheless, a collision should have very low probability.

      UUID is both a data type and a function. For more information on UUID data types, see UUID Type.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#syntax","title":"Syntax","text":"
      > UUID()\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a INT,  b float);\ninsert into t1 values(12124, -4213.413), (12124, -42413.409);\n\nmysql> SELECT length(uuid()) FROM t1;\n+----------------+\n| length(uuid()) |\n+----------------+\n|             36 |\n|             36 |\n+----------------+\n2 rows in set (0.00 sec)\n\nmysql> SELECT UUID();\n+--------------------------------------+\n| uuid()                               |\n+--------------------------------------+\n| b293b688-70a7-11ed-a25a-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#constraints","title":"Constraints","text":"

      UUID() does not support optional argument for now, which means it doesn't support UUID([number]).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/","title":"BIN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#description","title":"Description","text":"

      This function BIN() returns a string representation of the binary value of N, where N is a longlong (BIGINT) number. Returns NULL if N is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#syntax","title":"Syntax","text":"
      > BIN(N)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#arguments","title":"Arguments","text":"Arguments Description N Required. UINT Type"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#examples","title":"Examples","text":"
      > SELECT bin(1314);\n+-------------+\n| bin(1314)   |\n+-------------+\n| 10100100010 |\n+-------------+\n1 row in set (0.01 sec)\n\n> select bin(2e5);\n+--------------------+\n| bin(2e5)           |\n+--------------------+\n| 110000110101000000 |\n+--------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/","title":"BIT_LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#description","title":"Description","text":"

      Returns the length of the string str in bits. Returns NULL if str is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#syntax","title":"Syntax","text":"
      > BIT_LENGTH(str)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#arguments","title":"Arguments","text":"Arguments Description str Required. String you want to calculate."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#examples","title":"Examples","text":"
      > SELECT BIT_LENGTH('text');\n+------------------+\n| bit_length(text) |\n+------------------+\n|               32 |\n+------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/","title":"CHAR_LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#description","title":"Description","text":"

      The CHAR_LENGTH function returns the length of the string str, measured in code points. A multibyte character counts as a single code point. This means that, for a string containing two 3-byte characters, CHAR_LENGTH returns 6, whereas CHAR_LENGTH returns 2.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#syntax","title":"Syntax","text":"
      > CHAR_LENGTH(str)\n

      note

      The alias for CHAR_LENGTH can also be lengthUTF8()

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#arguments","title":"Arguments","text":"Arguments Description str Required. String you want to calculate."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> create table t1(a varchar(255),b varchar(255));\n> insert into t1 values('nihao','\u4f60\u597d');\n> select char_length(a), char_length(b) from t1;\n+---------------+---------------+\n| lengthutf8(a) | lengthutf8(b) |\n+---------------+---------------+\n|             5 |             2 |\n+---------------+---------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/","title":"CONCAT_WS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#description","title":"Description","text":"

      This function CONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments. If the separator is NULL, the result is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#syntax","title":"Syntax","text":"
      • Syntax 1
      > CONCAT_WS(separator,str1,str2,...)\n
      • Syntax 2
      > CONCAT_WS(separator,str1,NULL,str1,...);\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#arguments","title":"Arguments","text":"Arguments Description str Required. both CHAR and VARCHAR are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#examples","title":"Examples","text":"
      SELECT CONCAT_WS(',','First name','Second name','Last Name');\n+--------------------------------------------------+\n| concat_ws(,, First name, Second name, Last Name) |\n+--------------------------------------------------+\n| First name,Second name,Last Name                 |\n+--------------------------------------------------+\n1 row in set (0.01 sec)\n> SELECT CONCAT_WS(',','First name',NULL,'Last Name');\n+-------------------------------------------+\n| concat_ws(,, First name, null, Last Name) |\n+-------------------------------------------+\n| First name,Last Name                      |\n+-------------------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/","title":"CONCAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#description","title":"Description","text":"

      This function CONCAT() returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string.

      CONCAT() returns NULL if any argument is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#syntax","title":"Syntax","text":"
      >\nCONCAT(str1,str2,...)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#arguments","title":"Arguments","text":"Arguments Description str1,str2,... Required. The str to add together. Note: If any of the strs is a NULL value, it returns NULL."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#examples","title":"Examples","text":"
      mysql> SELECT CONCAT('My', 'S', 'QL');\n+-------------------+\n| concat(My, S, QL) |\n+-------------------+\n| MySQL             |\n+-------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CONCAT('My', NULL, 'QL');\n+----------------------+\n| concat(My, null, QL) |\n+----------------------+\n| NULL                 |\n+----------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#constraints","title":"Constraints","text":"

      Currently, CONCAT() doesn't support quoted strings and numeric argument.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/","title":"EMPTY()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#description","title":"Description","text":"

      Checks whether the input string is empty. A string is considered non-empty if it contains at least one byte, even if this is a space or a null byte.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#syntax","title":"Syntax","text":"
      > EMPTY(str)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#arguments","title":"Arguments","text":"Arguments Description str Required. both CHAR and VARCHAR are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#returned-values","title":"Returned Values","text":"

      Returns 1 for an empty string or 0 for a non-empty string.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> create table t1(a varchar(255),b varchar(255));\n> insert into t1 values('', 'abcd');\n> insert into t1 values('1111', '');\n> select empty(a),empty(b) from t1;\n+----------+----------+\n| empty(a) | empty(b) |\n+----------+----------+\n|        1 |        0 |\n|        0 |        1 |\n+----------+----------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/","title":"ENDSWITH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#description","title":"Description","text":"

      Returns whether to end with the specified suffix. Returns 1 if the string ends with the specified suffix, otherwise it returns 0. This function is case sensitive.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#syntax","title":"Syntax","text":"
      > ENDSWITH(str,suffix)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR both are supported. suffix Required. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#returned-values","title":"Returned Values","text":"
      • 1, if the string ends with the specified suffix.
      • 0, if the string does not end with the specified suffix.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> create table t1(a int,b varchar(100),c char(20));\n> insert into t1 values\n(1,'Ananya Majumdar', 'XI'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'XI');\n> select a,endsWith(b,'a') from t1;\n+------+----------------+\n| a    | endswith(b, a) |\n+------+----------------+\n|    1 |              0 |\n|    2 |              1 |\n|    3 |              1 |\n|    4 |              0 |\n|    5 |              0 |\n|    6 |              1 |\n+------+----------------+\n> select a,b,c from t1 where endswith(b,'a')=1 and endswith(c,'I')=1;\n+------+---------------+------+\n| a    | b             | c    |\n+------+---------------+------+\n|    3 | Aniket Sharma | XI   |\n|    6 | Tapan Samanta | XI   |\n+------+---------------+------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/","title":"FIELD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#description","title":"Description","text":"

      FIELD() returns the index (position) of str in the str1, str2, str3, ... list.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#syntax","title":"Syntax","text":"
      > FIELD(str,str1,str2,str3,...)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#arguments","title":"Arguments","text":"Arguments Description str Required. The value to search for in the list, case insensitive. str1,str2,str3,... Required. A list of values to search for, case insensitive."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#returned-value","title":"Returned Value","text":"

      If all arguments to FIELD() are strings, all arguments are compared as strings. If all arguments are numbers, they are compared as numbers. Otherwise, the arguments are compared as double.

      • The FIELD() function returns the corresponding position index if the specified value is found in the list. Indexes returned by the FIELD() function start at 1.

      • If more than one specified value is found in the list, the FIELD() function returns only the index of the first one.

      • Returns 0 if str is not found.

      • If str is NULL, the return value is 0 because NULL fails equality comparison with any value.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#examples","title":"Examples","text":"
      • Example 1:
      mysql> SELECT FIELD('Bb', 'Aa', 'Bb', 'Cc', 'Dd', 'Ff');\n+-------------------------------+\n| field(Bb, Aa, Bb, Cc, Dd, Ff) |\n+-------------------------------+\n|                             2 |\n+-------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FIELD('Gg', 'Aa', 'Bb', 'Cc', 'Dd', 'Ff');\n+-------------------------------+\n| field(Gg, Aa, Bb, Cc, Dd, Ff) |\n+-------------------------------+\n|                             0 |\n+-------------------------------+\n1 row in set (0.00 sec)\n
      • Example 2:
      drop table if exists t;\ncreate table t(\ni int,\nf float,\nd double\n);\ninsert into t() values (1, 1.1, 2.2), (2, 3.3, 4.4), (0, 0, 0), (0, null, 0);\n\nmysql> select * from t;\n+------+------+------+\n| i    | f    | d    |\n+------+------+------+\n|    1 |  1.1 |  2.2 |\n|    2 |  3.3 |  4.4 |\n|    0 |    0 |    0 |\n|    0 | NULL |    0 |\n+------+------+------+\n4 rows in set (0.01 sec)\n\nmysql> select field(1, i, f, d) from t;\n+-------------------+\n| field(1, i, f, d) |\n+-------------------+\n|                 1 |\n|                 0 |\n|                 0 |\n|                 0 |\n+-------------------+\n4 rows in set (0.01 sec)\n\nmysql> select field(i, f, d, 0, 1, 2) from t;\n+-------------------------+\n| field(i, f, d, 0, 1, 2) |\n+-------------------------+\n|                       4 |\n|                       5 |\n|                       1 |\n|                       2 |\n+-------------------------+\n4 rows in set (0.01 sec)\n\nmysql> select field('1', f, d, 0, 1, 2) from t;\n+-------------------------+\n| field(1, f, d, 0, 1, 2) |\n+-------------------------+\n|                       4 |\n|                       4 |\n|                       4 |\n|                       4 |\n+-------------------------+\n4 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/","title":"FIND_IN_SET()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#description","title":"Description","text":"

      This function FIND_IN_SET() returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings. A string list is a string composed of substrings separated by , characters. If the first argument is a constant string and the second is a column of type SET, the FIND_IN_SET() function is optimized to use bit arithmetic. Returns 0 if str is not in strlist or if strlist is the empty string. Returns NULL if either argument is NULL. This function does not work properly if the first argument contains a comma (,) character.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#syntax","title":"Syntax","text":"
      > FIND_IN_SET(str,strlist)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#arguments","title":"Arguments","text":"Arguments Description str Required. both CHAR and VARCHAR are supported. strlist Required."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#examples","title":"Examples","text":"
      select find_in_set('b','a,b,c,d');\n+-------------------------+\n| find_in_set(b, a,b,c,d) |\n+-------------------------+\n|                       2 |\n+-------------------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/","title":"FORMAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#description","title":"Description","text":"

      Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#syntax","title":"Syntax","text":"
      > FORMAT(X,D[,locale])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#arguments","title":"Arguments","text":"Arguments Description X Required. X is the number need to format. If X is NULL, the function returns NULL. D Required. D is the number of decimal places to round. If D is 0, the result has no decimal point or fractional part. If D is NULL, the function returns NULL. [,locale] Optional. The optional parameter enables a locale to be specified to be used for the result number's decimal point, thousands separator, and grouping between separators. If the locale is NULL or not specified, the default locale is 'en_US'. [,locale] supports locale parameters consistent with MySQL; see MySQL Server Locale Support."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#examples","title":"Examples","text":"
      mysql> SELECT FORMAT(12332.123456, 4);\n+-------------------------+\n| format(12332.123456, 4) |\n+-------------------------+\n| 12,332.1235             |\n+-------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT FORMAT(12332.1,4);\n+--------------------+\n| format(12332.1, 4) |\n+--------------------+\n| 12,332.1000        |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(12332.2,0);\n+--------------------+\n| format(12332.2, 0) |\n+--------------------+\n| 12,332             |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(12332.2,2,'de_DE');\n+---------------------------+\n| format(12332.2, 2, de_DE) |\n+---------------------------+\n| 12.332,20                 |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(19999999.999999999,4);\n+-------------------------------+\n| format(19999999.999999999, 4) |\n+-------------------------------+\n| 20,000,000.0000               |\n+-------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT FORMAT(\"-.12334.2\",\"2\", \"en_US\");\n+-----------------------------+\n| format(-.12334.2, 2, en_US) |\n+-----------------------------+\n| -0.12                       |\n+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(\"-.12334.2\",\"2\", \"de_CH\");\n+-----------------------------+\n| format(-.12334.2, 2, de_CH) |\n+-----------------------------+\n| -0.12                       |\n+-----------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/","title":"HEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#description","title":"Description","text":"

      For a string argument str, HEX() returns a hexadecimal string representation of str where each byte of each character in str is converted to two hexadecimal digits. (Multibyte characters therefore become more than two digits.)

      For a numeric argument N, HEX() returns a hexadecimal string representation of the value of N treated as an integer number. This is equivalent to CONV(N,10,16). The inverse of this operation is performed by CONV(HEX(N),16,10).

      For a NULL argument, this function returns NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#syntax","title":"Syntax","text":"
      > HEX(str), HEX(N)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#arguments","title":"Arguments","text":"Arguments Description N Required. A number which is to be converted to hexadecimal. str Required. A string whose each character is to be converted to two hexadecimal digits."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#examples","title":"Examples","text":"
      > SELECT HEX('abc');\n+----------+\n| hex(abc) |\n+----------+\n| 616263   |\n+----------+\n1 row in set (0.00 sec)\n\n> SELECT HEX(255);\n+----------+\n| hex(255) |\n+----------+\n| FF       |\n+----------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/","title":"INSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#description","title":"Description","text":"

      INSTR() function is used to return the position of the first occurrence of a substring in a given string. This function is multibyte safe, which means it is compatible with various character encodings and can correctly handle multibyte characters (such as characters encoded in UTF-8).

      The INSTR() function primarily uses data cleaning and transformation, such as when you need to search for a specific substring within a text field or split a text field based on a specific character. This can be particularly useful when dealing with data that follows a specific pattern or format, like email addresses, phone numbers, etc.

      Regarding case sensitivity, INSTR() function is case-sensitive only if at least one argument is a binary string. For non-binary strings, INSTR() is case-insensitive. However, to make a case-sensitive comparison, you can use the BINARY keyword to cast the string into a binary format.

      For example:

      SELECT INSTR(BINARY 'abc', 'A') AS Match;\n

      The above query will return 0 because, in binary format, 'A' and 'a' are considered different characters.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#syntax","title":"Syntax","text":"
      > INSTR(str,substr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#arguments","title":"Arguments","text":"Arguments Description str Required. The string is the string to search in. substr Required. The substring is the string you are looking for."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#examples","title":"Examples","text":"
      • Example 1
      mysql> SELECT INSTR('foobarbar', 'bar');\n+-----------------------+\n| instr(foobarbar, bar) |\n+-----------------------+\n|                     4 |\n+-----------------------+\n1 row in set (0.01 sec)\n
      • Example 2
      -- Using the INSTR function to find the first occurrence of 'o' in the string 'Hello World' will return 5, as 'o' first appears at the 5th position in 'Hello World'.\nmysql> SELECT INSTR('Hello World', 'o');\n+-----------------------+\n| instr(Hello World, o) |\n+-----------------------+\n|                     5 |\n+-----------------------+\n1 row in set (0.01 sec)\n
      • Example 3
      -- Create a table named t1, which contains two VARCHAR type columns a and b\nCREATE TABLE t1(a VARCHAR, b VARCHAR);\n\n-- Insert three rows of data into the table t1\nINSERT INTO t1 VALUES('axa','x'),('abababa','qq'),('qwer','er');\n\n-- Select each row from table t1, then use the INSTR function to find the position at which the string in column b first appears in column a\nmysql> select instr(a,b) from t1;\n+-------------+\n| instr(a, b) |\n+-------------+\n|           2 |\n|           0 |\n|           3 |\n+-------------+\n3 rows in set (0.01 sec)\n\n-- Select each row from table t1, then use the INSTR function to find the position at which NULL first appears in column a\n-- Since NULL is an unknown value, this query will return NULL\nmysql> select instr(a,null) from t1;\n+----------------+\n| instr(a, null) |\n+----------------+\n|           NULL |\n|           NULL |\n|           NULL |\n+----------------+\n3 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/","title":"LEFT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#description","title":"Description","text":"

      This function LEFT() returns the leftmost len characters from the string str, or NULL if any argument is NULL.

      This function is multibyte safe.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#syntax","title":"Syntax","text":"
      > LEFT(str,len)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#arguments","title":"Arguments","text":"Arguments Description str Required. The string to extract from. len Required. The number of characters to extract. If this parameter is larger than the number of characters in string, this function will return string"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#examples","title":"Examples","text":"
      mysql> select left('abcde', 3) from dual;\n+----------------+\n| left(abcde, 3) |\n+----------------+\n| abc            |\n+----------------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\nCREATE TABLE t1 (str VARCHAR(100) NOT NULL, len INT);\ninsert into t1 values('abcdefghijklmn',3);\ninsert into t1 values('  ABCDEFGH123456', 3);\ninsert into t1 values('ABCDEF  GHIJKLMN', 20);\ninsert into t1 values('ABCDEFGHijklmn   ', -1);\ninsert into t1 values('ABCDEFGH123456', -35627164);\ninsert into t1 values('', 3);\nmysql> select left(str, len) from t1;\n+------------------+\n| left(str, len)   |\n+------------------+\n| abc              |\n|   A              |\n| ABCDEF  GHIJKLMN |\n|                  |\n|                  |\n|                  |\n+------------------+\n6 rows in set (0.01 sec)\n\nmysql> select left('sdfsdfsdfsdf', len) from t1;\n+-------------------------+\n| left(sdfsdfsdfsdf, len) |\n+-------------------------+\n| sdf                     |\n| sdf                     |\n| sdfsdfsdfsdf            |\n|                         |\n|                         |\n| sdf                     |\n+-------------------------+\n6 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/","title":"LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#description","title":"Description","text":"

      The length() function returns the length of the string.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#syntax","title":"Syntax","text":"
      > LENGTH(str)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#arguments","title":"Arguments","text":"Arguments Description str Required. String you want to calculate."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#examples","title":"Examples","text":"
      > select a,length(a) from t1;\n\na   length(a)\na       1\nab      2\nabc     3\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/","title":"LPAD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#description","title":"Description","text":"

      This function LPAD(str,len,padstr) returns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#syntax","title":"Syntax","text":"
      > LPAD(str,len,padstr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#arguments","title":"Arguments","text":"Arguments Description str Required. The string to be padded. CHAR and VARCHAR both are supported. len Required. padstr Required. The string used to pad on the left. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> CREATE TABLE t1(Student_id INT,Student_name VARCHAR(100),Student_Class CHAR(20));\n> INSERT INTO t1\nVALUES\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> SELECT Student_id, Student_name,LPAD(Student_Class, 10, ' _') AS LeftPaddedString FROM t1;\n+------------+-----------------+------------------+\n| Student_id | Student_name    | LeftPaddedString |\n+------------+-----------------+------------------+\n|          1 | Ananya Majumdar |  _ _ _ _IX       |\n|          2 | Anushka Samanta |  _ _ _ _ X       |\n|          3 | Aniket Sharma   |  _ _ _ _XI       |\n|          4 | Anik Das        |  _ _ _ _ X       |\n|          5 | Riya Jain       |  _ _ _ _IX       |\n|          6 | Tapan Samanta   |  _ _ _ _ X       |\n+------------+-----------------+------------------+\n> SELECT Student_id, lpad(Student_name,4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 | Anan             |\n|          2 | Anus             |\n|          3 | Anik             |\n|          4 | Anik             |\n|          5 | Riya             |\n|          6 | Tapa             |\n+------------+------------------+\n> SELECT Student_id, lpad(Student_name,-4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 | NULL             |\n|          2 | NULL             |\n|          3 | NULL             |\n|          4 | NULL             |\n|          5 | NULL             |\n|          6 | NULL             |\n+------------+------------------+\n> SELECT Student_id, lpad(Student_name,0,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 |                  |\n|          2 |                  |\n|          3 |                  |\n|          4 |                  |\n|          5 |                  |\n|          6 |                  |\n+------------+------------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/","title":"LTRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#description","title":"Description","text":"

      This function LTRIM() returns the string with leading space characters removed.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#syntax","title":"Syntax","text":"
      > LTRIM(str)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> create table t1(a char(8),b varchar(10));\n> insert into t1 values('  matrix',' matrixone');\n> select ltrim(a),ltrim(b) from t1;\n\n+----------+-----------+\n| ltrim(a) | ltrim(b)  |\n+----------+-----------+\n| matrix   | matrixone |\n+----------+-----------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/","title":"OCT(N)","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#description","title":"Description","text":"

      This function OCT(N) returns a string representation of the octal value of N, where N is a longlong (BIGINT) number. Returns NULL if N is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#syntax","title":"Syntax","text":"
      > OCT(N)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#arguments","title":"Arguments","text":"Arguments Description N Required. UINT Type"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#examples","title":"Examples","text":"
      SELECT OCT(12);\n+---------+\n| oct(12) |\n+---------+\n| 14.0000 |\n+---------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/","title":"REPEAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#description","title":"Description","text":"

      Returns a string consisting of the string str repeated count times. If count is less than 1, returns an empty string. Returns NULL if str or count is NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#syntax","title":"Syntax","text":"
      > REPEAT(str,count)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#arguments","title":"Arguments","text":"Arguments Description str Required. The string to repeat. count Required. The number of times to repeat."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#examples","title":"Examples","text":"
      mysql> SELECT repeat('abc', -1);\n+-----------------+\n| repeat(abc, -1) |\n+-----------------+\n|                 |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT repeat('abc', 1), repeat('abc', 2), repeat('abc', 3);\n+----------------+----------------+----------------+\n| repeat(abc, 1) | repeat(abc, 2) | repeat(abc, 3) |\n+----------------+----------------+----------------+\n| abc            | abcabc         | abcabcabc      |\n+----------------+----------------+----------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/","title":"REVERSE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#description","title":"Description","text":"

      Returns the string str with the order of the characters reversed.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#syntax","title":"Syntax","text":"
      > REVERSE(str)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#arguments","title":"Arguments","text":"Arguments Description Str Required. both CHAR and VARCHAR are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> create table t1(a varchar(12),c char(30));\n> insert into t1 values('sdfad  ','2022-02-02 22:22:22');\n> insert into t1 values('  sdfad  ','2022-02-02 22:22:22');\n> insert into t1 values('adsf  sdfad','2022-02-02 22:22:22');\n> insert into t1 values('    sdfad','2022-02-02 22:22:22');\n> select reverse(a),reverse(c) from t1;\n+-------------+---------------------+\n| reverse(a)  | reverse(c)          |\n+-------------+---------------------+\n|   dafds     | 22:22:22 20-20-2202 |\n|   dafds     | 22:22:22 20-20-2202 |\n| dafds  fsda | 22:22:22 20-20-2202 |\n| dafds       | 22:22:22 20-20-2202 |\n+-------------+---------------------+\n> select a from t1 where reverse(a) like 'daf%';\n+-------------+\n| a           |\n+-------------+\n| adsf  sdfad |\n|     sdfad   |\n+-------------+\n> select reverse(a) reversea,reverse(reverse(a)) normala from t1;\n+-------------+-------------+\n| reversea    | normala     |\n+-------------+-------------+\n|   dafds     | sdfad       |\n|   dafds     |   sdfad     |\n| dafds  fsda | adsf  sdfad |\n| dafds       |     sdfad   |\n+-------------+-------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/","title":"RPAD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#description","title":"Description","text":"

      This function RPAD(str,len,padstr) returns the string str, right-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#syntax","title":"Syntax","text":"
      > RPAD(str,len,padstr)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#arguments","title":"Arguments","text":"Arguments Description str Required. The string to be padded. CHAR and VARCHAR both are supported. len Required. padstr Required. The string used to pad on the right. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> CREATE TABLE t1(Student_id INT,Student_name VARCHAR(100),Student_Class CHAR(20));\n> INSERT INTO t1\nVALUES\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> SELECT Student_id, Student_name,RPAD(Student_Class, 10, ' _') AS LeftPaddedString FROM t1;\n+------------+-----------------+------------------+\n| Student_id | Student_name    | LeftPaddedString |\n+------------+-----------------+------------------+\n|          1 | Ananya Majumdar | IX _ _ _ _       |\n|          2 | Anushka Samanta | X _ _ _ _        |\n|          3 | Aniket Sharma   | XI _ _ _ _       |\n|          4 | Anik Das        | X _ _ _ _        |\n|          5 | Riya Jain       | IX _ _ _ _       |\n|          6 | Tapan Samanta   | X _ _ _ _        |\n+------------+-----------------+------------------+\n> SELECT Student_id, rpad(Student_name,4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 | Anan             |\n|          2 | Anus             |\n|          3 | Anik             |\n|          4 | Anik             |\n|          5 | Riya             |\n|          6 | Tapa             |\n+------------+------------------+\n> SELECT Student_id, rpad(Student_name,-4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 | NULL             |\n|          2 | NULL             |\n|          3 | NULL             |\n|          4 | NULL             |\n|          5 | NULL             |\n|          6 | NULL             |\n+------------+------------------+\n> SELECT Student_id, rpad(Student_name,0,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n|          1 |                  |\n|          2 |                  |\n|          3 |                  |\n|          4 |                  |\n|          5 |                  |\n|          6 |                  |\n+------------+------------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/","title":"RTRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#description","title":"Description","text":"

      This function RTRIM() returns the string with trailing space characters removed.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#syntax","title":"Syntax","text":"
      > RTRIM(str)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> create table t1(a char(8),b varchar(10));\n> insert into t1 values('matrix  ','matrixone ');\n> select rtrim(a),rtrim(b) from t1;\n\n+----------+-----------+\n| rtrim(a) | rtrim(b)  |\n+----------+-----------+\n| matrix   | matrixone |\n+----------+-----------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/","title":"SPACE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#description","title":"Description","text":"

      SPACE(N) Returns a string consisting of N space characters.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#syntax","title":"Syntax","text":"
      > SPACE(N)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#arguments","title":"Arguments","text":"Arguments Description N Required. UINT Type"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> CREATE TABLE t1\n(\nEmployee_name VARCHAR(100) NOT NULL,\nJoining_Date DATE NOT NULL\n);\n> INSERT INTO t1\n(Employee_name, Joining_Date )\nVALUES\n('     Ananya Majumdar', '2000-01-11'),\n('   Anushka Samanta', '2002-11-10' ),\n('   Aniket Sharma ', '2005-06-11' ),\n('   Anik Das', '2008-01-21'  ),\n('  Riya Jain', '2008-02-01' ),\n('    Tapan Samanta', '2010-01-11' ),\n('   Deepak Sharma', '2014-12-01'  ),\n('   Ankana Jana', '2018-08-17'),\n('  Shreya Ghosh', '2020-09-10') ;\n> INSERT INTO t1\n(Employee_name, Joining_Date ) values('     ','2014-12-01');\n> select * from t1 where Employee_name=space(5);\n+---------------+--------------+\n| Employee_name | Joining_Date |\n+---------------+--------------+\n|               | 2014-12-01   |\n+---------------+--------------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/","title":"SPLIT_PART()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#description","title":"Description","text":"

      The SPLIT_PART() function is used to split a string into multiple parts based on a given delimiter and returns the specified part.

      If the specified part (designated by the unsigned_integer parameter) exceeds the actual number of existing parts, SPLIT_PART() will return NULL.

      SPLIT_PART() counts parts from left to right only. If unsigned_integer is a negative number, an error will occur.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#syntax","title":"Syntax","text":"
      > SPLIT_PART(expr, delimiter, unsigned_integer)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#arguments","title":"Arguments","text":"Arguments Description expr Required. The string to be split. delimiter Required. The delimiter used to split the string. unsigned_integer Required. This is an integer specifying which part of the string to return. The first part is 1, the second part is 2, and so on."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#examples","title":"Examples","text":"
      • Example 1
      -- Split the string 'axbxc' and use 'x' as the delimiter. This function will return the first part of the string 'axbxc'. Therefore, the result of executing this SQL statement is 'a' because 'a' is the first part of the string 'axbxc' split on the basis of the 'x' delimiter.\nmysql> select split_part('axbxc','x',1);\n+-------------------------+\n| split_part(axbxc, x, 1) |\n+-------------------------+\n| a                       |\n+-------------------------+\n1 row in set (0.00 sec)\n
      • Example 2
      -- Create a new table 't1' with three columns: 'a' (varchar type), 'b' (varchar type), and 'c' (int type).\ncreate table t1(a varchar,b varchar,c int);\n-- Insert multiple rows of data into the 't1' table\ninsert into t1 values('axbxc','x',1),('axbxcxd','x',2),('axbxcxd','x',3),('axbxcxd','xc',1),('axbxcxd','xc',2),('axbxcxd','xc',3),('axbxcxd','asas',1),('axbxcxd','asas',2),(null,'asas',3),('axbxcxd',null,3),('axbxcxd','asas',null),('axxx','x',1),('axxx','x',2);\n-- Query uses the split_part function to process each row in the 't1' table. For each row, it splits the value of the 'a' column into multiple parts (using the value of the 'b' column as the delimiter) and then returns the specified part (designated by the value of the 'c' column). For example, for the first row of data ('axbxc', 'x', 1), it returns 'a' because 'a' is the first part of the string 'axbxc' split on the basis of the 'x' delimiter.\nmysql> select split_part(a,b,c) from t1;\n+---------------------+\n| split_part(a, b, c) |\n+---------------------+\n| a                   |\n| b                   |\n| c                   |\n| axb                 |\n| xd                  |\n| NULL                |\n| axbxcxd             |\n| NULL                |\n| NULL                |\n| NULL                |\n| NULL                |\n| a                   |\n| NULL                |\n+---------------------+\n13 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/","title":"STARTSWITH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#description","title":"Description","text":"

      Returns 1 whether string starts with the specified prefix, otherwise it returns 0.This function is case sensitive.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#syntax","title":"Syntax","text":"
      > STARTSWITH(str,prefix)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR both are supported. prefix Required. CHAR and VARCHAR both are supported."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#returned-values","title":"Returned Values","text":"
      • 1, if the string starts with the specified prefix.
      • 0, if the string does not start with the specified prefix.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#examples","title":"Examples","text":"
      > drop table if exists t1;\n> create table t1(a int,b varchar(100),c char(20));\n> insert into t1 values\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> select a,startswith(b,'An') from t1;\n+------+-------------------+\n| a    | startswith(b, An) |\n+------+-------------------+\n|    1 |                 1 |\n|    2 |                 1 |\n|    3 |                 1 |\n|    4 |                 1 |\n|    5 |                 0 |\n|    6 |                 0 |\n+------+-------------------+\n> select a,b,c from t1 where startswith(b,'An')=1 and startswith(c,'I')=1;\n+------+-----------------+------+\n| a    | b               | c    |\n+------+-----------------+------+\n|    1 | Ananya Majumdar | IX   |\n+------+-----------------+------+\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/","title":"SUBSTRING_INDEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#description","title":"Description","text":"

      This function SUBSTRING_INDEX() returns the substring from string str before count occurrences of the delimiter delim.

      If count is positive, everything to the left of the final delimiter (counting from the left) is returned.

      If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.

      SUBSTRING_INDEX() returns NULL if any of its arguments are NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#syntax","title":"Syntax","text":"
      > SUBSTRING_INDEX(str,delim,count)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#arguments","title":"Arguments","text":"Arguments Description str A string. delim A delimiter. count An integer indicating the number of occurrences of delim."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#examples","title":"Examples","text":"
      mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);\n+--------------------------------------+\n| substring_index(www.mysql.com, ., 2) |\n+--------------------------------------+\n| www.mysql                            |\n+--------------------------------------+\n1 row in set (0.03 sec)\n\nmysql> select substring_index('xyz', 'abc', 9223372036854775808);\n+------------------------------------------------+\n| substring_index(xyz, abc, 9223372036854775808) |\n+------------------------------------------------+\n| xyz                                            |\n+------------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2);\n+---------------------------------------+\n| substring_index(www.mysql.com, ., -2) |\n+---------------------------------------+\n| mysql.com                             |\n+---------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('192,168,8,203', ',', 2), ',',-1);\n+--------------------------------------------------------------+\n| substring_index(substring_index(192,168,8,203, ,, 2), ,, -1) |\n+--------------------------------------------------------------+\n| 168                                                          |\n+--------------------------------------------------------------+\n1 row in set (0.02 sec)\n\ncreate table test(a varchar(100), b varchar(20), c int);\ninsert into test values('www.mysql.com', '.', 0);\ninsert into test values('www.mysql.com', '.', 1);\ninsert into test values('www.mysql.com', '.', 2);\ninsert into test values('www.mysql.com', '.', 3);\ninsert into test values('www.mysql.com', '.', 9223372036854775808);\ninsert into test values('www.mysql.com', '.', -1);\ninsert into test values('www.mysql.com', '.', -2);\ninsert into test values('www.mysql.com', '.', -3);\nmysql> select SUBSTRING_INDEX(a, b, c) from test;\n+--------------------------+\n| substring_index(a, b, c) |\n+--------------------------+\n|                          |\n| www                      |\n| www.mysql                |\n| www.mysql.com            |\n| com                      |\n| mysql.com                |\n| www.mysql.com            |\n+--------------------------+\n7 rows in set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/","title":"SUBSTRING()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#description","title":"Description","text":"

      SUBSTR() and MID() are both synonyms of SUBSTRING(). The forms without a len argument return a substring from string str starting at position pos. The forms with a len argument return a substring len characters long from string str, starting at position pos.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#syntax","title":"Syntax","text":"
      > SUBSTRING(str,pos)\n> SUBSTR(str,pos,len)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR are both supported pos Required. len Optional."},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#examples","title":"Examples","text":"
      > CREATE TABLE IF NOT EXISTS t1 (\npub_id varchar(8) COLLATE latin1_general_ci NOT NULL DEFAULT '',\npub_name varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT '',\npub_city varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\ncountry varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\ncountry_office varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\nno_of_branch int NOT NULL DEFAULT 0,\nestd date NOT NULL DEFAULT '2000-01-01'\n);\n\n> INSERT INTO t1 (pub_id, pub_name, pub_city, country, country_office, no_of_branch, estd) VALUES\n('P001', 'Jex Max Publication', 'New York', 'USA', 'New York', 15, '1969-12-25'),\n('P002', 'BPP Publication', 'Mumbai', 'India', 'New Delhi', 10, '1985-10-01'),\n('P003', 'New Harrold Publication', 'Adelaide', 'Australia', 'Sydney', 6, '1975-09-05'),\n('P004', 'Ultra Press Inc.', 'London', 'UK', 'London', 8, '1948-07-10'),\n('P005', 'Mountain Publication', 'Houstan', 'USA', 'Sun Diego', 25, '1975-01-01'),\n('P006', 'Summer Night Publication', 'New York', 'USA', 'Atlanta', 10, '1990-12-10'),\n('P007', 'Pieterson Grp. of Publishers', 'Cambridge', 'UK', 'London', 6, '1950-07-15'),\n('P008', 'Novel Publisher Ltd.', 'New Delhi', 'India', 'Bangalore', 10, '2000-01-01');\n\n> SELECT pub_name, SUBSTR(pub_name,4,5) FROM t1 WHERE country='USA';\n+--------------------------+------------------------+\n| pub_name                 | substr(pub_name, 4, 5) |\n+--------------------------+------------------------+\n| Jex Max Publication      |  Max                   |\n| Mountain Publication     | ntain                  |\n| Summer Night Publication | mer N                  |\n+--------------------------+------------------------+\n3 rows in set (0.04 sec)\n\n> SELECT pub_name, SUBSTR(pub_name,5) FROM t1 WHERE country='USA';\n+--------------------------+----------------------+\n| pub_name                 | substr(pub_name, 5)  |\n+--------------------------+----------------------+\n| Jex Max Publication      | Max Publication      |\n| Mountain Publication     | tain Publication     |\n| Summer Night Publication | er Night Publication |\n+--------------------------+----------------------+\n3 rows in set (0.03 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/","title":"TRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#description","title":"Description","text":"

      This function TRIM() returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.

      This function is multibyte safe. It returns NULL if any of its arguments are NULL.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#syntax","title":"Syntax","text":"
      > TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#arguments","title":"Arguments","text":"Arguments Description str Required. CHAR and VARCHAR are both supported"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#examples","title":"Examples","text":"
      mysql> select trim(' abc '), trim('abc '), trim(' abc'), trim('abc');\n+-------------+------------+------------+-----------+\n| trim( abc ) | trim(abc ) | trim( abc) | trim(abc) |\n+-------------+------------+------------+-----------+\n| abc         | abc        | abc        | abc       |\n+-------------+------------+------------+-----------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\ncreate table t1(a varchar(100), b varchar(100));\ninsert into t1 values('abc', 'abc');\ninsert into t1 values('\u554aabc\u54e6', '\u554aabc\u54e6');\ninsert into t1 values('\u554a\u554ao', 'o');\ninsert into t1 values('\u554a\u554ao', '\u554a');\ninsert into t1 values('\u554a\u554ao', 'o\u554a');\nmysql> select trim(both a from b) from t1;\n+---------------------+\n| trim(both a from b) |\n+---------------------+\n|                     |\n|                     |\n| o                   |\n| \u554a                  |\n| o\u554a                 |\n+---------------------+\n5 rows in set (0.00 sec)\n\nmysql> select trim(leading a from b) from t1;\n+------------------------+\n| trim(leading a from b) |\n+------------------------+\n|                        |\n|                        |\n| o                      |\n| \u554a                     |\n| o\u554a                    |\n+------------------------+\n5 rows in set (0.01 sec)\n\nmysql> select trim(trailing a from b) from t1;\n+-------------------------+\n| trim(trailing a from b) |\n+-------------------------+\n|                         |\n|                         |\n| o                       |\n| \u554a                      |\n| o\u554a                     |\n+-------------------------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/","title":"Regular Expressions Overview","text":"

      Regular expressions provide a powerful method for matching text patterns. You can use simple wildcards (such as %, _) in LIKE statements, but regular expressions offer more flexibility and matching options.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/#scenarios","title":"Scenarios","text":"

      Regular expressions can perform complex string matching and manipulation. Here are some common use cases:

      • Data Validation: Regular expressions can validate whether data complies with a specific format, such as checking whether a field contains a valid email address, phone number, or social security number. For example, you can use a regular expression to find all email addresses that do not conform to the standard format:

        SELECT email\nFROM users\nWHERE email NOT REGEXP '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\\.[A-Za-z]{2,}$';\n
      • Data Filtering: Regular expressions can be used to search for data that contains or does not contain specific patterns. For example, if you want to find all phone numbers that start with a specific prefix, you can use a regular expression to match these numbers:

        SELECT phone_number\nFROM users\nWHERE phone_number REGEXP '^180';\n
      • Data Cleaning: Regular expressions are also instrumental in data cleaning. For example, you may need to clear special characters and spaces or extract numbers from strings; regular expressions can quickly implement these functions:

        SELECT REGEXP_REPLACE(name, '[^a-zA-Z]', '')\nFROM users;\n

        This SQL will return the result of all non-alphabetical characters in the name field being replaced.

      • Text Analysis: If you are conducting text analysis, regular expressions can help you find specific words or phrases in the text and can even be used for certain forms of natural language processing.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/#special-characters","title":"Special Characters","text":"

      Regular expressions use POSIX (Portable Operating System Interface) extended regular expressions. Here are some special characters to note:

      Character Explanation . Matches any single character (except a newline) * Indicates the preceding element can be repeated any number of times (including zero times) + Indicates the preceding element can be repeated one or more times. ? Indicates the primary element can be repeated zero or once. {n} Indicates the primary element can be repeated n times. {n,} Indicates the primary element can be repeated n times or more. {n,m} Indicates the primary element can be repeated from n to m times. ^ Indicates matching the beginning of the string. $ Indicates matching the end of the string. [abc] Indicates matching a, b, or c. [^abc] Indicates matching any character that is not a, b, or c. (abc|def) Indicates matching abc or def. \\d Indicates matching numbers \\s Indicates matching whitespace characters \\w Indicates matching word characters \\D, \\S and \\W Indicate matching opposite character sets

      Note

      In regular expressions, these special characters need to be escaped using \\; for example, \\\\. indicates matching an actual . character, not any character.

      MatrixOne's regular expressions are case-sensitive by default. If you want to perform case-insensitive matching, you can use syntax like REGEXP_LIKE(column, pattern, 'i'). Where i indicates case insensitivity.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/#reference","title":"Reference","text":"

      List of Regular Expression Functions

      Name Definition NOT REGEXP Negation of REGEXP REGEXP_INSTR() Starting index of substring matching regular expression REGEXP_LIKE() Whether string matches regular expression REGEXP_REPLACE() Replace substring matching regular expression REGEXP_SUBSTR() Return substring matching regular expression"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/","title":"NOT REGEXP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#description","title":"Description","text":"

      NOT REGEXP is used to test whether a string does not match a specified regular expression.

      If column_name does not match pattern, it returns TRUE. If it matches, it returns FALSE.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#syntax","title":"Syntax","text":"
      > column_name NOT REGEXP pattern\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#explanations","title":"Explanations","text":"
      • column_name is the column to match.

      • pattern is the regular expression to apply.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#examples","title":"Examples","text":"
      CREATE TABLE example (\nid INT AUTO_INCREMENT,\ntext VARCHAR(255),\nPRIMARY KEY(id)\n);\n\n\nINSERT INTO example (text)\nVALUES ('Hello1'),\n('Hello2'),\n('World'),\n('HelloWorld'),\n('Hello_World'),\n('example'),\n('example1'),\n('example2');\n\nmysql> SELECT * FROM example WHERE text NOT REGEXP '[0-9]';\n+------+-------------+\n| id   | text        |\n+------+-------------+\n|    3 | World       |\n|    4 | HelloWorld  |\n|    5 | Hello_World |\n|    6 | example     |\n+------+-------------+\n4 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/","title":"REGEXP_INSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#description","title":"Description","text":"

      REGEXP_INSTR() returns the starting position in the string of the matched regular expression pattern. If no match is found, the function returns 0.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#syntax","title":"Syntax","text":"
      > REGEXP_INSTR(expr, pat[, pos[, occurrence[, return_option[, match_type]]]])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#explanations","title":"Explanations","text":"
      • expr is the string to match.

      • pat is the regular expression to match in the string.

      • pos: The position in expr at which to start the search. If omitted, the default is 1.

      • occurrence: Which occurrence of a match to replace. If omitted, the default is 0 (which means replace all occurrences).

      • return_option: This is an optional parameter specifying whether the returned position is where the pattern starts or ends. If 0 or omitted, the function returns the position at which the pattern begins. If 1, the function returns the position after the position where the pattern ends.

      • match_type: The optional match_type argument is a string that may contain any or all the following characters specifying how to perform matching:

        • 'c': Case-sensitive matching by default.
        • 'i': Case-insensitive matching.
        • 'n': The . character matches line terminators. The default is for . matching to stop at the end of a line.
        • 'm': Multiple-line mode. Recognize line terminators within the string. The default behavior is to match line terminators only at the start and end of the string expression.
        • 'u': Unix-only line endings. Only the newline character is recognized as a line ending by the ., ^, and $ match operators.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#examples","title":"Examples","text":"
      mysql> SELECT REGEXP_INSTR('Hello, my number is 12345.', '[0-9]+');\n+--------------------------------------------------+\n| regexp_instr(Hello, my number is 12345., [0-9]+) |\n+--------------------------------------------------+\n|                                               21 |\n+--------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('apple', 'z+');\n+-------------------------+\n| regexp_instr(apple, z+) |\n+-------------------------+\n|                       0 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('Hello, World!', 'World');\n+------------------------------------+\n| regexp_instr(Hello, World!, World) |\n+------------------------------------+\n|                                  8 |\n+------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('Hello, World! World!', 'World', 1, 2);\n+-------------------------------------------------+\n| regexp_instr(Hello, World! World!, World, 1, 2) |\n+-------------------------------------------------+\n|                                              15 |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/","title":"REGEXP_LIKE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#description","title":"Description","text":"

      Returns TRUE if the string expr matches the regular expression specified by the pattern pat, FALSE otherwise. If expr or pat is NULL, the return value is NULL.

      REGEXP and RLIKE are synonyms for REGEXP_LIKE().

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#syntax","title":"Syntax","text":"
      > REGEXP_LIKE(expr, pat[, match_type])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#explanations","title":"Explanations","text":"
      • expr is the string to search for.

      • pat is a regular expression to look for in the string.

      • match_type: The optional match_type argument is a string that may contain any or all the following characters specifying how to perform matching:

        • 'c': Case-sensitive matching by default.
        • 'i': Case-insensitive matching.
        • 'n': The . character matches line terminators. The default is for . matching to stop at the end of a line.
        • 'm': Multiple-line mode. Recognize line terminators within the string. The default behavior is to match line terminators only at the start and end of the string expression.
        • 'u': Unix-only line endings. Only the newline character is recognized as a line ending by the ., ^, and $ match operators.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#examples","title":"Examples","text":"
      mysql> SELECT REGEXP_INSTR('Hello, my number is 12345.', '[0-9]+');\n+--------------------------------------------------+\n| regexp_instr(Hello, my number is 12345., [0-9]+) |\n+--------------------------------------------------+\n|                                               21 |\n+--------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('apple', 'z+');\n+-------------------------+\n| regexp_instr(apple, z+) |\n+-------------------------+\n|                       0 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_LIKE('CamelCase', 'CAMELCASE');\n+-----------------------------------+\n| regexp_like(CamelCase, CAMELCASE) |\n+-----------------------------------+\n| false                             |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT REGEXP_LIKE('CamelCase', 'CAMELCASE', 'i');\n+--------------------------------------+\n| regexp_like(CamelCase, CAMELCASE, i) |\n+--------------------------------------+\n| true                                 |\n+--------------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/","title":"REGEXP_REPLACE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#description","title":"Description","text":"

      REGEXP_REPLACE() is used to replace a string matching a given regular expression pattern with the specified new string.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#syntax","title":"Syntax","text":"
      > REGEXP_REPLACE(expr, pat, repl[, pos[, occurrence[, match_type]]])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#explanations","title":"Explanations","text":"
      • expr is the string to replace.

      • pat This is a regular expression, the function will find all strings that match this pattern.

      • repl is the replacement string used to replace the found matching string.

      • pos: The position in expr at which to start the search. If omitted, the default is 1.

      • occurrence: Which occurrence of a match to replace. If omitted, the default is 0 (which means replace all occurrences).

      • match_type: The optional match_type argument is a string that may contain any or all the following characters specifying how to perform matching:

        • 'c': Case-sensitive matching by default.
        • 'i': Case-insensitive matching.
        • 'n': The . character matches line terminators. The default is for . matching to stop at the end of a line.
        • 'm': Multiple-line mode. Recognize line terminators within the string. The default behavior is to match line terminators only at the start and end of the string expression.
        • 'u': Unix-only line endings. Only the newline character is recognized as a line ending by the ., ^, and $ match operators.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#examples","title":"Examples","text":"
      mysql> SELECT REGEXP_REPLACE('Hello, World!', 'World', 'Universe');\n+------------------------------------------------+\n| regexp_replace(Hello, World!, World, Universe) |\n+------------------------------------------------+\n| Hello, Universe!                               |\n+------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat','Cat', 'Tiger') 'Result';\n+---------------------------+\n| Result                    |\n+---------------------------+\n| Tiger Dog Tiger Dog Tiger |\n+---------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/","title":"REGEXP_SUBSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#description","title":"Description","text":"

      REGEXP_SUBSTR() is used to return the substring of the string expr that matches the regular expression pattern pat.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#syntax","title":"Syntax","text":"
      > REGEXP_SUBSTR(expr, pat[, pos[, occurrence[, match_type]]])\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#explanations","title":"Explanations","text":"
      • expr: This is the original string in which to look for matches.

      • pat: This is a regular expression pattern, the function will look for strings that match this pattern.

      • pos: The position in expr at which to start the search. If omitted, the default is 1.

      • occurrence: Which occurrence of a match to replace. If omitted, the default is 0 (which means replace all occurrences).

      • match_type: The optional match_type argument is a string that may contain any or all the following characters specifying how to perform matching:

        • 'c': Case-sensitive matching by default.
        • 'i': Case-insensitive matching.
        • 'n': The . character matches line terminators. The default is for . matching to stop at the end of a line.
        • 'm': Multiple-line mode. Recognize line terminators within the string. The default behavior is to match line terminators only at the start and end of the string expression.
        • 'u': Unix-only line endings. Only the newline character is recognized as a line ending by the ., ^, and $ match operators.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#examples","title":"Examples","text":"
      mysql> SELECT REGEXP_SUBSTR('1a 2b 3c', '[0-9]a');\n+---------------------------------+\n| regexp_substr(1a 2b 3c, [0-9]a) |\n+---------------------------------+\n| 1a                              |\n+---------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_SUBSTR('Lend for land', '^C') Result;\n+--------+\n| Result |\n+--------+\n| NULL   |\n+--------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/","title":"UNNEST()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#description","title":"Description","text":"

      The UNNEST function is used to expand the column or parameter of the array type in the JSON type data into a table. It splits the elements in the array in the JSON-type data into individual rows so that the array elements can be processed individually or joined with other tables.

      When given an empty array, the UNNEST function returns an empty list because there are no additional elements.

      When a NULL value is entered, the UNNEST function returns an empty table because NULL is not a valid array.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#syntax","title":"Syntax","text":"
      > UNNEST(array_expression)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#arguments","title":"Arguments","text":"Arguments Description array_expression Required. It is an array expression that can be an array column, an array constant, or the return value of an array function."},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#examples","title":"Examples","text":"
      • Example 1:
      -- Expand a string array containing JSON objects, '{\"a\":1}' is a string array containing a single element. This element is a string representing a JSON object.\n> select * from unnest('{\"a\":1}') u;\n+----------------+------+------+------+-------+-------+----------+\n| col            | seq  | key  | path | index | value | this     |\n+----------------+------+------+------+-------+-------+----------+\n| UNNEST_DEFAULT |    0 | a    | $.a  |  NULL | 1     | {\"a\": 1} |\n+----------------+------+------+------+-------+-------+----------+\n1 row in set (0.00 sec)\n\n-- Expand a string array '[1,2,3]' containing integers, and use the alias u to represent the expanded columns.\n> select * from unnest('[1,2,3]') u;\n+----------------+------+------+------+-------+-------+-----------+\n| col            | seq  | key  | path | index | value | this      |\n+----------------+------+------+------+-------+-------+-----------+\n| UNNEST_DEFAULT |    0 | NULL | $[0] |     0 | 1     | [1, 2, 3] |\n| UNNEST_DEFAULT |    0 | NULL | $[1] |     1 | 2     | [1, 2, 3] |\n| UNNEST_DEFAULT |    0 | NULL | $[2] |     2 | 3     | [1, 2, 3] |\n+----------------+------+------+------+-------+-------+-----------+\n3 rows in set (0.00 sec)\n\n-- Expands a string array '[1,2,3]' containing integers and selects the first element of the array to return as part of the result set. '$[0]' is a path expression specifying the array elements to select, and true is a boolean indicating whether to return a path and uses the alias u for expanded columns.\n> select * from unnest('[1,2,3]','$[0]',true) u;\n+----------------+------+------+------+-------+-------+------+\n| col            | seq  | key  | path | index | value | this |\n+----------------+------+------+------+-------+-------+------+\n| UNNEST_DEFAULT |    0 | NULL | $[0] |  NULL | NULL  | 1    |\n+----------------+------+------+------+-------+-------+------+\n1 row in set (0.00 sec)\n
      • Example 2:
      create table t1 (a json,b int);\ninsert into t1 values ('{\"a\":1,\"b\":[{\"c\":2,\"d\":3},false,4],\"e\":{\"f\":true,\"g\":[null,true,1.1]}}',1);\ninsert into t1 values ('[1,true,false,null,\"aaa\",1.1,{\"t\":false}]',2);\n> select * from t1;\n+---------------------------------------------------------------------------------------+------+\n| a                                                                                     | b    |\n+---------------------------------------------------------------------------------------+------+\n| {\"a\": 1, \"b\": [{\"c\": 2, \"d\": 3}, false, 4], \"e\": {\"f\": true, \"g\": [null, true, 1.1]}} |    1 |\n| [1, true, false, null, \"aaa\", 1.1, {\"t\": false}]                                      |    2 |\n+---------------------------------------------------------------------------------------+------+\n2 rows in set (0.00 sec)\n\n-- Expand the elements of array t1.a from table t1 and select the expanded elements to return as part of the result set. \"$a\" is a path expression specifying the array elements to select; true is a Boolean value indicating whether to return the path; use f.* to select all columns after expansion; f is an alias for the UNNEST function, representing expanded the result of.\nmysql> select f.* from t1,unnest(t1.a, \"$.a\", true) as f;\n+------+------+------+------+-------+-------+------+\n| col  | seq  | key  | path | index | value | this |\n+------+------+------+------+-------+-------+------+\n| t1.a |    0 | NULL | $.a  |  NULL | NULL  | 1    |\n| t1.a |    0 | NULL | $.a  |  NULL | NULL  | 1    |\n+------+------+------+------+-------+-------+------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/","title":"DENSE_RANK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/#description","title":"Description","text":"

      DENSE_RANK() gives each row in the dataset a unique rank, very similar to the RANK() function. The DENSE_RANK() function first sorts the dataset according to the columns specified in the ORDER BY clause, then assigns each row a unique rank.

      The DENSE_RANK() function handles ties (i.e., two or more rows with the same value) slightly differently than the RANK() function. In the case of a link, DENSE_RANK() will assign the same rank to all rows with the same value but will not skip any ranks immediately following it. For example, if two rows rank 1, the next row gets rank 2, not 3.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/#syntax","title":"Syntax","text":"
      > DENSE_RANK() OVER (\n    [PARTITION BY column_1, column_2, ... ]\n    ORDER BY column_3, column_4, ...\n)\n
      • The PARTITION BY clause is optional and divides the dataset into partitions; the rank is computed individually inside each partition.
      • The ORDER BY clause defines how the dataset is sorted, i.e., according to which column or columns to sort. You can specify ascending (ASC) or descending (DESC) sorting.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/#examples","title":"Examples","text":"
      -- Create a new table, 'SalesTable' with three fields: 'Department', 'Employee', and 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- Insert data into the 'SalesTable' table; each row contains a department (Department), an employee (Employee), and their sales (Sales)\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- Query the 'SalesTable' table and return the employee's name, their sales, and their sales rank (using the 'DENSE_RANK()' function)\n-- In this query, the 'DENSE_RANK()' function ranks all employees in descending order of sales (specified by 'ORDER BY Sales DESC')\n-- If multiple employees have the same sales, they will get the same rank, and the rank of the next sales will not be skipped. So, if two employees are number one in sales, the next employee is number two, not number three.\nmysql> SELECT\nEmployee,\nSales,\nDENSE_RANK() OVER(ORDER BY Sales DESC) FROM\nSalesTable;\n+----------+-------+-----------------------------------------+\n| employee | sales | dense_rank() over (order by sales desc) |\n+----------+-------+-----------------------------------------+\n| Jane     |  1200 |                                       1 |\n| Bob      |  1100 |                                       2 |\n| John     |  1000 |                                       3 |\n| Alex     |   900 |                                       4 |\n| Charlie  |   850 |                                       5 |\n| Alice    |   800 |                                       6 |\n+----------+-------+-----------------------------------------+\n6 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/","title":"RANK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/#description","title":"Description","text":"

      RANK() provides a unique rank for each row in the dataset. RANK() first sorts the dataset according to the columns specified in the ORDER BY clause, then assigns each row a unique rank.

      The RANK() function has a unique behavior when it handles the case of equal values \u200b\u200b(i.e., tie). When two or more rows have the same value, they get the same rank. It will then skip the rank or ranks that follow it. For example, if two rows rank 1, the next row gets rank 3, not 2.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/#syntax","title":"Syntax","text":"
      > RANK() OVER (\n    [PARTITION BY column_1, column_2, ... ]\n    ORDER BY column_3, column_4, ...\n)\n
      • The PARTITION BY clause is optional and divides the dataset into partitions; the rank is computed individually inside each partition.
      • The ORDER BY clause defines how the dataset is sorted, i.e., according to which column or columns to sort. You can specify ascending (ASC) or descending (DESC) sorting.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/#examples","title":"Examples","text":"
      -- Create a new table, 'SalesTable' with three fields: 'Department', 'Employee', and 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- Insert data into the 'SalesTable' table; each row contains a department (Department), an employee (Employee), and their sales (Sales)\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- Query the 'SalesTable' table and return each employee in each department, their sales, and the total sales of their department (DepartmentSales)\n-- will also return each employee's sales rank in their department (SalesRank)\n-- For the total sales, use the window function SUM(), and use 'OVER(PARTITION BY Department)' to calculate each department separately\n-- For sales ranking, use the window function RANK(), and use 'OVER(PARTITION BY Department ORDER BY Sales DESC)' to rank employees in each department in descending order by sales\n-- In the RANK() function, if two employees have the same sales, they get the same rank, and the next sales rank is skipped. For example, if two employees are number one in sales, the next sales rank is number three, not number two.\nmysql> SELECT\nDepartment,\nEmployee,\nSales,\nSUM(Sales) OVER(PARTITION BY Department) AS DepartmentSales,\nRANK() OVER(PARTITION BY Department ORDER BY Sales DESC) AS SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------------+-----------+\n| department | employee | sales | DepartmentSales | SalesRank |\n+------------+----------+-------+-----------------+-----------+\n| HR         | Charlie  |   850 |            1650 |         1 |\n| HR         | Alice    |   800 |            1650 |         2 |\n| Marketing  | Jane     |  1200 |            2200 |         1 |\n| Marketing  | John     |  1000 |            2200 |         2 |\n| Sales      | Bob      |  1100 |            2000 |         1 |\n| Sales      | Alex     |   900 |            2000 |         2 |\n+------------+----------+-------+-----------------+-----------+\n6 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/","title":"ROW_NUMBER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/#description","title":"Description","text":"

      ROW_NUMBER() provides a unique ordinal number for each row in the dataset, starting at one and ending with the last row in the result set. It first sorts the dataset according to the columns specified in the ORDER BY clause and then assigns each row a unique number.

      Unlike the RANK() and DENSE_RANK() functions, ROW_NUMBER() gives each row a different row number when dealing with ties (i.e., two or more rows with the same value).

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/#syntax","title":"Syntax","text":"
      > ROW_NUMBER() OVER (\n    [PARTITION BY column_1, column_2, ... ]\n    ORDER BY column_3, column_4, ...\n)\n
      • The PARTITION BY clause is optional and divides the dataset into partitions; the rank is computed individually inside each partition.
      • The ORDER BY clause defines how the dataset is sorted, i.e., according to which column or columns to sort. You can specify ascending (ASC) or descending (DESC) sorting.
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/#examples","title":"Examples","text":"
      -- Create a new table, 'SalesTable' with three fields: 'Department', 'Employee', and 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- Insert data into the 'SalesTable' table; each row contains a department (Department), an employee (Employee), and their sales (Sales)\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- Query the sales ranking of employees in each department\n-- Use the ROW_NUMBER() function to rank employees by Department (Sales)\n-- The ROW_NUMBER() function divides the data set into multiple partitions according to the department (Department), then sorts the sales in descending order within each partition, and assigns each row a unique row number (SalesRank )\n-- So, the employee with the highest sales in each department will get row number 1, the employee with the second highest sales will get row number 2, and so on\nmysql> SELECT\nDepartment,\nEmployee,\nSales,\nROW_NUMBER() OVER (PARTITION BY Department ORDER BY Sales DESC) as SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------+\n| department | employee | sales | SalesRank |\n+------------+----------+-------+-----------+\n| HR         | Charlie  |   850 |         1 |\n| HR         | Alice    |   800 |         2 |\n| Marketing  | Jane     |  1200 |         1 |\n| Marketing  | John     |  1000 |         2 |\n| Sales      | Bob      |  1100 |         1 |\n| Sales      | Alex     |   900 |         2 |\n+------------+----------+-------+-----------+\n6 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/","title":"CURRENT_ROLE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#description","title":"Description","text":"

      Returns the role of the current session.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#syntax","title":"Syntax","text":"
      SELECT CURRENT_ROLE();\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#examples","title":"Examples","text":"
      mysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin        |\n+----------------+\n1 row in set (0.00 sec)\n\n-- Create a role and switch to the new role\ncreate role use_role_1;\ngrant all on database * to use_role_1;\ngrant use_role_1 to root;\nset role use_role_1;\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| use_role_1     |\n+----------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/","title":"CURRENT_ROLE_NAME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#description","title":"Description","text":"

      CURRENT_ROLE_NAME() is used to query the name of the role owned by the user you are currently logged in.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#syntax","title":"Syntax","text":"
      > CURRENT_ROLE_NAME()\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#examples","title":"Examples","text":"
      mysql> select current_role_name();\n+---------------------+\n| current_role_name() |\n+---------------------+\n| moadmin             |\n+---------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/","title":"CURRENT_USER, CURRENT_USER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#description","title":"Description","text":"

      Returns the current user account; the returned account format is username@hostname. The return value is a string in the utf8mb3 character set.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#syntax","title":"Syntax","text":"
      SELECT CURRENT_USER();\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#examples","title":"Examples","text":"
      mysql> select current_user();\n+----------------+\n| current_user() |\n+----------------+\n| root@0.0.0.0   |\n+----------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/","title":"CURRENT_USER_NAME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#description","title":"Description","text":"

      CURRENT_USER_NAME() is used to query the name of the user you are currently logged in as.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#syntax","title":"Syntax","text":"
      > CURRENT_USER_NAME()\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#examples","title":"Examples","text":"
      mysql> select current_user_name();\n+---------------------+\n| current_user_name() |\n+---------------------+\n| root                |\n+---------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/","title":"PURGE_LOG()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#description","title":"Description","text":"

      PURGE_LOG() deletes logs recorded in MatrixOne database system tables. Returning 0 means the deletion is successful; if the deletion fails, an error message will be returned.

      Note

      Only the root user (cluster administrator with MOADMIN privilege) can execute the PURGE_LOG() function for log deletion.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#syntax","title":"Syntax","text":"
      > PURGE_LOG('sys_table_name', 'date')\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#arguments","title":"Arguments","text":"Arguments Description 'sys_table_name' Currently, there are only three system tables that can be deleted: metric, rawlog, and statement_info. Note: 'sys_table_name' must be enclosed in quotes. 'date' Select a date and delete logs generated before that date. Note: 'date' must be enclosed in single quotes.

      Note

      MatrixOne has only three system log tables: metric, rawlog, and statement_info. For more information about these three tables, please refer to MatrixOne System Database and Tables.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#examples","title":"Examples","text":"
      • Example 1:
      -- Delete the statement_info type logs before 2023-06-30\nmysql> select purge_log('statement_info', '2023-06-30') a;\n+------+\n| a    |\n+------+\n| 0    |\n+------+\n1 row in set (0.01 sec)\n
      • Example 2:
      -- Query the time and quantity of metric log collection\nmysql> select date(collecttime), count(1) from system_metrics.metric group by date(collecttime);\n+-------------------+----------+\n| date(collecttime) | count(1) |\n+-------------------+----------+\n| 2023-07-07        |    20067 |\n| 2023-07-06        |    30246 |\n| 2023-07-05        |    27759 |\n+-------------------+----------+\n3 rows in set (0.00 sec)\n\n-- Delete rawlog, statement_info, and metric logs before 2023-07-06\nmysql> select purge_log('rawlog, statement_info, metric', '2023-07-06');\n+-------------------------------------------------------+\n| purge_log(rawlog, statement_info, metric, 2023-07-06) |\n+-------------------------------------------------------+\n|                                                     0 |\n+-------------------------------------------------------+\n1 row in set (0.33 sec)\n\n-- Query the number of metric logs for the three days of 2023-07-05, 2023-07-06 and 2023-07-07 again\nmysql> select date(collecttime), count(1) from system_metrics.metric group by date(collecttime);\n+-------------------+----------+\n| date(collecttime) | count(1) |\n+-------------------+----------+\n| 2023-07-06        |    30246 |\n| 2023-07-07        |    20121 |\n+-------------------+----------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/","title":"VERSION","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#description","title":"Description","text":"

      The VERSION() function is used to retrieve the version information of the current database management system. This function typically returns a string containing the version number of the database management system. For example, 0.8 indicates that the version of the MatrixOne database is 0.8.

      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#syntax","title":"Syntax","text":"
      > VERSION()\n
      "},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#example","title":"Example","text":"
      mysql> select version();\n+-----------+\n| version() |\n+-----------+\n| 0.8       |\n+-----------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Language-Structure/comment/","title":"Comments","text":"

      This document describes the comment syntax supported by MatrixOne.

      MatrixOne supports three comment styles:

      • Use # character to comment a line.
      mysql> select 100-99;   # This comment continues to the end of line\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.01 sec)\n
      • Use -- to comment a line. The -- (double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on).
      mysql> select 100-99;   -- This comment continues to the end of line\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.01 sec)\n
      • From a /* sequence to the following */ sequence, as in the C programming language. This syntax enables a comment to extend over multiple lines because the beginning and closing sequences need not be on the same line.
      mysql> select 100 /* this is an in-line comment */ -99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.01 sec)\n

      Or:

      mysql> select 100\n/*\nthis is an in-line comment\n*/\n-99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Language-Structure/comment/#mysql-compatible-comment-syntax","title":"MySQL-compatible comment syntax","text":"

      The same as MySQL, MatrixOne supports a variant of C comment style:

      mysql> select 100 /*! Specific code */ -99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.02 sec)\n

      Or:

      mysql> select 100 /*!50110 Specific code */ -99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/Language-Structure/comment/#matrixone-specific-comment-syntax","title":"MatrixOne specific comment syntax","text":"

      MatrixOne supports a variant of C comment style:

      mysql> select 100-99;   // This comment continues to the end of line\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n1 row in set (0.03 sec)\n

      Or:

      mysql> // This comment continues to the line\n-> select 100-99;\n+----------+\n| 100 - 99 |\n+----------+\n|        1 |\n+----------+\n
      "},{"location":"MatrixOne/Reference/Language-Structure/comment/#constraints","title":"Constraints","text":"

      MatrixOne does not support nested comments.

      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/","title":"Keywords","text":"

      This document introduces the keywords of MatrixOne. In MatrixOne, reserved keywords and non-reserved keywords are classified. When you use SQL statements, you can check reserved keywords and non-reserved keywords.

      Keyword is a word with a special meaning in SQL statements, such as SELECT, UPDATE, DELETE, and so on.

      • Reserved keyword: A word in a keyword that requires special processing before it can be used as an identifier is called a reserved keyword.

      When using reserved keywords as identifiers, they must be wrapped with backticks. Otherwise, an error will be reported:

      \\\\The reserved keyword select is not wrapped in backticks, resulting in an error.\nmysql> CREATE TABLE select (a INT);\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 19 near \" select (a INT)\";\n\n\\\\Correctly wrap the reserved keyword select with backticks.\nmysql> CREATE TABLE `select` (a INT);\nQuery OK, 0 rows affected (0.02 sec)\n
      • Non-reserved keywords: keywords can be directly used as identifiers, called non-reserved keywords.

      When using non-reserved keywords as identifiers, they can be used directly without wrapping them in backticks.

      \\\\BEGIN is not a reserved keyword and can be wrapped without backticks.\nmysql> CREATE TABLE `select` (BEGIN int);\nQuery OK, 0 rows affected (0.01 sec)\n

      Note

      Unlike MySQL, in MatrixOne, if the qualifier . is used, an error will be reported if the reserved keywords are not wrapped in backticks. It is recommended to avoid using reserved keywords when creating tables and databases:

      mysql> CREATE TABLE test.select (BEGIN int);\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 24 near \"select (BEGIN int)\";\n
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#reserved-keyword","title":"Reserved keyword","text":""},{"location":"MatrixOne/Reference/Language-Structure/keywords/#a","title":"A","text":"
      • ADD
      • ADMIN_NAME
      • ALL
      • AND
      • AS
      • ASC
      • ASCII
      • AUTO_INCREMENT
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#b","title":"B","text":"
      • BETWEEN
      • BINARY
      • BY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#c","title":"C","text":"
      • CASE
      • CHAR
      • CHARACTER
      • CHECK
      • COLLATE
      • COLLATION
      • CONVERT
      • COALESCE
      • COLUMN_NUMBER
      • CONSTRAINT
      • CREATE
      • CROSS
      • CURRENT
      • CURRENT_DATE
      • CURRENT_ROLE
      • CURRENT_USER
      • CURRENT_TIME
      • CURRENT_TIMESTAMP
      • CIPHER
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#d","title":"D","text":"
      • DATABASE
      • DATABASES
      • DECLARE
      • DEFAULT
      • DELAYED
      • DELETE
      • DESC
      • DESCRIBE
      • DISTINCT
      • DISTINCTROW
      • DIV
      • DROP
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#e","title":"E","text":"
      • ELSE
      • ENCLOSED
      • END
      • ESCAPE
      • ESCAPED
      • EXCEPT
      • EXISTS
      • EXPLAIN
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#f","title":"F","text":"
      • FALSE
      • FAILED_LOGIN_ATTEMPTS
      • FIRST
      • FOLLOWING
      • FOR
      • FORCE
      • FOREIGN
      • FROM
      • FULLTEXT
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#g","title":"G","text":"
      • GROUP
      • GROUPS
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#h","title":"H","text":"
      • HAVING
      • HOUR
      • HIGH_PRIORITY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#i","title":"I","text":"
      • IDENTIFIED
      • IF
      • IGNORE
      • IMPORT
      • IN
      • INFILE
      • INDEX
      • INNER
      • INSERT
      • INTERVAL
      • INTO
      • INT1
      • INT2
      • INT3
      • INT4
      • INT8
      • IS
      • ISSUER
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#j","title":"J","text":"
      • JOIN
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#k","title":"K","text":"
      • KEY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#l","title":"L","text":"
      • LAST
      • LEADING
      • LEFT
      • LIKE
      • LIMIT
      • LINES
      • LOAD
      • LOCALTIME
      • LOCALTIMESTAMP
      • LOCK
      • LOCKS
      • LOW_PRIORITY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#m","title":"M","text":"
      • MATCH
      • MAXVALUE
      • MICROSECOND
      • MINUTE
      • MOD
      • MODUMP
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#n","title":"N","text":"
      • NATURAL
      • NODE
      • NOT
      • NONE
      • NULL
      • NULLS
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#o","title":"O","text":"
      • ON
      • OPTIONAL
      • OPTIONALLY
      • OR
      • ORDER
      • OUTER
      • OUTFILE
      • OVER
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#p","title":"P","text":"
      • PASSWORD_LOCK_TIME
      • PARTITION
      • PRECEDING
      • PRIMARY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#q","title":"Q","text":"
      • QUICK
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#r","title":"R","text":"
      • RANDOM
      • REGEXP
      • RENAME
      • REPLACE
      • RETURNS
      • REUSE
      • RIGHT
      • REQUIRE
      • REPEAT
      • ROW
      • ROWS
      • ROW_COUNT
      • REFERENCES
      • RECURSIVE
      • REVERSE
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#s","title":"S","text":"
      • SAN
      • SECONDARY
      • SSL
      • SUBJECT
      • SCHEMA
      • SCHEMAS
      • SELECT
      • SECOND
      • SEPARATOR
      • SET
      • SHOW
      • SQL_SMALL_RESULT
      • SQL_BIG_RESULT
      • STRAIGHT_JOIN
      • STARTING
      • SUSPEND
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#t","title":"T","text":"
      • TABLE
      • TABLE_NUMBER
      • TABLE_SIZE
      • TABLE_VALUES
      • TERMINATED
      • THEN
      • TO
      • TRAILING
      • TRUE
      • TRUNCATE
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#u","title":"U","text":"
      • UNBOUNDED
      • UNION
      • UNIQUE
      • UPDATE
      • USE
      • USING
      • UTC_DATE
      • UTC_TIME
      • UTC_TIMESTAMP
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#v","title":"V","text":"
      • VALUES
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#w","title":"W","text":"
      • WHEN
      • WHERE
      • WEEK
      • WITH
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#non-reserved-keyword","title":"Non reserved keyword","text":""},{"location":"MatrixOne/Reference/Language-Structure/keywords/#a_1","title":"A","text":"
      • ACCOUNT
      • ACCOUNTS
      • AGAINST
      • AVG_ROW_LENGTH
      • AUTO_RANDOM
      • ATTRIBUTE
      • ACTION
      • ALGORITHM
      • ANY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#b_1","title":"B","text":"
      • BEGIN
      • BIGINT
      • BIT
      • BLOB
      • BOOL
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#c_1","title":"C","text":"
      • CHAIN
      • CHECKSUM
      • CLUSTER
      • COMPRESSION
      • COMMENT_KEYWORD
      • COMMIT
      • COMMITTED
      • CHARSET
      • COLUMNS
      • CONNECTION
      • CONSISTENT
      • COMPRESSED
      • COMPACT
      • COLUMN_FORMAT
      • CASCADE
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#d_1","title":"D","text":"
      • DATA
      • DATE
      • DATETIME
      • DECIMAL
      • DYNAMIC
      • DISK
      • DO
      • DOUBLE
      • DIRECTORY
      • DUPLICATE
      • DELAY_KEY_WRITE
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#e_1","title":"E","text":"
      • ENUM
      • ENCRYPTION
      • ENFORCED
      • ENGINE
      • ENGINES
      • ERRORS
      • EXPANSION
      • EXPIRE
      • EXTENDED
      • EXTENSION
      • EXTERNAL
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#f_1","title":"F","text":"
      • FORMAT
      • FLOAT_TYPE
      • FULL
      • FIXED
      • FIELDS
      • FORCE_QUOTE
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#g_1","title":"G","text":"
      • GEOMETRY
      • GEOMETRYCOLLECTION
      • GLOBAL
      • GRANT
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#h_1","title":"H","text":"
      • HASH
      • HEADER
      • HISTORY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#i_1","title":"I","text":"
      • INT
      • INTEGER
      • INDEXES
      • ISOLATION
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#j_1","title":"J","text":"
      • JSON
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#k_1","title":"K","text":"
      • KEY_BLOCK_SIZE
      • KEYS
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#l_1","title":"L","text":"
      • LANGUAGE
      • LESS
      • LEVEL
      • LINESTRING
      • LINEAR
      • LIST
      • LONGBLOB
      • LONGTEXT
      • LOCAL
      • LOW_CARDINALITY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#m_1","title":"M","text":"
      • MAX_CONNECTIONS_PER_HOUR
      • MAX_FILE_SIZE
      • MAX_QUERIES_PER_HOUR
      • MAX_ROWS
      • MAX_UPDATES_PER_HOUR
      • MAX_USER_CONNECTIONS
      • MEDIUMBLOB
      • MEDIUMINT
      • MEDIUMTEXT
      • MEMORY
      • MIN_ROWS
      • MODE
      • MONTH
      • MULTILINESTRING
      • MULTIPOINT
      • MULTIPOLYGON
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#n_1","title":"N","text":"
      • NAMES
      • NCHAR
      • NUMERIC
      • NEVER
      • NO
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#o_1","title":"O","text":"
      • OFFSET
      • ONLY
      • OPTIMIZE
      • OPEN
      • OPTION
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#p_1","title":"P","text":"
      • PACK_KEYS
      • PASSWORD
      • PARTIAL
      • PARTITIONS
      • POINT
      • POLYGON
      • PROCEDURE
      • PROFILES
      • PROXY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#q_1","title":"Q","text":"
      • QUARTER
      • QUERY
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#r_1","title":"R","text":"
      • ROLE
      • RANGE
      • READ
      • REAL
      • REORGANIZE
      • REDUNDANT
      • REPAIR
      • REPEATABLE
      • RELEASE
      • REVOKE
      • REPLICATION
      • ROW_FORMAT
      • ROLLBACK
      • RESTRICT
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#s_1","title":"S","text":"
      • SESSION
      • SERIALIZABLE
      • SHARE
      • SIGNED
      • SMALLINT
      • SNAPSHOT
      • SOME
      • SPATIAL
      • START
      • STATUS
      • STORAGE
      • STREAM
      • STATS_AUTO_RECALC
      • STATS_PERSISTENT
      • STATS_SAMPLE_PAGES
      • SUBPARTITIONS
      • SUBPARTITION
      • SIMPLE
      • S3OPTION
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#t_1","title":"T","text":"
      • TABLES
      • TEXT
      • THAN
      • TINYBLOB
      • TIME
      • TIMESTAMP
      • TINYINT
      • TINYTEXT
      • TRANSACTION
      • TRIGGER
      • TRIGGERS
      • TYPE
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#u_1","title":"U","text":"
      • UNCOMMITTED
      • UNKNOWN
      • UNSIGNED
      • UNUSED
      • UNLOCK
      • URL
      • USER
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#v_1","title":"V","text":"
      • VARBINARY
      • VARCHAR
      • VARIABLES
      • VIEW
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#w_1","title":"W","text":"
      • WRITE
      • WARNINGS
      • WORK
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#x","title":"X","text":"
      • X509
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#y","title":"Y","text":"
      • YEAR
      "},{"location":"MatrixOne/Reference/Language-Structure/keywords/#z","title":"Z","text":"
      • ZEROFILL
      "},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/","title":"JDBC supported features list in MatrixOne","text":"

      Using JDBC to develop applications, MatrixOne supports the following classes and objects:

      "},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#1-connection-class-get-the-database-connection-object","title":"1. Connection (Class): Get the database connection object","text":""},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#method-of-the-class","title":"Method of the Class","text":"
      1. Obtain the executed Sql object Statement

        • Statement createStatement();
        • Statement prepareStatement(String sql);
      2. Manage the transaction

        • Enable the transaction: setAutoCommit(boolean autoCommit), call this method to set the parameter to false, which enable the transaction
        • Commit the transaction: void commit()
        • Rollback the transaction: void rollback()
      Methon of the connection interface Supported(Y)/Not support(N) createStatement() Y prepareStatement(String sql) Y prepareCall(String sql) Y nativeSQL(String sql) Y setAutoCommit(boolean autoCommit) Y getAutoCommit() Y commit() Y rollback() Y close() Y isClosed() Y getMetaData() Y setReadOnly(boolean readOnly) Y isReadOnly() Y setCatalog() Y getCatalog() Y setTransactionIsolation(int level) N getTransactionIsolation() N getWarnings() N clearWarnings() N createStatement(int resultSetType, int resultSetConcurrency) Y prepareStatement(String sql, int resultSetType, int resultSetConcurrency) Y prepareCall(String sql, int resultSetType, int resultSetConcurrency) Y getTypeMap() N setTypeMap(java.util.Map<String,Class<?>> map) N setHoldability(int holdability) N getHoldability() N setSavepoint() N setSavepoint(String name) N rollback(Savepoint savepoint) N releaseSavepoint(Savepoint savepoint) N createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) Y prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) Y prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) Y prepareStatement(String sql, int autoGeneratedKeys) Y prepareStatement(String sql, int columnIndexes[]) Y prepareStatement(String sql, String columnNames[]) Y createClob() N createBlob() N createNClob() N createSQLXML() N isValid() Y setClientInfo(String name, String value) N setClientInfo(Properties properties) N getClientInfo(String name) N getClientInfo() N createArrayOf(String typeName, Object[] elements) N createStruct(String typeName, Object[] attributes) N setSchema(String schema) N getSchema() N abort(Executor executor) N setNetworkTimeout(Executor executor, int milliseconds) Y getNetworkTimeout() Y"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#2-method-of-the-statement-class","title":"2. Method of the Statement class","text":"Method of the Statement class Supported(Y)/Not support(N) executeQuery(String sql) Y executeUpdate(String sql) Y close() Y getMaxFieldSize() Y setMaxFieldSize() Y getMaxRows() Y setMaxRows() Y setEscapeProcessing() N getQueryTimeout() Y setQueryTimeout(int seconds) Y cancel() Y getWarnings() N clearWarnings() N setCursorName(String name) N execute(String sql) Y getResultSet() Y getUpdateCount() Y getMoreResults() Y setFetchDirection(int direction) Y getFetchDirection() N setFetchSize(int rows) Y getFetchSize() Y getResultSetConcurrency() Y getResultSetType() Y addBatch( String sql) Y clearBatch() Y executeBatch() Y getConnection() Y getMoreResults(int current) Y getGeneratedKeys() Y executeUpdate(String sql, int autoGeneratedKeys) Y executeUpdate(String sql, int columnIndexes[]) Y executeUpdate(String sql, String columnNames[]) Y execute(String sql, int autoGeneratedKeys) Y execute(String sql, int columnIndexes[]) Y execute(String sql, String columnNames[]) Y getResultSetHoldability() Y isClosed() Y setPoolable(boolean poolable) N isPoolable() N closeOnCompletion() Y isCloseOnCompletion() Y"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#3-method-of-the-resultset-class","title":"3. Method of the ResultSet class","text":"Method of the ResultSet class Supported(Y)/Not support(N) next() Y close() Y wasNull() Y getString(int columnIndex) Y getBoolean(int columnIndex) Y getByte(int columnIndex) Y getShort(int columnIndex) Y getInt(int columnIndex) Y getLong(int columnIndex) Y getFloat(int columnIndex) Y getDouble(int columnIndex) Y getBigDecimal(int columnIndex, int scale) Y getBytes(int columnIndex) Y getDate(int columnIndex) Y getTime(int columnIndex) Y getTimestamp(int columnIndex) Y getAsciiStream(int columnIndex) Y getUnicodeStream(int columnIndex) Y getBinaryStream(int columnIndex) Y getWarnings() N clearWarnings() N getCursorName() N getMetaData() Y getObject() N findColumn() Y getCharacterStream() Y isBeforeFirst() Y isAfterLast() Y isFirst() Y isLast() Y beforeFirst() Y afterLast() Y first() Y last() Y getRow() Y absolute() Y relative() Y previous() Y setFetchDirection() Y getFetchDirection() Y setFetchSize() Y getFetchSize() Y getType() Y getConcurrency() Y rowUpdated() Y rowInserted() Y rowDeleted() Y update()(String of data types) Y updateNull() Y"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#4-method-of-the-resultsetmetadata","title":"4. Method of the ResultSetMetaData","text":"Method of the ResultSetMetaData Supported(Y)/Not support(N) getColumnCount() Y isAutoIncrement() Y isCaseSensitive() Y isSearchable() Y isCurrency() Y isNullable() Y isSigned() Y getColumnDisplaySize() Y getColumnLabel() Y getColumnName() Y getSchemaName() N getPrecision() Y getScale() Y getTableName() Y getCatalogName() Y getColumnType() Y getColumnTypeName() Y isReadOnly() N isWritable() N isDefinitelyWritable() N getColumnClassName() Y"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#displaysize-prec-and-scale-statistics-of-mysql-data-type","title":"DisplaySize, Prec, and Scale statistics of Mysql data type","text":"Data types DisplaySize Prec Scale TINYINT 4 4 0 SMALLINT 6 6 0 INT 11 11 0 BIGINT 20 20 0 TINYINT UNSIGNED 3 3 0 SMALLINT UNSIGNED 5 5 0 INT UNSIGNED 10 10 0 BIGINT UNSIGNED 20 20 0 DECIMAL64(according to the actual) 17 15 2 DECIMAL128(according to the actual) 23 21 3 FLOAT 12 12 31 DOUBLE 22 22 31 VARCHAR(according to the actual) 100 100 0 CHAR(according to the actual) 100 100 0 DATE 10 10 0 DATETIME 19 19 0 TIMESTAMP 19 19 0 JSON 2147483647 2147483647 0"},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/","title":"MatrixOne DDL statement partitioning supported","text":""},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#1-the-partition-type-supported-by-matrixone","title":"1. The partition type supported by MatrixOne","text":"

      MatrixOne DDL statements support six partition types, which are the same as the MySQL official website:

      • KEY Partitioning
      • HASH Partitioning

      Subpartitioning syntax is currently supported, but plan builds are not.

      "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#2-about-partition-keys","title":"2. About Partition Keys","text":""},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#partition-keys-primary-keys-and-unique-keys","title":"Partition Keys, Primary Keys and Unique Keys","text":"

      The relationship rules of Partition Keys, Primary Keys, and Unique Keys can be summarized as follows:

      • All columns used in a partitioning expression for a partitioned table must be part of every unique key that the table may have.

      !!! note The Unique KEY includes PrimaryKey and unique key.

      • That is, each unique key on a table must use each column of the table's partitioning expression. A unique key also includes the primary key of a table because, by definition, a table's primary key is also a unique one.
      "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#examples","title":"Examples","text":"

      For example, because the unique key on the table does not use every column in the table, each statement that creates the table below is invalid:

      > CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1, col2)\n)\nPARTITION BY HASH(col3)\nPARTITIONS 4;\nERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function\n\n> CREATE TABLE t2 (\n     col1 INT NOT NULL,\n     col2 DATE NOT NULL,\n     col3 INT NOT NULL,\n     col4 INT NOT NULL,\n     UNIQUE KEY (col1),\n     UNIQUE KEY (col3)\n )\n  PARTITION BY HASH(col1 + col3)\n  PARTITIONS 4;\n\nERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function\n
      "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#about-the-partition-key-is-null","title":"About the partition KEY is NULL","text":"
      1. KEY only accepts lists with Null or more column names. In cases where the table has a primary key, any column used as a partitioning key must contain some or all of the table's primary keys.

        If no column name is specified as the partitioning key, you can ues the table's primary key. For example, the following CREATE TABLE statement is valid in MySQL.

      2. If there is no primary KEY but a UNIQUE KEY, the UNIQUE KEY is used as the partitioning key.

        For example, in the following table construction sentence, the KEY partition key is NULL, no primary key is defined, but the unique key is used as the partitioning key when the partition expression is constructed:

      CREATE TABLE t1 (\ncol1 INT  NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1, col2)\n)\nPARTITION BY KEY()\nPARTITIONS 4;\n

      Note

      Other partition rules are the same as MySQL.

      "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#3-about-matrixone-partition-expressions","title":"3. About MatrixOne Partition Expressions","text":"

      \u200bWhen a DDL statement constructs a partitioned table, a partition expression is generated for each partition definition. The partition expression can calculate the partition to which the data belongs.

      In the plan build phase, the partition information data structure in the DDL statement is plan.PartitionInfo:

      type PartitionInfo struct {\nType                 PartitionType\nExpr                 *Expr\nPartitionExpression  *Expr\nColumns              []*Expr\nPartitionColumns     []string\nPartitionNum         uint64\nPartitions           []*PartitionItem\nAlgorithm            int64\nIsSubPartition       bool\nPartitionMsg         string\n}\n

      PartitionExpression is the partition expression. Partition expressions are MatrixOne's way of converting a partition clause into an expression. Each partition expression is constructed as follows:

      "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#key-partitioning","title":"KEY Partitioning","text":"

      KEY partitioning will construct a partition expression based on the partition key and the number of partitions. The result of the partition expression is an integer greater than or equal to 0, representing the partition sequence number, which increases sequentially from zero.

      SQL example is as below:

      CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nPRIMARY KEY (col1, col2)\n)\nPARTITION BY KEY(col1)\nPARTITIONS 4;\n
      "},{"location":"MatrixOne/Reference/Limitations/mo-partition-support/#hash-partitioning","title":"HASH Partitioning","text":"

      HASH partitioning will construct a partition expression based on the partition function and the number of partitions. The result of the partition expression is an integer greater than or equal to 0, representing the partition sequence number, which increases sequentially from zero.

      SQL example is as below:

      CREATE TABLE t1 (\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n)\nPARTITION BY LINEAR HASH( YEAR(col3))\nPARTITIONS 6;\n
      "},{"location":"MatrixOne/Reference/Operators/interval/","title":"INTERVAL","text":""},{"location":"MatrixOne/Reference/Operators/interval/#description","title":"Description","text":"
      • The INTERVAL values are used mainly for date and time calculations. The INTERVAL in expressions represents a temporal interval.

      • Temporal intervals are used for certain functions, such as DATE_ADD() and DATE_SUB().

      • Temporal arithmetic also can be performed in expressions using INTERVAL together with the + or - operator:

        date + INTERVAL expr unit\ndate - INTERVAL expr unit\n
        • INTERVAL expr unit is permitted on either side of the + operator if the expression on the other side is a date or datetime value.
        • For the - operator, INTERVAL expr unit is permitted only on the right side, because it makes no sense to subtract a date or datetime value from an interval.
      "},{"location":"MatrixOne/Reference/Operators/interval/#syntax","title":"Syntax","text":"
      > INTERVAL (expr,unit)\n
      "},{"location":"MatrixOne/Reference/Operators/interval/#arguments","title":"Arguments","text":"Arguments Description expr represents a quantity. unit the unit for interpreting the quantity; it is a specifier such as HOUR, DAY, or WEEK.

      Note: The INTERVAL keyword and the unit specifier are not case-sensitive.

      • Temporal Interval Expression and Unit Arguments
      unit Value Expected expr Format MICROSECOND MICROSECONDS SECOND SECONDS MINUTE MINUTES HOUR HOURS DAY DAYS WEEK WEEKS MONTH MONTHS QUARTER QUARTERS YEAR YEARS SECOND_MICROSECOND 'SECONDS.MICROSECONDS' MINUTE_MICROSECOND 'MINUTES:SECONDS.MICROSECONDS' MINUTE_SECOND 'MINUTES:SECONDS' HOUR_MICROSECOND 'HOURS:MINUTES:SECONDS.MICROSECONDS' HOUR_SECOND 'HOURS:MINUTES:SECONDS' HOUR_MINUTE 'HOURS:MINUTES' DAY_MICROSECOND 'DAYS HOURS:MINUTES:SECONDS.MICROSECONDS' DAY_SECOND 'DAYS HOURS:MINUTES:SECONDS' DAY_MINUTE 'DAYS HOURS:MINUTES' DAY_HOUR 'DAYS HOURS' YEAR_MONTH 'YEARS-MONTHS'

      We permits any punctuation delimiter in the expr format. Those shown in the table are the suggested delimiters.

      "},{"location":"MatrixOne/Reference/Operators/interval/#examples","title":"Examples","text":""},{"location":"MatrixOne/Reference/Operators/interval/#example-1","title":"Example 1","text":"
      • Temporal intervals are used for DATE_ADD() and DATE_SUB():
      mysql> SELECT DATE_SUB('2018-05-01',INTERVAL 1 YEAR);\n+-----------------------------------------+\n| date_sub(2018-05-01, interval(1, year)) |\n+-----------------------------------------+\n| 2017-05-01                              |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2020-12-31 23:59:59', INTERVAL 1 SECOND);\n+----------------------------------------------------+\n| date_add(2020-12-31 23:59:59, interval(1, second)) |\n+----------------------------------------------------+\n| 2021-01-01 00:00:00                                |\n+----------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_ADD('2018-12-31 23:59:59', INTERVAL 1 DAY);\n+-------------------------------------------------+\n| date_add(2018-12-31 23:59:59, interval(1, day)) |\n+-------------------------------------------------+\n| 2019-01-01 23:59:59                             |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2100-12-31 23:59:59', INTERVAL '1:1' MINUTE_SECOND);\n+-------------------------------------------------------------+\n| date_add(2100-12-31 23:59:59, interval(1:1, minute_second)) |\n+-------------------------------------------------------------+\n| 2101-01-01 00:01:00                                         |\n+-------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_SUB('2025-01-01 00:00:00', INTERVAL '1 1:1:1' DAY_SECOND);\n+--------------------------------------------------------------+\n| date_sub(2025-01-01 00:00:00, interval(1 1:1:1, day_second)) |\n+--------------------------------------------------------------+\n| 2024-12-30 22:58:59                                          |\n+--------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('1900-01-01 00:00:00', INTERVAL '-1 10' DAY_HOUR);\n+----------------------------------------------------------+\n| date_add(1900-01-01 00:00:00, interval(-1 10, day_hour)) |\n+----------------------------------------------------------+\n| 1899-12-30 14:00:00.000000                               |\n+----------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_SUB('1998-01-02', INTERVAL 31 DAY);\n+-----------------------------------------+\n| date_sub(1998-01-02, interval(31, day)) |\n+-----------------------------------------+\n| 1997-12-02                              |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('1992-12-31 23:59:59.000002', INTERVAL '1.999999' SECOND_MICROSECOND);\n+------------------------------------------------------------------------------+\n| date_add(1992-12-31 23:59:59.000002, interval(1.999999, second_microsecond)) |\n+------------------------------------------------------------------------------+\n| 1993-01-01 00:00:01.000001                                                   |\n+------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/interval/#example-2","title":"Example 2","text":"
      • Using INTERVAL together with the + or - operator
      mysql> SELECT '2018-12-31 23:59:59' + INTERVAL 1 SECOND;\n+-------------------------------------------+\n| 2018-12-31 23:59:59 + interval(1, second) |\n+-------------------------------------------+\n| 2019-01-01 00:00:00                       |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT INTERVAL 1 DAY + '2018-12-31';\n+-------------------------------+\n| interval(1, day) + 2018-12-31 |\n+-------------------------------+\n| 2019-01-01                    |\n+-------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT '2025-01-01' - INTERVAL 1 SECOND;\n+----------------------------------+\n| 2025-01-01 - interval(1, second) |\n+----------------------------------+\n| 2024-12-31 23:59:59              |\n+----------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/interval/#example-3","title":"Example 3","text":"

      If you add to or subtract from a date value something that contains a time part, the result is automatically converted to a datetime value:

      mysql> SELECT DATE_ADD('2023-01-01', INTERVAL 1 DAY);\n+----------------------------------------+\n| date_add(2023-01-01, interval(1, day)) |\n+----------------------------------------+\n| 2023-01-02                             |\n+----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2023-01-01', INTERVAL 1 HOUR);\n+-----------------------------------------+\n| date_add(2023-01-01, interval(1, hour)) |\n+-----------------------------------------+\n| 2023-01-01 01:00:00                     |\n+-----------------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/interval/#example-4","title":"Example 4","text":"

      If you add MONTH, YEAR_MONTH, or YEAR and the resulting date has a day that is larger than the maximum day for the new month, the day is adjusted to the maximum days in the new month:

      mysql> SELECT DATE_ADD('2019-01-30', INTERVAL 1 MONTH);\n+------------------------------------------+\n| date_add(2019-01-30, interval(1, month)) |\n+------------------------------------------+\n| 2019-02-28                               |\n+------------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/interval/#example-5","title":"Example 5","text":"

      Date arithmetic operations require complete dates and do not work with incomplete dates such as '2016-07-00' or badly malformed dates:

      mysql> SELECT DATE_ADD('2016-07-00', INTERVAL 1 DAY);\n+----------------------------------------+\n| date_add(2016-07-00, interval(1, day)) |\n+----------------------------------------+\n| NULL                                   |\n+----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT '2005-03-32' + INTERVAL 1 MONTH;\n+---------------------------------+\n| 2005-03-32 + interval(1, month) |\n+---------------------------------+\n| NULL                            |\n+---------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/operator-precedence/","title":"Operator Precedence","text":"

      Operator precedences are shown in the following list, from highest precedence to the lowest. Operators that are shown together on a line have the same precedence.

      From highest precedence to the lowest Operators 1 INTERVAL 2 BINARY, COLLATE 3 ! 4 - (unary minus), ~ (unary bit inversion) 5 ^ 6 *, /, DIV, %, MOD 7 -, + 8 <<, >> 9 & 10 | 11 = (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, , IN, MEMBER OF 12 BETWEEN, CASE, WHEN, THEN, ELSE 13 NOT 14 AND, && 15 XOR 16 OR, || 17 = (assignment)

      The precedence of = depends on whether it is used as a comparison operator (=) or as an assignment operator (=). When used as a comparison operator, it has the same precedence as , >=, >, <=, <, <>, !=, IS, LIKE, and IN().

      For operators that occur at the same precedence level within an expression, evaluation proceeds left to right, with the exception that assignments evaluate right to left.

      "},{"location":"MatrixOne/Reference/Operators/operators/operators/","title":"Operators Overview","text":""},{"location":"MatrixOne/Reference/Operators/operators/operators/#arithmetic-operators","title":"Arithmetic Operators","text":"Name Description %,MOD Modulo operator * Multiplication operator + Addition operator - Minus operator - Change the sign of the argument / Division operator DIV Integer division"},{"location":"MatrixOne/Reference/Operators/operators/operators/#assignment-operators","title":"Assignment Operators","text":"Name Description = Equal operator"},{"location":"MatrixOne/Reference/Operators/operators/operators/#bit-functions-and-operators","title":"Bit Functions and Operators","text":"Name Description & Bitwise AND >> Right shift << Left shift ^ Bitwise XOR | Bitwise OR ~ Bitwise inversion"},{"location":"MatrixOne/Reference/Operators/operators/operators/#cast-functions-and-operators","title":"Cast Functions and Operators","text":"Name Description BINARY() Convert a value to a binary string CAST() Cast a value as a certain type CONVERT() Cast a value as a certain type"},{"location":"MatrixOne/Reference/Operators/operators/operators/#comparison-functions-and-operators","title":"Comparison Functions and Operators","text":"Name Description > Greater than operator >= Greater than or equal operator < Less than operator <>,!= Not equal operator <= Less than or equal operator = Equal operator BETWEEN ... AND ... Whether a value is within a range of values IN() Whether a value is within a set of values IS Test a value against a boolean IS NOT Test a value against a boolean IS NOT NULL NOT NULL value test IS NULL NULL value test ISNULL instead of = to test whether a value is NULL LIKE Simple pattern matching ILIKE Simple pattern matching. Same as LIKE. But it is not case sensitive. NOT BETWEEN ... AND ... Whether a value is not within a range of values NOT IN shorthand for multiple XOR conditions NOT LIKE Negation of simple pattern matching COALESCE Return the first non-null value in a list"},{"location":"MatrixOne/Reference/Operators/operators/operators/#flow-control-functions","title":"Flow Control Functions","text":"Name Description CASE Case operator IF() If/else construct IFNULL() Null if/else construct NULLIF() Return NULL if expr1 = expr2"},{"location":"MatrixOne/Reference/Operators/operators/operators/#logical-operators","title":"Logical Operators","text":"Name Description AND,&& Logical AND NOT,! Negates value OR Logical OR XOR Logical XOR"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/","title":"+","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#description","title":"Description","text":"

      The + operator is used for addition.

      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#syntax","title":"Syntax","text":"
      > SELECT value1+value2;\n
      > SELECT column1+column2... FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#examples","title":"Examples","text":"
      mysql> select 1123.2333+1233.3331;\n+-----------------------+\n| 1123.2333 + 1233.3331 |\n+-----------------------+\n|             2356.5664 |\n+-----------------------+\n1 row in set (0.01 sec)\n
      create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1+5 from t2;\n+--------+\n| c1 + 5 |\n+--------+\n|      2 |\n|      6 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1+c2 from t2;\n+---------+\n| c1 + c2 |\n+---------+\n|      -1 |\n|       3 |\n+---------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/","title":"Arithmetic Operators Overview","text":"Name Description %,MOD Modulo operator * Multiplication operator + Addition operator - Minus operator - Change the sign of the argument / Division operator DIV Integer division

      The usual arithmetic operators are available. The result is determined according to the following rules:

      • In the case of -, +, and *, the result is calculated with BIGINT (64-bit) precision if both operands are integers.

      • If both operands are integers and any of them are unsigned, the result is an unsigned integer.

      • If any of the operands of a +,-, /, *, % is a real or string value, the precision of the result is the precision of the operand with the maximum precision.

      In division performed with /, the scale of the result when using two exact-value operands is the scale of the first operand plus the value of the div_precision_increment system variable. For example, the result of the expression 5.05 / 0.014 has a scale of 13 decimal places (360.7142857142857).

      These rules are applied for each operation, such that nested calculations imply the precision of each component. Hence, (14620 / 9432456) / (24250 / 9432456), resolves first to (0.0014) / (0.0026), with the final result having 16 decimal places (0.6028865979381443).

      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/#constraints","title":"Constraints","text":"
      • Arithmetic operators only apply to numbers.
      • To ensure that components and subcomponents of a calculation use the appropriate level of precision. See Cast Functions and Operators.
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/","title":"DIV","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/#description","title":"Description","text":"

      The DIV operator is used for integer division. Discards from the division result any fractional part to the right of the decimal point.

      If either operand has a non-integer type, the operands are converted to DECIMAL and divided using DECIMAL arithmetic before converting the result to BIGINT. If the result exceeds BIGINT range, an error occurs.

      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/#syntax","title":"Syntax","text":"
      > SELECT value1 DIV value2;\n
      > SELECT column1 DIV column2... FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/#examples","title":"Examples","text":"
      mysql> SELECT 5 DIV 2, -5 DIV 2, 5 DIV -2, -5 DIV -2;\n+---------+----------+----------+-----------+\n| 5 div 2 | -5 div 2 | 5 div -2 | -5 div -2 |\n+---------+----------+----------+-----------+\n|       2 |       -2 |       -2 |         2 |\n+---------+----------+----------+-----------+\n1 row in set (0.00 sec)\n
      create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1 DIV 3 from t2;\n+----------+\n| c1 div 3 |\n+----------+\n|       -1 |\n|        0 |\n+----------+\n2 rows in set (0.00 sec)\n\nmysql> select c1 DIV c2 from t2;\n+-----------+\n| c1 div c2 |\n+-----------+\n|        -1 |\n|         0 |\n+-----------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/","title":"/","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#description","title":"Description","text":"

      The / operator is used for division.

      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#syntax","title":"Syntax","text":"
      > SELECT value1/value2;\n
      > SELECT column1/column2... FROM table_name;\n

      Division by zero produces a error result.

      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#examples","title":"Examples","text":"
      mysql> select 1123.2333/1233.3331;\n+-----------------------+\n| 1123.2333 / 1233.3331 |\n+-----------------------+\n|    0.9107298750029493 |\n+-----------------------+\n1 row in set (0.00 sec)\n
      create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1/2 from t2;\n+--------+\n| c1 / 2 |\n+--------+\n|   -1.5 |\n|    0.5 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1/c2 from t2;\n+---------+\n| c1 / c2 |\n+---------+\n|    -1.5 |\n|     0.5 |\n+---------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/","title":"-","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#description","title":"Description","text":"

      The - operator is used for subtraction.

      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#syntax","title":"Syntax","text":"
      > SELECT value1-value2;\n
      > SELECT column1-column2... FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#examples","title":"Examples","text":"
      mysql> select 1123.2333-1233.3331;\n+-----------------------+\n| 1123.2333 - 1233.3331 |\n+-----------------------+\n|   -110.09979999999996 |\n+-----------------------+\n1 row in set (0.00 sec)\n
      create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1-5 from t2;\n+--------+\n| c1 - 5 |\n+--------+\n|     -8 |\n|     -4 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1-c2 from t2;\n+---------+\n| c1 - c2 |\n+---------+\n|      -5 |\n|      -1 |\n+---------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/","title":"%,MOD","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#description","title":"Description","text":"

      The %,MOD operator is used for modulo operation. Returns the remainder of N divided by M. For more information.

      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#syntax","title":"Syntax","text":"
      > SELECT N % M, N MOD M;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#examples","title":"Examples","text":"
      mysql> select 12 mod 5;\n+--------+\n| 12 % 5 |\n+--------+\n|      2 |\n+--------+\n1 row in set (0.00 sec)\n
      create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1 mod 2 from t2;\n+--------+\n| c1 % 2 |\n+--------+\n|     -1 |\n|      1 |\n+--------+\n2 rows in set (0.01 sec)\n\nmysql> select c1 mod c2 from t2;\n+---------+\n| c1 % c2 |\n+---------+\n|      -1 |\n|       1 |\n+---------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/","title":"*","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#description","title":"Description","text":"

      The * operator is used for multiplication.

      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#syntax","title":"Syntax","text":"
      > SELECT value1*value2;\n
      > SELECT column1*column2... FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#examples","title":"Examples","text":"
      mysql> select 1123.2333*1233.3331;\n+-----------------------+\n| 1123.2333 * 1233.3331 |\n+-----------------------+\n|    1385320.8079122303 |\n+-----------------------+\n1 row in set (0.01 sec)\n
      create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1*2 from t2;\n+--------+\n| c1 * 2 |\n+--------+\n|     -6 |\n|      2 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1*c2 from t2;\n+---------+\n| c1 * c2 |\n+---------+\n|      -6 |\n|       2 |\n+---------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/","title":"-","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#description","title":"Description","text":"

      Unary minus. This operator changes the sign of the operand.

      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#syntax","title":"Syntax","text":"
      > SELECT -column1, -column2, ...\nFROM table_name;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#examples","title":"Examples","text":"
      mysql> select -2;\n+------+\n| -2   |\n+------+\n|   -2 |\n+------+\n
      create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select -c1 from t2;\n+------+\n| -c1  |\n+------+\n|    3 |\n|   -1 |\n+------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/","title":"Assignment Operators Overview","text":""},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/#assignment-operators-overview","title":"Assignment Operators Overview","text":"Name Description = Equal operator"},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/","title":"=","text":""},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#description","title":"Description","text":"

      This = operator is used to perform value assignments in the below cases:

      • Within a SET statement, = is treated as an assignment operator that causes the user variable on the left hand side of the operator to take on the value to its right. The value on the right hand side may be a literal value, another variable storing a value, or any legal expression that yields a scalar value, including the result of a query (provided that this value is a scalar value). You can perform multiple assignments in the same SET statement.

      • In the SET clause of an UPDATE statement, = also acts as an assignment operator. You can make multiple assignments in the same SET clause of an UPDATE statement.

      • In any other context, = is treated as a comparison operator.

      "},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#syntax","title":"Syntax","text":"
      > SELECT column1, column2, ...\nFROM table_name\nWHERE columnN = value1;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#examples","title":"Examples","text":"
      create table t1 (a bigint(3), b bigint(5) primary key);\ninsert into t1 VALUES (1,1),(1,2);\nupdate t1 set a=2 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 |    1 |\n|    1 |    2 |\n+------+------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bit-functions-and-operators-overview/","title":"Bit Functions and Operators","text":"Name Description & Bitwise AND >> Right shift << Left shift ^ Bitwise XOR [ ](bitwise-or.md) ~ Bitwise inversion

      Bit functions and operators required BIGINT (64-bit integer) arguments and returned BIGINT values, so they had a maximum range of 64 bits. Non-BIGINT arguments were converted to BIGINT prior to performing the operation and truncation could occur.

      Bit functions and operators permit binary string type arguments (BINARY, VARBINARY, and the BLOB types) and return a value of like type, which enables them to take arguments and produce return values larger than 64 bits. Nonbinary string arguments are converted to BIGINT and processed as such, as before.

      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/","title":"&","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#description","title":"Description","text":"

      Bitwise AND operator returns an unsigned 64-bit integer.

      The result type depends on whether the arguments are evaluated as binary strings or numbers:

      • Binary-string evaluation occurs when the arguments have a binary string type, and at least one of them is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to unsigned 64-bit integers as necessary.

      • Binary-string evaluation produces a binary string of the same length as the arguments. If the arguments have unequal lengths, an ER_INVALID_BITWISE_OPERANDS_SIZE error occurs. Numeric evaluation produces an unsigned 64-bit integer.

      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#syntax","title":"Syntax","text":"
      > SELECT value1 & value2;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#examples","title":"Examples","text":"
      mysql> SELECT 29 & 15;\n+---------+\n| 29 & 15 |\n+---------+\n|      13 |\n+---------+\n1 row in set (0.06 sec)\n\nCREATE TABLE bitwise (a_int_value INT NOT NULL,b_int_value INT NOT NULL);\nINSERT bitwise VALUES (170, 75);  mysql> SELECT a_int_value & b_int_value FROM bitwise;  +---------------------------+\n| a_int_value & b_int_value |\n+---------------------------+\n|                        10 |\n+---------------------------+\n1 row in set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/","title":"~","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#description","title":"Description","text":"

      Invert all bits.

      The result type depends on whether the bit argument is evaluated as a binary string or number:

      • Binary-string evaluation occurs when the bit argument has a binary string type, and is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to an unsigned 64-bit integer as necessary.

      • Binary-string evaluation produces a binary string of the same length as the bit argument. Numeric evaluation produces an unsigned 64-bit integer.

      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#syntax","title":"Syntax","text":"
      > SELECT value1 ~ value2;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#examples","title":"Examples","text":"
      mysql> select ~-5;\n+--------+\n| ~ (-5) |\n+--------+\n|      4 |\n+--------+\n1 row in set (0.00 sec)\n\nmysql> select ~null;\n+-------+\n| ~null |\n+-------+\n|  NULL |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> select ~a, ~b from t1;\n+------+----------------------+\n| ~a   | ~b                   |\n+------+----------------------+\n|    0 | 18446744073709551614 |\n|    4 | 18446744073709551610 |\n+------+----------------------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/","title":"|","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#description","title":"Description","text":"

      Bitwise OR.

      The result type depends on whether the arguments are evaluated as binary strings or numbers:

      • Binary-string evaluation occurs when the arguments have a binary string type, and at least one of them is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to unsigned 64-bit integers as necessary.

      • Binary-string evaluation produces a binary string of the same length as the arguments. If the arguments have unequal lengths, an ER_INVALID_BITWISE_OPERANDS_SIZE error occurs. Numeric evaluation produces an unsigned 64-bit integer.

      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#syntax","title":"Syntax","text":"
      > SELECT value1 | value2;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#examples","title":"Examples","text":"
      mysql> SELECT 29 | 15;\n+---------+\n| 29 | 15 |\n+---------+\n|      31 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null | 2;\n+----------+\n| null | 2 |\n+----------+\n|     NULL |\n+----------+\n1 row in set (0.01 sec)\n\nmysql> select null | 2;\n+----------+\n| null | 2 |\n+----------+\n|     NULL |\n+----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a | 2, b | 2 from t1;\n+-------+-------+\n| a | 2 | b | 2 |\n+-------+-------+\n|    -1 |     3 |\n|    -5 |     7 |\n+-------+-------+\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/","title":"^","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#description","title":"Description","text":"

      Bitwise XOR.

      The result type depends on whether the arguments are evaluated as binary strings or numbers:

      • Binary-string evaluation occurs when the arguments have a binary string type, and at least one of them is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to unsigned 64-bit integers as necessary.

      • Binary-string evaluation produces a binary string of the same length as the arguments. If the arguments have unequal lengths, an ER_INVALID_BITWISE_OPERANDS_SIZE error occurs. Numeric evaluation produces an unsigned 64-bit integer.

      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#syntax","title":"Syntax","text":"
      > SELECT value1 ^ value2;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#examples","title":"Examples","text":"
      mysql> SELECT 1 ^ 1;\n+-------+\n| 1 ^ 1 |\n+-------+\n|     0 |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> SELECT 1 ^ 0;\n+-------+\n| 1 ^ 0 |\n+-------+\n|     1 |\n+-------+\n1 row in set (0.01 sec)\n\nmysql> SELECT 11 ^ 3;\n+--------+\n| 11 ^ 3 |\n+--------+\n|      8 |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select null ^ 2;\n+----------+\n| null ^ 2 |\n+----------+\n|     NULL |\n+----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a ^ 2, b ^ 2 from t1;\n+-------+-------+\n| a ^ 2 | b ^ 2 |\n+-------+-------+\n|    -3 |     3 |\n|    -7 |     7 |\n+-------+-------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/","title":"<<","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#description","title":"Description","text":"

      Shifts a longlong (BIGINT) number or binary string to the left.

      The result type depends on whether the bit argument is evaluated as a binary string or number:

      • Binary-string evaluation occurs when the bit argument has a binary string type, and is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to an unsigned 64-bit integer as necessary.

      • Binary-string evaluation produces a binary string of the same length as the bit argument. Numeric evaluation produces an unsigned 64-bit integer.

      Bits shifted off the end of the value are lost without warning, regardless of the argument type. In particular, if the shift count is greater or equal to the number of bits in the bit argument, all bits in the result are 0.

      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#syntax","title":"Syntax","text":"
      > SELECT value1 << value2;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#examples","title":"Examples","text":"
      mysql> SELECT 1 << 2;\n+--------+\n| 1 << 2 |\n+--------+\n|      4 |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select -1 << 2;\n+---------+\n| -1 << 2 |\n+---------+\n|      -4 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null << 2;\n+-----------+\n| null << 2 |\n+-----------+\n|      NULL |\n+-----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a << 2, b << 2 from t1;\n+--------+--------+\n| a << 2 | b << 2 |\n+--------+--------+\n|     -4 |      4 |\n|    -20 |     20 |\n+--------+--------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/","title":">>","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#description","title":"Description","text":"

      Shifts a longlong (BIGINT) number or binary string to the right.

      The result type depends on whether the bit argument is evaluated as a binary string or number:

      • Binary-string evaluation occurs when the bit argument has a binary string type, and is not a hexadecimal literal, bit literal, or NULL literal. Numeric evaluation occurs otherwise, with argument conversion to an unsigned 64-bit integer as necessary.

      • Binary-string evaluation produces a binary string of the same length as the bit argument. Numeric evaluation produces an unsigned 64-bit integer.

      Bits shifted off the end of the value are lost without warning, regardless of the argument type. In particular, if the shift count is greater or equal to the number of bits in the bit argument, all bits in the result are 0.

      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#syntax","title":"Syntax","text":"
      > SELECT value1 >> value2;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#examples","title":"Examples","text":"
      mysql> select 1024 >> 2;\n+-----------+\n| 1024 >> 2 |\n+-----------+\n|       256 |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select -5 >> 2;\n+---------+\n| -5 >> 2 |\n+---------+\n|      -2 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null >> 2;\n+-----------+\n| null >> 2 |\n+-----------+\n|      NULL |\n+-----------+\n1 row in set (0.00 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a >> 2, b >> 2 from t1;\n+--------+--------+\n| a >> 2 | b >> 2 |\n+--------+--------+\n|     -1 |      0 |\n|     -2 |      1 |\n+--------+--------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/","title":"BINARY","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#description","title":"Description","text":"

      The BINARY() function is a function used to convert a value into a binary string. It is typically used when comparing text or character data, treating strings as binary rather than ordinary character data. This enables binary comparisons of character data regardless of character set or encoding.

      The BINARY() function implements binary comparison of character data, which handles cases such as case-sensitive string comparison.

      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#syntax","title":"Syntax","text":"
      > BINARY value\n
      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#parameter-values","title":"Parameter Values","text":"Parameter Description value Required. The value to convert"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#examples","title":"Examples","text":"
      CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, password VARCHAR(100) NOT NULL);\n\nINSERT INTO users (username, password) VALUES ('JohnDoe', 'Abcd123'), ('AliceSmith', 'Efgh456'), ('BobJohnson', 'ijkl789');\n\n-- Use the BINARY() operator for password verification, and the BINARY password = 'Abcd123' part treats the password value as a binary string, so the comparison is case-sensitive. If the entered password matches a record in the database, the query will return the corresponding user id and username. Otherwise, an empty result will be returned.\nmysql> SELECT id, username FROM users WHERE username = 'JohnDoe' AND BINARY password = 'Abcd123';\n+------+----------+\n| id   | username |\n+------+----------+\n|    1 | JohnDoe  |\n+------+----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT id, username FROM users WHERE username = 'JohnDoe' AND BINARY password = 'abcd123';\nEmpty set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast-functions-and-operators-overview/","title":"Cast Functions and Operators","text":"Name Description BINARY() convert a value to a binary string CAST() Cast a value as a certain type CONVERT() Cast a value as a certain type"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/","title":"CAST","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#description","title":"Description","text":"

      The CAST() function converts a value (of any type) into the specified datatype.

      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#syntax","title":"Syntax","text":"
      > CAST(value AS datatype)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#parameter-values","title":"Parameter Values","text":"Parameter Description value Required. The value to convert datatype Required. The datatype to convert to

      Currently, cast can support following conversion:

      • Conversion between numeric types, mainly including SIGNED, UNSIGNED, FLOAT, and DOUBLE type.
      • Numeric types to character CHAR type.
      • Numeric character types to numerical types(negative into SIGNED).
      • Time type (including Date, Datetime, Timestamp, and Time) is converted to INT type, with decimal point rounding
      • Time types (including Date, Datetime, Timestamp, and Time) are converted to fixed-point types with decimal places

      A detailed data type conversion rule can be refered to Data Conversion Rule.

      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#examples","title":"Examples","text":"
      drop table if exists t1;\nCREATE TABLE t1 (a int,b float,c char(1),d varchar(15));\nINSERT INTO t1 VALUES (1,1.5,'1','-2');\n\nmysql> SELECT CAST(a AS FLOAT) a_cast,CAST(b AS UNSIGNED) b_cast,CAST(c AS SIGNED) c_cast, CAST(d AS SIGNED) d_cast from t1;\n+--------+--------+--------+--------+\n| a_cast | b_cast | c_cast | d_cast |\n+--------+--------+--------+--------+\n| 1.0000 |      1 |      1 |     -2 |\n+--------+--------+--------+--------+\n\nmysql> SELECT CAST(a AS CHAR) a_cast, CAST(b AS CHAR) b_cast,CAST(c AS DOUBLE) c_cast, CAST(d AS FLOAT) d_cast from t1;\n+--------+--------+--------+---------+\n| a_cast | b_cast | c_cast | d_cast  |\n+--------+--------+--------+---------+\n| 1      | 1.5    | 1.0000 | -2.0000 |\n+--------+--------+--------+---------+\n
      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#constraints","title":"Constraints","text":"
      • Non-numeric character types cannot be converted to numeric types.
      • Numeric and character types with formats of Data cannot be converted to Date.
      • Date and Datetime types cannot be converted to character types.
      • Date and Datetime cannot be converted to each other.
      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/","title":"CONVERT","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#description","title":"Description","text":"

      The CONVERT() function converts a value into the specified datatype or character set.

      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#syntax","title":"Syntax","text":"
      > CONVERT(value, type)\n

      Or:

      > CONVERT(value USING charset)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#parameter-values","title":"Parameter Values","text":"Parameter Description value Required. The value to convert. datatype Required. The datatype to convert to. charset Required. The character set to convert to.

      Currently, convert can support following conversion:

      • Conversion between numeric types, mainly including SIGNED, UNSIGNED, FLOAT, and DOUBLE type.
      • Numeric types to character CHAR type.
      • Numeric character types to numerical types(negative into SIGNED).
      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#examples","title":"Examples","text":"
      mysql> select convert(150,char);\n+-------------------+\n| cast(150 as char) |\n+-------------------+\n| 150               |\n+-------------------+\n1 row in set (0.01 sec)\n
      CREATE TABLE t1(a tinyint);\nINSERT INTO t1 VALUES (127);\n\nmysql> SELECT 1 FROM\n-> (SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1) AS s LIMIT 1;\n+------+\n| 1    |\n+------+\n|    1 |\n+------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#constraints","title":"Constraints","text":"
      • Non-numeric character types cannot be converted to numeric types.
      • Numeric and character types with formats of Data cannot be converted to Date.
      • Date and Datetime types cannot be converted to character types.
      • Date and Datetime cannot be converted to each other.
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/","title":"=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#description","title":"Description","text":"

      The = operator returns true only if the left-hand operand is equal to the right-hand operand.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#syntax","title":"Syntax","text":"
      > SELECT x = y;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#examples","title":"Examples","text":"
      mysql> SELECT 2 = 2;\n+-------+\n| 2 = 2 |\n+-------+\n| true  |\n+-------+\n1 row in set (0.01 sec)\n
      create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where userID=spID and userID=score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n|      1 |    1 |     1 |\n|      2 |    2 |     2 |\n|      3 |    3 |     3 |\n+--------+------+-------+\n3 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/","title":"BETWEEN ... AND ...","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#description","title":"Description","text":"

      If expr is greater than or equal to min and expr is less than or equal to max, BETWEEN returns true, otherwise it returns false.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#syntax","title":"Syntax","text":"
      > expr BETWEEN min AND max\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#examples","title":"Examples","text":"
      mysql> SELECT 2 BETWEEN 1 AND 3, 2 BETWEEN 3 and 1;\n+-------------------+-------------------+\n| 2 between 1 and 3 | 2 between 3 and 1 |\n+-------------------+-------------------+\n| true              | false             |\n+-------------------+-------------------+\n1 row in set (0.01 sec)\n
      create table t (id bigint unsigned, b int);\ninsert into t values(8894754949779693574,1);\ninsert into t values(8894754949779693579,2);\ninsert into t values(17790886498483827171,3);\n\nmysql> select count(*) from t where id>=8894754949779693574 and id =17790886498483827171 order by 1 asc;\n+----------+\n| count(*) |\n+----------+\n|        0 |\n+----------+\n\nmysql> select count(*) from t where id between 8894754949779693574 and 17790886498483827171;\n+----------+\n| count(*) |\n+----------+\n|        0 |\n+----------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/","title":"COALESCE()","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#description","title":"Description","text":"

      The COALESCE() function returns the first non-null value in a list.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#syntax","title":"Syntax","text":"
      > COALESCE(val1, val2, ...., val_n)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#arguments","title":"Arguments","text":"Arguments Description val1, val2, val_n Required. The values to test"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#examples","title":"Examples","text":"
      • Example: Calculate
      mysql> SELECT COALESCE(1)+COALESCE(1);\n+---------------------------+\n| coalesce(1) + coalesce(1) |\n+---------------------------+\n|                         2 |\n+---------------------------+\n
      • Example: Comparison
      drop table if exists t2;\ncreate table t2(a float, b datetime);\ninsert into t2 values (12.345, '2022-02-20 10:10:10.999999');\ninsert into t2 values (3.45646, NULL);\ninsert into t2 values(NULL, '2023-04-03 22:10:29.999999');\ninsert into t2 values (NULL, NULL);\n\nmysql> select * from t2;\n+---------+---------------------+\n| a       | b                   |\n+---------+---------------------+\n|  12.345 | 2022-02-20 10:10:11 |\n| 3.45646 | NULL                |\n|    NULL | 2023-04-03 22:10:30 |\n|    NULL | NULL                |\n+---------+---------------------+\nmysql> select coalesce(a, 1.0) from t2;\n+--------------------+\n| coalesce(a, 1.0)   |\n+--------------------+\n| 12.345000267028809 |\n| 3.4564599990844727 |\n|                  1 |\n|                  1 |\n+--------------------+\nmysql> select coalesce(a, 1) from t2;\n+--------------------+\n| coalesce(a, 1)     |\n+--------------------+\n| 12.345000267028809 |\n| 3.4564599990844727 |\n|                  1 |\n|                  1 |\n+--------------------+\nmysql> select coalesce(b, 2022-01-01) from t2;\n+---------------------------+\n| coalesce(b, 2022 - 1 - 1) |\n+---------------------------+\n| 2022-02-20 10:10:11       |\n|                           |\n| 2023-04-03 22:10:30       |\n|                           |\n+---------------------------+\n
      • Example: ORDER BY Clause
      CREATE TABLE t1 ( a INTEGER, b varchar(255) );\nINSERT INTO t1 VALUES (1,'z');\nINSERT INTO t1 VALUES (2,'y');\nINSERT INTO t1 VALUES (3,'x');\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(MIN(b), 'a');\n+-------+\n| min_b |\n+-------+\n| x     |\n| y     |\n| z     |\n+-------+\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(min_b, 'a');\n+-------+\n| min_b |\n+-------+\n| x     |\n| y     |\n| z     |\n+-------+\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(MIN(b), 'a') DESC;\n+-------+\n| min_b |\n+-------+\n| z     |\n| y     |\n| x     |\n+-------+\n
      • Example: Case When Clause
      mysql> select if(1, cast(1111111111111111111 as unsigned), 1) i,case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, coalesce(cast(1111111111111111111 as unsigned), 1) co;\n+---------------------+---------------------+---------------------+\n| i                   | c                   | co                  |\n+---------------------+---------------------+---------------------+\n| 1111111111111111111 | 1111111111111111111 | 1111111111111111111 |\n+---------------------+---------------------+---------------------+\n
      • Example: IN Subquery
      CREATE TABLE ot (col_int_nokey int(11), col_varchar_nokey varchar(1));\nINSERT INTO ot VALUES (1,'x');\nCREATE TABLE it (col_int_key int(11), col_varchar_key varchar(1));\nINSERT INTO it VALUES (NULL,'x'), (NULL,'f');\n\nmysql> SELECT col_int_nokey FROM ot WHERE col_varchar_nokey IN(SELECT col_varchar_key FROM it WHERE coalesce(col_int_nokey, 1) );\n+---------------+\n| col_int_nokey |\n+---------------+\n|             1 |\n+---------------+\n
      • Example: WHERE
      CREATE TABLE ot1(a INT);\nCREATE TABLE ot2(a INT);\nCREATE TABLE ot3(a INT);\nCREATE TABLE it1(a INT);\nCREATE TABLE it2(a INT);\nCREATE TABLE it3(a INT);\nINSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);\nINSERT INTO ot2 VALUES(0),(2),(4),(6);\nINSERT INTO ot3 VALUES(0),(3),(6);\nINSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);\nINSERT INTO it2 VALUES(0),(2),(4),(6);\nINSERT INTO it3 VALUES(0),(3),(6);\n\nmysql> SELECT * FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3);\n+------+------+\n| a    | a    |\n+------+------+\n|    0 |    0 |\n|    1 | NULL |\n|    3 | NULL |\n|    5 | NULL |\n|    6 |    6 |\n|    7 | NULL |\n+------+------+\n
      • Example: HAVING
      drop table if exists t1;\ncreate table t1(a datetime);\nINSERT INTO t1 VALUES (NULL), ('2001-01-01 00:00:00.12'), ('2002-01-01 00:00:00.567');\n\nmysql> select a from t1 group by a having COALESCE(a)<\"2002-01-01\";\n+---------------------+\n| a                   |\n+---------------------+\n| 2001-01-01 00:00:00 |\n+---------------------+\n
      • Example: ON CONDITION
      drop table if exists t1;\ndrop table if exists t2;\ncreate table t1(a INT,  b varchar(255));\ncreate table t2(a INT,  b varchar(255));\ninsert into t1 values(1, \"\u4f60\u597d\"), (3, \"\u518d\u89c1\");\ninsert into t2 values(2, \"\u65e5\u671f\u65f6\u95f4\"), (4, \"\u660e\u5929\");\n> SELECT t1.a, t2.a FROM t1 JOIN t2 ON (length(COALESCE(t1.b)) = length(COALESCE(t2.b)));\n+------+------+\n| a    | a    |\n+------+------+\n|    1 |    4 |\n|    3 |    4 |\n+------+------+\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/comparison-functions-and-operators-overview/","title":"Comparison Functions and Operators Overview","text":"Name Description > Greater than operator >= Greater than or equal operator < Less than operator <>,!= Not equal operator <= Less than or equal operator = Equal operator BETWEEN ... AND ... Whether a value is within a range of values COALESCE Return the first non-null value in a list IN() Whether a value is within a set of values IS Test a value against a boolean IS NOT Test a value against a boolean IS NOT NULL NOT NULL value test IS NULL NULL value test ISNULL NULL value test LIKE Simple pattern matching ILIKE Simple pattern matching. Same as LIKE. But it is not case sensitive. NOT BETWEEN ... AND ... Whether a value is not within a range of values NOT IN shorthand for multiple XOR conditions. NOT LIKE Negation of simple pattern matching

      Comparison operations result in a value of TRUE, FALSE, or NULL. These operations work for both numbers and strings. Strings are automatically converted to numbers and numbers to strings as necessary.

      The following relational comparison operators can be used to compare not only scalar operands, but row operands:

      =  >  <  >=  <=  <>  !=\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/","title":"INTERVAL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#description","title":"Description","text":"

      The INTERVAL operator returns 0 if N < N1, 1 if N < N2 and so on or -1 if N is NULL. All arguments are treated as integers. It is required that N1 < N2 < N3 < ... < Nn for this function to work correctly. This is because a binary search is used (very fast).

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#syntax","title":"Syntax","text":"
      > INTERVAL(N,N1,N2,N3,...)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#examples","title":"Examples","text":"
      >\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/","title":"ISNULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#description","title":"Description","text":"

      The ISNULL() function can be used instead of = to test whether a value is NULL. (Comparing a value to NULL using = always yields NULL.)

      If expression is NULL, this function returns true. Otherwise, it returns false.

      The ISNULL() function shares some special behaviors with the IS NULL comparison operator. See the description of IS NULL.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#syntax","title":"Syntax","text":"
      > ISNULL(expr)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#examples","title":"Examples","text":"
      • Example 1:
      mysql> SELECT ISNULL(1+1);\n+---------------+\n| isnull(1 + 1) |\n+---------------+\n| false         |\n+---------------+\n1 row in set (0.02 sec)\n
      • Example 2:
      CREATE TABLE students (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, birth_date DATE );\n\nINSERT INTO students (name, birth_date) VALUES ('John Doe', '2000-05-15'), ('Alice Smith', NULL), ('Bob Johnson', '1999-10-20');\n\n-- Use the ISNULL() function to find students whose birth date is not filled in:\nmysql> SELECT * FROM students WHERE ISNULL(birth_date);\n+------+-------------+------------+\n| id   | name        | birth_date |\n+------+-------------+------------+\n|    2 | Alice Smith | NULL       |\n+------+-------------+------------+\n1 row in set (0.00 sec)\n\n-- The ISNULL() function can also use IS NULL to achieve the same function, so the following queries are also equivalent:\nmysql> SELECT * FROM students WHERE birth_date IS NULL;\n+------+-------------+------------+\n| id   | name        | birth_date |\n+------+-------------+------------+\n|    2 | Alice Smith | NULL       |\n+------+-------------+------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/","title":"STRCMP","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#description","title":"Description","text":"

      The STRCMP() returns 0 if the strings are the same, -1 if the first argument is smaller than the second according to the current sort order, and NULL if either argument is NULL. It returns 1 otherwise.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#syntax","title":"Syntax","text":"
      > STRCMP(expr1,expr2)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#examples","title":"Examples","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/","title":">=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#description","title":"Description","text":"

      The >= operator returns true only if the left-hand operand is greater than or equal to the right-hand operand.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#syntax","title":"Syntax","text":"
      > SELECT x >= y;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#examples","title":"Examples","text":"
      mysql> SELECT 2 >= 2;\n+--------+\n| 2 >= 2 |\n+--------+\n| true   |\n+--------+\n1 row in set (0.01 sec)\n
      create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where spID>=userID*score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n|      1 |    1 |     1 |\n+--------+------+-------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/","title":">","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#description","title":"Description","text":"

      The > operator returns true only if the left-hand operand is greater than the right-hand operand.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#syntax","title":"Syntax","text":"
      > SELECT x > y;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#examples","title":"Examples","text":"
      mysql> SELECT 2 > 2;\n+-------+\n| 2 > 2 |\n+-------+\n| false |\n+-------+\n1 row in set (0.00 sec)\n
      create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select spID,userID,score from t1 where spID>(userID-1);\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n|    1 |      1 |     1 |\n|    2 |      2 |     2 |\n|    2 |      1 |     4 |\n|    3 |      3 |     3 |\n|    1 |      1 |     5 |\n+------+--------+-------+\n5 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/","title":"ILIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#description","title":"Description","text":"

      The ILIKE operator is used similarly to the LIKE operator to search for a specified pattern in a column in the WHERE clause.

      The main difference between the ILIKE operator and the LIKE operator is case sensitivity. When using ILIKE, characters in a string are treated the same whether they are uppercase or lowercase.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#syntax","title":"Syntax","text":"
      > SELECT column1, column2, ...\nFROM table_name\nWHERE columnN ILIKE pattern;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#examples","title":"Examples","text":"
      drop table t1;\ncreate table t1(a varchar(20));\ninsert into t1 values ('abc'), ('ABC'), ('abC');\nselect * from t1 where a ilike '%abC%';\n\nmysql> select * from t1 where a ilike '%abC%';\n+------+\n| a    |\n+------+\n| abc  |\n| ABC  |\n| abC  |\n+------+\n3 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/","title":"IN","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#description","title":"Description","text":"

      The IN operator allows you to specify multiple values in a WHERE clause. And it's a shorthand for multiple OR conditions.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#syntax","title":"Syntax","text":"
      > SELECT column1, column2, ...\nFROM table_name\nWHERE column_name IN (value1, value2, ...);\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#examples","title":"Examples","text":"
      create table t2(a int,b varchar(5),c float, d date, e datetime);\ninsert into t2 values(1,'a',1.001,'2022-02-08','2022-02-08 12:00:00');\ninsert into t2 values(2,'b',2.001,'2022-02-09','2022-02-09 12:00:00');\ninsert into t2 values(1,'c',3.001,'2022-02-10','2022-02-10 12:00:00');\ninsert into t2 values(4,'d',4.001,'2022-02-11','2022-02-11 12:00:00');\n\nmysql> select * from t2 where a in (2,4);\na   b   c   d   e\n2   b   2.0010  2022-02-09  2022-02-09 12:00:00\n4   d   4.0010  2022-02-11  2022-02-11 12:00:00\n\nmysql> select * from t2 where a not in (2,4);\na   b   c   d   e\n1   a   1.0010  2022-02-08  2022-02-08 12:00:00\n1   c   3.0010  2022-02-10  2022-02-10 12:00:00\n\nmysql> select * from t2 where b not in ('e',\"f\");\na   b   c   d   e\n1   a   1.0010  2022-02-08  2022-02-08 12:00:00\n2   b   2.0010  2022-02-09  2022-02-09 12:00:00\n1   c   3.0010  2022-02-10  2022-02-10 12:00:00\n4   d   4.0010  2022-02-11  2022-02-11 12:00:00\n\nmysql> select * from t2 where e not in ('2022-02-09 12:00:00') and a in (4,5);\na   b   c   d   e\n4   d   4.0010  2022-02-11  2022-02-11 12:00:00\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#constraints","title":"Constraints","text":"
      • Currently, only constant lists are supported on the left side of IN.
      • There can only be a single column to the left of IN, not a tuple of multiple columns.
      • NULL values couldn't appear in the list to the right of IN.
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/","title":"IS NOT NULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/#description","title":"Description","text":"

      The IS NOT NULL function tests whether a value is not NULL.

      If expression is NOT NULL, this function returns true. Otherwise, it returns false.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/#syntax","title":"Syntax","text":"
      > expression IS NOT NULL\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/#examples","title":"Examples","text":"
      mysql> SELECT 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL;\n+---------------+---------------+------------------+\n| 1 is not null | 0 is not null | null is not null |\n+---------------+---------------+------------------+\n| true          | true          | false            |\n+---------------+---------------+------------------+\n1 row in set (0.01 sec)\n
      create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n| NULL  | NULL  |\n+-------+-------+\nmysql> select * from t1 where b is NOT NULL;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n+-------+-------+\n4 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/","title":"IS NOT","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#description","title":"Description","text":"

      The IS NOT tests a value against a boolean value, where boolean_value can be TRUE, FALSE, or UNKNOWN.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#syntax","title":"Syntax","text":"
      > IS NOT boolean_value\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#examples","title":"Examples","text":"
      mysql> SELECT 1 IS NOT TRUE, 0 IS NOT FALSE, NULL IS NOT UNKNOWN;\n+-----------+------------+----------+\n| 1 != true | 0 != false | null !=  |\n+-----------+------------+----------+\n| false     | false      | NULL     |\n+-----------+------------+----------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/","title":"IS NULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#description","title":"Description","text":"

      The IS NOT NULL function tests whether a value is NULL.

      It returns TRUE if a NULL value is found, otherwise it returns FALSE. It can be used in a SELECT, INSERT, UPDATE, or DELETE statement.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#syntax","title":"Syntax","text":"
      > expression IS NULL\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#examples","title":"Examples","text":"
      mysql> SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL;\n+-----------+-----------+--------------+\n| 1 is null | 0 is null | null is null |\n+-----------+-----------+--------------+\n| false     | false     | true         |\n+-----------+-----------+--------------+\n1 row in set (0.01 sec)\n
      create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n| NULL  | NULL  |\n+-------+-------+\nmysql> select * from t1 where a IS NULL;\n+------+------+\n| a    | b    |\n+------+------+\n| NULL | NULL |\n+------+------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/","title":"IS","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#description","title":"Description","text":"

      The IS tests a value against a boolean value, where boolean_value can be TRUE, FALSE, or UNKNOWN.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#syntax","title":"Syntax","text":"
      > IS boolean_value\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#examples","title":"Examples","text":"
      mysql> SELECT 1 IS TRUE, 0 IS FALSE, NULL IS UNKNOWN;\n+----------+-----------+---------+\n| 1 = true | 0 = false | null =  |\n+----------+-----------+---------+\n| true     | true      | NULL    |\n+----------+-----------+---------+\n1 row in set (0.01 sec)\n
      create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | false |\n| true  | true  |\n| false | false |\n| NULL  | NULL  |\n+-------+-------+\nmysql> select * from t1 where a<=b and a is not NULL;\n+-------+-------+\n| a     | b     |\n+-------+-------+\n| false | true  |\n| true  | true  |\n| false | false |\n+-------+-------+\n3 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/","title":"<=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#description","title":"Description","text":"

      The <= operator returns true only if the left-hand operand is less than or equal to the right-hand operand.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#syntax","title":"Syntax","text":"
      > SELECT x <= y;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#examples","title":"Examples","text":"
      mysql> SELECT 2 <= 2;\n+--------+\n| 2 <= 2 |\n+--------+\n| true   |\n+--------+\n1 row in set (0.00 sec)\n
      create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,score,spID from t1 where userID<=score/spID;\n+--------+-------+------+\n| userid | score | spid |\n+--------+-------+------+\n|      1 |     1 |    1 |\n|      1 |     4 |    2 |\n|      1 |     5 |    1 |\n|     11 |    99 |    5 |\n+--------+-------+------+\n4 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/","title":"<","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#description","title":"Description","text":"

      The < operator returns true only if the left-hand operand is less than the right-hand operand.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#syntax","title":"Syntax","text":"
      > SELECT x < y;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#examples","title":"Examples","text":"
      mysql> SELECT 2 < 2;\n+-------+\n| 2 < 2 |\n+-------+\n| false |\n+-------+\n1 row in set (0.00 sec)\n
      create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select spID,userID,score from t1 where (userID-1)<spID;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n|    1 |      1 |     1 |\n|    2 |      2 |     2 |\n|    2 |      1 |     4 |\n|    3 |      3 |     3 |\n|    1 |      1 |     5 |\n+------+--------+-------+\n5 rows in set (0.00 sec)\nmysql> select spID,userID,score from t1 where spID<(userID-1);\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n|    4 |      6 |    10 |\n|    5 |     11 |    99 |\n+------+--------+-------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/","title":"LIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#description","title":"Description","text":"

      The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

      There are two wildcards often used in conjunction with the LIKE operator:

      • The percent sign % wildcard: means to match any sequence of characters (including empty character sequences).

        • %text: matches a string ending with \"text\".
        • text%: matches a string starting with \"text\".
        • %text%: Matches a string containing \"text\".
      • Underscore _ wildcard: means match a single character.

        • te_t: can match \"text\", \"test\", etc.
      • Other characters: The LIKE operator is case-sensitive for other characters.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#syntax","title":"Syntax","text":"
      > SELECT column1, column2, ...\nFROM table_name\nWHERE columnN LIKE pattern;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#examples","title":"Examples","text":"
      drop table t1;\ncreate table t1(a varchar(20));\ninsert into t1 values ('abc'), ('ABC'), ('abC');\nselect * from t1 where a ilike '%abC%';\n\nmysql> select * from t1 where a like '%abC%';\n+------+\n| a    |\n+------+\n| abC  |\n+------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/","title":"NOT BETWEEN ... AND ...","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#description","title":"Description","text":"

      If expr is less than or equal to min and expr is greater than or equal to max, NOT BETWEEN returns true, otherwise it returns false.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#syntax","title":"Syntax","text":"
      > expr NOT BETWEEN min AND max\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#examples","title":"Examples","text":"
      mysql> SELECT 2 NOT BETWEEN 1 AND 3, 2 NOT BETWEEN 3 and 1;\n+-----------------------+-----------------------+\n| 2 not between 1 and 3 | 2 not between 3 and 1 |\n+-----------------------+-----------------------+\n| false                 | true                  |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n
      create table t (id bigint unsigned, b int);\ninsert into t values(8894754949779693574,1);\ninsert into t values(8894754949779693579,2);\ninsert into t values(17790886498483827171,3);\n\nmysql> select count(*) from t where id>=8894754949779693574 and id =17790886498483827171 order by 1 asc;\n+----------+\n| count(*) |\n+----------+\n|        0 |\n+----------+\nmysql> select count(*) from t where id not between 8894754949779693574 and 17790886498483827171;\n+----------+\n| count(*) |\n+----------+\n|        3 |\n+----------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/","title":"<>,!=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#description","title":"Description","text":"

      The <>,!= operator returns true only if the left-hand operand is not equal to the right-hand operand.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#syntax","title":"Syntax","text":"
      > SELECT x <> y;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#examples","title":"Examples","text":"
      mysql> SELECT 2 <> 2;\n+--------+\n| 2 != 2 |\n+--------+\n| false  |\n+--------+\n1 row in set (0.01 sec)\n
      create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where userID=spID and userID<>score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n|      1 |    1 |     5 |\n+--------+------+-------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/","title":"NOT IN","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#description","title":"Description","text":"

      The NOT IN operator allows you to specify multiple values in a WHERE clause. And it's a shorthand for multiple XOR conditions.

      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#syntax","title":"Syntax","text":"
      > SELECT column1, column2, ...\nFROM table_name\nWHERE column_name NOT IN (value1, value2, ...);\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#examples","title":"Examples","text":"
      create table t2(a int,b varchar(5),c float, d date, e datetime);\ninsert into t2 values(1,'a',1.001,'2022-02-08','2022-02-08 12:00:00');\ninsert into t2 values(2,'b',2.001,'2022-02-09','2022-02-09 12:00:00');\ninsert into t2 values(1,'c',3.001,'2022-02-10','2022-02-10 12:00:00');\ninsert into t2 values(4,'d',4.001,'2022-02-11','2022-02-11 12:00:00');\n\nmysql> select * from t2 where a not in (2,4);\n+------+------+-------+------------+----------------------------+\n| a    | b    | c     | d          | e                          |\n+------+------+-------+------------+----------------------------+\n|    1 | a    | 1.001 | 2022-02-08 | 2022-02-08 12:00:00.000000 |\n|    1 | c    | 3.001 | 2022-02-10 | 2022-02-10 12:00:00.000000 |\n+------+------+-------+------------+----------------------------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t2 where b not in ('e',\"f\");\n+------+------+-------+------------+----------------------------+\n| a    | b    | c     | d          | e                          |\n+------+------+-------+------------+----------------------------+\n|    1 | a    | 1.001 | 2022-02-08 | 2022-02-08 12:00:00.000000 |\n|    2 | b    | 2.001 | 2022-02-09 | 2022-02-09 12:00:00.000000 |\n|    1 | c    | 3.001 | 2022-02-10 | 2022-02-10 12:00:00.000000 |\n|    4 | d    | 4.001 | 2022-02-11 | 2022-02-11 12:00:00.000000 |\n+------+------+-------+------------+----------------------------+\n4 rows in set (0.01 sec)\n\nmysql> select * from t2 where e not in ('2022-02-09 12:00:00') and a in (4,5);\na   b   c   d   e\n4   d   4.0010  2022-02-11  2022-02-11 12:00:00\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#constraints","title":"Constraints","text":"
      • Currently, only constant lists are supported on the left side of NOT IN.
      • There can only be a single column to the left of NOT IN, not a tuple of multiple columns.
      • NULL values couldn't appear in the list to the right of NOT IN.
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/","title":"NOT LIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/#description","title":"Description","text":"

      The NOT LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

      There are two wildcards often used in conjunction with the NOT LIKE operator:

      • The percent sign (%) represents zero, one, or multiple characters.
      • The underscore sign (_) represents one, single character.
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/#syntax","title":"Syntax","text":"
      > SELECT column1, column2, ...\nFROM table_name\nWHERE columnN NOT LIKE pattern;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/#examples","title":"Examples","text":"
      create table t1 (a char(10));\ninsert into t1 values('abcdef');\ninsert into t1 values('_bcdef');\ninsert into t1 values('a_cdef');\ninsert into t1 values('ab_def');\ninsert into t1 values('abc_ef');\ninsert into t1 values('abcd_f');\ninsert into t1 values('abcde_');\n\nmysql> select * from t1 where a not like 'a%';\n+--------+\n| a      |\n+--------+\n| _bcdef |\n+--------+\nmysql> select * from t1 where a not like \"%d_\\_\";\n+--------+\n| a      |\n+--------+\n| abc_ef |\n+--------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/","title":"CASE WHEN","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/#description","title":"Description","text":"

      CASE WHEN statement is used in that evaluates a list of conditions and returns one of multiple possible result expressions.

      Cases come in two formats: a simple CASE function compares an expression to a set of simple expressions to determine the result. The CASE search function evaluates a set of Boolean expressions to determine the result. Both formats support the optional ELSE argument.

      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/#syntax","title":"Syntax","text":"
      • Syntax 1:
      CASE value WHEN compare_value THEN result [WHEN compare_value THEN result ...] [ELSE result] END\n

      This CASE syntax returns the result for the first value=compare_value comparison that is true.

      • Syntax 2:
      CASE WHEN condition THEN result [WHEN condition THEN result ...] [ELSE result] END\n

      This CASE syntax returns the result for the first condition that is true. If no comparison or condition is true, the result after ELSE is returned, or NULL if there is no ELSE part.

      note

      The CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END.

      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/#examples","title":"Examples","text":"
      mysql> SELECT CASE WHEN 1>0 THEN 'true' ELSE 'false' END;\n+------------------------------------------+\n| case when 1 > 0 then true else false end |\n+------------------------------------------+\n| true                                     |\n+------------------------------------------+\n1 row in set (0.00 sec)\n
      CREATE TABLE t1 (a INT, b INT);\nQuery OK, 0 rows affected (0.01 sec)\n\nINSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3);\nQuery OK, 6 rows affected (0.01 sec)\n\nmysql> SELECT CASE WHEN AVG(a)>=0 THEN 'Positive' ELSE 'Negative' END FROM t1 GROUP BY b;\n+-------------------------------------------------------+\n| case when avg(a) >= 0 then Positive else Negative end |\n+-------------------------------------------------------+\n| Positive                                              |\n| Positive                                              |\n| Positive                                              |\n+-------------------------------------------------------+\n3 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/flow-control-functions-overview/","title":"Flow Control Functions","text":"Name Description CASE Case operator IF() If/else construct IFNULL() Null if/else construct NULLIF() Return NULL if expr1 = expr2"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/","title":"IF","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#description","title":"Description","text":"

      The IF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.

      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#syntax","title":"Syntax","text":"
      > IF(expr1,expr2,expr3)\n
      • If expr1 is TRUE (expr1 <> 0 and expr1 IS NOT NULL), IF() returns expr2. Otherwise, it returns expr3.

      • If only one of expr2 or expr3 is explicitly NULL, the result type of the IF() function is the type of the non-NULL expression.

      • The default return type of IF() (which may matter when it is stored into a temporary table) is calculated as follows:

        • If expr2 or expr3 produce a string, the result is a string.

        • If expr2 and expr3 are both strings, the result is case-sensitive if either string is case-sensitive.

        • If expr2 or expr3 produce a floating-point value, the result is a floating-point value.

        • If expr2 or expr3 produce an integer, the result is an integer.

      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#examples","title":"Examples","text":"
      mysql> SELECT IF(1>2,2,3);\n+-----------------+\n| if(1 > 2, 2, 3) |\n+-----------------+\n|               3 |\n+-----------------+\n1 row in set (0.01 sec)\nmysql> SELECT IF(1<2,'yes','no');\n+--------------------+\n| if(1 < 2, yes, no) |\n+--------------------+\n| yes                |\n+--------------------+\n1 row in set (0.00 sec)\n
      CREATE TABLE t1 (st varchar(255) NOT NULL, u int(11) NOT NULL);\nINSERT INTO t1 VALUES ('a',1),('A',1),('aa',1),('AA',1),('a',1),('aaa',0),('BBB',0);\n\nmysql> select if(u=1,st,st) s from t1 order by s;\n+------+\n| s    |\n+------+\n| A    |\n| AA   |\n| BBB  |\n| a    |\n| a    |\n| aa   |\n| aaa  |\n+------+\n7 rows in set (0.00 sec)\n\nmysql> select if(u=1,st,st) s from t1 where st like \"%a%\" order by s;\n+------+\n| s    |\n+------+\n| a    |\n| a    |\n| aa   |\n| aaa  |\n+------+\n4 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#constraints","title":"Constraints","text":"

      Parameters BIGINT and VARCHAR are not supported with the function 'if'.

      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/","title":"IFNULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/#description","title":"Description","text":"

      If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2. The default return type of IFNULL(expr1,expr2) is the more \"general\" of the two expressions, in the order STRING, REAL, or INTEGER.

      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/#syntax","title":"Syntax","text":"
      > IFNULL(expr1,expr2)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/#examples","title":"Examples","text":"
      mysql> SELECT IFNULL(NULL,10);\n+------------------+\n| ifnull(null, 10) |\n+------------------+\n|               10 |\n+------------------+\n1 row in set (0.00 sec)\n
      mysql> SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL);\n+-----------------------------------------+\n| cast(ifnull(null, null) as decimal(10)) |\n+-----------------------------------------+\n|                                    NULL |\n+-----------------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/","title":"NULLIF","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#description","title":"Description","text":"

      The NULLIF() function returns NULL if expr1 = expr2 is true, otherwise returns expr1.

      The return value has the same type as the first argument.

      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#syntax","title":"Syntax","text":"
      > NULLIF(expr1,expr2)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#examples","title":"Examples","text":"
      CREATE TABLE employees ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, salary DECIMAL(10, 2) );\n\nINSERT INTO employees (name, salary) VALUES ('John Doe', 1000), ('Alice Smith', 2000), ('Bob Johnson', 1500);\n\n-- Use the NULLIF() function to set the salary of employees whose salary is a specific value to NULL. The NULLIF(salary, 1500) function will compare the value of the salary field with 1500. Returns NULL if the salary value equals 1500; otherwise, returns the salary value.\nmysql> SELECT name, salary, NULLIF(salary, 1500) AS adjusted_salary FROM employees;\n+-------------+---------+-----------------+\n| name        | salary  | adjusted_salary |\n+-------------+---------+-----------------+\n| John Doe    | 1000.00 | 1000.00         |\n| Alice Smith | 2000.00 | 2000.00         |\n| Bob Johnson | 1500.00 |                 |\n+-------------+---------+-----------------+\n3 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/","title":"AND,&&","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#description","title":"Description","text":"

      Logical AND,&&. Evaluates to true if all operands are nonzero and not NULL, to false if one or more operands are 0, otherwise NULL is returned.

      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#syntax","title":"Syntax","text":"
      > SELECT column_1 AND column_2 FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#examples","title":"Examples","text":"
      mysql> select 1 and 1;\n+---------+\n| 1 and 1 |\n+---------+\n| true    |\n+---------+\nmysql> select 1 and 0;\n+---------+\n| 1 and 0 |\n+---------+\n| false   |\n+---------+\nmysql> select 1 and null;\n+------------+\n| 1 and null |\n+------------+\n| NULL       |\n+------------+\nmysql> select null and 0;\n+------------+\n| null and 0 |\n+------------+\n| false      |\n+------------+\n1 row in set (0.01 sec)\n
      create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\nmysql> select a and b from t1;\n+---------+\n| a and b |\n+---------+\n| false   |\n| false   |\n| true    |\n| false   |\n| NULL    |\n+---------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/logical-operators-overview/","title":"Logical Operators","text":"Name Description AND,&& Logical AND NOT,! Negates value OR Logical OR XOR Logical XOR"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/","title":"NOT,!","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#description","title":"Description","text":"

      Logical NOT,!. Evaluates to true if the operand is 0, to false if the operand is nonzero, and NOT NULL returns NULL.

      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#syntax","title":"Syntax","text":"
      > SELECT not column_name FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#examples","title":"Examples","text":"
      mysql> select not 0;\n+-------+\n| not 0 |\n+-------+\n| true  |\n+-------+\n1 row in set (0.02 sec)\nmysql> select not null;\n+----------+\n| not null |\n+----------+\n| NULL     |\n+----------+\n1 row in set (0.00 sec)\nmysql> select not 1;\n+-------+\n| not 1 |\n+-------+\n| false |\n+-------+\n1 row in set (0.01 sec)\n
      create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select not a and not b from t1;\n+-----------------+\n| not a and not b |\n+-----------------+\n| false           |\n| false           |\n| false           |\n| true            |\n| NULL            |\n+-----------------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#constraints","title":"Constraints","text":"

      ! is not supported for now.

      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/","title":"OR","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#description","title":"Description","text":"

      Logical OR,||. When both operands are non-NULL, the result is true if any operand is nonzero, and false otherwise. With a NULL operand, the result is true if the other operand is nonzero, and NULL otherwise. If both operands are NULL, the result is NULL.

      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#syntax","title":"Syntax","text":"
      > SELECT column_1 OR column_2 FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#examples","title":"Examples","text":"
      mysql> select 1 or 1;\n+--------+\n| 1 or 1 |\n+--------+\n| true   |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select 1 or 0;\n+--------+\n| 1 or 0 |\n+--------+\n| true   |\n+--------+\n1 row in set (0.00 sec)\n\nmysql> select 0 or 0;\n+--------+\n| 0 or 0 |\n+--------+\n| false  |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select 0 or null;\n+-----------+\n| 0 or null |\n+-----------+\n| NULL      |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> select 1 or null;\n+-----------+\n| 1 or null |\n+-----------+\n| true      |\n+-----------+\n1 row in set (0.00 sec)\n
      create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select a or b from t1;\n+--------+\n| a or b |\n+--------+\n| true   |\n| true   |\n| true   |\n| false  |\n| NULL   |\n+--------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/","title":"XOR","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#description","title":"Description","text":"

      Logical XOR. Returns NULL if either operand is NULL. For non-NULL operands, evaluates to true if an odd number of operands is nonzero, otherwise false is returned.

      a XOR b is mathematically equal to (a AND (NOT b)) OR ((NOT a) and b).

      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#syntax","title":"Syntax","text":"
      > SELECT column_1 XOR column_2 FROM table_name;\n
      "},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#examples","title":"Examples","text":"
      mysql> select 1 xor 1;\n+---------+\n| 1 xor 1 |\n+---------+\n| false   |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select 1 xor 0;\n+---------+\n| 1 xor 0 |\n+---------+\n| true    |\n+---------+\n1 row in set (0.00 sec)\n\nmysql> select 1 xor null;\n+------------+\n| 1 xor null |\n+------------+\n| NULL       |\n+------------+\n1 row in set (0.01 sec)\n\nmysql> select 1 xor 1 xor 1;\n+---------------+\n| 1 xor 1 xor 1 |\n+---------------+\n| true          |\n+---------------+\n1 row in set (0.00 sec)\n
      create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select a xor b from t1;\n+---------+\n| a xor b |\n+---------+\n| true    |\n| true    |\n| false   |\n| false   |\n| NULL    |\n+---------+\n5 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/","title":"ALTER ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#description","title":"Description","text":"

      Modify account information.

      Note

      1. The cluster administrator (i.e., the root user) can modify the password of the account it creates.
      2. Accounts themselves can modify their own passwords.
      3. Only the cluster administrator (i.e., the root user) can perform SUSPEND \u200b\u200band RECOVER (OPEN) account operations.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#syntax","title":"Syntax","text":"
      > ALTER ACCOUNT [IF EXISTS]\naccount auth_option [COMMENT 'comment_string']\n\nauth_option: {\nADMIN_NAME [=] 'admin_name'\nIDENTIFIED BY 'auth_string'\n}\n\nstatus_option: {\nOPEN\n| SUSPEND\n| RESTRICTED\n}\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#auth_option","title":"auth_option","text":"

      Modifies the account's default account name and authorization mode, auth_string specifies the password explicitly.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#status_option","title":"status_option","text":"

      Set the state of the account. They are stored as VARCHAR in the mo_account table under the system database mo_catalog.

      • SUSPEND: Suspend the account's service; the account can no longer access MatrixOne after the suspension.

        • When the SUSPEND state is enabled for the account, access behavior will be suspended even if the account is accessing it.
        • To unsuspend the user's service, switch the status to OPEN to unsuspend the service; that is, run ALTER ACCOUNT account_name OPEN to unsuspend the service.
      • OPEN: Resume a suspended account, after which the account will usually access MatrixOne.

      • RESTRICTED: Allows the user to access and perform limited actions. After the RESTRICTED state is enabled for this tenant, this tenant can only perform SHOW/DELETE/SELECT/USE operations on the database, and other operations cannot be used.
        • When the RESTRICTED state is enabled for the tenant, access behavior will be restricted even if the account is accessing it.
        • To lift the restrictions on the user, switch the status to OPEN to remove the restrictions.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#comment","title":"comment","text":"

      Account notes are stored as VARCHAR in the table mo_account in the system database mo_catalog.

      COMMENT can be arbitrary quoted text, and the new COMMENT replaces any existing user comments. As follows:

      mysql> desc mo_catalog.mo_account;\n+----------------+--------------+------+------+---------+-------+---------+\n| Field          | Type         | Null | Key  | Default | Extra | Comment |\n+----------------+--------------+------+------+---------+-------+---------+\n| account_id     | INT          | YES  |      | NULL    |       |         |\n| account_name   | VARCHAR(300) | YES  |      | NULL    |       |         |\n| status         | VARCHAR(300) | YES  |      | NULL    |       |         |\n| created_time   | TIMESTAMP    | YES  |      | NULL    |       |         |\n| comments       | VARCHAR(256) | YES  |      | NULL    |       |         |\n| suspended_time | TIMESTAMP    | YES  |      | null    |       |         |\n+----------------+--------------+------+------+---------+-------+---------+\n6 rows in set (0.06 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/1.0-alter-account/#examples","title":"Examples","text":"
      • Example 1: Modify the information on the account
      -- Create a account named \"root1\" with password \"111\"\nmysql> create account acc1 admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.42 sec)\n-- Change the initial password \"111\" to \"Abcd_1234@1234\"\nmysql> alter account acc1 admin_name \"root1\" identified by \"Abcd_1234@1234\";\nQuery OK, 0 rows affected (0.01 sec)\n-- Modify the comment for account \"root1\"\nmysql> alter account acc1 comment \"new account\";\nQuery OK, 0 rows affected (0.02 sec)\n-- Check to verify that the \"new account\" comment has been added to the account \"root1\"\nmysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status | suspended_time | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| acc1         | root1      | 2023-02-15 06:26:51 | open   | NULL           |        5 |          34 |       787 | 0.036 | new account    |\n| sys          | root       | 2023-02-14 06:58:15 | open   | NULL           |        8 |          57 |      3767 | 0.599 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n3 rows in set (0.19 sec)\n
      • Example 2: Modify the status of the account
      -- Create a account named \"root1\" with password \"111\"\nmysql> create account accx admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.27 sec)\n-- Modify the account status to \"suspend\", that is, suspend user access to MatrixOne.\nmysql> alter account accx suspend;\nQuery OK, 0 rows affected (0.01 sec)\n-- Check if the modification status is successful.\nmysql> show accounts;\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status  | suspended_time      | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| accx         | root1      | 2023-02-15 06:26:51 | suspend | 2023-02-15 06:27:15 |        5 |          34 |       787 | 0.036 | new accout     |\n| sys          | root       | 2023-02-14 06:58:15 | open    | NULL                |        8 |          57 |      3767 | 0.599 | system account |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n2 rows in set (0.15 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/","title":"ALTER ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#description","title":"Description","text":"

      Modify account information.

      Note

      1. The cluster administrator (i.e., the root user) can modify the password of the account it creates.
      2. Accounts themselves can modify their own passwords.
      3. Only the cluster administrator (i.e., the root user) can perform SUSPEND \u200b\u200band RECOVER (OPEN) account operations.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#syntax","title":"Syntax","text":"
      > ALTER ACCOUNT [IF EXISTS]\naccount auth_option [COMMENT 'comment_string']\n\nauth_option: {\nADMIN_NAME [=] 'admin_name'\nIDENTIFIED BY 'auth_string'\n}\n\nstatus_option: {\nOPEN\n| SUSPEND\n}\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#auth_option","title":"auth_option","text":"

      Modifies the default account name and authorization mode of the account, auth_string specifies the password explicitly.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#status_option","title":"status_option","text":"

      Set the state of the account. They are stored as VARCHAR in the mo_account table under the system database mo_catalog.

      • SUSPEND: Suspend the account's service; that is, the account can no longer access MatrixOne after the suspension; users who are accessing the account can continue to access, and after closing the session, they will no longer be able to access MatrixOne.
      • OPEN: Resume a suspended account, after which the account will usually access MatrixOne.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#comment","title":"comment","text":"

      Account notes are stored as VARCHAR in the table mo_account in the system database mo_catalog.

      COMMENT can be arbitrary quoted text, and the new COMMENT replaces any existing user comments. As follows:

      mysql> desc mo_catalog.mo_account;\n+----------------+--------------+------+------+---------+-------+---------+\n| Field          | Type         | Null | Key  | Default | Extra | Comment |\n+----------------+--------------+------+------+---------+-------+---------+\n| account_id     | INT          | YES  |      | NULL    |       |         |\n| account_name   | VARCHAR(300) | YES  |      | NULL    |       |         |\n| status         | VARCHAR(300) | YES  |      | NULL    |       |         |\n| created_time   | TIMESTAMP    | YES  |      | NULL    |       |         |\n| comments       | VARCHAR(256) | YES  |      | NULL    |       |         |\n| suspended_time | TIMESTAMP    | YES  |      | null    |       |         |\n+----------------+--------------+------+------+---------+-------+---------+\n6 rows in set (0.06 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#examples","title":"Examples","text":"
      • Example 1: Modify the information on the account
      -- Create a account named \"root1\" with password \"111\"\nmysql> create account acc1 admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.42 sec)\n-- Change the initial password \"111\" to \"Abcd_1234@1234\"\nmysql> alter account acc1 admin_name \"root1\" identified by \"Abcd_1234@1234\";\nQuery OK, 0 rows affected (0.01 sec)\n-- Modify the comment for account \"root1\"\nmysql> alter account acc1 comment \"new account\";\nQuery OK, 0 rows affected (0.02 sec)\n-- Check to verify that the \"new account\" comment has been added to the account \"root1\"\nmysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status | suspended_time | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| acc1         | root1      | 2023-02-15 06:26:51 | open   | NULL           |        5 |          34 |       787 | 0.036 | new account    |\n| sys          | root       | 2023-02-14 06:58:15 | open   | NULL           |        8 |          57 |      3767 | 0.599 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n3 rows in set (0.19 sec)\n
      • Example 2: Modify the status of the account
      -- Create a account named \"root1\" with password \"111\"\nmysql> create account accx admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.27 sec)\n-- Modify the account status to \"suspend\", that is, suspend user access to MatrixOne.\nmysql> alter account accx suspend;\nQuery OK, 0 rows affected (0.01 sec)\n-- Check if the modification status is successful.\nmysql> show accounts;\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status  | suspended_time      | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| accx         | root1      | 2023-02-15 06:26:51 | suspend | 2023-02-15 06:27:15 |        5 |          34 |       787 | 0.036 | new accout     |\n| sys          | root       | 2023-02-14 06:58:15 | open    | NULL                |        8 |          57 |      3767 | 0.599 | system account |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n2 rows in set (0.15 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/","title":"ALTER USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#description","title":"Description","text":"

      Modify the attributes and passwords of database users.

      Note

      1. Accounts can modify the passwords of the users they create and only modify the passwords of one user at a time. The modified passwords will take effect on the next login, and the current session will not be interrupted.
      2. Users can modify their own passwords, and the modified passwords will take effect on the next login, and the current session will not be interrupted.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#syntax","title":"Syntax","text":"
      ALTER USER [IF EXISTS]\n    user auth_option\n\nauth_option: {\n    IDENTIFIED BY 'auth_string'}\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#auth_option","title":"auth_option","text":"

      Specifies the default user name and authorization mode of the account, auth_string specifies the password explicitly.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#examples","title":"Examples","text":"
      -- Create a user named \"admin_1\" with password \"123456\"\nmysql> create user admin_1 identified by '123456';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Modify the user's initial password \"123456\" to \"111111\"\nmysql> alter user 'admin_1' identified by '111111';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Check if the password was changed successfully\nmysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time        | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n|       0 | localhost | root      | 111                   | unlock | 2023-04-19 06:37:58 | NULL         | PASSWORD   |       0 |     0 |            0 |\n|       1 | localhost | root      | 111                   | unlock | 2023-04-19 06:37:58 | NULL         | PASSWORD   |       0 |     0 |            0 |\n|       2 | localhost | admin_1   | 111111                | unlock | 2023-04-21 06:21:31 | NULL         | PASSWORD   |       1 |     0 |            1 |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n3 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/","title":"CREATE ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#description","title":"Description","text":"

      Create a new account in your organization.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#syntax","title":"Syntax","text":"
      > CREATE ACCOUNT  [IF NOT EXISTS]\naccount auth_option\n[COMMENT 'comment_string']\n\nauth_option: {\n    ADMIN_NAME [=] 'admin_name'\n    IDENTIFIED BY 'auth_string'\n}\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#auth_option","title":"auth_option","text":"

      Specifies the default account name and authorization mode of the account, auth_string specifies the password explicitly.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#examples","title":"Examples","text":"
      > create account tenant_test admin_name = 'root' identified by '111' comment 'tenant_test';\nQuery OK, 0 rows affected (0.08 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/","title":"CREATE ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#description","title":"Description","text":"

      Create a new role in the system.

      After creating roles, you can grant object privileges to the role and then grant the role to other roles or individual users to enable access control security for objects in the system.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#syntax","title":"Syntax","text":"
      > CREATE ROLE [IF NOT EXISTS] role [, role ] ...\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#examples","title":"Examples","text":"
      > create role rolex;\nQuery OK, 0 rows affected (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/","title":"CREATE USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#description","title":"Description","text":"

      Creates a new user in the system.

      To use CREATE USER, you must have the CREATE USER privilege.

      • The default role with CREATE USER privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#syntax","title":"Syntax","text":"
      > CREATE USER [IF NOT EXISTS]\n    user auth_option [, user auth_option] ...\n    [DEFAULT ROLE rolename]  \n    [COMMENT 'comment_string' | ATTRIBUTE 'json_object']\n\nauth_option: {\n    IDENTIFIED BY 'auth_string'\n}\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#explanations","title":"Explanations","text":"

      An user when first created has no privileges and a default role of NONE. To assign privileges or roles, use the GRANT statement.

      The basic SQL statement of CREAT USER is as follows:

      create user user_name identified by 'password';\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#identified-by-auth_string","title":"IDENTIFIED BY 'auth_string'","text":"

      CREATE USER permits these auth_option syntaxes:

      • 'auth_string': 'auth_string' value (the default is password) will be stored in the mo_user system table.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#default-role","title":"DEFAULT ROLE","text":"

      The DEFAULT ROLE clause defines which roles become active when the user connects to MatrixOne and authenticates, or when the user executes the SET ROLE statement during a session.

      create user user_name identified by 'password' default role role_rolename;\n

      The DEFAULT ROLE clause permits a list of one or more comma-separated role names. These roles must exist at the time CREATE USER is executed; otherwise the statement raises an error, and the user is not created.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#examples","title":"Examples","text":"
      > create user userx identified by '111';\nQuery OK, 0 rows affected (0.04 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#constraints","title":"Constraints","text":"

      MatrxiOne does not supports CREATE USER COMMENT and CREATE USER ATTRIBUTE now.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/","title":"DROP ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#description","title":"Description","text":"

      Delete the account in your organization.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#syntax","title":"Syntax","text":"
      > DROP ACCOUNT  [IF EXISTS] account\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#examples","title":"Examples","text":"
      > drop account if exists tenant_test;\nQuery OK, 0 rows affected (0.12 sec)\n

      Note

      If the account is in the session, when the account is removed, the session will be disconnected and MatrixOne can no longer be connected.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/","title":"DROP ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#description","title":"Description","text":"

      Removes the specified role from the system.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#syntax","title":"Syntax","text":"
      > DROP ROLE [IF EXISTS] role [, role ] ...\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#examples","title":"Examples","text":"
      > drop role if exists rolex;\nQuery OK, 0 rows affected (0.02 sec)\n

      Note

      If the user using this role is in a session, when the role is removed, the session will be disconnected immediately, and this role can no longer be used for operations.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/","title":"DROP USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#description","title":"Description","text":"

      Removes the specified user from the system.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#syntax","title":"Syntax","text":"
      > DROP USER [IF EXISTS] user [, user] ...\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#examples","title":"Examples","text":"
      > drop user if exists userx;\nQuery OK, 0 rows affected (0.02 sec)\n

      Note

      If the user is in a session, when the user is removed, the session is disconnected and MatrixOne can no longer be connected.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/","title":"GRANT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#description","title":"Description","text":"

      The GRANT statement assigns privileges and roles to MatrixOne users and roles.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#grant-overview","title":"GRANT Overview","text":"

      System permissions are those of the initial System account administrator ( The corresponding user is the root). The System account administrator can create and delete other accounts, and manage accounts. A System account administrator cannot manage other resources of other accounts.

      To use GRANT to GRANT permissions to other users or roles, you must first have the WITH GRANT OPTION permissions and the permissions you are granting. Use the' SHOW GRANTS' statement to find out the grant status of your current or another role. For more information, see SHOW GRANTS.

      The REVOKE statement is related to GRANT and enables administrators to remove account privileges. For more information on REVOKE, see REVOKE.

      Normally, a cluster has one root by default, the root first uses CREATE ACCOUNT to create a new account and define its nonprivilege characteristics such as its password, then account uses CREATE USER to create an user and uses GRANT to define its privileges. ALTER ACCOUNT may be used to change the nonprivilege characteristics of existing accounts. ALTER USER is used to change the privilege characteristics of existing users. For more information on privileges supported by MatrixOne, see Privilege Control Types.

      GRANT responds with Query OK, 0 rows affected when executed successfully. To determine what privileges result from the operation, use SHOW GRANTS

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#syntax","title":"Syntax","text":"
      > GRANT\n    priv_type [(column_list)]\n      [, priv_type [(column_list)]] ...\n    ON [object_type] priv_level\n    TO user_or_role [, user_or_role] ...\n\nGRANT role [, role] ...\n    TO user_or_role [, user_or_role] ...\n    [WITH ADMIN OPTION]\n\nobject_type: {\n    TABLE\n  | FUNCTION\n  | PROCEDURE\n}\n\npriv_level: {\n    *\n  | *.*\n  | db_name.*\n  | db_name.tbl_name\n  | tbl_name\n  | db_name.routine_name\n}\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#explanations","title":"Explanations","text":"

      The GRANT statement enables account to grant privileges and roles, which can be granted to users and roles. These syntax restrictions apply:

      • GRANT cannot mix granting both privileges and roles in the same statement. A given GRANT statement must grant either privileges or roles.

      • The ON clause distinguishes whether the statement grants privileges or roles:

        • With ON, the statement grants privileges.

        • Without ON, the statement grants roles.

        • It is permitted to assign both privileges and roles to an account, but you must use separate GRANT statements, each with syntax appropriate to what is to be granted.

      To grant a privilege with GRANT, you must have the GRANT OPTION privilege, and you must have the privileges that you are granting.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#database-privileges","title":"Database Privileges","text":"

      Database privileges apply to all objects in a given database. To assign database-level privileges, use ON db_name * syntax:

      grant all on database * to role1;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#table-privileges","title":"Table Privileges","text":"

      Table privileges apply to all columns in a given table. To assign table-level privileges, use ON db_name.tbl_name syntax:

      grant all on table *.* to role1;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#granting-roles","title":"Granting Roles","text":"

      GRANT syntax without an ON clause grants roles rather than individual privileges. A role is a named collection of privileges. For example:

      grant role3 to role_user;\n

      Each role to be granted must exist, as well as each user account or role to which it is to be granted.

      These privileges are required to grant roles:

      • You have the privilege to grant or revoke any role to users or roles.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#examples","title":"Examples","text":"
      > drop user if exists user_prepare_01;\n> drop role if exists role_prepare_1;\n> create user user_prepare_01 identified by '123456';\n> create role role_prepare_1;\n> create database if not exists p_db;\n> grant create table ,drop table on database *.*  to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant connect on account * to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant insert,select on table *.* to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant role_prepare_1 to user_prepare_01;\nQuery OK, 0 rows affected (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/","title":"REVOKE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#description","title":"Description","text":"

      Removes one or more privileges on a securable object from a role. The privileges that can be revoked are object-specific.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#syntax","title":"Syntax","text":"
      > REVOKE [IF EXISTS]\n    priv_type [(column_list)]\n      [, priv_type [(column_list)]] ...\n    ON object_type priv_level\n\n> REVOKE [IF EXISTS] role [, role ] ...\n    FROM user_or_role [, user_or_role ] ...\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#examples","title":"Examples","text":"
      > CREATE USER mouser IDENTIFIED BY '111';\nQuery OK, 0 rows affected (0.10 sec)\n\n> CREATE ROLE role_r1;\nQuery OK, 0 rows affected (0.05 sec)\n\n> GRANT role_r1 to mouser;\nQuery OK, 0 rows affected (0.04 sec)\n\n> GRANT create table on database * to role_r1;\nQuery OK, 0 rows affected (0.03 sec)\n\n> SHOW GRANTS for mouser@localhost;\n+-------------------------------------------------------+\n| Grants for mouser@localhost                           |\n+-------------------------------------------------------+\n| GRANT create table ON database * `mouser`@`localhost` |\n| GRANT connect ON account  `mouser`@`localhost`        |\n+-------------------------------------------------------+\n2 rows in set (0.02 sec)\n\n> REVOKE role_r1 from mouser;\nQuery OK, 0 rows affected (0.04 sec)\n\n> SHOW GRANT for mouser@localhost;\n+------------------------------------------------+\n| Grants for mouser@localhost                    |\n+------------------------------------------------+\n| GRANT connect ON account  `mouser`@`localhost` |\n+------------------------------------------------+\n1 row in set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence/","title":"ALTER SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence/#description","title":"Description","text":"

      ALTER SEQUENCE is used to modify an existing sequence.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence/#syntax","title":"Syntax","text":"
      > ALTER SEQUENCE [ IF EXISTS ] SEQUENCE_NAME\n[ AS data_type ]\n[ INCREMENT [ BY ] increment ]\n[ MINVALUE minvalue] [ MAXVALUE maxvalue]\n[ START [ WITH ] start ] [ [ NO ] CYCLE ]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence/#explanations","title":"Explanations","text":"
      • [ IF EXISTS ]: An optional clause that indicates that if the specified sequence does not exist, it will not raise an error. If this clause is used, the system checks if the sequence exists; if it does not, it will ignore the modification request.

      • SEQUENCE_NAME: The name of the sequence to be modified.

      • [ AS data_type ]: An optional clause that allows you to specify the data type for the sequence. Typically, the data type of a sequence is an integer.

      • [ INCREMENT [ BY ] increment ]: This specifies the increment value for the sequence. The increment value of the sequence is the amount to be added to the current value each time it is incremented or decremented. If the increment value is not specified, it is typically set to 1.

      • [ MINVALUE minvalue ]: This is the minimum value of the sequence, specifying the minimum value allowed for the sequence. If a minimum value is set, the sequence's current value cannot go below this value.

      • [ MAXVALUE maxvalue ]: This is the maximum value of the sequence, specifying the maximum value allowed for the sequence. If a maximum value is specified, the sequence's current value cannot exceed this value.

      • [ START [ WITH ] start ]: This is the sequence's starting value, specifying the sequence's initial value. If the starting value is not specified, it is typically set to 1.

      • [ [ NO ] CYCLE ]: An optional clause used to specify whether the sequence values should cycle. If NO CYCLE is specified, the sequence will stop incrementing or decrementing after reaching the maximum or minimum value. If this clause is not specified, it typically defaults to not cycling.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence/#examples","title":"Examples","text":"
      -- Create a sequence named alter_seq_01 with an increment of 2, a minimum value of 30, a maximum value of 100, and enable cycling\ncreate sequence alter_seq_01 as smallint increment by 2 minvalue 30 maxvalue 100 cycle;\n\nmysql> show sequences;\n+--------------+-----------+\n| Names        | Data Type |\n+--------------+-----------+\n| alter_seq_01 | SMALLINT  |\n+--------------+-----------+\n1 row in set (0.00 sec)\n\nmysql> alter sequence alter_seq_01 as bigint;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> show sequences;\n+--------------+-----------+\n| Names        | Data Type |\n+--------------+-----------+\n| alter_seq_01 | BIGINT    |\n+--------------+-----------+\n1 row in set (0.00 sec)\n\n-- Remove cycling for sequence alter_seq_01\nmysql> alter sequence alter_seq_01 no cycle;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 30                    | 30                    |\n+-----------------------+-----------------------+\n1 row in set (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 32                    | 32                    |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n\n-- Set the starting value of sequence alter_seq_01 to 40\nmysql> alter sequence alter_seq_01 start with 40;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 40                    | 40                    |\n+-----------------------+-----------------------+\n1 row in set (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 42                    | 42                    |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n\n-- Set the increment value of sequence alter_seq_01 to 3\nmysql> alter sequence alter_seq_01 increment by 3;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 40                    | 40                    |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 43                    | 43                    |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-replace-view/","title":"CREATE OR REPLACE VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-replace-view/#description","title":"Description","text":"

      CREATE OR REPLACE VIEW is used to create a new view or, when the view already exists, replace the existing view. This means updating the definition of the view when it already exists without the need to delete the existing view.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-replace-view/#syntax","title":"Syntax","text":"
      > CREATE OR REPLACE VIEW view_name AS\nSELECT column1, column2, ...\nFROM table_name\nWHERE condition;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-replace-view/#explanations","title":"Explanations","text":"
      • view_name: The name of the view to be created or replaced. You need to specify a unique name for the view.

      • AS: Indicates that the following query statement is the query definition of the view.

      • SELECT column1, column2, ...: After the AS keyword, you need to specify the query definition of the view. This SELECT statement can select specific columns from a table using computed fields, expressions, and more. The view will use the result of this query as its data.

      • FROM table_name: The FROM clause is used to specify the table's name to be queried. Select one or more tables and perform related operations in the view.

      • WHERE condition: An optional WHERE clause used to filter the query results.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-replace-view/#examples","title":"Examples","text":"
      -- Create a table t1 with two columns, a and b\ncreate table t1 (a int, b int);\n\n-- Insert three rows of data into table t1\ninsert into t1 values (1, 11), (2, 22), (3, 33);\n\n-- Create a view v1 that includes all data from table t1\ncreate view v1 as select * from t1;\n\n-- Query all data from view v1\nmysql> select * from v1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |   11 |\n|    2 |   22 |\n|    3 |   33 |\n+------+------+\n3 rows in set (0.01 sec)\n\n-- Query data from view v1 where column a is greater than 1\nmysql> select * from v1 where a > 1;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 |   22 |\n|    3 |   33 |\n+------+------+\n2 rows in set (0.00 sec)\n\n-- Replace view v1 with a new view that only includes data from table t1 where column a is greater than 1\ncreate or replace view v1 as select * from t1 where a > 1;\n\n-- Query view v1 again, now containing data that meets the new condition\nmysql> select * from v1;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 |   22 |\n|    3 |   33 |\n+------+------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-stage/","title":"CREATE STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-stage/#description","title":"Description","text":"

      The CREATE STAGE command is used in the MatrixOne database to create a named internal or external data stage for data export. By creating a data stage and exporting data to it, you can download data files to your local system or store them in cloud storage services.

      • Internal Stage: Internal stages store data files within the MatrixOne system. Internal stages can be either permanent or temporary.

      • External Stage: External stages reference data files stored outside the MatrixOne environment. Currently, the following cloud storage services are supported:

        • Amazon S3 buckets
        • Aliyun buckets

      The storage location can be private/protected or public\u2014however, data held in archival cloud storage classes that require restoration before retrieval cannot be accessed.

      An internal or external stage can include a directory table. Directory tables maintain a catalog of staged file directories in cloud storage.

      • Configure a specified path to control the write permissions for user SELECT INTO operations. After creation, users can only write to the set STAGE path.

      • If no STAGE is created or all STAGE instances are DISABLED, users can write to any path permitted by the operating system or object storage permissions.

      • If not using a STAGE, users must forcefully include credential information during SELECT INTO operations.

      Note

      1. Cluster administrators (i.e., root users) and tenant administrators can create data stages.
      2. Once created, data tables can only be imported to the paths specified in the STAGE.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-stage/#syntax","title":"Syntax","text":"
      > CREATE STAGE [ IF NOT EXISTS ] { stage_name }\n   { StageParams }\u0005\n   [ directoryTableParams ]\n   [ COMMENT = '<string_literal>' ]\n\nStageParams (for Amazon S3) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"filepath\"='<string>', \"region\"='<string>'}\n\nStageParams (for Aliyun OSS) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for File System) :\nURL= 'filepath'\n\ndirectoryTableParams :\nENABLE = { TRUE | FALSE }\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-stage/#explanations","title":"Explanations","text":"
      • IF NOT EXISTS: An optional parameter used to check whether a stage with the same name already exists when creating a stage, avoiding duplicate creations.

      • stage_name: The name of the stage to be created.

      • StageParams: This parameter group is used to specify the stage's configuration parameters.

        • endpoint: The connection URL for the stage, indicating the location of the object storage service. This URL's content may vary for object storage services like Amazon S3, Aliyun OSS, or a file system. For example s3.us-west-2.amazonaws.com

        • CREDENTIALS: This JSON object contains the credentials required to connect to the object storage service.

          • access_key_id: Access key ID used for authentication.
          • secret_access_key: Key associated with the access key ID for authentication.
          • \"filepath\"='<string>': Specifies the file path or directory in the S3 storage.
          • \"region\"='<string>': Specifies the AWS region where the Amazon S3 storage is located.
      • directoryTableParams: This parameter group is used to specify the configuration of a directory table associated with the stage.

        • ENABLE: Indicates whether the directory table is enabled, with values TRUE or FALSE values.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-create-stage/#examples","title":"Examples","text":"
      CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- Create internal data stage\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- Export data from the table to data stage\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- You can see your exported table in your local directory\n\n-- After setting the data stage, the data table can only be exported to the specified path, and an error will be reported when exporting to other paths\nmysql> SELECT * FROM user INTO OUTFILE '~/tmp/csv2/user.txt';\nERROR 20101 (HY000): internal error: stage exists, please try to check and use a stage instead\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/","title":"ALTER PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#description","title":"Description","text":"

      ALTER PUBLICATION can change the attributes of a publication.

      You must own the publication to use ALTER PUBLICATION. Adding a table to a publication additionally requires owning that table.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#syntax","title":"Syntax","text":"
      ALTER PUBLICATION pubname ACCOUNT \u0005\n    { ALL\n    | account_name, [, ... ]\n    | ADD account_name, [, ... ]\n    | DROP account_name, [, ... ]\u0005\n    [ COMMENT 'string']\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#explanations","title":"Explanations","text":"
      • pubname: The name of an existing publication whose definition is to be altered.
      • account_name: The user name of the owner of the publication.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#examples","title":"Examples","text":"
      create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\nmysql> alter publication pub3 account add accx;\nshow create publication pub3;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show create publication pub3;\n+-------------+-----------------------------------------------------------------------+\n| Publication | Create Publication                                                    |\n+-------------+-----------------------------------------------------------------------+\n| pub3        | CREATE PUBLICATION `pub3` DATABASE `t` ACCOUNT `acc0`, `acc1`, `accx` |\n+-------------+-----------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show publications;\n+------+----------+\n| Name | Database |\n+------+----------+\n| pub3 | t        |\n+------+----------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/","title":"ALTER STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#description","title":"Description","text":"

      ALTER STAGE is used to modify the attributes of an existing named internal or external stage.

      Note

      Cluster administrators (i.e., root users) and account administrators can modify the data stage.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#syntax","title":"Syntax","text":"
      > ALTER STAGE [ IF EXISTS ] { stage_name }\n   { StageParams }\n   [ directoryTableParams ]\n   [ COMMENT = '<string_literal>' ]\n\nStageParams (for Amazon S3) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for Aliyun OSS) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for File System) :\nURL= 'filepath'\n\ndirectoryTableParams :\nENABLE = { TRUE | FALSE }\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#explanations","title":"Explanations","text":"
      • IF NOT EXISTS: An optional parameter used to check whether a stage with the same name already exists when modifying a stage, avoiding duplicate creations.

      • stage_name: The name of the stage to be modified.

      • StageParams: This parameter group is used to specify the stage's configuration parameters.

        • endpoint: The connection URL for the stage, indicating the location of the object storage service. This URL's content may vary for object storage services like Amazon S3, Aliyun OSS, or a file system. For example s3.us-west-2.amazonaws.com

        • CREDENTIALS: This JSON object contains the credentials required to connect to the object storage service, such as access_key_id, secret_access_key, etc.

      • directoryTableParams: This parameter group is used to specify the configuration of a directory table associated with the stage.

        • ENABLE: Indicates whether the directory table is enabled, with values TRUE or FALSE values.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#examples","title":"Examples","text":"
      CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- Create internal data stage\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- Export data from the table to data stage\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- You can see your exported table in your local directory\n\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+---------+\n| STAGE_NAME | URL                         | STATUS  | COMMENT |\n+------------+-----------------------------+---------+---------+\n| stage1     | /Users/Prinz/03testrepo/csv | ENABLED |         |\n+------------+-----------------------------+---------+---------+\n1 row in set (0.01 sec)\n\n-- modify the stage1\nmysql> ALTER STAGE stage1 SET COMMENT 'user stage';\n\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+------------+\n| STAGE_NAME | URL                         | STATUS  | COMMENT    |\n+------------+-----------------------------+---------+------------+\n| stage1     | /Users/Prinz/03testrepo/csv | ENABLED | user stage |\n+------------+-----------------------------+---------+------------+\n1 row in set (0.00 sec)\n\n-- disable the data stage named 'stage1'\nmysql> ALTER STAGE stage1 SET ENABLE = FALSE;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- Try to export the data of the user table to the data stage named 'stage1:/user.csv', but stage1 has been disabled, so it is no longer available, and an error is reported\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\nERROR 20101 (HY000): internal error: stage 'stage1' is invalid, please check\n\n-- Re-enable with a data stage named 'stage1'\nmysql> ALTER STAGE stage1 SET ENABLE = TRUE;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- The export can be executed successfully again\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/","title":"ALTER TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#description","title":"Description","text":"

      ALTER TABLE is used to modify the existing data table structure.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#syntax","title":"Syntax","text":"
      ALTER TABLE tbl_name\n    [alter_option [, alter_option] ...]\n\nalter_option: {\n    table_options\n  | ADD [COLUMN] col_name column_definition\n        [FIRST | AFTER col_name]\n  | ADD [COLUMN] (col_name column_definition,...)\n  | ADD {[INDEX | KEY] [index_name]\n        [index_option] ...\n  | ADD [CONSTRAINT] UNIQUE [INDEX | KEY]\n        [index_name][index_option] ...\n  | ADD [CONSTRAINT] FOREIGN KEY\n        [index_name] (col_name,...)\n        reference_definition\n  | ADD [CONSTRAINT [symbol]] PRIMARY KEY\n        [index_type] (key_part,...)\n  | CHANGE [COLUMN] old_col_name new_col_name column_definition\n        [FIRST | AFTER col_name]\n  | ALTER INDEX index_name {VISIBLE | INVISIBLE}\n  | DROP [COLUMN] col_name\n  | DROP {INDEX | KEY} index_name\n  | DROP FOREIGN KEY fk_symbol\n  | DROP PRIMARY KEY\n  | RENAME [TO | AS] new_tbl_name\n  | MODIFY [COLUMN] col_name column_definition\n        [FIRST | AFTER col_name]\n  | RENAME COLUMN old_col_name TO new_col_name\n    }\n\nkey_part: {col_name [(length)] | (expr)} [ASC | DESC]\nindex_option: {\n  COMMENT[=]'string'\n}\ntable_options:\n    table_option [[,] table_option] ...\ntable_option: {\n  COMMENT [=] 'string'\n}\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#explanations","title":"Explanations","text":"

      The explanations of each parameter are as the following:

      1. ALTER TABLE tbl_name: Indicates modifying a table named tbl_name.
      2. alter_option: Indicates that one or more change options can be executed, separated by commas.

        • table_options: Used to set or modify table options, such as table comments (COMMENT).
        • ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name]: Adds a new column to the table, specifying the position of the new column (before or after a particular column).
        • ADD [COLUMN] (col_name column_definition, ...): Adds multiple new columns simultaneously.
        • ADD {[INDEX | KEY] [index_name] [index_option] ...: Adds an index, specifying the index name and index options (such as comments).
        • ADD [CONSTRAINT] UNIQUE [INDEX | KEY] [index_name][index_option] ...: Adds a UNIQUE constraint or UNIQUE index.
        • ADD [CONSTRAINT] FOREIGN KEY [index_name] (col_name, ...) reference_definition: Adds a FOREIGN KEY constraint.
        • ADD [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (key_part,...): Add a primary key constraint.
        • CHANGE [COLUMN] old_col_name new_col_name column_definition [FIRST | AFTER col_name]: Modify the column definition, column name and order.
        • ALTER INDEX index_name {VISIBLE | INVISIBLE}: Changes the visibility of an index.
        • DROP [COLUMN] col_name: Drops a column.
        • DROP {INDEX | KEY} index_name: Drops an index.
        • DROP FOREIGN KEY fk_symbol: Drops a FOREIGN KEY constraint.
        • DROP PRIMARY KEY: Delete the primary key.
        • RENAME [TO | AS] new_tbl_name: Renames the table.
        • MODIFY [COLUMN] col_name column_definition [FIRST | AFTER col_name]: Modify column definition and order.
        • RENAME COLUMN old_col_name TO new_col_name: Rename a column.
      3. key_part: Represents the components of an index, which can be column names (when creating an index on a text column, you might specify a length for the index to only consider a certain number of characters in that column. If you create an index using a column name without specifying a length, the index will use the entire column value as an index component. In some cases, this may result in reduced performance, especially when dealing with large text or binary data columns. Specifying a length is usually unnecessary for smaller data types, such as integers or dates.).

      4. index_option: Represents index options, such as comments (COMMENT).
      5. table_options: Represents table options, such as table comments (COMMENT).
      6. table_option: Specific table options, such as comments (COMMENT).
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#examples","title":"Examples","text":"
      • Example 1:
      -- Create table f1 with two integer columns: fa (primary key) and fb (unique key)\nCREATE TABLE f1(fa INT PRIMARY KEY, fb INT UNIQUE KEY);\n-- Create table c1 with two integer columns: ca and cb\nCREATE TABLE c1 (ca INT, cb INT);\n-- Add a foreign key constraint named ffa to table c1, associating column ca of table c1 with column fa of table f1\nALTER TABLE c1 ADD CONSTRAINT ffa FOREIGN KEY (ca) REFERENCES f1(fa);\n-- Insert a record into table f1: (2, 2)\nINSERT INTO f1 VALUES (2, 2);\n-- Insert a record into table c1: (1, 1)\nINSERT INTO c1 VALUES (1, 1);\n-- Insert a record into table c1: (2, 2)\nINSERT INTO c1 VALUES (2, 2);\n-- Select all records from table c1 and order by column ca\nmysql> select ca, cb from c1 order by ca;\n+------+------+\n| ca   | cb   |\n+------+------+\n|    2 |    2 |\n+------+------+\n1 row in set (0.01 sec)\n-- Drop the foreign key constraint named ffa from table c1\nALTER TABLE c1 DROP FOREIGN KEY ffa;\n-- Insert a record into table c1: (1, 1)\nINSERT INTO c1 VALUES (1, 1);\n-- Select all records from table c1 and order by column ca\nmysql> select ca, cb from c1 order by ca;\n+------+------+\n| ca   | cb   |\n+------+------+\n|    1 |    1 |\n|    2 |    2 |\n+------+------+\n2 rows in set (0.01 sec)\n
      • Example 2:
      -- Create a new table 't1' with columns a, b, c, and d. Column 'a' is of type INTEGER, 'b' is of type CHAR(10), 'c' is of type DATE, and 'd' is of type DECIMAL(7,2). A unique key is added on columns 'a' and 'b'.\nCREATE TABLE t1(a INTEGER, b CHAR(10), c DATE, d DECIMAL(7,2), UNIQUE KEY(a, b));\n\n-- Describe the structure of the 't1' table.\nmysql> desc t1;\n+-------+--------------+------+------+---------+-------+---------+\n| Field | Type         | Null | Key  | Default | Extra | Comment |\n+-------+--------------+------+------+---------+-------+---------+\n| a     | INT(32)      | YES  |      | NULL    |       |         |\n| b     | CHAR(10)     | YES  |      | NULL    |       |         |\n| c     | DATE(0)      | YES  |      | NULL    |       |         |\n| d     | DECIMAL64(7) | YES  |      | NULL    |       |         |\n+-------+--------------+------+------+---------+-------+---------+\n4 rows in set (0.01 sec)\n\n-- Insert three rows into the 't1' table.\nINSERT INTO t1 VALUES(1, 'ab', '1980-12-17', 800);\nINSERT INTO t1 VALUES(2, 'ac', '1981-02-20', 1600);\nINSERT INTO t1 VALUES(3, 'ad', '1981-02-22', 500);\n\n-- Display all the rows from the 't1' table.\nmysql> select * from t1;\n+------+------+------------+---------+\n| a    | b    | c          | d       |\n+------+------+------------+---------+\n|    1 | ab   | 1980-12-17 |  800.00 |\n|    2 | ac   | 1981-02-20 | 1600.00 |\n|    3 | ad   | 1981-02-22 |  500.00 |\n+------+------+------------+---------+\n3 rows in set (0.01 sec)\n\n-- Alter the 't1' table to add a primary key 'pk1' on columns 'a' and 'b'.\nmysql> alter table t1 add primary key pk1(a, b);\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Describe the modified structure of the 't1' table after adding the primary key.\nmysql> desc t1;\n+-------+--------------+------+------+---------+-------+---------+\n| Field | Type         | Null | Key  | Default | Extra | Comment |\n+-------+--------------+------+------+---------+-------+---------+\n| a     | INT(32)      | NO   | PRI  | null    |       |         |\n| b     | CHAR(10)     | NO   | PRI  | null    |       |         |\n| c     | DATE(0)      | YES  |      | null    |       |         |\n| d     | DECIMAL64(7) | YES  |      | null    |       |         |\n+-------+--------------+------+------+---------+-------+---------+\n4 rows in set (0.01 sec)\n\n-- Display all the rows from the 't1' table after adding the primary key.\nmysql> select * from t1;\n+------+------+------------+---------+\n| a    | b    | c          | d       |\n+------+------+------------+---------+\n|    1 | ab   | 1980-12-17 |  800.00 |\n|    2 | ac   | 1981-02-20 | 1600.00 |\n|    3 | ad   | 1981-02-22 |  500.00 |\n+------+------+------------+---------+\n3 rows in set (0.00 sec)\n
      • Example 3:
      CREATE TABLE t1 (a INTEGER PRIMARY KEY, b CHAR(10));\nmysql> desc t1;\n+-------+----------+------+------+---------+-------+---------+\n| Field | Type     | Null | Key  | Default | Extra | Comment |\n+-------+----------+------+------+---------+-------+---------+\n| a     | INT(32)  | NO   | PRI  | NULL    |       |         |\n| b     | CHAR(10) | YES  |      | NULL    |       |         |\n+-------+----------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\ninsert into t1 values(1, 'ab');\ninsert into t1 values(2, 'ac');\ninsert into t1 values(3, 'ad');\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 | ab   |\n|    2 | ac   |\n|    3 | ad   |\n+------+------+\n3 rows in set (0.01 sec)\n\n-- Modify table 't1', change column 'a' name to 'x', and change datatype to VARCHAR(20).\nmysql> alter table t1 change a x VARCHAR(20);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> desc t1;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type        | Null | Key  | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| x     | VARCHAR(20) | NO   | PRI  | null    |       |         |\n| b     | CHAR(10)    | YES  |      | null    |       |         |\n+-------+-------------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t1;\n+------+------+\n| x    | b    |\n+------+------+\n| 1    | ab   |\n| 2    | ac   |\n| 3    | ad   |\n+------+------+\n3 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#constraints","title":"Constraints","text":"
      1. The clauses: CHANGE [COLUMN], MODIFY [COLUMN], RENAME COLUMN, ADD [CONSTRAINT [symbol]] PRIMARY KEY, DROP PRIMARY KEY, and ALTER COLUMN ORDER BY can be freely combined in ALTER TABLE, these are not supported to be used with other clauses for the time being.
      2. Temporary tables currently do not support using ALTER TABLE to modify the table structure.
      3. Tables created using CREATE TABLE ... CLUSTER BY... do not allow modifications to the table structure using ALTER TABLE.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/","title":"ALTER VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#description","title":"Description","text":"

      ALTER VIEW is used to alter an existing view.

      If any of the views named in the syntax parameter list do not exist, the statement reports an error and cannot change those views that do not exist.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#syntax","title":"Syntax","text":"
      > ALTER VIEW view_name [(column_list)]\n  AS select_statement\n  [WITH [CASCADED | LOCAL] CHECK OPTION]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values(1),(2),(3),(4);\ncreate view v5 as select * from t1;\n\nmysql> select * from v5;\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n4 rows in set (0.01 sec)\n\nalter view v5 as select * from t1 where a=1;\n\nmysql> select * from v5;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.01 sec)\n\nalter view v5 as select * from t1 where a > 2;\n\nmysql> select * from v5;\n+------+\n| a    |\n+------+\n|    3 |\n|    4 |\n+------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/","title":"CREATE DATABASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#description","title":"Description","text":"

      Create a database.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#syntax","title":"Syntax","text":"
      > CREATE DATABASE [IF NOT EXISTS] <database_name> [create_option] ...\n\n> create_option: [DEFAULT] {\n    CHARACTER SET [=] charset_name\n  | COLLATE [=] collation_name\n  | ENCRYPTION [=] {'Y' | 'N'}\n}\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#examples","title":"Examples","text":"
      CREATE DATABASE IF NOT EXISTS test01;\n

      Expected Result

      You can use SHOW DATABASES to check if the databases have been created.

      mysql> show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| mo_task            |\n| information_schema |\n| mysql              |\n| system_metrics     |\n| system             |\n| test01             |\n| mo_catalog         |\n+--------------------+\n10 rows in set (0.01 sec)\n

      You can see that the new database test01 has been created in addition to the six system databases.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#constraints","title":"Constraints","text":"
      • Only UTF-8 CHARACTER SET is supported for now.
      • CHARACTER SET, COLLATE, ENCRYPTION can be used but don't work.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/","title":"CREATE EXTERNAL TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#description","title":"Description","text":"

      External table access data in external sources as if it were in a table in the database.

      You can connect to the database and create metadata for the external table using DDL.

      The DDL for an external table consists of two parts: one part that describes the MatrixOne column types, and another part (the access parameters) that describes the mapping of the external data to the MatrixOne data columns.

      This document describe how to create a new tables outside of the MatrixOne databases.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#common-syntax","title":"Common syntax","text":"
      > CREATE EXTERNAL TABLE [IF NOT EXISTS] [db.]table_name;\n(\n    name1 type1,\n    name2 type2,\n    ...\n)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#syntax_1","title":"Syntax","text":"
      ## Create a external table for a local file (specify the compression format)\ncreate external table t(...) localfile{\"filepath\"='<string>', \"compression\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n## Create a external table for a local file (if no compression format is specified, the format is auto, and the file format is automatically checked)\ncreate external table t(...) localfile{\"filepath\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n\n## Create a external table for an S3 file (specify the compression format)\ncreate external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n## Create a external table for an S3 file (if no compression format is specified, the format is auto, and the file format is automatically checked)\ncreate external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#parameter-description","title":"Parameter Description","text":"Parameter Description endpoint A endpoint is a URL that can conncect to AWS Web service. For example: s3.us-west-2.amazonaws.com access_key_id S3 Access key ID secret_access_key S3 Secret access key bucket S3 Bucket to access filepath relative file path region AWS S3 Area compression Compressed format of S3 files. If empty, it indicates uncompressed files. Supported fields or Compressed format are \"auto\", \"none\", \"gzip\", \"bzip2\", \"flate\", \"zlib\", and \"lz4\". auto Compressed format: indicates that the file name extension automatically checks the compressed format of a file none Compressed format: indicates the uncompressed format, and the rest indicates the compressed format of the file"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#example","title":"Example","text":"
      create external table ex_table_cpk(clo1 tinyint,clo2 smallint,clo3 int,clo4 bigint,clo5 tinyint unsigned,clo6 smallint unsigned,clo7 int unsigned,clo8 bigint unsigned,col9 float,col10 double,col11 varchar(255),col12 Date,col13 DateTime,col14 timestamp,col15 bool,col16 decimal(5,2),col17 text,col18 varchar(255),col19 varchar(255),col20 varchar(255))infile{\"filepath\"='$resources/external_table_file/cpk_table_1.csv'};\n

      For more information on creating an external table with an s3option mapping to an S3 file, see Import the data from S3 Compatible object storage.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#constraints","title":"Constraints","text":"

      MatrixOne only supports select on EXTERNAL TABLE, delete, insert, and update is not supported.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/","title":"CREATE INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#description","title":"Description","text":"

      Create indexes on tables to query data more quickly and efficiently.

      You can't see the index; the index can only be used to speed up the search/query.

      Updating a table with an index takes longer than updating a table without an index because the index also needs to be updated. Therefore, the ideal approach is to create indexes only on frequently searched columns (and tables).

      There are two common types of indexes, namely:

      • Primary Key: The primary key index, that is, the index identified on the primary key column.
      • Secondary Index: the secondary index, that is, the index identified on the non-primary key.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#syntax","title":"Syntax","text":"
      > CREATE [UNIQUE] INDEX index_name\nON tbl_name (key_part,...)\nCOMMENT 'string'\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#create-unique-index","title":"CREATE UNIQUE INDEX","text":"

      Creates a unique index on a table. Duplicate values are not allowed.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(id int PRIMARY KEY,name VARCHAR(255),age int);\ninsert into t1 values(1,\"Abby\", 24);\ninsert into t1 values(2,\"Bob\", 25);\ninsert into t1 values(3,\"Carol\", 23);\ninsert into t1 values(4,\"Dora\", 29);\ncreate unique index idx on t1(name);\nmysql> select * from t1;\n+------+-------+------+\n| id   | name  | age  |\n+------+-------+------+\n|    1 | Abby  |   24 |\n|    2 | Bob   |   25 |\n|    3 | Carol |   23 |\n|    4 | Dora  |   29 |\n+------+-------+------+\n4 rows in set (0.00 sec)\n\nmysql> show create table t1;\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                     |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1    | CREATE TABLE `t1` (\n`id` INT NOT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`age` INT DEFAULT NULL,\nPRIMARY KEY (`id`),\nUNIQUE KEY `idx` (`name`)\n) |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n\ncreate table t2 (\ncol1 bigint primary key,\ncol2 varchar(25),\ncol3 float,\ncol4 varchar(50)\n);\ncreate unique index idx on t2(col2) comment 'create varchar index';\ninsert into t2 values(1,\"Abby\", 24,'zbcvdf');\ninsert into t2 values(2,\"Bob\", 25,'zbcvdf');\ninsert into t2 values(3,\"Carol\", 23,'zbcvdf');\ninsert into t2 values(4,\"Dora\", 29,'zbcvdf');\nmysql> select * from t2;\n+------+-------+------+--------+\n| col1 | col2  | col3 | col4   |\n+------+-------+------+--------+\n|    1 | Abby  |   24 | zbcvdf |\n|    2 | Bob   |   25 | zbcvdf |\n|    3 | Carol |   23 | zbcvdf |\n|    4 | Dora  |   29 | zbcvdf |\n+------+-------+------+--------+\n4 rows in set (0.00 sec)\nmysql> show create table t2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                                                                              |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t2    | CREATE TABLE `t2` (\n`col1` BIGINT NOT NULL,\n`col2` VARCHAR(25) DEFAULT NULL,\n`col3` FLOAT DEFAULT NULL,\n`col4` VARCHAR(50) DEFAULT NULL,\nPRIMARY KEY (`col1`),\nUNIQUE KEY `idx` (`col2`) COMMENT `create varchar index`\n) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/","title":"CREATE PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#description","title":"Description","text":"

      CREATE PUBLICATION adds a new publication into the current database.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#syntax","title":"Syntax","text":"
      CREATE PUBLICATION pubname\n    DATABASE database_name ACCOUNT\n    [ { ALL\n    | account_name, [, ... ] }]\n    [ COMMENT 'string']\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#explanations","title":"Explanations","text":"
      • pubname: The publication name. The publication name must be distinct from the name of any existing publication in the current database.
      • database_name: specifies the database name that exists under the current account.
      • account_name: The account name. The name of the account which obtains the publication.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#examples","title":"Examples","text":"
      create database t;\ncreate account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\nmysql> create publication pub1 database t account acc0,acc1;\nQuery OK, 0 rows affected (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#constraints","title":"Constraints","text":"

      MatrxiOne currently only supports publishing one database at a time.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/","title":"CREATE SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#description","title":"Description","text":"

      The CREATE SEQUENCE user creates a sequence object. A sequence is a unique database object that can automatically generate a unique sequence of numbers. Typically, sequences are used to automatically generate unique values for a table's primary key fields.

      CREATE SEQUENCE is a command that creates an auto-increment number sequence to generate unique, continuous numeric values, usually used to create values for primary key columns or other columns requiring auto-increment numbers.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#syntax","title":"Syntax","text":"
      > CREATE SEQUENCE [ IF NOT EXISTS ] SEQUENCE_NAME\n    [ AS data_type ]\n    [ INCREMENT [ BY ] increment ]\n    [ MINVALUE minvalue] [ MAXVALUE maxvalue]\n    [ START [ WITH ] start ] [ [ NO ] CYCLE ]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#data_type","title":"data_type","text":"

      The optional clause AS data_type specifies the data type of the sequence. Supported data types include smallint [unsigned], integer [unsigned], and bigint [unsigned], with bigint being the default. The data type determines the default minimum and maximum values for the sequence.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#increment","title":"INCREMENT","text":"

      The optional clause INCREMENT [BY] increment specifies the value to add to the current sequence value to create a new value. Positive values generate ascending sequences, and negative values generate descending sequences; the default value is 1.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#minvalue","title":"MINVALUE","text":"

      The optional clause MINVALUE minvalue determines the minimum value that the sequence can generate. If this clause is not provided or MINVALUE is not specified, a default value will be used. The default value for an ascending sequence is 1, and for a descending sequence it is the minimum value for the data type.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#maxvalue","title":"MAXVALUE","text":"

      The optional clause MAXVALUE maxvalue determines the maximum value for the sequence. If this clause is not provided or MAXVALUE is not specified, a default value will be used. The default value for an ascending sequence is the maximum value for the data type, and for a descending sequence it is -1.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#start","title":"START","text":"

      The optional clause START [WITH] start allows the sequence to start from any point. The default starting value is the minimum value for an ascending sequence and the maximum value for a descending sequence.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#cycle","title":"CYCLE","text":"

      The CYCLE option allows the sequence to wrap around when it reaches the maximum or minimum value for an ascending or descending sequence, respectively. If the limit is reached, the next generated number will be the minimum or maximum value, respectively.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#operations","title":"Operations","text":"

      The following functions are used to manipulate sequence values:

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#nextvalsequence_name","title":"NEXTVAL(sequence_name)","text":"

      Sets the current value to the next value in the sequence and returns it.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#currvalsequence_name","title":"CURRVAL(sequence_name)","text":"

      Returns the current value in the sequence.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#setvalsequence_name-n-b","title":"SETVAL(sequence_name, n [,b])","text":"

      Sets the current value in the sequence to n.

      • If b is set to true, the next call to NEXTVAL will return n.
      • If b is set to false, the next call to NEXTVAL will return n+increment.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#lastval","title":"LASTVAL()","text":"

      Return the value of any sequence obtained by NEXTVAL in the current session; if the current value is set by SETVAL first, and then use LASTVAL to operate on the sequence, return SETVAL The current value of the setting. Since 'LASTVAL()' returns a 'NEXTVAL' value, 'LASTVAL()' can only be initialized by 'NEXTVAL'.

      LASTVAL() is affected by SETVAL(sequence_name, n [,true]) to change the current value, as shown in the following example:

      Suppose a sequence named seq_id was created with a starting value of 1, an increment of 1, and a maximum value of 1000:

      CREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\n

      Then, the NEXTVAL() function can be used to get the next sequence value and automatically increment the sequence counter:

      SELECT NEXTVAL('seq_id');\n

      Next, the LASTVAL() function can be used to return the current value of the sequence:

      SELECT LASTVAL();\n

      Alternatively, the SETVAL() function can be used to set the current value to 30, with the optional [,b] parameter set to true:

      SELECT SETVAL('seq_id', 30);\n

      Afterward, the NEXTVAL() function can be used again to get the next sequence value:

      SELECT NEXTVAL('seq_id');\n

      This will return 31 because the current value has been set to 30, and the NEXTVAL() function will return the next sequence value 31.

      SELECT LASTVAL();\n

      Using LASTVAL() will return the value of the sequence that was retrieved with NEXTVAL() in the current session, which is 31 in this case.

      The above example shows that if the current value is set using SETVAL(sequence_name, n [,true]) and then the next sequence value is retrieved using NEXTVAL, calling LASTVAL() again will return the value of the sequence retrieved with NEXTVAL().

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#using-sequence-in-a-table","title":"Using SEQUENCE in a table","text":"

      To use a sequence in a table, the following steps need to be completed:

      1. Create a sequence object: A sequence named \"my_sequence\" can be created using the following SQL command:

        CREATE SEQUENCE my_sequence;\n

        This will create a simple sequence object that will start at 1 and increment by 1.

      2. Apply a sequence to a field in a table: To apply a sequence to a field in a table, you need to specify a default value for the next value in the sequence in the table definition, as follows:

        CREATE TABLE my_table (\nid INTEGER DEFAULT nextval('my_sequence'),\nname VARCHAR(50));\n

        In the example above, the \"id\" field will automatically get the following unique value from the sequence as its default value.

      3. Insert data: After the table and sequence have been defined, you can use the INSERT statement to insert data into the table. When inserting a row of data, if no value is specified for the \"id\" field, MatrixOne will automatically get the following unique value from the sequence as its default value.

        For example, the following statement will insert a row into the \"my_table\" table and automatically assign a unique value to the \"id\" field:

        INSERT INTO my_table (name) VALUES ('John');\nINSERT INTO my_table (name) VALUES ('Tom');\n
      4. Using sequences makes it easy to automatically assign unique identifiers in the form, thus avoiding the possible errors of manually assigning identifiers. Use the following statement for query verification:

        mysql> select * from my_table;\n+------+------+\n| id   | name |\n+------+------+\n|    1 | John |\n|    2 | Tom  |\n+------+------+\n2 rows in set (0.01 sec)\n

      Note

      When using SEQUENCE in a table, the auto_increment and sequence cannot be used together; otherwise, an error will be reported.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#examples","title":"Examples","text":"
      -- Create a sequence named \"seq_id\" that starts from 1, increments by 1, and has a maximum value of 1000:\nCREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\n-- After creating the sequence, the NEXTVAL function can be used to retrieve the next sequence value as shown below:\nmysql> SELECT NEXTVAL('seq_id');\n+-----------------+\n| nextval(seq_id) |\n+-----------------+\n| 1               |\n+-----------------+\n1 row in set (0.02 sec)\n-- This command will return the next value in the sequence (e.g., 1) and automatically increment the counter of the sequence.\n\n-- The CURRVAL function returns the current value.\nmysql> SELECT CURRVAL('seq_id');\n+-----------------+\n| currval(seq_id) |\n+-----------------+\n| 1               |\n+-----------------+\n1 row in set (0.01 sec)\n\n-- Returns the most recent value retrieved by NEXTVAL in the current session for any sequence.\nmysql> SELECT LASTVAL();\n+-----------+\n| lastval() |\n+-----------+\n| 1         |\n+-----------+\n1 row in set (0.00 sec)\n\n-- Set the current value to 30.\nmysql> SELECT SETVAL('seq_id', 30);\n+--------------------+\n| setval(seq_id, 30) |\n+--------------------+\n| 30                 |\n+--------------------+\n1 row in set (0.02 sec)\n\n-- The NEXTVAL function retrieves the next sequence value.\nmysql> SELECT NEXTVAL('seq_id');\n+-----------------+\n| nextval(seq_id) |\n+-----------------+\n| 31              |\n+-----------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/","title":"CREATE STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#description","title":"Description","text":"

      The CREATE STAGE command is used in the MatrixOne database to create a named internal or external data stage for data export. By creating a data stage and exporting data to it, you can download data files to your local system or store them in cloud storage services.

      • Internal Stage: Internal stages store data files within the MatrixOne system. Internal stages can be either permanent or temporary.

      • External Stage: External stages reference data files stored outside the MatrixOne environment. Currently, the following cloud storage services are supported:

        • Amazon S3 buckets
        • Aliyun buckets

      The storage location can be private/protected or public\u2014however, data held in archival cloud storage classes that require restoration before retrieval cannot be accessed.

      An internal or external stage can include a directory table. Directory tables maintain a catalog of staged file directories in cloud storage.

      • Configure a specified path to control the write permissions for user SELECT INTO operations. After creation, users can only write to the set STAGE path.

      • If no STAGE is created or all STAGE instances are DISABLED, users can write to any path permitted by the operating system or object storage permissions.

      • If not using a STAGE, users must forcefully include credential information during SELECT INTO operations.

      Note

      1. Cluster administrators (i.e., root users) and tenant administrators can create data stages.
      2. Once created, data tables can only be imported to the paths specified in the STAGE.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#syntax","title":"Syntax","text":"
      > CREATE STAGE [ IF NOT EXISTS ] { stage_name }\n   { StageParams }\u0005\n   [ directoryTableParams ]\n   [ COMMENT = '<string_literal>' ]\n\nStageParams (for Amazon S3) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for Aliyun OSS) :\nURL =  \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for File System) :\nURL= 'filepath'\n\ndirectoryTableParams :\nENABLE = { TRUE | FALSE }\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#explanations","title":"Explanations","text":"
      • IF NOT EXISTS: An optional parameter used to check whether a stage with the same name already exists when creating a stage, avoiding duplicate creations.

      • stage_name: The name of the stage to be created.

      • StageParams: This parameter group is used to specify the stage's configuration parameters.

        • endpoint: The connection URL for the stage, indicating the location of the object storage service. This URL's content may vary for object storage services like Amazon S3, Aliyun OSS, or a file system. For example s3.us-west-2.amazonaws.com

        • CREDENTIALS: This JSON object contains the credentials required to connect to the object storage service, such as access_key_id, secret_access_key, etc.

      • directoryTableParams: This parameter group is used to specify the configuration of a directory table associated with the stage.

        • ENABLE: Indicates whether the directory table is enabled, with values TRUE or FALSE values.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#examples","title":"Examples","text":"
      CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- Create internal data stage\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- Export data from the table to data stage\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- You can see your exported table in your local directory\n\n-- After setting the data stage, the data table can only be exported to the specified path, and an error will be reported when exporting to other paths\nmysql> SELECT * FROM user INTO OUTFILE '~/tmp/csv2/user.txt';\nERROR 20101 (HY000): internal error: stage exists, please try to check and use a stage instead\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/","title":"CREATE...FROM...PUBLICATION...","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#description","title":"Description","text":"

      CREATE...FROM...PUBLICATION... is when the subscriber subscribes to a publication created by the publisher to obtain the publisher's shared data.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#syntax","title":"Syntax","text":"
      CREATE DATABASE database_name\nFROM account_name\nPUBLICATION pubname;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#explanations","title":"Explanations","text":"
      • database_name: The name of the database created by the subscriber.
      • pubname: The name of the publication that the publisher has published.
      • account_name: The account name of the publication can be obtained.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#examples","title":"Examples","text":"
      --Suppose the system administrator creates a account acc1 as the subscriber\ncreate account acc1 admin_name 'root' identified by '111';\n\n--Assuming session 1 is the publisher, the publisher first publishes a database to the account\ncreate database sys_db_1;\nuse sys_db_1;\ncreate table sys_tbl_1(a int primary key );\ninsert into sys_tbl_1 values(1),(2),(3);\ncreate view v1 as (select * from sys_tbl_1);\ncreate publication sys_pub_1 database sys_db_1;\nmysql> show publications;\n+-----------+----------+\n| Name      | Database |\n+-----------+----------+\n| sys_pub_1 | sys_db_1 |\n+-----------+----------+\n1 row in set (0.01 sec)\n\n--Open a new session again, assuming that session 2 is the subscriber and the subscriber subscribes to the published database\nmysql -h 127.0.0.1 -P 6001 -u acc1:root -p  -- Log into the account\ncreate database sub1 from sys publication pub1;\n\nmysql> create database sub1 from sys publication sys_pub_1;\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| system             |\n| system_metrics     |\n| information_schema |\n| mysql              |\n| mo_catalog         |\n| sub1               |\n+--------------------+\n6 rows in set (0.00 sec)\n\nmysql> show subscriptions;\n+------+--------------+\n| Name | From_Account |\n+------+--------------+\n| sub1 | sys          |\n+------+--------------+\n1 row in set (0.01 sec)\n\nmysql> use sub1;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nmysql> show tables;\n+----------------+\n| Tables_in_sub1 |\n+----------------+\n| sys_tbl_1      |\n| v1             |\n+----------------+\n2 rows in set (0.01 sec)\n\nmysql> desc sys_tbl_1;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type    | Null | Key  | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a     | INT(32) | NO   | PRI  | NULL    |       |         |\n+-------+---------+------+------+---------+-------+---------+\n1 row in set (0.01 sec)\n\nmysql> select * from sys_tbl_1 order by a;\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.01 sec)\n-- Subscribe successfully\n

      Note

      If you need to unsubscribe, you can directly delete the subscribed database. Refer to 'DROP DATABASE`.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/","title":"CREATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#description","title":"Description","text":"

      Create a new table.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#syntax","title":"Syntax","text":"
      > CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n    (create_definition,...)\n    [table_options]\n    [partition_options]\n\ncreate_definition: {\n    col_name column_definition\n  | [CONSTRAINT [symbol]] PRIMARY KEY\n      [index_type] (key_part,...)\n      [index_option] ...\n  | [CONSTRAINT [symbol]] FOREIGN KEY\n      [index_name] (col_name,...)\n      reference_definition\n}\n\ncolumn_definition: {\n    data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]\n      [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]\n      [COMMENT 'string']\n      [reference_definition]\n  | data_type\n      [[PRIMARY] KEY]\n      [COMMENT 'string']\n      [reference_definition]\n}\n\nreference_definition:\n    REFERENCES tbl_name (key_part,...)\n      [ON DELETE reference_option]\n      [ON UPDATE reference_option]\n\nreference_option:\n    RESTRICT | CASCADE | SET NULL | NO ACTION\u0005\n\ntable_options:\n    table_option [[,] table_option] ...\n\ntable_option: {\n  | AUTO_INCREMENT [=] value\n  | COMMENT [=] 'string'\n  | START TRANSACTION\u0005\n}\n\npartition_options:\n    PARTITION BY\n        { [LINEAR] HASH(expr)\n        | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)}\n    [PARTITIONS num]\n    [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n     [VALUES\n         {LESS THAN {(expr | value_list) | MAXVALUE}\n         |\n         IN (value_list)}]\n     [COMMENT [=] 'string' ]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#explanations","title":"Explanations","text":"

      Various parameters and options that can be used when creating a table, including table creation, column definition, constraints, options, and partitioning, are explained below:

      • CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name: This is the primary table syntax. The TEMPORARY keyword indicates creating a temporary table, IF NOT EXISTS ensures creation only if the table doesn't exist, and tbl_name is the name of the table to be created.

      • (create_definition,...): This is the section for column definitions, used to define the table's columns and their attributes.

      • [table_options]: This is for table-level options where you can set parameters like storage engine, character set, etc.

      • [partition_options]: This is used for partitioned tables and defining partitioning methods and keys.

      The create_definition section is used to define attributes for each column, and it can contain the following:

      • col_name column_definition: This defines the column name and its attributes, including data type, whether it can be null, default value, etc.

      • [CONSTRAINT [symbol]] PRIMARY KEY: This defines a primary key constraint and can set a constraint name and the columns that make up the primary key.

      • [CONSTRAINT [symbol]] FOREIGN KEY: This defines a foreign key constraint and can set a constraint name, columns for the foreign key, and the referenced table.

      The column_definition section is used to define attributes for specific columns and can include the following:

      • data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]: This defines the data type of the column, whether it can be null, and its default value.

      • [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]: This sets options like auto-increment, uniqueness, and primary key constraint.

      • [COMMENT 'string']: This sets a comment for the column.

      • [reference_definition]: This is an optional reference definition used to define foreign key constraints.

      The reference_definition section is used to define references for foreign keys and includes the following:

      • REFERENCES tbl_name (key_part,...): This specifies the referenced table and columns for the foreign key.

      • [ON DELETE reference_option]: This sets the action to be taken when a referenced row is deleted.

      • [ON UPDATE reference_option]: This sets the action to be taken when a referenced row is updated.

      reference_option represents the options for foreign key actions, including RESTRICT, CASCADE, SET NULL, and NO ACTION.

      The table_options section sets table-level options, including initial auto-increment value, table comments, etc.

      The partition_options section defines options for partitioned tables, including partitioning methods, partition keys, and the number of partitions.

      For more detailed syntax explanations, see the following content.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#temporary-tables","title":"Temporary Tables","text":"

      You can use the TEMPORARY keyword when creating a table. A TEMPORARY table is visible only within the current session, and is dropped automatically when the session is closed. This means that two different sessions can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name. (The existing table is hidden until the temporary table is dropped.)

      Dropping a database does automatically drop any TEMPORARY tables created within that database.

      The creating session can perform any operation on the table, such as DROP TABLE, INSERT, UPDATE, or SELECT.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#comment","title":"COMMENT","text":"

      A comment for a column or a table can be specified with the COMMENT option.

      • Up to 1024 characters long. The comment is displayed by the SHOW CREATE TABLE and SHOW FULL COLUMNS statements. It is also shown in the COLUMN_COMMENT column of the INFORMATION_SCHEMA.COLUMNS table.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#auto_increment","title":"AUTO_INCREMENT","text":"

      The initial AUTO_INCREMENT value for the table.

      An integer column can have the additional attribute AUTO_INCREMENT. When you insert a value of NULL (recommended) or 0 into an indexed AUTO_INCREMENT column, the column is set to the next sequence value. Typically this is value+1, where the value is the largest value for the column currently in the table. AUTO_INCREMENT sequences begin with 1 default.

      There can be only one AUTO_INCREMENT column per table, which must be indexed and cannot have a DEFAULT value. An AUTO_INCREMENT column works properly only if it contains only positive values. Inserting a negative number is regarded as inserting a very large positive number. This is done to avoid precision problems when numbers \"wrap\" over from positive to negative and also to ensure that you do not accidentally get an AUTO_INCREMENT column that contains 0.

      You can use the AUTO_INCREMENT attribute to define the starting value of an auto-increment column. If you want to set the starting value of the auto-increment column to 10, you can use the AUTO_INCREMENT keyword when creating the table and specify the starting value later.

      For example, to create a table and define an auto-increment column with a starting value of 10, you can use the following SQL statement:

      -- set up\ncreate table t1(a int auto_increment primary key) auto_increment = 10;\n

      In this example, the id column is an auto-incrementing column with a starting value 10. When a new record is inserted into the table, the value of the id column will start from 10 and increment by 1 each time. If the starting value of AUTO_INCREMENT is not specified, the default starting value is 1, which is automatically incremented by 1 each time.

      Note

      1. MatrixOne currently only supports the default increment step size of 1; regardless of the initial value of the auto-increment column, each auto-increment is 1. Temporarily does not support setting the incremental step size.
      2. MatrixOne only syntax supports using the system variable set @@auto_increment_offset=n to set the initial value of the auto-increment column, but it does not take effect.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#primary-key","title":"PRIMARY KEY","text":"

      The PRIMARY KEY constraint uniquely identifies each record in a table.

      Primary keys must contain UNIQUE values, and cannot contain NULL values.

      A table can have only ONE primary key; and in the table, this primary key can consist of single column (field).

      • SQL PRIMARY KEY on CREATE TABLE

      The following SQL creates a PRIMARY KEY on the \"ID\" column when the \"Persons\" table is created:

      > CREATE TABLE Persons (\n    ID int NOT NULL,\n    LastName varchar(255) NOT NULL,\n    FirstName varchar(255),\n    Age int,\n    PRIMARY KEY (ID)\n);\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#foreign-key","title":"FOREIGN KEY","text":"

      The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables.

      A FOREIGN KEY is a field (or collection of fields) in one table, that refers to the PRIMARY KEY in another table.

      The table with the foreign key is called the child table, and the table with the primary key is called the referenced or parent table.

      The FOREIGN KEY constraint prevents invalid data from being inserted into the foreign key column, because it has to be one of the values contained in the parent table.

      When defining FOREIGN KEY, the following rules need to be followed:

      • The parent table must already exist in the database or be a table currently being created. In the latter case, the parent table and the slave table are the same table, such a table is called a self-referential table, and this structure is called self-referential integrity.

      • A primary key must be defined for the parent table.

      • Specify the column name or combination of column names after the table name of the parent table. This column or combination of columns must be the primary or candidate key of the primary table.

      • The number of columns in the foreign key must be the same as the number of columns in the primary key of the parent table.

      • The data type of the column in the foreign key must be the same as the data type of the corresponding column in the primary key of the parent table.

      The following is an example to illustrate the association of parent and child tables through FOREIGN KEY and PRIMARY KEY:

      First, create a parent table with field a as the primary key:

      create table t1(a int primary key,b varchar(5));\ninsert into t1 values(101,'abc'),(102,'def');\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|  101 | abc  |\n|  102 | def  |\n+------+------+\n2 rows in set (0.00 sec)\n

      Then create a child table with field c as the foreign key, associated with parent table field a:

      create table t2(a int ,b varchar(5),c int, foreign key(c) references t1(a));\ninsert into t2 values(1,'zs1',101),(2,'zs2',102);\ninsert into t2 values(3,'xyz',null);\nmysql> select * from t2;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 | zs1  |  101 |\n|    2 | zs2  |  102 |\n|    3 | xyz  | NULL |\n+------+------+------+\n3 rows in set (0.00 sec)\n

      In addition, [ON DELETE reference_option] and [ON UPDATE reference_option] are used when defining a foreign key relationship to specify actions to be taken when records in the parent table are deleted or updated. These two parameters are primarily used to maintain data integrity and consistency:

      • ON DELETE reference_option: This parameter specifies how to handle associated foreign key data when data in the referenced table is deleted. Common options include:

        • RESTRICT: If related foreign key data exists in the referenced table, deletion of data in the table is not allowed. This prevents accidental deletion of related data, ensuring data consistency.

        • CASCADE: When data in the referenced table is deleted, associated foreign key data is also deleted. This is used for cascading deletion of related data to maintain data integrity.

        • SET NULL: When data in the referenced table is deleted, the value of the foreign key column is set to NULL. This is used to retain foreign key data while disconnecting it from the referenced data upon deletion.

        • NO ACTION: Indicates no action is taken; it only checks for the existence of associated data. This is similar to RESTRICT but may have minor differences in some databases.

      • ON UPDATE reference_option: This parameter specifies how to handle associated foreign key data when data in the referenced table is updated. Common options are similar to those of ON DELETE reference_option, and their usage is identical, but they apply to data update operations.

      See the example below:

      Suppose there are two tables, Orders and Customers, where the Orders table has a foreign key column customer_id referencing the id column in the Customers table. If, when a customer is deleted from the Customers table, you also want to delete the associated order data, you can use ON DELETE CASCADE.

      CREATE TABLE Customers (\nid INT PRIMARY KEY,\nname VARCHAR(50)\n);\n\nCREATE TABLE Orders (\nid INT PRIMARY KEY,\norder_number VARCHAR(10),\ncustomer_id INT,\nFOREIGN KEY (customer_id) REFERENCES Customers(id) ON DELETE CASCADE\n);\n

      In the above example, when a customer is deleted from the Customers table, the associated order data will also be deleted through cascading, maintaining data integrity. Similarly, the ON UPDATE parameter can handle update operations.

      For more information on data integrity constraints, see Data Integrity Constraints Overview.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#cluster-by","title":"Cluster by","text":"

      Cluster by is a command used to optimize the physical arrangement of a table. When creating a table, the Cluster by command can physically sort the table based on a specified column for tables without a primary key. It will rearrange the data rows to match the order of values in that column. Using Cluster by improves query performance.

      • The syntax for a single column is: create table() cluster by col;
      • The syntax for multiple columns is: create table() cluster by (col1, col2);

      Note: Cluster by cannot coexist with a primary key, or a syntax error will occur. Cluster by can only be specified when creating a table and does not support dynamic creation.

      For more information on using Cluster by for performing tuning, see Using Cluster by for performance tuning.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#table-partition-and-partitions","title":"Table PARTITION and PARTITIONS","text":"
      partition_options:\n PARTITION BY\n     { [LINEAR] HASH(expr)\n     | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)\n [PARTITIONS num]\n [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n     [VALUES\n         {LESS THAN {(expr | value_list) | MAXVALUE}\n         |\n         IN (value_list)}]\n     [COMMENT [=] 'string' ]\n

      Partitions can be modified, merged, added to tables, and dropped from tables.

      • PARTITION BY

      If used, a partition_options clause begins with PARTITION BY. This clause contains the function that is used to determine the partition; the function returns an integer value ranging from 1 to num, where num is the number of partitions.

      • HASH(expr)

      Hashes one or more columns to create a key for placing and locating rows. expr is an expression using one or more table columns. For example, these are both valid CREATE TABLE statements using PARTITION BY HASH:

      CREATE TABLE t1 (col1 INT, col2 CHAR(5))\n    PARTITION BY HASH(col1);\n\nCREATE TABLE t1 (col1 INT, col2 CHAR(5), col3 DATETIME)\n    PARTITION BY HASH ( YEAR(col3) );\n
      • KEY(column_list)

      This is similar to HASH. The column_list argument is simply a list of 1 or more table columns (maximum: 16). This example shows a simple table partitioned by key, with 4 partitions:

      CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE)\n    PARTITION BY KEY(col3)\n    PARTITIONS 4;\n

      For tables that are partitioned by key, you can employ linear partitioning by using the LINEAR keyword. This has the same effect as with tables that are partitioned by HASH. This example uses linear partitioning by key to distribute data between 5 partitions:

      CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE)\n    PARTITION BY LINEAR KEY(col3)\n    PARTITIONS 5;\n
      • RANGE(expr)

      In this case, expr shows a range of values using a set of VALUES LESS THAN operators. When using range partitioning, you must define at least one partition using VALUES LESS THAN. You cannot use VALUES IN with range partitioning.

      PARTITION ... VALUES LESS THAN ... statements work in a consecutive fashion. VALUES LESS THAN MAXVALUE works to specify \"leftover\" values that are greater than the maximum value otherwise specified.

      The clauses must be arranged in such a way that the upper limit specified in each successive VALUES LESS THAN is greater than that of the previous one, with the one referencing MAXVALUE coming last of all in the list.

      • PARTITIONS num

      The number of partitions may optionally be specified with a PARTITIONS num clause, where num is the number of partitions. If both this clause and any PARTITION clauses are used, num must be equal to the total number of any partitions that are declared using PARTITION clauses.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#examples","title":"Examples","text":"
      • Example 1: Create a common table
      CREATE TABLE test(a int, b varchar(10));\nINSERT INTO test values(123, 'abc');\n\nmysql> SELECT * FROM test;\n+------+---------+\n|   a  |    b    |\n+------+---------+\n|  123 |   abc   |\n+------+---------+\n
      • Example 2: Add comments when creating a table
      create table t2 (a int, b int) comment = \"fact table\";\n\nmysql> show create table t2;\n+-------+---------------------------------------------------------------------------------------+\n| Table | Create Table                                                                          |\n+-------+---------------------------------------------------------------------------------------+\n| t2    | CREATE TABLE `t2` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL\n) COMMENT='fact table',    |\n+-------+---------------------------------------------------------------------------------------+\n
      • Example 3: Add comments to columns when creating tables
      create table t3 (a int comment 'Column comment', b int) comment = \"table\";\n\nmysql> SHOW CREATE TABLE t3;\n+-------+----------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                             |\n+-------+----------------------------------------------------------------------------------------------------------+\n| t3    | CREATE TABLE `t3` (\n`a` INT DEFAULT NULL COMMENT 'Column comment',\n`b` INT DEFAULT NULL\n) COMMENT='table',     |\n+-------+----------------------------------------------------------------------------------------------------------+\n
      • Example 4: Create a common partitioned table
      CREATE TABLE tp1 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY KEY(col3) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp1;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                             |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp1   | CREATE TABLE `tp1` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col3) partitions 4 |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- do not specify the number of partitions\nCREATE TABLE tp2 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY KEY(col3);\n\nmysql> SHOW CREATE TABLE tp2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| tp2   | CREATE TABLE `tp2` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col3) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- Specify partition algorithm\nCREATE TABLE tp3\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY KEY ALGORITHM = 1 (col3);\n\n\nmysql> show create table tp3;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| tp3   | CREATE TABLE `tp3` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 1 (col3) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- Specify partition algorithm and the number of partitions\nCREATE TABLE tp4 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY LINEAR KEY ALGORITHM = 1 (col3) PARTITIONS 5;\n\nmysql> SHOW CREATE TABLE tp4;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                    |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp4   | CREATE TABLE `tp4` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by linear key algorithm = 1 (col3) partitions 5 |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- Multi-column partition\nCREATE TABLE tp5\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY KEY(col1, col2) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp5;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                   |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp5   | CREATE TABLE `tp5` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col1, col2) partitions 4 |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- Create a primary key column partition\nCREATE TABLE tp6\n(\ncol1 INT  NOT NULL PRIMARY KEY,\ncol2 DATE NOT NULL,\ncol3 INT  NOT NULL,\ncol4 INT  NOT NULL\n) PARTITION BY KEY(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp6;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                                        |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp6   | CREATE TABLE `tp6` (\n`col1` INT NOT NULL,\n`col2` DATE NOT NULL,\n`col3` INT NOT NULL,\n`col4` INT NOT NULL,\nPRIMARY KEY (`col1`)\n) partition by key algorithm = 2 (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- Create HASH partition\nCREATE TABLE tp7\n(\ncol1 INT,\ncol2 CHAR(5)\n) PARTITION BY HASH(col1);\n\nmysql> SHOW CREATE TABLE tp7;\n+-------+------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                         |\n+-------+------------------------------------------------------------------------------------------------------+\n| tp7   | CREATE TABLE `tp7` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL\n) partition by hash (col1) |\n+-------+------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- Specifies the number of HASH partitions when creating hash partition\nCREATE TABLE tp8\n(\ncol1 INT,\ncol2 CHAR(5)\n) PARTITION BY HASH(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp8;\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                      |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| tp8   | CREATE TABLE `tp8` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL\n) partition by hash (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- specify the partition granularity when creating a partition\nCREATE TABLE tp9\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATETIME\n) PARTITION BY HASH (YEAR(col3));\n\nmysql> SHOW CREATE TABLE tp9;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                             |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n| tp9   | CREATE TABLE `tp9` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATETIME DEFAULT NULL\n) partition by hash (year(col3)) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- specify the partition granularity and number of partitions when creating a partition\nCREATE TABLE tp10\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY LINEAR HASH( YEAR(col3)) PARTITIONS 6;\n\nmysql> SHOW CREATE TABLE tp10;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                              |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp10  | CREATE TABLE `tp10` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by linear hash (year(col3)) partitions 6 |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- Use the primary key column as the HASH partition when creating a partition\nCREATE TABLE tp12 (col1 INT NOT NULL PRIMARY KEY, col2 DATE NOT NULL, col3 INT NOT NULL, col4 INT NOT NULL) PARTITION BY HASH(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp12;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                            |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp12  | CREATE TABLE `tp12` (\n`col1` INT NOT NULL,\n`col2` DATE NOT NULL,\n`col3` INT NOT NULL,\n`col4` INT NOT NULL,\nPRIMARY KEY (`col1`)\n) partition by hash (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
      • Example 5: Primary key auto increment
      drop table if exists t1;\ncreate table t1(a bigint primary key auto_increment,\nb varchar(10));\ninsert into t1(b) values ('bbb');\ninsert into t1 values (3, 'ccc');\ninsert into t1(b) values ('bbb1111');\n\nmysql> select * from t1 order by a;\n+------+---------+\n| a    | b       |\n+------+---------+\n|    1 | bbb     |\n|    3 | ccc     |\n|    4 | bbb1111 |\n+------+---------+\n3 rows in set (0.01 sec)\n\ninsert into t1 values (2, 'aaaa1111');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a    | b        |\n+------+----------+\n|    1 | bbb      |\n|    2 | aaaa1111 |\n|    3 | ccc      |\n|    4 | bbb1111  |\n+------+----------+\n4 rows in set (0.00 sec)\n\ninsert into t1(b) values ('aaaa1111');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a    | b        |\n+------+----------+\n|    1 | bbb      |\n|    2 | aaaa1111 |\n|    3 | ccc      |\n|    4 | bbb1111  |\n|    5 | aaaa1111 |\n+------+----------+\n5 rows in set (0.01 sec)\n\ninsert into t1 values (100, 'xxxx');\ninsert into t1(b) values ('xxxx');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a    | b        |\n+------+----------+\n|    1 | bbb      |\n|    2 | aaaa1111 |\n|    3 | ccc      |\n|    4 | bbb1111  |\n|    5 | aaaa1111 |\n|  100 | xxxx     |\n|  101 | xxxx     |\n+------+----------+\n7 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#constraints","title":"Constraints","text":"
      1. Currently, it is not supported to use the ALTER TABLE table_name DROP PRIMARY KEY statement to drop the primary key from a table.
      2. The ALTER TABLE table_name AUTO_INCREMENT = n; statement is not supported to modify the initial value of the auto-increment column.
      3. In MatrixOne, only syntax supports using the system variable set @@auto_increment_increment=n to set the incremental step size, and only syntax supports using the system variable set @@auto_increment_offset=n to set the default auto-increment column initial value, but it does not take effect; currently supports setting the initial value AUTO_INCREMENT=n of the auto-increment column, but the step size is still 1 by default.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/","title":"CREATE VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/#description","title":"Description","text":"

      The view is a virtual table based on the result-set of an SQL statement.

      A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.

      You can add SQL statements and functions to a view and present the data as if the data were coming from one single table.

      A view is created with the CREATE VIEW statement.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/#syntax","title":"Syntax","text":"
      > CREATE VIEW view_name AS\n  SELECT column1, column2, ...\n  FROM table_name\n  WHERE condition;\n

      Note

      A view always shows up-to-date data! The database engine recreates the view, every time a user queries it.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/#examples","title":"Examples","text":"
      • Example 1:
      CREATE TABLE t00(a INTEGER);\nINSERT INTO t00 VALUES (1),(2);\nCREATE TABLE t01(a INTEGER);\nINSERT INTO t01 VALUES (1);\nCREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\n\nmysql> SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    1 |\n|    2 | NULL |\n+------+------+\n2 rows in set (0.01 sec)\n\nmysql> SELECT * FROM v0 WHERE b >= 0;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    1 |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> SHOW CREATE VIEW v0;\n+------+----------------------------------------------------------------------------+\n| View | Create View                                                                |\n+------+----------------------------------------------------------------------------+\n| v0   | CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a) |\n+------+----------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
      • Example 2:
      drop table if exists t1;\ncreate table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\ninsert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\ndrop table if exists t2;\ncreate table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\ninsert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\nmysql> select * from (select * from t1) sub where id > 4;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.01 sec)\n\ncreate view v1 as select * from (select * from t1) sub where id > 4;\ncreate view v2 as select ti as t,fl as f from (select * from t1) sub where dl <> 4;\ncreate view v3 as select * from (select ti as t,fl as f from t1 where dl <> 4) sub;\ncreate view v4 as select id,min(ti) from (select * from t1) sub group by id;\ncreate view v5 as select * from (select id,min(ti) from (select * from t1) t1 group by id) sub;\nmysql> select * from v1;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id   | ti   | si   | bi   | fl       | dl      | de   | ch           | vch            | dd         | dt                  |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n|    5 |    1 |    2 |    6 |    51.26 |    5126 |   51 | byebye       |  is subquery?  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    6 |    3 |    2 |    1 |    632.1 |    6321 |  632 | good night   | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n|    7 |    4 |    4 |    3 |  7443.11 |  744311 | 7443 | yes          | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n|    8 |    7 |    5 |    8 |     8758 |  875800 | 8758 | nice to meet | just subquery  | 2022-04-28 | 2022-04-28 22:40:11 |\n|    9 |    8 |    4 |    9 | 9849.312 | 9849312 | 9849 | see you      | subquery       | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.00 sec)\n\nmysql> select * from v2;\n+------+----------+\n| t    | f        |\n+------+----------+\n|    1 |  1113.32 |\n|    2 |  2252.05 |\n|    6 |  3663.21 |\n|    7 |  4715.22 |\n|    1 |    51.26 |\n|    3 |    632.1 |\n|    4 |  7443.11 |\n|    7 |     8758 |\n|    8 | 9849.312 |\n+------+----------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v3;\n+------+----------+\n| t    | f        |\n+------+----------+\n|    1 |  1113.32 |\n|    2 |  2252.05 |\n|    6 |  3663.21 |\n|    7 |  4715.22 |\n|    1 |    51.26 |\n|    3 |    632.1 |\n|    4 |  7443.11 |\n|    7 |     8758 |\n|    8 | 9849.312 |\n+------+----------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v4;\n+------+---------+\n| id   | min(ti) |\n+------+---------+\n|    1 |       1 |\n|    2 |       2 |\n|    3 |       6 |\n|    4 |       7 |\n|    5 |       1 |\n|    6 |       3 |\n|    7 |       4 |\n|    8 |       7 |\n|    9 |       8 |\n+------+---------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v5;\n+------+---------+\n| id   | min(ti) |\n+------+---------+\n|    1 |       1 |\n|    2 |       2 |\n|    3 |       6 |\n|    4 |       7 |\n|    5 |       1 |\n|    6 |       3 |\n|    7 |       4 |\n|    8 |       7 |\n|    9 |       8 |\n+------+---------+\n9 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/","title":"DROP DATABASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#description","title":"Description","text":"

      Drop a database.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#syntax","title":"Syntax","text":"
      > DROP DATABASE [IF EXISTS] <database_name>\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#examples","title":"Examples","text":"
      CREATE DATABASE test01;\n\nmysql> DROP DATABASE test01;\nQuery OK, 0 rows affected (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/","title":"DROP INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#description","title":"Description","text":"

      This statement deletes the index from the currently selected table and will report an error if the index does not exist unless the IF EXISTS modifier is used.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#syntax","title":"Syntax","text":"
      > DROP INDEX index_name ON tbl_name\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#examples","title":"Examples","text":"
      create table t5(a int, b int, unique key(a));\nmysql> show create table t5;\n+-------+----------------------------------------------------------------------------------------+\n| Table | Create Table                                                                           |\n+-------+----------------------------------------------------------------------------------------+\n| t5    | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`)\n) |\n+-------+----------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\ncreate index b on t5(b);\nmysql> show create table t5;\n+-------+-------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                          |\n+-------+-------------------------------------------------------------------------------------------------------+\n| t5    | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`),\nKEY `b` (`b`)\n) |\n+-------+-------------------------------------------------------------------------------------------------------+\n1 row in set (0.02 sec)\n\ndrop index b on t5;\nmysql> show create table t5;\n+-------+----------------------------------------------------------------------------------------+\n| Table | Create Table                                                                           |\n+-------+----------------------------------------------------------------------------------------+\n| t5    | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`)\n) |\n+-------+----------------------------------------------------------------------------------------+\n1 row in set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/","title":"DROP PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#description","title":"Description","text":"

      DROP PUBLICATION can delete the existed publication.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#syntax","title":"Syntax","text":"
      DROP PUBLICATION pubname;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#explanations","title":"Explanations","text":"
      • pubname: The name of an existing publication whose definition is to be deleted.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#examples","title":"Examples","text":"
      create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nmysql> show publications;\n+------+----------+\n| Name | Database |\n+------+----------+\n| pub3 | t        |\n+------+----------+\n1 row in set (0.00 sec)\n\nmysql> drop publication pub3;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> show publications;\nEmpty set (0.00 sec)  
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/","title":"DROP SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#description","title":"Description","text":"

      DROP SEQUENCE is used to drop a sequence. It allows you to delete sequences previously created with the CREATE SEQUENCE command.

      Deleting a sequence deletes all properties and values of the sequence. Therefore, before dropping a sequence, you must ensure that no tables are still using the sequence.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#syntax","title":"Syntax","text":"
      > DROP SEQUENCE [ IF EXISTS ] SEQUENCE_NAME [, ...]\n  [IF EXISTS]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#examples","title":"Examples","text":"
      -- Delete the sequence named \"seq_id\"\nDROP SEQUENCE seq_id;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/","title":"DROP STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#description","title":"Description","text":"

      DROP STAGE drops a named internal or external data stage from the database. The data stage is a temporary storage area that loads data from a file into a database table or exports data from a database table to a file. Use the DROP STAGE command to remove stages of data that are no longer needed from the database, freeing storage space and avoiding additional storage charges.

      Note

      The cluster administrator (i.e., the root user) and account administrators can delete data stages.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#syntax","title":"Syntax","text":"
      -- Delete internal stage\n> DROP STAGE [IF EXISTS] {internal_stage_name};\n\n-- Delete external stage\n> DROP STAGE  [IF EXISTS] {external_stage_name};\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#examples","title":"Examples","text":"
      CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- Create internal data stage\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- Export data from the table to data stage\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- You can see your exported table in your local directory\n\n-- delete stage1\nmysql> drop stage stage1;\nQuery OK, 0 rows affected (0.01 sec)\n\n-- stage1 has been deleted; the data stage is not available\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\nERROR 20101 (HY000): internal error: stage 'stage1' is not exists, please check\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/","title":"DROP TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#description","title":"Description","text":"

      Deletes the table.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#syntax","title":"Syntax","text":"
      > DROP TABLE [IF EXISTS] [db.]name\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#examples","title":"Examples","text":"
      CREATE TABLE table01(a int);\n\nmysql> DROP TABLE table01;\nQuery OK, 0 rows affected (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/","title":"DROP VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#description","title":"Description","text":"

      DROP VIEW removes one or more views.

      If any views named in the argument list do not exist, the statement fails with an error indicating by name which nonexisting views it was unable to drop, and no changes are made.

      The IF EXISTS clause prevents an error from occurring for views that don't exist. When this clause is given, a NOTE is generated for each nonexistent view.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#syntax","title":"Syntax","text":"
      > DROP VIEW [IF EXISTS]\n    view_name [, view_name] ...\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#examples","title":"Examples","text":"
      CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT);\nCREATE VIEW v1 AS SELECT * FROM t1;\n\nmysql> DROP VIEW v1;\nQuery OK, 0 rows affected (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/","title":"TRUNCATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#description","title":"Description","text":"

      The TRUNCATE TABLE statement deletes all rows in a table without logging individual row deletions. TRUNCATE TABLE is similar to a DELETE statement without a WHERE clause; however, TRUNCATE TABLE is faster and uses fewer system and transaction log resources.

      TRUNCATE TABLE has the following characteristics:

      • It cannot be restored after the TRUNCATE TABLE is deleted.

      • If the table has an AUTO_INCREMENT column, the TRUNCATE TABLE statement resets the auto-increment value to zero.

      • The TRUNCATE TABLE statement deletes rows individually if the table has FOREIGN KEY constraints.

      • If the table does not have any FOREIGN KEY constraints, the TRUNCATE TABLE statement will drop the table and recreate a new one with the same structure

      The difference between DROP TABLE, TRUNCATE TABLE, and DELETE TABLE:

      • DROP TABLE: Use DROP TABLE when you no longer need the table.
      • TRUNCATE TABLE: Use TRUNCATE TABLE to keep the table, but delete all records.
      • DELETE TABLE: When you want to delete some records, use DELETE TABLE.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#syntax","title":"Syntax","text":"
      > TRUNCATE [TABLE] table_name;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#explanations","title":"Explanations","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#table","title":"TABLE","text":"

      The TABLE keyword is optional. Use this to distinguish the TRUNCATE TABLE statement from the TRUNCATE function.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#examples","title":"Examples","text":"
      create table index_table_05 (col1 bigint not null auto_increment,col2 varchar(25),col3 int,col4 varchar(50),primary key (col1),unique key col2(col2),key num_id(col4));\ninsert into index_table_05(col2,col3,col4) values ('apple',1,'10'),('store',2,'11'),('bread',3,'12');\nmysql> select * from index_table_05;\n+------+-------+------+------+\n| col1 | col2  | col3 | col4 |\n+------+-------+------+------+\n|    1 | apple |    1 | 10   |\n|    2 | store |    2 | 11   |\n|    3 | bread |    3 | 12   |\n+------+-------+------+------+\n3 rows in set (0.00 sec)\n\nmysql> truncate table index_table_05;\nQuery OK, 0 rows affected (0.12 sec)\n\nmysql> select * from index_table_05;\nEmpty set (0.03 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/","title":"LOAD DATA","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#description","title":"Description","text":"

      The LOAD DATA statement reads rows from a text file into a table at a very high speed. The file can be read from the server host or a S3 compatible object storage. LOAD DATA is the complement of SELECT ... INTO OUTFILE. To write data from a table to a file, use SELECT ... INTO OUTFILE. To read the file back into a table, use LOAD DATA. The syntax of the FIELDS and LINES clauses is the same for both statements.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#load-external-data","title":"Load external data","text":"
      > LOAD DATA [LOCAL]\n    INFILE 'file_name'\n    INTO TABLE tbl_name\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY 'string']\n        [[OPTIONALLY] ENCLOSED BY 'char']\n    ]\n    [LINES\n        [STARTING BY 'string']\n        [TERMINATED BY 'string']\n    ]\n    [IGNORE number {LINES | ROWS}]\n    [SET column_name_1=nullif(column_name_1, expr1), column_name_2=nullif(column_name_2, expr2)...]\n    [PARALLEL {'TRUE' | 'FALSE'}]\n

      Parameter Explanation

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#input-file-location","title":"Input File Location","text":"
      • LOAD DATA INFILE 'file_name': Indicates that the data file to be loaded is on the same machine as the MatrixOne host server. file_name can be the relative path name of the storage location of the file, or it can be the absolute path name.

      • LOAD DATA LOCAL INFILE 'file_name': indicates that the data file to be loaded is not on the same machine as the MatrixOne host server; that is, the data file is on the client server. file_name can be the relative path name of the storage location of the file, or it can be the absolute path name.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#field-and-line-handling","title":"Field and Line Handling","text":"

      For both the LOAD DATA and SELECT ... INTO OUTFILE statements, the syntax of the FIELDS and LINES clauses is the same. Both clauses are optional, but FIELDS must precede LINES if both are specified.

      If you specify a FIELDS clause, each of its subclauses (TERMINATED BY, [OPTIONALLY] ENCLOSED BY) is also optional, except that you must specify at least one of them. Arguments to these clauses are permitted to contain only ASCII characters.

      If you specify no FIELDS or LINES clause, the defaults are the same as if you had written this:

      FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n'\n

      Note

      • FIELDS TERMINATED BY ',': with and only ,, | or \\t as delimiters.
      • ENCLOSED BY '\"': with and only \" as the included character.
      • LINES TERMINATED BY '\\n': Use and only use \\n or \\r\\n as the line separator.

      FIELDS TERMINATED BY

      FIELDS TERMINATED BY specifies the delimiter for a field. The FIELDS TERMINATED BY values can be more than one character.

      For example, to read the comma-delimited file, the correct statement is:

      LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',';\n

      If instead you tried to read the file with the statement shown following, it would not work because it instructs LOAD DATA to look for tabs between fields:

      LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY '\\t';\n

      The likely result is that each input line would be interpreted as a single field. You may encounter an error of \"ERROR 20101 (HY000): internal error: the table column is larger than input data column\".

      FIELDS ENCLOSED BY

      FIELDS TERMINATED BY option specifies the character enclose the input values. ENCLOSED BY value must be a single character. If the input values are not necessarily enclosed within quotation marks, use OPTIONALLY before the ENCLOSED BY option.

      For example, if some input values are enclosed within quotation marks, some are not:

      LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"';\n

      LINES TERMINATED BY

      LINES TERMINATED BY specifies the delimiter for the a line. The LINES TERMINATED BY values can be more than one character.

      For example, if the lines in a csv file are terminated by carriage return/newline pairs, you can load it with LINES TERMINATED BY '\\r\\n':

      LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n  LINES TERMINATED BY '\\r\\n';\n

      LINE STARTING BY

      If all the input lines have a common prefix that you want to ignore, you can use LINES STARTING BY 'prefix_string' to skip the prefix and anything before it. If a line does not include the prefix, the entire line is skipped. Suppose that you issue the following statement:

      LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ','  LINES STARTING BY 'xxx';\n

      If the data file looks like this:

      xxx\"abc\",1\nsomething xxx\"def\",2\n\"ghi\",3\n

      The resulting rows are (\"abc\",1) and (\"def\",2). The third row in the file is skipped because it does not contain the prefix.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#ignore-lines","title":"IGNORE LINES","text":"

      The IGNORE number LINES clause can be used to ignore lines at the start of the file. For example, you can use IGNORE 1 LINES to skip an initial header line containing column names:

      LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1 IGNORE 1 LINES;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#set","title":"SET","text":"

      MatrixOne only supports SET column_name=nullif(column_name,expr). That is, when column_name = expr, it returns NULL; otherwise, it returns the original value of column_name. For example, SET a=nullif(a,1), if a=1, returns NULL; otherwise, it returns the original value of column a.

      By setting the parameter, you can use SET column_name=nullif(column_name,\"null\") to return the NULL value in the column when loading the file.

      Example

      1. The details of the local file test.txt are as follows:

        id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\nnull,wederTom,\"man\"\n
      2. Create a table named user in MatrixOne:

        create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\n
      3. Load test.txt into the table user:

        LOAD DATA INFILE '/tmp/test.txt' INTO TABLE user SET id=nullif(id,\"null\");\n
      4. The result of the talbe is as below:

        select * from user;\n+------+-----------+------+\n| id   | user_name | sex  |\n+------+-----------+------+\n|    1 | weder     | man  |\n|    2 | tom       | man  |\n| null | wederTom  | man  |\n+------+-----------+------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#parallel","title":"PARALLEL","text":"

      For a sizeable well-formed file, such as a JSOLLines file or a CSV file with no line breaks in a line of data, you can use PARALLEL to load the file in parallel to speed up the loading.

      For example, for a large file of 2 G, use two threads to load; the second thread first splits and locates the 1G position, then reads and loads backward. In this way, two threads can read large files at the same time, and each thread can read 1G of data.

      Enable/Disable Parallel Loading Command Line Example:

      --  Enable Parallel Loading\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'TRUE';\n\n--  Disable Parallel Loading\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'FALSE';\n\n--  Parallel loading is disabled by default\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES;\n

      Note

      [PARALLEL {'TRUE' | 'FALSE'}] currently only support TRUE or FALSE and are not case-sensitive.

      Note: If the PARALLEL field is not added in the LOAD statement, for CSV files, parallel loading is disabled by default; for JSOLLines files, parallel loading is enabled by default. If there is a line terminator in the CSV file, such as '\\n', otherwise it may cause data errors when the file is loaded. If the file is too large, manually splitting the file from the '\\n' as the starting and ending point is recommended, then enabling parallel loading.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#load-time-series-data","title":"Load Time-Series Data","text":"
      > LOAD DATA INLINE FORMAT='' DATA=''\nINTO TABLE tbl_name\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY 'string']\n        [[OPTIONALLY] ENCLOSED BY 'char']\n    ]\n    [LINES\n        [STARTING BY 'string']\n        [TERMINATED BY 'string']\n    ]\n    [IGNORE number {LINES | ROWS}]\n

      Parameter Explanation

      The SQL command LOAD DATA INLINE for loading time-series data has the following parameter explanations:

      • FORMAT: Specifies the format of the time-series data being loaded; for example, FORMAT='csv' indicates that the data being loaded is in CSV format. It supports the same formats as LOAD DATA INFILE.

      • DATA: Specifies the actual time-series data to be loaded. In the example, DATA='1\\n2\\n' indicates that the data to be loaded consists of two lines containing the numbers 1 and 2.

      Note

      Parameters such as FIELDS, COLUMNS, TERMINATED BY, ENCLOSED BY, LINES, STARTING BY, and IGNORE can be referred to the parameter explanations of LOAD DATA INFILE as mentioned earlier.

      Example command for loading time-series data: load data inline format='csv', data='1\\n2\\n' into table t1;. This command loads the specified data in CSV format (which includes two lines, namely 1 and 2) into a database table named t1.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#supported-file-formats","title":"Supported file formats","text":"

      In MatrixOne's current release, LOAD DATA supports CSV(comma-separated values) format and JSONLines format file. See full tutorials for loading csv and jsonline.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#csv-format-standard-description","title":"CSV format standard description","text":"

      The CSV format loaded by MatrixOne conforms to the RFC4180 standard, and the CSV format is specified as follows:

      1. Each record is on a separate line, separated by a newline character (CRLF):

        aaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

      2. The last record in the file can have a terminating newline or no terminating newline (CRLF):

        aaa,bbb,ccc CRLF\nzzz,yyy,xxx\n

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

      3. An optional header line appears as the first line of the file and has the same format as a standard record line. For example:

        field_name,field_name,field_name CRLF\naaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n

        Imported into the table as follows:

        +------------+------------+------------+ | field_name | field_name | field_name | +------------+------------+------------+ | aaa | bbb | ccc | | zzz | yyy | xxx | +------------+------------+------------+

      4. In the header and each record, there may be one or more fields separated by commas. Whitespace within a field is part of the field and should not be ignored. A comma cannot follow the last field in each record. For example:

        aaa,bbb,ccc\n

        Or:

        a aa, bbb,cc c\n

        Both examples are correct.

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | bbb | ccc | +---------+---------+---------+

        Or:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | a aa | bbb | cc c | +---------+---------+---------+

      5. Each field can be enclosed in double quotes or not. Double quotes cannot appear inside a field if the field is not enclosed in double-quotes. For example:

        \"aaa\",\"bbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n

        Or:

        \"aaa\",\"bbb\",ccc CRLF\nzzz,yyy,xxx\n

        Both examples are correct.

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | bbb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

      6. Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes. For example:

        \"aaa\",\"b CRLF\nbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

      7. If double quotation marks are used to enclose the field, then multiple double quotation marks appearing in the field must also be enclosed in double quotation marks; otherwise, the first quotation mark of two double quotation marks in the field will be parsed as an escape character, thus keep a single, double quote. For example:

        \"aaa\",\"b\",\"bb\",\"ccc\"\n

        The above CSV will parse \"b\"\"bb\" into b\"bb; if the correct field is b\"\"bb, then it should be written as:

        \"aaa\",\"b\"\"\"\"bb\",\"ccc\"\n

        Or:

        \"aaa\",b\"\"bb,\"ccc\"\n

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b\"\"bb | ccc | +---------+---------+---------+

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#examples","title":"Examples","text":"

      The SSB Test is an example of LOAD DATA syntax. Complete a SSB Test with MatrixOne

      > LOAD DATA INFILE '/ssb-dbgen-path/lineorder_flat.tbl ' INTO TABLE lineorder_flat;\n

      The above statement means: load the lineorder_flat.tbl data set under the directory path /ssb-dbgen-path/ into the MatrixOne data table lineorder_flat.

      You can also refer to the following syntax examples to quickly understand LOAD DATA:

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#example-1-load-csv","title":"Example 1: LOAD CSV","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#simple-example","title":"Simple example","text":"

      The data in the file locally named char_varchar.csv is as follows:

      a|b|c|d\n\"a\"|\"b\"|\"c\"|\"d\"\n'a'|'b'|'c'|'d'\n\"'a'\"|\"'b'\"|\"'c'\"|\"'d'\"\n\"aa|aa\"|\"bb|bb\"|\"cc|cc\"|\"dd|dd\"\n\"aa|\"|\"bb|\"|\"cc|\"|\"dd|\"\n\"aa|||aa\"|\"bb|||bb\"|\"cc|||cc\"|\"dd|||dd\"\n\"aa'|'||aa\"|\"bb'|'||bb\"|\"cc'|'||cc\"|\"dd'|'||dd\"\naa\"aa|bb\"bb|cc\"cc|dd\"dd\n\"aa\"aa\"|\"bb\"bb\"|\"cc\"cc\"|\"dd\"dd\"\n\"aa\"\"aa\"|\"bb\"\"bb\"|\"cc\"\"cc\"|\"dd\"\"dd\"\n\"aa\"\"\"aa\"|\"bb\"\"\"bb\"|\"cc\"\"\"cc\"|\"dd\"\"\"dd\"\n\"aa\"\"\"\"aa\"|\"bb\"\"\"\"bb\"|\"cc\"\"\"\"cc\"|\"dd\"\"\"\"dd\"\n\"aa\"\"|aa\"|\"bb\"\"|bb\"|\"cc\"\"|cc\"|\"dd\"\"|dd\"\n\"aa\"\"\"\"|aa\"|\"bb\"\"\"\"|bb\"|\"cc\"\"\"\"|cc\"|\"dd\"\"\"\"|dd\"\n|||\n||||\n\"\"|\"\"|\"\"|\n\"\"\"\"|\"\"\"\"|\"\"\"\"|\"\"\"\"\n\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"\n

      Create a table named t1 in MatrixOne:

      mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(\n-> col1 char(225),\n-> col2 varchar(225),\n-> col3 text,\n-> col4 varchar(225)\n-> );\nQuery OK, 0 rows affected (0.02 sec)\n

      Load the data file into table t1:

      load data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|';\n

      The query result is as follows:

      mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa|aa     | bb|bb     | cc|cc     | dd|dd     |\n| aa|       | bb|       | cc|       | dd|       |\n| aa|||aa   | bb|||bb   | cc|||cc   | dd|||dd   |\n| aa'|'||aa | bb'|'||bb | cc'|'||cc | dd'|'||dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"|aa    | bb\"|bb    | cc\"|cc    | dd\"|dd    |\n| aa\"\"|aa   | bb\"\"|bb   | cc\"\"|cc   | dd\"\"|dd   |\n|           |           |           |           |\n|           |           |           |           |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n20 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#add-conditional-example","title":"Add conditional Example","text":"

      Following the example above, you can modify the LOAD DATA statement and add LINES STARTING BY 'aa' ignore 10 lines; at the end of the statement to experience the difference:

      delete from t1;\nload data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|' LINES STARTING BY 'aa' ignore 10 lines;\n

      The query result is as follows:

      mysql> select * from t1;\n+---------+---------+---------+---------+\n| col1    | col2    | col3    | col4    |\n+---------+---------+---------+---------+\n| aa\"aa   | bb\"bb   | cc\"cc   | dd\"dd   |\n| aa\"\"aa  | bb\"\"bb  | cc\"\"cc  | dd\"\"dd  |\n| aa\"\"aa  | bb\"\"bb  | cc\"\"cc  | dd\"\"dd  |\n| aa\"|aa  | bb\"|bb  | cc\"|cc  | dd\"|dd  |\n| aa\"\"|aa | bb\"\"|bb | cc\"\"|cc | dd\"\"|dd |\n|         |         |         |         |\n|         |         |         |         |\n|         |         |         |         |\n| \"       | \"       | \"       | \"       |\n| \"\"      | \"\"      | \"\"      | \"\"      |\n+---------+---------+---------+---------+\n10 rows in set (0.00 sec)\n

      As you can see, the query result ignores the first line and and ignores the common prefix aa.

      For more information on loding csv, see Import the .csv data.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#example-2-load-jsonlines","title":"Example 2: LOAD JSONLines","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#simple-example_1","title":"Simple example","text":"

      The data in the file locally named jsonline_array.jl is as follows:

      [true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11,[\"1\",2,null,false,true,{\"q\":1}],\"1qaz\",null,null]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\",{\"c\":1,\"b\":[\"a\",\"b\",{\"q\":4}]},\"1aza\",null,null]\n

      Create a table named t1 in MatrixOne:

      mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(col1 bool,col2 int,col3 varchar(100), col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float,col9 json,col10 text,col11 json,col12 bool);\nQuery OK, 0 rows affected (0.03 sec)\n

      Load the data file into table t1:

      load data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1;\n

      The query result is as follows:

      mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4       | col5                | col6                | col7 | col8   | col9                                  | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | [\"1\", 2, null, false, true, {\"q\": 1}] | 1qaz  | NULL  | NULL  |\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1}   | 1aza  | NULL  | NULL  |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#add-conditional-example_1","title":"Add conditional Example","text":"

      Following the example above, you can modify the LOAD DATA statement and add ignore 1 lines at the end of the statement to experience the difference:

      delete from t1;\nload data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1 ignore 1 lines;\n

      The query result is as follows:

      mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4       | col5                | col6                | col7 | col8   | col9                                | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1} | 1aza  | NULL  | NULL  |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n1 row in set (0.00 sec)\n

      As you can see, the query result ignores the first line.

      For more information on loding JSONLines, see Import the JSONLines data.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/1.1-load-data/#constraints","title":"Constraints","text":"
      1. The REPLACE and IGNORE modifiers control handling of new (input) rows that duplicate existing table rows on unique key values (PRIMARY KEY or UNIQUE index values) are not supported in MatrixOne yet.
      2. Input pre-pressing with SET is supported very limitedly. Only SET columns_name=nullif(expr1,expr2) is supported.
      3. When enabling the parallel loading, it must be ensured that each row of data in the file does not contain the specified line terminator, such as '\\n'; otherwise, it will cause data errors during file loading.
      4. The parallel loading of files requires that the files be in uncompressed format, and parallel loading of files in compressed form is not currently supported.
      5. When you use load data local, you need to use the command line to connect to the MatrixOne service host: mysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile.
      6. MatrixOne does not support ESCAPED BY currently. Writing or reading special characters differs from MySQL to some extent.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/","title":"CASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#description","title":"Description","text":"

      The CASE statement for stored programs implements a complex conditional construct.

      Note: There is also a CASE operator, which differs from the CASE statement described here. See Flow Control Functions. The CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END.

      If no when_value or search_condition matches the value tested and the CASE statement contains no ELSE clause, a Case not found for CASE statement error results.

      Each statement_list consists of one or more SQL statements; an empty statement_list is not permitted.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#syntax-1","title":"Syntax 1","text":"
      CASE case_value\n    WHEN when_value THEN statement_list\n    [WHEN when_value THEN statement_list] ...\n    [ELSE statement_list]\nEND CASE\n

      For the first syntax, case_value is an expression. This value is compared to the when_value expression in each WHEN clause until one of them is equal. When an equal when_value is found, the corresponding THEN clause statement_list executes. If no when_value is equal, the ELSE clause statement_list executes, if there is one.

      This syntax cannot be used to test for equality with NULL because NULL = NULL is false.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#syntax-2","title":"Syntax 2","text":"
      CASE\n    WHEN search_condition THEN statement_list\n    [WHEN search_condition THEN statement_list] ...\n    [ELSE statement_list]\nEND CASE\n

      For the second syntax, each WHEN clause search_condition expression is evaluated until one is true, at which point its corresponding THEN clause statement_list executes. If no search_condition is equal, the ELSE clause statement_list executes, if there is one.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#examples","title":"Examples","text":"
      CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER);\nINSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1);\n\nmysql> SELECT CASE AVG (c0) WHEN any_value(c1) * any_value(c2) THEN 1 END FROM t1;\n+------------------------------------------------------------+\n| case avg(c0) when any_value(c1) * any_value(c2) then 1 end |\n+------------------------------------------------------------+\n|                                                          1 |\n+------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CASE any_value(c1) * any_value(c2) WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1;\n+--------------------------------------------------------------------------------+\n| case any_value(c1) * any_value(c2) when sum(c0) then 1 when avg(c0) then 2 end |\n+--------------------------------------------------------------------------------+\n|                                                                              2 |\n+--------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CASE any_value(c1) WHEN any_value(c1) + 1 THEN 1 END, ABS(AVG(c0)) FROM t1;\n+------------------------------------------------------+--------------+\n| case any_value(c1) when any_value(c1) + 1 then 1 end | abs(avg(c0)) |\n+------------------------------------------------------+--------------+\n|                                                 NULL |            1 |\n+------------------------------------------------------+--------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/","title":"DELETE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#description","title":"Description","text":"

      DELETE statement removes rows from a single table or multiple tables.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#single-table-syntax","title":"Single-Table Syntax","text":"
      DELETE FROM tbl_name [[AS] tbl_alias]\n    [WHERE where_condition]\n    [ORDER BY ...]\n    [LIMIT row_count]\n

      The DELETE statement deletes rows from tbl_name and returns the number of deleted rows.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#explanations","title":"Explanations","text":"
      • The conditions in the optional WHERE clause identify which rows to delete. With no WHERE clause, all rows are deleted.
      • If the ORDER BY clause is specified, the rows are deleted in the order that is specified. -The LIMIT clause places a limit on the number of rows that can be deleted.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#examples","title":"Examples","text":"
      • Single-Table Examples
      CREATE TABLE t1 (a bigint(3), b bigint(5) primary key);\ninsert INTO t1 VALUES (1,1),(1,2);\ndelete from t1 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    1 |    2 |\n+------+------+\n
      • Multiple-Table Examples

      Multiple-table join Syntax is also supported.

      drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a int);\ninsert into t1 values(1), (2), (4);\ncreate table t2 (b int);\ninsert into t2 values(1), (2), (5);\ndelete t1 from t1 join t2 where t1.a = 2;\n\nmysql> select * from t1;\n+------+\n| a    |\n+------+\n|    1 |\n|    4 |\n+------+\n2 rows in set (0.00 sec)\n
      drop database if exists db1;\ndrop database if exists db2;\ncreate database db1;\ncreate database db2;\nuse db2;\ndrop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values (1),(2),(4);\nuse db1;\ndrop table if exists t2;\ncreate table t2 (b int);\ninsert into t2 values(1),(2),(3);\ndelete from db1.t2, db2.t1 using db1.t2 join db2.t1 on db1.t2.b = db2.t1.a where 2 > 1;\n\nmysql> select * from db1.t2;\n+------+\n| b    |\n+------+\n|    3 |\n+------+\nmysql> select * from db2.t1;\n+------+\n| a    |\n+------+\n|    4 |\n+------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/","title":"INSERT INTO SELECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#description","title":"Description","text":"

      The INSERT INTO SELECT statement copies data from one table and inserts it into another table.

      The existing records in the target table are unaffected.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#syntax","title":"Syntax","text":"
      INSERT INTO table2 (column1, column2, column3, ...)\nSELECT column1, column2, column3, ...\nFROM table1\nWHERE condition;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#examples","title":"Examples","text":"
      create table t1(id int, name varchar(10));\ninsert into t1 values(1, 'a');\ninsert into t1 values(2, 'b');\ninsert into t1 values(3, 'c');\ncreate table t2(id int, appname varchar(10), country varchar(10));\ninsert into t2 values(1, 'appone', 'CN');\ninsert into t2 values(2, 'apptwo', 'CN');\nINSERT INTO t1 (name) SELECT appname FROM t2;\n\nmysql> select * from t1;\n+------+--------+\n| id   | name   |\n+------+--------+\n|    1 | a      |\n|    2 | b      |\n|    3 | c      |\n| NULL | appone |\n| NULL | apptwo |\n+------+--------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/","title":"INSERT ... ON DUPLICATE KEY UPDATE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/#description","title":"Description","text":"

      INSERT ... ON DUPLICATE KEY UPDATE is used to insert data into the database table; if the data already exists, update the data; otherwise, insert new data.

      The INSERT INTO statement is a standard statement used to insert data into a database table; the ON DUPLICATE KEY UPDATE statement performs an update operation when there are duplicate records in the table. If a record with the same unique index or primary key exists in the table, use the UPDATE clause to update the corresponding column value; otherwise, use the INSERT clause to insert a new record.

      It should be noted that the premise of using this syntax is that a primary key constraint needs to be established in the table to determine whether there are duplicate records. At the same time, both the update operation and the insert operation need to set the corresponding column value. Otherwise, a syntax error will result.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/#syntax","title":"Syntax","text":"
      > INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n  [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...];\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/#examples","title":"Examples","text":"
      CREATE TABLE user (\nid INT(11) NOT NULL PRIMARY KEY,\nname VARCHAR(50) NOT NULL,\nage INT(3) NOT NULL\n);\n-- Insert a new data; it does not exist, insert the new data\nINSERT INTO user (id, name, age) VALUES (1, 'Tom', 18)\nON DUPLICATE KEY UPDATE name='Tom', age=18;\n\nmysql> select * from user;\n+------+------+------+\n| id   | name | age  |\n+------+------+------+\n|    1 | Tom  |   18 |\n+------+------+------+\n1 row in set (0.01 sec)\n\n-- Increment the age field of an existing record by 1 while keeping the name field unchanged\nINSERT INTO user (id, name, age) VALUES (1, 'Tom', 18)\nON DUPLICATE KEY UPDATE age=age+1;\n\nmysql> select * from user;\n+------+------+------+\n| id   | name | age  |\n+------+------+------+\n|    1 | Tom  |   19 |\n+------+------+------+\n1 row in set (0.00 sec)\n\n-- Insert a new record, and update the name and age fields to the specified values\nINSERT INTO user (id, name, age) VALUES (2, 'Lucy', 20)\nON DUPLICATE KEY UPDATE name='Lucy', age=20;\n\nmysql> select * from user;\n+------+------+------+\n| id   | name | age  |\n+------+------+------+\n|    1 | Tom  |   19 |\n|    2 | Lucy |   20 |\n+------+------+------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-on-duplicate/#constraints","title":"Constraints","text":"

      Unique key are not currently supported with INSERT ... ON DUPLICATE KEY UPDATE, and since unique key can be null, some unknown errors can occur.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/","title":"INSERT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#description","title":"Description","text":"

      Writing data.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#syntax","title":"Syntax","text":"
      > INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(a int default (1+12), b int);\ninsert into t1(b) values(1), (1);\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|   13 |    1 |\n|   13 |    1 |\n+------+------+\n2 rows in set (0.01 sec)\n\ndrop table if exists t1;\ncreate table t1 (a date);\ninsert into t1 values(DATE(\"2017-06-15 09:34:21\")),(DATE(\"2019-06-25 10:12:21\")),(DATE(\"2019-06-25 18:20:49\"));\n\nmysql> select * from t1;\n+------------+\n| a          |\n+------------+\n| 2017-06-15 |\n| 2019-06-25 |\n| 2019-06-25 |\n+------------+\n3 rows in set (0.00 sec)\n\ndrop table if exists t;\nCREATE TABLE t (i1 INT, d1 DOUBLE, e2 DECIMAL(5,2));\nINSERT INTO t VALUES ( 6, 6.0, 10.0/3), ( null, 9.0, 10.0/3), ( 1, null, 10.0/3), ( 2, 2.0, null );\n\nmysql> select * from t;\n+------+------+------+\n| i1   | d1   | e2   |\n+------+------+------+\n|    6 |    6 | 3.33 |\n| NULL |    9 | 3.33 |\n|    1 | NULL | 3.33 |\n|    2 |    2 | NULL |\n+------+------+------+\n4 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/","title":"LOAD DATA","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#description","title":"Description","text":"

      The LOAD DATA statement reads rows from a text file into a table at a very high speed. The file can be read from the server host or a S3 compatible object storage. LOAD DATA is the complement of SELECT ... INTO OUTFILE. To write data from a table to a file, use SELECT ... INTO OUTFILE. To read the file back into a table, use LOAD DATA. The syntax of the FIELDS and LINES clauses is the same for both statements.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#syntax","title":"Syntax","text":"
      > LOAD DATA [LOCAL]\n    INFILE 'file_name'\n    INTO TABLE tbl_name\n    [{FIELDS | COLUMNS}\n        [TERMINATED BY 'string']\n        [[OPTIONALLY] ENCLOSED BY 'char']\n    ]\n    [LINES\n        [STARTING BY 'string']\n        [TERMINATED BY 'string']\n    ]\n    [IGNORE number {LINES | ROWS}]\n    [SET column_name_1=nullif(column_name_1, expr1), column_name_2=nullif(column_name_2, expr2)...]\n    [PARALLEL {'TRUE' | 'FALSE'}]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#input-file-location","title":"Input File Location","text":"
      • LOAD DATA INFILE 'file_name': Indicates that the data file to be loaded is on the same machine as the MatrixOne host server. file_name can be the relative path name of the storage location of the file, or it can be the absolute path name.

      • LOAD DATA LOCAL INFILE 'file_name': indicates that the data file to be loaded is not on the same machine as the MatrixOne host server; that is, the data file is on the client server. file_name can be the relative path name of the storage location of the file, or it can be the absolute path name.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#ignore-lines","title":"IGNORE LINES","text":"

      The IGNORE number LINES clause can be used to ignore lines at the start of the file. For example, you can use IGNORE 1 LINES to skip an initial header line containing column names:

      LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1 IGNORE 1 LINES;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#field-and-line-handling","title":"Field and Line Handling","text":"

      For both the LOAD DATA and SELECT ... INTO OUTFILE statements, the syntax of the FIELDS and LINES clauses is the same. Both clauses are optional, but FIELDS must precede LINES if both are specified.

      If you specify a FIELDS clause, each of its subclauses (TERMINATED BY, [OPTIONALLY] ENCLOSED BY) is also optional, except that you must specify at least one of them. Arguments to these clauses are permitted to contain only ASCII characters.

      If you specify no FIELDS or LINES clause, the defaults are the same as if you had written this:

      FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n'\n

      Note

      • FIELDS TERMINATED BY ',': with and only ,, | or \\t as delimiters.
      • ENCLOSED BY '\"': with and only \" as the included character.
      • LINES TERMINATED BY '\\n': Use and only use \\n or \\r\\n as the line separator.

      FIELDS TERMINATED BY

      FIELDS TERMINATED BY specifies the delimiter for a field. The FIELDS TERMINATED BY values can be more than one character.

      For example, to read the comma-delimited file, the correct statement is:

      LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',';\n

      If instead you tried to read the file with the statement shown following, it would not work because it instructs LOAD DATA to look for tabs between fields:

      LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY '\\t';\n

      The likely result is that each input line would be interpreted as a single field. You may encounter an error of \"ERROR 20101 (HY000): internal error: the table column is larger than input data column\".

      FIELDS ENCLOSED BY

      FIELDS TERMINATED BY option specifies the character enclose the input values. ENCLOSED BY value must be a single character. If the input values are not necessarily enclosed within quotation marks, use OPTIONALLY before the ENCLOSED BY option.

      For example, if some input values are enclosed within quotation marks, some are not:

      LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"';\n

      LINES TERMINATED BY

      LINES TERMINATED BY specifies the delimiter for the a line. The LINES TERMINATED BY values can be more than one character.

      For example, if the lines in a csv file are terminated by carriage return/newline pairs, you can load it with LINES TERMINATED BY '\\r\\n':

      LOAD DATA INFILE 'data.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n  LINES TERMINATED BY '\\r\\n';\n

      LINE STARTING BY

      If all the input lines have a common prefix that you want to ignore, you can use LINES STARTING BY 'prefix_string' to skip the prefix and anything before it. If a line does not include the prefix, the entire line is skipped. Suppose that you issue the following statement:

      LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1\n  FIELDS TERMINATED BY ','  LINES STARTING BY 'xxx';\n

      If the data file looks like this:

      xxx\"abc\",1\nsomething xxx\"def\",2\n\"ghi\",3\n

      The resulting rows are (\"abc\",1) and (\"def\",2). The third row in the file is skipped because it does not contain the prefix.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#set","title":"SET","text":"

      MatrixOne only supports SET column_name=nullif(column_name,expr). That is, when column_name = expr, it returns NULL; otherwise, it returns the original value of column_name. For example, SET a=nullif(a,1), if a=1, returns NULL; otherwise, it returns the original value of column a.

      By setting the parameter, you can use SET column_name=nullif(column_name,\"null\") to return the NULL value in the column when loading the file.

      Example

      1. The details of the local file test.txt are as follows:

        id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\nnull,wederTom,\"man\"\n
      2. Create a table named user in MatrixOne:

        create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\n
      3. Load test.txt into the table user:

        LOAD DATA INFILE '/tmp/test.txt' INTO TABLE user SET id=nullif(id,\"null\");\n
      4. The result of the talbe is as below:

        select * from user;\n+------+-----------+------+\n| id   | user_name | sex  |\n+------+-----------+------+\n|    1 | weder     | man  |\n|    2 | tom       | man  |\n| null | wederTom  | man  |\n+------+-----------+------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#parallel","title":"PARALLEL","text":"

      For a sizeable well-formed file, such as a JSOLLines file or a CSV file with no line breaks in a line of data, you can use PARALLEL to load the file in parallel to speed up the loading.

      For example, for a large file of 2 G, use two threads to load; the second thread first splits and locates the 1G position, then reads and loads backward. In this way, two threads can read large files at the same time, and each thread can read 1G of data.

      Enable/Disable Parallel Loading Command Line Example:

      --  Enable Parallel Loading\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'TRUE';\n\n--  Disable Parallel Loading\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'FALSE';\n\n--  Parallel loading is disabled by default\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES;\n

      Note

      [PARALLEL {'TRUE' | 'FALSE'}] currently only support TRUE or FALSE and are not case-sensitive.

      Note: If the PARALLEL field is not added in the LOAD statement, for CSV files, parallel loading is disabled by default; for JSOLLines files, parallel loading is enabled by default. If there is a line terminator in the CSV file, such as '\\n', otherwise it may cause data errors when the file is loaded. If the file is too large, manually splitting the file from the '\\n' as the starting and ending point is recommended, then enabling parallel loading.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#supported-file-formats","title":"Supported file formats","text":"

      In MatrixOne's current release, LOAD DATA supports CSV(comma-separated values) format and JSONLines format file. See full tutorials for loading csv and jsonline.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#csv-format-standard-description","title":"CSV format standard description","text":"

      The CSV format loaded by MatrixOne conforms to the RFC4180 standard, and the CSV format is specified as follows:

      1. Each record is on a separate line, separated by a newline character (CRLF):

        aaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

      2. The last record in the file can have a terminating newline or no terminating newline (CRLF):

        aaa,bbb,ccc CRLF\nzzz,yyy,xxx\n

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

      3. An optional header line appears as the first line of the file and has the same format as a standard record line. For example:

        field_name,field_name,field_name CRLF\naaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n

        Imported into the table as follows:

        +------------+------------+------------+ | field_name | field_name | field_name | +------------+------------+------------+ | aaa | bbb | ccc | | zzz | yyy | xxx | +------------+------------+------------+

      4. In the header and each record, there may be one or more fields separated by commas. Whitespace within a field is part of the field and should not be ignored. A comma cannot follow the last field in each record. For example:

        aaa,bbb,ccc\n

        Or:

        a aa, bbb,cc c\n

        Both examples are correct.

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | bbb | ccc | +---------+---------+---------+

        Or:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | a aa | bbb | cc c | +---------+---------+---------+

      5. Each field can be enclosed in double quotes or not. Double quotes cannot appear inside a field if the field is not enclosed in double-quotes. For example:

        \"aaa\",\"bbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n

        Or:

        \"aaa\",\"bbb\",ccc CRLF\nzzz,yyy,xxx\n

        Both examples are correct.

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | bbb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

      6. Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes. For example:

        \"aaa\",\"b CRLF\nbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b bb | ccc | | zzz | yyy | xxx | +---------+---------+---------+

      7. If double quotation marks are used to enclose the field, then multiple double quotation marks appearing in the field must also be enclosed in double quotation marks; otherwise, the first quotation mark of two double quotation marks in the field will be parsed as an escape character, thus keep a single, double quote. For example:

        \"aaa\",\"b\",\"bb\",\"ccc\"\n

        The above CSV will parse \"b\"\"bb\" into b\"bb; if the correct field is b\"\"bb, then it should be written as:

        \"aaa\",\"b\"\"\"\"bb\",\"ccc\"\n

        Or:

        \"aaa\",b\"\"bb,\"ccc\"\n

        Imported into the table as follows:

        +---------+---------+---------+ | col1 | col2 | col3 | +---------+---------+---------+ | aaa | b\"\"bb | ccc | +---------+---------+---------+

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#examples","title":"Examples","text":"

      The SSB Test is an example of LOAD DATA syntax. Complete a SSB Test with MatrixOne

      > LOAD DATA INFILE '/ssb-dbgen-path/lineorder_flat.tbl ' INTO TABLE lineorder_flat;\n

      The above statement means: load the lineorder_flat.tbl data set under the directory path /ssb-dbgen-path/ into the MatrixOne data table lineorder_flat.

      You can also refer to the following syntax examples to quickly understand LOAD DATA:

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#example-1-load-csv","title":"Example 1: LOAD CSV","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#simple-example","title":"Simple example","text":"

      The data in the file locally named char_varchar.csv is as follows:

      a|b|c|d\n\"a\"|\"b\"|\"c\"|\"d\"\n'a'|'b'|'c'|'d'\n\"'a'\"|\"'b'\"|\"'c'\"|\"'d'\"\n\"aa|aa\"|\"bb|bb\"|\"cc|cc\"|\"dd|dd\"\n\"aa|\"|\"bb|\"|\"cc|\"|\"dd|\"\n\"aa|||aa\"|\"bb|||bb\"|\"cc|||cc\"|\"dd|||dd\"\n\"aa'|'||aa\"|\"bb'|'||bb\"|\"cc'|'||cc\"|\"dd'|'||dd\"\naa\"aa|bb\"bb|cc\"cc|dd\"dd\n\"aa\"aa\"|\"bb\"bb\"|\"cc\"cc\"|\"dd\"dd\"\n\"aa\"\"aa\"|\"bb\"\"bb\"|\"cc\"\"cc\"|\"dd\"\"dd\"\n\"aa\"\"\"aa\"|\"bb\"\"\"bb\"|\"cc\"\"\"cc\"|\"dd\"\"\"dd\"\n\"aa\"\"\"\"aa\"|\"bb\"\"\"\"bb\"|\"cc\"\"\"\"cc\"|\"dd\"\"\"\"dd\"\n\"aa\"\"|aa\"|\"bb\"\"|bb\"|\"cc\"\"|cc\"|\"dd\"\"|dd\"\n\"aa\"\"\"\"|aa\"|\"bb\"\"\"\"|bb\"|\"cc\"\"\"\"|cc\"|\"dd\"\"\"\"|dd\"\n|||\n||||\n\"\"|\"\"|\"\"|\n\"\"\"\"|\"\"\"\"|\"\"\"\"|\"\"\"\"\n\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"\n

      Create a table named t1 in MatrixOne:

      mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(\n-> col1 char(225),\n-> col2 varchar(225),\n-> col3 text,\n-> col4 varchar(225)\n-> );\nQuery OK, 0 rows affected (0.02 sec)\n

      Load the data file into table t1:

      load data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|';\n

      The query result is as follows:

      mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1      | col2      | col3      | col4      |\n+-----------+-----------+-----------+-----------+\n| a         | b         | c         | d         |\n| a         | b         | c         | d         |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| 'a'       | 'b'       | 'c'       | 'd'       |\n| aa|aa     | bb|bb     | cc|cc     | dd|dd     |\n| aa|       | bb|       | cc|       | dd|       |\n| aa|||aa   | bb|||bb   | cc|||cc   | dd|||dd   |\n| aa'|'||aa | bb'|'||bb | cc'|'||cc | dd'|'||dd |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"aa     | bb\"bb     | cc\"cc     | dd\"dd     |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"\"aa    | bb\"\"bb    | cc\"\"cc    | dd\"\"dd    |\n| aa\"|aa    | bb\"|bb    | cc\"|cc    | dd\"|dd    |\n| aa\"\"|aa   | bb\"\"|bb   | cc\"\"|cc   | dd\"\"|dd   |\n|           |           |           |           |\n|           |           |           |           |\n|           |           |           |           |\n| \"         | \"         | \"         | \"         |\n| \"\"        | \"\"        | \"\"        | \"\"        |\n+-----------+-----------+-----------+-----------+\n20 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#add-conditional-example","title":"Add conditional Example","text":"

      Following the example above, you can modify the LOAD DATA statement and add LINES STARTING BY 'aa' ignore 10 lines; at the end of the statement to experience the difference:

      delete from t1;\nload data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|' LINES STARTING BY 'aa' ignore 10 lines;\n

      The query result is as follows:

      mysql> select * from t1;\n+---------+---------+---------+---------+\n| col1    | col2    | col3    | col4    |\n+---------+---------+---------+---------+\n| aa\"aa   | bb\"bb   | cc\"cc   | dd\"dd   |\n| aa\"\"aa  | bb\"\"bb  | cc\"\"cc  | dd\"\"dd  |\n| aa\"\"aa  | bb\"\"bb  | cc\"\"cc  | dd\"\"dd  |\n| aa\"|aa  | bb\"|bb  | cc\"|cc  | dd\"|dd  |\n| aa\"\"|aa | bb\"\"|bb | cc\"\"|cc | dd\"\"|dd |\n|         |         |         |         |\n|         |         |         |         |\n|         |         |         |         |\n| \"       | \"       | \"       | \"       |\n| \"\"      | \"\"      | \"\"      | \"\"      |\n+---------+---------+---------+---------+\n10 rows in set (0.00 sec)\n

      As you can see, the query result ignores the first line and and ignores the common prefix aa.

      For more information on loding csv, see Import the .csv data.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#example-2-load-jsonlines","title":"Example 2: LOAD JSONLines","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#simple-example_1","title":"Simple example","text":"

      The data in the file locally named jsonline_array.jl is as follows:

      [true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11,[\"1\",2,null,false,true,{\"q\":1}],\"1qaz\",null,null]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\",{\"c\":1,\"b\":[\"a\",\"b\",{\"q\":4}]},\"1aza\",null,null]\n

      Create a table named t1 in MatrixOne:

      mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(col1 bool,col2 int,col3 varchar(100), col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float,col9 json,col10 text,col11 json,col12 bool);\nQuery OK, 0 rows affected (0.03 sec)\n

      Load the data file into table t1:

      load data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1;\n

      The query result is as follows:

      mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4       | col5                | col6                | col7 | col8   | col9                                  | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | [\"1\", 2, null, false, true, {\"q\": 1}] | 1qaz  | NULL  | NULL  |\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1}   | 1aza  | NULL  | NULL  |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#add-conditional-example_1","title":"Add conditional Example","text":"

      Following the example above, you can modify the LOAD DATA statement and add ignore 1 lines at the end of the statement to experience the difference:

      delete from t1;\nload data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1 ignore 1 lines;\n

      The query result is as follows:

      mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4       | col5                | col6                | col7 | col8   | col9                                | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| true |    1 | var  | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 |   18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1} | 1aza  | NULL  | NULL  |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n1 row in set (0.00 sec)\n

      As you can see, the query result ignores the first line.

      For more information on loding JSONLines, see Import the JSONLines data.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#constraints","title":"Constraints","text":"
      1. The REPLACE and IGNORE modifiers control handling of new (input) rows that duplicate existing table rows on unique key values (PRIMARY KEY or UNIQUE index values) are not supported in MatrixOne yet.
      2. Input pre-pressing with SET is supported very limitedly. Only SET columns_name=nullif(expr1,expr2) is supported.
      3. When enabling the parallel loading, it must be ensured that each row of data in the file does not contain the specified line terminator, such as '\\n'; otherwise, it will cause data errors during file loading.
      4. The parallel loading of files requires that the files be in uncompressed format, and parallel loading of files in compressed form is not currently supported.
      5. When you use load data local, you need to use the command line to connect to the MatrixOne service host: mysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile.
      6. MatrixOne does not support ESCAPED BY currently. Writing or reading special characters differs from MySQL to some extent.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/","title":"REPLACE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#description","title":"Description","text":"

      REPLACE is a string function and a data manipulation statement for a replacement operation. The REPLACE statement functions to insert data into the table. If there is already a qualified record in the table, the record will be deleted first, and then new data will be inserted. New data will be inserted directly if there is no matching record in the table.

      REPLACE is typically used on tables with unique constraints.

      • The REPLACE statement requires that a primary key or unique index exist in the table to determine whether the same record exists.
      • When using the REPLACE statement to insert a new record, the old record will be deleted if a record with the same primary key or unique index already exists. Then a new record will be inserted, which may cause the value of the auto-increment column to change.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#syntax","title":"Syntax","text":"
      REPLACE\n    [INTO] tbl_name\n    [(col_name [, col_name] ...)]\n    { VALUES(value_list)\n      |\n      VALUES row_constructor_list\n    }\n\nREPLACE\n    [INTO] tbl_name\n    SET assignment_list\n\nvalue:\n    {expr | DEFAULT}\n\nvalue_list:\n    value [, value] ...\n\nrow_constructor_list:\n    ROW(value_list)\n\nassignment:\n    col_name = value\n\nassignment_list:\n    assignment [, assignment] ...\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#explanations","title":"Explanations","text":"

      The REPLACE statement inserts data into a table or updates existing data. Its syntax has two forms: an insert form based on column names and an update form based on the SET clause.

      The following is an explanation of each parameter:

      1. INTO: optional keyword indicating which table to insert or update data.

      2. tbl_name: Indicates the table's name to insert or update data.

      3. col_name: Optional parameter indicating the column's name to be inserted or updated. In the insert form, the column to be inserted can be specified by column name; in the update form, the column to be updated can be specified.

      4. value: Indicates the value to be inserted or updated. It can be a concrete expression (expr) or a default value (DEFAULT).

      5. value_list: Indicates a set of values \u200b\u200bto be inserted. Separate multiple values \u200b\u200bwith commas.

      6. (Not supported yet) row_constructor_list: Indicates a row consisting of a set of values \u200b\u200bfor insertion. Values \u200b\u200bon each row are enclosed in parentheses and separated by commas.

      7. assignment: Indicates the association between a column name and its corresponding value, which is used to update the form.

      8. assignment_list: Indicates the association of multiple column names and corresponding values, which is used to update the form\u2014separate multiple column names and values \u200b\u200bwith commas.

      Note

      • When using the insert form, you can use the VALUES keyword followed by value_list means inserting one row of data.
      • When using the update form, use the SET keyword followed by assignment_list to specify the columns to update and the corresponding values.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#examples","title":"Examples","text":"
      create table names(id int PRIMARY KEY,name VARCHAR(255),age int);\n\n-- Insert a row of data, id=1, name=\"Abby\", age=24\nreplace into names(id, name, age) values(1,\"Abby\", 24);\nmysql> select name, age from names where id = 1;\n+------+------+\n| name | age  |\n+------+------+\n| Abby |   24 |\n+------+------+\n1 row in set (0.00 sec)\n\nmysql> select * from names;\n+------+------+------+\n| id   | name | age  |\n+------+------+------+\n|    1 | Abby |   24 |\n+------+------+------+\n1 row in set (0.00 sec)\n\n-- Use the replace statement to update the record with id=1 to have the values \u200b\u200b\"Bob\" and 25 in the name and age columns\nreplace into names(id, name, age) values(1,\"Bobby\", 25);\n\nmysql> select name, age from names where id = 1;\n+-------+------+\n| name  | age  |\n+-------+------+\n| Bobby |   25 |\n+-------+------+\n1 row in set (0.00 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id   | name  | age  |\n+------+-------+------+\n|    1 | Bobby |   25 |\n+------+-------+------+\n1 row in set (0.01 sec)\n\n-- Use the replace statement to insert a row of data, id=2, name=\"Ciro\", age is NULL\nreplace into names set id = 2, name = \"Ciro\";\n\nmysql> select name, age from names where id = 2;\n+------+------+\n| name | age  |\n+------+------+\n| Ciro | NULL |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id   | name  | age  |\n+------+-------+------+\n|    1 | Bobby |   25 |\n|    2 | Ciro  | NULL |\n+------+-------+------+\n2 rows in set (0.00 sec)\n\n-- Use the replace statement to update the record with id=2 to have the value of the name column \"Ciro\" and the value of the age column 17\nreplace into names set id = 2, name = \"Ciro\", age = 17;\n\nmysql> select name, age from names where id = 2;\n+------+------+\n| name | age  |\n+------+------+\n| Ciro |   17 |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id   | name  | age  |\n+------+-------+------+\n|    1 | Bobby |   25 |\n|    2 | Ciro  |   17 |\n+------+-------+------+\n2 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/replace/#constraints","title":"Constraints","text":"

      MatrixOne does not currently support rows of values \u200b\u200binserted using the VALUES row_constructor_list parameter.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/","title":"UPDATE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#description","title":"Description","text":"

      The UPDATE statement is used to modify the existing records in a table.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#syntax","title":"Syntax","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#single-table-syntax","title":"Single-table Syntax","text":"
      UPDATE table_reference\n    SET assignment_list\n    [WHERE where_condition]\n    [ORDER BY ...]\n    [LIMIT row_count]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#explanations","title":"Explanations","text":"
      • The UPDATE statement updates columns of existing rows in the named table with new values.
      • The SET clause indicates which columns to modify and the values they should be given. Each value can be given as an expression, or the keyword DEFAULT to set a column explicitly to its default value.
      • The WHERE clause, if given, specifies the conditions that identify which rows to update. With no WHERE clause, all rows are updated.
      • If the ORDER BY clause is specified, the rows are updated in the order that is specified.
      • The LIMIT clause places a limit on the number of rows that can be updated.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#examples","title":"Examples","text":"
      • Single-table Examples
      CREATE TABLE t1 (a bigint(3), b bigint(5) primary key);\ninsert INTO t1 VALUES (1,1),(1,2);\nupdate t1 set a=2 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 |    1 |\n|    1 |    2 |\n+------+------+\n
      • Multiple-table Examples
      drop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values(1), (2), (4);\ndrop table if exists t2;\ncreate table t2 (b int);\ninsert into t2 values(1), (2), (3);\nupdate t1, t2 set a = 1, b =2;\n\nmysql> select * from t1;\n+------+\n| a    |\n+------+\n|    1 |\n|    1 |\n|    1 |\n+------+\n\nupdate t1, t2 set a = null, b =null;\n\nmysql> select * from t2;\n+------+\n| b    |\n+------+\n| NULL |\n| NULL |\n| NULL |\n+------+\nmysql> select * from t1;\n+------+\n| a    |\n+------+\n| NULL |\n| NULL |\n| NULL |\n+------+\n

      Multiple-table join Syntax is also supported.

      drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a int, b int, c int);\ninsert into t1 values(1, 2, 3), (4, 5, 6), (7, 8, 9);\ncreate table t2 (a int, b int, c int);\ninsert into t2 values(1, 2, 3), (4, 5, 6), (7, 8, 9);\nupdate t1 join t2 on t1.a = t2.a set t1.b = 222, t1.c = 333, t2.b = 222, t2.c = 333;\n\nmysql> select * from t1;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 |  222 |  333 |\n|    4 |  222 |  333 |\n|    7 |  222 |  333 |\n+------+------+------+\n\nmysql> with t11 as (select * from (select * from t1) as t22) update t11 join t2 on t11.a = t2.a set t2.b = 666;\n\nmysql> select * from t2;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 |  666 |  333 |\n|    4 |  666 |  333 |\n|    7 |  666 |  333 |\n+------+------+------+\n3 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/","title":"CURRENT_ROLE()","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/#description","title":"Description","text":"

      Returns the role of the current session.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/#syntax","title":"Syntax","text":"
      SELECT CURRENT_ROLE();\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/current_role/#examples","title":"Examples","text":"
      mysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin        |\n+----------------+\n1 row in set (0.00 sec)\n\n-- Create a role and switch to the new role\ncreate role use_role_1;\ngrant all on database * to use_role_1;\ngrant use_role_1 to root;\nset role use_role_1;\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| use_role_1     |\n+----------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/","title":"LAST_INSERT_ID()","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#description","title":"Description","text":"

      The LAST_INSERT_ID() function returns the AUTO_INCREMENT id of the last row that has been inserted or updated in a table.

      When the argument is NULL, LAST_INSERT_ID() returns a value representing the first automatically generated value successfully inserted for an AUTO_INCREMENT column as a result of the most recently executed INSERT statement; if you haven't inserted a column before, then the return value start at 1, and if you've inserted a column before, then the return value of the AUTO_INCREMENT column increases by 1.

      The value of LAST_INSERT_ID() remains unchanged if no rows are successfully inserted.

      In MySQL, if you insert multiple rows using a single INSERT statement, LAST_INSERT_ID() returns the value generated for the first inserted row only. For example:

      mysql> CREATE TABLE t (id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, name VARCHAR(10) NOT NULL);\nmysql> INSERT INTO t VALUES (NULL, 'Bob');\nmysql> SELECT * FROM t;\n+----+------+\n| id | name |\n+----+------+\n|  1 | Bob  |\n+----+------+\n\nmysql> SELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|                1 |\n+------------------+\n\nmysql> INSERT INTO t VALUES (NULL, 'Mary'), (NULL, 'Jane'), (NULL, 'Lisa');\n\nmysql> SELECT * FROM t;\n+----+------+\n| id | name |\n+----+------+\n|  1 | Bob  |\n|  2 | Mary |\n|  3 | Jane |\n|  4 | Lisa |\n+----+------+\n\nmysql> SELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n|                2 |\n+------------------+\n

      But in MatrixOne, we have a different behavior; if you insert multiple rows using a single INSERT statement, LAST_INSERT_ID() returns the value generated for the last inserted row. Like the example above, when you execute INSERT INTO t VALUES (NULL, 'Mary'), (NULL, 'Jane'), (NULL, 'Lisa');, the LAST_INSERT_ID() will return 4.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#syntax","title":"Syntax","text":"
      LAST_INSERT_ID(), LAST_INSERT_ID(expr)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#examples","title":"Examples","text":"
      create table t1(a int auto_increment primary key);\ninsert into t1 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|                1 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t1 values(11);\ninsert into t1 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|               12 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t1 values(null);\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|               13 |\n+------------------+\n1 row in set (0.02 sec)\n\ncreate table t2(a int auto_increment primary key);\ninsert into t2 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|                1 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t2 values(100);\ninsert into t2 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n|              101 |\n+------------------+\n1 row in set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/","title":"LAST_QUERY_ID","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#description","title":"Description","text":"

      Returns the ID of a specified query in the current session. If no query is specified, the most recently-executed query is returned.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#syntax","title":"Syntax","text":"
      LAST_QUERY_ID( [ <num> ] )\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#arguments","title":"Arguments","text":"

      num: Specifies the query to return, based on the position of the query (within the session).

      Default: -1

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#usage-notes","title":"Usage Notes","text":"

      Positive numbers start with the first query executed in the session. For example:

      • LAST_QUERY_ID(1) returns the first query.

      • LAST_QUERY_ID(2) returns the second query.

      • LAST_QUERY_ID(6) returns the sixth query.

      Negative numbers start with the most recently-executed query in the session. For example:

      • LAST_QUERY_ID(-1) returns the most recently-executed query (equivalent to LAST_QUERY_ID()).

      • LAST_QUERY_ID(-2) returns the second most recently-executed query.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#examples","title":"Examples","text":"
      mysql> SELECT LAST_QUERY_ID(-1);\n+--------------------------------------+\n| last_query_id(-1)                    |\n+--------------------------------------+\n| af974680-b1b5-11ed-8eb9-5ad2460dea4f |\n+--------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT LAST_QUERY_ID();\n+--------------------------------------+\n| last_query_id()                      |\n+--------------------------------------+\n| 550e4d44-b1b5-11ed-8eb9-5ad2460dea4f |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/","title":"INTERSECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/#description","title":"Description","text":"

      INTERSECT returns only the different rows of two or more queries.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/#syntax","title":"Syntax","text":"
      SELECT column_list FROM table_1\nINTERSECT\nSELECT column_list FROM table_2;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/#examples","title":"Examples","text":"
      drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a smallint, b bigint, c int);\ninsert into t1 values (1,2,3);\ninsert into t1 values (1,2,3);\ninsert into t1 values (3,4,5);\ninsert into t1 values (4,5,6);\ninsert into t1 values (4,5,6);\ninsert into t1 values (1,1,2);\ncreate table t2 (a smallint, b bigint, c int);\ninsert into t2 values (1,2,3);\ninsert into t2 values (3,4,5);\ninsert into t2 values (1,2,1);\n\nmysql> select * from t1 intersect select * from t2;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 |    2 |    3 |\n|    3 |    4 |    5 |\n+------+------+------+\n2 rows in set (0.01 sec)\n\nmysql> select a, b from t1 intersect select b, c from t2;\n+------+------+\n| a    | b    |\n+------+------+\n|    4 |    5 |\n+------+------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/","title":"MINUS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#description","title":"Description","text":"

      MINUS compares the result of two queries and returns the different rows in the first query that are not output by the second query.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#syntax","title":"Syntax","text":"
      SELECT column_list_1 FROM table_1\nMINUS\nSELECT columns_list_2 FROM table_2;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#examples","title":"Examples","text":"
      • Example 1
      CREATE TABLE t1 (id INT PRIMARY KEY);\nCREATE TABLE t2 (id INT PRIMARY KEY);\nINSERT INTO t1 VALUES (1),(2),(3);\nINSERT INTO t2 VALUES (2),(3),(4);\n\nmysql> SELECT id FROM t1 MINUS SELECT id FROM t2;\n+------+\n| id   |\n+------+\n|    1 |\n+------+\n
      • Example 2
      drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a smallint, b bigint, c int);\ninsert into t1 values (1,2,3);\ninsert into t1 values (1,2,3);\ninsert into t1 values (3,4,5);\ninsert into t1 values (4,5,6);\ninsert into t1 values (4,5,6);\ninsert into t1 values (1,1,2);\ncreate table t2 (a smallint, b bigint, c int);\ninsert into t2 values (1,2,3);\ninsert into t2 values (3,4,5);\ninsert into t2 values (1,2,1);\n\nmysql> select * from t1 minus select * from t2;\n+------+------+------+\n| a    | b    | c    |\n+------+------+------+\n|    1 |    1 |    2 |\n|    4 |    5 |    6 |\n+------+------+------+\n\nmysql> select a, b from t1 minus select b, c from t2;\n+------+------+\n| a    | b    |\n+------+------+\n|    3 |    4 |\n|    1 |    1 |\n|    1 |    2 |\n+------+------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/","title":"SELECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#description","title":"Description","text":"

      Retrieves data from a table.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#syntax","title":"Syntax","text":"
      SELECT\n[ALL | DISTINCT ]\nselect_expr [, select_expr] [[AS] alias] ...\n[INTO variable [, ...]]\n[FROM table_references\n[WHERE where_condition]\n[GROUP BY {col_name | expr | position}\n[ASC | DESC]]\n[HAVING where_condition]\n[ORDER BY {col_name | expr | position}\n[ASC | DESC]] [ NULLS { FIRST | LAST } ]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}]\n[FOR {UPDATE}]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#explanations","title":"Explanations","text":"

      The most commonly used clauses of SELECT statements are these:

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#select_expr","title":"select_expr","text":"

      Each select_expr indicates a column that you want to retrieve. There must be at least one select_expr.

      The list of select_expr terms comprises the select list that indicates which columns to retrieve. Terms specify a column or expression or can use *-shorthand:

      • A select list consisting only of a single unqualified * can be used as shorthand to select all columns from all tables:
      SELECT * FROM t1\n
      • tbl_name.* can be used as a qualified shorthand to select all columns from the named table:
      SELECT t1.*, t2.* FROM t1\n
      • A select_expr can be given an alias using AS alias_name.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#table_references","title":"table_references","text":"
      • The FROM table_references clause indicates the table or tables from which to retrieve rows.

      • You can refer to a table within the default database as tbl_name, or as db_name.tbl_name to specify a database explicitly. You can refer to a column as col_name, tbl_name.col_name, or db_name.tbl_name.col_name. You need not specify a tbl_name or db_name.tbl_name prefix for a column reference unless the reference would be ambiguous.

      • A table reference can be aliased using tbl_name AS alias_name or tbl_name alias_name.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#where","title":"WHERE","text":"

      The WHERE clause, if given, indicates the condition or conditions that rows must satisfy to be selected. where_condition is an expression that evaluates to true for each row to be selected. The statement selects all rows if there is no WHERE clause.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#group-by","title":"GROUP BY","text":"

      Columns selected for output can be referred to in ORDER BY and GROUP BY clauses using column names, column aliases, or column positions.

      Note

      • In the GROUP BY or HAVING clauses, it is not allowed to use an alias to define another alias.
      • In the GROUP BY or HAVING clauses, the SQL engine first attempts to group or filter by column names. If the corresponding column names are not found in these clauses, it checks if aliases match and use the matched aliases as a fallback.
      • It is recommended to avoid ambiguous column references when using aliases in the GROUP BY or HAVING clauses. In such cases, the SQL engine looks for matching columns based on the aliases, and if multiple matches are found, it will raise an error.
      • In the ORDER BY clause, sorting is first attempted using aliases. If aliases are not found, the SQL engine attempts sorting using column names.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#having","title":"HAVING","text":"

      The HAVING clause, like the WHERE clause, specifies selection conditions.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#order-by","title":"ORDER BY","text":"

      To sort in reverse order, add the DESC (descending) keyword to the name of the column in the ORDER BY clause that you are sorting by. The default is ascending order; this can be specified explicitly using the ASC keyword.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#limit","title":"LIMIT","text":"

      The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#for-update","title":"FOR UPDATE","text":"

      SELECT...FOR UPDATE is mainly used to lock a set of data rows in transaction processing to prevent them from being modified by other concurrent transactions. This statement is most commonly used in \"read-modify-write\" scenarios. That is, when you need to read a data set, make changes to it, and then write the results back to the database, you don't want other transactions to modify this data set.

      Using SELECT FOR UPDATE in a transaction can lock the selected rows until the transaction ends (either by commit or rollback) and the locks are released. This way, other transactions attempting to modify these rows are blocked until the first transaction is complete.

      See the example below:

      START TRANSACTION;\n\nSELECT * FROM Orders\nWHERE OrderID = 1\nFOR UPDATE;\n

      In the above transaction, the SELECT FOR UPDATE statement selects and locks the row with OrderID 1 in the Orders table. Other transactions cannot modify this row before the transaction ends. After you have finished modifying this row, you can commit the transaction to release the lock:

      UPDATE Orders\nSET Quantity = Quantity - 1\nWHERE OrderID = 1;\n\nCOMMIT;\n

      The above UPDATE statement modifies the Quantity value of the selected row, and then the COMMIT statement commits the transaction and releases the lock. At this point, other blocked transactions can continue. If you decide not to make any changes, you can use the ROLLBACK statement to end the transaction and release the lock.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#examples","title":"Examples","text":"
      create table t1 (spID int,userID int,score smallint);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\ninsert into t1 values (null,0,99);\n\nmysql> SELECT * FROM t1 WHERE spID>2 AND userID <2 || userID >=2 OR userID < 2 LIMIT 3;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| NULL |      0 |    99 |\n|    1 |      1 |     1 |\n|    2 |      2 |     2 |\n+------+--------+-------+\n\nmysql> SELECT userID,MAX(score) max_score FROM t1 WHERE userID <2 || userID > 3 GROUP BY userID ORDER BY max_score;\n+--------+-----------+\n| userid | max_score |\n+--------+-----------+\n|      1 |         5 |\n|      6 |        10 |\n|      0 |        99 |\n|     11 |        99 |\n+--------+-----------+\n\nmysql> select userID,count(score) from t1 group by userID having count(score)>1 order by userID;\n+--------+--------------+\n| userid | count(score) |\n+--------+--------------+\n|      1 |            3 |\n+--------+--------------+\n\nmysql> select userID,count(score) from t1 where userID>2 group by userID having count(score)>1 order by userID;\nEmpty set (0.01 sec)s\n\nmysql> select * from t1 order by spID asc nulls last;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n|    1 |      1 |     1 |\n|    1 |      1 |     5 |\n|    2 |      2 |     2 |\n|    2 |      1 |     4 |\n|    3 |      3 |     3 |\n|    4 |      6 |    10 |\n|    5 |     11 |    99 |\n| NULL |      0 |    99 |\n+------+--------+-------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#constraints","title":"Constraints","text":"
      1. SELECT...FOR UPDATE currently only supports single-table queries.
      2. INTO OUTFILE is limitedly support.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/","title":"Combining Queries (UNION,\u00a0INTERSECT,\u00a0MINUS)","text":"

      The results of the two queries can be combined using the set operations UNION, INTERSECT, and MINUS. The syntax is as below:

      query1 UNION [ALL] query2\nquery1 INTERSECT [ALL] query2\nquery1 MINUS [ALL] query2\n

      Tips: Where query1 and query2 are queries that can use any of the features discussed up to this point.

      UNION effectively appends the result of query2 to the result of query1 (although there is no guarantee that this is the order in which the rows are returned). Furthermore, it eliminates duplicate rows from its result, in the same way as DISTINCT, unless UNION ALL is used.

      INTERSECT returns all rows in both the result of query1 and query2. Duplicate rows are eliminated unless INTERSECT ALL is used.

      MINUS returns all rows in the result of query1 but not in query2. (This is sometimes called the difference between two queries.) Again, duplicates are eliminated unless MINUS ALL is used.

      To calculate the union, intersection, or difference of two queries, the two queries must be \"union compatible\", which means that they return the same number of columns and the corresponding columns have compatible data types.

      Set operations can be combined, for example:

      query1 UNION query2 MINUS query3\n

      which is equivalent to:

      (query1 UNION query2) MINUS query3\n

      As shown here, you can use parentheses to control the order of evaluation. Without parentheses, UNION and MINUS associate left-to-right, but INTERSECT binds more tightly than those two operators. Thus

      query1 UNION query2 INTERSECT query3\n

      that means:

      query1 UNION (query2 INTERSECT query3)\n

      You can also surround an individual query with parentheses. This is important if the query needs to use any of the clauses discussed in the following sections, such as LIMIT. Without parentheses, you'll get a syntax error, or else the clause will be understood as applying to the output of the set operation rather than one of its inputs. For example:

      SELECT a FROM b UNION SELECT x FROM y LIMIT 10\n

      is accepted, but it means:

      (SELECT a FROM b UNION SELECT x FROM y) LIMIT 10\n

      not as below:

      SELECT a FROM b UNION (SELECT x FROM y LIMIT 10)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/#reference","title":"Reference","text":"

      For more information on the single syntax as above, see:

      • UNION
      • INTERSECT
      • MINUS
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/","title":"UNION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#description","title":"Description","text":"

      UNION combines the result from multiple SELECT statements into a single result set.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#syntax","title":"Syntax","text":"
      SELECT ... UNION [ALL | DISTINCT] SELECT ... [UNION [ALL | DISTINCT] SELECT ...]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#arguments","title":"Arguments","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#union-distinct-and-union-all","title":"UNION [DISTINCT] and UNION ALL","text":"

      By default, duplicate rows are removed from the UNION results. UNION is used as the same as UNION [DISTINCT].

      Combining the result sets of two or more queries using the UNION operator requires the following conditions:

      • All SELECT statements must have the same number and order of columns.

      • Data types must be same or convertible.

      With UNION ALL, repeated lines (if available) are retained in the result.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#order-by-and-limit-in-union","title":"ORDER BY and LIMIT In UNION","text":"

      To apply anORDER BY or LIMIT clause to an individual SELECT, parenthesize the SELECT and place the clause inside the parentheses:

      Use of ORDER BY for individual SELECT statements implies nothing about the order in which the rows appear in the final result because UNION by default produces an unordered set of rows. Therefore, ORDER BY in this context typically is used in conjunction with LIMIT, to determine the subset of the selected rows to retrieve for the SELECT, even though it does not necessarily affect the order of those rows in the final UNION result.

      For example:

      (SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10)\nUNION\n(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);\n

      Or:

      (SELECT a FROM t1 WHERE a=10 AND B=1)\nUNION\n(SELECT a FROM t2 WHERE a=11 AND B=2)\nORDER BY a LIMIT 10;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#examples","title":"Examples","text":"
      CREATE TABLE t1 (id INT PRIMARY KEY);\nCREATE TABLE t2 (id INT PRIMARY KEY);\nINSERT INTO t1 VALUES (1),(2),(3);\nINSERT INTO t2 VALUES (2),(3),(4);\n\nmysql> SELECT id FROM t1 UNION SELECT id FROM t2;\n+------+\n| id   |\n+------+\n|    4 |\n|    1 |\n|    2 |\n|    3 |\n+------+\n\nmysql> SELECT id FROM t1 UNION ALL SELECT id FROM t2;\n+------+\n| id   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n
      drop table t1;\nCREATE TABLE t1 (a INT, b INT);\nINSERT INTO t1 VALUES ROW(4,-2),ROW(5,9),ROW(10,1),ROW(11,2),ROW(13,5);\ndrop table t2;\nCREATE TABLE t2 (a INT, b INT);\nINSERT INTO t2 VALUES ROW(1,2),ROW(3,4),ROW(11,2),ROW(10,3),ROW(15,8);\n\nmysql> (SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10) UNION (SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);\n+------+\n| a    |\n+------+\n|   10 |\n|   11 |\n+------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/","title":"WITH (Common Table Expressions)","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#description","title":"Description","text":"

      Common Table Expression (CTE) is a temporary result set defined within the scope of a single statement, valid only during the execution of the query. It can self-reference and can be referenced multiple times within the same query. Its purpose is simplifying complex queries, enhance code readability, and improve maintainability. A CTE can be seen as a temporary view that exists only for the query's execution and is not visible to external queries.

      Once defined, a CTE can be referenced like a SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement.

      The WITH clause is used to specify Common Table Expressions, and the WITH clause can include one or more comma-separated clauses. Each clause provides a subquery that generates a result set and associates a name with the subquery.

      Use Cases:

      • CTEs can reuse the same subquery in multiple places, avoiding redundant logic.
      • They can simplify recursive queries, such as querying tree-structured data.
      • Complex queries can be broken down into smaller parts using CTEs, making the query logic clearer and more understandable.

      Common Table Expressions are divided into two types: non-recursive and recursive:

      • Non-recursive CTE refers to an expression in which the CTE does not reference itself. It is used to build a one-time temporary result set and does not involve recursion.

      • Recursive CTE refers to an expression in which the CTE references itself. It handles data with recursive structures, such as trees or graphs. A recursive CTE includes a base query (initial condition) in its definition, then performs recursive operations on the result of that base query until a stop condition is met.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#non-recursive-cte","title":"Non-recursive CTE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#syntax","title":"Syntax","text":"
      WITH <query_name> AS (\n    <query_definition>\n)\nSELECT ... FROM <query_name>;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#explanations","title":"Explanations","text":"
      • <query_name>: Specifies the temporary name assigned to the CTE result set. It can be any valid identifier, similar to a table or column name.

      • <query_definition>: The query statement defines the CTE result set. It can be any valid SELECT query used to create the result set of the CTE.

      • SELECT ... FROM <query_name>: This is the query executed on the CTE, where you can use the name of the CTE.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#recursive-cte","title":"Recursive CTE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#syntax_1","title":"Syntax","text":"
      WITH RECURSIVE <query_name> AS (\n    <query_definition>\n)\nSELECT ... FROM <query_name>;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#explanations_1","title":"Explanations","text":"
      • WITH RECURSIVE: Indicates that this is a recursive CTE.

      • <query_name>: Specifies the temporary name assigned to the result set of the recursive CTE. It can be any valid identifier, similar to a table or column name.

      • <query_definition>: This consists of two parts in the context of a recursive CTE:

        • Initial part: Defines the recursion's initial condition and result set.
        • Recursive function: Defines how to recursively generate the next round of the result set from the initial result set.
      • SELECT ... FROM <query_name>: Use the name of the recursive CTE to query the recursive CTE.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#guidelines-for-using-recursive-ctes","title":"Guidelines for Using Recursive CTEs","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#anchor-and-recursive-members","title":"Anchor and Recursive Members","text":"

      A recursive common table expression (CTE) must consist of at least two query definitions: an anchor member and a recursive member. The anchor member should come before the first recursive member, and you can define multiple anchor and recursive members. All CTE query definitions are considered anchor members unless they reference the CTE itself.

      Suppose you have a table named Employee that contains employee information, including fields like EmployeeID, Name, and ManagerID, representing the employee's ID, name, and ID of their manager. You can use a recursive CTE to query the hierarchical relationship between employees and subordinates.

      Assuming the table data is as follows:

      EmployeeID Name ManagerID 1 Alice NULL 2 Bob 1 3 Charlie 1 4 David 2 5 Eve 2 6 Frank 3

      Here's an example of using a recursive CTE to query the hierarchical relationship between employees and their subordinates:

      WITH RECURSIVE EmployeeHierarchy AS (\n-- Anchor member: Find top-level employees\nSELECT EmployeeID, Name, ManagerID, 0 AS Level\nFROM Employee\nWHERE ManagerID IS NULL\n\nUNION ALL\n\n-- Recursive member: Recursively query subordinate employees\nSELECT e.EmployeeID, e.Name, e.ManagerID, eh.Level + 1\nFROM Employee AS e\nJOIN EmployeeHierarchy AS eh ON e.ManagerID = eh.EmployeeID\n)\nSELECT Name, Level\nFROM EmployeeHierarchy;\n

      In the above example:

      • The anchor member selects top-level employees (with ManagerID as NULL) and sets their level (Level) to 0.
      • The recursive member queries subordinate employees based on the previous round's results (EmployeeHierarchy), incrementing the level.
      • The final query uses SELECT to retrieve employee names and levels from the recursive CTE.

      Executing this query will provide information about the hierarchical relationship between employees and their subordinates. Both anchor and recursive members together form the structure of a recursive query. On the other hand, a non-recursive CTE is used to create a temporary result set with a single query definition, and you only need to reference this CTE in your query without concerning anchor and recursive members.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#operators-and-statement-requirements","title":"Operators and Statement Requirements","text":"
      • Set Operators: Anchor members must be combined using set operators (such as UNION ALL, UNION, INTERSECT, or EXCEPT). Only UNION ALL is allowed between the last anchor member and the first recursive member, as well as when combining multiple recursive members.

      • Column Matching: The number of columns in anchor and recursive members must be the same.

      • Data Types: Columns in the recursive member must have the same data types as the corresponding columns in the anchor member.

      • FROM Clause: The FROM clause of a recursive member can only reference the CTE expression_name once.

      • Unsupported Features: Certain features are not allowed in the CTE_query_definition of a recursive member, including:

        • Using the SELECT DISTINCT keyword for distinct queries.
        • Using GROUP BY to group results.
        • Using HAVING to filter results after grouping.
        • Scalar aggregation applies an aggregate function (like SUM, AVG, etc.) to a set of rows and returns a single value.
        • Outer join operations like LEFT, RIGHT, and OUTER JOIN (though INNER JOIN is allowed).
        • Subqueries.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#examples","title":"Examples","text":"
      • Non-recursive CTE example:
      CREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nsalary INT\n);\n\nINSERT INTO employees (id, name, salary) VALUES\n(1, 'Alice', 50000),\n(2, 'Bob', 60000),\n(3, 'Charlie', 75000),\n(4, 'David', 55000),\n(5, 'Eve', 80000);\n\n-- Query employees whose salary is higher than the average salary\nmysql> WITH avg_salary AS (\nSELECT AVG(salary) AS avg_salary FROM employees)\nSELECT name, salary\nFROM employees\nJOIN avg_salary ON salary > avg_salary.avg_salary;\n+---------+--------+\n| name    | salary |\n+---------+--------+\n| Charlie |  75000 |\n| Eve     |  80000 |\n+---------+--------+\n2 rows in set (0.00 sec)\n
      • Recursive CTE example:
      CREATE TABLE employees_hierarchy (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nmanager_id INT\n);\n\nINSERT INTO employees_hierarchy (id, name, manager_id) VALUES\n(1, 'Alice', NULL),\n(2, 'Bob', 1),\n(3, 'Charlie', 1),\n(4, 'David', 2),\n(5, 'Eve', 2),\n(6, 'Frank', 3);\n\n-- Query an employee and all his employees\nmysql> WITH RECURSIVE employee_hierarchy_cte (id, name, manager_id, level) AS (\nSELECT id, name, manager_id, 0\nFROM employees_hierarchy\nWHERE name = 'Alice'\nUNION ALL\nSELECT e.id, e.name, e.manager_id, eh.level + 1\nFROM employees_hierarchy AS e\nJOIN employee_hierarchy_cte AS eh ON e.manager_id = eh.id\n)\nSELECT name, level\nFROM employee_hierarchy_cte;\n+---------+-------+\n| name    | level |\n+---------+-------+\n| Alice   |     0 |\n| Bob     |     1 |\n| Charlie |     1 |\n| David   |     2 |\n| Eve     |     2 |\n| Frank   |     2 |\n+---------+-------+\n6 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/","title":"FULL JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#description","title":"Description","text":"

      The FULL JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records.

      note

      FULL OUTER JOIN and FULL JOIN are the same.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#syntax","title":"Syntax","text":"
      > SELECT column_name(s)\nFROM table1\nFULL OUTER JOIN table2\nON table1.column_name=table2.column_name;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#examples","title":"Examples","text":"
      drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 full join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n+----------+--------------------+------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/","title":"INNER JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#description","title":"Description","text":"

      The INNER JOIN keyword selects records that have matching values in both tables.(Same as JOIN)

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#syntax","title":"Syntax","text":"
      > SELECT column_name(s)\nFROM table1\nINNER JOIN table2\nON table1.column_name = table2.column_name;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#examples","title":"Examples","text":"
      drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n+----------+--------------------+------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/","title":"JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/#description","title":"Description","text":"

      The JOIN statement is used to combine rows from two or more tables.

      The following figure shows seven usages of LEFT JOIN, RIGHT JOIN, INNER JOIN, and OUTER JOIN.

      • LEFT JOIN
      SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL
      • RIGHT JOIN
      SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL
      • INNER JOIN
      SELECT [select_list] FROM TableA A INNER JOIN TableB B ON A.Key=B.Key
      • FULL JOIN
      SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL OR B.Key IS NULL

      For more information, see the reference below:

      • LEFT JOIN
      • RIGHT JOIN
      • INNER JOIN
      • FULL JOIN
      • OUTER JOIN
      • NATURAL JOIN
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/","title":"LEFT JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/#description","title":"Description","text":"

      The LEFT JOIN keyword returns all records from the left table (table1), and the matching records from the right table (table2). The result is 0 records from the right side, if there is no match.

      note

      In some databases LEFT JOIN is called LEFT OUTER JOIN.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/#syntax","title":"Syntax","text":"
      > SELECT column_name(s)\nFROM table1\nLEFT JOIN table2\nON table1.column_name=table2.column_name;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/#examples","title":"Examples","text":"
      drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 left join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n| NULL     | NULL               |    0 |\n+----------+--------------------+------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/","title":"NATURAL JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#description","title":"Description","text":"

      The NATURAL JOIN of two tables is defined to be semantically equivalent to an INNER JOIN or a LEFT JOIN with a USING clause that names all columns that exist in both tables.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#syntax","title":"Syntax","text":"
      > SELECT table_column1, table_column2...\nFROM table_name1\nNATURAL JOIN table_name2;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#examples","title":"Examples","text":"
      create table t1(id int,desc1 varchar(50),desc2 varchar(50));\ncreate table t2(id int,desc3 varchar(50),desc4 varchar(50));\nINSERT INTO t1(id,desc1,desc2) VALUES(100,'desc11','desc12'),(101,'desc21','desc22'),(102,'desc31','desc32');\nINSERT INTO t2(id,desc3,desc4) VALUES(101,'desc41','desc42'),(103,'desc51','desc52'),(105,'desc61','desc62');\n\nmysql> SELECT t1.id,t2.id,desc1,desc2,desc3,desc4 FROM t1 NATURAL JOIN t2;\n+------+------+--------+--------+--------+--------+\n| id   | id   | desc1  | desc2  | desc3  | desc4  |\n+------+------+--------+--------+--------+--------+\n|  101 |  101 | desc21 | desc22 | desc41 | desc42 |\n+------+------+--------+--------+--------+--------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/","title":"OUTER JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/#description","title":"Description","text":"

      When performing an INNER JOIN, rows from either table that are unmatched in the other table are not returned. In an OUTER JOIN, unmatched rows in one or both tables can be returned. There are a few types of outer joins:

      • LEFT JOIN returns only unmatched rows from the left table. For more information, see LEFT JOIN.
      • RIGHT JOIN returns only unmatched rows from the right table.For more information, see RIGHT JOIN.
      • FULL OUTER JOIN returns unmatched rows from both tables.For more information, see FULL JOIN.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/#examples","title":"Examples","text":"
      create table t1 (a1 int, a2 char(3));\ninsert into t1 values(10,'aaa'), (10,null), (10,'bbb'), (20,'zzz');\ncreate table t2(a1 char(3), a2 int, a3 real);\ninsert into t2 values('AAA', 10, 0.5);\ninsert into t2 values('BBB', 20, 1.0);\n\nmysql> select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10;\n+------+------+------+------+\n| a1   | a2   | a1   | a2   |\n+------+------+------+------+\n|   10 | aaa  | AAA  |   10 |\n|   10 | aaa  | BBB  |   20 |\n|   10 | NULL | AAA  |   10 |\n|   10 | NULL | BBB  |   20 |\n|   10 | bbb  | AAA  |   10 |\n|   10 | bbb  | BBB  |   20 |\n|   20 | zzz  | NULL | NULL |\n+------+------+------+------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/","title":"RIGHT JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#description","title":"Description","text":"

      The RIGHT JOIN keyword returns all records from the right table (table2), and the matching records from the left table (table1). The result is NULL records from the left side, if there is no match.

      note

      In some databases RIGHT JOIN is called RIGHT OUTER JOIN.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#syntax","title":"Syntax","text":"
      > SELECT column_name(s)\nFROM table1\nRIGHT JOIN table2\nON table1.column_name=table2.column_name;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#examples","title":"Examples","text":"
      drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 right join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n+----------+--------------------+------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/","title":"Comparisons Using Subqueries","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#description","title":"Description","text":"

      The most common use of a subquery is in the form:

      non_subquery_operand comparison_operator (subquery)\n

      Where comparison_operator is one of these operators:

      =  >  <  >=  <=  <>  !=  <=>\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#syntax","title":"Syntax","text":"
      > SELECT column_name(s) FROM table_name WHERE 'a' = (SELECT column1 FROM t1)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#examples","title":"Examples","text":"
      create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t3 values (6),(7),(3);\n\nmysql> select * from t3 where a = (select b from t2);\nERROR 1105 (HY000): scalar subquery returns more than 1 row\nmysql> select * from t3 where a = (select distinct b from t2);\n+------+\n| a    |\n+------+\n|    7 |\n+------+\n1 rows in set (0.01 sec)\n\nmysql> select a,b from t4 where a > ( select a ,b from t2 where a>1);\nERROR 1105 (HY000): Internal error: Unknow type TUPLE\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/","title":"Derived Tables","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#description","title":"Description","text":"

      This topic describes subqueries that occur as nested SELECT statements in the FROM clause of an outer SELECT statement. Such subqueries are sometimes called derived tables or table expressions because the outer query uses the results of the subquery as a data source.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#syntax","title":"Syntax","text":"

      Every table in a FROM clause must have a name, therefore the [AS] name clause is mandatory. Any columns in the subquery select list must have unique names.

      > SELECT ... FROM (subquery) [AS] name ...\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#examples","title":"Examples","text":"
      CREATE TABLE tb1 (c1 INT, c2 CHAR(5), c3 FLOAT);\nINSERT INTO tb1 VALUES (1, '1', 1.0);\nINSERT INTO tb1 VALUES (2, '2', 2.0);\nINSERT INTO tb1 VALUES (3, '3', 3.0);\n\nmysql> select * from tb1;\n+------+------+--------+\n| c1   | c2   | c3     |\n+------+------+--------+\n|    1 | 1    | 1.0000 |\n|    2 | 2    | 2.0000 |\n|    3 | 3    | 3.0000 |\n+------+------+--------+\n3 rows in set (0.03 sec)\n\nmysql> SELECT sc1, sc2, sc3 FROM (SELECT c1 AS sc1, c2 AS sc2, c3*3 AS sc3 FROM tb1) AS sb WHERE sc1 > 1;\n+------+------+--------+\n| sc1  | sc2  | sc3    |\n+------+------+--------+\n|    2 | 2    | 6.0000 |\n|    3 | 3    | 9.0000 |\n+------+------+--------+\n2 rows in set (0.02 sec)\n
      • Subquery with Join:
      create table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values('000','NewYorkPublicLibra',1);\ninsert into t3 values('001','NewYorkPublicLibra',2);\ninsert into t3 values('002','NewYorkPublicLibra',3);\ninsert into t3 values('003','NewYorkPublicLibra',4);\ninsert into t3 values('004','NewYorkPublicLibra',5);\ninsert into t3 values('005','NewYorkPublicLibra',6);\ninsert into t3 values('006','SanFransiscoPublic',5);\ninsert into t3 values('007','BerkeleyPublic1',3);\ninsert into t3 values('007','BerkeleyPublic2',3);\ninsert into t3 values('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select * from (select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1) sub ;\n+----------+--------------------+------+\n| city     | libname1           | a    |\n+----------+--------------------+------+\n| NewYork  | NewYorkPublicLibra |    6 |\n| SanFran  | SanFransiscoPublic |    1 |\n| Berkeley | BerkeleyPublic1    |    1 |\n| Berkeley | BerkeleyPublic2    |    1 |\n+----------+--------------------+------+\n4 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/","title":"Subqueries with ALL","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#description","title":"Description","text":"

      The word ALL, which must follow a comparison operator, means \"return TRUE if the comparison is TRUE for ALL of the values in the column that the subquery returns.\":

      operand comparison_operator ALL (subquery)\n

      For example:

      SELECT s1 FROM t1 WHERE s1 > ALL (SELECT s1 FROM t2);\n

      Suppose that there is a row in table t1 containing (10). The expression is TRUE if table t2 contains (-5,0,+5) because 10 is greater than all three values in t2. The expression is FALSE if table t2 contains (12,6,NULL,-100) because there is a single value 12 in table t2 that is greater than 10, and the result returns Empty set. The expression is unknown (that is, NULL) if table t2 contains (0,NULL,1).

      Finally, the expression is TRUE if table t2 is empty. So, the following expression is TRUE when table t2 is empty:

      SELECT * FROM t1 WHERE 1 > ALL (SELECT s1 FROM t2);\n

      But this expression is NULL when table t2 is empty:

      SELECT * FROM t1 WHERE 1 > (SELECT s1 FROM t2);\n

      In addition, the following expression is NULL when table t2 is empty:

      SELECT * FROM t1 WHERE 1 > ALL (SELECT MAX(s1) FROM t2);\n

      In general, tables containing NULL values and empty tables are \"edge cases.\" When writing subqueries, always consider whether you have taken those two possibilities into account.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#syntax","title":"Syntax","text":"
      > SELECT column_name(s) FROM table_name {WHERE | HAVING} [not] expression comparison_operator ALL (subquery)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#examples","title":"Examples","text":"
      create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select * from t3 where a <> all (select b from t2);\n+------+\n| a    |\n+------+\n|    6 |\n|    3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t4 where 5 > all (select a from t5);\n+------+------+\n| a    | b    |\n+------+------+\n|    4 |    8 |\n|    3 |    8 |\n|    5 |    9 |\n+------+------+\n3 rows in set (0.01 sec)\n\nmysql> select * from t3 where 10 > all (select b from t2);\n+------+\n| a    |\n+------+\n|    6 |\n|    7 |\n|    3 |\n+------+\n3 rows in set (0.00 sec)\n\nmysql> select a,b from t6 where a > all ( select a ,b from t4 where a>3);\nERROR 1105 (HY000): subquery should return 1 column\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/","title":"Subqueries with ANY or SOME","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#description","title":"Description","text":"

      Comparison operators (=, >, < , etc.) are used only on subqueries that return one row. SQL Subqueries with ANY, you can make comparisons on subqueries that return multiple rows. ANY evaluate whether any or all of the values returned by a subquery match the left-hand expression.

      Subqueries that use the ANY keyword return true when any value retrieved in the subquery matches the value of the left-hand expression.

      note

      The word SOME is an alias for ANY.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#syntax","title":"Syntax","text":"
      > SELECT column_name(s) FROM table_name WHERE column_name ANY (subquery);\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#examples","title":"Examples","text":"
      create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select * from t3 where a <> any (select b from t2);\n+------+\n| a    |\n+------+\n|    6 |\n|    3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t3 where a <> some (select b from t2);\n+------+\n| a    |\n+------+\n|    6 |\n|    3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t3 where a = some (select b from t2);\n+------+\n| a    |\n+------+\n|    7 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select * from t3 where a = any (select b from t2);\n+------+\n| a    |\n+------+\n|    7 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select a,b from t6 where a >  any ( select a ,b from t4 where a>3);\nERROR 1105 (HY000): subquery should return 1 column\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/","title":"Subqueries with EXISTS or NOT EXISTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#description","title":"Description","text":"

      The EXISTS operator is used to test for the existence of any record in a subquery.

      If a subquery returns any rows at all, EXISTS subquery is TRUE, and NOT EXISTS subquery is FALSE.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#syntax","title":"Syntax","text":"
      > SELECT column_name(s)\nFROM table_name\nWHERE EXISTS\n(SELECT column_name FROM table_name WHERE condition);\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#examples","title":"Examples","text":"
      create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t3 values (6),(7),(3);\n\nmysql> select * from t3 where exists (select * from t2 where t2.b=t3.a);\n+------+\n| a    |\n+------+\n|    7 |\n+------+\n1 row in set (0.00 sec)\nmysql> select * from t3 where not exists (select * from t2 where t2.b=t3.a);\n+------+\n| a    |\n+------+\n|    6 |\n|    3 |\n+------+\n2 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/","title":"Subqueries with IN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#description","title":"Description","text":"

      A subquery can be used with the IN operator as \"expression IN (subquery)\". The subquery should return a single column with one or more rows to form a list of values to be used by the IN operation.

      Use the IN clause for multiple-record, single-column subqueries. After the subquery returns results introduced by IN or NOT IN, the outer query uses them to return the final result.

      • If any row in the sub-query result matches, the answer is true.
      • If the subquery result is empty, the answer is false.
      • If no row in the sub-query result matches, the answer is also false.
      • If all of the values in the sub-query result are null, the answer is false.
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#syntax","title":"Syntax","text":"
      > SELECT ... FROM table_name WHERE column_name IN (subquery)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#examples","title":"Examples","text":"
      create table t1(val varchar(10));\ninsert into t1 values ('aaa'), ('bbb'),('eee'),('mmm'),('ppp');\n\nmysql> select count(*) from t1 as w1 where w1.val in (select w2.val from t1 as w2 where w2.val like 'm%') and w1.val in (select w3.val from t1 as w3 where w3.val like 'e%');\n+----------+\n| count(*) |\n+----------+\n|        0 |\n+----------+\n1 row in set (0.01 sec)\n
      create table t1 (id int not null, text varchar(20) not null default '', primary key (id));\ninsert into t1 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text11'), (12, 'text12');\n\nmysql> select * from t1 where id not in (select id from t1 where id < 8);\n+------+--------+\n| id   | text   |\n+------+--------+\n|    8 | text8  |\n|    9 | text9  |\n|   10 | text10 |\n|   11 | text11 |\n|   12 | text12 |\n+------+--------+\n5 rows in set (0.00 sec)\n
      CREATE TABLE t1 (a int);\nCREATE TABLE t2 (a int, b int);\nCREATE TABLE t3 (b int NOT NULL);\nINSERT INTO t1 VALUES (1), (2), (3), (4);\nINSERT INTO t2 VALUES (1,10), (3,30);\n\nmysql> select * from t1 where t1.a in (SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.a=t1.a);\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT * FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10;\nEmpty set (0.01 sec)\nmysql> SELECT * FROM t1 WHERE t1.a NOT IN (SELECT a FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10);\n+------+\n| a    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n|    4 |\n+------+\n4 rows in set (0.00 sec)\n
      create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select a,b from t6 where (a,b) in ( select a,b from t4 where a>3);\nEmpty set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/","title":"SUBQUERY","text":"

      A subquery is a SELECT statement within another statement. is a SQL query nested inside a larger query.

      Here is an example of a subquery:

      SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);\n

      In this example, SELECT * FROM t1 ... is the outer query (or outer statement), and (SELECT column1 FROM t2) is the subquery. We say that the subquery is nested within the outer query, and in fact it is possible to nest subqueries within other subqueries, to a considerable depth. A subquery must always appear within parentheses.

      The main advantages of subqueries are:

      • They allow queries that are structured so that it is possible to isolate each part of a statement.

      • They provide alternative ways to perform operations that would otherwise require complex joins and unions.

      • Many people find subqueries more readable than complex joins or unions.

      A subquery may occur in:

      • A SELECT clause
      • A FROM clause
      • A WHERE clause

      For more information, see the reference below:

      • Derived Tables
      • Comparisons Using Subqueries
      • SUBQUERY WITH ANY or SOME
      • SUBQUERY WITH ALL
      • SUBQUERY WITH EXISTS
      • SUBQUERY WITH IN
      "},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/#constraints","title":"Constraints","text":"

      MatrixOne does not support selecting multiple columns for the subquery.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/","title":"KILL","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#description","title":"Description","text":"

      The KILL statement terminates a running query or process.

      Info

      Terminating a process or query may result in the loss of unsaved data; terminating a running query may consume system resources and affect other running queries.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#syntax","title":"Syntax","text":"
      > KILL [CONNECTION | QUERY] processlist_id\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#explanations","title":"Explanations","text":"

      process_id refers to the identifier of the process or query to be terminated. process_id is the connection identifier if the CONNECTION keyword is used, and process_id is the query identifier if the QUERY keyword is used.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#examples","title":"Examples","text":"
      select connection_id();\n+-----------------+\n| connection_id() |\n+-----------------+\n|            1008 |\n+-----------------+\n1 row in set (0.00 sec)\n\n-- Terminate query process\nmysql> kill query 1008;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- Terminate the connection process\nmysql> kill connection 1008;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- Test for disconnection\nmysql> show databases;\nERROR 2013 (HY000): Lost connection to MySQL server during query\nNo connection. Trying to reconnect...\nConnection id:    1180\n-- The connection has been disconnected, and the service has started to reconnect\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/","title":"USE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#description","title":"Description","text":"

      The USE statement tells MatrixOne to use the named database as the default (current) database for subsequent statements.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#syntax","title":"Syntax","text":"
      > USE db_name\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#examples","title":"Examples","text":"
      > USE db1;\n> SELECT COUNT(*) FROM mytable; 
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/","title":"Obtaining Information with EXPLAIN ANALYZE","text":"

      EXPLAIN ANALYZE is a profiling tool for your queries that will show you where SQL spends time on your query and why. It will plan the query, instrument it and execute it while counting rows and measuring time spent at various points in the execution plan. When execution finishes, EXPLAIN ANALYZE will print the plan and the measurements instead of the query result.

      EXPLAIN ANALYZE, which runs a statement and produces EXPLAIN output along with timing and additional, iterator-based, information about how the optimizer's expectations matched the actual execution. For each iterator, the following information is provided:

      • Estimated execution cost

      Some iterators are not accounted for by the cost model, and so are not included in the estimate.

      • Estimated number of returned rows

      • Time to return first row

      • Time spent executing this iterator (including child iterators, but not parent iterators), in milliseconds.

      • Number of rows returned by the iterator

      • Number of loops

      The query execution information is displayed using the TREE output format, in which nodes represent iterators. EXPLAIN ANALYZE always uses the TREE output format, also can optionally be specified explicitly using FORMAT=TREE; formats other than TREE remain unsupported.

      EXPLAIN ANALYZE can be used with SELECT statements, as well as with multi-table UPDATE and DELETE statements.

      You can terminate this statement using KILL QUERY or CTRL-C.

      EXPLAIN ANALYZE cannot be used with FOR CONNECTION.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/#example","title":"Example","text":"

      Create table

      CREATE TABLE t1 (\nc1 INTEGER DEFAULT NULL,\nc2 INTEGER DEFAULT NULL\n);\n\nCREATE TABLE t2 (\nc1 INTEGER DEFAULT NULL,\nc2 INTEGER DEFAULT NULL\n);\n\nCREATE TABLE t3 (\npk INTEGER NOT NULL PRIMARY KEY,\ni INTEGER DEFAULT NULL\n);\n

      Example output:

      > EXPLAIN ANALYZE SELECT * FROM t1 JOIN t2 ON (t1.c1 = t2.c2)\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN:   Analyze: timeConsumed=0us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN:   ->  Join\n*************************** 4. row ***************************\nQUERY PLAN:         Analyze: timeConsumed=5053us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN:         Join Type: INNER\n*************************** 6. row ***************************\nQUERY PLAN:         Join Cond: (t1.c1 = t2.c2)\n*************************** 7. row ***************************\nQUERY PLAN:         ->  Table Scan on aaa.t1\n*************************** 8. row ***************************\nQUERY PLAN:               Analyze: timeConsumed=2176us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 9. row ***************************\nQUERY PLAN:         ->  Table Scan on aaa.t2\n*************************** 10. row ***************************\nQUERY PLAN:               Analyze: timeConsumed=0us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n10 rows in set (0.00 sec)\n\n> EXPLAIN ANALYZE SELECT * FROM t3 WHERE i > 8\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN:   Analyze: timeConsumed=0us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN:   ->  Table Scan on aaa.t3\n*************************** 4. row ***************************\nQUERY PLAN:         Analyze: timeConsumed=154us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN:         Filter Cond: (CAST(t3.i AS BIGINT) > 8)\n5 rows in set (0.00 sec)\n\n> EXPLAIN ANALYZE SELECT * FROM t3 WHERE pk > 17\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN:   Analyze: timeConsumed=0us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN:   ->  Table Scan on aaa.t3\n*************************** 4. row ***************************\nQUERY PLAN:         Analyze: timeConsumed=309us inputRows=0 outputRows=0 inputSize=0bytes outputSize=0bytes memorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN:         Filter Cond: (CAST(t3.pk AS BIGINT) > 17)\n5 rows in set (0.00 sec)\n

      Values shown for actual time in the output of this statement are expressed in milliseconds.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/","title":"EXPLAIN Output Format","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#output-structure","title":"Output Structure","text":"

      The command's result is a textual description of the plan selected for the statement, optionally annotated with execution statistics.

      Take the following SQL as an example, we demonstrate the output structure.

      explain select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n
      +--------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                 |\n+--------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=400.00 ndv=0.00 rowsize=0                                     |\n|   ->  Aggregate(cost=0.00..0.00 card=400.00 ndv=0.00 rowsize=0                             |\n|         Group Key:#[0,1], #[0,0]                                                           |\n|         Aggregate Functions: count(#[0,0])                                                 |\n|         ->  Join(cost=0.00..0.00 card=400.00 ndv=0.00 rowsize=0                            |\n|               Join Type: INNER                                                             |\n|               Join Cond: (#[1,2] = #[0,0])                                                 |\n|               ->  Table Scan on abc.t2(cost=0.00..0.00 card=8.00 ndv=0.00 rowsize=0        |\n|               ->  Join(cost=0.00..0.00 card=50.00 ndv=0.00 rowsize=0                       |\n|                     Join Type: INNER                                                       |\n|                     Join Cond: (#[0,0] = #[1,1])                                           |\n|                     ->  Table Scan on abc.t1(cost=0.00..0.00 card=5.00 ndv=0.00 rowsize=0  |\n|                     ->  Table Scan on abc.t3(cost=0.00..0.00 card=10.00 ndv=0.00 rowsize=0 |\n+--------------------------------------------------------------------------------------------+\n13 rows in set (0.00 sec)\n

      EXPLAIN outputs a tree structure, named as Execution Plan Tree. Every leaf node includes the information of node type, affected objects and other properties such as cost, rowsize and so on. We can simplify the above example only with node type information. It visualizes the whole process of a SQL query, shows which operation nodes it goes through and what are their cost estimation.

      Project\n\u2514\u2500\u2500 Aggregate\n    \u2514\u2500\u2500 Join\n        \u2514\u2500\u2500 Table Scan\n        \u2514\u2500\u2500 Join\n              \u2514\u2500\u2500Table Scan\n              \u2514\u2500\u2500Table Scan\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#node-types","title":"Node types","text":"

      MatrixOne supports the following node types:

      Node Type Name in Explain Node_TABLE_SCAN Table Scan Node_VALUE_SCAN Values Scan Node_PROJECT Project Node_AGG Aggregate Node_FILTER Filter Node_JOIN Join Node_SORT Sort Node_INSERT Insert Node_UPDATE Update Node_DELETE Delete"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#table-scan","title":"Table Scan","text":"Property Format Description cost cost=0.00..0.00 The first is estimated start-up cost. This is the time expended before the output phase can begin, e.g., time to do the sorting in a sort node. The second is estimated total cost. This is stated on the assumption that the plan node is run to completion, i.e., all available rows are retrieved. In practice a node's parent node might stop short of reading all available rows (see the LIMIT example below). card card=14.00 Estimated column cardinality. ndv ndv=0.00 Estimated number of distinct values. rowsize rowsize=0.00 Estimated rowsize. output Output: #[0,0], #[0,1], #[0,2], #[0,3], #[0,4], #[0,5], #[0,6], #[0,7] Node output information. Table Table : 'emp' (0:'empno', 1:'ename', 2:'job', 3:'mgr',) Table definition information after column pruning. Filter Cond Filter Cond: (CAST(#[0,5] AS DECIMAL128) > CAST(20 AS DECIMAL128)) Filter condition."},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#values-scan","title":"Values Scan","text":"Property Format Description cost (cost=0.00..0.00 card=14.00 ndv=0.00 rowsize=0) Estimated cost output Output: 0 Node output information"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#project","title":"Project","text":"Property Format Description cost (cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) Estimated cost output Output: (CAST(#[0,0] AS INT64) + 2) Node output information"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#aggregate","title":"Aggregate","text":"Property Format Description cost (cost=0.00..0.00 card=14.00 ndv=0.00 rowsize=0) Estimated cost output Output: #[0,0], #[0,1], #[0,2], #[0,3], #[0,4], #[0,5], #[0,6], #[0,7] Node output information Group Key Group Key:#[0,0] Key for grouping Aggregate Functions Aggregate Functions: max(#[0,1]) Aggregate function name"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#filter","title":"Filter","text":"Property Format Description cost (cost=0.00..0.00 card=14.00 ndv=0.00 rowsize=0) Estimated cost output Output: #[0,0], #[0,1], #[0,2], #[0,3], #[0,4], #[0,5], #[0,6], #[0,7] Node output information Filter Cond Filter Cond: (CAST(#[0,1] AS INT64) > 10) Filter condition"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#join","title":"Join","text":"Property Format Description cost (cost=0.00..0.00 card=14.00 ndv=0.00 rowsize=0) Estimated cost output Output: #[0,0] Node output information Join Type: INNER Join Type: INNER Join type Join Cond Join Cond: (#[0,0] = #[1,0]) Join condition"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#sort","title":"Sort","text":"Property Format Description cost (cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) Estimated cost output Output: #[0,0], #[0,1], #[0,2], #[0,3], #[0,4], #[0,5], #[0,6], #[0,7] Node output information Sort Key Sort Key: #[0,0] DESC, #[0,1] INTERNAL Sort key Limit Limit: 10 Number limit for output data Offset Offset: 20 Number offset for output data"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/","title":"EXPLAIN","text":"

      EXPLAIN \u2014 show the execution plan of a statement.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#syntax","title":"Syntax","text":"
      EXPLAIN [ ( option [, ...] ) ] statement\n\nwhere option can be one of:\n    ANALYZE [ boolean ]\n    VERBOSE [ boolean ]\n    FORMAT { TEXT | JSON }\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#description","title":"Description","text":"

      This command displays the execution plan that the MatrixOne planner generates for the supplied statement. The execution plan shows how the table(s) referenced by the statement will be scanned \u2014 by plain sequential scan, index scan, and so on. \u2014 and if multiple tables are referenced, what join algorithms will be used to bring together the required rows from each input table.

      The most critical part of the display is the estimated statement execution cost, which is the planner's guess at how long it will take to run the statement (measured in cost units that are arbitrary, but conventionally mean disk page fetches). Actually two numbers are shown: the start-up cost before the first row can be returned, and the total cost to return all the rows. For most queries the total cost is what matters, but in contexts such as a subquery in EXISTS, the planner will choose the smallest start-up cost instead of the smallest total cost (since the executor will stop after getting one row, anyway). Also, if you limit the number of rows to return with a LIMIT clause, the planner makes an appropriate interpolation between the endpoint costs to estimate which plan is really the cheapest.

      The ANALYZE option causes the statement to be actually executed, not only planned. Then actual run time statistics are added to the display, including the total elapsed time expended within each plan node (in milliseconds) and the total number of rows it actually returned. This is useful for seeing whether the planner's estimates are close to reality.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#parameters","title":"Parameters","text":"
      • ANALYZE:

      Carry out the command and show actual run times and other statistics. This parameter defaults to FALSE.

      • VERBOSE:

      Display additional information regarding the plan. Specifically, include the output column list for each node in the plan tree, schema-qualify table and function names, always label variables in expressions with their range table alias, and always print the name of each trigger for which statistics are displayed. This parameter is FALSE by default.

      • FORMAT:

      Specify the output format, which can be TEXT, JSON. Non-text output contains the same information as the text output format, but is easier for programs to parse. This parameter is TEXT by dafault.

      • BOOLEAN:

      Specifies whether the selected option should be turned on or off. You can write TRUEto enable the option, and FALSE to disable it. The boolean value can also be omitted, in which case TRUE is assumed.

      • STETEMENT

      MatrixOne supports any SELECT, UPDATE, DELETE statement execution plan. For INSERT statement, only INSERT INTO..SELECT is supported in 0.5.1 version. INSERT INTO...VALUES is not supported yet.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#examples","title":"Examples","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_table_scan","title":"Node_TABLE_SCAN","text":"
      mysql> explain verbose SELECT N_NAME, N_REGIONKEY a FROM NATION WHERE N_NATIONKEY > 0 OR N_NATIONKEY < 10;\n+------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                         |\n+------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                             |\n|   Output: #[0,0], #[0,1]                                                           |\n|   ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)      |\n|         Output: #[0,1], #[0,2]                                                     |\n|         Table: 'nation' (0:'n_nationkey', 1:'n_name', 2:'n_regionkey')             |\n|         Filter Cond: ((CAST(#[0,0] AS INT64) > 0) or (CAST(#[0,0] AS INT64) < 10)) |\n+------------------------------------------------------------------------------------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_value_scan","title":"Node_VALUE_SCAN","text":"
      mysql> explain verbose select abs(-1);\n+-----------------------------------------------------------------------------+\n| QUERY PLAN                                                                  |\n+-----------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=1.00 ndv=0.00 rowsize=0)                       |\n|   Output: 1                                                                 |\n|   ->  Values Scan \"*VALUES*\" (cost=0.00..0.00 card=1.00 ndv=0.00 rowsize=0) |\n|         Output: 0                                                           |\n+-----------------------------------------------------------------------------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_sort","title":"Node_SORT","text":"
      mysql> explain verbose SELECT N_NAME, N_REGIONKEY a FROM NATION WHERE N_NATIONKEY > 0 AND N_NATIONKEY < 10 ORDER BY N_NAME, N_REGIONKEY DESC;\n+--------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                 |\n+--------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                     |\n|   Output: #[0,0], #[0,1]                                                                   |\n|   ->  Sort(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                  |\n|         Output: #[0,0], #[0,1]                                                             |\n|         Sort Key: #[0,0] INTERNAL,  #[0,1] DESC                                            |\n|         ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                         |\n|               Output: #[0,0], #[0,1]                                                       |\n|               ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)  |\n|                     Output: #[0,1], #[0,2]                                                 |\n|                     Table: 'nation' (0:'n_nationkey', 1:'n_name', 2:'n_regionkey')         |\n|                     Filter Cond: (CAST(#[0,0] AS INT64) > 0), (CAST(#[0,0] AS INT64) < 10) |\n+--------------------------------------------------------------------------------------------+\n

      With limit and offset:

      mysql> explain SELECT N_NAME, N_REGIONKEY FROM NATION WHERE abs(N_REGIONKEY) > 0 AND N_NAME LIKE '%AA' ORDER BY N_NAME DESC, N_REGIONKEY limit 10;\n+-------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                |\n+-------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                    |\n|   ->  Sort(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                 |\n|         Sort Key: #[0,0] DESC,  #[0,1] INTERNAL                                           |\n|         Limit: 10                                                                         |\n|         ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|               ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|                     Filter Cond: (abs(CAST(#[0,1] AS INT64)) > 0), (#[0,0] like '%AA')    |\n+-------------------------------------------------------------------------------------------+\n
      mysql> explain SELECT N_NAME, N_REGIONKEY FROM NATION WHERE abs(N_REGIONKEY) > 0 AND N_NAME LIKE '%AA' ORDER BY N_NAME DESC, N_REGIONKEY LIMIT 10 offset 20;\n+-------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                |\n+-------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                    |\n|   ->  Sort(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                 |\n|         Sort Key: #[0,0] DESC,  #[0,1] INTERNAL                                           |\n|         Limit: 10, Offset: 20                                                             |\n|         ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|               ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|                     Filter Cond: (abs(CAST(#[0,1] AS INT64)) > 0), (#[0,0] like '%AA')    |\n+-------------------------------------------------------------------------------------------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_agg","title":"Node_AGG","text":"
      mysql> explain verbose SELECT count(*) FROM NATION group by N_NAME;\n+-------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                          |\n+-------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                              |\n|   Output: #[0,0]                                                                    |\n|   ->  Aggregate(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                      |\n|         Output: #[-2,0]                                                             |\n|         Group Key:#[0,1]                                                            |\n|         Aggregate Functions: starcount(#[0,0])                                      |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|               Output: #[0,0], #[0,1]                                                |\n|               Table: 'nation' (0:'n_nationkey', 1:'n_name')                         |\n+-------------------------------------------------------------------------------------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_join","title":"Node_JOIN","text":"
      mysql> explain verbose SELECT NATION.N_NAME, REGION.R_NAME FROM NATION join REGION on NATION.N_REGIONKEY = REGION.R_REGIONKEY WHERE NATION.N_REGIONKEY > 10 AND LENGTH(NATION.N_NAME) > LENGTH(REGION.R_NAME);\n+--------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                 |\n+--------------------------------------------------------------------------------------------+\n| Project(cost=0.00..0.00 card=125.00 ndv=0.00 rowsize=0)                                    |\n|   Output: #[0,1], #[0,0]                                                                   |\n|   ->  Filter(cost=0.00..0.00 card=125.00 ndv=0.00 rowsize=0)                               |\n|         Output: #[0,0], #[0,1]                                                             |\n|         Filter Cond: (length(CAST(#[0,1] AS CHAR)) > length(CAST(#[0,0] AS CHAR)))         |\n|         ->  Join(cost=0.00..0.00 card=125.00 ndv=0.00 rowsize=0)                           |\n|               Output: #[0,1], #[1,0]                                                       |\n|               Join Type: INNER                                                             |\n|               Join Cond: (#[1,1] = #[0,0])                                                 |\n|               ->  Table Scan on tpch.region(cost=0.00..0.00 card=5.00 ndv=0.00 rowsize=0)  |\n|                     Output: #[0,0], #[0,1]                                                 |\n|                     Table: 'region' (0:'r_regionkey', 1:'r_name')                          |\n|               ->  Table Scan on tpch.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|                     Output: #[0,0], #[0,1]                                                 |\n|                     Table: 'nation' (0:'n_name', 1:'n_regionkey')                          |\n|                     Filter Cond: (CAST(#[0,1] AS INT64) > 10)                              |\n+--------------------------------------------------------------------------------------------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_insert","title":"Node_INSERT","text":"
      mysql> explain verbose INSERT NATION select * from nation;\n+---------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                  |\n+---------------------------------------------------------------------------------------------+\n| Insert on db1.nation (cost=0.0..0.0 rows=0 ndv=0 rowsize=0)                                 |\n|   Output: #[0,0], #[0,1], #[0,2], #[0,3]                                                    |\n|   ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                                |\n|         Output: #[0,0], #[0,1], #[0,2], #[0,3]                                              |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)         |\n|               Output: #[0,0], #[0,1], #[0,2], #[0,3]                                        |\n|               Table: 'nation' (0:'n_nationkey', 1:'n_name', 2:'n_regionkey', 3:'n_comment') |\n+---------------------------------------------------------------------------------------------+\n7 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_update","title":"Node_Update","text":"
      mysql> explain verbose UPDATE NATION SET N_NAME ='U1', N_REGIONKEY=2 WHERE N_NATIONKEY > 10 LIMIT 20;\n+-------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                          |\n+-------------------------------------------------------------------------------------+\n| Update on db1.nation (cost=0.0..0.0 rows=0 ndv=0 rowsize=0)                         |\n|   ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|         Output: #[0,0], 'U1', CAST(2 AS INT32)                                      |\n|         Limit: 20                                                                   |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|               Output: #[0,1]                                                        |\n|               Table: 'nation' (0:'n_nationkey', 1:'PADDR')                          |\n|               Filter Cond: (CAST(#[0,0] AS INT64) > 10)                             |\n+-------------------------------------------------------------------------------------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#node_delete","title":"Node_Delete","text":"
      mysql> explain verbose DELETE FROM NATION WHERE N_NATIONKEY > 10;\n+-------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                          |\n+-------------------------------------------------------------------------------------+\n| Delete on db1.nation (cost=0.0..0.0 rows=0 ndv=0 rowsize=0)                         |\n|   ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|         Output: #[0,0]                                                              |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|               Output: #[0,1]                                                        |\n|               Table: 'nation' (0:'n_nationkey', 1:'PADDR')                          |\n|               Filter Cond: (CAST(#[0,0] AS INT64) > 10)                             |\n+-------------------------------------------------------------------------------------+\n

      With limit:

      mysql>  explain verbose DELETE FROM NATION WHERE N_NATIONKEY > 10 LIMIT 20;\n+-------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                          |\n+-------------------------------------------------------------------------------------+\n| Delete on db1.nation (cost=0.0..0.0 rows=0 ndv=0 rowsize=0)                         |\n|   ->  Project(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0)                        |\n|         Output: #[0,0]                                                              |\n|         Limit: 20                                                                   |\n|         ->  Table Scan on db1.nation(cost=0.00..0.00 card=25.00 ndv=0.00 rowsize=0) |\n|               Output: #[0,1]                                                        |\n|               Table: 'nation' (0:'n_nationkey', 1:'PADDR')                          |\n|               Filter Cond: (CAST(#[0,0] AS INT64) > 10)                             |\n+-------------------------------------------------------------------------------------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/","title":"DEALLOCATE PREPARE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#description","title":"Description","text":"

      To deallocate a prepared statement produced with PREPARE, use a DEALLOCATE PREPARE statement that refers to the prepared statement name. Attempting to execute a prepared statement after deallocating it results in an error. If too many prepared statements are created and not deallocated by either the DEALLOCATE PREPARE statement or the end of the session, you might encounter the upper limit enforced by the max_prepared_stmt_count system variable.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#syntax","title":"Syntax","text":"
      {DEALLOCATE | DROP} PREPARE stmt_name\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#arguments","title":"Arguments","text":"Arguments Description stmt_name The name of the prepared statement."},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#examples","title":"Examples","text":"
      > CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\n> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\n> SET @si_min = -9223372036854775808;\n> SET @si_max = 9223372036854775807;\n> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.00 sec)\n\n> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk   | ui   | si                   |\n+------+------+----------------------+\n|    0 |    0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.01 sec)\n\n> EXECUTE s2 USING @si_max;\n+------+----------------------+---------------------+\n| pk   | ui                   | si                  |\n+------+----------------------+---------------------+\n|    1 | 18446744073709551615 | 9223372036854775807 |\n+------+----------------------+---------------------+\n1 row in set (0.01 sec)\n\n> DEALLOCATE PREPARE s2;\nQuery OK, 0 rows affected (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/","title":"EXECUTE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#description","title":"Description","text":"

      After preparing a statement with PREPARE, you execute it with an EXECUTE statement that refers to the prepared statement name. If the prepared statement contains any parameter markers, you must supply a USING clause that lists user variables containing the values to be bound to the parameters. Parameter values can be supplied only by user variables, and the USING clause must name exactly as many variables as the number of parameter markers in the statement.

      You can execute a given prepared statement multiple times, passing different variables to it or setting the variables to different values before each execution.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#syntax","title":"Syntax","text":"
      EXECUTE stmt_name\n    [USING @var_name [, @var_name] ...]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#arguments","title":"Arguments","text":"Arguments Description stmt_name The name of the prepared statement."},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#examples","title":"Examples","text":"
      > CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\n> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\n> SET @si_min = -9223372036854775808;\n> SET @si_max = 9223372036854775807;\n> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.00 sec)\n\n> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk   | ui   | si                   |\n+------+------+----------------------+\n|    0 |    0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.01 sec)\n\n> EXECUTE s2 USING @si_max;\n+------+----------------------+---------------------+\n| pk   | ui                   | si                  |\n+------+----------------------+---------------------+\n|    1 | 18446744073709551615 | 9223372036854775807 |\n+------+----------------------+---------------------+\n1 row in set (0.01 sec)\n\n> DEALLOCATE PREPARE s2;\nQuery OK, 0 rows affected (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/","title":"PREPARE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#description","title":"Description","text":"

      The PREPARE statement prepares a SQL statement and assigns it a name, The prepared statement is executed with EXECUTE and released with DEALLOCATE PREPARE.

      Statement names are not case-sensitive.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#syntax","title":"Syntax","text":"
      PREPARE stmt_name FROM preparable_stmt\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#arguments","title":"Arguments","text":"Arguments Description stmt_name The name of the prepared statement. preparable_stmt a string literal or a user variable that contains the text of the SQL statement. The text must represent a single statement, not multiple statements. Within the statement, ? characters can be used as parameter markers to indicate where data values are to be bound to the query later when you execute it. The ? characters should not be enclosed within quotation marks, even if you intend to bind them to string values. Parameter markers can be used only where data values should appear, not for SQL keywords, identifiers, and so forth.

      If a prepared statement with the given name already exists, it is deallocated implicitly before the new statement is prepared. This means that if the new statement contains an error and cannot be prepared, an error is returned and no statement with the given name exists.

      The scope of a prepared statement is the session within which it is created, which as several implications:

      • A prepared statement created in one session is not available to other sessions.

      • When a session ends, whether normally or abnormally, its prepared statements no longer exist. If auto-reconnect is enabled, the client is not notified that the connection was lost. For this reason, clients may wish to disable auto-reconnect.

      A parameter used in a prepared statement has its type determined when the statement is first prepared, and retains this type whenever EXECUTE is invoked for this prepared statement. Rules for determining a parameter's type are listed here:

      • A parameter which is an operand of a binary arithmetic operator has the same data type as the other operand.

      • If both operands of a binary arithmetic operator are parameters, the type of the parameters is decided by the context of the operator.

      • If a parameter is the operand of a unary arithmetic operator, the parameter's type is decided by the context of the operator.

      • If an arithmetic operator has no type-determining context, the derived type for any parameters involved is DOUBLE PRECISION. This can happen, for example, when the parameter is a top-level node in a SELECT list, or when it is part of a comparison operator.

      • A parameter which is an operand of a character string operator has the same derived type as the aggregated type of the other operands. If all operands of the operator are parameters, the derived type is VARCHAR; its collation is determined by the value of collation_connection.

      • A parameter which is an operand of a temporal operator has type DATETIME if the operator returns a DATETIME, TIME if the operator returns a TIME, and DATE if the operator returns a DATE.

      • A parameter which is an operand of a binary comparison operator has the same derived type as the other operand of the comparison.

      • A parameter that is an operand of a ternary comparison operator such as BETWEEN has the same derived type as the aggregated type of the other operands.

      • If all operands of a comparison operator are parameters, the derived type for each of them is VARCHAR, with collation determined by the value of collation_connection.

      • A parameter that is an output operand of any of CASE, COALESCE, IF, IFNULL, or NULLIF has the same derived type as the aggregated type of the operator's other output operands.

      • If all output operands of any of CASE, COALESCE, IF, IFNULL, or NULLIF are parameters, or they are all NULL, the type of the parameter is decided by the context of the operator.

      • If the parameter is an operand of any of CASE, COALESCE(), IF, or IFNULL, and has no type-determining context, the derived type for each of the parameters involved is VARCHAR, and its collation is determined by the value of collation_connection.

      • A parameter which is the operand of a CAST() has the same type as specified by the CAST().

      • If a parameter is an immediate member of a SELECT list that is not part of an INSERT statement, the derived type of the parameter is VARCHAR, and its collation is determined by the value of collation_connection.

      • If a parameter is an immediate member of a SELECT list that is part of an INSERT statement, the derived type of the parameter is the type of the corresponding column into which the parameter is inserted.

      • If a parameter is used as source for an assignment in a SET clause of an UPDATE statement or in the ON DUPLICATE KEY UPDATE clause of an INSERT statement, the derived type of the parameter is the type of the corresponding column which is updated by the SET or ON DUPLICATE KEY UPDATE clause.

      • If a parameter is an argument of a function, the derived type depends on the function's return type.

      For some combinations of actual type and derived type, an automatic repreparation of the statement is triggered. Repreparation does not occur if any of the following conditions are true:

      • NULL is used as the actual parameter value.

      • A parameter is an operand of a CAST(). (Instead, a cast to the derived type is attempted, and an exception raised if the cast fails.)

      • A parameter is a string. (In this case, an implicit CAST(? AS derived_type) is performed.)

      • The derived type and actual type of the parameter are both INTEGER and have the same sign.

      • The parameter's derived type is DECIMAL and its actual type is either DECIMAL or INTEGER.

      • The derived type is DOUBLE and the actual type is any numeric type.

      • Both the derived type and the actual type are string types.

      • If the derived type is temporal and the actual type is temporal. Exceptions: The derived type is TIME and the actual type is not TIME; the derived type is DATE and the actual type is not DATE.

      • The derived type is temporal and the actual type is numeric.

      For cases other than those just listed, the statement is reprepared and the actual parameter types are used instead of the derived parameter types.

      These rules also apply to a user variable referenced in a prepared statement.

      Using a different data type for a given parameter or user variable within a prepared statement for executions of the statement subsequent to the first execution causes the statement to be reprepared. This is less efficient; it may also lead to the parameter's (or variable's) actual type to vary, and thus for results to be inconsistent, with subsequent executions of the prepared statement. For these reasons, it is advisable to use the same data type for a given parameter when re-executing a prepared statement.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#examples","title":"Examples","text":"
      > create table t13 (a int primary key);\n> insert into t13 values (1);\n> select * from t13 where 3 in (select (1+1) union select 1);\nEmpty set (0.01 sec)\n\n> select * from t13 where 3 in (select (1+2) union select 1);\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.01 sec)\n\n> prepare st_18492 from 'select * from t13 where 3 in (select (1+1) union select 1)';\nQuery OK, 0 rows affected (0.00 sec)\n\n> execute st_18492;\nEmpty set (0.01 sec)\n\n> prepare st_18493 from 'select * from t13 where 3 in (select (2+1) union select 1)';\nQuery OK, 0 rows affected (0.00 sec)\n\n> execute st_18493;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.00 sec)\n\n> deallocate prepare st_18492;\nQuery OK, 0 rows affected (0.00 sec)\n\n> deallocate prepare st_18493;\nQuery OK, 0 rows affected (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/","title":"SHOW ACCOUNTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#description","title":"Description","text":"

      Lists the meta information and statistics for the accounts created.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#syntax","title":"Syntax","text":"
      > SHOW ACCOUNTS;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#meta-information-of-account","title":"Meta information of account","text":"Column Name Details Type Date Source ACCOUNT_NAME Account name varchar mo_account ADMIN_NAME The default administrator name is created varchar In the mo_user table under each account CREATED Created time timestamp mo_account STATUS Status, OPEN or SUSPENDED varchar mo_account SUSPENDED_TIME Suspended time timestamp mo_account DB_COUNT the number of databases bigint unsigned mo_tables TABLE_COUNT the number of tables bigint unsigned mo_tables ROW_COUNT Total line number bigint unsigned sum(mo_table_rows()) SIZE Total space used (MB) decimal(29,3) sum(mo_table_size(mt.reldatabase,mt.relname) COMMENT COMMENT information at creation time varchar mo_account"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#examples","title":"Examples","text":"
      mysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created             | status | suspended_time | db_count | table_count | row_count | size  | comment        |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| sys          | root       | 2023-02-14 06:58:15 | open   | NULL           |        8 |          57 |      2681 | 0.351 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n1 row in set (0.14 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/","title":"SHOW COLLATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#description","title":"Description","text":"

      This statement lists collations supported by MatrixOne. By default, the output from SHOW COLLATION includes all available collations. The LIKE clause, if present, indicates which collation names to match. The WHERE clause can be given to select rows using more general conditions.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#syntax","title":"Syntax","text":"
      > SHOW COLLATION\n    [LIKE 'pattern' | WHERE expr]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#examples","title":"Examples","text":"
      mysql> show collation;\n+-------------+---------+------+----------+---------+\n| Collation   | Charset | Id   | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 |   46 | Yes      |       1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n\nmysql> show collation like '%';\n+-------------+---------+------+----------+---------+\n| Collation   | Charset | Id   | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 |   46 | Yes      |       1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n\nmysql> show collation where 'Charset'='utf8mb4';\n+-------------+---------+------+----------+---------+\n| Collation   | Charset | Id   | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 |   46 | Yes      |       1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/","title":"SHOW COLUMNS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#description","title":"Description","text":"

      SHOW COLUMNS displays information about the columns in a given table.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#syntax","title":"Syntax","text":"
      > SHOW [FULL] {COLUMNS}\n    {FROM | IN} tbl_name\n    [{FROM | IN} db_name]\n    [LIKE 'pattern' | WHERE expr]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(\ncol1 int comment 'First column',\ncol2 float comment '\"%$^&*()_+@!',\ncol3 varchar comment 'ZD5lTndyuEzw49gxR',\ncol4 bool comment ''\n);\nmysql> show columns from t1;\n+-------+----------------+------+------+---------+-------+-------------------+\n| Field | Type           | Null | Key  | Default | Extra | Comment           |\n+-------+----------------+------+------+---------+-------+-------------------+\n| col1  | INT            | YES  |      | NULL    |       | First column      |\n| col2  | FLOAT          | YES  |      | NULL    |       | \"%$^&*()_+@!      |\n| col3  | VARCHAR(65535) | YES  |      | NULL    |       | ZD5lTndyuEzw49gxR |\n| col4  | BOOL           | YES  |      | NULL    |       |                   |\n+-------+----------------+------+------+---------+-------+-------------------+\n4 rows in set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/","title":"SHOW CREATE PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#description","title":"Description","text":"

      Returns the SQL statement when PUBLICATION was created.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#syntax","title":"Syntax","text":"
      SHOW CREATE PUBLICATION pubname;\u0005\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#examples","title":"Examples","text":"
      create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\nmysql> alter publication pub3 account add accx;\nshow create publication pub3;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show create publication pub3;\n+-------------+-----------------------------------------------------------------------+\n| Publication | Create Publication                                                    |\n+-------------+-----------------------------------------------------------------------+\n| pub3        | CREATE PUBLICATION `pub3` DATABASE `t` ACCOUNT `acc0`, `acc1`, `accx` |\n+-------------+-----------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/","title":"SHOW CREATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#description","title":"Description","text":"

      This statement shows the CREATE TABLE statement that creates the named table.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#syntax","title":"Syntax","text":"
      > SHOW CREATE TABLE tbl_name\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#examples","title":"Examples","text":"
      drop table if exists t1;\ncreate table t1(\ncol1 int comment 'First column',\ncol2 float comment '\"%$^&*()_+@!',\ncol3 varchar comment 'ZD5lTndyuEzw49gxR',\ncol4 bool comment ''\n);\nmysql> show create table t1;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                                                                     |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1    | CREATE TABLE `t1` (\n`col1` INT DEFAULT NULL COMMENT 'First column',\n`col2` FLOAT DEFAULT NULL COMMENT '\"%$^&*()_+@!',\n`col3` VARCHAR(65535) DEFAULT NULL COMMENT 'ZD5lTndyuEzw49gxR',\n`col4` BOOL DEFAULT NULL\n) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/","title":"SHOW CREATE VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#description","title":"Description","text":"

      This statement shows the CREATE VIEW statement that creates the named view.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#syntax","title":"Syntax","text":"
      > SHOW CREATE VIEW view_name\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#examples","title":"Examples","text":"
      create table test_table(col1 int, col2 float, col3 bool, col4 Date, col5 varchar(255), col6 text);\ncreate view test_view as select * from test_table;\nmysql> show create view test_view;\n+-----------+---------------------------------------------------+\n| View      | Create View                                       |\n+-----------+---------------------------------------------------+\n| test_view | create view test_view as select * from test_table |\n+-----------+---------------------------------------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/","title":"SHOW DATABASES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#description","title":"Description","text":"

      SHOW DATABASES lists the databases on the MatrixOne. SHOW SCHEMAS is a synonym for SHOW DATABASES. The LIKE clause, if present, indicates which database names to match. The WHERE clause can be given to select rows using more general conditions.

      MatrixOne implements databases as directories in the data directory, so this statement simply lists directories in that location.

      Database information is also available from the INFORMATION_SCHEMA SCHEMATA table.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#syntax","title":"Syntax","text":"
      > SHOW {DATABASES | SCHEMAS}\n    [LIKE 'pattern' | WHERE expr]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#examples","title":"Examples","text":"
      create database demo_1;\n\nmysql> show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| mo_task            |\n| information_schema |\n| mysql              |\n| system_metrics     |\n| system             |\n| demo_1         |\n| mo_catalog         |\n+--------------------+\n7 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/","title":"SHOW FUNCTION STATUS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#description","title":"Description","text":"

      SHOW FUNCTION STATUS displays information about all functions in the database, including function name, database name, creation time, etc.

      The SHOW FUNCTION STATUS command only shows user-defined functions, not system functions.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#syntax","title":"Syntax","text":"
      > SHOW FUNCTION STATUS\n    [LIKE 'pattern' | WHERE expr]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#explanations","title":"Explanations","text":"

      LIKE 'pattern' is an optional argument to filter the functions to display. pattern is a string that can use % and _ wildcards. For example, to display all functions starting with my_function, the following command can be used:

      SHOW FUNCTION STATUS LIKE 'my_function%';\n

      The output will include the function name, database name, type, creation time, and modification time.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#examples","title":"Examples","text":"
      mysql> create function twosum (x float, y float) returns float language sql as 'select $1 + $2' ;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> create function mysumtable(x int) returns int language sql as 'select mysum(test_val, id) from tbl1 where id = $1';\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> create function helloworld () returns int language sql as 'select id from tbl1 limit 1';\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> show function status;\n+------+------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| Db   | Name       | Type     | Definer | Modified            | Created             | Security_type | Comment | character_set_client | collation_connection | Database Collation |\n+------+------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| aab  | twosum     | FUNCTION | root    | 2023-03-27 06:25:41 | 2023-03-27 06:25:41 | DEFINER       |         | utf8mb4              | utf8mb4_0900_ai_ci   | utf8mb4_0900_ai_ci |\n| aab  | mysumtable | FUNCTION | root    | 2023-03-27 06:25:51 | 2023-03-27 06:25:51 | DEFINER       |         | utf8mb4              | utf8mb4_0900_ai_ci   | utf8mb4_0900_ai_ci |\n| aab  | helloworld | FUNCTION | root    | 2023-03-27 06:25:58 | 2023-03-27 06:25:58 | DEFINER       |         | utf8mb4              | utf8mb4_0900_ai_ci   | utf8mb4_0900_ai_ci |\n+------+------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n3 rows in set (0.00 sec)\n\nmysql> show function status like 'two%';\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| Db   | Name   | Type     | Definer | Modified            | Created             | Security_type | Comment | character_set_client | collation_connection | Database Collation |\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| aab  | twosum | FUNCTION | root    | 2023-03-27 06:25:41 | 2023-03-27 06:25:41 | DEFINER       |         | utf8mb4              | utf8mb4_0900_ai_ci   | utf8mb4_0900_ai_ci |\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/","title":"SHOW GRANTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#description","title":"Description","text":"

      Use the SHOW GRANTS statement to display all grant information for a user. This would display privileges that were assigned to the user using the GRANT command.

      SHOW GRANTS requires the SELECT privilege privileges to query all tables in the mo_catalog database, except to display privileges and roles for the current user.

      To name the account or role for SHOW GRANTS, use the same format as for the GRANT statement, for example:

      show grants for 'root'@'localhost';\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#syntax","title":"Syntax","text":"
      > SHOW GRANTS FOR {username[@hostname] | rolename};\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#examples","title":"Examples","text":"
      > create role role1;\n> grant all on table *.* to role1;\n> grant create table, drop table on database *.* to role1;\n> create user user1 identified by 'pass1';\n> grant role1 to user1;\n> show grants for 'user1'@'localhost';\n+--------------------------------------------------------+\n| Grants for user1@localhost                             |\n+--------------------------------------------------------+\n| GRANT connect ON account  `user1`@`localhost`          |\n| GRANT table all ON table *.* `user1`@`localhost`       |\n| GRANT create table ON database *.* `user1`@`localhost` |\n| GRANT drop table ON database *.* `user1`@`localhost`   |\n+--------------------------------------------------------+\n4 rows in set (0.00 sec)\n\nmysql> show grants for ROLE role1;\n+--------------------------------------------+\n| Grants for role1                           |\n+--------------------------------------------+\n| GRANT table all ON table *.* `role1`       |\n| GRANT create table ON database *.* `role1` |\n| GRANT drop table ON database *.* `role1`   |\n+--------------------------------------------+\n3 rows in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/","title":"SHOW INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#description","title":"Description","text":"

      SHOW INDEX returns table index information.

      SHOW INDEX returns the following fields:

      Fields Description Table The name of the table. Non_unique 0 if the index cannot contain duplicates, 1 if it can. Key_name The name of the index. If the index is the primary key, the name is always PRIMARY. Seq_in_index The column sequence number in the index, starting with 1. Column_name The column name. See also the description for the Expression column. Collation How the column is sorted in the index. This can have values A (ascending), D (descending), or NULL (not sorted). Cardinality An estimate of the number of unique values in the index. To update this number, run ANALYZE TABLE or (for MyISAM tables) myisamchk -a.Cardinality is counted based on statistics stored as integers, so the value is not necessarily exact even for small tables. The higher the cardinality, the greater the chance that MySQL uses the index when doing joins. Sub_part The index prefix. That is, the number of indexed characters if the column is only partly indexed, NULL if the entire column is indexed. Note: Prefix limits are measured in bytes. However, prefix lengths for index specifications in CREATE TABLE, ALTER TABLE, and CREATE INDEX statements are interpreted as number of characters for nonbinary string types (CHAR, VARCHAR, TEXT) and number of bytes for binary string types (BINARY, VARBINARY, BLOB). Take this into account when specifying a prefix length for a nonbinary string column that uses a multibyte character set. Packed Indicates how the key is packed. NULL if it is not. Null Contains YES if the column may contain NULL values and '' if not. Index_type The index method used (BTREE, FULLTEXT, HASH, RTREE). Comment Information about the index not described in its own column, such as disabled if the index is disabled. Visible Whether the index is visible to the optimizer. Expression For a nonfunctional key part, Column_name indicates the column indexed by the key part and Expression is NULL.For a functional key part, Column_name column is NULL and Expression indicates the expression for the key part."},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#syntax","title":"Syntax","text":"
      > SHOW {INDEX | INDEXES}\n    {FROM | IN} tbl_name\n    [{FROM | IN} db_name]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#explanations","title":"Explanations","text":"

      An alternative to tbl_name FROM db_name syntax is db_name.tbl_name.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#examples","title":"Examples","text":"
      CREATE TABLE show_01(sname varchar(30),id int);\nmysql> show INDEX FROM show_01;\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n| Table   | Non_unique | Key_name   | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment          | Visible | Expression |\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n| show_01 |          0 | id         |            1 | id          | A         |           0 | NULL     | NULL   | YES  |            |                  | YES     | NULL       |\n| show_01 |          0 | sname      |            1 | sname       | A         |           0 | NULL     | NULL   | YES  |            |                  | YES     | NULL       |\n| show_01 |          0 | __mo_rowid |            1 | __mo_rowid  | A         |           0 | NULL     | NULL   | NO   |            | Physical address | NO      | NULL       |\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n3 rows in set (0.02 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/","title":"SHOW PROCESSLIST","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#description","title":"Description","text":"

      SHOW PROCESSLIST is used to view a list of currently executing threads (also known as a process list), providing information about all active connections and executing queries on the MatrixOne server.

      SHOW PROCESSLIST is used to monitor and manage activities in the database, identify potential issues, help diagnose query performance problems, and aid in decision-making to optimize database operations:

      • Monitoring Database Activity: By executing SHOW PROCESSLIST, you can view the queries and operations currently running in the database in real time. This is useful for monitoring database activity and promptly identifying potential performance issues. You can see which queries are running, their status, and whether there are long-running or blocked queries, as well as information about locks, deadlocks, or resource contention.

      • Terminating Queries: By examining the process list, you can identify the query ID of a specific query that needs to be terminated and then use the KILL command to stop that particular query. This is beneficial for controlling long-running queries or resolving deadlock situations.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#syntax","title":"Syntax","text":"
      > SHOW PROCESSLIST;\n

      The explanations for the queried table structure are as follows:

      Column Name Data Type Constraint Remarks node_id varchar not null Node ID uniquely identifies different nodes in the database cluster. In MatrixOne, a node corresponds to a CN (Compute Node). Note: - In the single-node version of MatrixOne, there is usually only one node and all processes run on this node, so all processes have the same node_id. - In the distributed version of MatrixOne, each node has a unique node_id. System tenants can view the node_id corresponding to the nodes where all executing threads run. In contrast, non-system tenants can only see the node_id corresponding to the nodes where threads executing for their tenant are running. conn_id uint32 not null Connection ID used to identify different database connections. To terminate a specific database connection, use the KILL CONNECTION conn_id; command. Each connection in the database is assigned a unique conn_id for identification. Note: System tenants can view all conn_id, while non-system tenants can only see conn_id for their tenant. session_id varchar not null Session ID account varchar not null account Note: Under the system, account, sessions, and account names can be viewed. Non-system accounts can only view sessions and account names of their accounts. user varchar not null User host varchar not null Hostname of client-server db varchar Database name session_start varchar Session start time command varchar not null Command type, e.g., COM_QUERY info varchar Current or previous SQL statement txn_id varchar not null Current or previous transaction ID statement_id varchar Current or previous statement ID statement_type varchar Current or previous statement type query_type varchar Query type, e.g., DDL, DML, etc. sql_source_type varchar SQL source type, e.g., external_sql, internal_sql, etc. query_start varchar Query start time"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#examples","title":"Examples","text":"
      mysql> SHOW PROCESSLIST;\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n| node_id                              | conn_id | session_id                           | account | user                                 | host           | db      | session_start              | command   | info                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | txn_id                           | statement_id                         | statement_type   | query_type | sql_source_type | query_start                |\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf |       1 | 97f85f80-2a5c-11ee-ae41-5ad2460dea4f | sys     | mo_logger                            | 127.0.0.1:6001 |         | 2023-07-24 19:59:27.005755 | COM_QUERY | COMMIT                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |                                  |                                      |                  |            | internal_sql    |                            |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf |       8 | a056b7c6-2a5c-11ee-ae42-5ad2460dea4f | sys     | root                                 | 127.0.0.1:6001 | aab     | 2023-07-24 19:59:41.045851 | COM_QUERY | SHOW PROCESSLIST                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | c207acc30a19432f8d3cbac387c6e520 | 421aadaa-2a68-11ee-ae5b-5ad2460dea4f | Show Processlist | Other      | external_sql    | 2023-07-24 21:22:56.907266 |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf |      24 | 0915f91a-2a63-11ee-ae4d-5ad2460dea4f | sys     | 3bf028e0-aa43-4917-b82f-ed533c0f401e | 127.0.0.1:6001 | mo_task | 2023-07-24 20:45:33.762679 | COM_QUERY | select\ntask_id,\ntask_metadata_id,\ntask_metadata_executor,\ntask_metadata_context,\ntask_metadata_option,\ntask_parent_id,\ntask_status,\ntask_runner,\ntask_epoch,\nlast_heartbeat,\nresult_code,\nerror_msg,\ncreate_at,\nend_at\nfrom mo_task.sys_async_task where task_id>17 AND task_runner='dd1dccb4-4d3c-41f8-b482-5251dc7a41bf' AND task_status=1 order by task_id limit 3 |                                  |                                      |                  |            | internal_sql    |                            |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf |      36 | d8aa4060-2a67-11ee-ae59-5ad2460dea4f | sys     | 3bf028e0-aa43-4917-b82f-ed533c0f401e | 127.0.0.1:6001 | mo_task | 2023-07-24 21:20:00.009746 | COM_QUERY | select\ncron_task_id,\ntask_metadata_id,\ntask_metadata_executor,\ntask_metadata_context,\ntask_metadata_option,\ncron_expr,\nnext_time,\ntrigger_times,\ncreate_at,\nupdate_at\nfrom mo_task.sys_cron_task                                                                                                                                                                        |                                  |                                      |                  |            | internal_sql    |                            |\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n4 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/","title":"SHOW PUBLICATIONS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#description","title":"Description","text":"

      Returns a list of all PUBLICATION names and corresponding database names.

      For more information, you need have the authority of account administrator; check the system table mo_pubs for more parameters.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#syntax","title":"Syntax","text":"
      SHOW PUBLICATIONS;\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#examples","title":"Examples","text":"
      create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nmysql> show publications;\n+------+----------+\n| Name | Database |\n+------+----------+\n| pub3 | t        |\n+------+----------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/","title":"SHOW ROLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#description","title":"Description","text":"

      Lists the meta information of the roles created under your account, including role name, creator, creation time, and comments.

      Note: To query the role you are currently using, use the select current_role() statement.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#syntax","title":"Syntax","text":"
      > SHOW ROLES [LIKE 'pattern'];\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#examples","title":"Examples","text":"
      -- Show the roles currently under your account\nmysql> show roles;\n+-----------+---------+---------------------+----------+\n| ROLE_NAME | CREATOR | CREATED_TIME        | COMMENTS |\n+-----------+---------+---------------------+----------+\n| moadmin   |       0 | 2023-04-19 06:37:58 |          |\n| public    |       0 | 2023-04-19 06:37:58 |          |\n+-----------+---------+---------------------+----------+\n2 rows in set (0.01 sec)\n\n-- create a new role named rolex\nmysql> create role rolex;\nQuery OK, 0 rows affected (0.02 sec)\n\n-- Show the roles currently under your account\nmysql> show roles;\n+-----------+---------+---------------------+----------+\n| ROLE_NAME | CREATOR | CREATED_TIME        | COMMENTS |\n+-----------+---------+---------------------+----------+\n| rolex     |       1 | 2023-04-19 06:43:29 |          |\n| moadmin   |       0 | 2023-04-19 06:37:58 |          |\n| public    |       0 | 2023-04-19 06:37:58 |          |\n+-----------+---------+---------------------+----------+\n3 rows in set (0.01 sec)\n\n-- Query the role you are currently using\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin        |\n+----------------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/","title":"SHOW SEQUENCES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#description","title":"Description","text":"

      SHOW SEQUENCES is used to view the name and list type of the current sequence list.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#syntax","title":"Syntax","text":"
      > SHOW SQUENCES\n       [WHERE expr]\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#examples","title":"Examples","text":"
      CREATE SEQUENCE s1 START 101;\nCREATE SEQUENCE s3 as smallint INCREMENT 10 MINVALUE -100 MAXVALUE 100 START 0 CYCLE;\nCREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\nmysql> show sequences;\n+--------+-----------+\n| Names  | Data Type |\n+--------+-----------+\n| s3     | SMALLINT  |\n| s1     | BIGINT    |\n| seq_id | BIGINT    |\n+--------+-----------+\n3 rows in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/","title":"SHOW STAGES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#description","title":"Description","text":"

      Display the data stage of the current database creation as a list.

      MatrixOne users use SHOW STAGES to view all the data stages of the current database and can choose a valid path to export the data to.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#syntax","title":"Syntax","text":"
      > SHOW STAGES [LIKE 'pattern']\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#examples","title":"Examples","text":"
      CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- Create internal data stage\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- Export data from table to the data stage\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- You can see your exported table in your local directory\n\n-- Display the data stage of the current database creation as a list.\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+---------+\n| STAGE_NAME | URL                         | STATUS  | COMMENT |\n+------------+-----------------------------+---------+---------+\n| stage1     | /tmp                        | ENABLED |         |\n+------------+-----------------------------+---------+---------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/","title":"SHOW SUBSCRIPTIONS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#description","title":"Description","text":"

      Returns a list of all subscription library names and source account names.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#syntax","title":"Syntax","text":"
      SHOW SUBSCRIPTIONS;\u0005\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#examples","title":"Examples","text":"
      Create database sub1 from sys publication pub1;\n\nmysql> create database sub1 from sys publication sys_pub_1;\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> show subscriptions;\n+------+--------------+\n| Name | From_Account |\n+------+--------------+\n| sub1 | sys          |\n+------+--------------+\n1 row in set (0.01 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/","title":"SHOW TABLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#description","title":"Description","text":"

      Shows the list of tables in the currently selected database.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#syntax","title":"Syntax","text":"
      > SHOW TABLES  [LIKE 'pattern' | WHERE expr | FROM 'pattern' | IN 'pattern']\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#examples","title":"Examples","text":"
      > SHOW TABLES;\n+---------------+\n| name          |\n+---------------+\n| clusters      |\n| contributors  |\n| databases     |\n| functions     |\n| numbers       |\n| numbers_local |\n| numbers_mt    |\n| one           |\n| processes     |\n| settings      |\n| tables        |\n| tracing       |\n+---------------+\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/","title":"SHOW VARIABLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#description","title":"Description","text":"

      SHOW VARIABLES shows the values of MatrixOne system variables.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#syntax","title":"Syntax","text":"
      > SHOW VARIABLES\n    [LIKE 'pattern']\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#explanations","title":"Explanations","text":"
      • With a LIKE clause, the statement displays only rows for those variables with names that match the pattern.

      • To get a list of variables whose name match a pattern, use the % wildcard character in a LIKE clause.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#examples","title":"Examples","text":"
      mysql> SHOW VARIABLES;\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n| Variable_name            | Value                                                                                                                 |\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n| auto_increment_increment | 1                                                                                                                     |\n| auto_increment_offset    | 1                                                                                                                     |\n| autocommit               | 1                                                                                                                     |\n| character_set_client     | utf8mb4                                                                                                               |\n| character_set_connection | utf8mb4                                                                                                               |\n| character_set_database   | utf8mb4                                                                                                               |\n| character_set_results    | utf8mb4                                                                                                               |\n| character_set_server     | utf8mb4                                                                                                               |\n| collation_connection     | default                                                                                                               |\n| collation_server         | utf8mb4_bin                                                                                                           |\n| completion_type          | NO_CHAIN                                                                                                              |\n| host                     | 0.0.0.0                                                                                                               |\n| init_connect             |                                                                                                                       |\n| interactive_timeout      | 28800                                                                                                                 |\n| license                  | APACHE                                                                                                                |\n| lower_case_table_names   | 0                                                                                                                     |\n| max_allowed_packet       | 16777216                                                                                                              |\n| net_write_timeout        | 60                                                                                                                    |\n| performance_schema       | 0                                                                                                                     |\n| port                     | 6001                                                                                                                  |\n| profiling                | 0                                                                                                                     |\n| query_result_maxsize     | 100                                                                                                                   |\n| query_result_timeout     | 24                                                                                                                    |\n| save_query_result        | 0                                                                                                                     |\n| sql_mode                 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |\n| sql_safe_updates         | 0                                                                                                                     |\n| sql_select_limit         | 18446744073709551615                                                                                                  |\n| system_time_zone         |                                                                                                                       |\n| testbotchvar_nodyn       | 0                                                                                                                     |\n| testbothvar_dyn          | 0                                                                                                                     |\n| testglobalvar_dyn        | 0                                                                                                                     |\n| testglobalvar_nodyn      | 0                                                                                                                     |\n| testsessionvar_dyn       | 0                                                                                                                     |\n| testsessionvar_nodyn     | 0                                                                                                                     |\n| time_zone                | SYSTEM                                                                                                                |\n| transaction_isolation    | REPEATABLE-READ                                                                                                       |\n| transaction_read_only    | 0                                                                                                                     |\n| tx_isolation             | REPEATABLE-READ                                                                                                       |\n| tx_read_only             | 0                                                                                                                     |\n| version_comment          | MatrixOne                                                                                                             |\n| wait_timeout             | 28800                                                                                                                 |\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n41 rows in set (0.01 sec)\n\nmysql> show variables like 'auto%';\n+--------------------------+-------+\n| Variable_name            | Value |\n+--------------------------+-------+\n| auto_increment_increment | 1     |\n| auto_increment_offset    | 1     |\n| autocommit               | 1     |\n+--------------------------+-------+\n3 rows in set (0.00 sec)\n\nmysql> show variables like 'auto_increment_increment';\n+--------------------------+-------+\n| Variable_name            | Value |\n+--------------------------+-------+\n| auto_increment_increment | 1     |\n+--------------------------+-------+\n1 row in set (0.00 sec)\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/","title":"SET ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#description","title":"Description","text":"

      Specifies the active/current primary role or secondary role for the session.

      The authorization to perform any SQL action other than creating objects can be provided by secondary roles.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#syntax","title":"Syntax","text":"
      > SET SECONDARY ROLE {\n    NONE\n  | ALL  \n}\nSET ROLE role\n
      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#explanations","title":"Explanations","text":"

      A role is a collection of permissions, and a user can correspond to multiple roles.

      For example, user1 has the primary role role1, secondary roles role2 and role3, role1 is granted the permissions pri1 and pri2; role2 is given the permission pri3; role3 is given the permission pri4, the permission comparison representation is as follows:

      User name Role name Privilege name user1 role1 pri1,pri2 role2 pri3 role3 pri4

      For a more intuitive understanding, you can refer to the following example:

      User Role Privilege Name Tom Application Developer Read Data, Write Data O&M expert Read data Database Administrator Administrator Privileges

      At this time, Tom's main role is an application developer, and Tom needs to call administrator authority, then Tom can use two methods:

      • To switch his role to database administrator, use the SET ROLE role statement.
      • To use all privileges of primary and secondary roles, use the SET SECONDARY ROLE ALL statement.

      The two statements are explained as follows:

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-secondary-role-all","title":"SET SECONDARY ROLE ALL","text":"

      The union of all roles of the user.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-secondary-role-none","title":"SET SECONDARY ROLE NONE","text":"

      Kicking all roles except the PRIMARY ROLE from the current session.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-role-role","title":"SET ROLE role","text":"

      Switching the current ROLE to a new role.

      "},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#examples","title":"Examples","text":"
      > drop role if exists use_role_1,use_role_2,use_role_3,use_role_4,use_role_5;\n> drop user if exists use_user_1,use_user_2;\n> drop database if exists use_db_1;\n> create role use_role_1,use_role_2,use_role_3,use_role_4,use_role_5;\n> create database use_db_1;\n> create user use_user_1 identified by '123456' default role use_role_1;\n##grant the `select`, `insert` and `update` privileges of all tables to use_role_1\n> grant select ,insert ,update on table *.* to use_role_1;\n#grant all the privileges of database to use_role_2\n> grant all on database * to use_role_2;\n#grant the use_role_2 to use_user_1\n> grant use_role_2 to use_user_1;\n#create table named `use_table_1`\n> create table use_db_1.use_table_1(a int,b varchar(20),c double );\n#set user use_user_1 primary and secondary roles are all available\n> set secondary role all;\n#show the privileges of `use_user_1`\n> show grants for 'use_user_1'@'localhost';\n+-----------------------------------------------------------+\n| Grants for use_user_1@localhost                           |\n+-----------------------------------------------------------+\n| GRANT select ON table *.* `use_user_1`@`localhost`        |\n| GRANT insert ON table *.* `use_user_1`@`localhost`        |\n| GRANT update ON table *.* `use_user_1`@`localhost`        |\n| GRANT connect ON account  `use_user_1`@`localhost`        |\n| GRANT database all ON database * `use_user_1`@`localhost` |\n+-----------------------------------------------------------+\n5 rows in set (0.01 sec)\n#It can be seen that the `use_user_1` has the default privilege to connect to MatrixOne; it also has the `select`, `insert` and `update` privileges on all tables, and also has all the privileges on the database\n
      "},{"location":"MatrixOne/Reference/System-Parameters/configuration-settings/","title":"Boot Parameters for standalone installation","text":"

      There are three configuration files cn.toml, tn.toml and log.toml in the matrixone/etc/launch-tae-CN-tae-TN/ directory.

      The parameters contained in each configuration file are explained as follows:

      "},{"location":"MatrixOne/Reference/System-Parameters/configuration-settings/#cntoml","title":"cn.toml","text":"Parameters Description service-type = \"CN\" Node Type data-dir = \"./mo-data\" Default data directory [log] level = \"info\" Log level, can be modified to info/debug/error/faltal format = \"console\" Log format max-size = 512 Log default length [hakeeper-client] HAkeeper default address and port, not recommended to change service-addresses = [ \"127.0.0.1:32001\",] [metacache] Metadata Cache memory-capacity = \"512MB\" Set the cache size for metadata, default is 512MB. The data caching feature results in slower first-time queries, but subsequent queries will be faster. [[fileservice]] fileservice, not recommended to change name = \"LOCAL\" fileservice storage type, local storage backend = \"DISK\" fileservice backend, disk [[fileservice]] name = \"SHARED\" fileservice storage type, S3 backend = \"DISK\" fileservice backend, disk data-dir = \"mo-data/s3\" s3 storage data directory [fileservice.cache] memory-capacity = \"512MB\" cache memory size used by fileservice disk-capacity = \"8GB\" cache disk size used by fileservice disk-path = \"mo-data/file-service-cache\" fileservice disk cache path disk-min-evict-interval = \"7m\" Interval for disk cache recovery, in seconds (s) or minutes (m) disk-evict-target = 0.8 Target capacity for disk cache recovery, parameter is the ratio of template capacity to total capacity [[fileservice]] name = \"ETL\" fileservice storage type, ETL backend = \"DISK-ETL\" fileservice backend, DISK-ETL [observability] Observability parameter, disabled by default disableTrace = true disableMetric = true [cn] cn code number, cannot be modified uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" [cn.Engine] Storage engine of the cn node, distributed tae, cannot be modified type = \"distributed-tae\" [cn.txn] enable-sacrificing-freshness = false When set to true and push mode, this parameter does not guarantee that a transaction can see the latest committed data. Instead, it uses the latest Logtail commit timestamp received by the current CN as the transaction start time. This setting ensures that a transaction on the same database connection can see the data written by its previously committed transactions. enable-cn-based-consistency = false When the above parameter is set to true, it ensures external consistency on the same CN. When a transaction starts, it can see the data written by previously committed transactions."},{"location":"MatrixOne/Reference/System-Parameters/configuration-settings/#tntoml","title":"tn.toml","text":"Parameters Description service-type = \"TN\" Node Type data-dir = \"./mo-data\" Default data directory [log] level = \"info\" Log level, can be modified to info/debug/error/faltal format = \"console\" Log format max-size = 512 Log default length [hakeeper-client] HAkeeper default address and port, not recommended to change service-addresses = [ \"127.0.0.1:32001\",] [metacache] Metadata Cache memory-capacity = \"512MB\" Set the cache size for metadata, default is 512MB. The data caching feature results in slower first-time queries, but subsequent queries will be faster. [[fileservice]] fileservice, not recommended to change name = \"LOCAL\" fileservice storage type, local storage backend = \"DISK\" fileservice backend, disk [[fileservice]] name = \"SHARED\" fileservice storage type, S3 backend = \"DISK\" fileservice backend, disk data-dir = \"mo-data/s3\" s3 storage data directory [fileservice.cache] memory-capacity = \"512MB\" cache memory size used by fileservice disk-capacity = \"8GB\" cache disk size used by fileservice disk-path = \"mo-data/file-service-cache\" fileservice disk cache path disk-min-evict-interval = \"7m\" Interval for disk cache recovery, in seconds (s) or minutes (m) disk-evict-target = 0.8 Target capacity for disk cache recovery, parameter is the ratio of template capacity to total capacity [[fileservice]] name = \"ETL\" fileservice storage type, ETL backend = \"DISK-ETL\" fileservice backend, DISK-ETL [tn] uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" uuid of TN, cannot be modified [tn.Txn.Storage] The storage engine of the TN transaction backend, cannot be modified backend = \"TAE\" log-backend = \"logservice\" [tn.Txn] incremental-dedup = false If set to false, TN initiates deduplication for all data. If set to true, TN will only deduplicate primary key data after the snapshot timestamp. [tn.Ckp] the checkpoint related parameters of TN, not recommended to change flush-interval = \"60s\" internal refresh interval min-count = 100 Minimum number of checkpoints scan-interval = \"5s\" internal scan interval incremental-interval = \"180s\" checkpoint increment interval global-min-count = 60 The global minimum number of TN checkpoints [tn.LogtailServer] listen-address = \"0.0.0.0:32003\" logtail listening port service-address = \"127.0.0.1:32003\" logtail internal access address rpc-max-message-size = \"16KiB\" maximum rpc message size used by logtail rpc-payload-copy-buffer-size = \"16KiB\" rpc copy buffer size rpc-enable-checksum = true whether to enable rpc checksum logtail-collect-interval = \"2ms\" logtail statistics collection interval logtail-response-send-timeout = \"10s\" logtail sending timeout max-logtail-fetch-failure = 5 The maximum number of failures allowed by fetching logtail"},{"location":"MatrixOne/Reference/System-Parameters/configuration-settings/#logtoml","title":"log.toml","text":"Parameters Description service-type = \"LOG\" Node Type data-dir = \"./mo-data\" Default data directory [log] level = \"info\" Log level, can be modified to info/debug/error/faltal format = \"console\" Log format max-size = 512 Log default length [[fileservice]] fileservice configuration, not recommended to change name = \"LOCAL\" fileservice storage type, local storage backend = \"DISK\" fileservice backend media, disk [[fileservice]] name = \"SHARED\" fileservice storage type, S3 backend = \"DISK\" fileservice backend, disk data-dir = \"mo-data/s3\" s3 storage data directory [fileservice.cache] memory-capacity = \"512MB\" cache memory size used by fileservice disk-capacity = \"8GB\" cache disk size used by fileservice disk-path = \"mo-data/file-service-cache\" fileservice disk cache path disk-min-evict-interval = \"7m\" Interval for disk cache recovery, in seconds (s) or minutes (m) disk-evict-target = 0.8 Target capacity for disk cache recovery, parameter is the ratio of template capacity to total capacity [[fileservice]] name = \"ETL\" fileservice storage type, ETL backend = \"DISK-ETL\" fileservice backend, DISK-ETL [observability] Monitor parameters statusPort = 7001 Reserve the monitoring port of Prometheus enableTraceDebug = false Enable the dbug mode of the trace [hakeeper-client] HAkeeper default address and port, not recommended to change service-addresses = [ \"127.0.0.1:32001\",] [logservice] The parameters of logservice, cannot be modified deployment-id = 1 Deployment ID of logservice uuid = \"7c4dccb4-4d3c-41f8-b482-5251dc7a41bf\" Node ID of logservice raft-address = \"127.0.0.1:32000\" The address of the raft protocol logservice-address = \"127.0.0.1:32001\" logservice address gossip-address = \"127.0.0.1:32002\" The address of the gossip protocol gossip-seed-addresses = [\"127.0.0.1:32002\",] The root node address of the gossip protocol gossip-allow-self-as-seed = true Whether to allow the gossip protocol to use this node as a root node [logservice.BootstrapConfig] Bootstrap parameters, cannot be modified bootstrap-cluster = true Whether bootstrap cluster launchs num-of-log-shards = 1 The number of shards of logservice num-of-tn-shards = 1 The number of shards of tn num-of-log-shard-replicas = 1 The number of replicas of the logservice shard init-hakeeper-members = [ \"131072:7c4dccb4-4d3c-41f8-b482-5251dc7a41bf\",] Initialize members of hakeeper"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/","title":"Distributed Common Parameters Configuration","text":"

      In the matrixone/etc/launch-with-proxy/ directory, there are four configuration files: cn.toml, tn.toml, proxy.toml, and log.toml. The parameters contained in these configuration files are explained below:

      "},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#cntoml","title":"cn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#default-parameters","title":"Default Parameters","text":"

      The cn.toml file contains the following default parameters:

      Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [cn] cn node, not editable / port-base Starting port number used by \"cn\". Find an available port for internal services by incrementing from this base port number, continuously checking the next 20 ports port-base = 18000 service-host Service connection address used for registration with HAKeeper service-host = \"127.0.0.1\" [cn.frontend] Frontend configuration section port Port for MatrixOne to listen on and for client connections port = 6001 host Listening IP address host = \"0.0.0.0\" [fileservice.s3] S3 File service configuration section bucket S3 bucket name bucket = \"my-bucket\" key-prefix S3 key prefix key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#extended-parameters","title":"Extended Parameters","text":"

      In the cn.toml file, you can also customize and add the following configuration parameters:

      Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"log1.log\" [cn.frontend] Frontend configuration section unix-socket Listen on Unix domain socket unix-socket = \"/tmp/mysql.sock\" lengthOfQueryPrinted Console output query length lengthOfQueryPrinted = 200000 enableTls Enable TLS enableTls = false tlsCaFile Client SSL CA list file path tlsCaFile = '' tlsCertFile Client X509 PEM format key file path tlsCertFile = '' tlsKeyFile Client X509 PEM format key file path tlsKeyFile = '' saveQueryResult Save query results saveQueryResult = false queryResultTimeout Query result timeout queryResultTimeout = 24 queryResultMaxsize Maximum query result size queryResultMaxsize = 100 lowerCaseTableNames Case sensitivity of identifiers. The default value is 1, which means case-insensitive lowerCaseTableNames = 1 [cn.Txn] Transaction configuration section isolation Transaction isolation level. This parameter configures the isolation level on the node (cn). The isolation level defines how transactions behave when dealing with concurrent operations. By default, if the isolation level (Isolation) is not set and the transaction mode (Mode) is set to optimistic, the isolation level will be set to Serializable Isolation (SI). When the transaction mode is pessimistic, the isolation level will be set to Read Committed Isolation (RC). Default: RC isolation = \"RC\" mode Transaction mode. This parameter configures the transaction mode on the node (cn). The transaction mode defines how operations and concurrency are handled in transactions. Valid values are optimistic and pessimistic, with the default being pessimistic. mode = \"pessimistic\" [fileservice.s3] endpoint S3 endpoint address endpoint = \"s3.amazonaws.com\" [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" disk-path Disk cache path disk-path = \"/var/matrixone/cache\" disk-capacity Disk cache capacity disk-capacity = \"8GB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. statusPort = 7001 enableMetricToProm Enable metric service. If set to true, metric service will be enabled enableMetricToProm = false disableMetric Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to disableMetric = false disableTrace Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data disableTrace = false longQueryTime Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#tntoml","title":"tn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#default-parameters_1","title":"Default Parameters","text":"

      The tn.toml file contains the following default parameters:

      Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [dn] TN node, not editable uuid Unique identifier of TN, not editable uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" port-base Starting port number used by \"TN\". Find an available port for internal services by incrementing from this base port number, continuously checking the next 20 ports port-base = 19000 service-host Service connection address used for registration with HAKeeper service-host = \"0.0.0.0\" [fileservice.s3] S3 File service configuration section bucket S3 bucket name bucket = \"my-bucket\" key-prefix S3 key prefix key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#extended-parameters_1","title":"Extended Parameters","text":"

      In the tn.toml file, you can also customize and add the following configuration parameters:

      | Parameter |

      Explanation | Example | |-------------------|-------------------------------------------|---------------------------| | [log] | Log configuration section | | | format | Log save format as JSON or other | format = \"console\" | | filename | Log filename | filename = \"log1.log\" | | [dn.LogtailServer]| Logtail server configuration section | | | rpc-enable-checksum| Enable RPC checksum | rpc-enable-checksum = false| | [fileservice.s3] | | | | endpoint | S3 endpoint address | endpoint = \"s3.amazonaws.com\"| | [fileservice.cache]| File service cache configuration section | | | memory-capacity | Cache memory size | memory-capacity = \"512MB\" | | disk-path | Disk cache path | disk-path = \"/var/matrixone/cache\"| | disk-capacity | Disk cache capacity | disk-capacity = \"8GB\"| | [observability] | Observability parameters | | | host | Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. | host = \"0.0.0.0\" | | statusPort | Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. | statusPort = 7001 | | enableMetricToProm | Enable metric service. If set to true, metric service will be enabled | enableMetricToProm = false| | disableMetric | Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to | disableMetric = false | | disableTrace | Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data | disableTrace = false | | longQueryTime | Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. | longQueryTime = 1.0 |

      "},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#logtoml","title":"log.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#default-parameters_2","title":"Default Parameters","text":"

      The log.toml file contains the following default parameters:

      Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [logservice] Logservice configuration section uuid Unique identifier of Logservice, not editable uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" data-dir Default data directory data-dir = \"./mo-data/logservice\" [fileservice.s3] S3 File service configuration section bucket S3 bucket name bucket = \"my-bucket\" key-prefix S3 key prefix key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#extended-parameters_2","title":"Extended Parameters","text":"

      In the log.toml file, you can also customize and add the following configuration parameters:

      Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"log1.log\" [logservice.BootstrapConfig] num-of-log-shards num-of-log-shards = 0 num-of-tn-shards num-of-tn-shards = 0 num-of-log-shard-replicas num-of-log-shard-replicas = 0 [fileservice.s3] endpoint S3 endpoint address endpoint = \"s3.amazonaws.com\" [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" disk-path Disk cache path disk-path = \"/var/matrixone/cache\" disk-capacity Disk cache capacity disk-capacity = \"8GB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. statusPort = 7001 enableMetricToProm Enable metric service. If set to true, metric service will be enabled enableMetricToProm = false disableMetric Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to disableMetric = false disableTrace Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data disableTrace = false longQueryTime Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#proxytoml","title":"proxy.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#default-parameters_3","title":"Default Parameters","text":"

      The proxy.toml file contains the following default parameters:

      Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [proxy] Proxy configuration section listen-address Listen address, default is 0.0.0.0:6009 listen-address = \"0.0.0.0:6009\" [fileservice.s3] S3 File service configuration section bucket S3 bucket name bucket = \"my-bucket\" key-prefix S3 key prefix key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#extended-parameters_3","title":"Extended Parameters","text":"

      In the proxy.toml file, you can also customize and add the following configuration parameters:

      Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"log1.log

      \" | | [proxy] | Proxy configuration section | | | rebalance-interval | Rebalance interval. This is the time interval between two rebalance operations. In distributed systems, rebalance operations are performed to balance the load between servers, ensuring each server has a similar workload. | rebalance-interval = 30 | | rebalance-disabled | Rebalance disabled flag. If set to true, the rebalance is disabled, and the system won't perform rebalance operations automatically. | rebalance-disabled = false| | rebalance-tolerance| Rebalance tolerance. This parameter indicates the tolerance level of the rebalance. When the number of connections exceeds the average value avg * (1 + tolerance), the connections will be migrated to other CN (Compute Node) servers. The tolerance value should be less than 1, defining to what extent the number of connections can exceed the average without triggering a rebalance operation. For example, if tolerance is set to 0.3 when the number of connections on a server exceeds 30% of the average connection count, rebalance operations will migrate connections to other servers to balance the load. | rebalance-tolerance = 0.3 | | [fileservice.s3] | | | | endpoint | S3 endpoint address | endpoint = \"s3.amazonaws.com\"| | [fileservice.cache]| File service cache configuration section | | | memory-capacity | Cache memory size | memory-capacity = \"512MB\" | | disk-path | Disk cache path | disk-path = \"/var/matrixone/cache\"| | disk-capacity | Disk cache capacity | disk-capacity = \"8GB\"| | [observability] | Observability parameters | | | host | Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. | host = \"0.0.0.0\" | | statusPort | Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. | statusPort = 7001 | | enableMetricToProm | Enable metric service. If set to true, metric service will be enabled | enableMetricToProm = false| | disableMetric | Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to | disableMetric = false | | disableTrace | Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data | disableTrace = false | | longQueryTime | Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. | longQueryTime = 1.0 |

      "},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/","title":"Standalone Common Parameters Configuration","text":"

      Four configuration files are in the matrixone/etc/launch/ directory: cn.toml, tn.toml, proxy.toml, and log.toml, used to configure standard parameters.

      "},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#cntoml","title":"cn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#default-parameters","title":"Default Parameters","text":"

      The cn.toml file contains the following default parameters:

      Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [cn] cn node, not editable / port-base Starting port number used by \"cn\", continuously finding 20 available ports for internal services starting from this port number port-base = 18000 service-host Service connection address used for registration to HAKeeper service-host = \"127.0.0.1\" [cn.frontend] Frontend configuration section port Port for MatrixOne to listen and for client connections port = 6001 host Listening IP address host = \"0.0.0.0\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#extended-parameters","title":"Extended Parameters","text":"

      In the cn.toml file, you can also customize and add the following configuration parameters:

      Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"mo.log\" [cn.frontend] Frontend configuration section unix-socket Listen to Unix domain interface unix-socket = \"/tmp/mysql.sock\" lengthOfQueryPrinted Console output query length lengthOfQueryPrinted = 200000 enableTls Enable TLS enableTls = false tlsCaFile Client SSL CA list file path tlsCaFile = '' tlsCertFile Client X509 PEM format key file path tlsCertFile = '' tlsKeyFile Client X509 PEM format key file path tlsKeyFile = '' saveQueryResult Save query results saveQueryResult = false queryResultTimeout Query result timeout time queryResultTimeout = 24 queryResultMaxsize Query result maximum size queryResultMaxsize = 100 lowerCaseTableNames Identifier case sensitivity, the default parameter value is 1, indicating case insensitivity lowerCaseTableNames = 1 [cn.Txn] Transaction configuration section isolation Transaction isolation level, used to configure the transaction isolation level on the \"cn\" node. The isolation level defines the behavior of transactions during concurrent operations. By default, if the isolation level (Isolation) is not set, it will be set to Serializable Isolation (SI) when the transaction mode (Mode) is set to optimistic and to Read Committed Isolation (RC) when the transaction mode is set to pessimistic. Default: RC isolation = \"RC\" mode Transaction mode configures the transaction mode on the \"cn\" node. The transaction mode defines how operations and concurrency are handled in a transaction. Possible values are optimistic and pessimistic, with the default value being optimistic. mode = \"optimistic\" [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. statusPort = 7001 enableMetricToProm Enable metric service. If set to true, metric service will be enabled enableMetricToProm = false disableMetric Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to disableMetric = false disableTrace Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data disableTrace = false longQueryTime Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#tntoml","title":"tn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#default-parameters_1","title":"Default Parameters","text":"

      The tn.toml file contains the following default parameters:

      Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [dn] TN node, not editable uuid Unique identifier of TN, not editable uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" port-base Starting port number used by \"TN\", continuously finding 20 available ports for internal services starting from this port number port-base = 19000 service-host Service connection address used for registration to HAKeeper service-host = \"0.0.0.0\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#extended-parameters_1","title":"Extended Parameters","text":"

      In the tn.toml file, you can also customize and add the following configuration parameters:

      Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"tn.log\" [dn.LogtailServer] Logtail Server configuration section rpc-enable-checksum Enable RPC checksum rpc-enable-checksum = false [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically

      Provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. | statusPort = 7001 | | enableMetricToProm | Enable metric service. If set to true, metric service will be enabled | enableMetricToProm = false| | disableMetric | Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to | disableMetric = false | | disableTrace | Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data | disableTrace = false | | longQueryTime | Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. | longQueryTime = 1.0 |

      "},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#logtoml","title":"log.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#default-parameters_2","title":"Default Parameters","text":"

      The log.toml file contains the following default parameters:

      Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [logservice] Logservice configuration section uuid Unique identifier of Logservice, not editable uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" data-dir Default data directory data-dir = \"./mo-data\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#extended-parameters_2","title":"Extended Parameters","text":"

      In the log.toml file, you can also customize and add the following configuration parameters:

      Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"log1.log\" [logservice] Logservice configuration section logservice-address Logservice address logservice-address = \"0.0.0.0:32000\" raft-address Raft address raft-address = \"0.0.0.0:32001\" gossip-address Gossip address gossip-address = \"0.0.0.0:32002\" gossip-seed-addresses Gossip seed node addresses gossip-seed-addresses = \" \" [LogtailServer.BootstrapConfig] LogtailServer bootstrap configuration section init-hakeeper-members Initial HAKeeper members init-hakeeper-members = \" \" [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" [observability] Observability parameters host Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. host = \"0.0.0.0\" statusPort Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. statusPort = 7001 enableMetricToProm Enable metric service. If set to true, metric service will be enabled enableMetricToProm = false disableMetric Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to disableMetric = false disableTrace Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data disableTrace = false longQueryTime Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#proxytoml","title":"proxy.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#default-parameters_3","title":"Default Parameters","text":"

      The proxy.toml file contains the following default parameters:

      Parameter Explanation Example [log] Log configuration section level Log level, default is info, can be modified to different levels level = \"info\" [proxy] Proxy configuration section listen-address Listen address, default is 0.0.0.0:6009 listen-address = \"0.0.0.0:6009\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#extended-parameters_3","title":"Extended Parameters","text":"

      In the proxy.toml file, you can also customize and add the following configuration parameters:

      Parameter Explanation Example [log] Log configuration section format Log save format as JSON or other format = \"console\" filename Log filename filename = \"proxy.log\" [proxy] Proxy configuration section rebalance-interval Rebalance interval. This is the time interval between two rebalance operations. In distributed systems, rebalance operations are performed to balance the load between servers and ensure each server has a similar workload. rebalance-interval = 30 rebalance-disabled Rebalance disable flag. If set to true, the rebalance will be disabled, and the system will not automatically perform rebalance operations. rebalance-disabled = false rebalance-tolerance Rebalance tolerance. This parameter indicates the tolerance of the rebalance. When the number of connections exceeds the average value avg * (1 + tolerance), the connections will be migrated to other CN (compute node) servers. The tolerance value should be less than 1, defining to what extent the number of connections can exceed the average value without triggering a rebalance operation. For example, suppose tolerance is set to 0.3 when a server's connections exceed 30% of the average connection count. In that case, the rebalance operation will migrate connections to other servers to balance the load. rebalance-tolerance = 0.3 [fileservice.cache] File service cache configuration section memory-capacity Cache memory size memory-capacity = \"512MB\" [observability] Observability parameters

      | | | host | Exposed metrics service listening IP. This parameter specifies the IP address that the metrics service listens on. | host = \"0.0.0.0\" | | statusPort | Prometheus monitoring port. This parameter defines the port number that the metrics service listens on. Metrics services typically provide metric data via HTTP. This parameter and the host parameter form the access address for the metrics service. | statusPort = 7001 | | enableMetricToProm | Enable metric service. If set to true, metric service will be enabled | enableMetricToProm = false| | disableMetric | Disable metric collection. If set to true, the system will not collect any metric data, and the metric service port will not be listened to | disableMetric = false | | disableTrace | Disable trace collection. If set to true, the system will stop collecting any trace, metric, and log data | disableTrace = false | | longQueryTime | Log queries that exceed execution time. This parameter defines a threshold in seconds to filter out queries that exceed this threshold in execution time. The execution plans (ExecPlan) of these queries are then logged for later analysis. If set to 0.0, all execution plans of queries will be logged. | longQueryTime = 1.0 |

      "},{"location":"MatrixOne/Reference/System-Parameters/system-parameter/","title":"System Parameters Overview","text":"

      In MatrixOne, various database system parameters are involved, some configured through configuration files and take effect only during startup. Such parameters are referred to as static parameters.

      Another type is parameters that can be dynamically configured on the client and take effect immediately. These are referred to as dynamic parameters. Both parameters are used to configure and control the behavior of the MatrixOne server.

      Dynamic parameter modifications can be done at the session and global levels.

      • Global Level Parameter Configuration: Pertains to parameter configuration for the current tenant in MatrixOne. These parameters affect all new sessions connected to this tenant. Global parameters are persistently stored in the metadata table mo_catalog.mo_mysql_compatbility_mode when the MatrixOne server starts, and changes to global parameters will take effect on the next login.

      • Session Level Parameter Configuration: Pertains to parameter configuration for an individual MatrixOne connection. These parameters only affect the behavior of that connection. When the connection is established, session parameters are read from mo_catalog.mo_mysql_compatbility_mode and can be configured for the current connection using client commands. The session parameter configuration will be reset to the default values when the connection is closed.

      It's worth noting that MatrixOne is a multi-tenant database, and the set global command will only affect the current tenant.

      "},{"location":"MatrixOne/Reference/System-Parameters/system-parameter/#reference-documentation","title":"Reference Documentation","text":"

      For documentation on static parameters, you can refer to:

      • Standalone Common Parameters Configuration
      • Distributed Common Parameters Configuration

      For documentation on dynamic parameters, you can refer to:

      • System Variables Overview
      • Custom Variables
      "},{"location":"MatrixOne/Reference/Variable/custom-variable/","title":"Setting custom variable","text":"

      In MatrixOne, custom variables are a mechanism for storing and manipulating values. Custom variables can be set through the the'SET'statement, and the value can be kept unchanged throughout the session. You can customize variables through the SET command and use it in SQL. The specific syntax is as follows:

      SET @variable_name = value;\n

      @variable_name is the name of the custom variable, and value is the value to be assigned to the variable. Once defined, the variable can be used in the SQL statement instead of the actual value.

      For example, the following statement will define a variable named @max_salary and set it to 100000:

      SET @max_salary = 100000;\n--View the value set by the @max_salary variable\nmysql> select @max_salary;\n+-------------+\n| @max_salary |\n+-------------+\n| 100000      |\n+-------------+\n1 row in set (0.01 sec)\n

      When using a custom variable, you can include it in an SQL statement and reference it as @variable_name. For example, the following statement will return all employee records whose salary is less than @max_salary:

      SELECT * FROM employees WHERE salary < @max_salary;\n

      You can affect the result of an SQL query by changing the value of a custom variable. For example, the following statement will change the value of @max_salary and return a new query result:

      SET @max_salary = 80000;\nSELECT * FROM employees WHERE salary < @max_salary;\n

      It should be noted that custom variables only remain valid in the current session, and when the session ends, the variables will be deleted and released. In addition, variable names must start with the @ symbol and are case-sensitive.

      "},{"location":"MatrixOne/Reference/Variable/custom-variable/#simple-example","title":"Simple Example","text":"

      Now let's define two variables, a and b:

      > SET  @a=2, @b=3;\nQuery OK, 0 rows affected (0.00 sec)\n\n> select @a;\n+------+\n| @a   |\n+------+\n|    2 |\n+------+\n1 row in set (0.00 sec)\n\n> select @b;\n+------+\n| @b   |\n+------+\n|    3 |\n+------+\n1 row in set (0.00 sec)\n

      Using custom variables in SQL:

      > create table t1(a int,b varchar(1));\nQuery OK, 0 rows affected (0.02 sec)\n\n> insert into t1 values(@a,@b);\nQuery OK, 1 row affected (0.02 sec)\n\n> select * from t1;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 | 3    |\n+------+------+\n1 row in set (0.01 sec)\n

      Note

      The variables a and b are both ints here. If you want a string of 2 or 3, it is recommended to use SET @a ='2', @b='3';.

      "},{"location":"MatrixOne/Reference/Variable/custom-variable/#mysql-compatibility","title":"MySQL compatibility","text":"

      MatrixOne supports the session level, which is the same as MySQL support.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/","title":"lower_case_table_names support","text":"

      There are 5 different modes for the MatrixOne case sensitivity, and the case parameter lower_case_table_names can be set to 0, 1, 2, 3, or 4.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#parameter-explanation","title":"Parameter Explanation","text":""},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-0","title":"Setting Parameter Value to 0","text":"

      Setting lower_case_table_names to 0 stores identifiers as the original strings, and name comparisons are case sensitive.

      Examples

      set global lower_case_table_names = 0;\ncreate table Tt (Aa int);\ninsert into Tt values (1), (2), (3);\n\nmysql> select Aa from Tt;\n+------+\n| Aa   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
      "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-1","title":"Setting Parameter Value to 1","text":"

      Setting lower_case_table_names to 1 stores identifiers as lowercase, and name comparisons are case insensitive.

      Examples

      set global lower_case_table_names = 1;\ncreate table Tt (Aa int);\ninsert into Tt values (1), (2), (3);\n\nmysql> select Aa from Tt;\n+------+\n| aa   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
      set global lower_case_table_names = 1;\ncreate table t(a int);\ninsert into t values(1), (2), (3);\n\n-- Column aliases display the original string when the result set is returned, but name comparisons are case insensitive, as shown in the following example:\nmysql> select a as Aa from t;\n+------+\n| Aa   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
      "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-2","title":"Setting Parameter Value to 2","text":"

      Setting lower_case_table_names to 2 stores identifiers as the original strings, and name comparisons are case insensitive.

      Examples

      set global lower_case_table_names = 2;\ncreate table Tt (Aa int);\ninsert into tt values (1), (2), (3);\n\nmysql> select AA from tt;\n+------+\n| Aa   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
      "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-3","title":"Setting Parameter Value to 3","text":"

      Setting lower_case_table_names to 3 stores identifiers as uppercase, and name comparisons are case insensitive.

      Examples

      set global lower_case_table_names = 3;\ncreate table Tt (Aa int);\ninsert into Tt values (1), (2), (3);\n\nmysql> select Aa from Tt;\n+------+\n| AA   |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n3 rows in set (0.03 sec)\n
      "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#setting-parameter-value-to-4","title":"Setting Parameter Value to 4","text":"

      Setting lower_case_table_names to 4 stores identifiers with `` as the original strings and case sensitive, while others are converted to lowercase.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#configuration-parameters","title":"Configuration Parameters","text":"
      • To configure globally, insert the following code in the cn.toml configuration file before starting MatrixOne:
      [cn.frontend]\nlowerCaseTableNames = \"0\" // default is 1\n# 0 stores identifiers as the original strings and name comparisons are case sensitive\n# 1 stores identifiers as lowercase and name comparisons are case insensitive\n# 2 stores identifiers as the original strings and name comparisons are case insensitive\n# 3 stores identifiers as uppercase and name comparisons are case insensitive\n# 4 stores identifiers with `` as the original strings and case sensitive, while others are converted to lowercase\n

      When configuring globally, each cn needs to be configured if multiple cns are started. For configuration file parameter instructions, seeBoot Parameters for standalone installation.

      Note

      Currently, you can only set the parameter to 0 or 1. However, the parameter 2,3 or 4 is not supported.

      • To enable saving query results only for the current session:
      set global lower_case_table_names = 1;\n

      When creating a database, MatrixOne automatically obtains the value of lower_case_table_names as the default value for initializing the database configuration.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#features-that-are-different-from-mysql","title":"Features that are different from MySQL","text":"

      MatrixOne lower_case_table_names is set to 1 by default and only supports setting the value to 0 or 1.

      The default value in MySQL:

      • On Linux: 0. Table and database names are stored on disk using the letter case specified in the CREATE TABLE or CREATE DATABASE statement. Name comparisons are case-sensitive.
      • On Windows: 1. It means that table names are stored in lowercase on disk, and name comparisons are not case-sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.
      • On macOS: 2. Table and database names are stored on disk using the letter case specified in the CREATE TABLE or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case-sensitive.
      "},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#constraints","title":"Constraints","text":"

      MatrixOne system variable lower_case_table_names does not currently support setting values 2, 3, or 4.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/","title":"save_query_result Support","text":"

      After enabling save_query_result, MatrixOne will save the query results.

      Three parameters affect the saving of query results:

      • save_query_result: enables/disables the saving of query results.
      • query_result_timeout: sets the time for saving query results.
      • query_result_maxsize: sets the maximum size of a single query result.
      "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#enable-save_query_result","title":"Enable save_query_result","text":"

      Enable saving query results for the current session only:

      -- The default is off\nset global save_query_result = on  
      • If you need to enable it globally, you can modify the configuration file cn.toml before starting MatrixOne, insert the following code, and save it:
      [cn.frontend]\nsaveQueryResult = \"on\"  // The default is off\n
      "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#set-the-saving-time","title":"Set the saving time","text":"

      Set the save time unit to hours.

      • Enable query_result_timeout only for the current session:
      -- The default is 24\nset global query_result_timeout = 48\n
      • If you need to enable it globally, you can modify the configuration file cn.toml before starting MatrixOne, insert the following code, and save it:
      [cn.frontend]\nqueryResultTimeout = 48  //The default is 24\n

      Note: If the save time is set to a shorter value than the previous one, it will not affect the previous save results.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#set-the-maximum-value-of-a-single-query-result","title":"Set the maximum value of a single query result","text":"

      Set the maximum unit of a single query result to MB.

      • Set the maximum value of query results for the current session only:
      -- The default is 100\nset global query_result_maxsize = 200\n
      • If you need to enable it globally, you can modify the configuration file cn.toml before starting MatrixOne, insert the following code, and save it:
      [cn.frontend]\nqueryResultMaxsize = 200 // The default is 100\n

      Note: If the maximum value of a single query result is set smaller than the previous setting, it will not affect the size of the last saved results.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#query-metadata-information","title":"Query metadata information","text":"

      You can use the following SQL statement to query metadata information:

      select * from meta_scan(query_id) as u;\n\u5f53\u524d account_id\nselect query_id from meta_scan(query_id) as u;\n

      The metadata information is as follows:

      Column Name Type Remarks query_id uuid query result ID statement text SQL statement executed account_id uint32 account ID role_id uint32 role ID result_path text The path to save the query results, the default is the mo-data/s3 path of the matrixone folder, if you want to modify the default path, you need to modify data-dir = \"mo-data/s3\" in the configuration file . For a description of configuration file parameters, see Common Parameter Configuration created_time timestamp creation time result_size float Result size in MB. tables text tables used by SQL user_id uint32 user ID expired_time timestamp timeout of query result column_map text If the query has a column result name with the same name, the result scan will remap the column name"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#save-query-results","title":"Save query results","text":"

      You can store query results locally or in S3.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#syntax","title":"Syntax","text":"
      MODUMP QUERY_RESULT query_id INTO s3_path\n[FIELDS TERMINATED BY 'char']\n[ENCLOSED BY 'char']\n[LINES TERMINATED BY 'string']\n[header 'bool']\n[MAX_FILE_SIZE unsigned_number]\n
      • query_id: A string of UUID.

      • s3_path: the path where the query result file is saved. The default is the mo-data/s3 path in the matrixone folder. If you need to modify the default path, you must modify data-dir = \"mo-data/s3\" in the configuration file. For more information about configuration file parameters, see Common Parameter Configuration

      root@rootMacBook-Pro 02matrixone % cd matrixone/mo-data\nroot@rootMacBook-Pro mo-data % ls\ntn-data         etl             local           logservice-data s3\n

      Note: If you need to export the csv file. The path needs to start with etl:.

      • [FIELDS TERMINATED BY 'char']: optional parameter. Field delimiter, the default is single quote '.

      • [ENCLOSED BY 'char']: optional parameter. Fields include symbols, which default to double quotes \".

      • [LINES TERMINATED BY 'string']: optional parameter. The end of line symbol, the default is the newline symbol \\n.

      The first row of the csv file is a header row for each column name.- [header 'bool']: optional parameter. The bool type can choose true or false.

      • [MAX_FILE_SIZE unsigned_number]: optional parameter. The maximum file size of the file is in KB. The default is 0.
      "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#example","title":"Example","text":"
      -- Enable save_query_result\nmysql> set global save_query_result = on;\n-- Set the saving time to 24 hours\nmysql> set global query_result_timeout = 24;\n-- Set the maximum value of a single query result to 100M\nmysql> set global query_result_maxsize = 200;\n-- Create a table and insert datas\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\n-- You can check the table structure to confirm that the inserted data is correct\nmysql> select a from t1;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.16 sec)\n-- Query the most recently executed query ID in the current session\nmysql> select last_query_id();\n+--------------------------------------+\n| last_query_id()                      |\n+--------------------------------------+\n| c187873e-c25d-11ed-aa5a-acde48001122 |\n+--------------------------------------+\n1 row in set (0.12 sec)\n-- Get the query results for this query ID\nmysql> select * from result_scan('c187873e-c25d-11ed-aa5a-acde48001122') as t;\n+------+\n| a    |\n+------+\n|    1 |\n+------+\n1 row in set (0.01 sec)\n-- Check the metadata for this query ID\nmysql> select * from meta_scan('c187873e-c25d-11ed-aa5a-acde48001122') as t;\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| query_id                             | statement        | account_id | role_id | result_path                                                         | create_time         | result_size          | tables | user_id | expired_time        | ColumnMap |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| c187873e-c25d-11ed-aa5a-acde48001122 | select a from t1 |          0 |       0 | SHARED:/query_result/sys_c187873e-c25d-11ed-aa5a-acde48001122_1.blk | 2023-03-14 19:45:45 | 0.000003814697265625 | t1     |       1 | 2023-03-15 19:45:45 | t1.a -> a |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n1 row in set (0.00 sec)\n\n-- Save query results locally\nMODUMP QUERY_RESULT c187873e-c25d-11ed-aa5a-acde48001122 INTO 'etl:your_local_path';\n
      "},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#constraints","title":"Constraints","text":"

      MatrixOne only supports on saving the query results of SELECT and SHOW.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/","title":"SQL Mode","text":"

      sql_mode is a system parameter in MatrixOne, which specifies the mode in which MatrixOne executes queries and operations. sql_mode can affect the syntax and semantic rules of MatrixOne, thus altering the behavior of MatrixOne's SQL queries. This article will introduce the purpose of sql_mode, standard modes, and how to set sql_mode.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#why-set-sql_mode","title":"Why set sql_mode","text":"

      sql_mode can control the behavior of MatrixOne, including how to handle NULL values, perform insert operations, and sort and compare strings. It can ensure strict compliance with SQL standards and avoid non-standard behavior. In addition, sql_mode can help developers better identify errors and potential issues in SQL statements.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#default-modes-of-sql_mode","title":"Default modes of sql_mode","text":"

      The following are the standard modes of sql_mode, which are also the default modes in MatrixOne:

      • ONLY_FULL_GROUP_BY: The GROUP BY clause is used to group query results and perform aggregate calculations on each group, such as COUNT, SUM, AVG, etc. In the GROUP BY clause, the specified columns are the grouping columns. Other columns can be identified in the SELECT list, including aggregate or non-aggregate function columns. Without the ONLY_FULL_GROUP_BY mode, if a non-aggregate function column is set in the SELECT list, MatrixOne will select any value that matches the GROUP BY column use it to calculate the aggregate function by default.

      Note

      If your table structure is complex and for ease of querying, you can disable the ONLY_FULL_GROUP_BY mode.

      • STRICT_TRANS_TABLES: When executing INSERT and UPDATE statements, an error will be reported if the data does not conform to the rules defined for the table.

      • NO_ZERO_IN_DATE: Prohibits inserting zero values into fields of type DATE or DATETIME.

      • NO_ZERO_DATE: Prohibits inserting or updating the field value of 0000-00-00 as a date or datetime type. The purpose of this mode is to avoid inserting invalid or illegal values into a date or datetime field and require the use of a valid date or datetime values. If such an operation is performed, an error will be reported. It should be noted that the NO_ZERO_DATE mode is only effective for insert or update operations. For existing 0000-00-00 values, they can still be queried and used.

      • ERROR_FOR_DIVISION_BY_ZERO: This mode throws an error when dividing by zero.

      • NO_ENGINE_SUBSTITUTION: This mode throws an error when executing ALTER TABLE or CREATE TABLE statements. The purpose of this mode is to force the use of the specified storage engine, preventing data inconsistencies or performance issues. The specified storage engine is unavailable or does not exist instead of automatically substituting it with another available storage engine. If automatic substitution of storage engines is desired, this mode can be removed from the sql_mode or set to other supported sql_mode methods. It is important to note that this mode only applies to ALTER TABLE or CREATE TABLE statements and does not affect the storage engine of existing tables.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#optional-modes-for-sql_mode","title":"Optional modes for sql_mode","text":"
      • ANSI: ANSI is a standard SQL language specification developed by ANSI (American National Standards Institute). In ANSI mode, SQL statements must comply with the ANSI SQL standard, which means that specific SQL language extensions or features specific to a particular database cannot be used.

      • ALLOW_INVALID_DATES: ALLOW_INVALID_DATES, also known as \"loose mode\" in MatrixOne SQL mode, allows the insertion of invalid dates in standard date format, such as '0000-00-00' or '2000-00-00'. This mode exists to be compatible with some earlier versions of MySQL and non-standard date formats. It is important to note that inserting invalid dates in ALLOW_INVALID_DATES mode can cause unexpected behavior, as invalid dates will not be handled appropriately. Therefore, it is always recommended to use the standard date format.

      • ANSI_QUOTES: ANSI_QUOTES is a strict mode in SQL mode, used to enforce SQL standards more strictly. In ANSI_QUOTES mode, MatrixOne treats double quotes as identifier quotes instead of string quotes. If you want to use double quotes to quote an identifier such as a table name or column name, you must use double quotes instead of single quotes. For example, the following SQL statement is correct in ANSI_QUOTES mode:

      SELECT \"column_name\" FROM \"table_name\";\n

      In the default SQL mode, double quotes will be interpreted as string quotes, resulting in incorrect syntax. Therefore, to use double quotes to quote identifiers, you must set MatrixOne to the ANSI_QUOTES mode.

      It should be noted that using the ANSI_QUOTES mode may cause SQL syntax incompatibility with other database systems because most other database systems use double quotes as string quotes rather than identifier quotes. Therefore, ANSI_QUOTES mode should be used cautiously when writing portable SQL statements.

      • HIGH_NOT_PRECEDENCE: HIGH_NOT_PRECEDENCE is called the \"high-priority NOT operator\" mode in MatrixOne SQL mode. In HIGH_NOT_PRECEDENCE mode, MatrixOne treats the NOT operator as a high-priority operator, meaning its priority is higher than most other operators. This means that if you use both the NOT operator and other operators in an SQL statement, MatrixOne will first calculate the result of the NOT operator and then calculate the results of the other operators. For example:
      SELECT * FROM table WHERE NOT column = 1 AND column2 = 'value';\n

      In HIGH_NOT_PRECEDENCE mode, MatrixOne will first calculate the result of NOT column = 1, and then calculate the result of column2 = 'value'. If the NOT operator is not correctly placed in the statement, it may result in unexpected results.

      It should be noted that in MatrixOne's default SQL mode, the NOT operator has the same priority as other operators. If you need to use the HIGH_NOT_PRECEDENCE mode, make sure to use parentheses in your SQL statements to clarify the priority.

      • IGNORE_SPACE: IGNORE_SPACE is referred to as the \"ignore space\" mode in MatrixOne SQL mode. In IGNORE_SPACE mode, MatrixOne ignores multiple spaces or tabs in an SQL statement and only considers one space or tab as a delimiter. This means that the following two SQL statements are equivalent in IGNORE_SPACE mode:
      SELECT * FROM my_table;\nSELECT*FROM my_table;\n

      The purpose of this mode is to make SQL statements more flexible and readable by allowing any number of spaces or tabs between keywords. However, it should be noted that in some cases, this mode may cause unexpected behavior, such as syntax errors when spaces or tabs are incorrectly placed in SQL functions or column names.

      By default, MatrixOne does not enable the IGNORE_SPACE mode. To enable this mode, you can use the SQL command SET sql_mode='IGNORE_SPACE' when connecting to MatrixOne.

      • NO_AUTO_VALUE_ON_ZERO: NO_AUTO_VALUE_ON_ZERO is called the \"no auto value on zero\" mode in MatrixOne SQL mode. In NO_AUTO_VALUE_ON_ZERO mode, when you insert a value of 0 into an auto-increment column, MatrixOne does not treat it as an auto-increment value but as a regular 0 value. This means that if you insert a value of 0 into an auto-increment column, the value of that column will not be automatically incremented but will remain 0 in NO_AUTO_VALUE_ON_ZERO mode. For example, the following SQL statement will not auto-increment the id column in NO_AUTO_VALUE_ON_ZERO mode:
      CREATE TABLE my_table (\nid INT(11) NOT NULL AUTO_INCREMENT,\nname VARCHAR(255) NOT NULL,\nPRIMARY KEY (id)\n);\n\nINSERT INTO my_table (id, name) VALUES (0, 'John');\n

      In the default SQL mode, when you insert a value of 0 into an auto-increment column, MatrixOne treats it as an auto-increment value and automatically increases it to the next available one. However, this may not be the desired behavior in some cases, so you can use the NO_AUTO_VALUE_ON_ZERO mode to disable it.

      If you use the NO_AUTO_VALUE_ON_ZERO mode, inserting data with a value of 0 may cause primary key duplicates or unique vital conflicts. So, extra attention is needed when you insert data.

      • NO_BACKSLASH_ESCAPES: NO_BACKSLASH_ESCAPES is also known as \"no backslash escapes\" mode in MatrixOne SQL mode. In NO_BACKSLASH_ESCAPES mode, MatrixOne does not treat the backslash as an escape character. This means that you cannot use the backslash to escape special characters, such as quotes or percent signs, in SQL statements. Instead, if you need to use these special characters in SQL statements, you must use other methods to escape them, such as using single quotes to represent double quotes in strings. For example, the following SQL statement will cause a syntax error in NO_BACKSLASH_ESCAPES mode:
      SELECT 'It's a nice day' FROM my_table;\n

      In the default SQL mode, MatrixOne allows backslashes to escape special characters, so backslashes can be used in SQL statements to run characters such as quotes and percent signs. However, in some cases, using backslash escapes may result in confusion or incorrect results, so the NO_BACKSLASH_ESCAPES mode can be used to prohibit this behavior.

      If you use the NO_BACKSLASH_ESCAPES mode, you must use other ways to escape special characters, which may make SQL statements more complex and difficult to understand. Therefore, it's necessary to consider when using this mode carefully.

      • NO_DIR_IN_CREATE: known as \"no directory in create\" mode in MatrixOne SQL mode, prohibits directory paths in CREATE TABLE statements. In the NO_DIR_IN_CREATE mode, MatrixOne will report an error when a directory path is used in the column definition of a CREATE TABLE statement, which includes a way that contains a file name. For example:
      CREATE TABLE my_table (\nid INT(11) NOT NULL AUTO_INCREMENT,\nname VARCHAR(255) NOT NULL,\ndatafile '/var/lib/MatrixOne/my_table_data.dat',\nPRIMARY KEY (id)\n);\n

      In the SQL statement above, the datafile column defines a path containing a file name, specifying the file storing table data. In the NO_DIR_IN_CREATE mode, MatrixOne does not allow the use of such directory paths in CREATE TABLE statements and requires that the file path and file name be defined separately, for example:

      CREATE TABLE my_table (\nid INT(11) NOT NULL AUTO_INCREMENT,\nname VARCHAR(255) NOT NULL,\ndatafile VARCHAR(255) NOT NULL,\nPRIMARY KEY (id)\n) DATA DIRECTORY '/var/lib/MatrixOne/' INDEX DIRECTORY '/var/lib/MatrixOne/';\n

      The data file column in the SQL statement above only defines the file name. In contrast, the file path is defined separately in the DATA DIRECTORY and INDEX DIRECTORY clauses of the CREATE TABLE statement.

      It should be noted that the NO_DIR_IN_CREATE mode does not affect column definitions in already created tables but only affects column definitions in CREATE TABLE statements. Therefore, when using this mode, you'll need careful consideration to ensure your SQL statements meet its requirements.

      • NO_UNSIGNED_SUBTRACTION: NO_UNSIGNED_SUBTRACTION is also also known as \"no unsigned subtraction\" mode in MatrixOne SQL mode, treats the result of the subtraction of unsigned integers with the subtraction operator (-) as a signed integer instead of an unsigned integer. This means that if the value of the unsigned integer is smaller than the subtrahend, the result will be a negative number instead of an unsigned integer. For example:
      SET SQL_MODE = 'NO_UNSIGNED_SUBTRACTION';\nSELECT CAST(1 AS UNSIGNED) - CAST(2 AS UNSIGNED);\n

      In the SQL statement above, the NO_UNSIGNED_SUBTRACTION mode treats CAST(1 AS UNSIGNED) - CAST(2 AS UNSIGNED) as a signed integer operation, so the result is -1 instead of the result of an unsigned integer operation, which is 4294967295.

      It should be noted that the NO_UNSIGNED_SUBTRACTION mode only affects unsigned integers that are subtracted using the subtraction operator (-), and other operations that use unsigned integers are not affected. If you need to perform many unsigned integer operations in MatrixOne, using appropriate type conversions in your code is recommended to avoid potential errors.

      • PAD_CHAR_TO_FULL_LENGTH: PAD_CHAR_TO_FULL_LENGTH is called the \"pad CHAR to full length\" mode in MatrixOne SQL mode.

      In the PAD_CHAR_TO_FULL_LENGTH mode, when you define a column of CHAR type, MatrixOne pads the column's value with spaces to make its length equal to the length specified for the column. This is because in MatrixOne, a column of CHAR type always occupies the defined length when stored, and any shortfall is filled with spaces. However, by default, the character set used by MatrixOne may be a multi-byte character set, so if spaces are used for padding, it may lead to incorrect length calculation.

      In the PAD_CHAR_TO_FULL_LENGTH mode, MatrixOne uses the maximum character length of the character set to pad the column of CHAR type to ensure that the length it occupies matches the defined size. This can avoid the problem of length calculation errors when using multi-byte character sets, but it also increases the use of storage space.

      It should be noted that the PAD_CHAR_TO_FULL_LENGTH mode only affects columns of CHAR type and does not affect columns of other varieties. If you need to use CHAR type columns in MatrixOne and correctly calculate the length of column values in a multi-byte character set, you can consider using the PAD_CHAR_TO_FULL_LENGTH mode.

      • PIPES_AS_CONCAT: PIPES_AS_CONCAT is called the \"pipes as concatenation\" mode in MatrixOne SQL mode. In the PIPES_AS_CONCAT mode, MatrixOne treats the vertical bar symbol (|) as a string concatenation rather than a bitwise operator. If you use the standing bar symbol to concatenate two strings, MatrixOne will treat them as one string instead of interpreting them as a binary bit operation.

      For example, the following SQL statement will return an error in the default mode because MatrixOne treats the vertical bar symbol as a bitwise operator:

      SELECT 'abc' | 'def';\n

      However, if the SQL mode is set to PIPES_AS_CONCAT, the above SQL statement will return the string 'abcdef'.

      Note that if your SQL statement contains the vertical bar symbol and it should be treated as a bitwise operator, do not use the PIPES_AS_CONCAT mode. Conversely, if you need to treat the vertical bar symbol as a string concatenation operator, use the PIPES_AS_CONCAT mode.

      • REAL_AS_FLOAT: REAL_AS_FLOAT is known as \"treat REAL type as FLOAT type\" mode in MatrixOne SQL mode.

      In REAL_AS_FLOAT mode, MatrixOne treats data of the REAL type as data of the FLOAT type. This means that MatrixOne uses the storage format of the FLOAT type to store data of the REAL type, rather than the more precise but also more space-consuming DOUBLE type storage format.

      Note that since the storage format of FLOAT type data occupies less space than DOUBLE type data, treating data of the REAL type as data of the FLOAT type can save storage space in some cases. However, doing so will also reduce the precision of the data, as FLOAT type data can only provide about 7 significant digits of precision, while DOUBLE type data can provide about 15 significant digits of precision.

      If you need to store high-precision floating-point data in MatrixOne, it is recommended not to use the REAL_AS_FLOAT mode and use DOUBLE type data to store it. If you do not require high data precision, you may consider using the REAL_AS_FLOAT mode to save storage space.

      • STRICT_ALL_TABLES: STRICT_ALL_TABLES is known as \"enable strict mode\" mode in MatrixOne SQL mode. In STRICT_ALL_TABLES mode, MatrixOne enables a series of strict checks to ensure that insert, update, and delete operations comply with constraints such as data types, NULL values, and foreign keys. Specifically, STRICT_ALL_TABLES mode performs the following operations:

      a. Rejects illegal values from being inserted into any column. b. Rejects NULL values from being inserted into non-NULL columns. c. Rejects values outside the allowed range from being inserted into any column. d. Rejects strings from being inserted into numeric type columns. e. Rejects date or time strings from being inserted into non-date or time type columns. f. Rejects values that exceed the length defined for CHAR, VARCHAR, and TEXT type columns from being inserted. g. Rejects values with mismatched data types from being inserted into foreign key columns.

      Note that enabling strict mode may cause problems for some old applications as they may assume that MatrixOne does not perform mandatory constraint checks. If you encounter problems when updating or migrating applications, consider disabling strict mode or modifying the application to comply with strict mode requirements.

      • TIME_TRUNCATE_FRACTIONAL: TIME_TRUNCATE_FRACTIONAL is known as \"truncate fractional part of time\" mode in MatrixOne SQL mode. In TIME_TRUNCATE_FRACTIONAL mode, MatrixOne truncates the fractional part of data of the TIME, DATETIME, and TIMESTAMP types, retaining only the integer part. This means that if you insert time data with a fractional part into a column of the TIME,DATETIME, or TIMESTAMP type, MatrixOne will truncate the fractional part and set it to 0.

      Note that enabling the TIME_TRUNCATE_FRACTIONAL mode may cause some loss of data precision, as truncating the fractional part may lose some critical time information. If you need to store and manipulate accurate time data, it is recommended not to use the TIME_TRUNCATE_FRACTIONAL mode.

      • TRADITIONAL: TRADITIONAL is a type of schema in the MatrixOne SQL mode, also known as the \"traditional\" mode. In TRADITIONAL mode, MatrixOne enables a series of strict checks to ensure that insert, update, and delete operations conform to SQL standard constraints. Specifically, the TRADITIONAL mode performs the following operations:

      a. Enables STRICT_TRANS_TABLES and STRICT_ALL_TABLES modes. b. Rejects INSERT statements that omit column names to ensure all columns are explicitly assigned values. c. Rejects inserting values with unclear data types into foreign key columns. d. Rejects inserting strings into numeric columns. e. Rejects inserting date or time strings into non-date or time-type columns. f. Rejects inserting values that exceed the defined length of CHAR, VARCHAR, and TEXT columns. g. Rejects using non-aggregate columns in the GROUP BY clause. h. Rejects using non-listed non-aggregate columns in the SELECT statement. i. It should be noted that enabling traditional mode may cause issues with some older applications that assume MatrixOne will not perform mandatory constraint checks. If you encounter problems when updating or migrating applications, consider the traditional disabling mode or modifying the applications to comply with traditional mode requirements.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#how-to-set-sql_mode","title":"How to set sql_mode","text":"

      The sql_mode can be set using the SET statement, for example:

      SET sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY';\n

      The sql_mode can also be set in the configuration file of MatrixOne, for example:

      sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY;\n

      In the example settings above, MatrixOne will use the STRICT_TRANS_TABLES, NO_ZERO_IN_DATE, and ONLY_FULL_GROUP_BY modes.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#constraints","title":"Constraints","text":"

      MatrixOne is compatible with MySQL, except the ONLY_FULL_GROUP_BY mode; other modes of sql_mode only implement syntax support.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/","title":"Server System Variables","text":"

      MatrixOne server system variables are variables used to control or configure the behavior of the database engine or other components in the MatrixOne server. The values of these variables can be set and changed using the SET statement.

      System variables can be divided into two categories: Global variables and Session variables.

      • Global variables: Global variables apply to all connected sessions of the MatrixOne server. Their values are set when the MatrixOne server starts and remain unchanged until the server is shut down. Global variables are typically used to control the behavior of the MatrixOne server, such as specifying default backup and restore locations, the default language environment, and so on.

      • Session variables: Session variables apply only to the currently connected user's session of the MatrixOne server. Their values can be changed anytime during the user's connection and are automatically cleared when the user disconnects. Session variables are typically used to control session behavior, such as how to print the information displayed and specify transaction isolation levels.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#how-to-query-system-variables","title":"How to query system variables?","text":"

      You can use the following SQL to query:

      SHOW VARIABLES;\n

      This will list all system variables and their current values. If you only want to see system variables related to a specific topic, you can use the following syntax:

      SHOW VARIABLES LIKE '%theme%';\n

      This will list all system variables with names containing the word theme and their current values.

      Note: The LIKE operator is used for fuzzy matching query strings, with % representing zero or more arbitrary characters. Therefore, the above command will match any system variables with names containing the word theme.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#how-to-query-global-variables","title":"How to query global variables?","text":"

      You can use the following SQL to query:

      SHOW GLOBAL VARIABLES;\n

      This will list all global variables and their current values. If you only want to see global variables related to a specific topic, you can use the following syntax:

      SHOW GLOBAL VARIABLES LIKE '%theme%';\n

      This will list all global variables with names containing the word theme and their current values.

      Note: The LIKE operator is used for fuzzy matching query strings, with % representing zero or more arbitrary characters. Therefore, the above command will match any global variables with names containing the word theme.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#how-to-query-session-variables","title":"How to query session variables?","text":"

      You can use the following SQL to query:

      SHOW SESSION VARIABLES;\n

      This will list all session variables and their current values. If you only want to see session variables related to a specific topic, you can use the following syntax:

      SHOW SESSION VARIABLES LIKE '%theme%';\n

      This will list all session variables with names containing the word theme and their current values.

      Note: The LIKE operator is used for fuzzy matching query strings, with % representing zero or more arbitrary characters. Therefore, the above command will match any session variables with names containing the word theme.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#system-veariable-reference","title":"System Veariable Reference","text":"Variable_name Cmd-Line(Y/N) Option File(Y/N) Variable Type System Var(Y/N) Var Scope(Global/Both/Session) Dynamic(Y/N) Default Value Optional value auto_increment_increment Y N int Y Both Y 1 1-65535 auto_increment_offset Y N int Y Both Y 1 1-65535 autocommit Y N bool Y Both Y TRUE FALSE character_set_client Y N string Y Both Y \"utf8mb4\" character_set_connection Y N string Y Both Y \"utf8mb4\" character_set_database Y N string Y Both Y \"utf8mb4\" character_set_results Y N string Y Both Y \"utf8mb4\" character_set_server Y N string Y Both Y \"utf8mb4\" collation_connection Y N string Y Both Y \"default\" collation_server Y N string Y Both Y \"utf8mb4_bin\" completion_type Y N enum Y Both Y \"NO_CHAIN\" \"NO_CHAIN\",\"CHAIN\", \"RELEASE\" host Y N string Y Both N \"0.0.0.0\" init_connect Y N string Y Both Y \"\" interactive_timeout Y N int Y Both Y 28800 1-31536000 license Y N string Y Both N \"APACHE\" lower_case_table_names Y N int Y Both N 1 0-2 max_allowed_packet Y N int Y Both Y 16777216 1024-1073741824 net_write_timeout Y N int Y Both Y 60 1-31536000 performance_schema Y N int Y Both Y 0 0-1 port Y N int Y Both N 6001 0-65535 profiling Y N int Y Both Y 0 0-1 query_result_maxsize Y N uint Y Both Y 100 0-18446744073709551615 query_result_timeout Y N uint Y Both Y 24 0-18446744073709551615 save_query_result Y N bool Y Both Y FALSE TRUE sql_mode Y N set Y Both Y \"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\" \"ANSI\", \"TRADITIONAL\", \"ALLOW_INVALID_DATES\", \"ANSI_QUOTES\", \"ERROR_FOR_DIVISION_BY_ZERO\", \"HIGH_NOT_PRECEDENCE\", \"IGNORE_SPACE\", \"NO_AUTO_VALUE_ON_ZERO\", \"NO_BACKSLASH_ESCAPES\", \"NO_DIR_IN_CREATE\", \"NO_ENGINE_SUBSTITUTION\", \"NO_UNSIGNED_SUBTRACTION\", \"NO_ZERO_DATE\", \"NO_ZERO_IN_DATE\", \"ONLY_FULL_GROUP_BY\", \"PAD_CHAR_TO_FULL_LENGTH\", \"PIPES_AS_CONCAT\", \"REAL_AS_FLOAT\", \"STRICT_ALL_TABLES\", \"STRICT_TRANS_TABLES\", \"TIME_TRUNCATE_FRACTIONAL\" sql_safe_updates Y N int Y Both Y 0 0-1 sql_select_limit Y N uint Y Both Y 18446744073709551615 0-18446744073709551615 system_time_zone Y N string Y Both N \"\" time_zone Y N string Y Both N \"SYSTEM\" transaction_isolation Y N enum Y Both Y \"REPEATABLE-READ\" \"READ-UNCOMMITTED\", \"READ-COMMITTED\", \"REPEATABLE-READ\",\"REPEATABLE-READ\", \"SERIALIZABLE\" transaction_read_only Y N int Y Both Y 0 0-1 version_comment Y N string Y Both N \"MatrixOne\" wait_timeout Y N int Y Both Y 28800 1-2147483"},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/#constraints","title":"Constraints","text":"

      MatrixOne is compatible with MySQL, and the SQL mode only supports the ONLY_FULL_GROUP_BY mode; other SQL modes are only supported by syntax and have no actual effect.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/timezone/","title":"Time Zone Support","text":"

      The time zone in MatrixOne is decided by three time_zone system variables: global.time_zone, session.time_zone, global.system_time_zone.

      • global.system_time_zone indicates the server system time zone. When the server starts, it attempts to determine the time zone of the host machine and uses it to set the system_time_zone system variable.

      • The server current time zone. The global.time_zone system variable indicates the time zone the server currently is operating in. The initial time_zone value is 'SYSTEM', which indicates that the server time zone is the same as the system time zone.

      You can use the following statement to set the global server time_zone value at runtime. But it won't be effective in the current session, only if you exit and reconnect to MatrixOne you may see the time_zone affected.

      > SET GLOBAL time_zone = timezone;\n
      • Per-session time zones. Each client that connects has its own session time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement. This setting will only last during the current session.
      SET time_zone = timezone;\n

      You can use the following statement to view the current values of the global, client-specific and system time zones:

      > SELECT @@global.time_zone, @@session.time_zone, @@global.system_time_zone;\n+-------------+-------------+--------------------+\n| @@time_zone | @@time_zone | @@system_time_zone |\n+-------------+-------------+--------------------+\n| timezone    | +08:00      | CST                |\n+-------------+-------------+--------------------+\n1 row in set (0.01 sec)\n

      To set the format of the value of the time_zone:

      • The value SYSTEM indicates that the time zone should be the same as the server system time zone.

      • The value UTC indicates that the time zone is set to Coordinated Universal Time. Only UTC as time zone abbreviation is supported.

      • The value can be given as a string indicating an offset from UTC of the form HH:MM with a + or -, such as +10:00 or -06:00. The permitted range is -13:59 to +14:00, inclusive.

      The current session time zone setting affects the display and storage of time values that are zone-sensitive. This includes the values displayed by functions such as NOW() and values stored in and retrieved from TIMESTAMP columns.

      The session time zone setting does not affect values displayed by functions such as UTC_TIMESTAMP() or values in DATE, TIME, or DATETIME columns.

      Note

      Only the values of the Timestamp data type is affected by time zone. This is because the Timestamp data type uses the literal value + time zone information. Other data types, such as Datetime/Date/Time, do not have time zone information, thus their values are not affected by the changes of time zone.

      > SELECT @@global.time_zone, @@session.time_zone, @@global.system_time_zone;\n+-------------+-------------+--------------------+\n| @@time_zone | @@time_zone | @@system_time_zone |\n+-------------+-------------+--------------------+\n| SYSTEM      | SYSTEM      | CST                |\n+-------------+-------------+--------------------+\n1 row in set (0.00 sec)\n\n> create table t (ts timestamp, dt datetime);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> set @@time_zone = 'UTC';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> insert into t values ('2017-09-30 11:11:11', '2017-09-30 11:11:11');\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> set @@time_zone = '+08:00';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select * from t;\n+---------------------+---------------------+\n| ts                  | dt                  |\n+---------------------+---------------------+\n| 2017-09-30 19:11:11 | 2017-09-30 11:11:11 |\n+---------------------+---------------------+\n1 row in set (0.00 sec)\n

      In this example, no matter how you adjust the value of the time zone, the value of the Datetime data type is not affected. But the displayed value of the Timestamp data type changes if the time zone information changes. In fact, the value that is stored in the storage does not change, it's just displayed differently according to different time zone setting.

      Note

      Time zone is involved during the conversion of the value of Timestamp and Datetime, which is handled based on the current time_zone.

      "},{"location":"MatrixOne/Reference/Variable/system-variables/timezone/#changing-matrixone-time-zone","title":"Changing MatrixOne Time Zone","text":"
      1. View the current time and time zone:
      > select now();\n+----------------------------+\n| now()                      |\n+----------------------------+\n| 2022-10-14 18:38:27.876181 |\n+----------------------------+\n1 row in set (0.00 sec)\n\n> show variables like \"%time_zone%\";\n+------------------+--------+\n| Variable_name    | Value  |\n+------------------+--------+\n| system_time_zone | CST    |\n| time_zone        | SYSTEM |\n+------------------+--------+\n2 rows in set (0.00 sec)\n
      • time_zone indicates that MatrixOne uses the system time zone.

      • system_time_zone indicates the time zone which server system uses.

      • modify the time zone:

      set global time_zone = '+08:00';\nset time_zone = '+08:00';\n
      • set global time_zone = '+08:00';: Change the global time zone to Beijing time if we are in the east eight zones.
      • set time_zone = '+08:00';: Change the time zone of the current session.
      "},{"location":"MatrixOne/Reference/Variable/system-variables/timezone/#constraints","title":"Constraints","text":"

      Only (+/-)HH:MM form and UTC is supported for setting time_zone values.

      "},{"location":"MatrixOne/Release-Notes/release-timeline/","title":"MatrixOne Release Timeline","text":"

      This document shows all the released MatrixOne versions in reverse chronological order.

      Version Release Date v1.0.0-rc1 2023/8/24 v0.8.0 2023/6/30 v0.7.0 2023/2/23 v0.6.0 2022/11/29 v0.5.1 2022/8/19 v0.5.0 2022/7/18 v0.4.0 2022/5/5 v0.3.0 2022/3/10 v0.2.0 2022/1/6 v0.1.0 2021/10/24"},{"location":"MatrixOne/Release-Notes/v0.1.0/","title":"MatrixOne v0.1.0 Release Notes","text":"

      We are excited to announce the first release of MatrixOne 0.1.0 on 2021/10/24. Cheers!

      "},{"location":"MatrixOne/Release-Notes/v0.1.0/#docker","title":"Docker","text":"

      docker pull matrixorigin/matrixone:0.1.0

      "},{"location":"MatrixOne/Release-Notes/v0.1.0/#features","title":"Features","text":""},{"location":"MatrixOne/Release-Notes/v0.1.0/#sql","title":"SQL","text":"

      Following SQL statements are supported in this release.

      "},{"location":"MatrixOne/Release-Notes/v0.1.0/#ddl","title":"DDL","text":"
      • CREATE / DROP DATABASE
      • CREATE / DROP TABLE
      "},{"location":"MatrixOne/Release-Notes/v0.1.0/#dml","title":"DML","text":"
      • INSERT
      • LOAD DATA
      • SELECT
        • WHERE
        • GROUP BY
        • ORDER BY
        • LIMIT, OFFSET
      • SHOW
        • DATABASES
        • TABLES
      • USE
      "},{"location":"MatrixOne/Release-Notes/v0.1.0/#data-types","title":"Data Types","text":"
      • TINYINT / SMALLINT / INT / BIGINT, SIGNED / UNSIGNED
      • FLOAT / DOUBLE
      • CHAR / VARCHAR
      "},{"location":"MatrixOne/Release-Notes/v0.1.0/#operators","title":"Operators","text":"
      • <, >=, <, <=, <>, !=, =
      • BETWEEN \u2026 AND \u2026, NOT BETWEEN \u2026 AND \u2026
      • AND, &&, OR, ||
      • +, -, *, /, %, MOD, DIV, NEG
      • CAST
      "},{"location":"MatrixOne/Release-Notes/v0.1.0/#aggregation-functions","title":"Aggregation Functions","text":"
      • COUNT
      • SUM
      • AVG
      • MAX
      • MIN
      "},{"location":"MatrixOne/Release-Notes/v0.1.0/#database-engine","title":"Database Engine","text":"
      • MySQL dialect is supported.
      • Build-in Append only columnar engine(AOE) has been supported as the first fusion database engine.
      • Real-time analytical queries are supported.
      • Vectorized query execution engine, based on MPP solution, is introduced.
      • Part of the expression execution has been vectorized through SIMD instructions.
      • Distributed AOE with strong consistency guaranteed by RAFT has been supported.
      • The performance of replicated state machine has been greatly improved through the unique design of reusing RAFT log as well as Write-Ahead log without any redundancy.
      "},{"location":"MatrixOne/Release-Notes/v0.1.0/#contributors","title":"Contributors","text":"

      This release includes 453 commits by 16 authors. Special thanks to the first author:

      Yan Wenze (@nnsgmsone) Chen Mingsong(@m-schen) Jin Hai (@JinHai-CN) Jiang xinmeng (@jiangxinmeng1) Li Yang (@lignay) Lin Junhong (@iamlinjunhong) lni (@lni) Long Ran (@aunjgr) Peng Zhen (@daviszhen) Qin Shuqi (@sukki37) Shen JiangWei(@LeftHandCold) Wei Ziran (@w-zr) Xiong Jingjuan (@anitajjx) Xu Peng (@XuPeng-SH) Yan Wenze(@nnsgmsone) Zilong Zhou (@zzl200012) Zhang Yingfeng (@yingfeng)

      "},{"location":"MatrixOne/Release-Notes/v0.2.0/","title":"MatrixOne v0.2.0 Release Notes","text":"

      We are excited to announce MatrixOne 0.2.0 release on 2022/1/6. Cheers!

      "},{"location":"MatrixOne/Release-Notes/v0.2.0/#docker","title":"Docker","text":"

      docker pull matrixorigin/matrixone:0.2.0

      "},{"location":"MatrixOne/Release-Notes/v0.2.0/#features","title":"Features","text":"
      • Support automatic rebalancing for the built-in AOE columnar storage engine.
      • Introduce new SQL parser.
      • Introduce factorized SQL execution engine which is the fastest MPP in Golang.
      • Support CREATE / DROP INDEX.
      • Support PRIMARY KEY in CREATE TABLE.
      • Support more data types for SQL binary operators.
      • Support equi join with group by or aggregation statements.
      • Support new types of DATE and DATETIME.
      "},{"location":"MatrixOne/Release-Notes/v0.2.0/#database-engine","title":"Database Engine","text":"
      • For continuous table creation actions in a script, the parameter of pre-allocated-group-num should be set to a bigger value such in cluster scenarios. Otherwise, \"no available raft group\" may be notified during tables creation sequence.
      "},{"location":"MatrixOne/Release-Notes/v0.2.0/#contributors","title":"Contributors","text":"

      This release includes 243 commits by 21 authors.

      • BingLin Chang (@decster)
      • Chen Mingsong(@m-schen)
      • Nan Deng (@dengn)
      • Jin Hai (@JinHai-CN)
      • Jiang xinmeng (@jiangxinmeng1)
      • Li Yang (@lignay)
      • Lin Junhong (@iamlinjunhong)
      • lni (@lni)
      • Long Ran (@aunjgr)
      • Peng Zhen (@daviszhen)
      • Qin Shuqi (@sukki37)
      • Shen JiangWei(@LeftHandCold)
      • Jian Wang(@jianwan0214)
      • broccoliSpicy(@broccoliSpicy)
      • Ryan Wang(@wanglei4687)
      • Xiong Jingjuan (@anitajjx)
      • Xu Peng (@XuPeng-SH)
      • Yan Wenze(@nnsgmsone)
      • Yuesheng Li(@reusee)
      • Zilong Zhou (@zzl200012)
      • Zhang Yingfeng (@yingfeng)
      "},{"location":"MatrixOne/Release-Notes/v0.3.0/","title":"MatrixOne v0.3.0 Release Notes","text":"

      We are excited to announce MatrixOne 0.3.0 release on 2022/3/10. Cheers!

      "},{"location":"MatrixOne/Release-Notes/v0.3.0/#docker","title":"Docker","text":"

      docker pull matrixorigin/matrixone:0.3.0

      "},{"location":"MatrixOne/Release-Notes/v0.3.0/#features","title":"Features","text":"
      • Exports data into CSV file.
      • Introduces parallel execution and improve performance for projection query.
      • Introduces IN operator and allows you to specify multiple values in a WHERE clause.
      • Support NULLABLE column in group by expression.
      • Introduces new functions: round and floor.
      • Introduces a Chaos Testing framework for distributed system.
      "},{"location":"MatrixOne/Release-Notes/v0.3.0/#known-issues","title":"Known issues","text":"
      • For continuous table creation actions in a script, the parameter of pre-allocated-group-num should be set to a bigger value such in cluster scenarios. Otherwise, \"no available raft group\" may be notified during tables creation sequence.
      "},{"location":"MatrixOne/Release-Notes/v0.3.0/#contributors","title":"Contributors","text":"

      This release includes 157 commits by 21 authors.

      • broccoliSpicy(@broccoliSpicy)
      • Chen Mingsong(@m-schen)
      • hanfang (@aptend)
      • O2 (@ikenchina)
      • Jin Hai (@JinHai-CN)
      • Jiang xinmeng (@jiangxinmeng1)
      • Lin Junhong (@iamlinjunhong)
      • Long Ran (@aunjgr)
      • Nan Deng (@dengn)
      • Otter(@WenhaoKong2001)
      • Peng Zhen (@daviszhen)
      • Qin Shuqi (@sukki37)
      • Sundy Li(@sundy-li)
      • Shen JiangWei(@LeftHandCold)
      • Jian Wang(@jianwan0214)
      • Wan Hanbo(@wanhanbo )
      • Xu Peng (@XuPeng-SH)
      • Yan Wenze(@nnsgmsone)
      • Yuesheng Li(@reusee)
      • Zilong Zhou (@zzl200012)
      • Zhang Yingfeng (@yingfeng)
      "},{"location":"MatrixOne/Release-Notes/v0.3.0/#new-contributors","title":"New Contributors","text":"
      • @wanhanbo made their first contribution in https://github.com/matrixorigin/matrixone/pull/1600
      • @ikenchina made their first contribution in https://github.com/matrixorigin/matrixone/pull/1685
      • @sundy-li made their first contribution in https://github.com/matrixorigin/matrixone/pull/1704
      • @WenhaoKong2001 made their first contribution in https://github.com/matrixorigin/matrixone/pull/1838

      We appreciate your contribution! Welcome to MatrixOne community.

      "},{"location":"MatrixOne/Release-Notes/v0.3.0/#full-changelog","title":"Full Changelog","text":"

      https://github.com/matrixorigin/matrixone/compare/v0.2.0...v0.3.0

      "},{"location":"MatrixOne/Release-Notes/v0.4.0/","title":"MatrixOne v0.4.0 Release Notes","text":"

      We are excited to announce MatrixOne 0.4.0 release on 2022/5/5. Cheers!

      "},{"location":"MatrixOne/Release-Notes/v0.4.0/#docker","title":"Docker","text":"

      docker pull matrixorigin/matrixone:0.4.0

      "},{"location":"MatrixOne/Release-Notes/v0.4.0/#features","title":"Features","text":"
      • Support inner join with equality operator.
      • Support subquery within from clause.
      • Support decimal data type.
      • Support following builtin functions:
        • Mathematical: Abs, Log, Ln, Ceil, Exp, Power, Pi, Sin, Sinh, Cos, ACos, Tan, ATan, Cot
        • Datetime: Month, Weekday, Date, DayOfYear
        • String: Space, Reverse, Substring, Ltrim, Rtrim, StartsWith, EndsWith, Lpad, Rpad, Empty, LengthUTF8
      • Support following aggregate functions:
        • Bit_and, Bit_or, Bit_xor, Stddev_pop, Var
      "},{"location":"MatrixOne/Release-Notes/v0.4.0/#known-issues","title":"Known issues","text":"
      • For continuous table creation actions in a script, the parameter of pre-allocated-group-num should be set to a bigger value such in cluster scenarios. Otherwise, \"no available raft group\" may be notified during tables creation sequence.
      "},{"location":"MatrixOne/Release-Notes/v0.4.0/#contributors","title":"Contributors","text":"

      This release includes 253 commits by 50 authors.

      "},{"location":"MatrixOne/Release-Notes/v0.4.0/#new-contributors","title":"New Contributors","text":"
      • @BePPPower
      • @JackTan25
      • @Charlie17Li
      • @domingozhang
      • @Fungx
      • @JasonPeng1310
      • @jiajunhuang
      • @NTH19
      • @noneback
      • @RinChanNOWWW
      • @chaixuqing
      • @Y7n05h
      • @yuxubinchen
      • @adlternative
      • @ajian2002
      • @bxiiiiii
      • @coderzc
      • @e11jah
      • @fengttt
      • @florashi181
      • @hiyoyolumi
      • @jinfuchiang
      • @ouyuanning
      • @qingxinhome
      • @supermario1990
      • @whileskies
      • @xiw5
      • @yclchuxue
      • @ZtXavier

      We appreciate your contribution! Welcome to MatrixOne community.

      "},{"location":"MatrixOne/Release-Notes/v0.4.0/#full-changelog","title":"Full Changelog","text":"

      https://github.com/matrixorigin/matrixone/compare/v0.3.0...v0.4.0

      "},{"location":"MatrixOne/Release-Notes/v0.5.0/","title":"MatrixOne v0.5.0 Release Notes","text":"

      We are excited to announce MatrixOne 0.5.0 release on 2022/7/18. In this release, MatrixOne has a stand-alone columnar storage engine which can support HTAP workloads. Cheers!

      "},{"location":"MatrixOne/Release-Notes/v0.5.0/#docker","title":"Docker","text":"
      docker pull matrixorigin/matrixone:0.5.0\n
      "},{"location":"MatrixOne/Release-Notes/v0.5.0/#features","title":"Features","text":"
      • Support ACID transaction with a Snapshot Isolation level.
      • Support UPDATE, DELETE and INSERT INTO ... SELECT ... statement.
      • Support BOOL and Timestamp data type.
      • Support LEFT / RIGHT / OUTER / NATURAL JOIN.
      • Support Having expression.
      • Support subquery.
      • Support Common Table Expression.
      • Support CASE ... WHEN expression.
      • Support Interval expression.
      • Support Explain plan tree.
      • Support new aggregate function: any_value
      • Lots of new functions are supported.
      "},{"location":"MatrixOne/Release-Notes/v0.5.0/#known-issues","title":"Known issues","text":"
      • Hotfix on 0.5.0 may cause data format incompatable.
      • 'Too many open files' error might be issued when user insert/update/delete data or create/drop table frequently. User need to increase the 'max open files' to resolve the issue.
      • Running 1GB TPCH benchmark test with memory less than 64GB may result in an out of memory error.
      • Loading large size of CSV file than 100GB might lead to system hanging. #3858
      • Mixed TP and AP work loads running for a long time, might cause system panic. #3947 #3961
      "},{"location":"MatrixOne/Release-Notes/v0.5.0/#contributors","title":"Contributors","text":"

      This release includes 811 commits by 73 authors.

      "},{"location":"MatrixOne/Release-Notes/v0.5.0/#new-contributors","title":"New Contributors","text":"
      • @lawrshen
      • @lyfer233
      • @wuliuqii
      • @ericsyh
      • @dongdongyang33
      • @aylei
      • @richelleguice
      • @aressu1985
      • @mklzl

      We appreciate your contribution! Welcome to MatrixOne community.

      "},{"location":"MatrixOne/Release-Notes/v0.5.0/#full-changelog","title":"Full Changelog","text":"

      https://github.com/matrixorigin/matrixone/compare/v0.4.0...v0.5.0

      "},{"location":"MatrixOne/Release-Notes/v0.5.1/","title":"MatrixOne v0.5.1 Release Notes","text":"

      We are excited to announce MatrixOne 0.5.1 release on 2022/8/19. In this release, MatrixOne resolved some log replaying and storage Garbage Collection(GC) issues.

      "},{"location":"MatrixOne/Release-Notes/v0.5.1/#docker","title":"Docker","text":"
      docker pull matrixorigin/matrixone:0.5.1\n
      "},{"location":"MatrixOne/Release-Notes/v0.5.1/#function-optimize","title":"Function Optimize","text":"
      • Optimize checkpoint in replay. #4214
      • Fix the bug that block and index file reference count is not released. #4052
      • Fix the bug that replay dead loop when the log is not full. #4051

      These bugs lead to some stability issues of a MatrixOne instance.

      "},{"location":"MatrixOne/Release-Notes/v0.5.1/#full-changelog","title":"Full Changelog","text":"

      https://github.com/matrixorigin/matrixone/compare/v0.4.0...v0.5.1

      "},{"location":"MatrixOne/Release-Notes/v0.6.0/","title":"MatrixOne v0.6.0 Release Notes","text":"

      We are excited to announce MatrixOne 0.6.0 release on 2022/11/29. In this release, MatrixOne has upgraded to a disaggregated compute and storage architecture, with a cloud native HTAP engine and many new features. Cheers!

      "},{"location":"MatrixOne/Release-Notes/v0.6.0/#docker","title":"Docker","text":"
      docker pull matrixorigin/matrixone:0.6.0\n
      "},{"location":"MatrixOne/Release-Notes/v0.6.0/#features","title":"Features","text":"
      • Support distributed ACID transaction with a Snapshot Isolation level.
      • Support TEXT, BLOB, TIME, JSON data type.
      • Support multi-tenancy with account, user and role.
      • Support VIEW.
      • Support Java, Python, Golang connector and Mybatis, Spring JPA, SQLAlchemy ORM connection.
      • Support import CSV and JSON data from local file system and cloud S3 storage.
      • Implemented a MatrixOne dedicated backup tool modump.
      • Support composite primary key, unique key and auto-increment constraint.
      • Add system_metrics database in the catalog to monitor instance status.
      • Add system database in the catalog to record user statements and system logs.
      • Support timezone.
      • Support TLS encrypted connection.
      • Support pre-compilation statements PREPARE, EXECUTE, DEALLOCATE.
      • Support EXPLAIN ANALYZE.
      • Support UNION, UNION ALL, INTERSECT, MINUS operators.
      • Support TEMPORARY TABLE.
      • Support EXTERNAL TABLE.
      • Support PARTITION BY.
      • Add many system variables and tables to maintain MySQL compatibility.
      • Add many new JSON, Datetime functions.
      "},{"location":"MatrixOne/Release-Notes/v0.6.0/#known-issues","title":"Known Issues","text":"
      • 0.6.0 data format is not compatible with the previous versions.
      • Transactional performance doesn't compete with mature DBMS products.
      • Composite Primary Key, Unique Key and Secondary Key doesn't improve any performance. #6028
      • Insert/update into select having more than 100MB data will fail in a distributed setting. #6780
      • Execute load data in a loop may cause out of memory. #6793
      • Data race happens in a distributed setting. #6855, #6926
      • Background jobs have a low probability causing user transaction being aborted due to r-w conflict. #6049
      • Insert file into BLOB type might fail. #6302
      "},{"location":"MatrixOne/Release-Notes/v0.6.0/#contributors","title":"Contributors","text":"

      This release includes 1520 commits by 97 authors.

      "},{"location":"MatrixOne/Release-Notes/v0.6.0/#new-contributors","title":"New Contributors","text":"
      • @lokax
      • @triump2020
      • @Abirdcfly
      • @yjw1268
      • @Juneezee
      • @ZoranPandovski
      • @Toms1999
      • @xy2398437254
      • @goodMan-code
      • @DanielZhangQD
      • @taofengliu
      • @TszKitLo40
      • @TheR1sing3un
      • @qqIsAProgrammer

      We appreciate your contribution! Welcome to MatrixOne community.

      "},{"location":"MatrixOne/Release-Notes/v0.6.0/#full-changelog","title":"Full Changelog","text":"

      https://github.com/matrixorigin/matrixone/compare/v0.5.1...v0.6.0

      "},{"location":"MatrixOne/Release-Notes/v0.7.0/","title":"MatrixOne v0.7.0 Release Notes","text":"

      We are excited to announce MatrixOne 0.7.0 release on 2023/2/23. In this release, MatrixOne version 0.7.0 has been optimized for stability and performance under a cloud-native architecture and complete database functionality.

      To improve stability, we have optimized the memory management mechanism to significantly reduce the likelihood of memory leaks. We have also adjusted the timeout mechanism of some modules to prevent the system from becoming unresponsive during extreme cases, such as data import and restart. Additionally, we have fixed the issue where a single module failure in the distributed architecture would cause a system-wide collapse.

      To enhance performance, this iteration has focused on read and write optimization. For reading, we have implemented Zonemap-based statistical information and provided a better execution plan. We have also added the Cluster by field when creating a table to arrange data in advance, making it easier to obtain data faster. Furthermore, we have optimized many performance bottlenecks, including the IN operator, type conversion, and predicate filtering. As for writing, this iteration has achieved many parallel writes to shared storage directly through the CN node, greatly improving loading performance.

      "},{"location":"MatrixOne/Release-Notes/v0.7.0/#docker","title":"Docker","text":"
      docker pull matrixorigin/matrixone:0.7.0\n
      "},{"location":"MatrixOne/Release-Notes/v0.7.0/#features","title":"Features","text":"
      • Support parallel load data mode.
      • Support Foreign Key.
      • Support adding Cluster by in DDL statements.
      • Add a MYSQL_COMPATBILITY_MODE to manage MySQL-compatible behaviors.
      • Modify the system default isolation level parameter to REPEATABLE_READ for better MySQL compatibility.
      • Improve Unique Index behavior.
      • Support to load data from the client machine.
      • Support Alter View.
      • Add query_result() function to get saved query results.
      • Support account suspending.
      • Support system table sharing to accounts.
      • Support aggregate function group_concat.
      • Support built-in functions: format, replace, curdate, field, substring_index, and other system functions.
      "},{"location":"MatrixOne/Release-Notes/v0.7.0/#known-issues","title":"Known Issues","text":"
      • 0.7.0 data format is not compatible with the previous versions.
      • Transactional performance doesn't compete with mature DBMS products.
      • The concurrent performance of OLTP type load is unstable.
      • Secondary Key doesn't improve any performance.
      • Only support up to 100GB benchmark testing.
      • Out of memory(OOM) error or context deadline will occur after 5 hours of frequent testing.
      • Loading multiple GB-level large tables in a distributed cluster will cause OOM problems.
      "},{"location":"MatrixOne/Release-Notes/v0.7.0/#contributors","title":"Contributors","text":"

      This release includes 656 commits by 43 authors.

      "},{"location":"MatrixOne/Release-Notes/v0.7.0/#new-contributors","title":"New Contributors","text":"
      • @sourcelliu
      • @iceTTTT
      • @chrisxu333
      • @songjiayang
      • @dr-lab
      • @arjunsk
      • @Morranto

      We appreciate your contribution! Welcome to MatrixOne community.

      "},{"location":"MatrixOne/Release-Notes/v0.7.0/#full-changelog","title":"Full Changelog","text":"

      https://github.com/matrixorigin/matrixone/compare/v0.6.0...v0.7.0

      "},{"location":"MatrixOne/Release-Notes/v0.8.0/","title":"MatrixOne v0.8.0 Release Notes","text":"

      We are excited to announce MatrixOne 0.8.0 release on 2023/6/30.

      After four months of intensive development, MatrixOne has achieved significant performance, scalability, and usability enhancements. This update's highlight is the Proxy module's introduction, which accurately associates various SQL requests and load types with corresponding CN groups. This results in notable improvements in critical functions such as tenant isolation, read-write separation, and separation of transaction processing (TP) and analytical processing (AP) loads. Worth noting is that this 0.8.0 release is the final version of MatrixOne before its full public launch and also serves as the public Beta version of the MatrixOne product. We cordially invite all users and developers to download, test, and give feedback. Cheers!

      "},{"location":"MatrixOne/Release-Notes/v0.8.0/#docker","title":"Docker","text":"
      • General Image:
      docker pull matrixorigin/matrixone:0.8.0\n
      • If you are using the network in mainland China, you can pull the image on Alibaba Cloud:
      docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:0.8.0\n
      "},{"location":"MatrixOne/Release-Notes/v0.8.0/#key-points","title":"Key Points","text":""},{"location":"MatrixOne/Release-Notes/v0.8.0/#performance","title":"Performance","text":"
      • OLTP Performance: In common OLTP scenarios such as point queries and insertions, MatrixOne's performance has improved several times, reaching the performance level of MySQL in the standalone version.
      • OLAP Performance: MatrixOne has further improved its OLAP performance. Standard OLAP benchmarks such as TPCH are comparable to the performance of leading OLAP databases in the industry.
      • Scalability: MatrixOne implements second-level expansion of CN computing nodes, and after expansion, the performance of OLTP and OLAP increases linearly.
      "},{"location":"MatrixOne/Release-Notes/v0.8.0/#improved-usability","title":"Improved Usability","text":"
      • Backward Compatibility of Data Format: Starting from version 0.8.0, all subsequent versions of MatrixOne will be compatible with the underlying data storage format of version 0.8.0. When upgrading the version, you no longer need to delete or re-import the old data directory.
      • Simplified Deployment and Administration Tools: This iteration provides a simplified deployment and administration command-line tool, mo_ctl, which helps users quickly check the basic hardware environment, initialize configurations, and perform one-click installation and deployment. Both standalone and distributed version users no longer need to use complex Linux and K8s native commands for deployment and maintenance.
      • Improved MySQL Compatibility: An upper and lower case mode compatible with MySQL has been added, and a tool for converting SQL from MySQL to MatrixOne is provided. Additionally, MatrixOne has added many table structures in the information_schema library, significantly reducing the adaptation work required for migration from MySQL.
      • Support for Pessimistic Transactions: To better adapt to the current OLTP application transaction usage habits, MatrixOne has added support for pessimistic transactions. Also, MatrixOne supports SI and RC isolation levels. There is no need to set a retry mechanism for potential conflicts arising from optimistic transactions. At the same time, MatrixOne has added support for the Select for update command. (Experimental)
      "},{"location":"MatrixOne/Release-Notes/v0.8.0/#other-features","title":"Other Features","text":"
      • Support window function RANK(), ROW_NUMBER() and DENSE_RANK().
      • Support the BINARY type and related functions.
      • Support data sharing between tenants and PUBLISH/SUBSCRIBE functions.
      • Support INSERT...ON DUPLICATE KEY UPDATE statement.
      • Add Sequence and related statements.
      • Support ADD [COLUMN] | DROP [COLUMN] in the ALTER TABLE statement.
      • Support multi-layer foreign key.
      • Support RAND() built-in function.
      • Support setting global variables in configuration files.
      • Secure initial MatrixOne account by password replacement.
      • Several types of partitioning are supported. (Experimental)
      "},{"location":"MatrixOne/Release-Notes/v0.8.0/#known-issues","title":"Known Issues","text":"
      • Data formats of versions before 0.8.0 are incompatible and cannot be upgraded directly.
      • Secondary indexes have not been improved in any performance.
      • Occasional memory leaks may lead to system out-of-memory(OOM) errors.
      • Workload isolation tags are currently only supported in JDBC.
      • TN represents a single point of failure for distributed version.
      • Occasional system hang-ups under high-concurrency workloads.
      • Pessimistic transaction has a few fatal bugs remaining.
      "},{"location":"MatrixOne/Release-Notes/v0.8.0/#contributors","title":"Contributors","text":""},{"location":"MatrixOne/Release-Notes/v0.8.0/#new-contributors","title":"New Contributors","text":"
      • @zengyan1
      • @forsaken628
      • @gavinyue
      • @gouhongshen
      • @WitcherTheWhite

      We appreciate your contribution! Welcome to the MatrixOne community.

      "},{"location":"MatrixOne/Release-Notes/v0.8.0/#full-changelog","title":"Full Changelog","text":"

      https://github.com/matrixorigin/matrixone/compare/v0.7.0...v0.8.0

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/","title":"MatrixOne v1.0.0-RC1 Release Notes","text":"

      We are thrilled to announce the release of MatrixOne 1.0.0-RC1 on 2023/8/24!

      This milestone marks we have basically achieved the initial design goal of the MatrixOne open-source project. Cheers!

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#matrixone-100-rc1-review","title":"MatrixOne 1.0.0-RC1 Review","text":"

      MatrixOne is designed to provide a unified and scalable database management solution for transactional, analytical and streaming workloads and powers a wide range of applications. In general, MatrixOne 1.0.0-RC1 has delivered a cloud-native architecture with separated storage and computing, presenting a fully-functional database with high performance queries and elastic scaling with familiar relational SQL. The OLTP and OLAP performance of MatrixOne has also reached the industry's average level, meanwhile MatrixOne provides an experimental function of Stream table and Kafka connector for streaming processing.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#sql","title":"SQL","text":"
      • Syntax: MatrixOne SQL syntax is highly compatible with MySQL 8.0.
      • DDL: Supports common DDL statements such as CREATE, ALTER, and DELETE databases, tables, views, and partitioned tables.
      • DML: Supports common DML statements including INSERT, UPDATE, DELETE, and data import/export statements.
      • Basic SQL query: Supports basic query capabilities such as grouping, deduplication, filtering, sorting, limiting, regular expressions, etc.
      • Advanced SQL query: Supports advanced query capabilities including views, subqueries, joins, unions, Common Table Expressions (CTE), window functions, prepared statements, etc.
      • Data Types: Supports data types including integer, floating-point, string, date/time, boolean, enum, binary, and JSON types.
      • Aggregate Functions: Supports common aggregate functions such as AVG, COUNT, MIN, MAX, SUM, etc.
      • System Functions and Operators: Supports common string, date/time, mathematical functions, and operators.
      • Indexes and Constraints: Supports primary keys, unique constraints, non-null constraints, foreign keys, auto-increment constraints, and secondary indexes.
      • Streaming: Supports the creation of streaming tables and integration with Kafka data sources.
      • Multi-tenancy: Supports the creation and management of internal tenants within the database.
      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#data-import-and-export","title":"Data Import and Export","text":"
      • Supports batch insert data using INSERT, LOAD DATA, SOURCE, etc.
      • Supports data export using SELECT INTO and modump methods.
      • Supports direct import from local files and object storage.
      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#transactions","title":"Transactions","text":"
      • Supports ACID (Atomicity, Consistency, Isolation, Durability) transaction properties.
      • Supports transaction initiation, commit, and rollback operations.
      • Supports both pessimistic and optimistic transactions, allowing users to switch between them.
      • Provides configuration options for isolation levels, including Snapshot Isolation and Read Committed.
      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#deployment","title":"Deployment","text":"
      • Supports both standalone and distributed deployment architectures.
      • Supports deployment through source code, binary packages, Docker, and Kubernetes.
      • Supports deployment on public cloud, private cloud, and physical machines.
      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#application-development","title":"Application Development","text":"
      • Supports native connectors for popular development languages such as Java, Python, and Golang, including JDBC, pymysql, go-sql-driver.
      • Supports common ORM frameworks for various languages such as MyBatis, Spring JPA, SQLAlchemy, GORM.
      • Supports popular MySQL management tools like Navicat, MySQL Workbench, DBeaver, HeidiSQL.
      • Provides a standalone and distributed command-line management tool named mo_ctl.
      • Includes comprehensive database logging and query recording capabilities, with the ability to integrate with visualization components like Grafana for real-time cluster monitoring.
      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#security-and-privileges","title":"Security and Privileges","text":"
      • Supports Transport Layer Security (TLS) encrypted connections.
      • Supports Role-Based Access Control (RBAC).
      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#backup-and-restore","title":"Backup and Restore","text":"
      • Supports logical backups using the modump tool.
      • Supports physical backups using the mobr tool.
      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#matrixone-use-cases","title":"MatrixOne Use Cases","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#operational-analytics","title":"Operational Analytics","text":"

      As the data volume of common IT systems such as OA, ERP, CRM, etc., increases with business growth, traditional single-node databases may not meet their performance requirements. Many companies set up a separate analytical database system to meet the needs of important reporting requirements at month-end or quarter-end, or use sharding techniques to reduce query loads. An operational analytics system is one that allows you to make quick decisions based on the current operational system. MatrixOne can fulfill the requirements of both the business system and the analytical system with a single database, while providing powerful scalability that can seamlessly expand as the business grows.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#real-time-analytics","title":"Real-time Analytics","text":"

      For typical OLAP (Online Analytical Processing) applications in business, such as dashboards and BI reports, massive data analysis is often required. When the data volume becomes significant, performance bottlenecks may arise, resulting in poor timeliness. MatrixOne offers fast data ingestion, powerful analytical performance and scalability, enabling accelerated processing of complex and large-scale SQL queries, achieving sub-second response times, and improving the agility of enterprise decision-making and analysis.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#iot-monitoring","title":"IoT Monitoring","text":"

      With the widespread application of sensors and network technologies, various IoT devices generate massive amounts of data, such as manufacturing plant production lines, renewable energy vehicles, city surveillance cameras, and more. The scale of data can easily reach hundreds of terabytes or even petabytes. There is an increasing demand for enterprises to store and utilize this data. Traditional database solutions cannot handle the real-time data ingestion and processing required in such massive and large-scale scenarios. MatrixOne provides powerful capabilities for streaming data ingestion and processing, along with robust scalability to handle any workload and data volume, fully meeting the requirements of this scenario.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#fluctuating-web-applications","title":"Fluctuating Web Applications","text":"

      For internet-based web applications such as gaming, e-commerce, entertainment, social media, news, etc., where user numbers are large and business fluctuations are frequent and significant, substantial computing resources are often required to support business demands during peak events. MatrixOne, with its fully cloud-native architecture, offers exceptional scalability, automatically scaling up or down in response to changes in the business, thereby greatly reducing the operational complexity for users.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#saas-applications","title":"SaaS Applications","text":"

      SaaS applications have experienced explosive growth in recent years. In SaaS application development, a multi-tenant model needs to be considered. Traditional solutions often involve either shared database instances for multiple tenants or dedicated database instances for each tenant, facing a trade-off between management costs and isolation. MatrixOne comes with built-in multi-tenancy capabilities, providing natural workload isolation between tenants and independent scalability. It also offers centralized management capabilities, effectively addressing cost, ease of management, and isolation requirements, making it the ideal choice for SaaS applications.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#quick-start","title":"Quick Start","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#docker","title":"Docker","text":"
      docker pull matrixorigin/matrixone:1.0.0-rc1\n

      This documentation site also provides detailed architecture instructions, installation guides, and development tutorials to help you explore the features and capabilities of MatrixOne here.

      Additionally, our GitHub and community forums are available for any questions, discussions, or feedback you may have.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#whats-changed-from-08-to-10","title":"What's changed from 0.8 to 1.0","text":"

      From 0.8 to 1.0, we mainly developed some new functions and improve usability for production-level deployment.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#key-new-features","title":"Key New Features","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#physical-backupenterprise-edition","title":"Physical Backup(Enterprise Edition)","text":"

      In this version, we have introduced the physical backup feature, allowing users to easily backup and restore databases. Now, you can effortlessly create snapshots of your database and restore to previous states when needed, ensuring data integrity and reliability.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#stream-computing","title":"Stream Computing","text":"

      As the final piece of the HSTAP architecture puzzle, we have completed the framework design for stream computing. In this iteration, we have added the ability to create streaming tables and implemented a Kafka connector to meet the streaming data ingestion needs of various time-series scenarios.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#recursive-cte","title":"Recursive CTE","text":"

      Recursive CTE (Common Table Expression) is a feature that allows for repeatedly executing an initial CTE to return subsets of data until the complete result set is obtained. The implementation in this iteration enables users to easily handle hierarchical data and build more complex and flexible queries using recursive queries.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#key-improvements","title":"Key Improvements","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#mysql-ddl-compatibility","title":"MySQL DDL Compatibility","text":"

      We have further improved MatrixOne's compatibility with MySQL, enabling better support for MySQL table creation statements. Now, users can seamlessly migrate existing MySQL applications to MatrixOne without modifying existing table creation statements.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#session-migration-during-scaling","title":"Session Migration during Scaling","text":"

      We have added the capability to migrate sessions seamlessly during distributed instance scaling operations. Users can easily adjust the capacity of MatrixOne without impacting existing sessions and business operations.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#simplified-system-configuration","title":"Simplified System Configuration","text":"

      We have significantly simplified the startup configuration options for both single-node and distributed versions, allowing users to quickly and easily start the database.

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#mo_ctl-tool","title":"mo_ctl Tool","text":"

      We have optimized the functionality of the mo_ctl maintenance tool for both single-node and distributed setups, providing more powerful and user-friendly maintenance capabilities. Now, you can effortlessly deploy, upgrade, scale, and perform other maintenance operations using the distributed mo_ctl tool (Enterprise Edition).

      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#other-features","title":"Other Features","text":"
      • Add Replace for DDL
      • Add column modification for Alter Table
      • Add Create Stage statement, simplify Data Import/Export process
      • Add Show Processlist for checking system status
      • Add enum data type
      • Add Year data type
      • Add To_Days/To_Seconds system functions
      • Improve Group by behavior by alias support
      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#known-issues","title":"Known Issues","text":"
      • Secondary Key doesn't improve any performance.
      • Memory leak occasionally happens and may lead to an OOM error.
      • DN is a single point of failure for distributed version.
      • Occasional system hung under high concurrency workload.
      "},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#full-changelog","title":"Full Changelog","text":"

      https://github.com/matrixorigin/matrixone/compare/v0.8.0...v1.0.0-rc1

      "},{"location":"MatrixOne/Security/Authentication/","title":"Authentication and Authorization","text":"

      When accessing the MatrixOne database, users need to undergo authentication and authorization. Currently, MatrixOne only supports username-password authentication. The database verifies the identity of the user accessing the data, confirms whether the user can be associated with a database user, and checks the validity of the provided password.

      "},{"location":"MatrixOne/Security/Authentication/#syntax","title":"Syntax","text":"

      In MatrixOne, a user's login identity comprises acccount_name, user_name, host, and password. The complete syntax is as follows:

      mysql -h host -p password -u accountname:username -P port\n

      The -h, -p, and -P parameters are the same as those used in MySQL. The difference lies in:

      • -u represents the user. In MatrixOne's user system, users are a concept below the tenant account. Therefore, when logging in, you need to specify the tenant account_name first and then specify the user username within the tenant to complete the login. If account_name is not specified, the default is the system tenant sys.

      Example:

      > mysql -h 127.0.0.1 -P6001 -utenant1:u1 -p111\n

      Note

      For the standalone version of MatrixOne, you can configure the connection string as parameters in the mo_ctl tool to simplify the login process.

      "},{"location":"MatrixOne/Security/Authentication/#query-current-user","title":"Query Current User","text":"

      After logging in, you can retrieve information about the current user using the user() or current_user() functions.

      mysql> select user();\n+--------------------+\n| user()             |\n+--------------------+\n| tenant1:u1@0.0.0.0 |\n+--------------------+\n1 row in set (0.00 sec)\nmysql> select current_user();\n+--------------------+\n| current_user()     |\n+--------------------+\n| tenant1:u1@0.0.0.0 |\n+--------------------+\n1 row in set (0.00 sec)\n

      Note

      MatrixOne currently does not support IP whitelisting. Therefore, regardless of the location you log in, the user will always be shown as 0.0.0.0.

      "},{"location":"MatrixOne/Security/Authentication/#query-all-users","title":"Query All Users","text":"

      Each user identity is unique, and users with the accountadmin role in a tenant can view all users within that tenant.

      mysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string                     | status | created_time        | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n|   10001 | localhost | u1        | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-10 06:43:44 | NULL         | PASSWORD   |       0 |     0 |            1 |\n|       0 | localhost | root      | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-08 03:17:27 | NULL         | PASSWORD   |       0 |     0 |            0 |\n|       1 | localhost | root      | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-08 03:17:27 | NULL         | PASSWORD   |       0 |     0 |            0 |\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n3 rows in set (0.01 sec)\n

      Note

      The location and table structure of user records in MatrixOne differs from MySQL. In MatrixOne, user metadata is not stored in the mysql.user table but in the mo_catalog.mo_user table.

      "},{"location":"MatrixOne/Security/Authentication/#constraints","title":"Constraints","text":"
      1. MatrixOne currently does not enforce password complexity requirements. It is recommended that users set strong passwords. For password modification operations, refer to Password Management.
      2. The initial password for the initial user (root user of the sys tenant) in MatrixOne is 111. After users modify their passwords, they need to remember the new password. Once a password is forgotten, MatrixOne currently does not provide a means to retrieve or bypass security verification to reset the password. Reinstallation of MatrixOne is required.
      "},{"location":"MatrixOne/Security/Security-Permission-Overview/","title":"Security and Permissions Overview","text":"

      Database security and permissions are critical to ensuring the protection and management of a database system and the data it stores. It involves a range of strategies, measures, and permission controls to ensure that only authorized users can access, modify, and operate the database. This chapter introduces the security and permission management system of the MatrixOne database.

      "},{"location":"MatrixOne/Security/Security-Permission-Overview/#security-management","title":"Security Management","text":"

      MatrixOne database security aims to protect the database from unauthorized access, data leaks, data tampering, and other security threats. MatrixOne provides the following capabilities to ensure database security:

      • Identity authentication and authentication: Enhance database security through identity identification, user authentication, roles, and password management.
      • Access control: Restrict access to the database system and specific data objects only to authorized users using authentication and authorization mechanisms.
      • Data transmission encryption: Encrypt data transmission to ensure that data cannot be intercepted, decrypted, and read during transmission.
      • Audit and logging: Monitor database activities, record access, and operation logs to track abnormal behavior, and conduct audits.
      "},{"location":"MatrixOne/Security/Security-Permission-Overview/#permission-management","title":"Permission Management","text":"

      MatrixOne database permission management manages user access and operation permissions to the database. Implementing fine-grained permission controls ensures that each user can only perform the necessary operations and restricts access to sensitive data. MatrixOne's database permission management includes the following aspects:

      • User roles and permission assignments: Assign users to different roles, each with different levels of permissions. Then associate permissions with roles to simplify permission management.
      • Object-level permissions: Define user access and operation permissions for specific database objects, such as tables and views, to ensure that users can only perform operations within their authorized scope.
      • Permission inheritance and control: Using inheritance mechanisms, transfer role permissions to users or other roles and control the inheritance process to ensure proper permission inheritance and management.
      "},{"location":"MatrixOne/Security/TLS-introduction/","title":"Data Transmission Encryption","text":"

      This document will introduce MatrixOne's support for data transmission encryption and how to enable encrypted transmission.

      "},{"location":"MatrixOne/Security/TLS-introduction/#overview","title":"Overview","text":"

      MatrixOne uses non-encrypted transmission by default and supports encrypted transmission based on TLS protocol. Encrypted transmission can reduce the risk of leakage of sensitive information in the database. Encrypted transmission is the process of encrypting and decrypting information using keys, which can effectively protect data security.

      Transport Layer Security (TLS) is a widely adopted security protocol. The protocol versions supported by MatrixOne include TLS 1.0, TLS 1.1, and TLS 1.2.

      • Do not enable TLS encrypted transmission (default): Use the username and password to connect to MatrixOne directly.
      • Use encrypted transmission: It is necessary to enable encrypted transmission support on the MatrixOne server and specify the use of encrypted transmission on the client side. You can follow the instructions in this article to enable TLS secure connections.
      "},{"location":"MatrixOne/Security/TLS-introduction/#how-to-use","title":"How to Use","text":"

      Main steps of TLS secure connection configuration:

      1. First, enable TLS in MatrixOne.

      2. Then, configure the MySQL client security connection parameters.

      After completing the configuration of these two main steps, a TLS secure connection can be established.

      "},{"location":"MatrixOne/Security/TLS-introduction/#step-1-enable-matrixones-tls-support","title":"Step 1: Enable MatrixOne's TLS support","text":"
      1. Generate certificate and key: MatrixOne does not yet support loading a private key protected by a password, so a private key file without a password must be provided. Certificates and keys can be issued and generated using OpenSSL. It is recommended to use the tool mysql_ssl_rsa_setup that comes with MySQL to generate quickly:

        #Check your local MySQL client installation directory\nps -ef|grep mysql\n#Go to the installation directory of your local MySQL client\ncd /usr/local/mysql/bin\n#Generate certificate and key\n./mysql_ssl_rsa_setup --datadir=<yourpath>\n#Check your generated pem file\nls <yourpath>\n\u251c\u2500\u2500 ca-key.pem\n\u251c\u2500\u2500 ca.pem\n\u251c\u2500\u2500 client-cert.pem\n\u251c\u2500\u2500 client-key.pem\n\u251c\u2500\u2500 private_key.pem\n\u251c\u2500\u2500 public_key.pem\n\u251c\u2500\u2500 server-cert.pem\n\u2514\u2500\u2500 server-key.pem\n

        Note: <yourpath> in the above code is the local directory path where you need to store the generated certificate and key files.

      2. Enter the cn.toml configuration file in your local MatrixOne file directory path matrixone/etc/launch-tae-CN-tae-TN/:

        You can also use the vim command to open the cn. toml file directly in the terminal

        vim $matrixone/etc/launch-tae-CN-tae-TN/cn.toml\n

        Copy and paste the code below into the configuration file:

        [cn.frontend]\n#default is false. With true. Server will support tls\nenableTls = true\n\n#default is ''. Path of file that contains X509 certificate in PEM format for client\ntlsCertFile = \"<yourpath>/server-cert.pem\"\n\n#default is ''. Path of file that contains X509 key in PEM format for client\ntlsKeyFile = \"<yourpath>/server-key.pem\"\n\n#default is ''. Path of file that contains list of trusted SSL CAs for client\ntlsCaFile = \"<yourpath>/ca.pem\"\n

        Note: <yourpath> in the above code is the local directory path where you need to store the generated certificate and key files

        In the above code, the configuration parameters are explained as follows:

        Parameters Description enableTls Bool, enable TLS support on the MatrixOne server. tlsCertFile Specify the SSL certificate file path tlsKeyFile Specify the private key corresponding to the certificate file tlsCaFile Optional, specify the trusted CA certificate file path

        Note: If you use Docker to install and launch MatrixOne, before modifying the configuration file, you need to mount the configuration file first and then modify it. For more information, see Mount directory to Docker container.

      3. Verify that MatrixOne's SSL is enabled.

        \u2460 Use the MySQL client to connect to MatrixOne:

        mysql -h 127.0.0.1 -P 6001 -uroot -p111\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n

        \u2461 Use the Status command to check whether SSL is enabled.

        Successfully enabled, the code example is as follows; you can see that the SSL status is Cipher in use is TLS_AES_128_GCM_SHA256:

        mysql> status\nmysql  Ver 8.0.28 for macos11 on arm64 (MySQL Community Server - GPL)\n\nConnection id:          1001\nCurrent database:\nCurrent user:           root@0.0.0.0\nSSL:                    Cipher in use is TLS_AES_128_GCM_SHA256\nCurrent pager:          stdout\nUsing outfile:          ''\nUsing delimiter:        ;\nServer version:         8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\nProtocol version:       10\nConnection:             127.0.0.1 via TCP/IP\nServer characterset:    utf8mb4\nDB     characterset:    utf8mb4\nClient characterset:    utf8mb4\nConn.  characterset:    utf8mb4\nTCP port:               6001\nBinary data as:         Hexadecimal\n--------------\n

        If it is not enabled successfully, the returned result is as follows; you can see that the SSL status is Not in use; you need to recheck whether the local directory path (namely ) of the certificate and key file you configured in the above steps is correct:

        mysql> status;\n/usr/local/mysql/bin/mysql  Ver 8.0.30 for macos12 on arm64 (MySQL Community Server - GPL)\n\nConnection id:      1009\nCurrent database:   test\nCurrent user:       root@0.0.0.0\nSSL:            Not in use\nCurrent pager:      stdout\nUsing outfile:      ''\nUsing delimiter:    ;\nServer version:     8.0.30-MatrixOne-v1.0.0-rc1 MatrixOne\nProtocol version:   10\nConnection:     127.0.0.1 via TCP/IP\nServer characterset:    utf8mb4\nDb     characterset:    utf8mb4\nClient characterset:    utf8mb4\nConn.  characterset:    utf8mb4\nTCP port:       6001\nBinary data as:     Hexadecimal\n--------------\n

        After completing the above steps, MatrixOne's TLS is enabled.

        "},{"location":"MatrixOne/Security/TLS-introduction/#step-2-configure-the-parameters-of-mysql-client","title":"Step 2: Configure the parameters of MySQL client","text":"

        When a MySQL client connects to Matrix One Server, the encrypted connection behavior needs to be specified by the --ssl-mode parameter, such as:

        mysql -h 127.0.0.1 -P 6001 -uroot -p111 --ssl-mode=PREFFERED\n

        Info

        The login account in the above code snippet is the initial account; please change the initial password after logging in to MatrixOne; see Password Management.

        The value types of ssl mode are as follows:

        ssl-mode value Description DISABLED Establish an encrypted connection without SSL/TLS, synonymous with skip-ssl. PREFFERED The default behavior is first to establish an encrypted connection using SSL/TLS; if it cannot be established, it will try to establish a non-SSL/TLS connection. REQUIRED Only SSL/TLS will be attempted to establish an encrypted connection, and if the connection cannot be established, the connection will fail. VERIFY_CA As with the REQUIRED behavior, and also verifies that the CA certificate on the Server side is valid. VERIFY_IDENTITY It acts like VERIFY_CA and verifies that the host in the server-side CA certificate is the same as the hostname for the actual connection.

        Note

        When the client specifies --ssl-mode=VERIFY_CA, it needs to use --ssl-ca to specify the CA certificate; If --ssl-mode=VERIFY_IDENTITY is specified on the client, you need to specify the CA certificate. You need to use --ssl-key to specify the client private key and --ssl-cert to specify the client certificate.

        "},{"location":"MatrixOne/Security/audit/","title":"Audit","text":""},{"location":"MatrixOne/Security/audit/#overview","title":"Overview","text":"

        The audit function records user behaviors and major internal events in the database. After logging in to the database, it registers all users' database operations and major internal events. It is also one of the essential features of many enterprise databases.

        In daily database operation and maintenance, an audit is a very effective means to ensure that all behaviors of database users comply with the law. When important events occur in the database, such as start and stop, node breakdown, and so on., the audit content can be very convenient for tracing the behavior of the protective device library before and after the period.

        It is necessary to enable database audit when you need to effectively and completely monitor necessary service information tables or system configuration tables. For example, it monitors all user A's behaviors in the database to discover the source of data modification or deletion promptly. For the monitoring of major internal events in the database, the fault can be rectified immediately, and the root cause of the accident can be traced back.

        MatrixOne supports auditing user behavior, operation logs, and SQL statements. The audit data of MatrixOne is stored in the database table, and the audit data can be queried directly through SQL interaction.

        "},{"location":"MatrixOne/Security/audit/#enable-audit","title":"Enable Audit","text":"

        To enable the audit, execute the following SQL statements:

        drop database if exists mo_audits;\ncreate database mo_audits;\nuse mo_audits;\ncreate view mo_user_action as select request_at,user,host,statement,status from system.statement_info where user in (select distinct user_name from mo_catalog.mo_user) and statement not like '______internal_%' order by request_at desc;\ncreate view mo_events as select timestamp,level,message from system.log_info where level in ('error','panic','fatal') order by timestamp desc;\n
        "},{"location":"MatrixOne/Security/audit/#audit-query","title":"Audit Query","text":"

        To audit user behaviors, execute the following SQL statement:

        mysql> select * from mo_audits.mo_user_action;\n

        The example query result as below:

        +----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n| request_at                 | user | host    | statement                                                                                                                                                                                                                                      | status  |\n+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n| 2023-02-10 19:54:28.831970 | root | 0.0.0.0 | create view mo_user_action as select request_at, user, host, statement, status from system.statement_info where user in (select distinct user_name from mo_catalog.mo_user) and statement not like \"______internal_%\" order by request_at desc | Success |\n| 2023-02-10 19:54:14.079939 | root | 0.0.0.0 | show tables                                                                                                                                                                                                                                    | Success |\n| 2023-02-10 19:54:14.076260 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:54:14.071728 | root | 0.0.0.0 | use mo_audits                                                                                                                                                                                                                                  | Success |\n| 2023-02-10 19:54:14.071108 | root | 0.0.0.0 | select database()                                                                                                                                                                                                                              | Success |\n| 2023-02-10 19:54:01.007241 | root | 0.0.0.0 | create database mo_audits                                                                                                                                                                                                                      | Success |\n| 2023-02-10 19:53:48.924819 | root | 0.0.0.0 | drop database if exists mo_audits                                                                                                                                                                                                              | Success |\n| 2023-02-10 19:30:59.668646 | root | 0.0.0.0 | show triggers                                                                                                                                                                                                                                  | Success |\n| 2023-02-10 19:30:53.438212 | root | 0.0.0.0 | show locks                                                                                                                                                                                                                                     | Success |\n| 2023-02-10 19:30:44.258894 | root | 0.0.0.0 | show index from t                                                                                                                                                                                                                              | Success |\n| 2023-02-10 19:30:43.662063 | root | 0.0.0.0 | create table t (a int, b int, c int, primary key (a))                                                                                                                                                                                          | Success |\n| 2023-02-10 19:30:23.104830 | root | 0.0.0.0 | show triggers                                                                                                                                                                                                                                  | Success |\n| 2023-02-10 19:30:20.062010 | root | 0.0.0.0 | show tables                                                                                                                                                                                                                                    | Success |\n| 2023-02-10 19:30:20.060324 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:30:20.055515 | root | 0.0.0.0 | use aab                                                                                                                                                                                                                                        | Success |\n| 2023-02-10 19:30:20.055186 | root | 0.0.0.0 | select database()                                                                                                                                                                                                                              | Success |\n| 2023-02-10 19:30:17.152087 | root | 0.0.0.0 | create database aab                                                                                                                                                                                                                            | Success |\n| 2023-02-10 19:30:10.621294 | root | 0.0.0.0 | create aab                                                                                                                                                                                                                                     | Failed  |\n| 2023-02-10 19:29:59.983433 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:29:45.370956 | root | 0.0.0.0 | show index from t                                                                                                                                                                                                                              | Failed  |\n| 2023-02-10 19:29:44.875580 | root | 0.0.0.0 | create table t (a int, b int, c int, primary key (a))                                                                                                                                                                                          | Failed  |\n| 2023-02-10 19:29:44.859588 | root | 0.0.0.0 | drop table if exists t                                                                                                                                                                                                                         | Success |\n| 2023-02-10 19:29:19.974775 | root | 0.0.0.0 | show index                                                                                                                                                                                                                                     | Failed  |\n| 2023-02-10 19:29:11.188286 | root | 0.0.0.0 | show locks                                                                                                                                                                                                                                     | Success |\n| 2023-02-10 19:29:06.618778 | root | 0.0.0.0 | show node list                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:19:11.319058 | root | 0.0.0.0 | show triggers                                                                                                                                                                                                                                  | Failed  |\n| 2023-02-10 19:19:06.809302 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 19:18:52.840282 | root | 0.0.0.0 | show triggers                                                                                                                                                                                                                                  | Failed  |\n| 2023-02-10 10:54:09.892254 | root | 0.0.0.0 | show databases                                                                                                                                                                                                                                 | Success |\n| 2023-02-10 10:54:04.468721 | root | 0.0.0.0 | select @@version_comment limit 1                                                                                                                                                                                                               | Success |\n+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n30 rows in set (0.81 sec)\n

        Query database internal status change query, execute the following SQL statement to view:

        mysql> select * from mo_events;\n

        The example query result as below:

        |\n| 2022-10-18 15:26:20.293735 | error | error: timeout, converted to code 20429                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| 2022-10-18 15:26:20.293725 | error | failed to propose initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| 2022-10-18 15:26:20.288695 | error | failed to set initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| 2022-10-18 15:26:20.288559 | error | failed to propose initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| 2022-10-18 15:26:20.285384 | error | failed to set initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| 2022-10-18 15:26:20.285235 | error | failed to propose initial cluster info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| 2022-10-18 15:26:18.473472 | error | failed to join the gossip group, 1 error occurred:\n    * Failed to join 127.0.0.1:32022: dial tcp 127.0.0.1:32022: connect: connection refused                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| 2022-10-18 15:26:18.469029 | error | failed to join the gossip group, 1 error occurred:\n    * Failed to join 127.0.0.1:32012: dial tcp 127.0.0.1:32012: connect: connection refused       \n
        "},{"location":"MatrixOne/Security/audit/#disable-audit","title":"Disable Audit","text":"

        To disable the audit, execute the following SQL statement:

        > drop database if exists mo_audits;\n
        "},{"location":"MatrixOne/Security/password-mgmt/","title":"MatrixOne Password Management","text":"

        To protect the security of user passwords, MatrixOne supports password management capabilities:

        • Password complexity strategy: Requires users to set strong passwords to prevent empty or weak passwords.
        "},{"location":"MatrixOne/Security/password-mgmt/#password-complexity-strategy","title":"Password Complexity Strategy","text":"

        MatrixOne recommends that users set complex passwords to ensure account security.

        • Suggested complexity: uppercase letters, lowercase letters, numbers, and special symbols.
        • Recommended length: no less than 12 characters.
        "},{"location":"MatrixOne/Security/password-mgmt/#modify-password-permissions","title":"Modify Password Permissions","text":"
        • System Administrator (i.e., the root user): Has the highest authority. Can modify the password of the root user itself and the password of Accounts created by the root user.
        • Accounts: Have authority second only to the system administrator. They can modify their own password and the password of ordinary users created by the Account.
        • Other ordinary users: Can only modify their own passwords.

        For more information about permission levels, see Privilege Control Types.

        "},{"location":"MatrixOne/Security/password-mgmt/#tutorial-of-password-changing","title":"Tutorial of Password Changing","text":""},{"location":"MatrixOne/Security/password-mgmt/#root-user-changing-password","title":"Root User Changing Password","text":""},{"location":"MatrixOne/Security/password-mgmt/#root-user-changing-their-own-password","title":"Root User Changing their own Password","text":"

        After starting MatrixOne and successfully logging in with the root, you can use the following command to change the password:

        mysql> alter user root identified by '${your password}'\n

        After the change is completed, you can go ahead and exit the current session and log into MatrixOne again for the new password to take effect.

        Note

        Since the root account is the user with the highest authority by default, please log in with the initial account password and change the password in time.

        "},{"location":"MatrixOne/Security/password-mgmt/#root-changing-accounts-password","title":"Root Changing Account's Password","text":"

        Refer to ALTER ACCOUNT

        "},{"location":"MatrixOne/Security/password-mgmt/#other-users-changing-password","title":"Other Users Changing Password","text":""},{"location":"MatrixOne/Security/password-mgmt/#account-changing-their-own-password","title":"Account Changing their own Password","text":"

        Refer to ALTER ACCOUNT

        "},{"location":"MatrixOne/Security/password-mgmt/#account-changing-the-password-of-other-users-they-created","title":"Account Changing The Password Of Other Users They Created","text":"

        Refer to ALTER USER

        "},{"location":"MatrixOne/Security/password-mgmt/#ordinary-user-changing-their-own-password","title":"Ordinary User Changing their own Password","text":"

        Refer to ALTER USER

        "},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/","title":"Create accounts, Verify Resource Isolation","text":"

        When initializing access to the MatrixOne cluster, the system will automatically generate a default cluster administrator. The cluster administrator is automatically granted the authority to manage accounts by default, but cannot manage resources under the account.

        This document will guide you to use the cluster administrator to create two new accounts, grant the permissions of the accountadmin, and check whether the resource isolation between accounts is implemented.

        "},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/#before-you-start","title":"Before you start","text":"
        • MatrixOne cluster has been depolyed and connected.
        • You have obtained the cluster administrator user name and password (The default user name and password are root and 111 respectively).
        "},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/#steps","title":"Steps","text":"
        1. Log into MatrixOne with the cluster administrator's username (root by default) and password:

          mysql -h 127.0.0.1 -P 6001 -u root -p\n
        2. Create a new account:

          • The login username and password of account a1 are: admin1, test123
          • The login username and password of account a2 are: admin2, test456
          create account a1 ADMIN_NAME 'admin1' IDENTIFIED BY 'test123';\ncreate account a2 ADMIN_NAME 'admin2' IDENTIFIED BY 'test456';\n
        3. Use admin1 to log in to account a1, and create data table db1.t1:

          mysql -h 127.0.0.1 -P 6001 -u a1:admin1 -p\ncreate database db1;\ncreate table db1.t1(c1 int,c2 varchar);\ninsert into db1.t1 values (1,'shanghai'),(2,'beijing');\n

          Use the following command to verify whether the table was created successfully for account a1:

          mysql> select * from db1.t1;\n+------+----------+\n| c1   | c2       |\n+------+----------+\n|    1 | shanghai |\n|    2 | beijing  |\n+------+----------+\n2 rows in set (0.01 sec)\n
        4. Login to account a2 using admin2:

          mysql -h 127.0.0.1 -P 6001 -u a2:admin2 -p\n

          Check db1.t1 data in account a1:

          mysql> select * from db1.t1;\nERROR 1064 (HY000): SQL parser error: table \"t1\" does not exist\n

          The above command runs an error, which proves that the database db1 in the account a1 cannot be seen in the account a2:

        5. The database db1 and table db1.t1 can also be created in the account a2:

          mysql> create database db1;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> create table db1.t1(c1 int,c2 varchar);\nQuery OK, 0 rows affected (0.05 sec)\n\nmysql> insert into db1.t1 values (3,'guangzhou');\nQuery OK, 1 row affected (0.05 sec)\n

          Insert different data into table db1.t1 of account a2 from table db1.t1 in account a1 and check:

          mysql> insert into db1.t1 values (3,'guangzhou');\nQuery OK, 1 row affected (0.05 sec)\n\nmysql> select * from db1.t1;\n+------+-----------+\n| c1   | c2        |\n+------+-----------+\n|    3 | guangzhou |\n+------+-----------+\n1 row in set (0.01 sec)\n

          It can be seen that even though the database and table in account a1 have the same name, the two databases and tables do not interfere with each other and are completely isolated.

        "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/","title":"Create a new account, use the new account, creates users, create roles, and grant the privilege","text":"

        When initializing access to the MatrixOne cluster, the system will automatically generate a default account, which is the cluster administrator. The default user name of the cluster administrator is root. root is both a cluster administrator and a system account administrator. root can create and manage other common accounts (non-system account administrators).

        This document will guide you through creating a new account, switching to the new account to log in, using the new account account to create users, creating roles, creating permissions, and granting user privileges.

        "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#before-you-start","title":"Before you start","text":"
        • MatrixOne cluster has been depolyed and connected.
        • You have obtained the cluster administrator user name and password (The default user name and password are root and 111 respectively).
        "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#steps","title":"Steps","text":""},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#step-1-create-a-new-account","title":"Step 1: Create a new account","text":"
        1. Log into MatrixOne with the cluster administrator's username (root by default) and password:

          mysql -h 127.0.0.1 -P 6001 -u root -p\n
        2. Create a new account a1; the username and password of account a1 are: admin, test123:

          create account a1 ADMIN_NAME 'admin' IDENTIFIED BY 'test123';\n

          Check all accounts information in the cluster (only root can view):

          mysql> select * from mo_catalog.mo_account;\n+------------+--------------+--------+---------------------+----------------+----------------+\n| account_id | account_name | status | created_time        | comments       | suspended_time |\n+------------+--------------+--------+---------------------+----------------+----------------+\n|          1 | a1           | open   | 2022-12-19 14:47:19 |                | NULL           |\n|          0 | sys          | open   | 2022-12-07 11:00:58 | system account | NULL           |\n+------------+--------------+--------+---------------------+----------------+----------------+\n
        "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#step-2-log-in-to-the-new-account-account-create-users-create-roles-and-grant-the-privilege","title":"Step 2: Log in to the new account account, create users, create roles and grant the privilege","text":"
        1. You can reopen a new session with admin login to account a1:

          mysql -h 127.0.0.1 -P 6001 -u a1:admin -p\n
        2. Now you can check the default users and roles under the account as a1:

          mysql> select * from mo_catalog.mo_role;\n+---------+--------------+---------+-------+---------------------+----------+\n| role_id | role_name    | creator | owner | created_time        | comments |\n+---------+--------------+---------+-------+---------------------+----------+\n|       2 | accountadmin |       0 |     0 | 2022-12-19 14:47:20 |          |\n|       1 | public       |       0 |     0 | 2022-12-19 14:47:20 |          |\n+---------+--------------+---------+-------+---------------------+----------+\n2 rows in set (0.01 sec)\n\nmysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time        | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n|       2 | localhost | admin     | test123               | unlock | 2022-12-19 14:47:20 | NULL         | PASSWORD   |       0 |     0 |            2 |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n1 row in set (0.00 sec)\n

          After account a1 is successfully created, it has account administrator privileges by default so that you can view the system table information under account a1. In the mo_user table, it can be observed that there is currently a user account named admin, which is specified when creating a account; in addition, there are two default roles, accountadmin and public:

          • accountadmin has the highest authority of the account, and the account named admin is granted by default;
          • The system will authorize the public role for each new ordinary user by default, and the initial permission of the public role is connect, that is, to connect to MatrixOne.

          In addition, you can also view the privilege sets of these default roles in the system table:

          mysql> select * from mo_catalog.mo_role_privs;\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n| role_id | role_name    | obj_type | obj_id | privilege_id | privilege_name     | privilege_level | operation_user_id | granted_time        | with_grant_option |\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n|       2 | accountadmin | account  |      0 |            3 | create user        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            4 | drop user          | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            5 | alter user         | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            6 | create role        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            7 | drop role          | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |            9 | create database    | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           10 | drop database      | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           11 | show databases     | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           12 | connect            | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           13 | manage grants      | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | account  |      0 |           14 | account all        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           18 | show tables        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           20 | create table       | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           23 | drop table         | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           26 | alter table        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           21 | create view        | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           24 | drop view          | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           27 | alter view         | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           28 | database all       | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | database |      0 |           29 | database ownership | *               |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           30 | select             | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           31 | insert             | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           32 | update             | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           33 | truncate           | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           34 | delete             | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           35 | reference          | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           36 | index              | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           37 | table all          | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           38 | table ownership    | *.*             |                 0 | 2022-12-19 14:47:20 | true              |\n|       2 | accountadmin | table    |      0 |           41 | values             | t               |                 0 | 2022-12-19 14:47:20 | true              |\n|       1 | public       | account  |      0 |           12 | connect            | *               |                 0 | 2022-12-19 14:47:20 | true              |\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n
        3. In account a1, create a new user and role:

          • Username and password for user u1 are: u1, user123
          • Username and password for user u2 are: u2, user456
          • Role r1 is named: r1
          • Role r2 is named: r2
          create user u1 identified by 'user123';\ncreate user u2 identified by 'user456';\ncreate role r1;\ncreate role r2;\n
        4. Create database db1 and create table t1 in db1:

          create database db1;\ncreate table db1.t1(c1 int,c2 varchar);\n
        5. Grant select privilege on db1.t1 to r1 and insert privilege to r2:

          grant select on table db1.t1 to r1;\ngrant insert on table db1.t1 to r2;\n
        6. Grant role r1 to user u1; grant role r2 to user u2:

          grant r1 to u1;\ngrant r2 to u2;\n

          At this point, the newly created user, role, and object permission relationship is shown in the following figure:

        "},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#step-3-verify-the-privilege-is-valid","title":"Step 3: Verify the privilege is valid","text":"

        Log in to account a1 with users u1 and u2, respectively, to verify that the privileges are in effect.

        Since u2 has been granted the r2 role, and r2 has been granted the insert privilege of db1.t1, so u2 has the insert privilege of db1.t1, that is, db1.t1 insert data.

        Use u1 to log into a1 to verify that the privilege is valid:

        mysql -h 127.0.0.1 -P 6001 -u a1:u2:r2 -p\n\nmysql> insert into db1.t1 values (1,'shanghai'),(2,'beijing');\nQuery OK, 2 rows affected (0.04 sec)\n\nmysql> select * from db1.t1;\nERROR 20101 (HY000): internal error: do not have privilege to execute the statement\n

        u2 can successfully insert data into the table db1.t1, but cannot view the data in the table db1.t1.

        Similarly, you can use u1 to log in to a1 for privilege verification:

        mysql -h 127.0.0.1 -P 6001 -u a1:u1:r1 -p\n\nmysql> select * from db1.t1;\n+------+----------+\n| c1   | c2       |\n+------+----------+\n|    1 | shanghai |\n|    2 | beijing  |\n+------+----------+\n2 rows in set (0.01 sec)\n\nmysql> insert into db1.t1 values (3,'guangzhou');\nERROR 20101 (HY000): internal error: do not have privilege to execute the statement\n

        As shown in the above code, u1 can successfully query the data of table db1.t1, but cannot insert data into it.

        Note

        For more information about system tables, see MatrixOne System Database and Tables

        "},{"location":"MatrixOne/Security/how-tos/user-guide/","title":"Privileges Management Overview","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#manage-account","title":"Manage Account","text":"
        • Prerequisites: Account management is only possible with a cluster administrator (the default account is the root).

        The roles and permissions corresponding to the root are shown in the following table:

        Username Explanation Role Privilege Description root Cluster administrator MOADMIN Create, edit, delete accounts Automatically generated and granted after cluster creation root System account administrator MOADMIN Manage all resources under the system account, including users, roles, databases/tables/views, authorization management Automatically generated and granted after the cluster is created"},{"location":"MatrixOne/Security/how-tos/user-guide/#create-account","title":"Create Account","text":"

        SQL Statement

        create account <account_name> admin_name='<user_name>' identified by '<password>';\n

        Parameter Description

        Parameter Description account_name account name user_name The administrator username of the newly created account, which will be automatically granted the highest privilege role of the account, namely ACCOUNTADMIN password Newly created account administrator password

        For more information, see CREATE ACCOUNT.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#select-account","title":"Select Account","text":"

        SQL Statement

        select * from mo_catalog.mo_account;\n
        "},{"location":"MatrixOne/Security/how-tos/user-guide/#delect-account","title":"Delect Account","text":"

        SQL Statement

        drop account if exists <account_name>;\n

        Parameter Description

        Parameter Description account_name The name of the account to be deleted

        Note

        After the account is deleted, it cannot be restored, including all data under the account account. Please use it with caution.

        For more information, see DROP ACCOUNT.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#manage-user","title":"Manage User","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#create-user","title":"Create User","text":"
        • Prerequisites: Has the CREATE USER privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Create a username and password for a user in the current account.

        SQL Statement

        create user <user_name> identified by '<password>';\n

        Parameter Description

        Parameter Description user_name The name of a new user password The password of a new user

        For more information, see CREATE USER.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#view-user","title":"View User","text":"
        • Prerequisites: Has the privilege to view users.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: View all the users in the current account.

        SQL Statement

        select * from mo_catalog.mo_user;\n
        "},{"location":"MatrixOne/Security/how-tos/user-guide/#delete-user","title":"Delete User","text":"
        • Prerequisites: Has the DROP USER privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Delete the specified user in the current account.

        SQL Statement

        drop user if exist <user_name>;\n

        Parameter Description

        Parameter Description user_name The name of the user to be deleted

        Note

        When deleting a user, you need to stop the user's current session first, otherwise the deletion will fail.

        For more information, see DROP USER.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#manage-role","title":"Manage Role","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#create-role","title":"Create Role","text":"
        • Prerequisites: Has the CREATE ROLE privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Create a custom role in the current account.

        SQL Statement

        create role <role_name>;\n

        Parameter Description

        Parameter Description role_name The name of a new role

        For more information, see CREATE ROLE.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#view-role","title":"View Role","text":"
        • Prerequisites: Has the privilege to view role.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: View all the roles in the current account.

        SQL Statement

        select * from mo_catalog.mo_role;\n
        "},{"location":"MatrixOne/Security/how-tos/user-guide/#switch-role","title":"Switch Role","text":"
        • Prerequisites: Has the SET ROLE privilege. By default, all users have this privilege.

        • Introduction: Switch the role of the user in the account, and obtain the privilege of the secondary role to execute the corresponding SQL.

        SQL Statement

        set role <role_name>;\n

        Parameter Description

        Parameter Description role_name The name of the role to be switched

        For more information, see SET ROLE.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#delete-role","title":"Delete Role","text":"
        • Prerequisites: Has the DROP ROLE privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Delete the specified role in the current account.

        SQL Statement

        drop role if exists <role_name>;\n

        Parameter Description

        Parameter Description role_name The name of the role to be deleted

        Note

        When deleting a specified role, the roles of authorized users will be recovered simultaneously.

        For more information, see DROP ROLE.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#manage-privilege","title":"Manage Privilege","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#grant-an-object-privilege-to-a-role","title":"Grant an object privilege to a role","text":"
        • Prerequisites: Has the MANAGE GRANTS privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Grant an object privilege to a role.

        SQL Statement

        grant <privilege> on <object_type> <object_name> to <role_name>\n

        Parameter Description

        Parameter Description privilege Privilege Name object_type The type of object object_name The name of object role_name The name of the role which is granted

        For more information, see GRANT.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#grant-certain-kind-of-object-privileges-to-a-role","title":"Grant certain kind of object privileges to a role","text":"
        • Prerequisites: Has the MANAGE GRANTS privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Grant the privilege on all databases/tables to a role.

        SQL Statement

        grant <privilege> on database * to <role_name>;\ngrant <privilege> on table *.* to <role_name>;\n

        Parameter Description

        Parameter Description privilege Privilege Name role_name The name of the role which is granted

        Note

        Although this operation is relatively simple when authorizing multiple objects of the same category, it is also prone to permission leakage, so please use it with caution.

        For more information, see GRANT.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#grant-a-role-to-a-user","title":"Grant a role to a user","text":"
        • Prerequisites: Has the MANAGE GRANTS privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Grant a role to a user.

        SQL Statement

        grant <role_name> to <user_name>;\n

        Parameter Description

        Parameter Description role_name The name of the role which is granted user_name The name of the user which is granted

        For more information, see GRANT.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#one-role-inherit-the-privileges-of-another-role","title":"One role inherit the privileges of another role","text":"
        • Prerequisites: Has the MANAGE GRANTS privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Let role_b inherit all privileges of role_a.

        SQL Statement

        grant <role_a> to <role_b>;\n

        Note

        The permissions are inherited dynamically. If the permissions of role_a change, the permissions inherited by role_b will also change dynamically. MatrixOne does not allow role ring inheritance; that is, role1 inherits role2, role2 inherits role3, but role3 can not inherits role1.

        For more information, see GRANT ROLE.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#show-the-privilege-of-user","title":"Show the privilege of user","text":"
        • Prerequisites: Has the SHOW GRANTS privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Show all privileges currently owned by the specified user.

        SQL Statement

        show grants for <user_name>@<localhost>\n

        Parameter Description

        Parameter Description user_name The name of user which is granted.

        For more information, see SHOW GRANTS.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#revoke-the-role-of-user","title":"Revoke the role of user","text":"
        • Prerequisites: Has the REVOKE privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Remove a role from a user.

        SQL Statement

        revoke <role_name> from <user_name>\n

        Parameter Description

        Parameter Description role_name The name of role which is granted. user_name The name of user which is granted.

        For more information, see REVOKE.

        "},{"location":"MatrixOne/Security/how-tos/user-guide/#revoke-privilege-of-roles","title":"Revoke privilege of roles","text":"
        • Prerequisites: Has the REVOKE privilege.

          \u00b7 The default role with this privilege is MOADMIN or ACCOUNTADMIN: the cluster administrator (the default account is root), and the tenant administrator created by the cluster administrator has the privilege by default.

        • Introduction: Revoke privileges on an object in a role.

        SQL Statement

        revoke <privilege> on <object_type> <object_name> to <role_name>;\n

        Parameter Description

        Parameter Description privilege Privilege object_type The type of the object object_name The name of the object role_name A role that needs to be granted

        For more information, see REVOKE.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/","title":"Privilege Management Overview","text":"

        MatrixOne privilege management helps you manage accounts and users' life cycles, assign users complementary roles, and control access rights to resources in MatrixOne. When there are multiple users in a database or cluster unit, privilege management ensures that users only access authorized help, and granting users the principle of least authority can reduce enterprise information security risks. MatrixOne can also implement multi-account solutions through rights management. In MatrixOne, the data or resources owned by each account in the cluster are safely isolated, and users across cluster units cannot access the help of other cluster units. Only users authorized to access resources in the cluster have the right to access this A resource within a cluster unit.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#privilege-management-features","title":"Privilege Management Features","text":"

        MatrixOne's privilege management is designed and implemented by combining two security models: RBAC (Role-based access control) and discretionary access control (DAC, Discretionary access control). These two security models are neutral access. The control mechanism mainly revolves around role and authority authorization strategies. It not only ensures data access security but also provides flexible and convenient management methods for database operation and maintenance personnel.

        • Role-Based Access Control (RBAC): assign privileges to roles, and then assign roles to users.

        • Discretionary Access Control (DAC): Every object has an owner who can set and grant access privileges to that object.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#key-concepts","title":"Key Concepts","text":""},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#object","title":"Object","text":"

        In MatrixOne, the privileges are encapsulated in an entity, which is objectto facilitate the management of multiple operation privileges.

        For example, operation privileges such as Select, Insert, and Update is encapsulated in the Table object. For more information about object privileges, please refer to MatrixOne Privilege Control Types.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#relationship-between-objects","title":"Relationship between objects","text":"

        As shown in the diagram below: from above, higher-level objects can create (or delete) lower-level objects.

        The hierarchical relationships in the above figure are all 1:n relationships; that is, multiple accounts can be created in one cluster, multiple users and roles can be created under one account, and multiple tables and views can be created in one database.

        In MatrixOne, although the operation privileges in each object are independent of each other (for example, the SHOW TABLES privilege in the Database object is not directly related to the SELECT privilege in the Table object), the creation of objects still has Certain associations, for example, the CREAT TABLE privilege in the Database object can create Table objects, which forms a hierarchical relationship between objects,

        Then, since high-level objects can create low-level objects, the higher-level objects are object creators (Owner).

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#object-creators-owner","title":"Object creators (Owner)","text":"

        When an object is created, the creator is the object's owner, who has the highest authority to manage the object (that is, Ownership authority, which is all the authority encapsulated in the object). The owner's operation authority sets all operations on the object.

        For example, the Table object has Select, Insert, Update, Delete, Truncate, and Ownership privileges; if a role has the Ownership privilege of a certain Table, then the role is equivalent to having Select, Insert, Update, Delete, Truncate privileges.

        Due to the transitivity between privileges, roles, and users, you can understand the creator of an object (starting now referred to as the object owner) as a role.

        How to understand that the creator of an object is a role?

        A user can have multiple roles at the same time. For example, User A has three roles: Role 1, Role 2, and Role 3. Each role has different privileges, as shown in the following figure, to help you quickly understand this behavior:

        If User A is currently using Role 1, User A needs to create a new User B, but the current Role 1 does not have privilege to create new users. Role 2 has the authorization to create new users, then User A needs to switch to the Role 2 role and create a new user. Then, the Owner of New User B is Role 2, and other roles, Role 1 and Role 3, cannot have the ownership of User B.

        Owner points to the object

        • An object's Owner is a role, and the object's original Owner is the role that created it.

        • There is only one Owner of an object at any time.

        • A role can create multiple objects so that a role can be the Owner of multiple objects.

        • A role is an object, so a role also has an Owner.

        • When the Owner of an object is deleted, the Owner of the object will be automatically changed to the Owner of the deleted role.

        • The owner can be transferred to another role.

        Note: ACCOUNTADMIN (account administrator role, automatically generated after the account is created) is not the Owner of the objects used in the account. Still, it has the Ownership privilege of all objects.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#cluste","title":"Cluste","text":"

        The cluster is the highest-level object in MatrixOne privileges management.

        Tip: The collection of operational privileges on cluster objects is called system privileges.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#account","title":"Account","text":"

        In the MatrixOne cluster, multiple accounts with completely isolated data and user authority systems can be created and managed, and these resource-isolated accounts can be managed. This multi-account function not only saves the cost of deploying and operating multiple sets of data business systems but also can take advantage of sharing hardware resources between accounts to save machine costs to the greatest extent.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#system-account","title":"System Account","text":"

        To be compatible with the usage habits of traditional non-multi-account databases, MatrixOne will automatically create a new system default account after the cluster is created, that is, Sys Account. If you only have one set of data business systems that need to be managed by MatrixOne, there is no need to create more accounts, log in and access the Sys Account directly.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#role","title":"Role","text":"

        A role is also an object used to manage and grant privileges in MatrixOne.

        First of all, you need to have a high-privilege account first to do some initial resource allocation; for example, create some roles and users by Sys Account or Account, grant object privileges to the role, and then grant the role to the user, at this time, the user can operate on the object. It needs to be granted to a user. In a account, the user cannot perform any operations if a user is not granted a role.

        Role is set up to save the operation cost of granting the same authority. The three privileges p1, p2, and p3 must be granted to users u1, u2, and u3. You only need to grant p1, p2, and p3 to role r1 first, then grant role r1 to users u1, u2, and u3 simultaneously. It is easier to operate than granting each privilege to each user separately, and this advantage will become more obvious as the number of users and privileges increases. At the same time, the emergence of roles further abstracts the privilege set and its relationship, which is also very convenient for later privilege maintenance.

        After the cluster and account (Account) are created, MatrixOne will automatically create some default roles and users (see the Initialization Access section below for details); these roles have the highest management authority and are used to manage the cluster and account at the beginning ( Account), we do not recommend that you grant these roles to users who execute SQL daily. Excessive privileges will introduce more security issues. Therefore, MatrixOne supports the creation of custom roles. You can customize roles according to the user's business needs and assign appropriate privileges to these roles.

        Highlights

        In MatrixOne, the behavior details of roles are as follows:

        • A role can be granted multiple privileges.
        • A role can be granted to multiple users.
        • A role can pass its privileges to another role.

          • Use all the privileges of a role to another role; for example, pass all the privileges of role1 to role2, then role2 inherits the privileges of role1,
        • Roles and users only take effect within their respective Account, including the Sys Account.

        Note

        1. The privilege inheritance of roles is dynamic. If the privileges of the inherited role change, the scope of privileges inherited by the inherited role will also change dynamically.
        2. The inheritance relationship of roles cannot form a loop. For example, role1 inherits role2, role 2 inherits role3, and role3 inherits role1.
        3. The transfer of privileges between roles makes privilege management more convenient, but it also has risks. For this reason, MatrixOne only allows roles with Manage Grants privilege to do this kind of operation. This privilege is granted to the system default role MOADMIN by default or ACCOUNTADMIN, and it is not recommended to grant this privilege to a custom role when creating a new one.
        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#role-switching","title":"Role Switching","text":"

        A user is granted multiple roles to perform different types of data services.

        Main role: The user can only use one of the roles at a particular moment; we call the currently used role main role.

        Secondary role: In addition to the main role, the set of other roles owned by the user is called the secondary role.

        By default, if a user wants to execute SQL with another role's privilege, he needs to switch roles first (Use SQL as set role <role>). In addition, to be compatible with the privilege behavior of classic databases, MatrixOne also supports the function of using secondary roles: use set secondary role all; after executing this SQL, the user can have the privileges of all his roles at the same time, execute set secondary role none to turn off this feature.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#application-scenarios","title":"Application scenarios","text":""},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#resource-isolation-scenarios-introduction","title":"Resource Isolation Scenarios Introduction","text":"

        Company A purchased a MatrixOne cluster and completed the deployment. Since Company A has a large scale, many complex business lines, and a huge amount of data, it wants to develop an application for a certain business line, assuming it is named BusinessApp. Still, it needs to be isolated from the data of other business lines. So how does MatrxiOne isolate these data resources and authority resources?

        After completing the deployment of the MatrixOne cluster, Tom of the R&D department obtained the account of the cluster administrator, and the company assigned him to complete the task of resource isolation. Tom needs to do this:

        1. Tom logs into MatrixOne with the cluster administrator account.
        2. Tom needs to create two accounts first, one is BusinessAccount and the other is ElseAccount.

          • The data resources within BusinessAccount are mainly used to develop the application BusinessApp.
          • Data resources within ElseAccount may be used for other business purposes.

        For the specific operation of resource isolation, please refer to Quick Start: Create accounts, Verify Resource Isolation.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#introduction-to-user-creation-and-authorization-scenarios","title":"Introduction to User Creation and Authorization Scenarios","text":"

        Still using the above scenario example, Tom gives the account account BusinessAccount to the company's data administrator Robert, and asks Robert to assign new user accounts and privileges to other R&D colleagues.

        R&D colleague Joe is the application developer of this company. A project BusinessApp, Joe has a development task, and Joe needs to use all the data in the database. Then Robert will help Joe open an account and authorize Joe:

        1. Robert first creates a user account (i.e., user) for Joe, named Joe_G, and Joe uses Joe_G to log in to MatrixOne.
        2. Robert creates another role for Joe, named Appdeveloper, and assigns the Appdeveloper role to Joe's user account Joe_G.
        3. Robert grants the ALL ON DATABASE permission to the role Appdeveloper.
        4. Joe can use the account Joe_G to log in to MatrixOne, and has full authority to operate the database for development.

        For specific user creation and authorization operations, see Quick start: Create a new account, use the new account, creates users, create roles, and grant the privilege.

        "},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#initialize-access","title":"Initialize Access","text":"

        After initializing the cluster or account, the system will automatically generate some default users and default roles:

        Username Explanation Role Privilege Description root Cluster administrator MOADMIN Create, edit, delete accounts Automatically generated and granted after cluster creation root System account administrator MOADMIN Manage all resources under the system account, including users, roles, databases/tables/views, authorization management Automatically generated and granted after the cluster is created account administrator ACCOUNTADMIN Manage all resources under common accounts, including users, roles, databases/tables/views, and authorization management Accounts are automatically generated and granted after they are created All users Ordinary users PUBLIC Connect to MatrixOne After all users are created, they are automatically granted the PUBLIC role"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#quick-start","title":"Quick Start","text":"
        • Quick Start: Create accounts, Verify Resource Isolation
        • Quick start: Create a new account, use the new account, creates users, create roles, and grant the privilege
        • Typical Application Scenarios
        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/","title":"Privilege Management Scenario","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-overview","title":"Scenario overview","text":"
        • If your company has deployed a MatrixOne cluster after the deployment, a cluster administrator will automatically exist when the cluster is initialized. If you like, contact the project manager or sales representative of MatrixOne to get the account information and initial password. Using the cluster administrator, you can create a new account, manage the life cycle of the account, and assign the account account password to the corresponding person in charge of your company. For more information on how to manage accounts, see Quick Start: Create accounts, Verify Resource Isolation or Privilege Management Operation Guide.

        • If your enterprise only needs to use MatrixOne cluster account resources, after the deployment is complete, the MatrixOne cluster administrator will help you open an account administrator account. Please contact the MatrixOne project manager or sales representative for the account information and initial password. Using the account administrator account, you can create new users, manage user lifecycles and resources in the account (users, roles, and permissions), and assign user account passwords to the corresponding persons in charge of your company. For more information on how to manage accounts, see Quick Start: Create accounts, Verify Resource Isolation or Privilege Management Operation Guide.

        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-1-create-a-new-data-administrator-and-grant-the-privilege","title":"Scenario 1: Create a new data administrator and grant the privilege","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-introduction","title":"Scenario Introduction","text":"

        In practical application scenarios, it is necessary to set up a data administrator position responsible for managing the allocation of resources in the entire database. For example, other company members need to be assigned a user account, password, and role and be granted minimum Usage rights.

        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#before-you-start","title":"Before you start","text":"
        • You first need to have an account of account Administrator.

        • Already connected to the MatrixOne cluster.

        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#solution","title":"Solution","text":"

        Create a data administrator role and grant him global management permissions within the account; then, you need to do the following:

        • Create a new user, username: dbauser; password: 123456.
        • Assign a data administrator role to this user, and the role is named: dba.
        • This role requires the following permissions:
          • Own all permissions of the account object: With this permission, the data administrator can create new users and new roles and assign permissions to other users.
          • Own all permissions of database objects: With this permission, the data administrator can create, edit, and delete databases.
          • Own all permissions of the table object: With this permission, the data administrator can create, edit, and delete data tables.
        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#steps","title":"Steps","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#step-1-use-the-account-administrator-to-create-the-database-administrator","title":"Step 1: Use the account administrator to create the database administrator","text":"
        1. Log in to the account with the account administrator account:

          Note: The account administrator account account1 here is an example; you can customize it when creating an account administrator.

          mysql -h 127.0.0.1 -P 6001 -u account1:admin:admin -p\n
        2. Create a user and named dbauser with a password of 123456:

          create user dbauser identified by \"123456\";\n
        3. Create a data administrator role named dba:

          create role dba;\n
        4. Grant the privilege to the role the following permissions:

          • Full permissions on the account object
          • Full permissions on database objects
          • Full permissions on the table object
          grant all on account * to dba with grant option;\ngrant all on database * to dba with grant option;\ngrant all on table *.* to dba with grant option;\n
        5. Grant role dba to user dbauser:

          grant dba to dbauser;\n
        6. Check the privilege using the following command:

          show grants for dbauser@localhost;\n
        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#step-2-use-the-data-administrator-to-log-and-test","title":"Step 2: Use the data administrator to log and test","text":"
        1. Log into MatrixOne with the data administrator account dbauser:

          mysql -h 127.0.0.1 -P 6001 -u account1:dbauser:dba -p\n
        2. Check the privileges of dbauser:

          show grants for dbauser@localhost;\n
        3. Check the role of dbauser:

          SET SECONDARY ROLE ALL;\nuse mo_catalog;\nselect mu.user_name,mr.role_name from mo_role mr,mo_user mu,mo_user_grant mug where mu.user_id=mug.user_id and mr.role_id=mug.role_id and mu.user_name='dbauser';\n
        4. Create a database to verify the privilege is valid:

          drop database if exists test;\ncreate database test;\nuse test;\ncreate table t1(a int);\ninsert into t1 values(1),(2),(3);\nselect * from t1;\n
        5. The above code indicates that the verification is successful.

        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-2-application-system-goes-online","title":"Scenario 2: Application System Goes Online","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#scenario-introduction_1","title":"Scenario Introduction","text":"

        When the application system goes online, a new database and corresponding database user will be created according to the usage requirements of the application system, and this user will be granted all permissions of the target database.

        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#before-you-start_1","title":"Before you start","text":"
        • You first need to have an account of account administrator (or you, as a user, already have full privileges to create new users and authorize new user the database objects).

        • Already connected to the MatrixOne cluster.

        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#solution_1","title":"Solution","text":"
        • Requirement 1: The application system requires a new database dedicated to application development.

          • Solution: Create a new database named appdb.
        • Requirement 2: The application system requires a dedicated role.

          • Solution: Create a new database role, named approle, and grant all database privileges to this role.
        • Requirement 3: The application system requires a dedicated person to manage the database.

          • Solution: Create a new database user, named appuser, and authorize the role to this user.
        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#steps_1","title":"Steps","text":""},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#step-1-the-account-administrator-creates-and-authorizes-the-database-user","title":"Step 1: The account administrator creates and authorizes the database user","text":"
        1. Log in to the account with the account administrator:

          Note: The account administrator account account1 here is an example; you can customize it when creating an account administrator.

          mysql -h 127.0.0.1 -P 6001 -u account1:admin:admin -p\n
        2. To create the database required by the application, name the database appdb :

          create database appdb;\n
        3. Create a role named approle and grant this role full privilege to database appdb :

          create role approle;\ngrant all on database appdb to approle;\ngrant all on table appdb.* to approle;\n
        4. Create user appuser with password 123456 and grant the role approle to appuser :

          create user appuser identified by \"123456\" default role approle;\n
        "},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#step-2-use-the-data-user-to-log-in-and-test","title":"Step 2: Use the data user to log in and test","text":"
        1. Log into MatrixOne with the data user appuser:

          mysql -h127.0.0.1 -utest:appuser -P6001 -p123456\n
        2. Verify the privileges of the data user appuser:

          set secondary role all;\nuse appdb;\ncreate table t1(a int);\ninsert into t1 values(1),(2),(3);\nselect * from t1;\ndrop table t1;\n
        3. The above code indicates that the verification is successful.

        "},{"location":"MatrixOne/Security/role-priviledge-management/best-practice/","title":"Best Practices","text":"

        The following are typical roles and recommended minimum permissions in MatrixOne for you to reference.

        "},{"location":"MatrixOne/Security/role-priviledge-management/best-practice/#engineer-responsible-for-database-resource-user-role-permission-management","title":"Engineer responsible for database resource (user, role, permission) management","text":"

        Database Administrator

        • Main job functions: manage all configuration information in the tenant, user permissions, backup and recovery, performance tuning, troubleshooting
        • Reference grant role: the default administrator role accountadmin generated when creating a tenant.
        • Refer to granting permissions: user management (CREATE USER, ALTER USER, DROP USER), authority management (MANAGE GRANTS)
        "},{"location":"MatrixOne/Security/role-priviledge-management/best-practice/#engineer-responsible-for-data-management","title":"Engineer responsible for data management","text":"

        Data Operation and Maintenance Engineer

        • Main job function: manage all data and metadata information in the tenant, and authorize data permissions
        • Refer to Granting Permissions: Tenant-Level Data Management (ALL ON ACCOUNT)

        App Developer

        • Main job function: operate specific databases under the development environment tenant, and have read-only permission from the system tenant
        • Refer to grant permissions: database level data management (ALL ON DATABASE), system database read-only (SELECT ON DATABASE)

        Application System Management Engineer

        • Main job function: operate specific databases under the production environment tenant
        • Refer to Granting Permissions: Data Management at the Database Level (ALL ON DATABASE)

        System Monitoring Engineer

        • Main job function: monitor all system statistics and error messages under the tenant
        • Refer to grant permissions: read-only permissions for all system databases (SELECT ON DATABASE)
        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/","title":"Complete a SSB Test with MatrixOne","text":"

        The Star Schema Benchmark(SSB)Test is a popular scenario for OLAP database performance test. By going through this tutorial, you'll learn how to complete a SSB Test with MatrixOne.

        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#before-you-start","title":"Before you start","text":"

        Make sure you have already Deployed standalone MatrixOne.

        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#1-compile-dbgen","title":"1. Compile dbgen","text":"
        git clone git@github.com:vadimtk/ssb-dbgen.git\ncd ssb-dbgen\nmake\n

        Note

        Compile dbgen on a PC with M1 chip. See Deployment FAQs.

        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#2-generate-data","title":"2. Generate data","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#option-1-generate-the-single-table-dataset","title":"Option 1: Generate the single table dataset","text":"

        With -s 1 dbgen generates 6 million rows (670MB), while while -s 10 it generates 60 million rows (which takes some time)

        ./dbgen -s 1 -T c\n./dbgen -s 1 -T l\n./dbgen -s 1 -T p\n./dbgen -s 1 -T s\n./dbgen -s 1 -T d\n
        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#option-2-download-the-large-wide-table-dataset","title":"Option 2: Download the large wide table dataset","text":"

        We have also prepared a 1GB large wide table dataset for downloading. You can get the data files directly:

        https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/lineorder_flat.tar.bz2\n
        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#3-create-tables-in-matrixone","title":"3. Create tables in MatrixOne","text":"
        create database if not exists ssb;\nuse ssb;\n\ndrop table if exists lineorder;\ndrop table if exists part;\ndrop table if exists supplier;\ndrop table if exists customer;\ndrop table if exists date;\ndrop table if exists lineorder_flat;\n\ncreate table lineorder (\n        lo_orderkey bigint,\n        lo_linenumber int,\n        lo_custkey int,\n        lo_partkey int,\n        lo_suppkey int,\n        lo_orderdate date,\n        lo_orderpriority char (15),\n        lo_shippriority tinyint,\n        lo_quantity double,\n        lo_extendedprice double,\n        lo_ordtotalprice double,\n        lo_discount double,\n        lo_revenue double,\n        lo_supplycost double,\n        lo_tax double,\n        lo_commitdate date,\n        lo_shipmode char (10)\n) ;\n\ncreate table part (\n        p_partkey int,\n        p_name varchar (22),\n        p_mfgr char (6),\n        p_category char (7),\n        p_brand char (9),\n        p_color varchar (11),\n        p_type varchar (25),\n        p_size int,\n        p_container char (10)\n) ;\n\ncreate table supplier (\n        s_suppkey int,\n        s_name char (25),\n        s_address varchar (25),\n        s_city char (10),\n        s_nation char (15),\n        s_region char (12),\n        s_phone char (15)\n) ;\n\ncreate table customer (\n        c_custkey int,\n        c_name varchar (25),\n        c_address varchar (25),\n        c_city char (10),\n        c_nation char (15),\n        c_region char (12),\n        c_phone char (15),\n        c_mktsegment char (10)\n) ;\n\ncreate table date (\n        d_datekey date,\n        d_date char (18),\n        d_dayofweek char (9),\n        d_month char (9),\n        d_year int,\n        d_yearmonthnum int,\n        d_yearmonth char (7),\n        d_daynuminweek varchar(12),\n        d_daynuminmonth int,\n        d_daynuminyear int,\n        d_monthnuminyear int,\n        d_weeknuminyear int,\n        d_sellingseason varchar (12),\n        d_lastdayinweekfl varchar (1),\n        d_lastdayinmonthfl varchar (1),\n        d_holidayfl varchar (1),\n        d_weekdayfl varchar (1)\n) ;\n\nCREATE TABLE lineorder_flat(\n  LO_ORDERKEY bigint key,\n  LO_LINENUMBER int,\n  LO_CUSTKEY int,\n  LO_PARTKEY int,\n  LO_SUPPKEY int,\n  LO_ORDERDATE date,\n  LO_ORDERPRIORITY char(15),\n  LO_SHIPPRIORITY tinyint,\n  LO_QUANTITY double,\n  LO_EXTENDEDPRICE double,\n  LO_ORDTOTALPRICE double,\n  LO_DISCOUNT double,\n  LO_REVENUE int unsigned,\n  LO_SUPPLYCOST int unsigned,\n  LO_TAX double,\n  LO_COMMITDATE date,\n  LO_SHIPMODE char(10),\n  C_NAME varchar(25),\n  C_ADDRESS varchar(25),\n  C_CITY char(10),\n  C_NATION char(15),\n  C_REGION char(12),\n  C_PHONE char(15),\n  C_MKTSEGMENT char(10),\n  S_NAME char(25),\n  S_ADDRESS varchar(25),\n  S_CITY char(10),\n  S_NATION char(15),\n  S_REGION char(12),\n  S_PHONE char(15),\n  P_NAME varchar(22),\n  P_MFGR char(6),\n  P_CATEGORY char(7),\n  P_BRAND char(9),\n  P_COLOR varchar(11),\n  P_TYPE varchar(25),\n  P_SIZE int,\n  P_CONTAINER char(10)\n);\n
        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#4-load-data-into-the-created-tables","title":"4. Load data into the created tables","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#option-1-load-the-sigle-table-dataset-into-related-tables-with-this-command-in-matrixone","title":"Option 1: Load the sigle table dataset into related tables with this command in MatrixOne","text":"
        load data infile '/ssb-dbgen-path/supplier.tbl' into table supplier FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/customer.tbl' into table customer FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/date.tbl' into table date FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/part.tbl' into table part FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/lineorder.tbl' into table lineorder FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n

        Then you can query data in MatrixOne with the created table.

        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#option-2-load-the-large-wide-table-dataset-into-the-lineorder_flat","title":"Option 2: Load the large wide table dataset into the lineorder_flat","text":"
        load data infile '/ssb-dbgen-path/lineorder_flat.tbl' into table lineorder_flat FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#5-run-ssb-queries","title":"5. Run SSB Queries","text":"

        Note

        GROUP BY does not support using the alias name for now.

        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#flat-table-queries","title":"Flat table queries","text":"
        -- Q1.1\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25;\n\n-- Q1.2\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1994 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35;\n\n-- Q1.3\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1994 AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35;\n\n-- Q2.1\nSELECT sum(LO_REVENUE),year(LO_ORDERDATE) AS year,P_BRAND FROM lineorder_flat WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' GROUP BY year(LO_ORDERDATE), P_BRAND ORDER BY year,P_BRAND;\n\n-- Q2.2\nSELECT sum(LO_REVENUE), year(LO_ORDERDATE) AS year, P_BRAND FROM lineorder_flat WHERE P_BRAND BETWEEN 'MFGR#2221' AND 'MFGR#2228' AND S_REGION = 'ASIA' GROUP BY year(LO_ORDERDATE), P_BRAND ORDER BY year, P_BRAND;\n\n-- Q2.3\nSELECT sum(LO_REVENUE), year(LO_ORDERDATE) AS year, P_BRAND FROM lineorder_flat WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' GROUP BY year(LO_ORDERDATE), P_BRAND ORDER BY year, P_BRAND;\n\n-- Q3.1\nSELECT C_NATION, S_NATION, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year(LO_ORDERDATE)  between 1992 AND 1997 GROUP BY C_NATION, S_NATION, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n-- Q3.2\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE C_NATION = 'CHINA' AND S_NATION = 'CHINA' AND year(LO_ORDERDATE)  between 1992 AND 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE)  ORDER BY year asc, revenue desc;\n\n-- Q3.3\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE (C_CITY = 'UNITED KI0' OR C_CITY = 'UNITED KI7') AND (S_CITY = 'UNITED KI0' OR S_CITY = 'UNITED KI7') AND year(LO_ORDERDATE)  between 1992 AND 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n-- Q3.4\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE (C_CITY = 'UNITED KI0' OR C_CITY = 'UNITED KI7') AND (S_CITY = 'MOZAMBIQU1' OR S_CITY = 'KENYA    4') AND year(LO_ORDERDATE)= 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n-- Q4.1\nSELECT year(LO_ORDERDATE) AS year, C_NATION, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') GROUP BY year(LO_ORDERDATE), C_NATION ORDER BY year, C_NATION;\n\n-- Q4.2\nSELECT year(LO_ORDERDATE) AS year, S_NATION, P_CATEGORY, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year(LO_ORDERDATE) = 1997 OR year(LO_ORDERDATE) = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') GROUP BY  year(LO_ORDERDATE), S_NATION, P_CATEGORY ORDER BY year, S_NATION, P_CATEGORY;\n\n-- Q4.3\nSELECT year(LO_ORDERDATE) AS year, S_CITY, P_BRAND, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE S_NATION = 'UNITED STATES' AND (year(LO_ORDERDATE) = 1997 OR year(LO_ORDERDATE) = 1998) AND P_CATEGORY = 'MFGR#14' GROUP BY  year(LO_ORDERDATE), S_CITY, P_BRAND ORDER BY year, S_CITY, P_BRAND;\n
        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#multiple-tables-queries","title":"Multiple tables queries","text":"
        -- Q1.1\nselect sum(lo_revenue) as revenue\nfrom lineorder join date on lo_orderdate = d_datekey\nwhere year(d_datekey)  = 1993 and lo_discount between 1 and 3 and lo_quantity < 25;\n\n-- Q1.2\nselect sum(lo_revenue) as revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\nwhere d_yearmonthnum = 199401\nand lo_discount between 4 and 6\nand lo_quantity between 26 and 35;\n\n-- Q1.3\nselect sum(lo_revenue) as revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\nwhere d_weeknuminyear = 6 and year(d_datekey)  = 1994\nand lo_discount between 5 and 7\nand lo_quantity between 26 and 35;\n\n-- Q2.1\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_category = 'MFGR#12' and s_region = 'AMERICA'\ngroup by year(d_datekey), p_brand\norder by year, p_brand;\n\n-- Q2.2\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_brand between 'MFGR#2221' and 'MFGR#2228' and s_region = 'ASIA'\ngroup by year(d_datekey), p_brand\norder by year, p_brand;\n\n-- Q2.3\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_brand = 'MFGR#2239' and s_region = 'EUROPE'\ngroup by year(d_datekey), p_brand\norder by year, p_brand;\n\n-- Q3.1\nselect c_nation, s_nation, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere c_region = 'ASIA' and s_region = 'ASIA' and year(d_datekey) between 1992 and 1997\ngroup by c_nation, s_nation, year(d_datekey)\norder by year asc, lo_revenue desc;\n\n-- Q3.2\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere c_nation = 'UNITED STATES' and s_nation = 'UNITED STATES'\nand year(d_datekey) between 1992 and 1997\ngroup by c_city, s_city, year(d_datekey)\norder by year asc, lo_revenue desc;\n\n-- Q3.3\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere (c_city='UNITED KI1' or c_city='UNITED KI5')\nand (s_city='UNITED KI1' or s_city='UNITED KI5')\nand year(d_datekey) between 1992 and 1997\ngroup by c_city, s_city, year(d_datekey)\norder by year asc, lo_revenue desc;\n\n-- Q3.4\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere (c_city='UNITED KI1' or c_city='UNITED KI5') and (s_city='UNITED KI1' or s_city='UNITED KI5') and d_yearmonth = '199712'\ngroup by c_city, s_city, year(d_datekey)\norder by year(d_datekey) asc, lo_revenue desc;\n\n-- Q4.1\nselect year(d_datekey) as year, c_nation, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere c_region = 'AMERICA' and s_region = 'AMERICA' and (p_mfgr = 'MFGR#1' or p_mfgr = 'MFGR#2')\ngroup by year(d_datekey), c_nation\norder by year, c_nation;\n\n-- Q4.2\nselect year(d_datekey) as year, s_nation, p_category, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere c_region = 'AMERICA'and s_region = 'AMERICA'\nand (year(d_datekey) = 1997 or year(d_datekey) = 1998)\nand (p_mfgr = 'MFGR#1' or p_mfgr = 'MFGR#2')\ngroup by year(d_datekey), s_nation, p_category\norder by year, s_nation, p_category;\n\n-- Q4.3\nselect year(d_datekey) as year, s_city, p_brand, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin dates on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere\n(year(d_datekey) = 1997 or year(d_datekey) = 1998)\nand c_region = 'AMERICA'\nand s_nation = 'UNITED STATES'\nand p_category = 'MFGR#14'\ngroup by year, s_city, p_brand\norder by year, s_city, p_brand;\n
        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#6-expected-results","title":"6. Expected Results","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#flat-table-queries-expected-results","title":"Flat table queries expected results","text":"
        -- Q1.1\n+--------------+\n| revenue      |\n+--------------+\n| 702223464659 |\n+--------------+\n\n-- Q1.2\n+---------------+\n| revenue       |\n+---------------+\n| 1842875090496 |\n+---------------+\n\n-- Q1.3\n+---------------+\n| revenue       |\n+---------------+\n| 2208738861324 |\n+---------------+\n\n-- Q2.1\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand   |\n+-----------------+------+-----------+\n|       283684289 | 1992 | MFGR#121  |\n|      1344702529 | 1992 | MFGR#1210 |\n|       757158682 | 1992 | MFGR#1211 |\n|      1156022815 | 1992 | MFGR#1212 |\n|       676164367 | 1992 | MFGR#1213 |\n|       522779256 | 1992 | MFGR#1214 |\n|       233507213 | 1992 | MFGR#1215 |\n|       726755819 | 1992 | MFGR#1216 |\n|      1865504710 | 1992 | MFGR#1217 |\n|       685600451 | 1992 | MFGR#1218 |\n|       814671470 | 1992 | MFGR#1219 |\n|       655405800 | 1992 | MFGR#122  |\n|       962120553 | 1992 | MFGR#1220 |\n|       961393626 | 1992 | MFGR#1221 |\n|       922110830 | 1992 | MFGR#1222 |\n|       814842712 | 1992 | MFGR#1223 |\n|      1402773165 | 1992 | MFGR#1224 |\n|       977517439 | 1992 | MFGR#1225 |\n|      1392114944 | 1992 | MFGR#1226 |\n|       658922951 | 1992 | MFGR#1227 |\n|       892495927 | 1992 | MFGR#1228 |\n|       806609100 | 1992 | MFGR#1229 |\n|       578875657 | 1992 | MFGR#123  |\n|       691236902 | 1992 | MFGR#1230 |\n|       482715249 | 1992 | MFGR#1231 |\n|       618556590 | 1992 | MFGR#1232 |\n|       981657009 | 1992 | MFGR#1233 |\n|      1050794669 | 1992 | MFGR#1234 |\n|      1335217991 | 1992 | MFGR#1235 |\n|       686009527 | 1992 | MFGR#1236 |\n|       605242584 | 1992 | MFGR#1237 |\n|       430455641 | 1992 | MFGR#1238 |\n|       359654993 | 1992 | MFGR#1239 |\n|       818818457 | 1992 | MFGR#124  |\n|      1388502581 | 1992 | MFGR#1240 |\n|       711566198 | 1992 | MFGR#125  |\n|       893045647 | 1992 | MFGR#126  |\n|      1240534333 | 1992 | MFGR#127  |\n|       871966127 | 1992 | MFGR#128  |\n|       719176622 | 1992 | MFGR#129  |\n|       245880758 | 1993 | MFGR#121  |\n|      1480662753 | 1993 | MFGR#1210 |\n|       982292725 | 1993 | MFGR#1211 |\n|      1001136766 | 1993 | MFGR#1212 |\n|       227144072 | 1993 | MFGR#1213 |\n|       291611370 | 1993 | MFGR#1214 |\n|       454576668 | 1993 | MFGR#1215 |\n|       772027256 | 1993 | MFGR#1216 |\n|      1155751851 | 1993 | MFGR#1217 |\n|       897883050 | 1993 | MFGR#1218 |\n|      1209508962 | 1993 | MFGR#1219 |\n|       530577973 | 1993 | MFGR#122  |\n|       901650471 | 1993 | MFGR#1220 |\n|       739540494 | 1993 | MFGR#1221 |\n|       698751459 | 1993 | MFGR#1222 |\n|      1327979157 | 1993 | MFGR#1223 |\n|      1476697469 | 1993 | MFGR#1224 |\n|       792103134 | 1993 | MFGR#1225 |\n|      1420277376 | 1993 | MFGR#1226 |\n|      1446032835 | 1993 | MFGR#1227 |\n|       884375309 | 1993 | MFGR#1228 |\n|       522705868 | 1993 | MFGR#1229 |\n|       601685233 | 1993 | MFGR#123  |\n|       806727248 | 1993 | MFGR#1230 |\n|       399477390 | 1993 | MFGR#1231 |\n|       894047578 | 1993 | MFGR#1232 |\n|       496067089 | 1993 | MFGR#1233 |\n|      1050223756 | 1993 | MFGR#1234 |\n|       891681399 | 1993 | MFGR#1235 |\n|      1402903631 | 1993 | MFGR#1236 |\n|       347380448 | 1993 | MFGR#1237 |\n|       514853194 | 1993 | MFGR#1238 |\n|       410543863 | 1993 | MFGR#1239 |\n|       673483594 | 1993 | MFGR#124  |\n|       713343630 | 1993 | MFGR#1240 |\n|       512610707 | 1993 | MFGR#125  |\n|      1228110634 | 1993 | MFGR#126  |\n|       936958961 | 1993 | MFGR#127  |\n|       579067515 | 1993 | MFGR#128  |\n|       636174833 | 1993 | MFGR#129  |\n|       370347074 | 1994 | MFGR#121  |\n|       483900410 | 1994 | MFGR#1210 |\n|      1240306281 | 1994 | MFGR#1211 |\n|      1003345253 | 1994 | MFGR#1212 |\n|       557310864 | 1994 | MFGR#1213 |\n|       314972328 | 1994 | MFGR#1214 |\n|      1130260810 | 1994 | MFGR#1215 |\n|       401618319 | 1994 | MFGR#1216 |\n|       652173601 | 1994 | MFGR#1217 |\n|       923612074 | 1994 | MFGR#1218 |\n|       469711377 | 1994 | MFGR#1219 |\n|       580152115 | 1994 | MFGR#122  |\n|       433134653 | 1994 | MFGR#1220 |\n|       730569849 | 1994 | MFGR#1221 |\n|       607609104 | 1994 | MFGR#1222 |\n|       949877669 | 1994 | MFGR#1223 |\n|      1644687916 | 1994 | MFGR#1224 |\n|       492974194 | 1994 | MFGR#1225 |\n|       921499688 | 1994 | MFGR#1226 |\n|       719059761 | 1994 | MFGR#1227 |\n|      1000497056 | 1994 | MFGR#1228 |\n|       486968927 | 1994 | MFGR#1229 |\n|       734124906 | 1994 | MFGR#123  |\n|       645016873 | 1994 | MFGR#1230 |\n|       526638240 | 1994 | MFGR#1231 |\n|      1358112405 | 1994 | MFGR#1232 |\n|      1167074905 | 1994 | MFGR#1233 |\n|      1102915239 | 1994 | MFGR#1234 |\n|       693058125 | 1994 | MFGR#1235 |\n|      1673392892 | 1994 | MFGR#1236 |\n|       849630029 | 1994 | MFGR#1237 |\n|       721392705 | 1994 | MFGR#1238 |\n|      1237195774 | 1994 | MFGR#1239 |\n|      1107832795 | 1994 | MFGR#124  |\n|       827906290 | 1994 | MFGR#1240 |\n|       682827304 | 1994 | MFGR#125  |\n|      1198768141 | 1994 | MFGR#126  |\n|      1274148181 | 1994 | MFGR#127  |\n|       738849138 | 1994 | MFGR#128  |\n|       751136619 | 1994 | MFGR#129  |\n|       318978803 | 1995 | MFGR#121  |\n|       383199448 | 1995 | MFGR#1210 |\n|      1300165814 | 1995 | MFGR#1211 |\n|      1550400731 | 1995 | MFGR#1212 |\n|       451958158 | 1995 | MFGR#1213 |\n|       431434279 | 1995 | MFGR#1214 |\n|       713735582 | 1995 | MFGR#1215 |\n|       919323722 | 1995 | MFGR#1216 |\n|      1542358864 | 1995 | MFGR#1217 |\n|       500930092 | 1995 | MFGR#1218 |\n|      1208162086 | 1995 | MFGR#1219 |\n|       785707989 | 1995 | MFGR#122  |\n|       993828211 | 1995 | MFGR#1220 |\n|       667253893 | 1995 | MFGR#1221 |\n|      1654114297 | 1995 | MFGR#1222 |\n|       986528377 | 1995 | MFGR#1223 |\n|       755014642 | 1995 | MFGR#1224 |\n|      1090300100 | 1995 | MFGR#1225 |\n|      1063626454 | 1995 | MFGR#1226 |\n|      1382528859 | 1995 | MFGR#1227 |\n|       919953351 | 1995 | MFGR#1228 |\n|       457795295 | 1995 | MFGR#1229 |\n|       953851827 | 1995 | MFGR#123  |\n|       807209283 | 1995 | MFGR#1230 |\n|       236304454 | 1995 | MFGR#1231 |\n|       668449537 | 1995 | MFGR#1232 |\n|       240657083 | 1995 | MFGR#1233 |\n|       920389826 | 1995 | MFGR#1234 |\n|       684096065 | 1995 | MFGR#1235 |\n|      1005844219 | 1995 | MFGR#1236 |\n|       626170996 | 1995 | MFGR#1237 |\n|       984581826 | 1995 | MFGR#1238 |\n|       602850634 | 1995 | MFGR#1239 |\n|      1172025628 | 1995 | MFGR#124  |\n|       489788581 | 1995 | MFGR#1240 |\n|       643100327 | 1995 | MFGR#125  |\n|       894596661 | 1995 | MFGR#126  |\n|       706917239 | 1995 | MFGR#127  |\n|       428671983 | 1995 | MFGR#128  |\n|       971611472 | 1995 | MFGR#129  |\n|       306497573 | 1996 | MFGR#121  |\n|       890719726 | 1996 | MFGR#1210 |\n|      1761977172 | 1996 | MFGR#1211 |\n|       633845765 | 1996 | MFGR#1212 |\n|       475801202 | 1996 | MFGR#1213 |\n|       271930385 | 1996 | MFGR#1214 |\n|       366399844 | 1996 | MFGR#1215 |\n|       877472476 | 1996 | MFGR#1216 |\n|       970366290 | 1996 | MFGR#1217 |\n|       537175690 | 1996 | MFGR#1218 |\n|       956970528 | 1996 | MFGR#1219 |\n|       711962074 | 1996 | MFGR#122  |\n|      1062161683 | 1996 | MFGR#1220 |\n|       406293744 | 1996 | MFGR#1221 |\n|       785404335 | 1996 | MFGR#1222 |\n|       579267044 | 1996 | MFGR#1223 |\n|      1220640256 | 1996 | MFGR#1224 |\n|       490130196 | 1996 | MFGR#1225 |\n|      1603805636 | 1996 | MFGR#1226 |\n|      1530646510 | 1996 | MFGR#1227 |\n|      1093328922 | 1996 | MFGR#1228 |\n|       596520140 | 1996 | MFGR#1229 |\n|       450815571 | 1996 | MFGR#123  |\n|       315053350 | 1996 | MFGR#1230 |\n|       198951017 | 1996 | MFGR#1231 |\n|       579778438 | 1996 | MFGR#1232 |\n|       480905486 | 1996 | MFGR#1233 |\n|      1433336215 | 1996 | MFGR#1234 |\n|       560925251 | 1996 | MFGR#1235 |\n|      1038766181 | 1996 | MFGR#1236 |\n|       783697960 | 1996 | MFGR#1237 |\n|       972656445 | 1996 | MFGR#1238 |\n|       614528801 | 1996 | MFGR#1239 |\n|      1418931894 | 1996 | MFGR#124  |\n|       995139591 | 1996 | MFGR#1240 |\n|       824028471 | 1996 | MFGR#125  |\n|       669475113 | 1996 | MFGR#126  |\n|       831704651 | 1996 | MFGR#127  |\n|       920514555 | 1996 | MFGR#128  |\n|       436162421 | 1996 | MFGR#129  |\n|       553684594 | 1997 | MFGR#121  |\n|      1317368046 | 1997 | MFGR#1210 |\n|      1617056983 | 1997 | MFGR#1211 |\n|      1196031005 | 1997 | MFGR#1212 |\n|      1056458336 | 1997 | MFGR#1213 |\n|       352179650 | 1997 | MFGR#1214 |\n|       511058114 | 1997 | MFGR#1215 |\n|       658259312 | 1997 | MFGR#1216 |\n|      1238450697 | 1997 | MFGR#1217 |\n|       376245955 | 1997 | MFGR#1218 |\n|       913437812 | 1997 | MFGR#1219 |\n|      1114996000 | 1997 | MFGR#122  |\n|       814059433 | 1997 | MFGR#1220 |\n|       817328516 | 1997 | MFGR#1221 |\n|       541428597 | 1997 | MFGR#1222 |\n|      1260539052 | 1997 | MFGR#1223 |\n|      1766426582 | 1997 | MFGR#1224 |\n|      1221271245 | 1997 | MFGR#1225 |\n|      1499152922 | 1997 | MFGR#1226 |\n|       491586909 | 1997 | MFGR#1227 |\n|       911517084 | 1997 | MFGR#1228 |\n|       728186585 | 1997 | MFGR#1229 |\n|       904363416 | 1997 | MFGR#123  |\n|       605369014 | 1997 | MFGR#1230 |\n|       290370455 | 1997 | MFGR#1231 |\n|       602414397 | 1997 | MFGR#1232 |\n|       765339065 | 1997 | MFGR#1233 |\n|      1170973957 | 1997 | MFGR#1234 |\n|       860319765 | 1997 | MFGR#1235 |\n|      1031080311 | 1997 | MFGR#1236 |\n|       736404810 | 1997 | MFGR#1237 |\n|      1012330790 | 1997 | MFGR#1238 |\n|       681055343 | 1997 | MFGR#1239 |\n|       601626600 | 1997 | MFGR#124  |\n|       920404157 | 1997 | MFGR#1240 |\n|      1007678757 | 1997 | MFGR#125  |\n|       622347203 | 1997 | MFGR#126  |\n|      1215295592 | 1997 | MFGR#127  |\n|       822274972 | 1997 | MFGR#128  |\n|       643903475 | 1997 | MFGR#129  |\n|       470008435 | 1998 | MFGR#121  |\n|       568508492 | 1998 | MFGR#1210 |\n|       323759101 | 1998 | MFGR#1211 |\n|       572013331 | 1998 | MFGR#1212 |\n|       448137748 | 1998 | MFGR#1213 |\n|       137422458 | 1998 | MFGR#1214 |\n|       346491756 | 1998 | MFGR#1215 |\n|       454542243 | 1998 | MFGR#1216 |\n|       759205210 | 1998 | MFGR#1217 |\n|       674544462 | 1998 | MFGR#1218 |\n|       735952270 | 1998 | MFGR#1219 |\n|       490186568 | 1998 | MFGR#122  |\n|       769456686 | 1998 | MFGR#1220 |\n|       654540341 | 1998 | MFGR#1221 |\n|       800329859 | 1998 | MFGR#1222 |\n|       263849231 | 1998 | MFGR#1223 |\n|       445461642 | 1998 | MFGR#1224 |\n|       387808862 | 1998 | MFGR#1225 |\n|       675424382 | 1998 | MFGR#1226 |\n|       265906673 | 1998 | MFGR#1227 |\n|       585938371 | 1998 | MFGR#1228 |\n|       683188537 | 1998 | MFGR#1229 |\n|       304403717 | 1998 | MFGR#123  |\n|       533781674 | 1998 | MFGR#1230 |\n|       304060011 | 1998 | MFGR#1231 |\n|       635275907 | 1998 | MFGR#1232 |\n|       658295080 | 1998 | MFGR#1233 |\n|       524133341 | 1998 | MFGR#1234 |\n|       363911877 | 1998 | MFGR#1235 |\n|       300885635 | 1998 | MFGR#1236 |\n|       532608453 | 1998 | MFGR#1237 |\n|       484291410 | 1998 | MFGR#1238 |\n|       445336624 | 1998 | MFGR#1239 |\n|       719027801 | 1998 | MFGR#124  |\n|       518860961 | 1998 | MFGR#1240 |\n|       491235383 | 1998 | MFGR#125  |\n|       520917638 | 1998 | MFGR#126  |\n|      1158787745 | 1998 | MFGR#127  |\n|       401190922 | 1998 | MFGR#128  |\n|       406656337 | 1998 | MFGR#129  |\n+-----------------+------+-----------+\n\n-- Q2.2\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand   |\n+-----------------+------+-----------+\n|      1259802358 | 1992 | MFGR#2221 |\n|      1728549344 | 1992 | MFGR#2222 |\n|      1375260024 | 1992 | MFGR#2223 |\n|      1299982475 | 1992 | MFGR#2224 |\n|      1541960331 | 1992 | MFGR#2225 |\n|      1151853513 | 1992 | MFGR#2226 |\n|      1271175264 | 1992 | MFGR#2227 |\n|      1726441695 | 1992 | MFGR#2228 |\n|      1251460032 | 1993 | MFGR#2221 |\n|      1331062515 | 1993 | MFGR#2222 |\n|       902809293 | 1993 | MFGR#2223 |\n|       980512417 | 1993 | MFGR#2224 |\n|      1253088003 | 1993 | MFGR#2225 |\n|       959195148 | 1993 | MFGR#2226 |\n|       555593932 | 1993 | MFGR#2227 |\n|      2186479174 | 1993 | MFGR#2228 |\n|      1094092222 | 1994 | MFGR#2221 |\n|      1491699323 | 1994 | MFGR#2222 |\n|      1501160826 | 1994 | MFGR#2223 |\n|      1387107418 | 1994 | MFGR#2224 |\n|      1641588884 | 1994 | MFGR#2225 |\n|      1387296390 | 1994 | MFGR#2226 |\n|      1038341470 | 1994 | MFGR#2227 |\n|      1565763138 | 1994 | MFGR#2228 |\n|      1412945650 | 1995 | MFGR#2221 |\n|      1546178356 | 1995 | MFGR#2222 |\n|      1218352073 | 1995 | MFGR#2223 |\n|      1052197762 | 1995 | MFGR#2224 |\n|      1822921900 | 1995 | MFGR#2225 |\n|       728142181 | 1995 | MFGR#2226 |\n|       966131607 | 1995 | MFGR#2227 |\n|      1379320517 | 1995 | MFGR#2228 |\n|      1042767284 | 1996 | MFGR#2221 |\n|       994733835 | 1996 | MFGR#2222 |\n|      1615788545 | 1996 | MFGR#2223 |\n|      1113980216 | 1996 | MFGR#2224 |\n|      1622570253 | 1996 | MFGR#2225 |\n|      1540226758 | 1996 | MFGR#2226 |\n|      1115687883 | 1996 | MFGR#2227 |\n|      1716355343 | 1996 | MFGR#2228 |\n|       867705636 | 1997 | MFGR#2221 |\n|      1529877498 | 1997 | MFGR#2222 |\n|      1594444450 | 1997 | MFGR#2223 |\n|       587421043 | 1997 | MFGR#2224 |\n|      1112274470 | 1997 | MFGR#2225 |\n|      1327884722 | 1997 | MFGR#2226 |\n|       884180880 | 1997 | MFGR#2227 |\n|      1664207656 | 1997 | MFGR#2228 |\n|       827743515 | 1998 | MFGR#2221 |\n|       662242310 | 1998 | MFGR#2222 |\n|       861445539 | 1998 | MFGR#2223 |\n|       694538672 | 1998 | MFGR#2224 |\n|       675179021 | 1998 | MFGR#2225 |\n|       480728720 | 1998 | MFGR#2226 |\n|       643763072 | 1998 | MFGR#2227 |\n|       994499201 | 1998 | MFGR#2228 |\n+-----------------+------+-----------+\n\n-- Q2.3\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand   |\n+-----------------+------+-----------+\n|      1428843284 | 1992 | MFGR#2239 |\n|      1865666054 | 1993 | MFGR#2239 |\n|      2242753254 | 1994 | MFGR#2239 |\n|      1446677305 | 1995 | MFGR#2239 |\n|       921681503 | 1996 | MFGR#2239 |\n|      1549990572 | 1997 | MFGR#2239 |\n|       926327433 | 1998 | MFGR#2239 |\n+-----------------+------+-----------+\n\n-- Q3.1\n+-----------+-----------+------+-------------+\n| c_nation  | s_nation  | year | revenue     |\n+-----------+-----------+------+-------------+\n| VIETNAM   | CHINA     | 1992 | 17194479086 |\n| JAPAN     | CHINA     | 1992 | 15572594510 |\n| JAPAN     | JAPAN     | 1992 | 13861682954 |\n| INDONESIA | CHINA     | 1992 | 13499663933 |\n| VIETNAM   | INDONESIA | 1992 | 13163103649 |\n| JAPAN     | INDONESIA | 1992 | 13035158590 |\n| INDIA     | CHINA     | 1992 | 12987688902 |\n| INDONESIA | JAPAN     | 1992 | 12939737918 |\n| VIETNAM   | JAPAN     | 1992 | 12174715858 |\n| JAPAN     | VIETNAM   | 1992 | 11669093753 |\n| INDIA     | INDONESIA | 1992 | 11452602145 |\n| INDONESIA | INDONESIA | 1992 | 10394407561 |\n| INDIA     | JAPAN     | 1992 | 10313084900 |\n| JAPAN     | INDIA     | 1992 | 10035511089 |\n| CHINA     | CHINA     | 1992 |  9828744666 |\n| VIETNAM   | VIETNAM   | 1992 |  9701522505 |\n| INDONESIA | INDIA     | 1992 |  9271105764 |\n| INDIA     | INDIA     | 1992 |  8879645522 |\n| CHINA     | INDONESIA | 1992 |  8373693838 |\n| CHINA     | JAPAN     | 1992 |  8051248951 |\n| VIETNAM   | INDIA     | 1992 |  7804539029 |\n| INDONESIA | VIETNAM   | 1992 |  7615465790 |\n| CHINA     | INDIA     | 1992 |  7344868842 |\n| INDIA     | VIETNAM   | 1992 |  6830508508 |\n| CHINA     | VIETNAM   | 1992 |  6529888238 |\n| JAPAN     | CHINA     | 1993 | 18839180326 |\n| VIETNAM   | CHINA     | 1993 | 14761890330 |\n| JAPAN     | INDONESIA | 1993 | 13648082171 |\n| INDONESIA | CHINA     | 1993 | 13518181805 |\n| INDIA     | CHINA     | 1993 | 13249555999 |\n| JAPAN     | JAPAN     | 1993 | 12667833152 |\n| JAPAN     | VIETNAM   | 1993 | 11529854580 |\n| CHINA     | CHINA     | 1993 | 11216468573 |\n| INDONESIA | INDONESIA | 1993 | 10953284722 |\n| VIETNAM   | INDONESIA | 1993 | 10582912267 |\n| INDIA     | JAPAN     | 1993 | 10482950584 |\n| VIETNAM   | JAPAN     | 1993 | 10370811002 |\n| INDIA     | INDONESIA | 1993 | 10145286112 |\n| INDONESIA | JAPAN     | 1993 |  9850020303 |\n| VIETNAM   | VIETNAM   | 1993 |  9591468153 |\n| CHINA     | INDONESIA | 1993 |  9015864524 |\n| CHINA     | JAPAN     | 1993 |  8972996729 |\n| INDONESIA | INDIA     | 1993 |  8903638786 |\n| JAPAN     | INDIA     | 1993 |  8848048514 |\n| INDONESIA | VIETNAM   | 1993 |  8024464882 |\n| VIETNAM   | INDIA     | 1993 |  7806575746 |\n| INDIA     | VIETNAM   | 1993 |  7537331106 |\n| INDIA     | INDIA     | 1993 |  7211053846 |\n| CHINA     | VIETNAM   | 1993 |  6700022269 |\n| CHINA     | INDIA     | 1993 |  6327331541 |\n| JAPAN     | CHINA     | 1994 | 15661051644 |\n| VIETNAM   | CHINA     | 1994 | 13958591931 |\n| JAPAN     | JAPAN     | 1994 | 13566252348 |\n| CHINA     | CHINA     | 1994 | 12870010072 |\n| VIETNAM   | JAPAN     | 1994 | 12728320716 |\n| INDONESIA | CHINA     | 1994 | 12295790872 |\n| INDIA     | CHINA     | 1994 | 12166419121 |\n| JAPAN     | INDONESIA | 1994 | 11358955025 |\n| INDIA     | INDONESIA | 1994 | 11111248365 |\n| JAPAN     | INDIA     | 1994 | 10078806371 |\n| VIETNAM   | INDONESIA | 1994 |  9923852578 |\n| INDIA     | JAPAN     | 1994 |  9839136767 |\n| CHINA     | JAPAN     | 1994 |  9836586308 |\n| INDONESIA | JAPAN     | 1994 |  9786694572 |\n| INDIA     | VIETNAM   | 1994 |  9551081406 |\n| JAPAN     | VIETNAM   | 1994 |  9035431932 |\n| VIETNAM   | INDIA     | 1994 |  9032319402 |\n| INDONESIA | INDONESIA | 1994 |  8876012426 |\n| CHINA     | INDONESIA | 1994 |  8375581981 |\n| VIETNAM   | VIETNAM   | 1994 |  8095638136 |\n| INDONESIA | INDIA     | 1994 |  7943993512 |\n| INDONESIA | VIETNAM   | 1994 |  7927236697 |\n| INDIA     | INDIA     | 1994 |  7534915457 |\n| CHINA     | VIETNAM   | 1994 |  6062387221 |\n| CHINA     | INDIA     | 1994 |  5816794324 |\n| VIETNAM   | CHINA     | 1995 | 15128423080 |\n| INDONESIA | CHINA     | 1995 | 14794647970 |\n| INDIA     | CHINA     | 1995 | 14724240804 |\n| JAPAN     | CHINA     | 1995 | 14579848516 |\n| CHINA     | CHINA     | 1995 | 14296657586 |\n| INDIA     | JAPAN     | 1995 | 13511381754 |\n| JAPAN     | JAPAN     | 1995 | 12015968288 |\n| VIETNAM   | INDONESIA | 1995 | 11290647784 |\n| JAPAN     | INDONESIA | 1995 | 10968840402 |\n| INDIA     | INDONESIA | 1995 | 10879296370 |\n| CHINA     | INDONESIA | 1995 | 10611767914 |\n| VIETNAM   | JAPAN     | 1995 | 10493043807 |\n| INDONESIA | INDONESIA | 1995 | 10350165199 |\n| VIETNAM   | INDIA     | 1995 | 10147175135 |\n| CHINA     | JAPAN     | 1995 |  9967113498 |\n| JAPAN     | VIETNAM   | 1995 |  9871240910 |\n| INDONESIA | JAPAN     | 1995 |  9554798320 |\n| JAPAN     | INDIA     | 1995 |  9224478715 |\n| INDIA     | INDIA     | 1995 |  8880501531 |\n| VIETNAM   | VIETNAM   | 1995 |  8530802028 |\n| INDIA     | VIETNAM   | 1995 |  8470249830 |\n| CHINA     | INDIA     | 1995 |  8460557790 |\n| INDONESIA | VIETNAM   | 1995 |  8393411088 |\n| CHINA     | VIETNAM   | 1995 |  7838238263 |\n| INDONESIA | INDIA     | 1995 |  7001659338 |\n| JAPAN     | CHINA     | 1996 | 14974943391 |\n| INDIA     | CHINA     | 1996 | 14236197987 |\n| VIETNAM   | CHINA     | 1996 | 13723231674 |\n| JAPAN     | INDONESIA | 1996 | 13304501801 |\n| INDONESIA | CHINA     | 1996 | 12444022202 |\n| CHINA     | CHINA     | 1996 | 12120893189 |\n| INDIA     | JAPAN     | 1996 | 11649117519 |\n| INDONESIA | JAPAN     | 1996 | 11345350775 |\n| VIETNAM   | JAPAN     | 1996 | 11294284203 |\n| INDONESIA | INDONESIA | 1996 | 11111201530 |\n| JAPAN     | INDIA     | 1996 | 10871364136 |\n| JAPAN     | JAPAN     | 1996 | 10836947449 |\n| INDIA     | INDONESIA | 1996 | 10568008435 |\n| JAPAN     | VIETNAM   | 1996 | 10503890555 |\n| VIETNAM   | INDONESIA | 1996 | 10494783196 |\n| INDONESIA | VIETNAM   | 1996 |  9940440124 |\n| INDONESIA | INDIA     | 1996 |  9864980677 |\n| VIETNAM   | VIETNAM   | 1996 |  9560258720 |\n| INDIA     | VIETNAM   | 1996 |  9324764214 |\n| INDIA     | INDIA     | 1996 |  9023346020 |\n| VIETNAM   | INDIA     | 1996 |  8968179949 |\n| CHINA     | INDONESIA | 1996 |  8877441837 |\n| CHINA     | JAPAN     | 1996 |  8749420872 |\n| CHINA     | VIETNAM   | 1996 |  6973983457 |\n| CHINA     | INDIA     | 1996 |  6515658476 |\n| JAPAN     | CHINA     | 1997 | 15365039212 |\n| INDONESIA | CHINA     | 1997 | 14159930904 |\n| VIETNAM   | CHINA     | 1997 | 13678288757 |\n| INDIA     | CHINA     | 1997 | 13599028484 |\n| JAPAN     | JAPAN     | 1997 | 12921870544 |\n| CHINA     | CHINA     | 1997 | 12720975220 |\n| VIETNAM   | JAPAN     | 1997 | 11929000810 |\n| VIETNAM   | INDONESIA | 1997 | 11325447090 |\n| JAPAN     | INDONESIA | 1997 | 10764312416 |\n| INDONESIA | JAPAN     | 1997 | 10555558162 |\n| INDONESIA | INDONESIA | 1997 | 10416928126 |\n| CHINA     | INDONESIA | 1997 | 10317902565 |\n| INDIA     | JAPAN     | 1997 | 10272590051 |\n| JAPAN     | VIETNAM   | 1997 |  9940032294 |\n| CHINA     | JAPAN     | 1997 |  9519485461 |\n| JAPAN     | INDIA     | 1997 |  9465935835 |\n| INDIA     | INDONESIA | 1997 |  9405085270 |\n| INDONESIA | INDIA     | 1997 |  8930955270 |\n| INDIA     | INDIA     | 1997 |  8295504178 |\n| VIETNAM   | VIETNAM   | 1997 |  8293412532 |\n| INDONESIA | VIETNAM   | 1997 |  8116443059 |\n| INDIA     | VIETNAM   | 1997 |  7960292262 |\n| VIETNAM   | INDIA     | 1997 |  7529455873 |\n| CHINA     | VIETNAM   | 1997 |  7038413355 |\n| CHINA     | INDIA     | 1997 |  6530770558 |\n+-----------+-----------+------+-------------+\n\n-- Q3.2\n\n+------------+------------+------+-----------+\n| c_city     | s_city     | year | revenue   |\n+------------+------------+------+-----------+\n| CHINA    3 | CHINA    0 | 1992 | 539864249 |\n| CHINA    0 | CHINA    6 | 1992 | 471363128 |\n| CHINA    8 | CHINA    1 | 1992 | 421384110 |\n| CHINA    6 | CHINA    1 | 1992 | 382204882 |\n| CHINA    6 | CHINA    7 | 1992 | 355755835 |\n| CHINA    8 | CHINA    9 | 1992 | 349006417 |\n| CHINA    7 | CHINA    7 | 1992 | 320232842 |\n| CHINA    8 | CHINA    3 | 1992 | 296105733 |\n| CHINA    5 | CHINA    3 | 1992 | 277283951 |\n| CHINA    6 | CHINA    6 | 1992 | 265527771 |\n| CHINA    4 | CHINA    1 | 1992 | 237402078 |\n| CHINA    8 | CHINA    6 | 1992 | 234720401 |\n| CHINA    4 | CHINA    6 | 1992 | 230169075 |\n| CHINA    9 | CHINA    1 | 1992 | 223815249 |\n| CHINA    1 | CHINA    1 | 1992 | 223467947 |\n| CHINA    2 | CHINA    1 | 1992 | 219559691 |\n| CHINA    9 | CHINA    6 | 1992 | 205915890 |\n| CHINA    7 | CHINA    9 | 1992 | 201288909 |\n| CHINA    1 | CHINA    6 | 1992 | 195622902 |\n| CHINA    9 | CHINA    7 | 1992 | 190345063 |\n| CHINA    8 | CHINA    4 | 1992 | 174478626 |\n| CHINA    1 | CHINA    7 | 1992 | 173803257 |\n| CHINA    9 | CHINA    9 | 1992 | 162458028 |\n| CHINA    6 | CHINA    0 | 1992 | 154260702 |\n| CHINA    8 | CHINA    0 | 1992 | 149794069 |\n| CHINA    5 | CHINA    9 | 1992 | 149369922 |\n| CHINA    8 | CHINA    8 | 1992 | 147607252 |\n| CHINA    6 | CHINA    4 | 1992 | 147137516 |\n| CHINA    7 | CHINA    8 | 1992 | 139974858 |\n| CHINA    5 | CHINA    6 | 1992 | 138467127 |\n| CHINA    3 | CHINA    6 | 1992 | 119521008 |\n| CHINA    8 | CHINA    7 | 1992 | 109887269 |\n| CHINA    6 | CHINA    3 | 1992 | 107201214 |\n| CHINA    9 | CHINA    4 | 1992 | 101504450 |\n| CHINA    1 | CHINA    3 | 1992 | 101388208 |\n| CHINA    7 | CHINA    0 | 1992 |  98475237 |\n| CHINA    5 | CHINA    8 | 1992 |  98370738 |\n| CHINA    2 | CHINA    6 | 1992 |  93254616 |\n| CHINA    2 | CHINA    4 | 1992 |  86394644 |\n| CHINA    3 | CHINA    7 | 1992 |  81027008 |\n| CHINA    5 | CHINA    4 | 1992 |  78587418 |\n| CHINA    3 | CHINA    9 | 1992 |  78114762 |\n| CHINA    2 | CHINA    0 | 1992 |  77786892 |\n| CHINA    2 | CHINA    8 | 1992 |  75605732 |\n| CHINA    4 | CHINA    3 | 1992 |  75101512 |\n| CHINA    7 | CHINA    4 | 1992 |  74119240 |\n| CHINA    2 | CHINA    9 | 1992 |  73413108 |\n| CHINA    5 | CHINA    7 | 1992 |  73199718 |\n| CHINA    4 | CHINA    4 | 1992 |  72839118 |\n| CHINA    1 | CHINA    9 | 1992 |  68538220 |\n| CHINA    0 | CHINA    8 | 1992 |  65856888 |\n| CHINA    0 | CHINA    9 | 1992 |  65590624 |\n| CHINA    3 | CHINA    8 | 1992 |  64556586 |\n| CHINA    2 | CHINA    7 | 1992 |  63336330 |\n| CHINA    4 | CHINA    9 | 1992 |  57645963 |\n| CHINA    0 | CHINA    7 | 1992 |  55251918 |\n| CHINA    0 | CHINA    1 | 1992 |  51774462 |\n| CHINA    6 | CHINA    8 | 1992 |  45676858 |\n| CHINA    3 | CHINA    3 | 1992 |  41147560 |\n| CHINA    3 | CHINA    4 | 1992 |  36838082 |\n| CHINA    5 | CHINA    0 | 1992 |  36554488 |\n| CHINA    3 | CHINA    1 | 1992 |  32036313 |\n| CHINA    4 | CHINA    8 | 1992 |  31517575 |\n| CHINA    0 | CHINA    3 | 1992 |  25524054 |\n| CHINA    1 | CHINA    4 | 1992 |  12681846 |\n| CHINA    7 | CHINA    3 | 1992 |  11395152 |\n| CHINA    6 | CHINA    9 | 1992 |   8642375 |\n| CHINA    8 | CHINA    6 | 1993 | 638396852 |\n| CHINA    7 | CHINA    6 | 1993 | 576731239 |\n| CHINA    2 | CHINA    6 | 1993 | 528008729 |\n| CHINA    8 | CHINA    9 | 1993 | 522412584 |\n| CHINA    8 | CHINA    7 | 1993 | 475478848 |\n| CHINA    8 | CHINA    1 | 1993 | 452064153 |\n| CHINA    0 | CHINA    1 | 1993 | 425902649 |\n| CHINA    9 | CHINA    1 | 1993 | 405252987 |\n| CHINA    6 | CHINA    9 | 1993 | 385005953 |\n| CHINA    8 | CHINA    8 | 1993 | 382884778 |\n| CHINA    0 | CHINA    6 | 1993 | 344911487 |\n| CHINA    6 | CHINA    7 | 1993 | 341436211 |\n| CHINA    3 | CHINA    6 | 1993 | 291652051 |\n| CHINA    7 | CHINA    1 | 1993 | 257769861 |\n| CHINA    8 | CHINA    0 | 1993 | 231981252 |\n| CHINA    4 | CHINA    6 | 1993 | 215180968 |\n| CHINA    3 | CHINA    0 | 1993 | 213320777 |\n| CHINA    9 | CHINA    6 | 1993 | 207281000 |\n| CHINA    5 | CHINA    9 | 1993 | 206555882 |\n| CHINA    6 | CHINA    1 | 1993 | 205665388 |\n| CHINA    5 | CHINA    1 | 1993 | 193491875 |\n| CHINA    2 | CHINA    9 | 1993 | 193324425 |\n| CHINA    5 | CHINA    8 | 1993 | 190521023 |\n| CHINA    7 | CHINA    0 | 1993 | 183487919 |\n| CHINA    0 | CHINA    9 | 1993 | 170223958 |\n| CHINA    6 | CHINA    8 | 1993 | 166821272 |\n| CHINA    3 | CHINA    8 | 1993 | 163053528 |\n| CHINA    2 | CHINA    0 | 1993 | 158276154 |\n| CHINA    3 | CHINA    1 | 1993 | 153652018 |\n| CHINA    5 | CHINA    6 | 1993 | 151359347 |\n| CHINA    6 | CHINA    0 | 1993 | 140494698 |\n| CHINA    8 | CHINA    4 | 1993 | 139857147 |\n| CHINA    2 | CHINA    7 | 1993 | 136009418 |\n| CHINA    5 | CHINA    7 | 1993 | 133892119 |\n| CHINA    9 | CHINA    9 | 1993 | 118965507 |\n| CHINA    1 | CHINA    1 | 1993 | 108898379 |\n| CHINA    6 | CHINA    6 | 1993 | 100311475 |\n| CHINA    0 | CHINA    4 | 1993 |  93483068 |\n| CHINA    1 | CHINA    4 | 1993 |  87714152 |\n| CHINA    4 | CHINA    1 | 1993 |  87690658 |\n| CHINA    4 | CHINA    7 | 1993 |  83701574 |\n| CHINA    1 | CHINA    0 | 1993 |  82670983 |\n| CHINA    7 | CHINA    4 | 1993 |  77396461 |\n| CHINA    5 | CHINA    4 | 1993 |  73556161 |\n| CHINA    4 | CHINA    8 | 1993 |  72203335 |\n| CHINA    0 | CHINA    7 | 1993 |  70395334 |\n| CHINA    3 | CHINA    4 | 1993 |  64771003 |\n| CHINA    7 | CHINA    8 | 1993 |  64514099 |\n| CHINA    3 | CHINA    7 | 1993 |  62868516 |\n| CHINA    8 | CHINA    3 | 1993 |  56504804 |\n| CHINA    2 | CHINA    4 | 1993 |  56031779 |\n| CHINA    1 | CHINA    7 | 1993 |  48951262 |\n| CHINA    7 | CHINA    3 | 1993 |  45962220 |\n| CHINA    4 | CHINA    9 | 1993 |  43158138 |\n| CHINA    7 | CHINA    9 | 1993 |  42611979 |\n| CHINA    2 | CHINA    8 | 1993 |  38092546 |\n| CHINA    1 | CHINA    9 | 1993 |  29665374 |\n| CHINA    1 | CHINA    3 | 1993 |  23991216 |\n| CHINA    6 | CHINA    6 | 1994 | 596294890 |\n| CHINA    8 | CHINA    6 | 1994 | 542104721 |\n| CHINA    6 | CHINA    1 | 1994 | 504359553 |\n| CHINA    3 | CHINA    7 | 1994 | 476727294 |\n| CHINA    3 | CHINA    6 | 1994 | 476349724 |\n| CHINA    8 | CHINA    9 | 1994 | 427241348 |\n| CHINA    6 | CHINA    9 | 1994 | 358191581 |\n| CHINA    9 | CHINA    6 | 1994 | 352344057 |\n| CHINA    3 | CHINA    0 | 1994 | 351708546 |\n| CHINA    8 | CHINA    0 | 1994 | 351131413 |\n| CHINA    3 | CHINA    3 | 1994 | 339279574 |\n| CHINA    0 | CHINA    1 | 1994 | 298307857 |\n| CHINA    0 | CHINA    7 | 1994 | 289536010 |\n| CHINA    0 | CHINA    6 | 1994 | 285639032 |\n| CHINA    7 | CHINA    6 | 1994 | 263170455 |\n| CHINA    2 | CHINA    8 | 1994 | 250332990 |\n| CHINA    6 | CHINA    4 | 1994 | 235897763 |\n| CHINA    5 | CHINA    1 | 1994 | 234681515 |\n| CHINA    8 | CHINA    7 | 1994 | 234390101 |\n| CHINA    1 | CHINA    6 | 1994 | 232792764 |\n| CHINA    8 | CHINA    1 | 1994 | 223808842 |\n| CHINA    4 | CHINA    6 | 1994 | 209522926 |\n| CHINA    8 | CHINA    4 | 1994 | 208632636 |\n| CHINA    7 | CHINA    3 | 1994 | 202424117 |\n| CHINA    4 | CHINA    7 | 1994 | 185487544 |\n| CHINA    2 | CHINA    7 | 1994 | 183551771 |\n| CHINA    7 | CHINA    1 | 1994 | 178421732 |\n| CHINA    4 | CHINA    1 | 1994 | 176262868 |\n| CHINA    5 | CHINA    6 | 1994 | 173651872 |\n| CHINA    0 | CHINA    4 | 1994 | 173584501 |\n| CHINA    8 | CHINA    8 | 1994 | 172179808 |\n| CHINA    9 | CHINA    1 | 1994 | 169617585 |\n| CHINA    0 | CHINA    9 | 1994 | 167569085 |\n| CHINA    5 | CHINA    8 | 1994 | 162066559 |\n| CHINA    7 | CHINA    9 | 1994 | 161041255 |\n| CHINA    5 | CHINA    4 | 1994 | 154820955 |\n| CHINA    7 | CHINA    0 | 1994 | 152844960 |\n| CHINA    2 | CHINA    6 | 1994 | 149839190 |\n| CHINA    7 | CHINA    8 | 1994 | 149536114 |\n| CHINA    1 | CHINA    4 | 1994 | 142403628 |\n| CHINA    9 | CHINA    9 | 1994 | 131064832 |\n| CHINA    2 | CHINA    1 | 1994 | 124489283 |\n| CHINA    2 | CHINA    0 | 1994 | 114263273 |\n| CHINA    5 | CHINA    7 | 1994 | 113311766 |\n| CHINA    8 | CHINA    3 | 1994 | 112573609 |\n| CHINA    3 | CHINA    4 | 1994 | 104903651 |\n| CHINA    4 | CHINA    0 | 1994 | 101914439 |\n| CHINA    3 | CHINA    1 | 1994 |  98253251 |\n| CHINA    1 | CHINA    7 | 1994 |  94582288 |\n| CHINA    4 | CHINA    4 | 1994 |  92818317 |\n| CHINA    1 | CHINA    9 | 1994 |  85220541 |\n| CHINA    6 | CHINA    3 | 1994 |  84604801 |\n| CHINA    0 | CHINA    3 | 1994 |  77574978 |\n| CHINA    1 | CHINA    3 | 1994 |  74435316 |\n| CHINA    4 | CHINA    9 | 1994 |  72622300 |\n| CHINA    3 | CHINA    8 | 1994 |  72559366 |\n| CHINA    9 | CHINA    0 | 1994 |  69298222 |\n| CHINA    3 | CHINA    9 | 1994 |  67472592 |\n| CHINA    6 | CHINA    8 | 1994 |  66271372 |\n| CHINA    7 | CHINA    4 | 1994 |  59634606 |\n| CHINA    2 | CHINA    9 | 1994 |  56882136 |\n| CHINA    1 | CHINA    1 | 1994 |  56592337 |\n| CHINA    5 | CHINA    9 | 1994 |  52879724 |\n| CHINA    9 | CHINA    4 | 1994 |  49324497 |\n| CHINA    2 | CHINA    3 | 1994 |  45042384 |\n| CHINA    7 | CHINA    7 | 1994 |  44458451 |\n| CHINA    5 | CHINA    0 | 1994 |  39091925 |\n| CHINA    9 | CHINA    3 | 1994 |  39082405 |\n| CHINA    0 | CHINA    8 | 1994 |  28203459 |\n| CHINA    6 | CHINA    7 | 1994 |  27243775 |\n| CHINA    0 | CHINA    0 | 1994 |  15591040 |\n| CHINA    2 | CHINA    6 | 1995 | 832176707 |\n| CHINA    8 | CHINA    6 | 1995 | 793322102 |\n| CHINA    3 | CHINA    7 | 1995 | 505446788 |\n| CHINA    7 | CHINA    9 | 1995 | 483519933 |\n| CHINA    4 | CHINA    6 | 1995 | 440320366 |\n| CHINA    8 | CHINA    1 | 1995 | 394522570 |\n| CHINA    7 | CHINA    1 | 1995 | 393861389 |\n| CHINA    5 | CHINA    1 | 1995 | 343166828 |\n| CHINA    1 | CHINA    7 | 1995 | 341736584 |\n| CHINA    8 | CHINA    7 | 1995 | 323623203 |\n| CHINA    6 | CHINA    6 | 1995 | 312876143 |\n| CHINA    3 | CHINA    6 | 1995 | 306516324 |\n| CHINA    7 | CHINA    6 | 1995 | 294840537 |\n| CHINA    3 | CHINA    3 | 1995 | 290066240 |\n| CHINA    8 | CHINA    3 | 1995 | 289182495 |\n| CHINA    3 | CHINA    1 | 1995 | 288853766 |\n| CHINA    0 | CHINA    1 | 1995 | 279082523 |\n| CHINA    0 | CHINA    8 | 1995 | 265291443 |\n| CHINA    1 | CHINA    6 | 1995 | 262283412 |\n| CHINA    4 | CHINA    1 | 1995 | 246559891 |\n| CHINA    2 | CHINA    8 | 1995 | 246465167 |\n| CHINA    6 | CHINA    7 | 1995 | 246385862 |\n| CHINA    9 | CHINA    6 | 1995 | 231314393 |\n| CHINA    2 | CHINA    7 | 1995 | 224354491 |\n| CHINA    4 | CHINA    7 | 1995 | 222368398 |\n| CHINA    0 | CHINA    7 | 1995 | 221334917 |\n| CHINA    6 | CHINA    3 | 1995 | 217756587 |\n| CHINA    6 | CHINA    9 | 1995 | 215736018 |\n| CHINA    4 | CHINA    9 | 1995 | 210496516 |\n| CHINA    0 | CHINA    6 | 1995 | 197891458 |\n| CHINA    8 | CHINA    9 | 1995 | 192018213 |\n| CHINA    7 | CHINA    0 | 1995 | 188804482 |\n| CHINA    5 | CHINA    6 | 1995 | 186378531 |\n| CHINA    6 | CHINA    1 | 1995 | 165831073 |\n| CHINA    1 | CHINA    3 | 1995 | 165118263 |\n| CHINA    6 | CHINA    8 | 1995 | 157640218 |\n| CHINA    1 | CHINA    1 | 1995 | 150838433 |\n| CHINA    1 | CHINA    4 | 1995 | 147632879 |\n| CHINA    6 | CHINA    0 | 1995 | 147314401 |\n| CHINA    5 | CHINA    4 | 1995 | 142820978 |\n| CHINA    5 | CHINA    9 | 1995 | 141416829 |\n| CHINA    2 | CHINA    0 | 1995 | 135608473 |\n| CHINA    5 | CHINA    7 | 1995 | 131596218 |\n| CHINA    0 | CHINA    4 | 1995 | 129159370 |\n| CHINA    3 | CHINA    9 | 1995 | 126837748 |\n| CHINA    8 | CHINA    0 | 1995 | 126564932 |\n| CHINA    0 | CHINA    3 | 1995 | 121337041 |\n| CHINA    7 | CHINA    7 | 1995 | 118697587 |\n| CHINA    5 | CHINA    8 | 1995 | 116538842 |\n| CHINA    8 | CHINA    8 | 1995 | 110161904 |\n| CHINA    9 | CHINA    0 | 1995 | 109582187 |\n| CHINA    9 | CHINA    1 | 1995 | 103455098 |\n| CHINA    2 | CHINA    1 | 1995 | 100264691 |\n| CHINA    7 | CHINA    3 | 1995 |  99011859 |\n| CHINA    3 | CHINA    0 | 1995 |  90383390 |\n| CHINA    4 | CHINA    3 | 1995 |  89908903 |\n| CHINA    7 | CHINA    8 | 1995 |  81425699 |\n| CHINA    3 | CHINA    4 | 1995 |  77577579 |\n| CHINA    4 | CHINA    8 | 1995 |  74805746 |\n| CHINA    9 | CHINA    7 | 1995 |  74597020 |\n| CHINA    9 | CHINA    9 | 1995 |  73514511 |\n| CHINA    5 | CHINA    0 | 1995 |  73274726 |\n| CHINA    8 | CHINA    4 | 1995 |  61708487 |\n| CHINA    1 | CHINA    0 | 1995 |  58753734 |\n| CHINA    3 | CHINA    8 | 1995 |  57133566 |\n| CHINA    9 | CHINA    4 | 1995 |  53259334 |\n| CHINA    1 | CHINA    9 | 1995 |  46177797 |\n| CHINA    2 | CHINA    4 | 1995 |  45147325 |\n| CHINA    0 | CHINA    0 | 1995 |  43963173 |\n| CHINA    0 | CHINA    9 | 1995 |  40184107 |\n| CHINA    1 | CHINA    8 | 1995 |  18859188 |\n| CHINA    8 | CHINA    7 | 1996 | 621957444 |\n| CHINA    3 | CHINA    9 | 1996 | 530082848 |\n| CHINA    8 | CHINA    6 | 1996 | 525755549 |\n| CHINA    8 | CHINA    1 | 1996 | 399229343 |\n| CHINA    6 | CHINA    7 | 1996 | 365540749 |\n| CHINA    8 | CHINA    8 | 1996 | 351864283 |\n| CHINA    1 | CHINA    6 | 1996 | 329186504 |\n| CHINA    9 | CHINA    6 | 1996 | 321113085 |\n| CHINA    3 | CHINA    6 | 1996 | 318264871 |\n| CHINA    2 | CHINA    6 | 1996 | 315233397 |\n| CHINA    2 | CHINA    9 | 1996 | 285852841 |\n| CHINA    9 | CHINA    9 | 1996 | 264510548 |\n| CHINA    5 | CHINA    6 | 1996 | 261385523 |\n| CHINA    8 | CHINA    9 | 1996 | 259497265 |\n| CHINA    6 | CHINA    6 | 1996 | 258200131 |\n| CHINA    4 | CHINA    9 | 1996 | 257345949 |\n| CHINA    6 | CHINA    9 | 1996 | 247667288 |\n| CHINA    2 | CHINA    7 | 1996 | 234569026 |\n| CHINA    2 | CHINA    1 | 1996 | 218568966 |\n| CHINA    4 | CHINA    1 | 1996 | 207383476 |\n| CHINA    0 | CHINA    1 | 1996 | 204596428 |\n| CHINA    3 | CHINA    0 | 1996 | 204375870 |\n| CHINA    4 | CHINA    0 | 1996 | 202299286 |\n| CHINA    4 | CHINA    4 | 1996 | 191983261 |\n| CHINA    4 | CHINA    8 | 1996 | 183961012 |\n| CHINA    4 | CHINA    6 | 1996 | 183872085 |\n| CHINA    6 | CHINA    8 | 1996 | 182132356 |\n| CHINA    7 | CHINA    9 | 1996 | 170941341 |\n| CHINA    0 | CHINA    6 | 1996 | 168082672 |\n| CHINA    1 | CHINA    7 | 1996 | 165942066 |\n| CHINA    1 | CHINA    9 | 1996 | 165878775 |\n| CHINA    9 | CHINA    8 | 1996 | 156009357 |\n| CHINA    7 | CHINA    7 | 1996 | 155842944 |\n| CHINA    2 | CHINA    0 | 1996 | 147709906 |\n| CHINA    5 | CHINA    7 | 1996 | 147257366 |\n| CHINA    1 | CHINA    8 | 1996 | 141840928 |\n| CHINA    2 | CHINA    4 | 1996 | 136244052 |\n| CHINA    9 | CHINA    0 | 1996 | 130997019 |\n| CHINA    1 | CHINA    0 | 1996 | 124362038 |\n| CHINA    0 | CHINA    9 | 1996 | 114011231 |\n| CHINA    7 | CHINA    3 | 1996 | 112398764 |\n| CHINA    4 | CHINA    7 | 1996 | 110567337 |\n| CHINA    3 | CHINA    4 | 1996 | 109269982 |\n| CHINA    5 | CHINA    1 | 1996 | 107482704 |\n| CHINA    6 | CHINA    4 | 1996 | 105485170 |\n| CHINA    1 | CHINA    4 | 1996 | 105320270 |\n| CHINA    0 | CHINA    7 | 1996 | 102545071 |\n| CHINA    2 | CHINA    3 | 1996 | 100407151 |\n| CHINA    0 | CHINA    4 | 1996 |  95913303 |\n| CHINA    7 | CHINA    0 | 1996 |  94706269 |\n| CHINA    6 | CHINA    1 | 1996 |  86949951 |\n| CHINA    8 | CHINA    3 | 1996 |  84157344 |\n| CHINA    2 | CHINA    8 | 1996 |  83176903 |\n| CHINA    5 | CHINA    9 | 1996 |  83104330 |\n| CHINA    7 | CHINA    8 | 1996 |  81490639 |\n| CHINA    9 | CHINA    3 | 1996 |  79655829 |\n| CHINA    5 | CHINA    0 | 1996 |  77489995 |\n| CHINA    8 | CHINA    0 | 1996 |  76989056 |\n| CHINA    9 | CHINA    1 | 1996 |  72011031 |\n| CHINA    7 | CHINA    4 | 1996 |  64764322 |\n| CHINA    5 | CHINA    4 | 1996 |  62827767 |\n| CHINA    5 | CHINA    8 | 1996 |  62673237 |\n| CHINA    7 | CHINA    6 | 1996 |  61880459 |\n| CHINA    3 | CHINA    7 | 1996 |  56642844 |\n| CHINA    3 | CHINA    1 | 1996 |  50799366 |\n| CHINA    3 | CHINA    3 | 1996 |  42601269 |\n| CHINA    4 | CHINA    3 | 1996 |  38290290 |\n| CHINA    3 | CHINA    8 | 1996 |  21263056 |\n| CHINA    7 | CHINA    1 | 1996 |  14836937 |\n| CHINA    5 | CHINA    3 | 1996 |  13611339 |\n| CHINA    1 | CHINA    3 | 1996 |   8430793 |\n| CHINA    1 | CHINA    1 | 1996 |   1601332 |\n| CHINA    1 | CHINA    7 | 1997 | 664436721 |\n| CHINA    8 | CHINA    9 | 1997 | 585552148 |\n| CHINA    8 | CHINA    6 | 1997 | 543571889 |\n| CHINA    8 | CHINA    7 | 1997 | 516131917 |\n| CHINA    6 | CHINA    7 | 1997 | 467477883 |\n| CHINA    3 | CHINA    9 | 1997 | 444914344 |\n| CHINA    5 | CHINA    6 | 1997 | 353316321 |\n| CHINA    6 | CHINA    4 | 1997 | 338136205 |\n| CHINA    0 | CHINA    7 | 1997 | 329137493 |\n| CHINA    5 | CHINA    1 | 1997 | 328142466 |\n| CHINA    8 | CHINA    4 | 1997 | 308276385 |\n| CHINA    6 | CHINA    9 | 1997 | 306814317 |\n| CHINA    5 | CHINA    9 | 1997 | 301145803 |\n| CHINA    7 | CHINA    1 | 1997 | 299575802 |\n| CHINA    8 | CHINA    8 | 1997 | 282083295 |\n| CHINA    4 | CHINA    9 | 1997 | 280242025 |\n| CHINA    9 | CHINA    1 | 1997 | 253155313 |\n| CHINA    4 | CHINA    6 | 1997 | 234247182 |\n| CHINA    5 | CHINA    0 | 1997 | 217246162 |\n| CHINA    9 | CHINA    4 | 1997 | 215424663 |\n| CHINA    0 | CHINA    6 | 1997 | 211152240 |\n| CHINA    3 | CHINA    6 | 1997 | 205982217 |\n| CHINA    7 | CHINA    6 | 1997 | 196440117 |\n| CHINA    1 | CHINA    6 | 1997 | 195757737 |\n| CHINA    2 | CHINA    3 | 1997 | 189836909 |\n| CHINA    7 | CHINA    8 | 1997 | 189291379 |\n| CHINA    9 | CHINA    6 | 1997 | 189236146 |\n| CHINA    3 | CHINA    1 | 1997 | 188537684 |\n| CHINA    9 | CHINA    7 | 1997 | 182516267 |\n| CHINA    0 | CHINA    0 | 1997 | 182459980 |\n| CHINA    5 | CHINA    8 | 1997 | 177077882 |\n| CHINA    2 | CHINA    6 | 1997 | 176030529 |\n| CHINA    2 | CHINA    1 | 1997 | 168770050 |\n| CHINA    8 | CHINA    0 | 1997 | 167294093 |\n| CHINA    4 | CHINA    3 | 1997 | 161980658 |\n| CHINA    3 | CHINA    4 | 1997 | 154433882 |\n| CHINA    6 | CHINA    6 | 1997 | 153336736 |\n| CHINA    6 | CHINA    3 | 1997 | 151596497 |\n| CHINA    8 | CHINA    1 | 1997 | 145432603 |\n| CHINA    1 | CHINA    4 | 1997 | 126773981 |\n| CHINA    1 | CHINA    0 | 1997 | 120594770 |\n| CHINA    7 | CHINA    3 | 1997 | 119618460 |\n| CHINA    6 | CHINA    1 | 1997 | 119529805 |\n| CHINA    2 | CHINA    9 | 1997 | 114591288 |\n| CHINA    7 | CHINA    7 | 1997 | 111335941 |\n| CHINA    5 | CHINA    3 | 1997 | 111044153 |\n| CHINA    6 | CHINA    0 | 1997 | 104404276 |\n| CHINA    1 | CHINA    1 | 1997 |  98869501 |\n| CHINA    7 | CHINA    0 | 1997 |  97198605 |\n| CHINA    7 | CHINA    9 | 1997 |  92872632 |\n| CHINA    0 | CHINA    9 | 1997 |  91097832 |\n| CHINA    9 | CHINA    9 | 1997 |  86479272 |\n| CHINA    2 | CHINA    7 | 1997 |  79380820 |\n| CHINA    9 | CHINA    0 | 1997 |  78499693 |\n| CHINA    1 | CHINA    9 | 1997 |  73589328 |\n| CHINA    2 | CHINA    8 | 1997 |  71633835 |\n| CHINA    8 | CHINA    3 | 1997 |  70505885 |\n| CHINA    3 | CHINA    0 | 1997 |  61039282 |\n| CHINA    0 | CHINA    3 | 1997 |  58325113 |\n| CHINA    5 | CHINA    7 | 1997 |  55476389 |\n| CHINA    4 | CHINA    7 | 1997 |  46480159 |\n| CHINA    0 | CHINA    1 | 1997 |  38223038 |\n| CHINA    4 | CHINA    1 | 1997 |  21636342 |\n| CHINA    9 | CHINA    3 | 1997 |  13092788 |\n| CHINA    6 | CHINA    8 | 1997 |   2490092 |\n+------------+------------+------+-----------+\n\n-- Q3.3\n+------------+------------+------+-----------+\n| c_city     | s_city     | year | revenue   |\n+------------+------------+------+-----------+\n| UNITED KI0 | UNITED KI7 | 1992 | 251282102 |\n| UNITED KI0 | UNITED KI0 | 1992 | 170005406 |\n| UNITED KI7 | UNITED KI7 | 1992 |  36835396 |\n| UNITED KI0 | UNITED KI7 | 1993 | 560335810 |\n| UNITED KI0 | UNITED KI0 | 1993 | 294257692 |\n| UNITED KI7 | UNITED KI0 | 1993 | 159005896 |\n| UNITED KI7 | UNITED KI7 | 1993 | 139029264 |\n| UNITED KI0 | UNITED KI7 | 1994 | 739847089 |\n| UNITED KI0 | UNITED KI0 | 1994 | 302339390 |\n| UNITED KI7 | UNITED KI7 | 1994 | 275609814 |\n| UNITED KI7 | UNITED KI0 | 1994 | 117654093 |\n| UNITED KI0 | UNITED KI7 | 1995 | 540994655 |\n| UNITED KI0 | UNITED KI0 | 1995 | 230825439 |\n| UNITED KI7 | UNITED KI0 | 1995 | 197347696 |\n| UNITED KI7 | UNITED KI7 | 1995 | 136620517 |\n| UNITED KI0 | UNITED KI7 | 1996 | 448412094 |\n| UNITED KI0 | UNITED KI0 | 1996 | 203511607 |\n| UNITED KI7 | UNITED KI7 | 1996 |  94528075 |\n| UNITED KI7 | UNITED KI0 | 1996 |  35448536 |\n| UNITED KI7 | UNITED KI0 | 1997 | 289323850 |\n| UNITED KI7 | UNITED KI7 | 1997 | 214791175 |\n| UNITED KI0 | UNITED KI7 | 1997 | 196510174 |\n| UNITED KI0 | UNITED KI0 | 1997 | 125066127 |\n+------------+------------+------+-----------+\n\n-- Q3.4\n+------------+------------+------+-----------+\n| c_city     | s_city     | year | revenue   |\n+------------+------------+------+-----------+\n| UNITED KI7 | KENYA    4 | 1997 | 170083300 |\n| UNITED KI0 | MOZAMBIQU1 | 1997 | 155234463 |\n| UNITED KI0 | KENYA    4 | 1997 |  87283610 |\n+------------+------------+------+-----------+\n\n-- Q4.1\n+------+---------------+-------------+\n| year | c_nation      | profit      |\n+------+---------------+-------------+\n| 1992 | ARGENTINA     | 13746243380 |\n| 1992 | BRAZIL        | 15762831144 |\n| 1992 | CANADA        | 17477043721 |\n| 1992 | PERU          | 14698567030 |\n| 1992 | UNITED STATES | 14043501956 |\n| 1993 | ARGENTINA     | 13992888207 |\n| 1993 | BRAZIL        | 15146262693 |\n| 1993 | CANADA        | 12463985574 |\n| 1993 | PERU          | 11385007831 |\n| 1993 | UNITED STATES | 10651361815 |\n| 1994 | ARGENTINA     | 13128610315 |\n| 1994 | BRAZIL        | 13764866493 |\n| 1994 | CANADA        | 13723188154 |\n| 1994 | PERU          | 12784683808 |\n| 1994 | UNITED STATES | 12554422837 |\n| 1995 | ARGENTINA     | 14337205612 |\n| 1995 | BRAZIL        | 15068918320 |\n| 1995 | CANADA        | 14529005783 |\n| 1995 | PERU          | 13086675480 |\n| 1995 | UNITED STATES | 11330297649 |\n| 1996 | ARGENTINA     | 13659108915 |\n| 1996 | BRAZIL        | 12660837584 |\n| 1996 | CANADA        | 14558903190 |\n| 1996 | PERU          | 14162285166 |\n| 1996 | UNITED STATES | 11117076866 |\n| 1997 | ARGENTINA     | 12556399750 |\n| 1997 | BRAZIL        | 13961587144 |\n| 1997 | CANADA        | 15567856947 |\n| 1997 | PERU          | 13595325340 |\n| 1997 | UNITED STATES | 10779073839 |\n| 1998 | ARGENTINA     |  7843424759 |\n| 1998 | BRAZIL        |  8853904827 |\n| 1998 | CANADA        |  8286104334 |\n| 1998 | PERU          |  5822590950 |\n| 1998 | UNITED STATES |  8526236814 |\n+------+---------------+-------------+\n\n-- Q4.2\n+------+---------------+------------+------------+\n| year | s_nation      | p_category | profit     |\n+------+---------------+------------+------------+\n| 1997 | ARGENTINA     | MFGR#11    | 1636950553 |\n| 1997 | ARGENTINA     | MFGR#12    | 1265547847 |\n| 1997 | ARGENTINA     | MFGR#13    | 1505131346 |\n| 1997 | ARGENTINA     | MFGR#14    | 1405447137 |\n| 1997 | ARGENTINA     | MFGR#15    | 1564085340 |\n| 1997 | ARGENTINA     | MFGR#21    | 1335009490 |\n| 1997 | ARGENTINA     | MFGR#22    | 1309054179 |\n| 1997 | ARGENTINA     | MFGR#23    | 1305213794 |\n| 1997 | ARGENTINA     | MFGR#24    | 1089725126 |\n| 1997 | ARGENTINA     | MFGR#25    | 1291995512 |\n| 1997 | BRAZIL        | MFGR#11    |  721240147 |\n| 1997 | BRAZIL        | MFGR#12    |  928318830 |\n| 1997 | BRAZIL        | MFGR#13    | 1164674879 |\n| 1997 | BRAZIL        | MFGR#14    | 1215622587 |\n| 1997 | BRAZIL        | MFGR#15    |  940971658 |\n| 1997 | BRAZIL        | MFGR#21    | 1158909618 |\n| 1997 | BRAZIL        | MFGR#22    | 1251221641 |\n| 1997 | BRAZIL        | MFGR#23    | 1552552455 |\n| 1997 | BRAZIL        | MFGR#24    |  929057361 |\n| 1997 | BRAZIL        | MFGR#25    |  574645288 |\n| 1997 | CANADA        | MFGR#11    | 1170341370 |\n| 1997 | CANADA        | MFGR#12    | 1220238121 |\n| 1997 | CANADA        | MFGR#13    | 1245774025 |\n| 1997 | CANADA        | MFGR#14    | 1032046642 |\n| 1997 | CANADA        | MFGR#15    |  738650612 |\n| 1997 | CANADA        | MFGR#21    | 1476055209 |\n| 1997 | CANADA        | MFGR#22    | 1239005798 |\n| 1997 | CANADA        | MFGR#23    |  869393804 |\n| 1997 | CANADA        | MFGR#24    | 1466964051 |\n| 1997 | CANADA        | MFGR#25    | 1358922727 |\n| 1997 | PERU          | MFGR#11    | 1031023174 |\n| 1997 | PERU          | MFGR#12    |  731821491 |\n| 1997 | PERU          | MFGR#13    | 1044642877 |\n| 1997 | PERU          | MFGR#14    |  654877417 |\n| 1997 | PERU          | MFGR#15    | 1201769474 |\n| 1997 | PERU          | MFGR#21    | 1275496672 |\n| 1997 | PERU          | MFGR#22    |  599324545 |\n| 1997 | PERU          | MFGR#23    | 1200754744 |\n| 1997 | PERU          | MFGR#24    |  942152801 |\n| 1997 | PERU          | MFGR#25    | 1064322995 |\n| 1997 | UNITED STATES | MFGR#11    | 2365218925 |\n| 1997 | UNITED STATES | MFGR#12    | 1132346574 |\n| 1997 | UNITED STATES | MFGR#13    | 2460882362 |\n| 1997 | UNITED STATES | MFGR#14    | 2190816877 |\n| 1997 | UNITED STATES | MFGR#15    | 1687829921 |\n| 1997 | UNITED STATES | MFGR#21    | 2125880770 |\n| 1997 | UNITED STATES | MFGR#22    | 2013348097 |\n| 1997 | UNITED STATES | MFGR#23    | 2570581084 |\n| 1997 | UNITED STATES | MFGR#24    | 2724372315 |\n| 1997 | UNITED STATES | MFGR#25    | 1480012758 |\n| 1998 | ARGENTINA     | MFGR#11    |  783662770 |\n| 1998 | ARGENTINA     | MFGR#12    |  472818450 |\n| 1998 | ARGENTINA     | MFGR#13    |  585091533 |\n| 1998 | ARGENTINA     | MFGR#14    |  507297527 |\n| 1998 | ARGENTINA     | MFGR#15    |  549185408 |\n| 1998 | ARGENTINA     | MFGR#21    |  972928972 |\n| 1998 | ARGENTINA     | MFGR#22    | 1508294213 |\n| 1998 | ARGENTINA     | MFGR#23    |  517896738 |\n| 1998 | ARGENTINA     | MFGR#24    |  240754731 |\n| 1998 | ARGENTINA     | MFGR#25    |  757030162 |\n| 1998 | BRAZIL        | MFGR#11    |  826283793 |\n| 1998 | BRAZIL        | MFGR#12    |  482293349 |\n| 1998 | BRAZIL        | MFGR#13    | 1037202334 |\n| 1998 | BRAZIL        | MFGR#14    |  743598666 |\n| 1998 | BRAZIL        | MFGR#15    |  584176304 |\n| 1998 | BRAZIL        | MFGR#21    |  557259779 |\n| 1998 | BRAZIL        | MFGR#22    |  535654445 |\n| 1998 | BRAZIL        | MFGR#23    |  403656721 |\n| 1998 | BRAZIL        | MFGR#24    | 1305217551 |\n| 1998 | BRAZIL        | MFGR#25    | 1109801463 |\n| 1998 | CANADA        | MFGR#11    |  936169617 |\n| 1998 | CANADA        | MFGR#12    | 1017751308 |\n| 1998 | CANADA        | MFGR#13    |  850046376 |\n| 1998 | CANADA        | MFGR#14    |  808138010 |\n| 1998 | CANADA        | MFGR#15    |  701990010 |\n| 1998 | CANADA        | MFGR#21    |  402611051 |\n| 1998 | CANADA        | MFGR#22    |  382705122 |\n| 1998 | CANADA        | MFGR#23    |  509674722 |\n| 1998 | CANADA        | MFGR#24    | 1003021250 |\n| 1998 | CANADA        | MFGR#25    |  574602788 |\n| 1998 | PERU          | MFGR#11    |  552608732 |\n| 1998 | PERU          | MFGR#12    |  500581456 |\n| 1998 | PERU          | MFGR#13    |  894607711 |\n| 1998 | PERU          | MFGR#14    |  386487826 |\n| 1998 | PERU          | MFGR#15    | 1044780577 |\n| 1998 | PERU          | MFGR#21    |  184346232 |\n| 1998 | PERU          | MFGR#22    |  674942976 |\n| 1998 | PERU          | MFGR#23    |  665523956 |\n| 1998 | PERU          | MFGR#24    |  631374203 |\n| 1998 | PERU          | MFGR#25    |  602609608 |\n| 1998 | UNITED STATES | MFGR#11    | 1230069867 |\n| 1998 | UNITED STATES | MFGR#12    | 1557720319 |\n| 1998 | UNITED STATES | MFGR#13    |  999206739 |\n| 1998 | UNITED STATES | MFGR#14    |  605040268 |\n| 1998 | UNITED STATES | MFGR#15    |  850219215 |\n| 1998 | UNITED STATES | MFGR#21    | 1032550760 |\n| 1998 | UNITED STATES | MFGR#22    | 1370141401 |\n| 1998 | UNITED STATES | MFGR#23    | 1226632297 |\n| 1998 | UNITED STATES | MFGR#24    | 1528135100 |\n| 1998 | UNITED STATES | MFGR#25    | 1127867278 |\n+------+---------------+------------+------------+\n\n-- Q4.3\n+------+------------+-----------+-----------+\n| year | s_city     | p_brand   | profit    |\n+------+------------+-----------+-----------+\n| 1997 | UNITED ST0 | MFGR#1410 |  58481513 |\n| 1997 | UNITED ST0 | MFGR#1412 |  33582225 |\n| 1997 | UNITED ST0 | MFGR#1413 | 135625490 |\n| 1997 | UNITED ST0 | MFGR#1414 |  18581969 |\n| 1997 | UNITED ST0 | MFGR#142  | 164080005 |\n| 1997 | UNITED ST0 | MFGR#1420 |  30831591 |\n| 1997 | UNITED ST0 | MFGR#1424 |   4085253 |\n| 1997 | UNITED ST0 | MFGR#1425 | 163183170 |\n| 1997 | UNITED ST0 | MFGR#1427 |  87578288 |\n| 1997 | UNITED ST0 | MFGR#1428 | 109488143 |\n| 1997 | UNITED ST0 | MFGR#143  | 198055627 |\n| 1997 | UNITED ST0 | MFGR#1430 |  52544552 |\n| 1997 | UNITED ST0 | MFGR#1432 | 158742311 |\n| 1997 | UNITED ST0 | MFGR#144  |  43479982 |\n| 1997 | UNITED ST0 | MFGR#1440 |  40412893 |\n| 1997 | UNITED ST0 | MFGR#145  | 175568435 |\n| 1997 | UNITED ST1 | MFGR#141  |  11932912 |\n| 1997 | UNITED ST1 | MFGR#1411 |  40637463 |\n| 1997 | UNITED ST1 | MFGR#1415 |  27562355 |\n| 1997 | UNITED ST1 | MFGR#1421 | 100271780 |\n| 1997 | UNITED ST1 | MFGR#1422 | 103286764 |\n| 1997 | UNITED ST1 | MFGR#1423 | 106114459 |\n| 1997 | UNITED ST1 | MFGR#1427 | 157715681 |\n| 1997 | UNITED ST1 | MFGR#1428 |  91550168 |\n| 1997 | UNITED ST1 | MFGR#1430 |  56560173 |\n| 1997 | UNITED ST1 | MFGR#1431 | 248448914 |\n| 1997 | UNITED ST1 | MFGR#1435 |    994228 |\n| 1997 | UNITED ST1 | MFGR#144  |  55729825 |\n| 1997 | UNITED ST1 | MFGR#145  | 118034196 |\n| 1997 | UNITED ST1 | MFGR#146  |  99170724 |\n| 1997 | UNITED ST1 | MFGR#147  |   5123001 |\n| 1997 | UNITED ST2 | MFGR#141  | 111908637 |\n| 1997 | UNITED ST2 | MFGR#1414 |  96864725 |\n| 1997 | UNITED ST2 | MFGR#1415 | 123601050 |\n| 1997 | UNITED ST2 | MFGR#1421 |  21014618 |\n| 1997 | UNITED ST2 | MFGR#1427 |  46524767 |\n| 1997 | UNITED ST2 | MFGR#1429 |  18800062 |\n| 1997 | UNITED ST2 | MFGR#1431 |  79199532 |\n| 1997 | UNITED ST2 | MFGR#1432 |  53841788 |\n| 1997 | UNITED ST2 | MFGR#1433 | 133842836 |\n| 1997 | UNITED ST2 | MFGR#1434 |  96443006 |\n| 1997 | UNITED ST2 | MFGR#1435 |  50858424 |\n| 1997 | UNITED ST2 | MFGR#1438 |  64571457 |\n| 1997 | UNITED ST2 | MFGR#144  |  61319000 |\n| 1997 | UNITED ST2 | MFGR#146  |  69558050 |\n| 1997 | UNITED ST2 | MFGR#147  |  41160961 |\n| 1997 | UNITED ST2 | MFGR#149  |  31735872 |\n| 1997 | UNITED ST3 | MFGR#1410 | 306449140 |\n| 1997 | UNITED ST3 | MFGR#1411 | 114677189 |\n| 1997 | UNITED ST3 | MFGR#1412 |  49229127 |\n| 1997 | UNITED ST3 | MFGR#1413 | 174911640 |\n| 1997 | UNITED ST3 | MFGR#1415 | 134932298 |\n| 1997 | UNITED ST3 | MFGR#1416 |  97111854 |\n| 1997 | UNITED ST3 | MFGR#1417 | 176279103 |\n| 1997 | UNITED ST3 | MFGR#1418 |  70684147 |\n| 1997 | UNITED ST3 | MFGR#1420 |  27591782 |\n| 1997 | UNITED ST3 | MFGR#1422 |  39411253 |\n| 1997 | UNITED ST3 | MFGR#1424 | 226736650 |\n| 1997 | UNITED ST3 | MFGR#1426 |  63997112 |\n| 1997 | UNITED ST3 | MFGR#1429 |    556053 |\n| 1997 | UNITED ST3 | MFGR#143  |  73550925 |\n| 1997 | UNITED ST3 | MFGR#1430 | 218807697 |\n| 1997 | UNITED ST3 | MFGR#1431 |  39936281 |\n| 1997 | UNITED ST3 | MFGR#1432 |  44356689 |\n| 1997 | UNITED ST3 | MFGR#1435 |  49225455 |\n| 1997 | UNITED ST3 | MFGR#1436 |  90326644 |\n| 1997 | UNITED ST3 | MFGR#1439 |  84615817 |\n| 1997 | UNITED ST3 | MFGR#144  |  59081596 |\n| 1997 | UNITED ST3 | MFGR#1440 |  59601014 |\n| 1997 | UNITED ST3 | MFGR#145  | 100692258 |\n| 1997 | UNITED ST3 | MFGR#147  | 142417874 |\n| 1997 | UNITED ST3 | MFGR#148  |  38233221 |\n| 1997 | UNITED ST5 | MFGR#1416 |  62387773 |\n| 1997 | UNITED ST5 | MFGR#1417 |  54974702 |\n| 1997 | UNITED ST5 | MFGR#1418 |  87301086 |\n| 1997 | UNITED ST5 | MFGR#1421 |   9869673 |\n| 1997 | UNITED ST5 | MFGR#1422 |  58912225 |\n| 1997 | UNITED ST5 | MFGR#1424 |  80038584 |\n| 1997 | UNITED ST5 | MFGR#1428 |  44422717 |\n| 1997 | UNITED ST5 | MFGR#1430 |  67186074 |\n| 1997 | UNITED ST5 | MFGR#1433 | 105646942 |\n| 1997 | UNITED ST5 | MFGR#1434 |  13923867 |\n| 1997 | UNITED ST5 | MFGR#145  | 104286534 |\n| 1997 | UNITED ST5 | MFGR#146  |  20965182 |\n| 1997 | UNITED ST5 | MFGR#148  | 170596496 |\n| 1997 | UNITED ST5 | MFGR#149  |  42639213 |\n| 1997 | UNITED ST6 | MFGR#1411 |  48199726 |\n| 1997 | UNITED ST6 | MFGR#1413 |  28825982 |\n| 1997 | UNITED ST6 | MFGR#1414 | 107783723 |\n| 1997 | UNITED ST6 | MFGR#1415 |  92119787 |\n| 1997 | UNITED ST6 | MFGR#1416 |  35390328 |\n| 1997 | UNITED ST6 | MFGR#1417 |  92594053 |\n| 1997 | UNITED ST6 | MFGR#1418 |  67638716 |\n| 1997 | UNITED ST6 | MFGR#1421 |  98608466 |\n| 1997 | UNITED ST6 | MFGR#143  |  23938737 |\n| 1997 | UNITED ST6 | MFGR#1432 | 104846191 |\n| 1997 | UNITED ST6 | MFGR#1435 | 185809031 |\n| 1997 | UNITED ST6 | MFGR#1436 |  82920407 |\n| 1997 | UNITED ST6 | MFGR#1438 | 137524730 |\n| 1997 | UNITED ST6 | MFGR#146  |  28124052 |\n| 1997 | UNITED ST7 | MFGR#141  |  65266383 |\n| 1997 | UNITED ST7 | MFGR#1411 |  78295166 |\n| 1997 | UNITED ST7 | MFGR#1413 |  37554700 |\n| 1997 | UNITED ST7 | MFGR#1414 |  20428356 |\n| 1997 | UNITED ST7 | MFGR#1416 |  92381468 |\n| 1997 | UNITED ST7 | MFGR#1418 | 105276410 |\n| 1997 | UNITED ST7 | MFGR#1419 | 116086880 |\n| 1997 | UNITED ST7 | MFGR#1420 |  62010492 |\n| 1997 | UNITED ST7 | MFGR#1428 |  50904528 |\n| 1997 | UNITED ST7 | MFGR#1430 | 103558679 |\n| 1997 | UNITED ST7 | MFGR#1431 |  38342548 |\n| 1997 | UNITED ST7 | MFGR#1436 |  59859992 |\n| 1997 | UNITED ST7 | MFGR#1437 |  90701341 |\n| 1997 | UNITED ST7 | MFGR#147  | 133840269 |\n| 1997 | UNITED ST7 | MFGR#148  | 175852097 |\n| 1997 | UNITED ST9 | MFGR#1411 |  62786695 |\n| 1997 | UNITED ST9 | MFGR#1416 |  25354497 |\n| 1997 | UNITED ST9 | MFGR#1417 |  47367797 |\n| 1997 | UNITED ST9 | MFGR#1418 |  27220077 |\n| 1997 | UNITED ST9 | MFGR#142  |  41015203 |\n| 1997 | UNITED ST9 | MFGR#1423 |  41473506 |\n| 1997 | UNITED ST9 | MFGR#1424 |  10735092 |\n| 1997 | UNITED ST9 | MFGR#1425 |  27926087 |\n| 1997 | UNITED ST9 | MFGR#1426 | 136645966 |\n| 1997 | UNITED ST9 | MFGR#1430 |  41283531 |\n| 1997 | UNITED ST9 | MFGR#1433 |    497505 |\n| 1997 | UNITED ST9 | MFGR#1434 | 101147110 |\n| 1997 | UNITED ST9 | MFGR#1436 |  30923170 |\n| 1997 | UNITED ST9 | MFGR#145  |  18049495 |\n| 1997 | UNITED ST9 | MFGR#146  |  43726737 |\n| 1998 | UNITED ST0 | MFGR#1413 | 131487843 |\n| 1998 | UNITED ST0 | MFGR#1426 |  52942692 |\n| 1998 | UNITED ST0 | MFGR#146  |  13567224 |\n| 1998 | UNITED ST1 | MFGR#1410 |  65992198 |\n| 1998 | UNITED ST1 | MFGR#1416 | 115552383 |\n| 1998 | UNITED ST1 | MFGR#1418 |  15646035 |\n| 1998 | UNITED ST1 | MFGR#1419 | 129708776 |\n| 1998 | UNITED ST1 | MFGR#1428 |  18176281 |\n| 1998 | UNITED ST1 | MFGR#1431 |  17985830 |\n| 1998 | UNITED ST1 | MFGR#1436 |  16714417 |\n| 1998 | UNITED ST1 | MFGR#145  |  48297153 |\n| 1998 | UNITED ST2 | MFGR#1418 |   9240384 |\n| 1998 | UNITED ST2 | MFGR#1419 |  40909344 |\n| 1998 | UNITED ST2 | MFGR#1420 |  78625306 |\n| 1998 | UNITED ST2 | MFGR#1426 |  67161050 |\n| 1998 | UNITED ST2 | MFGR#1430 |  19028508 |\n| 1998 | UNITED ST2 | MFGR#1434 | 127804385 |\n| 1998 | UNITED ST2 | MFGR#1435 |  75092689 |\n| 1998 | UNITED ST2 | MFGR#1436 |  54579894 |\n| 1998 | UNITED ST2 | MFGR#1440 |  29067722 |\n| 1998 | UNITED ST2 | MFGR#148  |  78886426 |\n| 1998 | UNITED ST3 | MFGR#141  |   4311846 |\n| 1998 | UNITED ST3 | MFGR#1412 |  98979253 |\n| 1998 | UNITED ST3 | MFGR#1415 | 102275672 |\n| 1998 | UNITED ST3 | MFGR#1416 |  50781431 |\n| 1998 | UNITED ST3 | MFGR#1419 |  37451476 |\n| 1998 | UNITED ST3 | MFGR#1420 |  24660608 |\n| 1998 | UNITED ST3 | MFGR#1422 |  98548762 |\n| 1998 | UNITED ST3 | MFGR#1424 |  96601854 |\n| 1998 | UNITED ST3 | MFGR#1425 |  74508450 |\n| 1998 | UNITED ST3 | MFGR#1426 | 330583054 |\n| 1998 | UNITED ST3 | MFGR#1427 |  41352585 |\n| 1998 | UNITED ST3 | MFGR#1428 |  61979722 |\n| 1998 | UNITED ST3 | MFGR#1429 |    869295 |\n| 1998 | UNITED ST3 | MFGR#1432 |  66991135 |\n| 1998 | UNITED ST3 | MFGR#146  |  35929398 |\n| 1998 | UNITED ST3 | MFGR#147  |   8484972 |\n| 1998 | UNITED ST3 | MFGR#149  |  11793257 |\n| 1998 | UNITED ST5 | MFGR#1410 |  55951811 |\n| 1998 | UNITED ST5 | MFGR#1413 |  13403140 |\n| 1998 | UNITED ST5 | MFGR#142  |  24156762 |\n| 1998 | UNITED ST5 | MFGR#1422 | 105826683 |\n| 1998 | UNITED ST5 | MFGR#1430 |  67851607 |\n| 1998 | UNITED ST5 | MFGR#1431 |  84833774 |\n| 1998 | UNITED ST5 | MFGR#1434 |  45541810 |\n| 1998 | UNITED ST5 | MFGR#1437 |  33353745 |\n| 1998 | UNITED ST5 | MFGR#146  |  19891496 |\n| 1998 | UNITED ST6 | MFGR#1413 | 135522572 |\n| 1998 | UNITED ST6 | MFGR#1416 | 185707286 |\n| 1998 | UNITED ST6 | MFGR#1417 |  80511133 |\n| 1998 | UNITED ST6 | MFGR#1419 | 127132766 |\n| 1998 | UNITED ST6 | MFGR#142  |  72629474 |\n| 1998 | UNITED ST6 | MFGR#1435 | 158543190 |\n| 1998 | UNITED ST7 | MFGR#1412 |  56750777 |\n| 1998 | UNITED ST7 | MFGR#1424 |  89508621 |\n| 1998 | UNITED ST7 | MFGR#1425 | 160377031 |\n| 1998 | UNITED ST7 | MFGR#1434 |  20882477 |\n| 1998 | UNITED ST7 | MFGR#146  | 100783548 |\n| 1998 | UNITED ST7 | MFGR#147  |  61595522 |\n| 1998 | UNITED ST9 | MFGR#1412 |   5049765 |\n| 1998 | UNITED ST9 | MFGR#142  |  69919113 |\n| 1998 | UNITED ST9 | MFGR#1425 |  11003199 |\n| 1998 | UNITED ST9 | MFGR#1426 | 103616972 |\n| 1998 | UNITED ST9 | MFGR#1435 |  18879758 |\n| 1998 | UNITED ST9 | MFGR#1438 | 101903219 |\n+------+------------+-----------+-----------+\n
        "},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#multiple-tables-queries-expected-results","title":"Multiple tables queries expected results","text":"
        -- Q1.1\n+--------------+\n| revenue      |\n+--------------+\n| 218453880421 |\n+--------------+\n\n-- Q1.2\n+---------+\n| revenue |\n+---------+\n|    NULL |\n+---------+\n\n-- Q1.3\n+-------------+\n| revenue     |\n+-------------+\n| 17527575453 |\n+-------------+\n\n-- Q2.1\n+------------+------+-----------+\n| lo_revenue | year | p_brand   |\n+------------+------+-----------+\n| 1135676414 | 1992 | MFGR#121  |\n| 1221327580 | 1992 | MFGR#1210 |\n| 1101539324 | 1992 | MFGR#1211 |\n| 1298411712 | 1992 | MFGR#1212 |\n| 1248062482 | 1992 | MFGR#1213 |\n| 1340976936 | 1992 | MFGR#1214 |\n| 1266304940 | 1992 | MFGR#1215 |\n| 1349693562 | 1992 | MFGR#1216 |\n| 1350186870 | 1992 | MFGR#1217 |\n| 1200404140 | 1992 | MFGR#1218 |\n| 1076087188 | 1992 | MFGR#1219 |\n| 1310653344 | 1992 | MFGR#122  |\n| 1080525764 | 1992 | MFGR#1220 |\n| 1112241266 | 1992 | MFGR#1221 |\n| 1181525554 | 1992 | MFGR#1222 |\n| 1070897302 | 1992 | MFGR#1223 |\n| 1407505222 | 1992 | MFGR#1224 |\n| 1141665736 | 1992 | MFGR#1225 |\n| 1228123186 | 1992 | MFGR#1226 |\n| 1163518776 | 1992 | MFGR#1227 |\n| 1289285184 | 1992 | MFGR#1228 |\n| 1281716860 | 1992 | MFGR#1229 |\n| 1579511670 | 1992 | MFGR#123  |\n|  937070174 | 1992 | MFGR#1230 |\n| 1184873312 | 1992 | MFGR#1231 |\n| 1328550304 | 1992 | MFGR#1232 |\n| 1227770200 | 1992 | MFGR#1233 |\n| 1334798562 | 1992 | MFGR#1234 |\n| 1280580140 | 1992 | MFGR#1235 |\n| 1003785122 | 1992 | MFGR#1236 |\n| 1182963006 | 1992 | MFGR#1237 |\n|  954847540 | 1992 | MFGR#1238 |\n| 1276518748 | 1992 | MFGR#1239 |\n| 1144708392 | 1992 | MFGR#124  |\n| 1480958496 | 1992 | MFGR#1240 |\n|  957554190 | 1992 | MFGR#125  |\n| 1184349232 | 1992 | MFGR#126  |\n| 1412303264 | 1992 | MFGR#127  |\n| 1084613292 | 1992 | MFGR#128  |\n| 1163974704 | 1992 | MFGR#129  |\n| 1646175404 | 1993 | MFGR#121  |\n| 1296321412 | 1993 | MFGR#1210 |\n| 1269487796 | 1993 | MFGR#1211 |\n| 1571278566 | 1993 | MFGR#1212 |\n| 1276510058 | 1993 | MFGR#1213 |\n| 1233674474 | 1993 | MFGR#1214 |\n| 1269375950 | 1993 | MFGR#1215 |\n| 1276707800 | 1993 | MFGR#1216 |\n| 1326745902 | 1993 | MFGR#1217 |\n| 1367971710 | 1993 | MFGR#1218 |\n| 1293900066 | 1993 | MFGR#1219 |\n| 1245065968 | 1993 | MFGR#122  |\n| 1061660254 | 1993 | MFGR#1220 |\n| 1086692674 | 1993 | MFGR#1221 |\n| 1513842406 | 1993 | MFGR#1222 |\n| 1067088700 | 1993 | MFGR#1223 |\n| 1831832170 | 1993 | MFGR#1224 |\n|  946014762 | 1993 | MFGR#1225 |\n| 1478072248 | 1993 | MFGR#1226 |\n| 1184357774 | 1993 | MFGR#1227 |\n| 1167014116 | 1993 | MFGR#1228 |\n| 1234906982 | 1993 | MFGR#1229 |\n| 1275727736 | 1993 | MFGR#123  |\n| 1251068620 | 1993 | MFGR#1230 |\n| 1160655270 | 1993 | MFGR#1231 |\n| 1394746196 | 1993 | MFGR#1232 |\n| 1031142832 | 1993 | MFGR#1233 |\n| 1303871516 | 1993 | MFGR#1234 |\n| 1151558960 | 1993 | MFGR#1235 |\n| 1183757334 | 1993 | MFGR#1236 |\n| 1219237152 | 1993 | MFGR#1237 |\n|  889228020 | 1993 | MFGR#1238 |\n| 1190512654 | 1993 | MFGR#1239 |\n| 1321172474 | 1993 | MFGR#124  |\n| 1577460118 | 1993 | MFGR#1240 |\n| 1232449078 | 1993 | MFGR#125  |\n| 1234253508 | 1993 | MFGR#126  |\n| 1308876648 | 1993 | MFGR#127  |\n| 1463314002 | 1993 | MFGR#128  |\n| 1096096790 | 1993 | MFGR#129  |\n| 1128811296 | 1994 | MFGR#121  |\n| 1290809698 | 1994 | MFGR#1210 |\n| 1263241270 | 1994 | MFGR#1211 |\n| 1136664696 | 1994 | MFGR#1212 |\n| 1357571714 | 1994 | MFGR#1213 |\n| 1068004660 | 1994 | MFGR#1214 |\n| 1308800484 | 1994 | MFGR#1215 |\n| 1117292682 | 1994 | MFGR#1216 |\n| 1375691282 | 1994 | MFGR#1217 |\n| 1093348694 | 1994 | MFGR#1218 |\n| 1134545884 | 1994 | MFGR#1219 |\n| 1319768124 | 1994 | MFGR#122  |\n| 1125164344 | 1994 | MFGR#1220 |\n| 1197237994 | 1994 | MFGR#1221 |\n| 1202032882 | 1994 | MFGR#1222 |\n| 1110268808 | 1994 | MFGR#1223 |\n| 1474844604 | 1994 | MFGR#1224 |\n| 1141491910 | 1994 | MFGR#1225 |\n| 1492604490 | 1994 | MFGR#1226 |\n| 1303414962 | 1994 | MFGR#1227 |\n| 1147387094 | 1994 | MFGR#1228 |\n| 1295836746 | 1994 | MFGR#1229 |\n| 1160899184 | 1994 | MFGR#123  |\n|  986540824 | 1994 | MFGR#1230 |\n| 1207092296 | 1994 | MFGR#1231 |\n| 1439730662 | 1994 | MFGR#1232 |\n| 1277964476 | 1994 | MFGR#1233 |\n| 1486495354 | 1994 | MFGR#1234 |\n| 1197361918 | 1994 | MFGR#1235 |\n| 1231452194 | 1994 | MFGR#1236 |\n| 1085139630 | 1994 | MFGR#1237 |\n| 1147021562 | 1994 | MFGR#1238 |\n| 1159711706 | 1994 | MFGR#1239 |\n| 1369146644 | 1994 | MFGR#124  |\n| 1747471474 | 1994 | MFGR#1240 |\n| 1120976608 | 1994 | MFGR#125  |\n| 1314073028 | 1994 | MFGR#126  |\n| 1245142366 | 1994 | MFGR#127  |\n| 1173691328 | 1994 | MFGR#128  |\n| 1069083050 | 1994 | MFGR#129  |\n| 1412939022 | 1995 | MFGR#121  |\n| 1205785606 | 1995 | MFGR#1210 |\n| 1290332184 | 1995 | MFGR#1211 |\n| 1226578566 | 1995 | MFGR#1212 |\n| 1199172958 | 1995 | MFGR#1213 |\n| 1125141608 | 1995 | MFGR#1214 |\n| 1345057510 | 1995 | MFGR#1215 |\n| 1338001944 | 1995 | MFGR#1216 |\n| 1450724898 | 1995 | MFGR#1217 |\n| 1314053270 | 1995 | MFGR#1218 |\n| 1039318006 | 1995 | MFGR#1219 |\n| 1449455482 | 1995 | MFGR#122  |\n| 1035912262 | 1995 | MFGR#1220 |\n| 1271482702 | 1995 | MFGR#1221 |\n| 1128736820 | 1995 | MFGR#1222 |\n| 1201330298 | 1995 | MFGR#1223 |\n| 1525400702 | 1995 | MFGR#1224 |\n| 1343339172 | 1995 | MFGR#1225 |\n| 1145137496 | 1995 | MFGR#1226 |\n| 1060722600 | 1995 | MFGR#1227 |\n| 1266714170 | 1995 | MFGR#1228 |\n| 1095920488 | 1995 | MFGR#1229 |\n| 1321422154 | 1995 | MFGR#123  |\n| 1205471716 | 1995 | MFGR#1230 |\n|  999704292 | 1995 | MFGR#1231 |\n| 1430601506 | 1995 | MFGR#1232 |\n| 1114299142 | 1995 | MFGR#1233 |\n| 1420046118 | 1995 | MFGR#1234 |\n| 1244850478 | 1995 | MFGR#1235 |\n| 1269131002 | 1995 | MFGR#1236 |\n| 1145694540 | 1995 | MFGR#1237 |\n| 1098637824 | 1995 | MFGR#1238 |\n| 1187703424 | 1995 | MFGR#1239 |\n| 1170843630 | 1995 | MFGR#124  |\n| 1414415776 | 1995 | MFGR#1240 |\n| 1076493744 | 1995 | MFGR#125  |\n| 1211598042 | 1995 | MFGR#126  |\n| 1331956224 | 1995 | MFGR#127  |\n| 1293921912 | 1995 | MFGR#128  |\n| 1017498802 | 1995 | MFGR#129  |\n| 1047758290 | 1996 | MFGR#121  |\n| 1287290106 | 1996 | MFGR#1210 |\n| 1190130678 | 1996 | MFGR#1211 |\n| 1349252880 | 1996 | MFGR#1212 |\n|  992594174 | 1996 | MFGR#1213 |\n| 1166499010 | 1996 | MFGR#1214 |\n| 1404369714 | 1996 | MFGR#1215 |\n| 1203618668 | 1996 | MFGR#1216 |\n| 1409796774 | 1996 | MFGR#1217 |\n| 1057686172 | 1996 | MFGR#1218 |\n| 1172492660 | 1996 | MFGR#1219 |\n| 1424220984 | 1996 | MFGR#122  |\n| 1036888430 | 1996 | MFGR#1220 |\n|  998638828 | 1996 | MFGR#1221 |\n| 1358938712 | 1996 | MFGR#1222 |\n| 1257525508 | 1996 | MFGR#1223 |\n| 1449689712 | 1996 | MFGR#1224 |\n| 1321241174 | 1996 | MFGR#1225 |\n| 1335349458 | 1996 | MFGR#1226 |\n|  967676170 | 1996 | MFGR#1227 |\n| 1219710782 | 1996 | MFGR#1228 |\n| 1317919114 | 1996 | MFGR#1229 |\n| 1132435704 | 1996 | MFGR#123  |\n| 1057759996 | 1996 | MFGR#1230 |\n| 1178962388 | 1996 | MFGR#1231 |\n| 1405611792 | 1996 | MFGR#1232 |\n| 1327359894 | 1996 | MFGR#1233 |\n| 1142298900 | 1996 | MFGR#1234 |\n|  957296148 | 1996 | MFGR#1235 |\n| 1136498730 | 1996 | MFGR#1236 |\n| 1185232334 | 1996 | MFGR#1237 |\n|  933352296 | 1996 | MFGR#1238 |\n| 1341387438 | 1996 | MFGR#1239 |\n| 1121335438 | 1996 | MFGR#124  |\n| 1642335900 | 1996 | MFGR#1240 |\n|  953728666 | 1996 | MFGR#125  |\n| 1116061768 | 1996 | MFGR#126  |\n| 1271747782 | 1996 | MFGR#127  |\n| 1102021236 | 1996 | MFGR#128  |\n| 1121141260 | 1996 | MFGR#129  |\n| 1174026414 | 1997 | MFGR#121  |\n| 1232575784 | 1997 | MFGR#1210 |\n| 1097177522 | 1997 | MFGR#1211 |\n| 1179187784 | 1997 | MFGR#1212 |\n|  848613340 | 1997 | MFGR#1213 |\n| 1023943820 | 1997 | MFGR#1214 |\n| 1263544492 | 1997 | MFGR#1215 |\n| 1384270280 | 1997 | MFGR#1216 |\n| 1555989914 | 1997 | MFGR#1217 |\n| 1414107440 | 1997 | MFGR#1218 |\n| 1122339054 | 1997 | MFGR#1219 |\n| 1329832490 | 1997 | MFGR#122  |\n| 1188932314 | 1997 | MFGR#1220 |\n| 1177696342 | 1997 | MFGR#1221 |\n| 1057977920 | 1997 | MFGR#1222 |\n| 1074196422 | 1997 | MFGR#1223 |\n| 1349526332 | 1997 | MFGR#1224 |\n|  900804584 | 1997 | MFGR#1225 |\n| 1402721444 | 1997 | MFGR#1226 |\n| 1012023140 | 1997 | MFGR#1227 |\n| 1171157474 | 1997 | MFGR#1228 |\n| 1245488032 | 1997 | MFGR#1229 |\n| 1293006336 | 1997 | MFGR#123  |\n| 1143601882 | 1997 | MFGR#1230 |\n| 1005203580 | 1997 | MFGR#1231 |\n| 1355849312 | 1997 | MFGR#1232 |\n| 1068911952 | 1997 | MFGR#1233 |\n| 1429869430 | 1997 | MFGR#1234 |\n| 1534302840 | 1997 | MFGR#1235 |\n| 1237754358 | 1997 | MFGR#1236 |\n| 1279276114 | 1997 | MFGR#1237 |\n|  803906838 | 1997 | MFGR#1238 |\n| 1221513428 | 1997 | MFGR#1239 |\n| 1086496174 | 1997 | MFGR#124  |\n| 1350265384 | 1997 | MFGR#1240 |\n|  958198730 | 1997 | MFGR#125  |\n| 1141393136 | 1997 | MFGR#126  |\n| 1166149184 | 1997 | MFGR#127  |\n| 1390266208 | 1997 | MFGR#128  |\n| 1311277552 | 1997 | MFGR#129  |\n|  689151850 | 1998 | MFGR#121  |\n|  834304832 | 1998 | MFGR#1210 |\n|  634136336 | 1998 | MFGR#1211 |\n|  748683032 | 1998 | MFGR#1212 |\n|  665481806 | 1998 | MFGR#1213 |\n|  609746004 | 1998 | MFGR#1214 |\n|  732202264 | 1998 | MFGR#1215 |\n|  758267796 | 1998 | MFGR#1216 |\n|  719016994 | 1998 | MFGR#1217 |\n|  641246668 | 1998 | MFGR#1218 |\n|  692365724 | 1998 | MFGR#1219 |\n|  624880054 | 1998 | MFGR#122  |\n|  696247922 | 1998 | MFGR#1220 |\n|  679690796 | 1998 | MFGR#1221 |\n|  710832322 | 1998 | MFGR#1222 |\n|  689779644 | 1998 | MFGR#1223 |\n|  793813382 | 1998 | MFGR#1224 |\n|  580417756 | 1998 | MFGR#1225 |\n|  838831414 | 1998 | MFGR#1226 |\n|  716932680 | 1998 | MFGR#1227 |\n|  503099910 | 1998 | MFGR#1228 |\n|  766277720 | 1998 | MFGR#1229 |\n|  592661122 | 1998 | MFGR#123  |\n|  874362486 | 1998 | MFGR#1230 |\n|  797888984 | 1998 | MFGR#1231 |\n|  848124910 | 1998 | MFGR#1232 |\n|  813934376 | 1998 | MFGR#1233 |\n|  857734480 | 1998 | MFGR#1234 |\n|  704555562 | 1998 | MFGR#1235 |\n|  723654172 | 1998 | MFGR#1236 |\n|  683237138 | 1998 | MFGR#1237 |\n|  489478462 | 1998 | MFGR#1238 |\n|  828303606 | 1998 | MFGR#1239 |\n|  660164742 | 1998 | MFGR#124  |\n|  830624906 | 1998 | MFGR#1240 |\n|  720579248 | 1998 | MFGR#125  |\n|  683315160 | 1998 | MFGR#126  |\n|  755014122 | 1998 | MFGR#127  |\n|  722832994 | 1998 | MFGR#128  |\n|  637539146 | 1998 | MFGR#129  |\n+------------+------+-----------+\n\n-- Q2.2\n+------------+------+-----------+\n| lo_revenue | year | p_brand   |\n+------------+------+-----------+\n| 1419049858 | 1992 | MFGR#2221 |\n| 1567692788 | 1992 | MFGR#2222 |\n| 1530104004 | 1992 | MFGR#2223 |\n| 1302977924 | 1992 | MFGR#2224 |\n| 1293057178 | 1992 | MFGR#2225 |\n| 1419301096 | 1992 | MFGR#2226 |\n| 1491112632 | 1992 | MFGR#2227 |\n| 1513803750 | 1992 | MFGR#2228 |\n| 1533042206 | 1993 | MFGR#2221 |\n| 1382951194 | 1993 | MFGR#2222 |\n| 1516441504 | 1993 | MFGR#2223 |\n| 1339325414 | 1993 | MFGR#2224 |\n| 1547708456 | 1993 | MFGR#2225 |\n| 1474175036 | 1993 | MFGR#2226 |\n| 1563935532 | 1993 | MFGR#2227 |\n| 1361760432 | 1993 | MFGR#2228 |\n| 1371555036 | 1994 | MFGR#2221 |\n| 1333049614 | 1994 | MFGR#2222 |\n| 1467987180 | 1994 | MFGR#2223 |\n| 1415738080 | 1994 | MFGR#2224 |\n| 1442503934 | 1994 | MFGR#2225 |\n| 1644991838 | 1994 | MFGR#2226 |\n| 1441674256 | 1994 | MFGR#2227 |\n| 1652450700 | 1994 | MFGR#2228 |\n| 1550874148 | 1995 | MFGR#2221 |\n| 1522709584 | 1995 | MFGR#2222 |\n| 1275665150 | 1995 | MFGR#2223 |\n| 1179531414 | 1995 | MFGR#2224 |\n| 1416580078 | 1995 | MFGR#2225 |\n| 1494712766 | 1995 | MFGR#2226 |\n| 1605005080 | 1995 | MFGR#2227 |\n| 1791873572 | 1995 | MFGR#2228 |\n| 1400020016 | 1996 | MFGR#2221 |\n| 1554620170 | 1996 | MFGR#2222 |\n| 1312190628 | 1996 | MFGR#2223 |\n| 1313719834 | 1996 | MFGR#2224 |\n| 1531641792 | 1996 | MFGR#2225 |\n| 1616355468 | 1996 | MFGR#2226 |\n| 1459126606 | 1996 | MFGR#2227 |\n| 1639331748 | 1996 | MFGR#2228 |\n| 1454684764 | 1997 | MFGR#2221 |\n| 1329067558 | 1997 | MFGR#2222 |\n| 1496576784 | 1997 | MFGR#2223 |\n| 1260844162 | 1997 | MFGR#2224 |\n| 1514782406 | 1997 | MFGR#2225 |\n| 1495778514 | 1997 | MFGR#2226 |\n| 1457715798 | 1997 | MFGR#2227 |\n| 1550625970 | 1997 | MFGR#2228 |\n|  670609008 | 1998 | MFGR#2221 |\n|  818694274 | 1998 | MFGR#2222 |\n|  918219154 | 1998 | MFGR#2223 |\n|  826636144 | 1998 | MFGR#2224 |\n|  820804190 | 1998 | MFGR#2225 |\n|  907030088 | 1998 | MFGR#2226 |\n|  781012810 | 1998 | MFGR#2227 |\n|  795878206 | 1998 | MFGR#2228 |\n+------------+------+-----------+\n\n-- Q2.3\n+------------+------+-----------+\n| lo_revenue | year | p_brand   |\n+------------+------+-----------+\n| 1452854972 | 1992 | MFGR#2239 |\n| 1410477918 | 1993 | MFGR#2239 |\n| 1328290268 | 1994 | MFGR#2239 |\n| 1427678672 | 1995 | MFGR#2239 |\n| 1456985730 | 1996 | MFGR#2239 |\n| 1467793064 | 1997 | MFGR#2239 |\n|  760511462 | 1998 | MFGR#2239 |\n+------------+------+-----------+\n\n-- Q3.1\n+-----------+-----------+------+-------------+\n| c_nation  | s_nation  | year | lo_revenue  |\n+-----------+-----------+------+-------------+\n| INDONESIA | INDONESIA | 1992 | 13811397976 |\n| CHINA     | INDONESIA | 1992 | 13232157738 |\n| CHINA     | CHINA     | 1992 | 12912862954 |\n| VIETNAM   | INDONESIA | 1992 | 12680363414 |\n| VIETNAM   | CHINA     | 1992 | 12665688780 |\n| INDONESIA | CHINA     | 1992 | 12621419066 |\n| INDIA     | INDONESIA | 1992 | 12477614708 |\n| JAPAN     | INDONESIA | 1992 | 12445131276 |\n| CHINA     | INDIA     | 1992 | 12379662702 |\n| CHINA     | JAPAN     | 1992 | 12315357786 |\n| JAPAN     | CHINA     | 1992 | 12134201310 |\n| INDIA     | CHINA     | 1992 | 12132923622 |\n| VIETNAM   | JAPAN     | 1992 | 11727572698 |\n| JAPAN     | INDIA     | 1992 | 11605499970 |\n| INDONESIA | INDIA     | 1992 | 11540406436 |\n| VIETNAM   | INDIA     | 1992 | 11397022802 |\n| INDONESIA | JAPAN     | 1992 | 11327531220 |\n| JAPAN     | JAPAN     | 1992 | 11296069422 |\n| INDIA     | JAPAN     | 1992 | 10843918562 |\n| CHINA     | VIETNAM   | 1992 | 10824644052 |\n| JAPAN     | VIETNAM   | 1992 | 10803385110 |\n| INDIA     | INDIA     | 1992 | 10722487510 |\n| INDONESIA | VIETNAM   | 1992 | 10605276744 |\n| INDIA     | VIETNAM   | 1992 | 10490661242 |\n| VIETNAM   | VIETNAM   | 1992 | 10223463556 |\n| INDONESIA | INDONESIA | 1993 | 13862726524 |\n| INDONESIA | CHINA     | 1993 | 13225782498 |\n| CHINA     | INDONESIA | 1993 | 13163026732 |\n| VIETNAM   | INDONESIA | 1993 | 13023278704 |\n| CHINA     | CHINA     | 1993 | 12889027574 |\n| CHINA     | INDIA     | 1993 | 12843388242 |\n| VIETNAM   | CHINA     | 1993 | 12827159998 |\n| INDIA     | INDONESIA | 1993 | 12662117188 |\n| JAPAN     | CHINA     | 1993 | 12584587990 |\n| INDIA     | CHINA     | 1993 | 12418707584 |\n| CHINA     | JAPAN     | 1993 | 12390933768 |\n| VIETNAM   | INDIA     | 1993 | 12322348954 |\n| INDONESIA | INDIA     | 1993 | 12303328612 |\n| INDONESIA | JAPAN     | 1993 | 12295210498 |\n| JAPAN     | INDONESIA | 1993 | 12107892626 |\n| INDIA     | JAPAN     | 1993 | 11990417970 |\n| CHINA     | VIETNAM   | 1993 | 11770046456 |\n| VIETNAM   | JAPAN     | 1993 | 11748533734 |\n| INDONESIA | VIETNAM   | 1993 | 11680575444 |\n| JAPAN     | INDIA     | 1993 | 11646686314 |\n| INDIA     | INDIA     | 1993 | 11143151598 |\n| VIETNAM   | VIETNAM   | 1993 | 11108322366 |\n| JAPAN     | JAPAN     | 1993 | 10860637166 |\n| JAPAN     | VIETNAM   | 1993 | 10813139306 |\n| INDIA     | VIETNAM   | 1993 | 10467742974 |\n| VIETNAM   | CHINA     | 1994 | 13419766884 |\n| CHINA     | CHINA     | 1994 | 13297885930 |\n| INDONESIA | CHINA     | 1994 | 12967201820 |\n| CHINA     | JAPAN     | 1994 | 12698074042 |\n| VIETNAM   | INDONESIA | 1994 | 12694883862 |\n| JAPAN     | CHINA     | 1994 | 12640018436 |\n| INDONESIA | INDONESIA | 1994 | 12630662172 |\n| CHINA     | INDIA     | 1994 | 12595165622 |\n| CHINA     | INDONESIA | 1994 | 12469575792 |\n| VIETNAM   | JAPAN     | 1994 | 12463946094 |\n| INDONESIA | INDIA     | 1994 | 12396824490 |\n| INDIA     | INDONESIA | 1994 | 12336379718 |\n| INDONESIA | JAPAN     | 1994 | 12282391938 |\n| JAPAN     | INDONESIA | 1994 | 12026069236 |\n| CHINA     | VIETNAM   | 1994 | 11770637466 |\n| INDIA     | CHINA     | 1994 | 11630045428 |\n| VIETNAM   | INDIA     | 1994 | 11578797382 |\n| JAPAN     | JAPAN     | 1994 | 11507642964 |\n| JAPAN     | INDIA     | 1994 | 11291637744 |\n| INDONESIA | VIETNAM   | 1994 | 11248692736 |\n| INDIA     | INDIA     | 1994 | 11169873030 |\n| VIETNAM   | VIETNAM   | 1994 | 10836996318 |\n| INDIA     | JAPAN     | 1994 | 10788269948 |\n| JAPAN     | VIETNAM   | 1994 | 10551643274 |\n| INDIA     | VIETNAM   | 1994 | 10502079630 |\n| CHINA     | INDONESIA | 1995 | 14149078888 |\n| INDONESIA | CHINA     | 1995 | 13857241240 |\n| CHINA     | CHINA     | 1995 | 13249333224 |\n| JAPAN     | CHINA     | 1995 | 13039778770 |\n| VIETNAM   | CHINA     | 1995 | 12665462536 |\n| INDONESIA | INDONESIA | 1995 | 12537062642 |\n| VIETNAM   | JAPAN     | 1995 | 12527914040 |\n| CHINA     | INDIA     | 1995 | 12493312748 |\n| VIETNAM   | INDIA     | 1995 | 12396883914 |\n| INDONESIA | INDIA     | 1995 | 12347610366 |\n| VIETNAM   | INDONESIA | 1995 | 12115640296 |\n| CHINA     | JAPAN     | 1995 | 12043708260 |\n| INDONESIA | JAPAN     | 1995 | 12038187742 |\n| INDIA     | CHINA     | 1995 | 12021065586 |\n| INDIA     | INDONESIA | 1995 | 11951037194 |\n| JAPAN     | JAPAN     | 1995 | 11904558258 |\n| JAPAN     | INDONESIA | 1995 | 11894001470 |\n| VIETNAM   | VIETNAM   | 1995 | 11509455214 |\n| JAPAN     | INDIA     | 1995 | 11461486252 |\n| INDONESIA | VIETNAM   | 1995 | 11149948132 |\n| INDIA     | INDIA     | 1995 | 11131991100 |\n| JAPAN     | VIETNAM   | 1995 | 11002627550 |\n| CHINA     | VIETNAM   | 1995 | 10979872126 |\n| INDIA     | JAPAN     | 1995 | 10938406854 |\n| INDIA     | VIETNAM   | 1995 | 10414126568 |\n| INDONESIA | INDONESIA | 1996 | 13500112566 |\n| CHINA     | INDONESIA | 1996 | 13314250150 |\n| INDONESIA | CHINA     | 1996 | 13226878224 |\n| CHINA     | CHINA     | 1996 | 13183395830 |\n| VIETNAM   | CHINA     | 1996 | 12857307780 |\n| VIETNAM   | INDONESIA | 1996 | 12591253464 |\n| JAPAN     | INDONESIA | 1996 | 12454895712 |\n| INDIA     | CHINA     | 1996 | 12397135638 |\n| INDIA     | INDONESIA | 1996 | 12378484116 |\n| CHINA     | INDIA     | 1996 | 12307574730 |\n| INDONESIA | INDIA     | 1996 | 12277621726 |\n| CHINA     | JAPAN     | 1996 | 12211132648 |\n| JAPAN     | CHINA     | 1996 | 12177971128 |\n| INDONESIA | JAPAN     | 1996 | 12111276444 |\n| VIETNAM   | JAPAN     | 1996 | 11839994300 |\n| VIETNAM   | VIETNAM   | 1996 | 11721684604 |\n| INDIA     | JAPAN     | 1996 | 11683329610 |\n| VIETNAM   | INDIA     | 1996 | 11614973966 |\n| JAPAN     | INDIA     | 1996 | 11289159232 |\n| JAPAN     | JAPAN     | 1996 | 11132409590 |\n| INDIA     | INDIA     | 1996 | 11064146206 |\n| INDONESIA | VIETNAM   | 1996 | 10877028774 |\n| CHINA     | VIETNAM   | 1996 | 10869545636 |\n| JAPAN     | VIETNAM   | 1996 | 10668555098 |\n| INDIA     | VIETNAM   | 1996 | 10587783062 |\n| CHINA     | INDONESIA | 1997 | 13306469392 |\n| INDONESIA | CHINA     | 1997 | 13154792628 |\n| CHINA     | CHINA     | 1997 | 12927589590 |\n| JAPAN     | INDONESIA | 1997 | 12858540252 |\n| INDONESIA | INDONESIA | 1997 | 12796855642 |\n| VIETNAM   | INDONESIA | 1997 | 12727166240 |\n| CHINA     | JAPAN     | 1997 | 12569467036 |\n| VIETNAM   | CHINA     | 1997 | 12328437446 |\n| INDIA     | CHINA     | 1997 | 12306564428 |\n| CHINA     | INDIA     | 1997 | 12168567966 |\n| INDONESIA | JAPAN     | 1997 | 12002855912 |\n| INDIA     | INDONESIA | 1997 | 11966878600 |\n| JAPAN     | CHINA     | 1997 | 11947699374 |\n| CHINA     | VIETNAM   | 1997 | 11816508352 |\n| JAPAN     | INDIA     | 1997 | 11593843984 |\n| JAPAN     | JAPAN     | 1997 | 11580900078 |\n| INDONESIA | INDIA     | 1997 | 11578734210 |\n| VIETNAM   | INDIA     | 1997 | 11460243216 |\n| INDIA     | INDIA     | 1997 | 11386057814 |\n| VIETNAM   | JAPAN     | 1997 | 11378690460 |\n| INDONESIA | VIETNAM   | 1997 | 11331356264 |\n| VIETNAM   | VIETNAM   | 1997 | 11240502648 |\n| INDIA     | JAPAN     | 1997 | 11175655826 |\n| JAPAN     | VIETNAM   | 1997 | 10499749228 |\n| INDIA     | VIETNAM   | 1997 | 10007249674 |\n+-----------+-----------+------+-------------+\n\n-- Q3.2\n+------------+------------+------+------------+\n| c_city     | s_city     | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED ST4 | UNITED ST1 | 1992 |  204054910 |\n| UNITED ST1 | UNITED ST0 | 1992 |  193978982 |\n| UNITED ST7 | UNITED ST0 | 1992 |  192156020 |\n| UNITED ST9 | UNITED ST0 | 1992 |  189626588 |\n| UNITED ST4 | UNITED ST0 | 1992 |  189288484 |\n| UNITED ST2 | UNITED ST4 | 1992 |  182361000 |\n| UNITED ST5 | UNITED ST0 | 1992 |  180864600 |\n| UNITED ST6 | UNITED ST7 | 1992 |  175316534 |\n| UNITED ST3 | UNITED ST9 | 1992 |  172284096 |\n| UNITED ST6 | UNITED ST5 | 1992 |  171765932 |\n| UNITED ST7 | UNITED ST3 | 1992 |  167531332 |\n| UNITED ST2 | UNITED ST9 | 1992 |  167411236 |\n| UNITED ST4 | UNITED ST6 | 1992 |  163772748 |\n| UNITED ST2 | UNITED ST1 | 1992 |  163678330 |\n| UNITED ST9 | UNITED ST1 | 1992 |  161590604 |\n| UNITED ST6 | UNITED ST3 | 1992 |  157556436 |\n| UNITED ST6 | UNITED ST0 | 1992 |  157393912 |\n| UNITED ST0 | UNITED ST1 | 1992 |  154534792 |\n| UNITED ST0 | UNITED ST0 | 1992 |  151244244 |\n| UNITED ST1 | UNITED ST9 | 1992 |  150734118 |\n| UNITED ST3 | UNITED ST1 | 1992 |  147274980 |\n| UNITED ST2 | UNITED ST0 | 1992 |  144420436 |\n| UNITED ST1 | UNITED ST7 | 1992 |  142945946 |\n| UNITED ST6 | UNITED ST4 | 1992 |  142173888 |\n| UNITED ST4 | UNITED ST4 | 1992 |  140222670 |\n| UNITED ST6 | UNITED ST1 | 1992 |  138817376 |\n| UNITED ST4 | UNITED ST3 | 1992 |  138003574 |\n| UNITED ST5 | UNITED ST7 | 1992 |  136667302 |\n| UNITED ST4 | UNITED ST9 | 1992 |  135675940 |\n| UNITED ST7 | UNITED ST6 | 1992 |  131026410 |\n| UNITED ST4 | UNITED ST5 | 1992 |  130115744 |\n| UNITED ST7 | UNITED ST4 | 1992 |  129801776 |\n| UNITED ST1 | UNITED ST1 | 1992 |  129338140 |\n| UNITED ST3 | UNITED ST5 | 1992 |  128478096 |\n| UNITED ST0 | UNITED ST9 | 1992 |  127959992 |\n| UNITED ST3 | UNITED ST4 | 1992 |  126289544 |\n| UNITED ST5 | UNITED ST6 | 1992 |  125256186 |\n| UNITED ST4 | UNITED ST7 | 1992 |  125058752 |\n| UNITED ST3 | UNITED ST0 | 1992 |  124883312 |\n| UNITED ST9 | UNITED ST4 | 1992 |  122979026 |\n| UNITED ST8 | UNITED ST6 | 1992 |  121080880 |\n| UNITED ST7 | UNITED ST9 | 1992 |  120652084 |\n| UNITED ST7 | UNITED ST7 | 1992 |  120242772 |\n| UNITED ST5 | UNITED ST1 | 1992 |  119890574 |\n| UNITED ST5 | UNITED ST4 | 1992 |  115251254 |\n| UNITED ST7 | UNITED ST5 | 1992 |  115133604 |\n| UNITED ST2 | UNITED ST5 | 1992 |  114042730 |\n| UNITED ST9 | UNITED ST7 | 1992 |  113766718 |\n| UNITED ST0 | UNITED ST3 | 1992 |  112718634 |\n| UNITED ST1 | UNITED ST3 | 1992 |  111454948 |\n| UNITED ST5 | UNITED ST3 | 1992 |  107927106 |\n| UNITED ST0 | UNITED ST7 | 1992 |  101166818 |\n| UNITED ST5 | UNITED ST9 | 1992 |  100382182 |\n| UNITED ST7 | UNITED ST1 | 1992 |  100334416 |\n| UNITED ST0 | UNITED ST8 | 1992 |   99465280 |\n| UNITED ST0 | UNITED ST4 | 1992 |   99353614 |\n| UNITED ST9 | UNITED ST3 | 1992 |   95362330 |\n| UNITED ST8 | UNITED ST4 | 1992 |   93514038 |\n| UNITED ST3 | UNITED ST3 | 1992 |   90174432 |\n| UNITED ST8 | UNITED ST0 | 1992 |   88737678 |\n| UNITED ST0 | UNITED ST6 | 1992 |   84943612 |\n| UNITED ST6 | UNITED ST8 | 1992 |   84927380 |\n| UNITED ST8 | UNITED ST7 | 1992 |   83795802 |\n| UNITED ST3 | UNITED ST8 | 1992 |   82551528 |\n| UNITED ST6 | UNITED ST9 | 1992 |   81183442 |\n| UNITED ST0 | UNITED ST5 | 1992 |   80241772 |\n| UNITED ST1 | UNITED ST4 | 1992 |   78652692 |\n| UNITED ST3 | UNITED ST7 | 1992 |   78057158 |\n| UNITED ST3 | UNITED ST6 | 1992 |   77597430 |\n| UNITED ST9 | UNITED ST9 | 1992 |   72096686 |\n| UNITED ST2 | UNITED ST8 | 1992 |   72092898 |\n| UNITED ST2 | UNITED ST3 | 1992 |   71963926 |\n| UNITED ST8 | UNITED ST1 | 1992 |   71361504 |\n| UNITED ST1 | UNITED ST6 | 1992 |   70809980 |\n| UNITED ST8 | UNITED ST5 | 1992 |   70375220 |\n| UNITED ST1 | UNITED ST5 | 1992 |   67942502 |\n| UNITED ST5 | UNITED ST8 | 1992 |   67756106 |\n| UNITED ST2 | UNITED ST7 | 1992 |   67405558 |\n| UNITED ST8 | UNITED ST3 | 1992 |   61898648 |\n| UNITED ST8 | UNITED ST8 | 1992 |   58618216 |\n| UNITED ST5 | UNITED ST5 | 1992 |   58559136 |\n| UNITED ST1 | UNITED ST8 | 1992 |   57131158 |\n| UNITED ST9 | UNITED ST5 | 1992 |   56150008 |\n| UNITED ST2 | UNITED ST6 | 1992 |   55627478 |\n| UNITED ST0 | UNITED ST2 | 1992 |   55437466 |\n| UNITED ST2 | UNITED ST2 | 1992 |   51487308 |\n| UNITED ST8 | UNITED ST9 | 1992 |   45368942 |\n| UNITED ST4 | UNITED ST8 | 1992 |   43856884 |\n| UNITED ST9 | UNITED ST8 | 1992 |   42772200 |\n| UNITED ST5 | UNITED ST2 | 1992 |   40991634 |\n| UNITED ST6 | UNITED ST6 | 1992 |   36274210 |\n| UNITED ST9 | UNITED ST6 | 1992 |   31759136 |\n| UNITED ST4 | UNITED ST2 | 1992 |   24123690 |\n| UNITED ST7 | UNITED ST8 | 1992 |   23791404 |\n| UNITED ST6 | UNITED ST2 | 1992 |   23641396 |\n| UNITED ST9 | UNITED ST2 | 1992 |   23246354 |\n| UNITED ST8 | UNITED ST2 | 1992 |   21943122 |\n| UNITED ST1 | UNITED ST2 | 1992 |   15413456 |\n| UNITED ST7 | UNITED ST2 | 1992 |    9886408 |\n| UNITED ST3 | UNITED ST2 | 1992 |    2194416 |\n| UNITED ST0 | UNITED ST9 | 1993 |  219668080 |\n| UNITED ST7 | UNITED ST0 | 1993 |  219576048 |\n| UNITED ST5 | UNITED ST0 | 1993 |  213645194 |\n| UNITED ST0 | UNITED ST0 | 1993 |  213485096 |\n| UNITED ST1 | UNITED ST0 | 1993 |  198611904 |\n| UNITED ST4 | UNITED ST4 | 1993 |  196300930 |\n| UNITED ST3 | UNITED ST4 | 1993 |  184987840 |\n| UNITED ST0 | UNITED ST1 | 1993 |  182393186 |\n| UNITED ST4 | UNITED ST1 | 1993 |  177042846 |\n| UNITED ST8 | UNITED ST0 | 1993 |  176712742 |\n| UNITED ST4 | UNITED ST7 | 1993 |  176344396 |\n| UNITED ST4 | UNITED ST0 | 1993 |  173836916 |\n| UNITED ST6 | UNITED ST3 | 1993 |  166834322 |\n| UNITED ST6 | UNITED ST1 | 1993 |  166691878 |\n| UNITED ST7 | UNITED ST9 | 1993 |  160621402 |\n| UNITED ST3 | UNITED ST1 | 1993 |  156460556 |\n| UNITED ST6 | UNITED ST7 | 1993 |  156394588 |\n| UNITED ST5 | UNITED ST9 | 1993 |  152573078 |\n| UNITED ST0 | UNITED ST3 | 1993 |  152342566 |\n| UNITED ST5 | UNITED ST8 | 1993 |  148718558 |\n| UNITED ST9 | UNITED ST1 | 1993 |  148118838 |\n| UNITED ST4 | UNITED ST9 | 1993 |  146593918 |\n| UNITED ST5 | UNITED ST1 | 1993 |  142909246 |\n| UNITED ST6 | UNITED ST4 | 1993 |  139293826 |\n| UNITED ST2 | UNITED ST1 | 1993 |  139263402 |\n| UNITED ST6 | UNITED ST0 | 1993 |  136495078 |\n| UNITED ST7 | UNITED ST7 | 1993 |  136219640 |\n| UNITED ST2 | UNITED ST3 | 1993 |  133944876 |\n| UNITED ST3 | UNITED ST0 | 1993 |  133253852 |\n| UNITED ST9 | UNITED ST7 | 1993 |  133250966 |\n| UNITED ST1 | UNITED ST8 | 1993 |  132292396 |\n| UNITED ST2 | UNITED ST7 | 1993 |  128370028 |\n| UNITED ST5 | UNITED ST4 | 1993 |  126831278 |\n| UNITED ST9 | UNITED ST9 | 1993 |  126521526 |\n| UNITED ST1 | UNITED ST4 | 1993 |  125768694 |\n| UNITED ST7 | UNITED ST4 | 1993 |  123313226 |\n| UNITED ST3 | UNITED ST6 | 1993 |  117169616 |\n| UNITED ST2 | UNITED ST4 | 1993 |  113300782 |\n| UNITED ST3 | UNITED ST5 | 1993 |  111814610 |\n| UNITED ST6 | UNITED ST9 | 1993 |  109801884 |\n| UNITED ST1 | UNITED ST7 | 1993 |  109702366 |\n| UNITED ST3 | UNITED ST9 | 1993 |  109525192 |\n| UNITED ST8 | UNITED ST6 | 1993 |  109266124 |\n| UNITED ST8 | UNITED ST3 | 1993 |  108099748 |\n| UNITED ST5 | UNITED ST7 | 1993 |  105491076 |\n| UNITED ST0 | UNITED ST5 | 1993 |  105402104 |\n| UNITED ST1 | UNITED ST9 | 1993 |  105029804 |\n| UNITED ST8 | UNITED ST5 | 1993 |  104475674 |\n| UNITED ST1 | UNITED ST3 | 1993 |  104195892 |\n| UNITED ST8 | UNITED ST4 | 1993 |  102838712 |\n| UNITED ST0 | UNITED ST6 | 1993 |  100864564 |\n| UNITED ST5 | UNITED ST5 | 1993 |  100714378 |\n| UNITED ST3 | UNITED ST7 | 1993 |  100270896 |\n| UNITED ST0 | UNITED ST4 | 1993 |   98520134 |\n| UNITED ST0 | UNITED ST7 | 1993 |   97592720 |\n| UNITED ST2 | UNITED ST9 | 1993 |   96377014 |\n| UNITED ST1 | UNITED ST1 | 1993 |   95077220 |\n| UNITED ST9 | UNITED ST3 | 1993 |   93887294 |\n| UNITED ST7 | UNITED ST5 | 1993 |   89527384 |\n| UNITED ST1 | UNITED ST6 | 1993 |   89457080 |\n| UNITED ST8 | UNITED ST1 | 1993 |   88830868 |\n| UNITED ST7 | UNITED ST8 | 1993 |   87805256 |\n| UNITED ST9 | UNITED ST6 | 1993 |   87734320 |\n| UNITED ST2 | UNITED ST0 | 1993 |   85690970 |\n| UNITED ST3 | UNITED ST8 | 1993 |   84503696 |\n| UNITED ST0 | UNITED ST8 | 1993 |   84005364 |\n| UNITED ST4 | UNITED ST8 | 1993 |   83315164 |\n| UNITED ST1 | UNITED ST5 | 1993 |   81387026 |\n| UNITED ST9 | UNITED ST5 | 1993 |   79370538 |\n| UNITED ST7 | UNITED ST3 | 1993 |   79047722 |\n| UNITED ST8 | UNITED ST8 | 1993 |   77580470 |\n| UNITED ST8 | UNITED ST9 | 1993 |   77032722 |\n| UNITED ST2 | UNITED ST5 | 1993 |   74813690 |\n| UNITED ST9 | UNITED ST8 | 1993 |   74369392 |\n| UNITED ST8 | UNITED ST7 | 1993 |   73804436 |\n| UNITED ST6 | UNITED ST8 | 1993 |   72913482 |\n| UNITED ST7 | UNITED ST1 | 1993 |   68782318 |\n| UNITED ST6 | UNITED ST5 | 1993 |   68458164 |\n| UNITED ST5 | UNITED ST3 | 1993 |   68063622 |\n| UNITED ST2 | UNITED ST8 | 1993 |   66890892 |\n| UNITED ST4 | UNITED ST3 | 1993 |   66258824 |\n| UNITED ST6 | UNITED ST6 | 1993 |   66101326 |\n| UNITED ST9 | UNITED ST0 | 1993 |   65306610 |\n| UNITED ST4 | UNITED ST6 | 1993 |   61398510 |\n| UNITED ST9 | UNITED ST4 | 1993 |   61289374 |\n| UNITED ST4 | UNITED ST5 | 1993 |   58239188 |\n| UNITED ST7 | UNITED ST6 | 1993 |   54201004 |\n| UNITED ST4 | UNITED ST2 | 1993 |   54025356 |\n| UNITED ST2 | UNITED ST6 | 1993 |   52964452 |\n| UNITED ST5 | UNITED ST6 | 1993 |   50715358 |\n| UNITED ST3 | UNITED ST3 | 1993 |   43554288 |\n| UNITED ST3 | UNITED ST2 | 1993 |   43118146 |\n| UNITED ST5 | UNITED ST2 | 1993 |   41220484 |\n| UNITED ST7 | UNITED ST2 | 1993 |   40438608 |\n| UNITED ST6 | UNITED ST2 | 1993 |   37628734 |\n| UNITED ST9 | UNITED ST2 | 1993 |   35436780 |\n| UNITED ST1 | UNITED ST2 | 1993 |   33689076 |\n| UNITED ST0 | UNITED ST2 | 1993 |   30084290 |\n| UNITED ST2 | UNITED ST2 | 1993 |   29043990 |\n| UNITED ST8 | UNITED ST2 | 1993 |   19968732 |\n| UNITED ST8 | UNITED ST0 | 1994 |  198441578 |\n| UNITED ST3 | UNITED ST9 | 1994 |  194952370 |\n| UNITED ST6 | UNITED ST1 | 1994 |  193874294 |\n| UNITED ST6 | UNITED ST9 | 1994 |  189366618 |\n| UNITED ST9 | UNITED ST1 | 1994 |  180881896 |\n| UNITED ST0 | UNITED ST9 | 1994 |  179730404 |\n| UNITED ST5 | UNITED ST7 | 1994 |  178179922 |\n| UNITED ST9 | UNITED ST0 | 1994 |  175341146 |\n| UNITED ST3 | UNITED ST1 | 1994 |  171047306 |\n| UNITED ST4 | UNITED ST9 | 1994 |  167644786 |\n| UNITED ST0 | UNITED ST0 | 1994 |  167053754 |\n| UNITED ST7 | UNITED ST0 | 1994 |  164531072 |\n| UNITED ST2 | UNITED ST1 | 1994 |  162600178 |\n| UNITED ST5 | UNITED ST0 | 1994 |  157296114 |\n| UNITED ST4 | UNITED ST7 | 1994 |  153908280 |\n| UNITED ST4 | UNITED ST4 | 1994 |  153674762 |\n| UNITED ST0 | UNITED ST1 | 1994 |  153226758 |\n| UNITED ST1 | UNITED ST3 | 1994 |  151984918 |\n| UNITED ST7 | UNITED ST1 | 1994 |  150641598 |\n| UNITED ST4 | UNITED ST0 | 1994 |  147438680 |\n| UNITED ST5 | UNITED ST1 | 1994 |  147016836 |\n| UNITED ST4 | UNITED ST1 | 1994 |  144439114 |\n| UNITED ST2 | UNITED ST9 | 1994 |  139342108 |\n| UNITED ST6 | UNITED ST5 | 1994 |  132923068 |\n| UNITED ST2 | UNITED ST3 | 1994 |  131241520 |\n| UNITED ST3 | UNITED ST0 | 1994 |  131045454 |\n| UNITED ST5 | UNITED ST3 | 1994 |  130669822 |\n| UNITED ST7 | UNITED ST4 | 1994 |  129557430 |\n| UNITED ST3 | UNITED ST4 | 1994 |  126824730 |\n| UNITED ST8 | UNITED ST4 | 1994 |  124283362 |\n| UNITED ST0 | UNITED ST4 | 1994 |  123039488 |\n| UNITED ST0 | UNITED ST7 | 1994 |  122961640 |\n| UNITED ST0 | UNITED ST6 | 1994 |  122577556 |\n| UNITED ST2 | UNITED ST0 | 1994 |  120364306 |\n| UNITED ST6 | UNITED ST4 | 1994 |  119659978 |\n| UNITED ST4 | UNITED ST5 | 1994 |  118794056 |\n| UNITED ST8 | UNITED ST9 | 1994 |  117333812 |\n| UNITED ST4 | UNITED ST6 | 1994 |  117266964 |\n| UNITED ST5 | UNITED ST5 | 1994 |  112470426 |\n| UNITED ST6 | UNITED ST3 | 1994 |  112246476 |\n| UNITED ST2 | UNITED ST4 | 1994 |  111358754 |\n| UNITED ST8 | UNITED ST3 | 1994 |  110407682 |\n| UNITED ST1 | UNITED ST1 | 1994 |  108766348 |\n| UNITED ST1 | UNITED ST7 | 1994 |  107706212 |\n| UNITED ST6 | UNITED ST0 | 1994 |  107457706 |\n| UNITED ST5 | UNITED ST9 | 1994 |  106734662 |\n| UNITED ST9 | UNITED ST9 | 1994 |  103961698 |\n| UNITED ST5 | UNITED ST4 | 1994 |  103599186 |\n| UNITED ST7 | UNITED ST9 | 1994 |  100288170 |\n| UNITED ST7 | UNITED ST7 | 1994 |   92892884 |\n| UNITED ST6 | UNITED ST6 | 1994 |   92399444 |\n| UNITED ST7 | UNITED ST5 | 1994 |   91790728 |\n| UNITED ST3 | UNITED ST3 | 1994 |   91254306 |\n| UNITED ST8 | UNITED ST5 | 1994 |   89106112 |\n| UNITED ST9 | UNITED ST4 | 1994 |   87821522 |\n| UNITED ST1 | UNITED ST0 | 1994 |   86450402 |\n| UNITED ST1 | UNITED ST9 | 1994 |   86000074 |\n| UNITED ST7 | UNITED ST8 | 1994 |   85552934 |\n| UNITED ST0 | UNITED ST5 | 1994 |   83616602 |\n| UNITED ST2 | UNITED ST6 | 1994 |   83052210 |\n| UNITED ST1 | UNITED ST4 | 1994 |   82763116 |\n| UNITED ST3 | UNITED ST7 | 1994 |   81870262 |\n| UNITED ST8 | UNITED ST1 | 1994 |   80304192 |\n| UNITED ST9 | UNITED ST8 | 1994 |   78557616 |\n| UNITED ST5 | UNITED ST6 | 1994 |   77316902 |\n| UNITED ST2 | UNITED ST5 | 1994 |   75280634 |\n| UNITED ST8 | UNITED ST7 | 1994 |   75201374 |\n| UNITED ST9 | UNITED ST5 | 1994 |   74293452 |\n| UNITED ST6 | UNITED ST7 | 1994 |   74115616 |\n| UNITED ST8 | UNITED ST6 | 1994 |   73553138 |\n| UNITED ST3 | UNITED ST6 | 1994 |   72580514 |\n| UNITED ST9 | UNITED ST3 | 1994 |   71693000 |\n| UNITED ST2 | UNITED ST8 | 1994 |   67535548 |\n| UNITED ST0 | UNITED ST8 | 1994 |   63690866 |\n| UNITED ST4 | UNITED ST3 | 1994 |   63198866 |\n| UNITED ST9 | UNITED ST7 | 1994 |   63172346 |\n| UNITED ST1 | UNITED ST6 | 1994 |   62574652 |\n| UNITED ST1 | UNITED ST8 | 1994 |   60490306 |\n| UNITED ST7 | UNITED ST3 | 1994 |   58849680 |\n| UNITED ST9 | UNITED ST6 | 1994 |   58425854 |\n| UNITED ST0 | UNITED ST3 | 1994 |   54655658 |\n| UNITED ST6 | UNITED ST8 | 1994 |   53185992 |\n| UNITED ST3 | UNITED ST5 | 1994 |   52395750 |\n| UNITED ST6 | UNITED ST2 | 1994 |   51618000 |\n| UNITED ST1 | UNITED ST5 | 1994 |   49878276 |\n| UNITED ST7 | UNITED ST6 | 1994 |   49263874 |\n| UNITED ST1 | UNITED ST2 | 1994 |   47113172 |\n| UNITED ST4 | UNITED ST2 | 1994 |   46071784 |\n| UNITED ST2 | UNITED ST7 | 1994 |   44365516 |\n| UNITED ST0 | UNITED ST2 | 1994 |   44035908 |\n| UNITED ST4 | UNITED ST8 | 1994 |   41370704 |\n| UNITED ST7 | UNITED ST2 | 1994 |   39310162 |\n| UNITED ST5 | UNITED ST8 | 1994 |   37863782 |\n| UNITED ST2 | UNITED ST2 | 1994 |   36137314 |\n| UNITED ST3 | UNITED ST8 | 1994 |   31872102 |\n| UNITED ST8 | UNITED ST8 | 1994 |   20046824 |\n| UNITED ST3 | UNITED ST2 | 1994 |   19990468 |\n| UNITED ST9 | UNITED ST2 | 1994 |   19401978 |\n| UNITED ST5 | UNITED ST2 | 1994 |   14325592 |\n| UNITED ST8 | UNITED ST2 | 1994 |    7579252 |\n| UNITED ST5 | UNITED ST1 | 1995 |  239587338 |\n| UNITED ST4 | UNITED ST9 | 1995 |  198980136 |\n| UNITED ST7 | UNITED ST0 | 1995 |  196062590 |\n| UNITED ST6 | UNITED ST0 | 1995 |  183436942 |\n| UNITED ST4 | UNITED ST1 | 1995 |  181757306 |\n| UNITED ST0 | UNITED ST1 | 1995 |  181527198 |\n| UNITED ST8 | UNITED ST9 | 1995 |  177710178 |\n| UNITED ST7 | UNITED ST7 | 1995 |  173143248 |\n| UNITED ST3 | UNITED ST0 | 1995 |  168925466 |\n| UNITED ST9 | UNITED ST1 | 1995 |  165877934 |\n| UNITED ST2 | UNITED ST4 | 1995 |  164864610 |\n| UNITED ST1 | UNITED ST0 | 1995 |  163353246 |\n| UNITED ST5 | UNITED ST4 | 1995 |  162033522 |\n| UNITED ST7 | UNITED ST1 | 1995 |  159928724 |\n| UNITED ST5 | UNITED ST3 | 1995 |  156198260 |\n| UNITED ST5 | UNITED ST0 | 1995 |  155231492 |\n| UNITED ST9 | UNITED ST9 | 1995 |  153031916 |\n| UNITED ST7 | UNITED ST9 | 1995 |  150635418 |\n| UNITED ST4 | UNITED ST4 | 1995 |  149174142 |\n| UNITED ST9 | UNITED ST4 | 1995 |  145051372 |\n| UNITED ST1 | UNITED ST9 | 1995 |  144941740 |\n| UNITED ST4 | UNITED ST7 | 1995 |  138528814 |\n| UNITED ST6 | UNITED ST3 | 1995 |  135026124 |\n| UNITED ST2 | UNITED ST3 | 1995 |  130436258 |\n| UNITED ST2 | UNITED ST9 | 1995 |  130110356 |\n| UNITED ST7 | UNITED ST6 | 1995 |  130041342 |\n| UNITED ST3 | UNITED ST1 | 1995 |  129525630 |\n| UNITED ST1 | UNITED ST1 | 1995 |  128398664 |\n| UNITED ST6 | UNITED ST9 | 1995 |  126914210 |\n| UNITED ST0 | UNITED ST9 | 1995 |  126506998 |\n| UNITED ST5 | UNITED ST9 | 1995 |  124729794 |\n| UNITED ST4 | UNITED ST5 | 1995 |  124163010 |\n| UNITED ST1 | UNITED ST7 | 1995 |  123031482 |\n| UNITED ST2 | UNITED ST7 | 1995 |  120000416 |\n| UNITED ST8 | UNITED ST6 | 1995 |  117980808 |\n| UNITED ST1 | UNITED ST4 | 1995 |  115071198 |\n| UNITED ST0 | UNITED ST3 | 1995 |  112721416 |\n| UNITED ST8 | UNITED ST0 | 1995 |  110463328 |\n| UNITED ST5 | UNITED ST7 | 1995 |  107481518 |\n| UNITED ST2 | UNITED ST0 | 1995 |  105121676 |\n| UNITED ST3 | UNITED ST7 | 1995 |  103159096 |\n| UNITED ST9 | UNITED ST0 | 1995 |  103097242 |\n| UNITED ST6 | UNITED ST6 | 1995 |  101909354 |\n| UNITED ST5 | UNITED ST5 | 1995 |  100788014 |\n| UNITED ST7 | UNITED ST4 | 1995 |   99799090 |\n| UNITED ST3 | UNITED ST3 | 1995 |   96316178 |\n| UNITED ST6 | UNITED ST4 | 1995 |   95394482 |\n| UNITED ST9 | UNITED ST7 | 1995 |   92929178 |\n| UNITED ST4 | UNITED ST0 | 1995 |   92285798 |\n| UNITED ST1 | UNITED ST3 | 1995 |   91646112 |\n| UNITED ST2 | UNITED ST1 | 1995 |   90874680 |\n| UNITED ST6 | UNITED ST5 | 1995 |   90856304 |\n| UNITED ST8 | UNITED ST5 | 1995 |   89989726 |\n| UNITED ST7 | UNITED ST3 | 1995 |   87399468 |\n| UNITED ST9 | UNITED ST6 | 1995 |   86964988 |\n| UNITED ST2 | UNITED ST5 | 1995 |   86764834 |\n| UNITED ST6 | UNITED ST8 | 1995 |   83947840 |\n| UNITED ST0 | UNITED ST6 | 1995 |   81437884 |\n| UNITED ST3 | UNITED ST5 | 1995 |   80115630 |\n| UNITED ST7 | UNITED ST5 | 1995 |   78030586 |\n| UNITED ST0 | UNITED ST0 | 1995 |   77969004 |\n| UNITED ST6 | UNITED ST1 | 1995 |   76656704 |\n| UNITED ST4 | UNITED ST6 | 1995 |   76219048 |\n| UNITED ST3 | UNITED ST9 | 1995 |   74729246 |\n| UNITED ST4 | UNITED ST3 | 1995 |   74712792 |\n| UNITED ST2 | UNITED ST6 | 1995 |   74292576 |\n| UNITED ST9 | UNITED ST5 | 1995 |   72019848 |\n| UNITED ST1 | UNITED ST8 | 1995 |   69837586 |\n| UNITED ST8 | UNITED ST1 | 1995 |   68435560 |\n| UNITED ST0 | UNITED ST7 | 1995 |   66790626 |\n| UNITED ST1 | UNITED ST5 | 1995 |   63714904 |\n| UNITED ST8 | UNITED ST7 | 1995 |   61836404 |\n| UNITED ST2 | UNITED ST8 | 1995 |   61008378 |\n| UNITED ST3 | UNITED ST4 | 1995 |   60844692 |\n| UNITED ST5 | UNITED ST6 | 1995 |   60409474 |\n| UNITED ST8 | UNITED ST3 | 1995 |   58699876 |\n| UNITED ST0 | UNITED ST4 | 1995 |   58340076 |\n| UNITED ST1 | UNITED ST6 | 1995 |   54278806 |\n| UNITED ST7 | UNITED ST8 | 1995 |   52888980 |\n| UNITED ST6 | UNITED ST7 | 1995 |   47667954 |\n| UNITED ST4 | UNITED ST8 | 1995 |   46106472 |\n| UNITED ST4 | UNITED ST2 | 1995 |   45574006 |\n| UNITED ST3 | UNITED ST8 | 1995 |   45010478 |\n| UNITED ST9 | UNITED ST8 | 1995 |   42585054 |\n| UNITED ST8 | UNITED ST4 | 1995 |   38574622 |\n| UNITED ST8 | UNITED ST2 | 1995 |   36565980 |\n| UNITED ST9 | UNITED ST3 | 1995 |   35078204 |\n| UNITED ST3 | UNITED ST6 | 1995 |   33477060 |\n| UNITED ST0 | UNITED ST8 | 1995 |   32786498 |\n| UNITED ST5 | UNITED ST2 | 1995 |   29902046 |\n| UNITED ST2 | UNITED ST2 | 1995 |   26910062 |\n| UNITED ST5 | UNITED ST8 | 1995 |   26693864 |\n| UNITED ST3 | UNITED ST2 | 1995 |   25773658 |\n| UNITED ST9 | UNITED ST2 | 1995 |   25306724 |\n| UNITED ST0 | UNITED ST5 | 1995 |   22907418 |\n| UNITED ST6 | UNITED ST2 | 1995 |   22727102 |\n| UNITED ST8 | UNITED ST8 | 1995 |   22571734 |\n| UNITED ST1 | UNITED ST2 | 1995 |   15983352 |\n| UNITED ST0 | UNITED ST2 | 1995 |    9552920 |\n| UNITED ST7 | UNITED ST2 | 1995 |    7947130 |\n| UNITED ST6 | UNITED ST0 | 1996 |  264573526 |\n| UNITED ST4 | UNITED ST0 | 1996 |  213795126 |\n| UNITED ST5 | UNITED ST0 | 1996 |  209003958 |\n| UNITED ST0 | UNITED ST4 | 1996 |  206457498 |\n| UNITED ST9 | UNITED ST1 | 1996 |  203967654 |\n| UNITED ST1 | UNITED ST0 | 1996 |  189723108 |\n| UNITED ST0 | UNITED ST1 | 1996 |  183897554 |\n| UNITED ST6 | UNITED ST1 | 1996 |  179411740 |\n| UNITED ST2 | UNITED ST1 | 1996 |  176512310 |\n| UNITED ST1 | UNITED ST1 | 1996 |  174531696 |\n| UNITED ST4 | UNITED ST7 | 1996 |  167355628 |\n| UNITED ST6 | UNITED ST3 | 1996 |  164336458 |\n| UNITED ST2 | UNITED ST7 | 1996 |  160936954 |\n| UNITED ST8 | UNITED ST1 | 1996 |  157943512 |\n| UNITED ST7 | UNITED ST4 | 1996 |  155882022 |\n| UNITED ST1 | UNITED ST3 | 1996 |  155221810 |\n| UNITED ST9 | UNITED ST9 | 1996 |  154603480 |\n| UNITED ST0 | UNITED ST9 | 1996 |  151870418 |\n| UNITED ST7 | UNITED ST0 | 1996 |  151204890 |\n| UNITED ST3 | UNITED ST1 | 1996 |  149493398 |\n| UNITED ST7 | UNITED ST7 | 1996 |  148081288 |\n| UNITED ST4 | UNITED ST1 | 1996 |  145639734 |\n| UNITED ST5 | UNITED ST9 | 1996 |  145228228 |\n| UNITED ST1 | UNITED ST9 | 1996 |  139647538 |\n| UNITED ST9 | UNITED ST4 | 1996 |  139233228 |\n| UNITED ST6 | UNITED ST4 | 1996 |  138592010 |\n| UNITED ST2 | UNITED ST0 | 1996 |  134190244 |\n| UNITED ST5 | UNITED ST1 | 1996 |  130692778 |\n| UNITED ST6 | UNITED ST9 | 1996 |  126512364 |\n| UNITED ST4 | UNITED ST6 | 1996 |  124378656 |\n| UNITED ST0 | UNITED ST0 | 1996 |  123057710 |\n| UNITED ST8 | UNITED ST9 | 1996 |  120933382 |\n| UNITED ST3 | UNITED ST0 | 1996 |  120453680 |\n| UNITED ST8 | UNITED ST6 | 1996 |  119493310 |\n| UNITED ST2 | UNITED ST3 | 1996 |  119297196 |\n| UNITED ST0 | UNITED ST5 | 1996 |  115525790 |\n| UNITED ST8 | UNITED ST7 | 1996 |  115047850 |\n| UNITED ST2 | UNITED ST4 | 1996 |  114974114 |\n| UNITED ST6 | UNITED ST7 | 1996 |  114181238 |\n| UNITED ST3 | UNITED ST4 | 1996 |  109676518 |\n| UNITED ST4 | UNITED ST9 | 1996 |  108269680 |\n| UNITED ST1 | UNITED ST6 | 1996 |  108112732 |\n| UNITED ST3 | UNITED ST7 | 1996 |  107974436 |\n| UNITED ST2 | UNITED ST9 | 1996 |  106982830 |\n| UNITED ST4 | UNITED ST8 | 1996 |  106071324 |\n| UNITED ST9 | UNITED ST5 | 1996 |  105651844 |\n| UNITED ST7 | UNITED ST3 | 1996 |  104713772 |\n| UNITED ST6 | UNITED ST8 | 1996 |  104273568 |\n| UNITED ST1 | UNITED ST5 | 1996 |  102379298 |\n| UNITED ST8 | UNITED ST4 | 1996 |  102066108 |\n| UNITED ST1 | UNITED ST4 | 1996 |  100271094 |\n| UNITED ST3 | UNITED ST9 | 1996 |   99224608 |\n| UNITED ST9 | UNITED ST0 | 1996 |   99181402 |\n| UNITED ST3 | UNITED ST3 | 1996 |   98527592 |\n| UNITED ST9 | UNITED ST7 | 1996 |   97597518 |\n| UNITED ST7 | UNITED ST1 | 1996 |   97568350 |\n| UNITED ST9 | UNITED ST6 | 1996 |   97370126 |\n| UNITED ST2 | UNITED ST5 | 1996 |   94057952 |\n| UNITED ST9 | UNITED ST3 | 1996 |   94042036 |\n| UNITED ST2 | UNITED ST8 | 1996 |   93730226 |\n| UNITED ST4 | UNITED ST3 | 1996 |   92921880 |\n| UNITED ST6 | UNITED ST5 | 1996 |   92060208 |\n| UNITED ST2 | UNITED ST6 | 1996 |   90833298 |\n| UNITED ST8 | UNITED ST5 | 1996 |   86960946 |\n| UNITED ST5 | UNITED ST5 | 1996 |   86041444 |\n| UNITED ST6 | UNITED ST6 | 1996 |   85846064 |\n| UNITED ST4 | UNITED ST5 | 1996 |   85616824 |\n| UNITED ST3 | UNITED ST6 | 1996 |   83763256 |\n| UNITED ST1 | UNITED ST7 | 1996 |   83443012 |\n| UNITED ST5 | UNITED ST7 | 1996 |   81892660 |\n| UNITED ST8 | UNITED ST0 | 1996 |   79690854 |\n| UNITED ST8 | UNITED ST3 | 1996 |   79071880 |\n| UNITED ST1 | UNITED ST8 | 1996 |   78861764 |\n| UNITED ST5 | UNITED ST6 | 1996 |   76664088 |\n| UNITED ST0 | UNITED ST6 | 1996 |   74464124 |\n| UNITED ST7 | UNITED ST6 | 1996 |   73071256 |\n| UNITED ST9 | UNITED ST8 | 1996 |   72224602 |\n| UNITED ST3 | UNITED ST8 | 1996 |   67849464 |\n| UNITED ST3 | UNITED ST5 | 1996 |   67434878 |\n| UNITED ST5 | UNITED ST4 | 1996 |   66849718 |\n| UNITED ST5 | UNITED ST3 | 1996 |   65839852 |\n| UNITED ST4 | UNITED ST4 | 1996 |   65575990 |\n| UNITED ST7 | UNITED ST5 | 1996 |   65568448 |\n| UNITED ST5 | UNITED ST8 | 1996 |   64831364 |\n| UNITED ST0 | UNITED ST7 | 1996 |   62782362 |\n| UNITED ST0 | UNITED ST3 | 1996 |   59591330 |\n| UNITED ST7 | UNITED ST9 | 1996 |   50056182 |\n| UNITED ST7 | UNITED ST8 | 1996 |   48697702 |\n| UNITED ST6 | UNITED ST2 | 1996 |   40895694 |\n| UNITED ST8 | UNITED ST8 | 1996 |   32681206 |\n| UNITED ST0 | UNITED ST8 | 1996 |   30336524 |\n| UNITED ST4 | UNITED ST2 | 1996 |   24903734 |\n| UNITED ST1 | UNITED ST2 | 1996 |   20165072 |\n| UNITED ST5 | UNITED ST2 | 1996 |   17088466 |\n| UNITED ST7 | UNITED ST2 | 1996 |   16780940 |\n| UNITED ST9 | UNITED ST2 | 1996 |   16216070 |\n| UNITED ST8 | UNITED ST2 | 1996 |   14056668 |\n| UNITED ST0 | UNITED ST2 | 1996 |   13814398 |\n| UNITED ST3 | UNITED ST2 | 1996 |    8623600 |\n| UNITED ST5 | UNITED ST0 | 1997 |  242915532 |\n| UNITED ST0 | UNITED ST9 | 1997 |  239712536 |\n| UNITED ST5 | UNITED ST1 | 1997 |  213800322 |\n| UNITED ST9 | UNITED ST9 | 1997 |  212445590 |\n| UNITED ST5 | UNITED ST4 | 1997 |  206865854 |\n| UNITED ST7 | UNITED ST1 | 1997 |  202653880 |\n| UNITED ST5 | UNITED ST9 | 1997 |  194785280 |\n| UNITED ST8 | UNITED ST0 | 1997 |  178869690 |\n| UNITED ST1 | UNITED ST3 | 1997 |  170351276 |\n| UNITED ST4 | UNITED ST1 | 1997 |  169222376 |\n| UNITED ST4 | UNITED ST7 | 1997 |  169213992 |\n| UNITED ST1 | UNITED ST4 | 1997 |  166185138 |\n| UNITED ST0 | UNITED ST1 | 1997 |  160334278 |\n| UNITED ST4 | UNITED ST9 | 1997 |  159395854 |\n| UNITED ST1 | UNITED ST0 | 1997 |  155335732 |\n| UNITED ST2 | UNITED ST0 | 1997 |  155182940 |\n| UNITED ST1 | UNITED ST7 | 1997 |  154091444 |\n| UNITED ST2 | UNITED ST7 | 1997 |  152967604 |\n| UNITED ST1 | UNITED ST1 | 1997 |  152680888 |\n| UNITED ST0 | UNITED ST7 | 1997 |  145154980 |\n| UNITED ST4 | UNITED ST0 | 1997 |  139751608 |\n| UNITED ST6 | UNITED ST3 | 1997 |  139451012 |\n| UNITED ST2 | UNITED ST9 | 1997 |  139087968 |\n| UNITED ST7 | UNITED ST0 | 1997 |  138708624 |\n| UNITED ST9 | UNITED ST7 | 1997 |  138105260 |\n| UNITED ST8 | UNITED ST3 | 1997 |  133836788 |\n| UNITED ST0 | UNITED ST0 | 1997 |  132617032 |\n| UNITED ST9 | UNITED ST0 | 1997 |  132133582 |\n| UNITED ST2 | UNITED ST3 | 1997 |  130858906 |\n| UNITED ST2 | UNITED ST1 | 1997 |  130792270 |\n| UNITED ST4 | UNITED ST4 | 1997 |  125064692 |\n| UNITED ST9 | UNITED ST1 | 1997 |  124836812 |\n| UNITED ST3 | UNITED ST7 | 1997 |  122190600 |\n| UNITED ST7 | UNITED ST4 | 1997 |  120246988 |\n| UNITED ST4 | UNITED ST3 | 1997 |  119268306 |\n| UNITED ST3 | UNITED ST4 | 1997 |  116712282 |\n| UNITED ST6 | UNITED ST9 | 1997 |  116462526 |\n| UNITED ST6 | UNITED ST4 | 1997 |  114430044 |\n| UNITED ST2 | UNITED ST4 | 1997 |  114025222 |\n| UNITED ST5 | UNITED ST3 | 1997 |  113579864 |\n| UNITED ST9 | UNITED ST5 | 1997 |  112183840 |\n| UNITED ST6 | UNITED ST0 | 1997 |  111649838 |\n| UNITED ST6 | UNITED ST1 | 1997 |  110235418 |\n| UNITED ST7 | UNITED ST9 | 1997 |  110079940 |\n| UNITED ST5 | UNITED ST7 | 1997 |  109068630 |\n| UNITED ST3 | UNITED ST1 | 1997 |  108301366 |\n| UNITED ST3 | UNITED ST0 | 1997 |  108100344 |\n| UNITED ST3 | UNITED ST9 | 1997 |  102740616 |\n| UNITED ST1 | UNITED ST5 | 1997 |  102104220 |\n| UNITED ST6 | UNITED ST7 | 1997 |   99591698 |\n| UNITED ST5 | UNITED ST6 | 1997 |   98060032 |\n| UNITED ST1 | UNITED ST9 | 1997 |   97888222 |\n| UNITED ST3 | UNITED ST3 | 1997 |   96770466 |\n| UNITED ST0 | UNITED ST5 | 1997 |   95976836 |\n| UNITED ST2 | UNITED ST8 | 1997 |   92783818 |\n| UNITED ST4 | UNITED ST6 | 1997 |   92473698 |\n| UNITED ST9 | UNITED ST3 | 1997 |   92243448 |\n| UNITED ST8 | UNITED ST9 | 1997 |   91705592 |\n| UNITED ST7 | UNITED ST8 | 1997 |   90952532 |\n| UNITED ST8 | UNITED ST1 | 1997 |   86568278 |\n| UNITED ST7 | UNITED ST7 | 1997 |   85133206 |\n| UNITED ST0 | UNITED ST4 | 1997 |   82387606 |\n| UNITED ST8 | UNITED ST7 | 1997 |   81756858 |\n| UNITED ST8 | UNITED ST8 | 1997 |   81498800 |\n| UNITED ST2 | UNITED ST5 | 1997 |   81325772 |\n| UNITED ST0 | UNITED ST3 | 1997 |   80157016 |\n| UNITED ST6 | UNITED ST8 | 1997 |   75976890 |\n| UNITED ST9 | UNITED ST6 | 1997 |   75193764 |\n| UNITED ST6 | UNITED ST5 | 1997 |   75143576 |\n| UNITED ST2 | UNITED ST2 | 1997 |   74068666 |\n| UNITED ST7 | UNITED ST5 | 1997 |   73779472 |\n| UNITED ST8 | UNITED ST4 | 1997 |   73201168 |\n| UNITED ST3 | UNITED ST6 | 1997 |   72151688 |\n| UNITED ST7 | UNITED ST3 | 1997 |   70337844 |\n| UNITED ST2 | UNITED ST6 | 1997 |   68548934 |\n| UNITED ST5 | UNITED ST8 | 1997 |   65821892 |\n| UNITED ST3 | UNITED ST5 | 1997 |   65623926 |\n| UNITED ST4 | UNITED ST8 | 1997 |   65199472 |\n| UNITED ST5 | UNITED ST5 | 1997 |   65137776 |\n| UNITED ST4 | UNITED ST5 | 1997 |   63991736 |\n| UNITED ST9 | UNITED ST4 | 1997 |   63530956 |\n| UNITED ST7 | UNITED ST2 | 1997 |   62819180 |\n| UNITED ST9 | UNITED ST8 | 1997 |   62544770 |\n| UNITED ST0 | UNITED ST8 | 1997 |   60482740 |\n| UNITED ST3 | UNITED ST8 | 1997 |   58204440 |\n| UNITED ST7 | UNITED ST6 | 1997 |   55079862 |\n| UNITED ST8 | UNITED ST5 | 1997 |   53347486 |\n| UNITED ST6 | UNITED ST6 | 1997 |   49966582 |\n| UNITED ST0 | UNITED ST2 | 1997 |   47168458 |\n| UNITED ST0 | UNITED ST6 | 1997 |   45848092 |\n| UNITED ST1 | UNITED ST2 | 1997 |   41198260 |\n| UNITED ST8 | UNITED ST6 | 1997 |   40146000 |\n| UNITED ST1 | UNITED ST6 | 1997 |   36410652 |\n| UNITED ST1 | UNITED ST8 | 1997 |   30750516 |\n| UNITED ST6 | UNITED ST2 | 1997 |   29493360 |\n| UNITED ST5 | UNITED ST2 | 1997 |   27726876 |\n| UNITED ST8 | UNITED ST2 | 1997 |   24107412 |\n| UNITED ST3 | UNITED ST2 | 1997 |   15783756 |\n| UNITED ST4 | UNITED ST2 | 1997 |    5696314 |\n| UNITED ST9 | UNITED ST2 | 1997 |    5323304 |\n+------------+------------+------+------------+\n\n-- Q3.3\n+------------+------------+------+------------+\n| c_city     | s_city     | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED KI1 | UNITED KI1 | 1992 |   93471990 |\n| UNITED KI5 | UNITED KI1 | 1992 |   72554110 |\n| UNITED KI5 | UNITED KI5 | 1992 |   50710534 |\n| UNITED KI1 | UNITED KI5 | 1992 |   43835692 |\n| UNITED KI5 | UNITED KI1 | 1993 |  122035214 |\n| UNITED KI1 | UNITED KI1 | 1993 |   91339070 |\n| UNITED KI5 | UNITED KI5 | 1993 |   68198784 |\n| UNITED KI1 | UNITED KI5 | 1993 |   42888412 |\n| UNITED KI5 | UNITED KI1 | 1994 |   72564326 |\n| UNITED KI1 | UNITED KI1 | 1994 |   69736882 |\n| UNITED KI5 | UNITED KI5 | 1994 |   69014568 |\n| UNITED KI1 | UNITED KI5 | 1994 |   42443560 |\n| UNITED KI5 | UNITED KI1 | 1995 |  165911792 |\n| UNITED KI1 | UNITED KI1 | 1995 |   71762372 |\n| UNITED KI5 | UNITED KI5 | 1995 |   41079610 |\n| UNITED KI1 | UNITED KI5 | 1995 |   34353020 |\n| UNITED KI5 | UNITED KI1 | 1996 |  131534098 |\n| UNITED KI1 | UNITED KI1 | 1996 |  119846074 |\n| UNITED KI5 | UNITED KI5 | 1996 |   92154684 |\n| UNITED KI1 | UNITED KI5 | 1996 |   27400508 |\n| UNITED KI1 | UNITED KI1 | 1997 |  140686266 |\n| UNITED KI5 | UNITED KI1 | 1997 |  129956718 |\n| UNITED KI5 | UNITED KI5 | 1997 |   54664054 |\n| UNITED KI1 | UNITED KI5 | 1997 |   32821336 |\n+------------+------------+------+------------+\n\n-- Q3.4\n+------------+------------+------+------------+\n| c_city     | s_city     | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED KI5 | UNITED KI1 | 1997 |   18235692 |\n| UNITED KI5 | UNITED KI5 | 1997 |   12407602 |\n| UNITED KI1 | UNITED KI5 | 1997 |    3740140 |\n+------------+------------+------+------------+\n\n-- Q4.1\n+------+---------------+-------------+\n| year | c_nation      | profit      |\n+------+---------------+-------------+\n| 1992 | ARGENTINA     | 19317928938 |\n| 1992 | BRAZIL        | 18453966110 |\n| 1992 | CANADA        | 19286353574 |\n| 1992 | PERU          | 18821353194 |\n| 1992 | UNITED STATES | 19698855306 |\n| 1993 | ARGENTINA     | 19952665706 |\n| 1993 | BRAZIL        | 18937598458 |\n| 1993 | CANADA        | 19794604840 |\n| 1993 | PERU          | 18618891672 |\n| 1993 | UNITED STATES | 20007970172 |\n| 1994 | ARGENTINA     | 19880610430 |\n| 1994 | BRAZIL        | 18697303354 |\n| 1994 | CANADA        | 19165295192 |\n| 1994 | PERU          | 18590530026 |\n| 1994 | UNITED STATES | 19039760850 |\n| 1995 | ARGENTINA     | 20287682760 |\n| 1995 | BRAZIL        | 18312154700 |\n| 1995 | CANADA        | 19125224320 |\n| 1995 | PERU          | 19556174422 |\n| 1995 | UNITED STATES | 18621130488 |\n| 1996 | ARGENTINA     | 20003855790 |\n| 1996 | BRAZIL        | 18336970302 |\n| 1996 | CANADA        | 20123208406 |\n| 1996 | PERU          | 18710271348 |\n| 1996 | UNITED STATES | 19539424348 |\n| 1997 | ARGENTINA     | 19709120522 |\n| 1997 | BRAZIL        | 18243142094 |\n| 1997 | CANADA        | 20194743556 |\n| 1997 | PERU          | 18631051834 |\n| 1997 | UNITED STATES | 21013447758 |\n| 1998 | ARGENTINA     | 11668480814 |\n| 1998 | BRAZIL        | 10712796190 |\n| 1998 | CANADA        | 10846422392 |\n| 1998 | PERU          | 11452371940 |\n| 1998 | UNITED STATES | 12018924038 |\n+------+---------------+-------------+\n\n-- Q4.2\n+------+---------------+------------+------------+\n| year | s_nation      | p_category | profit     |\n+------+---------------+------------+------------+\n| 1997 | ARGENTINA     | MFGR#11    | 1814143132 |\n| 1997 | ARGENTINA     | MFGR#12    | 1848231124 |\n| 1997 | ARGENTINA     | MFGR#13    | 1945723642 |\n| 1997 | ARGENTINA     | MFGR#14    | 1950820690 |\n| 1997 | ARGENTINA     | MFGR#15    | 1877734750 |\n| 1997 | ARGENTINA     | MFGR#21    | 2029565148 |\n| 1997 | ARGENTINA     | MFGR#22    | 1746033566 |\n| 1997 | ARGENTINA     | MFGR#23    | 2060714604 |\n| 1997 | ARGENTINA     | MFGR#24    | 1786921158 |\n| 1997 | ARGENTINA     | MFGR#25    | 2012622806 |\n| 1997 | BRAZIL        | MFGR#11    | 2146438656 |\n| 1997 | BRAZIL        | MFGR#12    | 1979717666 |\n| 1997 | BRAZIL        | MFGR#13    | 2256960758 |\n| 1997 | BRAZIL        | MFGR#14    | 2388513444 |\n| 1997 | BRAZIL        | MFGR#15    | 2188838248 |\n| 1997 | BRAZIL        | MFGR#21    | 1820053664 |\n| 1997 | BRAZIL        | MFGR#22    | 1986284096 |\n| 1997 | BRAZIL        | MFGR#23    | 2215345748 |\n| 1997 | BRAZIL        | MFGR#24    | 2116027298 |\n| 1997 | BRAZIL        | MFGR#25    | 1989467528 |\n| 1997 | CANADA        | MFGR#11    | 1709450040 |\n| 1997 | CANADA        | MFGR#12    | 1877436328 |\n| 1997 | CANADA        | MFGR#13    | 1918531780 |\n| 1997 | CANADA        | MFGR#14    | 2005624900 |\n| 1997 | CANADA        | MFGR#15    | 1696366026 |\n| 1997 | CANADA        | MFGR#21    | 1999610544 |\n| 1997 | CANADA        | MFGR#22    | 1556839526 |\n| 1997 | CANADA        | MFGR#23    | 1856719290 |\n| 1997 | CANADA        | MFGR#24    | 1699790256 |\n| 1997 | CANADA        | MFGR#25    | 1809175930 |\n| 1997 | PERU          | MFGR#11    | 2200485754 |\n| 1997 | PERU          | MFGR#12    | 1988730700 |\n| 1997 | PERU          | MFGR#13    | 1694972210 |\n| 1997 | PERU          | MFGR#14    | 1895539366 |\n| 1997 | PERU          | MFGR#15    | 1998791356 |\n| 1997 | PERU          | MFGR#21    | 1735846788 |\n| 1997 | PERU          | MFGR#22    | 1977494918 |\n| 1997 | PERU          | MFGR#23    | 2133290172 |\n| 1997 | PERU          | MFGR#24    | 1871331450 |\n| 1997 | PERU          | MFGR#25    | 1962908258 |\n| 1997 | UNITED STATES | MFGR#11    | 2093412096 |\n| 1997 | UNITED STATES | MFGR#12    | 1818427418 |\n| 1997 | UNITED STATES | MFGR#13    | 2192557812 |\n| 1997 | UNITED STATES | MFGR#14    | 1868564222 |\n| 1997 | UNITED STATES | MFGR#15    | 1925521686 |\n| 1997 | UNITED STATES | MFGR#21    | 2001352948 |\n| 1997 | UNITED STATES | MFGR#22    | 2153895230 |\n| 1997 | UNITED STATES | MFGR#23    | 1874576204 |\n| 1997 | UNITED STATES | MFGR#24    | 2006772726 |\n| 1997 | UNITED STATES | MFGR#25    | 2107332104 |\n| 1998 | ARGENTINA     | MFGR#11    | 1135224454 |\n| 1998 | ARGENTINA     | MFGR#12    | 1054050084 |\n| 1998 | ARGENTINA     | MFGR#13    | 1165583584 |\n| 1998 | ARGENTINA     | MFGR#14    | 1047452736 |\n| 1998 | ARGENTINA     | MFGR#15    | 1044156534 |\n| 1998 | ARGENTINA     | MFGR#21    | 1009425370 |\n| 1998 | ARGENTINA     | MFGR#22    | 1012123472 |\n| 1998 | ARGENTINA     | MFGR#23    | 1120959602 |\n| 1998 | ARGENTINA     | MFGR#24    | 1049158236 |\n| 1998 | ARGENTINA     | MFGR#25    | 1095680422 |\n| 1998 | BRAZIL        | MFGR#11    | 1277156976 |\n| 1998 | BRAZIL        | MFGR#12    | 1292625362 |\n| 1998 | BRAZIL        | MFGR#13    | 1310323544 |\n| 1998 | BRAZIL        | MFGR#14    | 1105352340 |\n| 1998 | BRAZIL        | MFGR#15    | 1327625418 |\n| 1998 | BRAZIL        | MFGR#21    | 1337644896 |\n| 1998 | BRAZIL        | MFGR#22    | 1183583836 |\n| 1998 | BRAZIL        | MFGR#23    | 1381297754 |\n| 1998 | BRAZIL        | MFGR#24    | 1124724440 |\n| 1998 | BRAZIL        | MFGR#25    | 1408364752 |\n| 1998 | CANADA        | MFGR#11    | 1018172250 |\n| 1998 | CANADA        | MFGR#12    |  976179544 |\n| 1998 | CANADA        | MFGR#13    |  973066594 |\n| 1998 | CANADA        | MFGR#14    | 1055674454 |\n| 1998 | CANADA        | MFGR#15    | 1071738598 |\n| 1998 | CANADA        | MFGR#21    |  911737302 |\n| 1998 | CANADA        | MFGR#22    | 1188554616 |\n| 1998 | CANADA        | MFGR#23    | 1148250140 |\n| 1998 | CANADA        | MFGR#24    | 1017060848 |\n| 1998 | CANADA        | MFGR#25    | 1095515984 |\n| 1998 | PERU          | MFGR#11    | 1135677094 |\n| 1998 | PERU          | MFGR#12    | 1081089514 |\n| 1998 | PERU          | MFGR#13    | 1182663766 |\n| 1998 | PERU          | MFGR#14    |  962670128 |\n| 1998 | PERU          | MFGR#15    | 1140492276 |\n| 1998 | PERU          | MFGR#21    | 1067466660 |\n| 1998 | PERU          | MFGR#22    | 1055581312 |\n| 1998 | PERU          | MFGR#23    | 1272786442 |\n| 1998 | PERU          | MFGR#24    | 1178150524 |\n| 1998 | PERU          | MFGR#25    | 1086502230 |\n| 1998 | UNITED STATES | MFGR#11    | 1112552464 |\n| 1998 | UNITED STATES | MFGR#12    | 1224771964 |\n| 1998 | UNITED STATES | MFGR#13    | 1244827854 |\n| 1998 | UNITED STATES | MFGR#14    | 1110013774 |\n| 1998 | UNITED STATES | MFGR#15    | 1050239138 |\n| 1998 | UNITED STATES | MFGR#21    | 1126813672 |\n| 1998 | UNITED STATES | MFGR#22    | 1160957470 |\n| 1998 | UNITED STATES | MFGR#23    | 1312160930 |\n| 1998 | UNITED STATES | MFGR#24    | 1076890116 |\n| 1998 | UNITED STATES | MFGR#25    | 1178223904 |\n+------+---------------+------------+------------+\n\n-- Q4.3\n+------+------------+-----------+---------------+\n| year | s_city     | p_brand   | profit        |\n+------+------------+-----------+---------------+\n| 1997 | UNITED ST1 | MFGR#1414 | 10001830.0000 |\n| 1997 | UNITED ST1 | MFGR#147  | 13643806.0000 |\n| 1997 | UNITED ST9 | MFGR#144  |  4953914.0000 |\n| 1998 | UNITED ST0 | MFGR#1424 | 14202690.0000 |\n| 1998 | UNITED ST5 | MFGR#1430 |  7742358.0000 |\n+------+------------+-----------+---------------+\n5 rows in set (0.25 sec)\n
        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/","title":"Complete a TPC-C Test with MatrixOne","text":"

        By walking through this tutorial, you'll learn how to complete a TPC-C Test with MatrixOne.

        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#tpc-c-overview","title":"TPC-C Overview","text":"

        TPC-C is an industry-standard benchmark for OLTP databases. TPC-C models a warehouse-centric order processing application, and the database used in the TPC-C benchmark consists of nine tables, such as Warehouse, Customer, Order, Item, and so on (See the below ER diagram). Except for the item table, each record is populated on a per-warehouse basis, and the number of warehouses can be configurable as a scale factor.

        TPC-C has five transaction types: NewOrder, Payment, OrderStatus, Delivery, and StockLevel. The request rate of each transaction is defined in the specification, and almost 90% of transactions are NewOrder and Payment, which are write-intensive. TPC-C transactions mostly access a single (local) warehouse, but about 10% of transactions interact with another (remote) warehouse.

        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#before-you-start","title":"Before you start","text":"

        Make sure you have already Deployed standalone MatrixOne.

        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#clone-mo-tpcc-repository","title":"Clone mo-tpcc repository","text":"
        git clone https://github.com/matrixorigin/mo-tpcc.git\n
        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#steps","title":"Steps","text":""},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#introduction","title":"Introduction","text":"

        This section will teach you how to generate the TPCC data, create TPCC tables, load data to MatrixOne, and run TPCC.

        Now you can execute commands step by step as the following descriptions.

        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#1-configure-the-propsmo-file","title":"1. Configure the props.mo file","text":"

        After the mo-tpch repository is cloned, open the mo-tpcc directory, and modify the configuration items of the props.mo file. The number of warehouses can be configurable by the warehouse=XX row in this file.

        db=mo\ndriver=com.mysql.cj.jdbc.Driver\nconn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\nuser=root\npassword=111\n\n//the number of warehouse\nwarehouses=10\nloadWorkers=4\n\n//the num of terminals that will simultaneously run\n//must be less than warehouses*10\nterminals=1\n//To run specified transactions per terminal- runMins must equal zero\nrunTxnsPerTerminal=0\n//To run for specified minutes- runTxnsPerTerminal must equal zero\nrunMins=1\n//Number of total transactions per minute\nlimitTxnsPerMin=0\n

        After the modifications are complete, save the props.mo file.

        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#2-create-tpcc-database-and-tables","title":"2. Create TPCC database and tables","text":"

        Open a new terminal window, execute the following command:

        cd mo-tpcc\n./runSQL.sh props.mo tableCreates\n

        Npte: If you get an error like java:command not found while running ./runSQL.sh props.mo tableCreates, install or reinstall Java and the JDK on your computer.

        The above code means to enter the mo-tpch directory and create the TPCC database and table.

        The following is an example of the command output:

        # ------------------------------------------------------------\n# Loading SQL file ./sql/tableCreates.sql\n# ------------------------------------------------------------\ndrop database if exists tpcc;\ncreate database if not exists tpcc;\nuse tpcc;\ncreate table bmsql_config (\ncfg_name    varchar(30) primary key,\ncfg_value   varchar(50)\n);\ncreate table bmsql_warehouse (\nw_id        integer   not null,\nw_ytd       decimal(12,2),\nw_tax       decimal(4,4),\nw_name      varchar(10),\nw_street_1  varchar(20),\nw_street_2  varchar(20),\nw_city      varchar(20),\nw_state     char(2),\nw_zip       char(9),\nprimary key (w_id)\n) PARTITION BY KEY(w_id);\ncreate table bmsql_district (\nd_w_id       integer       not null,\nd_id         integer       not null,\nd_ytd        decimal(12,2),\nd_tax        decimal(4,4),\nd_next_o_id  integer,\nd_name       varchar(10),\nd_street_1   varchar(20),\nd_street_2   varchar(20),\nd_city       varchar(20),\nd_state      char(2),\nd_zip        char(9),\nprimary key (d_w_id, d_id)\n) PARTITION BY KEY(d_w_id);\ncreate table bmsql_customer (\nc_w_id         integer        not null,\nc_d_id         integer        not null,\nc_id           integer        not null,\nc_discount     decimal(4,4),\nc_credit       char(2),\nc_last         varchar(16),\nc_first        varchar(16),\nc_credit_lim   decimal(12,2),\nc_balance      decimal(12,2),\nc_ytd_payment  decimal(12,2),\nc_payment_cnt  integer,\nc_delivery_cnt integer,\nc_street_1     varchar(20),\nc_street_2     varchar(20),\nc_city         varchar(20),\nc_state        char(2),\nc_zip          char(9),\nc_phone        char(16),\nc_since        timestamp,\nc_middle       char(2),\nc_data         varchar(500),\nprimary key (c_w_id, c_d_id, c_id)\n) PARTITION BY KEY(c_w_id);\ncreate table bmsql_history (\nhist_id  integer auto_increment,\nh_c_id   integer,\nh_c_d_id integer,\nh_c_w_id integer,\nh_d_id   integer,\nh_w_id   integer,\nh_date   timestamp,\nh_amount decimal(6,2),\nh_data   varchar(24),\nprimary key (hist_id)\n);\ncreate table bmsql_new_order (\nno_w_id  integer   not null,\nno_d_id  integer   not null,\nno_o_id  integer   not null,\nprimary key (no_w_id, no_d_id, no_o_id)\n) PARTITION BY KEY(no_w_id);\ncreate table bmsql_oorder (\no_w_id       integer      not null,\no_d_id       integer      not null,\no_id         integer      not null,\no_c_id       integer,\no_carrier_id integer,\no_ol_cnt     integer,\no_all_local  integer,\no_entry_d    timestamp,\nprimary key (o_w_id, o_d_id, o_id)\n) PARTITION BY KEY(o_w_id);\ncreate table bmsql_order_line (\nol_w_id         integer   not null,\nol_d_id         integer   not null,\nol_o_id         integer   not null,\nol_number       integer   not null,\nol_i_id         integer   not null,\nol_delivery_d   timestamp,\nol_amount       decimal(6,2),\nol_supply_w_id  integer,\nol_quantity     integer,\nol_dist_info    char(24),\nprimary key (ol_w_id, ol_d_id, ol_o_id, ol_number)\n) PARTITION BY KEY(ol_w_id);\ncreate table bmsql_item (\ni_id     integer      not null,\ni_name   varchar(24),\ni_price  decimal(5,2),\ni_data   varchar(50),\ni_im_id  integer,\nprimary key (i_id)\n) PARTITION BY KEY(i_id);\ncreate table bmsql_stock (\ns_w_id       integer       not null,\ns_i_id       integer       not null,\ns_quantity   integer,\ns_ytd        integer,\ns_order_cnt  integer,\ns_remote_cnt integer,\ns_data       varchar(50),\ns_dist_01    char(24),\ns_dist_02    char(24),\ns_dist_03    char(24),\ns_dist_04    char(24),\ns_dist_05    char(24),\ns_dist_06    char(24),\ns_dist_07    char(24),\ns_dist_08    char(24),\ns_dist_09    char(24),\ns_dist_10    char(24),\nprimary key (s_w_id, s_i_id)\n) PARTITION BY KEY(s_w_id);\n
        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#3-generate-tpcc-data","title":"3. Generate TPCC data","text":"

        To generate the TPCC data execute the following command:

        ./runLoader.sh props.mo filelocation /yourpath/\n

        The following is an example of the command output:

        Starting BenchmarkSQL LoadData\n\nprops.mo\ndriver=com.mysql.cj.jdbc.Driver\nconn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\nuser=root\npassword=***********\nwarehouses=10\nloadWorkers=4\nfileLocation (not defined)\ncsvNullValue (not defined - using default '')\n\nWorker 000: Loading ITEM\nWorker 001: Loading Warehouse      1\nWorker 002: Loading Warehouse      2\nWorker 003: Loading Warehouse      3\nWorker 000: Loading ITEM done\nWorker 000: Loading Warehouse      4\nWorker 003: Loading Warehouse      3 done\nWorker 003: Loading Warehouse      5\nWorker 001: Loading Warehouse      1 done\nWorker 001: Loading Warehouse      6\nWorker 002: Loading Warehouse      2 done\nWorker 002: Loading Warehouse      7\nWorker 000: Loading Warehouse      4 done\nWorker 000: Loading Warehouse      8\nWorker 003: Loading Warehouse      5 done\nWorker 003: Loading Warehouse      9\nWorker 000: Loading Warehouse      8 done\nWorker 000: Loading Warehouse     10\nWorker 002: Loading Warehouse      7 done\nWorker 001: Loading Warehouse      6 done\nWorker 000: Loading Warehouse     10 done\nWorker 003: Loading Warehouse      9 done\n

        You will find in your designated path 10 csv files. Each csv file maps to a table created in the second step.

        config.csv\ncust-hist.csv\ncustomer.csv\ndistrict.csv\nitem.csv\nnew-order.csv\norder-line.csv\norder.csv\nstock.csv\nwarehouse.csv\n
        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#4-load-tpcc-data-to-matrixone","title":"4. Load TPCC data to MatrixOne","text":"

        Use MySQL client to connect to MatrixOne and execute the following statements to load the csv files into MatrixOne.

        mysql> load data infile '/yourpath/config.csv' INTO TABLE bmsql_config FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/cust-hist.csv' INTO TABLE bmsql_history FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/customer.csv' INTO TABLE bmsql_customer FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/district.csv' INTO TABLE bmsql_district FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/warehouse.csv' INTO TABLE bmsql_warehouse FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/item.csv' INTO TABLE bmsql_item FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/new-order.csv' INTO TABLE bmsql_new_order FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/order-line.csv' INTO TABLE bmsql_order_line FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/stock.csv' INTO TABLE bmsql_stock FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/order.csv' INTO TABLE bmsql_oorder FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
        "},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#5-run-tpcc-test","title":"5. Run TPCC test","text":"

        To run the TPCC test, execute the following command:

        ./runBenchmark.sh props.mo\n

        The following is an example of the command output:

        .:./lib/*\n2022-12-22 21:15:35 INFO  jTPCC:78 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:79 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO  jTPCC:80 - Term-00,      BenchmarkSQL v5.0\n2022-12-22 21:15:35 INFO  jTPCC:81 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO  jTPCC:82 - Term-00,  (c) 2003, Raul Barbosa\n2022-12-22 21:15:35 INFO  jTPCC:83 - Term-00,  (c) 2004-2016, Denis Lussier\n2022-12-22 21:15:35 INFO  jTPCC:84 - Term-00,  (c) 2016, Jan Wieck\n2022-12-22 21:15:35 INFO  jTPCC:85 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO  jTPCC:86 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, db=mo\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, driver=com.mysql.cj.jdbc.Driver\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, conn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, user=root\n2022-12-22 21:15:35 INFO  jTPCC:93 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, warehouses=10\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, terminals=1\n2022-12-22 21:15:35 INFO  jTPCC:100 - Term-00, runMins=1\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, limitTxnsPerMin=0\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, terminalWarehouseFixed=false\n2022-12-22 21:15:35 INFO  jTPCC:108 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, newOrderWeight=45\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, paymentWeight=43\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, orderStatusWeight=4\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, deliveryWeight=4\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, stockLevelWeight=4\n2022-12-22 21:15:35 INFO  jTPCC:115 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS\n2022-12-22 21:15:35 INFO  jTPCC:63 - Term-00, osCollectorScript=null\n2022-12-22 21:15:35 INFO  jTPCC:119 - Term-00,\n2022-12-22 21:15:35 INFO  jTPCC:710 - Term-00, Loading database driver: 'com.mysql.cj.jdbc.Driver'...\n2022-12-22 21:15:35 INFO  jTPCC:219 - Term-00, copied props.mo to my_result_2022-12-22_211535/run.properties\n2022-12-22 21:15:35 INFO  jTPCC:239 - Term-00, created my_result_2022-12-22_211535/data/runInfo.csv for runID 1\n2022-12-22 21:15:35 INFO  jTPCC:255 - Term-00, writing per transaction results to my_result_2022-12-22_211535/data/result.csv\n2022-12-22 21:15:35 INFO  jTPCC:268 - Term-00,\n2022-12-22 21:15:36 INFO  jTPCC:324 - Term-00, C value for C_LAST during load: 28\n2022-12-22 21:15:36 INFO  jTPCC:325 - Term-00, C value for C_LAST this run:    132\n2022-12-22 21:15:36 INFO  jTPCC:326 - Term-00,\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Session started!   Memory Usage: 17MB / 245MB          \n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Creating 1 terminal(s) with -1 transaction(s) per terminal...\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Terminal Warehouse is NOT fixed\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Transaction Weights: 45% New-Order, 43% Payment, 4% Order-Status, 4% Delivery, 4% Stock-Level\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Number of Terminals      1\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Creating database connection for Term-01...\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Term-01  7\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Transaction      Weight\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % New-Order      45\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % Payment        43\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % Order-Status   4\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % Delivery       4\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, % Stock-Level    4\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Transaction Number       Terminal        Type    Execution Time (ms)             Comment\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Created 1 terminal(s) successfully!\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, Starting all terminals...\n2022-12-22 21:15:36 INFO  jTPCC:710 - Term-00, All terminals started executing 2022-12-22 21:15:36\nTerm-00, Running Average tpmTOTAL: 60000.00    Current tpmTOTAL: 12    Memory Usage: 19MB / 245MB   2022-12-22 21:15:36 INFO  jTPCCTerminal:350 - Term-01, Executing for a limited time...\n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, The time limit has been reached.: 21MB / 245MB          \n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, Signalling all terminals to stop...\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01,\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, Terminal received stop signal!\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, Finishing current transaction before exit...\n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, Waiting for all active transactions to end...\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, OTAL: 24    Memory Usage: 22MB / 245MB          \n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, Closing statement and connection...\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01,\n2022-12-22 21:16:42 INFO  jTPCCTerminal:350 - Term-01, Terminal 'Term-01' finished after 0 transaction(s).\n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, All terminals finished executing 2022-12-22 21:16:42\n\n2022-12-22 21:16:42 INFO  jTPCC:694 - Term-00,\n2022-12-22 21:16:42 INFO  jTPCC:695 - Term-00,\n2022-12-22 21:16:42 INFO  jTPCC:696 - Term-00, Measured tpmC (NewOrders) = 2.74\n2022-12-22 21:16:42 INFO  jTPCC:697 - Term-00, Measured tpmTOTAL = 3.66\n2022-12-22 21:16:42 INFO  jTPCC:698 - Term-00, Measured tpmE (ErrorCount) = 0.0\n2022-12-22 21:16:42 INFO  jTPCC:699 - Term-00, Session Start     = 2022-12-22 21:15:36\n2022-12-22 21:16:42 INFO  jTPCC:700 - Term-00, Session End       = 2022-12-22 21:16:42\n2022-12-22 21:16:42 INFO  jTPCC:701 - Term-00, Transaction Count = 3\n2022-12-22 21:16:42 INFO  jTPCC:702 - Term-00, Transaction Error = 0\n2022-12-22 21:16:42 INFO  jTPCC:703 - Term-00, Transaction NewOrders = 3\n2022-12-22 21:16:42 INFO  jTPCC:710 - Term-00, Session finished!\n

        The value of tpmC(transactions per minute) is given in the result.

        "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/","title":"Complete a TPCH Test with MatrixOne","text":"

        The TPC-H is a decision support benchmark. It consists of a suite of business oriented ad-hoc queries and concurrent data modifications. The queries and the data populating the database have been chosen to have broad industry-wide relevance. This benchmark illustrates decision support systems that examine large volumes of data, execute queries with a high degree of complexity, and give answers to critical business questions. TPC-H is a widely used benchmark for OLAP databases.

        By walking through this tutorial, you'll learn how to complete a TPC-H Test with MatrixOne.

        "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#before-you-start","title":"Before you start","text":"

        Make sure you have already Deployed standalone MatrixOne.

        "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#1-compile-tpch-dbgen","title":"1. Compile TPCH dbgen","text":"

        The tpch dbgen utility generates, by default, a set of flat files suitable for loading into the tpch schema with the size based on the \"Scale Factor\" argument. A scale factor of 1 produces a complete data set of approximately 1 GB, a scale factor of 10 produces a data set of approximately 10 GB and so on.

        git clone https://github.com/electrum/tpch-dbgen.git\ncd tpch-dbgen\nmake\n
        "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#2-generate-data","title":"2. Generate data","text":"

        Run dbgen for the appropriate database size factor (1GB in the sample).

        ./dbgen -s 1\n

        Generation may take a while. When completed, you can see the resulting files.

        total 2150000\n-rw-r--r--  1 deister  staff   24346144 13 may 12:05 customer.tbl\n-rw-r--r--  1 deister  staff  759863287 13 may 12:05 lineitem.tbl\n-rw-r--r--  1 deister  staff       2224 13 may 12:05 nation.tbl\n-rw-r--r--  1 deister  staff  171952161 13 may 12:05 orders.tbl\n-rw-r--r--  1 deister  staff   24135125 13 may 12:05 part.tbl\n-rw-r--r--  1 deister  staff  118984616 13 may 12:05 partsupp.tbl\n-rw-r--r--  1 deister  staff        389 13 may 12:05 region.tbl\n-rw-r--r--  1 deister  staff    1409184 13 may 12:05 supplier.tbl\n

        We have also prepared a 1GB dataset for downloading. You can get the data files directly:

        https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
        "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#3-create-tables-in-matrixone","title":"3. Create tables in MatrixOne","text":"

        MatrixOne does not support partition acceleration at the moment, and the creation code of the LINEITEM table has the following modifications:

        • Removed PARTITION BY KEY() for LINEITEM table.
        drop database if exists TPCH;\ncreate database if not exists TPCH;\nuse TPCH;\nCREATE TABLE NATION(\nN_NATIONKEY  INTEGER NOT NULL,\nN_NAME       CHAR(25) NOT NULL,\nN_REGIONKEY  INTEGER NOT NULL,\nN_COMMENT    VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY)\n);\n\nCREATE TABLE REGION(\nR_REGIONKEY  INTEGER NOT NULL,\nR_NAME       CHAR(25) NOT NULL,\nR_COMMENT    VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY)\n);\n\nCREATE TABLE PART(\nP_PARTKEY     INTEGER NOT NULL,\nP_NAME        VARCHAR(55) NOT NULL,\nP_MFGR        CHAR(25) NOT NULL,\nP_BRAND       CHAR(10) NOT NULL,\nP_TYPE        VARCHAR(25) NOT NULL,\nP_SIZE        INTEGER NOT NULL,\nP_CONTAINER   CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT     VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY)\n);\n\nCREATE TABLE SUPPLIER(\nS_SUPPKEY     INTEGER NOT NULL,\nS_NAME        CHAR(25) NOT NULL,\nS_ADDRESS     VARCHAR(40) NOT NULL,\nS_NATIONKEY   INTEGER NOT NULL,\nS_PHONE       CHAR(15) NOT NULL,\nS_ACCTBAL     DECIMAL(15,2) NOT NULL,\nS_COMMENT     VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY)\n);\n\nCREATE TABLE PARTSUPP (\nPS_PARTKEY    INTEGER NOT NULL,\nPS_SUPPKEY    INTEGER NOT NULL,\nPS_AVAILQTY   INTEGER NOT NULL,\nPS_SUPPLYCOST DECIMAL(15,2) NOT NULL,\nPS_COMMENT    VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY)\n);\n\nCREATE TABLE CUSTOMER(\nC_CUSTKEY     INTEGER NOT NULL,\nC_NAME        VARCHAR(25) NOT NULL,\nC_ADDRESS     VARCHAR(40) NOT NULL,\nC_NATIONKEY   INTEGER NOT NULL,\nC_PHONE       CHAR(15) NOT NULL,\nC_ACCTBAL     DECIMAL(15,2)   NOT NULL,\nC_MKTSEGMENT  CHAR(10) NOT NULL,\nC_COMMENT     VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY)\n);\n\nCREATE TABLE ORDERS(\nO_ORDERKEY       BIGINT NOT NULL,\nO_CUSTKEY        INTEGER NOT NULL,\nO_ORDERSTATUS    CHAR(1) NOT NULL,\nO_TOTALPRICE     DECIMAL(15,2) NOT NULL,\nO_ORDERDATE      DATE NOT NULL,\nO_ORDERPRIORITY  CHAR(15) NOT NULL,\nO_CLERK          CHAR(15) NOT NULL,\nO_SHIPPRIORITY   INTEGER NOT NULL,\nO_COMMENT        VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY)\n);\n\nCREATE TABLE LINEITEM (\nL_ORDERKEY BIGINT NOT NULL,\nL_PARTKEY INTEGER NOT NULL,\nL_SUPPKEY INTEGER NOT NULL,\nL_LINENUMBER INTEGER NOT NULL,\nL_QUANTITY DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,\nL_DISCOUNT DECIMAL(15,2) NOT NULL,\nL_TAX DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG CHAR(1) NOT NULL,\nL_LINESTATUS CHAR(1) NOT NULL,\nL_SHIPDATE DATE NOT NULL,\nL_COMMITDATE DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE CHAR(10) NOT NULL,\nL_COMMENT VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER)\n);\n
        "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#4-load-data-into-the-created-tables","title":"4. Load data into the created tables","text":"

        Load the sigle table dataset into related tables with this command in MatrixOne:

        load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n

        Then you can query data in MatrixOne with the created table.

        "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#5-run-tpch-queries","title":"5. Run TPCH Queries","text":"
        -- Q1\nselect\nl_returnflag,\nl_linestatus,\nsum(l_quantity) as sum_qty,\nsum(l_extendedprice) as sum_base_price,\nsum(l_extendedprice * (1 - l_discount)) as sum_disc_price,\nsum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,\navg(l_quantity) as avg_qty,\navg(l_extendedprice) as avg_price,\navg(l_discount) as avg_disc,\ncount(*) as count_order\nfrom\nlineitem\nwhere\nl_shipdate <= date '1998-12-01' - interval '112' day\ngroup by\nl_returnflag,\nl_linestatus\norder by\nl_returnflag,\nl_linestatus\n;\n\n-- Q2\nselect\ns_acctbal,\ns_name,\nn_name,\np_partkey,\np_mfgr,\ns_address,\ns_phone,\ns_comment\nfrom\npart,\nsupplier,\npartsupp,\nnation,\nregion\nwhere\np_partkey = ps_partkey\nand s_suppkey = ps_suppkey\nand p_size = 48\nand p_type like '%TIN'\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'MIDDLE EAST'\nand ps_supplycost = (\nselect\nmin(ps_supplycost)\nfrom\npartsupp,\nsupplier,\nnation,\nregion\nwhere\np_partkey = ps_partkey\nand s_suppkey = ps_suppkey\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'MIDDLE EAST'\n)\norder by\ns_acctbal desc,\nn_name,\ns_name,\np_partkey\nlimit 100\n;\n\n\n-- Q3\nselect\nl_orderkey,\nsum(l_extendedprice * (1 - l_discount)) as revenue,\no_orderdate,\no_shippriority\nfrom\ncustomer,\norders,\nlineitem\nwhere\nc_mktsegment = 'HOUSEHOLD'\nand c_custkey = o_custkey\nand l_orderkey = o_orderkey\nand o_orderdate < date '1995-03-29'\nand l_shipdate > date '1995-03-29'\ngroup by\nl_orderkey,\no_orderdate,\no_shippriority\norder by\nrevenue desc,\no_orderdate\nlimit 10\n;\n\n-- Q4\nselect\no_orderpriority,\ncount(*) as order_count\nfrom\norders\nwhere\no_orderdate >= date '1997-07-01'\nand o_orderdate < date '1997-07-01' + interval '3' month\nand exists (\nselect\n*\nfrom\nlineitem\nwhere\nl_orderkey = o_orderkey\nand l_commitdate < l_receiptdate\n)\ngroup by\no_orderpriority\norder by\no_orderpriority\n;\n\n\n-- Q5\nselect\nn_name,\nsum(l_extendedprice * (1 - l_discount)) as revenue\nfrom\ncustomer,\norders,\nlineitem,\nsupplier,\nnation,\nregion\nwhere\nc_custkey = o_custkey\nand l_orderkey = o_orderkey\nand l_suppkey = s_suppkey\nand c_nationkey = s_nationkey\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'AMERICA'\nand o_orderdate >= date '1994-01-01'\nand o_orderdate < date '1994-01-01' + interval '1' year\ngroup by\nn_name\norder by\nrevenue desc\n;\n\n\n-- Q6\nselect\nsum(l_extendedprice * l_discount) as revenue\nfrom\nlineitem\nwhere\nl_shipdate >= date '1994-01-01'\nand l_shipdate < date '1994-01-01' + interval '1' year\nand l_discount between 0.03 - 0.01 and 0.03 + 0.01\nand l_quantity < 24;\n\n-- Q7\nselect\nsupp_nation,\ncust_nation,\nl_year,\nsum(volume) as revenue\nfrom\n(\nselect\nn1.n_name as supp_nation,\nn2.n_name as cust_nation,\nextract(year from l_shipdate) as l_year,\nl_extendedprice * (1 - l_discount) as volume\nfrom\nsupplier,\nlineitem,\norders,\ncustomer,\nnation n1,\nnation n2\nwhere\ns_suppkey = l_suppkey\nand o_orderkey = l_orderkey\nand c_custkey = o_custkey\nand s_nationkey = n1.n_nationkey\nand c_nationkey = n2.n_nationkey\nand (\n(n1.n_name = 'FRANCE' and n2.n_name = 'ARGENTINA')\nor (n1.n_name = 'ARGENTINA' and n2.n_name = 'FRANCE')\n)\nand l_shipdate between date '1995-01-01' and date '1996-12-31'\n) as shipping\ngroup by\nsupp_nation,\ncust_nation,\nl_year\norder by\nsupp_nation,\ncust_nation,\nl_year\n;\n\n-- Q8\nselect\no_year,\n(sum(case\nwhen nation = 'ARGENTINA' then volume\nelse 0\nend) / sum(volume)) as mkt_share\nfrom\n(\nselect\nextract(year from o_orderdate) as o_year,\nl_extendedprice * (1 - l_discount) as volume,\nn2.n_name as nation\nfrom\npart,\nsupplier,\nlineitem,\norders,\ncustomer,\nnation n1,\nnation n2,\nregion\nwhere\np_partkey = l_partkey\nand s_suppkey = l_suppkey\nand l_orderkey = o_orderkey\nand o_custkey = c_custkey\nand c_nationkey = n1.n_nationkey\nand n1.n_regionkey = r_regionkey\nand r_name = 'AMERICA'\nand s_nationkey = n2.n_nationkey\nand o_orderdate between date '1995-01-01' and date '1996-12-31'\nand p_type = 'ECONOMY BURNISHED TIN'\n) as all_nations\ngroup by\no_year\norder by\no_year\n;\n\n-- Q9\nselect\nnation,\no_year,\nsum(amount) as sum_profit\nfrom\n(\nselect\nn_name as nation,\nextract(year from o_orderdate) as o_year,\nl_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount\nfrom\npart,\nsupplier,\nlineitem,\npartsupp,\norders,\nnation\nwhere\ns_suppkey = l_suppkey\nand ps_suppkey = l_suppkey\nand ps_partkey = l_partkey\nand p_partkey = l_partkey\nand o_orderkey = l_orderkey\nand s_nationkey = n_nationkey\nand p_name like '%pink%'\n) as profit\ngroup by\nnation,\no_year\norder by\nnation,\no_year desc\n;\n\n\n-- Q10\nselect\nc_custkey,\nc_name,\nsum(l_extendedprice * (1 - l_discount)) as revenue,\nc_acctbal,\nn_name,\nc_address,\nc_phone,\nc_comment\nfrom\ncustomer,\norders,\nlineitem,\nnation\nwhere\nc_custkey = o_custkey\nand l_orderkey = o_orderkey\nand o_orderdate >= date '1993-03-01'\nand o_orderdate < date '1993-03-01' + interval '3' month\nand l_returnflag = 'R'\nand c_nationkey = n_nationkey\ngroup by\nc_custkey,\nc_name,\nc_acctbal,\nc_phone,\nn_name,\nc_address,\nc_comment\norder by\nrevenue desc\nlimit 20\n;\n\n\n-- Q11\nselect\nps_partkey,\nsum(ps_supplycost * ps_availqty) as value\nfrom\npartsupp,\nsupplier,\nnation\nwhere\nps_suppkey = s_suppkey\nand s_nationkey = n_nationkey\nand n_name = 'JAPAN'\ngroup by\nps_partkey having\nsum(ps_supplycost * ps_availqty) > (\nselect\nsum(ps_supplycost * ps_availqty) * 0.0001000000\nfrom\npartsupp,\nsupplier,nation\nwhere\nps_suppkey = s_suppkey\nand s_nationkey = n_nationkey\nand n_name = 'JAPAN'\n)\norder by\nvalue desc\n;\n\n-- Q12\nselect\nl_shipmode,\nsum(case\nwhen o_orderpriority = '1-URGENT'\nor o_orderpriority = '2-HIGH'\nthen 1\nelse 0\nend) as high_line_count,\nsum(case\nwhen o_orderpriority <> '1-URGENT'\nand o_orderpriority <> '2-HIGH'\nthen 1\nelse 0\nend) as low_line_count\nfrom\norders,\nlineitem\nwhere\no_orderkey = l_orderkey\nand l_shipmode in ('FOB', 'TRUCK')\nand l_commitdate < l_receiptdate\nand l_shipdate < l_commitdate\nand l_receiptdate >= date '1996-01-01'\nand l_receiptdate < date '1996-01-01' + interval '1' year\ngroup by\nl_shipmode\norder by\nl_shipmode\n;\n\n-- Q13\nselect\nc_count,\ncount(*) as custdist\nfrom\n(\nselect\nc_custkey,\ncount(o_orderkey)\nfrom\ncustomer left outer join orders on\nc_custkey = o_custkey\nand o_comment not like '%pending%accounts%'\ngroup by\nc_custkey\n) as c_orders (c_custkey, c_count)\ngroup by\nc_count\norder by\ncustdist desc,\nc_count desc\n;\n\n-- Q14\nselect\n100.00 * sum(case\nwhen p_type like 'PROMO%'\nthen l_extendedprice * (1 - l_discount)\nelse 0\nend) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue\nfrom\nlineitem,\npart\nwhere\nl_partkey = p_partkey\nand l_shipdate >= date '1996-04-01'\nand l_shipdate < date '1996-04-01' + interval '1' month;\n\n-- Q15\nwith q15_revenue0 as (\nselect\nl_suppkey as supplier_no,\nsum(l_extendedprice * (1 - l_discount)) as total_revenue\nfrom\nlineitem\nwhere\nl_shipdate >= date '1995-12-01'\nand l_shipdate < date '1995-12-01' + interval '3' month\ngroup by\nl_suppkey\n)\nselect\ns_suppkey,\ns_name,\ns_address,\ns_phone,\ntotal_revenue\nfrom\nsupplier,\nq15_revenue0\nwhere\ns_suppkey = supplier_no\nand total_revenue = (\nselect\nmax(total_revenue)\nfrom\nq15_revenue0\n)\norder by\ns_suppkey\n;\n\n-- Q16\nselect\np_brand,\np_type,\np_size,\ncount(distinct ps_suppkey) as supplier_cnt\nfrom\npartsupp,\npart\nwhere\np_partkey = ps_partkey\nand p_brand <> 'Brand#35'\nand p_type not like 'ECONOMY BURNISHED%'\nand p_size in (14, 7, 21, 24, 35, 33, 2, 20)\nand ps_suppkey not in (\nselect\ns_suppkey\nfrom\nsupplier\nwhere\ns_comment like '%Customer%Complaints%'\n)\ngroup by\np_brand,\np_type,\np_size\norder by\nsupplier_cnt desc,\np_brand,\np_type,\np_size\n;\n\n-- Q17\nselect\nsum(l_extendedprice) / 7.0 as avg_yearly\nfrom\nlineitem,\npart\nwhere\np_partkey = l_partkey\nand p_brand = 'Brand#54'\nand p_container = 'LG BAG'\nand l_quantity < (\nselect\n0.2 * avg(l_quantity)\nfrom\nlineitem\nwhere\nl_partkey = p_partkey\n);\n\n-- Q18\nselect\nc_name,\nc_custkey,\no_orderkey,\no_orderdate,\no_totalprice,\nsum(l_quantity)\nfrom\ncustomer,\norders,\nlineitem\nwhere\no_orderkey in (\nselect\nl_orderkey\nfrom\nlineitem\ngroup by\nl_orderkey having\nsum(l_quantity) > 314\n)\nand c_custkey = o_custkey\nand o_orderkey = l_orderkey\ngroup by\nc_name,\nc_custkey,\no_orderkey,\no_orderdate,\no_totalprice\norder by\no_totalprice desc,\no_orderdate\nlimit 100\n;\n\n-- Q19\nselect\nsum(l_extendedprice* (1 - l_discount)) as revenue\nfrom\nlineitem,\npart\nwhere\n(\np_partkey = l_partkey\nand p_brand = 'Brand#23'\nand p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')\nand l_quantity >= 5 and l_quantity <= 5 + 10\nand p_size between 1 and 5\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n)\nor\n(\np_partkey = l_partkey\nand p_brand = 'Brand#15'\nand p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')\nand l_quantity >= 14 and l_quantity <= 14 + 10\nand p_size between 1 and 10\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n)\nor\n(\np_partkey = l_partkey\nand p_brand = 'Brand#44'\nand p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')\nand l_quantity >= 28 and l_quantity <= 28 + 10\nand p_size between 1 and 15\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n);\n\n-- Q20\nselect\ns_name,\ns_address\nfrom\nsupplier,\nnation\nwhere\ns_suppkey in (\nselect\nps_suppkey\nfrom\npartsupp\nwhere\nps_partkey in (\nselect\np_partkey\nfrom\npart\nwhere\np_name like 'lime%'\n)\nand ps_availqty > (\nselect\n0.5 * sum(l_quantity)\nfrom\nlineitem\nwhere\nl_partkey = ps_partkey\nand l_suppkey = ps_suppkey\nand l_shipdate >= date '1993-01-01'\nand l_shipdate < date '1993-01-01' + interval '1' year\n)\n)\nand s_nationkey = n_nationkey\nand n_name = 'VIETNAM'\norder by s_name\n;\n\n-- Q21\nselect\ns_name,\ncount(*) as numwait\nfrom\nsupplier,\nlineitem l1,\norders,\nnation\nwhere\ns_suppkey = l1.l_suppkey\nand o_orderkey = l1.l_orderkey\nand o_orderstatus = 'F'\nand l1.l_receiptdate > l1.l_commitdate\nand exists (\nselect\n*\nfrom\nlineitem l2\nwhere\nl2.l_orderkey = l1.l_orderkey\nand l2.l_suppkey <> l1.l_suppkey\n)\nand not exists (\nselect\n*\nfrom\nlineitem l3\nwhere\nl3.l_orderkey = l1.l_orderkey\nand l3.l_suppkey <> l1.l_suppkey\nand l3.l_receiptdate > l3.l_commitdate\n)\nand s_nationkey = n_nationkey\nand n_name = 'BRAZIL'\ngroup by\ns_name\norder by\nnumwait desc,\ns_name\nlimit 100\n;\n\n-- Q22\nselect\ncntrycode,\ncount(*) as numcust,\nsum(c_acctbal) as totacctbal\nfrom\n(\nselect\nsubstring(c_phone from 1 for 2) as cntrycode,\nc_acctbal\nfrom\ncustomer\nwhere\nsubstring(c_phone from 1 for 2) in\n('10', '11', '26', '22', '19', '20', '27')\nand c_acctbal > (\nselect\navg(c_acctbal)\nfrom\ncustomer\nwhere\nc_acctbal > 0.00\nand substring(c_phone from 1 for 2) in\n('10', '11', '26', '22', '19', '20', '27')\n)\nand not exists (\nselect\n*\nfrom\norders\nwhere\no_custkey = c_custkey\n)\n) as custsale\ngroup by\ncntrycode\norder by\ncntrycode\n;\n
        "},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#6-expected-results","title":"6. Expected Results","text":"

        Below are the expected results for the 22 TPCH queries. Q16's result is too long to print, please refer to the complete result in this link:

        https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch1g_result_matrixone.md\n
        Q1\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+---------+-----------+----------+-------------+\n| l_returnflag | l_linestatus | sum_qty     | sum_base_price  | sum_disc_price    | sum_charge          | avg_qty | avg_price | avg_disc | count_order |\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+---------+-----------+----------+-------------+\n| A            | F            | 37734107.00 |  56586554400.73 |  53758257134.8700 |  55909065222.827692 |   25.52 |  38273.12 |     0.04 |     1478493 |\n| N            | F            |   991417.00 |   1487504710.38 |   1413082168.0541 |   1469649223.194375 |   25.51 |  38284.46 |     0.05 |       38854 |\n| N            | O            | 76633518.00 | 114935210409.19 | 109189591897.4720 | 113561024263.013782 |   25.50 |  38248.01 |     0.05 |     3004998 |\n| R            | F            | 37719753.00 |  56568041380.90 |  53741292684.6040 |  55889619119.831932 |   25.50 |  38250.85 |     0.05 |     1478870 |\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+---------+-----------+----------+-------------+\n4 rows in set\n\nQ2\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n| s_acctbal | s_name             | n_name       | p_partkey | p_mfgr         | s_address                                | s_phone         | s_comment                                                                                           |\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n|   9973.93 | Supplier#000004194 | JORDAN       |     14193 | Manufacturer#1 | A8AoX9AK,qhf,CpEF                        | 23-944-413-2681 | t fluffily. regular requests about the regular, unusual somas play of the furiously busy            |\n|   9956.34 | Supplier#000005108 | IRAN         |    140079 | Manufacturer#5 | d3PLCdpPP3uE4GzbbAh4bWmU 7ecOifL9e1mNnzG | 20-842-882-7047 | ronic accounts. carefully bold accounts sleep beyond                                                |\n|   9836.43 | Supplier#000000489 | IRAN         |    190488 | Manufacturer#2 | y9NMoYGxDUPfrB1GwjYhLtCeV7pOt            | 20-375-500-2226 | quickly carefully pending accounts. fina                                                            |\n|   9825.95 | Supplier#000007554 | IRAQ         |     40041 | Manufacturer#5 | Huq0k qKET hByp3RcMcr                    | 21-787-637-9651 | ending, final requests thrash pending,                                                              |\n|   9806.52 | Supplier#000005276 | IRAQ         |    132762 | Manufacturer#2 | inh0KOhRfLM7WRhdRNvJJDQx                 | 21-834-496-7360 | the slyly unusual theodolites; carefully even accounts use slyly. sl                                |\n|   9796.31 | Supplier#000005847 | IRAQ         |    188292 | Manufacturer#1 | obol3bfh0zWi                             | 21-530-950-2847 | equests. blithely regular deposits should have to impress. final platelets integrate fluffily       |\n|   9775.37 | Supplier#000007245 | IRAQ         |    169696 | Manufacturer#5 | 5VOUnvxlJeOJ                             | 21-663-724-2985 | ic deposits about the slyly bold requests                                                           |\n|   9755.43 | Supplier#000002439 | EGYPT        |    172438 | Manufacturer#5 | rXxojWV0VefSK7A0dhF                      | 14-410-168-5354 | p quickly packages. carefully pending pinto beans after the                                         |\n|   9714.60 | Supplier#000007317 | EGYPT        |     29810 | Manufacturer#4 | nJGsPl2ruoq4Ydtv0fwWG385eOFV6  VUokbCZ   | 14-666-351-2592 | ons integrate furiously? slyly ironic requests sl                                                   |\n|   9557.33 | Supplier#000007367 | EGYPT        |    197366 | Manufacturer#3 | bTP8DLvaRAB0n                            | 14-234-934-5255 | ep slyly regular accounts-- regular, regular excuses dazzle furiously about the reg                 |\n|   9538.15 | Supplier#000000979 | IRAN         |     55968 | Manufacturer#1 | cdvHjrKZR7iDlmSWU2a                      | 20-151-688-1408 | ckages cajole quietly carefully regular in                                                          |\n|   9513.31 | Supplier#000004163 | SAUDI ARABIA |    109142 | Manufacturer#4 | 2VnQypC7pJPJRu6HzYRg7nAvhzckcYAQFbI      | 30-544-852-3772 | he regular requests. blithely final                                                                 |\n|   9450.15 | Supplier#000002067 | EGYPT        |      9566 | Manufacturer#3 | 9dO68x0XLMCUDuFk1J6k9hpvLoKx 4qasok4lIb  | 14-252-246-5791 | rding to the regular dolphins. quickly ir                                                           |\n|   9359.59 | Supplier#000005087 | JORDAN       |     55086 | Manufacturer#4 | q0c6r9wYVQx31IeGBZKfe                    | 23-335-392-5204 | osits. quickly regular packages haggle among the quickly silent ins                                 |\n|   9343.35 | Supplier#000006337 | IRAN         |    173819 | Manufacturer#1 | ilQgNOdCAysclt3SgODb6LeJ7d4RzYD          | 20-950-345-8173 | quickly ironic packages affix aft                                                                   |\n|   9318.47 | Supplier#000003834 | SAUDI ARABIA |     11332 | Manufacturer#5 | cxGQnW3nShks59xA5bPoaC bIvcBWUt          | 30-823-353-6520 | regular instructions. express packages run slyly pending                                            |\n|   9318.47 | Supplier#000003834 | SAUDI ARABIA |    108813 | Manufacturer#2 | cxGQnW3nShks59xA5bPoaC bIvcBWUt          | 30-823-353-6520 | regular instructions. express packages run slyly pending                                            |\n|   9315.33 | Supplier#000003009 | IRAN         |     40504 | Manufacturer#2 | oTbwfQ,Yfdcf3ysgc60NKtTpSIc              | 20-306-556-2450 | the carefully special requests. express instructions wake                                           |\n|   9296.31 | Supplier#000008213 | JORDAN       |    163180 | Manufacturer#2 | YhdN9ESxYvhJp9ngr12Bbeo4t3zLPD,          | 23-197-507-9431 | g to the blithely regular accounts! deposit                                                         |\n|   9284.57 | Supplier#000009781 | EGYPT        |      4780 | Manufacturer#4 | 49NAd1iDiY4,                             | 14-410-636-4312 | its. ironic pinto beans are blithely. express depths use caref                                      |\n|   9261.13 | Supplier#000000664 | EGYPT        |    125639 | Manufacturer#5 | ln6wISAnC8Bpj q4V                        | 14-244-772-4913 | ly special foxes cajole slyly ironic reque                                                          |\n|   9260.78 | Supplier#000001949 | IRAN         |     86932 | Manufacturer#2 | W79M2lpYiSY76Ujo6fSRUQiu                 | 20-531-767-2819 | thinly ironic excuses haggle slyly. f                                                               |\n|   9227.16 | Supplier#000009461 | EGYPT        |    126948 | Manufacturer#2 | Eweba 0sfaF,l4sAxXGTgEjzsJsNWWIGjYhFkRWV | 14-983-137-4957 | lly bold packages. carefully express deposits integrate about the unusual accounts. regular,        |\n|   9185.89 | Supplier#000007888 | EGYPT        |     27887 | Manufacturer#1 | nq06Y48amPfS8YBuduy1RYu                  | 14-462-704-3828 | ole slyly-- blithely careful foxes wake against the furiously ironic accounts. pending ideas        |\n|   9185.89 | Supplier#000007888 | EGYPT        |    190330 | Manufacturer#4 | nq06Y48amPfS8YBuduy1RYu                  | 14-462-704-3828 | ole slyly-- blithely careful foxes wake against the furiously ironic accounts. pending ideas        |\n|   9132.92 | Supplier#000007878 | IRAN         |     92859 | Manufacturer#3 | aq6T3tUVq1,                              | 20-861-274-6282 | waters cajole ironic, ironic requests. furi                                                         |\n|   9058.94 | Supplier#000002789 | IRAN         |    142788 | Manufacturer#4 | 7EkIldjP7M6psSWcJ11tf65GT7ZC7UaiCh       | 20-842-716-4307 | s. platelets use carefully. busily regular accounts cajole fluffily above the slowly final pinto be |\n|   9026.80 | Supplier#000005436 | SAUDI ARABIA |     92926 | Manufacturer#3 | 3HiusYZGYmHItExgX5VfNCdJwkW8W7R          | 30-453-280-6340 | . blithely unusual requests                                                                         |\n|   9007.16 | Supplier#000001747 | EGYPT        |    121746 | Manufacturer#3 | UyDlFjVxanP,ifej7L5jtNaubC               | 14-141-360-9722 | maintain bravely across the busily express pinto beans. sometimes                                   |\n|   8846.35 | Supplier#000005446 | EGYPT        |     57930 | Manufacturer#2 | Nusoq0ckv9SwnJZV8Rw2dUqE,V0ylm Bon       | 14-468-853-6477 | deposits. ironic, bold ideas wake. fluffily ironic deposits must have to sleep furiously pending    |\n|   8837.21 | Supplier#000007210 | JORDAN       |    144695 | Manufacturer#3 | G7MYkWkkJDVu,rr23aXjQCwNqZ2Vk6           | 23-560-295-1805 | en, express foxes use across the blithely bold                                                      |\n|   8800.91 | Supplier#000008182 | EGYPT        |    143153 | Manufacturer#5 | KGMyipBiAF00tSB99DwH                     | 14-658-338-3635 | thely even excuses integrate blithel                                                                |\n|   8788.46 | Supplier#000003437 | IRAN         |    118414 | Manufacturer#4 | JfgZDO9fsP4ljfzsi,s7431Ld3A7zXtHfrF74    | 20-547-871-1712 | ickly unusual dependencies. carefully regular dolphins ha                                           |\n|   8750.12 | Supplier#000001064 | IRAQ         |     31063 | Manufacturer#5 | QgmUIaEs5KpuW ,oREZV2b4wr3HEC1z4F        | 21-440-809-7599 | sly even deposits? furiously regular pack                                                           |\n|   8594.80 | Supplier#000007553 | IRAN         |      5052 | Manufacturer#4 | wAU2Lui w9                               | 20-663-409-7956 | old, stealthy accounts are blithely. fluffily final                                                 |\n|   8594.80 | Supplier#000007553 | IRAN         |    195033 | Manufacturer#1 | wAU2Lui w9                               | 20-663-409-7956 | old, stealthy accounts are blithely. fluffily final                                                 |\n|   8588.63 | Supplier#000008094 | SAUDI ARABIA |    148093 | Manufacturer#1 | SNS6FCscBNZBFecA                         | 30-465-665-6735 | ake quickly blithely ironic theodolites. quickly ironic ideas boost. furiously iro                  |\n|   8522.70 | Supplier#000004208 | IRAQ         |    166659 | Manufacturer#5 | x3jZYF7ZYN 8a4LY1c1kEsh                  | 21-468-998-1571 | furiously regular accounts!                                                                         |\n|   8514.86 | Supplier#000006347 | JORDAN       |    181310 | Manufacturer#5 | wwR5j4kdIAwLe33uBwo                      | 23-340-942-3641 | uests breach blithely ironic deposi                                                                 |\n|   8473.01 | Supplier#000003912 | IRAQ         |     33911 | Manufacturer#3 | Op7,1zt3MAxs34Qo4O W                     | 21-474-809-6508 | es. regular, brave instructions wa                                                                  |\n|   8405.28 | Supplier#000007886 | IRAQ         |    192847 | Manufacturer#4 | sFTj5nzc5EIVmzjXwenFTXD U                | 21-735-778-5786 | ven dependencies boost blithely ironic de                                                           |\n|   8375.58 | Supplier#000001259 | IRAQ         |     38755 | Manufacturer#2 | 32cJBGFFpGEkEjx1sF8JZAy0A72uXL5qU        | 21-427-422-4993 | ironic accounts haggle slyly alongside of the carefully ironic deposit                              |\n|   8351.75 | Supplier#000007495 | IRAQ         |    114983 | Manufacturer#4 | 3jQQGvfs,5Aryhn0Z                        | 21-953-463-7239 | requests. carefully final accounts after the qui                                                    |\n|   8230.12 | Supplier#000001058 | SAUDI ARABIA |     68551 | Manufacturer#2 | fJ8egP,xkLygXGv8bmtc9T1FJ                | 30-496-504-3341 | requests haggle? regular, regular pinto beans integrate fluffily. dependenc                         |\n|   8195.44 | Supplier#000009805 | IRAQ         |      4804 | Manufacturer#4 | dTTmLRYJNat,JbhlQlxwWp HjMR              | 21-838-243-3925 | lets. quickly even theodolites dazzle slyly even a                                                  |\n|   8175.17 | Supplier#000003172 | IRAN         |     55656 | Manufacturer#5 | 8ngbGS7BQoTDmJyMa5WV9XbaM31u5FAayd2vT3   | 20-834-374-7746 | ss deposits use furiously after the quickly final sentiments. fluffily ruthless ideas believe regu  |\n|   8159.13 | Supplier#000007486 | EGYPT        |     17485 | Manufacturer#1 | AjfdzbrrJE1                              | 14-970-643-1521 | ld accounts. enticingly furious requests cajole. final packages s                                   |\n|   8111.40 | Supplier#000007567 | IRAN         |    197566 | Manufacturer#1 | 7W4k2qEVoBkRehprGliXRSYVOQEh             | 20-377-181-7435 | gular foxes. silent attainments boost furiousl                                                      |\n|   8046.55 | Supplier#000001625 | IRAQ         |     14121 | Manufacturer#2 | yKlKMbENR6bfmIu7aCFmbs                   | 21-769-404-7617 | deposits. ideas boost blithely. slyly even Tiresias according to the platelets are q                |\n|   8040.16 | Supplier#000001925 | SAUDI ARABIA |      4424 | Manufacturer#4 | Cu5Ub AAdXT                              | 30-969-417-1108 | pending packages across the regular req                                                             |\n|   8031.68 | Supplier#000002370 | SAUDI ARABIA |    147341 | Manufacturer#5 | xGQB9xSPqRtCuMZaJavOrFuTY7km             | 30-373-388-2352 | dependencies. carefully express deposits use slyly among the slyly unusual pearls. dogge            |\n|   8031.42 | Supplier#000008216 | IRAN         |     83199 | Manufacturer#2 | jsqlyr1ViAo                              | 20-224-305-7298 | to the carefully even excuses haggle blithely against the pending pinto be                          |\n|   8007.83 | Supplier#000006266 | JORDAN       |     81249 | Manufacturer#1 | XWBf5Jd2V5SOurbn11Tt1                    | 23-363-445-7184 | as cajole carefully against the quickly special ac                                                  |\n|   7995.78 | Supplier#000006957 | IRAN         |    161924 | Manufacturer#1 | 8lvRhU5xtXv                              | 20-312-173-2216 | ly ironic accounts. stealthily regular foxes about the blithely ironic requests play blithely abo   |\n|   7913.40 | Supplier#000003148 | JORDAN       |     58137 | Manufacturer#1 | CpCJWI4PHeiwYuq0                         | 23-767-770-9172 | ove the quickly final packages boost fluffily among the furiously final platelets. carefully s      |\n|   7910.16 | Supplier#000002102 | IRAQ         |     99592 | Manufacturer#2 | 1kuyUn5q6czLOGB60fAVgpv68M2suwchpmp2nK   | 21-367-198-9930 | accounts after the blithely                                                                         |\n|   7893.58 | Supplier#000000918 | SAUDI ARABIA |     13414 | Manufacturer#1 | e0sB7xAU3,cWF7pzXrpIbATUNydCUZup         | 30-303-831-1662 | ependencies wake carefull                                                                           |\n|   7885.17 | Supplier#000004001 | JORDAN       |     38994 | Manufacturer#2 | 3M39sZY1XeQXPDRO                         | 23-109-632-6806 | efully express packages integrate across the regular pearls. blithely unusual packages mainta       |\n|   7880.20 | Supplier#000005352 | JORDAN       |       351 | Manufacturer#3 | PP9gHTn946hXqUF5E7idIPLkhnN              | 23-557-756-7951 | egular frays. final instructions sleep a                                                            |\n|   7844.31 | Supplier#000006987 | IRAQ         |     44482 | Manufacturer#5 | UH1zBxTNjTminnmHRe h YUT1eR              | 21-963-444-7397 | nag quickly carefully regular requests. ironic theo                                                 |\n|   7812.27 | Supplier#000006967 | SAUDI ARABIA |    151936 | Manufacturer#4 | S4i1HfrSM4m3di3R9Cxxp59M1                | 30-193-457-6365 | ely. dependencies cajole quickly. final warhorses across the furiously ironic foxes integr          |\n|   7767.63 | Supplier#000004306 | IRAN         |     31802 | Manufacturer#2 | SkZkJZflW5mDg9wL fJ                      | 20-911-180-1895 | uickly regular ideas. blithely express accounts along the carefully sile                            |\n|   7741.42 | Supplier#000000899 | IRAQ         |     53383 | Manufacturer#5 | oLlkiVghtro IwzcwFuzwMCG94rRpux          | 21-980-994-3905 | equests wake quickly special, express accounts. courts promi                                        |\n|   7741.42 | Supplier#000000899 | IRAQ         |    105878 | Manufacturer#3 | oLlkiVghtro IwzcwFuzwMCG94rRpux          | 21-980-994-3905 | equests wake quickly special, express accounts. courts promi                                        |\n|   7741.10 | Supplier#000001059 | IRAN         |    103528 | Manufacturer#4 | 4tBenOMokWbWVRB8i8HwENeO cQjM9           | 20-620-710-8984 | to the carefully special courts.                                                                    |\n|   7599.20 | Supplier#000006596 | SAUDI ARABIA |    184077 | Manufacturer#2 | k8qeFxfXKIGYdQ82RXAfCwddSrc              | 30-804-947-3851 | ously unusual deposits boost carefully after the enticing                                           |\n|   7598.31 | Supplier#000008857 | IRAQ         |     63844 | Manufacturer#4 | dP2th8vneyOLIUFwNBwqixkFD6               | 21-691-170-4769 | s. quickly ironic frays detect carefully                                                            |\n|   7591.79 | Supplier#000009723 | JORDAN       |    104702 | Manufacturer#2 | Q1CkkpDdlLOpCJiV,zIf,Mv86otWhxj7slGc     | 23-710-907-3873 | e fluffily even instructions. packages impress enticingly.                                          |\n|   7575.12 | Supplier#000007557 | IRAQ         |     77556 | Manufacturer#1 | udLvpjNvIx9qeRNdjL1ZAO0OZNOBo6h          | 21-629-935-9941 | ally special accounts nod; f                                                                        |\n|   7496.91 | Supplier#000005828 | IRAN         |    103317 | Manufacturer#1 | Xt0EqDCNU6X00sNsIO7nd0ws3H               | 20-435-850-8703 | furiously about the fluffily careful idea                                                           |\n|   7472.88 | Supplier#000004204 | EGYPT        |     14203 | Manufacturer#1 | 0rGZJ6VZXdH                              | 14-520-667-4690 | y pending pinto beans. even, final requests sleep care                                              |\n|   7472.88 | Supplier#000004204 | EGYPT        |    161687 | Manufacturer#3 | 0rGZJ6VZXdH                              | 14-520-667-4690 | y pending pinto beans. even, final requests sleep care                                              |\n|   7467.63 | Supplier#000003270 | IRAN         |     45757 | Manufacturer#2 | 7j4n5FnNEHVJxFhiyz                       | 20-450-599-9591 | regular, even instructions boost deposits                                                           |\n|   7465.41 | Supplier#000008686 | EGYPT        |    188685 | Manufacturer#4 | 4Onf4yxuNwHCRIC0y                        | 14-454-946-4151 | ly final ideas. bravely unusual deposits doze carefully. expr                                       |\n|   7460.80 | Supplier#000008701 | IRAQ         |     83684 | Manufacturer#3 | PLR2QehcW08                              | 21-747-984-4244 | ideas use carefully pending, final deposits. ironic, pe                                             |\n|   7447.86 | Supplier#000005877 | JORDAN       |    120852 | Manufacturer#2 | EyqOHClZZMJkq grnOX9 4alZx6P7B2fq        | 23-419-288-6451 | lar pinto beans breach carefully final pinto                                                        |\n|   7445.03 | Supplier#000009802 | IRAQ         |    164769 | Manufacturer#5 | y6wLN KiZuTf5HT9Hbm0BELn1GUTD6yl         | 21-116-708-2013 | nic requests. pinto beans across the carefully regular grouches snooze among the final pin          |\n|   7401.46 | Supplier#000008677 | IRAN         |    123652 | Manufacturer#5 | WNa780JZzivxuGBEsDszqoT1Pj               | 20-899-256-5288 | onic instructions along the furiously ironic accounts haggle fluffily silently un                   |\n|   7393.50 | Supplier#000007056 | IRAQ         |     54550 | Manufacturer#1 | M5cAJQvW9D5zwC7o2qkoe                    | 21-175-383-4727 | slyly even requests. forges haggle boldly express requests. furio                                   |\n|   7376.11 | Supplier#000003982 | IRAQ         |    118959 | Manufacturer#1 | jx9EloF33Ez                              | 21-890-236-4160 | s the furiously special warhorses affix after the car                                               |\n|   7264.42 | Supplier#000001565 | IRAQ         |     14061 | Manufacturer#4 | bOwKHdBteMkZoZcxdigk4Tnu07w1gDztmV7hvCw  | 21-791-273-8592 | to beans. express accounts nag around the                                                           |\n|   7256.46 | Supplier#000009116 | IRAQ         |      4115 | Manufacturer#3 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt       | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci                                   |\n|   7256.46 | Supplier#000009116 | IRAQ         |     99115 | Manufacturer#1 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt       | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci                                   |\n|   7256.46 | Supplier#000009116 | IRAQ         |    131576 | Manufacturer#4 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt       | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci                                   |\n|   7254.81 | Supplier#000005664 | EGYPT        |     35663 | Manufacturer#2 | b8VWuTXRt66wF9bfrgTmNGuxf1PU0x3O9e       | 14-214-171-8987 | ts across the quickly pending pin                                                                   |\n|   7186.63 | Supplier#000006958 | IRAN         |     71943 | Manufacturer#4 | 0n9BD,gRzUc3B,PsFcxDBGp4BFf4P            | 20-185-413-5590 | against the instructions. requests are. speci                                                       |\n|   7166.36 | Supplier#000003541 | EGYPT        |    116007 | Manufacturer#1 | DbwyOxoaMEdhEtIB3y045QrKCi2fQpGRu,       | 14-508-763-1850 | ages. carefully unusual requests across the pending instructions aff                                |\n|   7128.81 | Supplier#000000677 | JORDAN       |     50676 | Manufacturer#4 | 8mhrffG7D2WJBSQbOGstQ                    | 23-290-639-3315 | nder blithely. slyly unusual theod                                                                  |\n|   7051.73 | Supplier#000003349 | IRAQ         |    125812 | Manufacturer#3 | wtTK9df9kY7mQ5QUM0Xe5bHLMRLgwE           | 21-614-525-7451 | ar theodolites cajole fluffily across the pending requests. slyly final requests a                  |\n|   7023.47 | Supplier#000009543 | SAUDI ARABIA |     47038 | Manufacturer#1 | VYKinyOBNXRr Hdqn8kOxfTw                 | 30-785-782-6088 | sts. furiously pending packages sleep slyly even requests. final excuses print deposits. final pac  |\n|   6985.93 | Supplier#000006409 | IRAQ         |    131382 | Manufacturer#1 | eO8JDNM19HrlQMR                          | 21-627-356-3992 | sts. slyly final deposits around the regular accounts are along the furiously final pac             |\n|   6964.75 | Supplier#000009931 | EGYPT        |     57425 | Manufacturer#1 | peQYiRFk G0xZKfJ                         | 14-989-166-5782 | deposits according to the sometimes silent requests wake along the packages-- blithely f            |\n|   6964.04 | Supplier#000007399 | IRAQ         |     77398 | Manufacturer#2 | zdxjENOGR4QiCFP                          | 21-859-733-1999 | e blithely after the even requests. carefully ironic packages use slyly a                           |\n|   6913.81 | Supplier#000002625 | IRAQ         |     22624 | Manufacturer#3 | a4V0rWemgbsT ZMj w7DB8rUbZ4F4lqqW5VKljQF | 21-136-564-3910 | . asymptotes among the express requests cajole furiously after the ca                               |\n|   6880.18 | Supplier#000006704 | IRAN         |     26703 | Manufacturer#4 | 97rxJlAImbO1 sUlChUWoOJ0ZzvQ2NI3KI6VDOwk | 20-588-916-1286 | old accounts wake quickly. ca                                                                       |\n|   6878.62 | Supplier#000001697 | IRAQ         |    146668 | Manufacturer#5 | 37nm ODTeHy0xWTWegplgdWQqelh             | 21-377-544-4864 | ironic theodolites. furiously regular d                                                             |\n|   6790.39 | Supplier#000008703 | IRAN         |    123678 | Manufacturer#4 | wMslK1A8SEUTIIdApQ                       | 20-782-266-2552 | eep blithely regular, pending w                                                                     |\n|   6763.46 | Supplier#000007882 | EGYPT        |    137881 | Manufacturer#5 | JDv8BZiYG0UlZ                            | 14-111-252-9120 | the silent accounts wake foxes. furious                                                             |\n|   6751.81 | Supplier#000003156 | EGYPT        |    165607 | Manufacturer#2 | alRWaW4FTFERMM4vf2rHKIKE                 | 14-843-946-7775 | are furiously. final theodolites affix slyly bold deposits. even packages haggle idly slyly specia  |\n|   6702.07 | Supplier#000006276 | EGYPT        |     31269 | Manufacturer#2 | ,dE1anEjKQGZfgquYfkx2fkGcXH              | 14-896-626-7847 | ze about the carefully regular pint                                                                 |\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n100 rows in set\n\nQ3\n+------------+-------------+-------------+----------------+\n| l_orderkey | revenue     | o_orderdate | o_shippriority |\n+------------+-------------+-------------+----------------+\n|    2152675 | 431309.8065 | 1995-03-28  |              0 |\n|    4994400 | 423834.7976 | 1995-03-09  |              0 |\n|    2160291 | 401149.7805 | 1995-03-18  |              0 |\n|    2845094 | 401094.1393 | 1995-03-06  |              0 |\n|    1902471 | 400497.3847 | 1995-03-01  |              0 |\n|    5624358 | 395710.6806 | 1995-03-20  |              0 |\n|    2346242 | 392580.0394 | 1995-03-17  |              0 |\n|    2529826 | 387365.1560 | 1995-02-17  |              0 |\n|    5168933 | 385433.6198 | 1995-03-20  |              0 |\n|    2839239 | 380503.7310 | 1995-03-22  |              0 |\n+------------+-------------+-------------+----------------+\n10 rows in set\n\nQ4\n+-----------------+-------------+\n| o_orderpriority | order_count |\n+-----------------+-------------+\n| 1-URGENT        |       10623 |\n| 2-HIGH          |       10465 |\n| 3-MEDIUM        |       10309 |\n| 4-NOT SPECIFIED |       10618 |\n| 5-LOW           |       10541 |\n+-----------------+-------------+\n5 rows in set\n\nQ5\n+---------------+---------------+\n| n_name        | revenue       |\n+---------------+---------------+\n| PERU          | 56206762.5035 |\n| CANADA        | 56052846.0161 |\n| ARGENTINA     | 54595012.8076 |\n| BRAZIL        | 53601776.5201 |\n| UNITED STATES | 50890580.8962 |\n+---------------+---------------+\n5 rows in set\n\nQ6\n+---------------+\n| revenue       |\n+---------------+\n| 61660051.7967 |\n+---------------+\n\nQ7\n+-------------+-------------+--------+---------------+\n| supp_nation | cust_nation | l_year | revenue       |\n+-------------+-------------+--------+---------------+\n| ARGENTINA   | FRANCE      |   1995 | 57928886.8015 |\n| ARGENTINA   | FRANCE      |   1996 | 55535134.8474 |\n| FRANCE      | ARGENTINA   |   1995 | 52916227.7375 |\n| FRANCE      | ARGENTINA   |   1996 | 51077995.8841 |\n+-------------+-------------+--------+---------------+\n4 rows in set\n\nQ8\n+--------+----------------------+\n| o_year | mkt_share            |\n+--------+----------------------+\n|   1995 | 0.035094304475112484 |\n|   1996 |  0.03724375099464825 |\n+--------+----------------------+\n2 rows in set\n\nQ9\n+----------------+--------+---------------+\n| nation         | o_year | sum_profit    |\n+----------------+--------+---------------+\n| ALGERIA        |   1998 | 29931671.4862 |\n| ALGERIA        |   1997 | 49521023.1139 |\n| ALGERIA        |   1996 | 51283603.7356 |\n| ALGERIA        |   1995 | 50206939.3447 |\n| ALGERIA        |   1994 | 48738988.5891 |\n| ALGERIA        |   1993 | 48084070.1204 |\n| ALGERIA        |   1992 | 49725592.1793 |\n| ARGENTINA      |   1998 | 26407044.9262 |\n| ARGENTINA      |   1997 | 46224601.0785 |\n| ARGENTINA      |   1996 | 44579611.0571 |\n| ARGENTINA      |   1995 | 45081953.2540 |\n| ARGENTINA      |   1994 | 48291282.8512 |\n| ARGENTINA      |   1993 | 48063838.9130 |\n| ARGENTINA      |   1992 | 45277890.2991 |\n| BRAZIL         |   1998 | 28577022.6384 |\n| BRAZIL         |   1997 | 46808660.3688 |\n| BRAZIL         |   1996 | 47119265.0765 |\n| BRAZIL         |   1995 | 47706399.9100 |\n| BRAZIL         |   1994 | 48377469.9386 |\n| BRAZIL         |   1993 | 46933565.7471 |\n| BRAZIL         |   1992 | 47272215.5408 |\n| CANADA         |   1998 | 30500303.6521 |\n| CANADA         |   1997 | 50046257.5687 |\n| CANADA         |   1996 | 52638586.9029 |\n| CANADA         |   1995 | 50433911.3289 |\n| CANADA         |   1994 | 51605251.7124 |\n| CANADA         |   1993 | 50117218.8464 |\n| CANADA         |   1992 | 50347111.2789 |\n| CHINA          |   1998 | 26956001.9487 |\n| CHINA          |   1997 | 48311246.7866 |\n| CHINA          |   1996 | 51133929.1033 |\n| CHINA          |   1995 | 48024289.1049 |\n| CHINA          |   1994 | 50027433.6557 |\n| CHINA          |   1993 | 48240226.3801 |\n| CHINA          |   1992 | 47769117.6007 |\n| EGYPT          |   1998 | 26972573.1604 |\n| EGYPT          |   1997 | 46708654.7666 |\n| EGYPT          |   1996 | 46095050.4457 |\n| EGYPT          |   1995 | 44901908.2949 |\n| EGYPT          |   1994 | 48522762.8892 |\n| EGYPT          |   1993 | 49055807.7642 |\n| EGYPT          |   1992 | 46909796.1083 |\n| ETHIOPIA       |   1998 | 26364411.6457 |\n| ETHIOPIA       |   1997 | 44889623.0645 |\n| ETHIOPIA       |   1996 | 47554295.2892 |\n| ETHIOPIA       |   1995 | 44747639.5440 |\n| ETHIOPIA       |   1994 | 46497570.0631 |\n| ETHIOPIA       |   1993 | 43853718.5460 |\n| ETHIOPIA       |   1992 | 44005773.0397 |\n| FRANCE         |   1998 | 27033406.6353 |\n| FRANCE         |   1997 | 45763555.5515 |\n| FRANCE         |   1996 | 47178544.9301 |\n| FRANCE         |   1995 | 48821282.1929 |\n| FRANCE         |   1994 | 46444640.9397 |\n| FRANCE         |   1993 | 46602311.0590 |\n| FRANCE         |   1992 | 47769356.5113 |\n| GERMANY        |   1998 | 26165681.8305 |\n| GERMANY        |   1997 | 46600844.4431 |\n| GERMANY        |   1996 | 44873520.1979 |\n| GERMANY        |   1995 | 47761215.6058 |\n| GERMANY        |   1994 | 42283120.0209 |\n| GERMANY        |   1993 | 46954873.9820 |\n| GERMANY        |   1992 | 46263626.6361 |\n| INDIA          |   1998 | 27651103.0250 |\n| INDIA          |   1997 | 46000888.8340 |\n| INDIA          |   1996 | 43993476.7354 |\n| INDIA          |   1995 | 44015709.1914 |\n| INDIA          |   1994 | 44281439.6282 |\n| INDIA          |   1993 | 45367255.7857 |\n| INDIA          |   1992 | 45350810.5330 |\n| INDONESIA      |   1998 | 27120545.3120 |\n| INDONESIA      |   1997 | 45745362.3667 |\n| INDONESIA      |   1996 | 45347554.8232 |\n| INDONESIA      |   1995 | 45685709.4978 |\n| INDONESIA      |   1994 | 44738603.1901 |\n| INDONESIA      |   1993 | 45172063.2033 |\n| INDONESIA      |   1992 | 44623924.3942 |\n| IRAN           |   1998 | 27876287.0949 |\n| IRAN           |   1997 | 47184621.5647 |\n| IRAN           |   1996 | 47397859.7878 |\n| IRAN           |   1995 | 49579120.6991 |\n| IRAN           |   1994 | 48032316.8744 |\n| IRAN           |   1993 | 48295593.2066 |\n| IRAN           |   1992 | 50531453.3934 |\n| IRAQ           |   1998 | 29997323.2927 |\n| IRAQ           |   1997 | 52851471.1377 |\n| IRAQ           |   1996 | 53671825.6297 |\n| IRAQ           |   1995 | 53251012.1025 |\n| IRAQ           |   1994 | 50934553.4361 |\n| IRAQ           |   1993 | 51961214.1186 |\n| IRAQ           |   1992 | 50840364.3833 |\n| JAPAN          |   1998 | 26054615.4955 |\n| JAPAN          |   1997 | 43557394.2595 |\n| JAPAN          |   1996 | 46531743.0980 |\n| JAPAN          |   1995 | 41688293.4741 |\n| JAPAN          |   1994 | 45526719.0728 |\n| JAPAN          |   1993 | 45619475.4478 |\n| JAPAN          |   1992 | 44545639.3069 |\n| JORDAN         |   1998 | 24793092.4101 |\n| JORDAN         |   1997 | 42050730.7748 |\n| JORDAN         |   1996 | 42562783.8663 |\n| JORDAN         |   1995 | 42253019.5330 |\n| JORDAN         |   1994 | 45027034.7721 |\n| JORDAN         |   1993 | 44797510.9808 |\n| JORDAN         |   1992 | 41313405.2890 |\n| KENYA          |   1998 | 24550926.4693 |\n| KENYA          |   1997 | 42767120.5848 |\n| KENYA          |   1996 | 45000095.1105 |\n| KENYA          |   1995 | 43250458.0109 |\n| KENYA          |   1994 | 42891596.7158 |\n| KENYA          |   1993 | 43599201.5126 |\n| KENYA          |   1992 | 45286145.8141 |\n| MOROCCO        |   1998 | 23482053.5970 |\n| MOROCCO        |   1997 | 41503033.0020 |\n| MOROCCO        |   1996 | 45645555.9409 |\n| MOROCCO        |   1995 | 44462858.7689 |\n| MOROCCO        |   1994 | 44768368.8310 |\n| MOROCCO        |   1993 | 44611871.2477 |\n| MOROCCO        |   1992 | 43057959.1352 |\n| MOZAMBIQUE     |   1998 | 28824737.9244 |\n| MOZAMBIQUE     |   1997 | 48682746.5995 |\n| MOZAMBIQUE     |   1996 | 50816940.9909 |\n| MOZAMBIQUE     |   1995 | 50010039.0178 |\n| MOZAMBIQUE     |   1994 | 48794892.1253 |\n| MOZAMBIQUE     |   1993 | 48451128.3332 |\n| MOZAMBIQUE     |   1992 | 50113858.5449 |\n| PERU           |   1998 | 30575758.1899 |\n| PERU           |   1997 | 49323405.6808 |\n| PERU           |   1996 | 50063490.6085 |\n| PERU           |   1995 | 51272843.6555 |\n| PERU           |   1994 | 50690589.2334 |\n| PERU           |   1993 | 49086129.3668 |\n| PERU           |   1992 | 50067216.3450 |\n| ROMANIA        |   1998 | 27367992.9903 |\n| ROMANIA        |   1997 | 45668932.7094 |\n| ROMANIA        |   1996 | 46594220.7498 |\n| ROMANIA        |   1995 | 44576835.1623 |\n| ROMANIA        |   1994 | 45640971.0684 |\n| ROMANIA        |   1993 | 46374545.0712 |\n| ROMANIA        |   1992 | 47130533.3076 |\n| RUSSIA         |   1998 | 27486839.8755 |\n| RUSSIA         |   1997 | 44050712.6907 |\n| RUSSIA         |   1996 | 45604597.4983 |\n| RUSSIA         |   1995 | 48972490.6009 |\n| RUSSIA         |   1994 | 45652045.5872 |\n| RUSSIA         |   1993 | 47139548.1597 |\n| RUSSIA         |   1992 | 47159990.1221 |\n| SAUDI ARABIA   |   1998 | 29766229.7961 |\n| SAUDI ARABIA   |   1997 | 51473031.6922 |\n| SAUDI ARABIA   |   1996 | 52859666.6646 |\n| SAUDI ARABIA   |   1995 | 50946175.0229 |\n| SAUDI ARABIA   |   1994 | 53085288.9954 |\n| SAUDI ARABIA   |   1993 | 50907571.2046 |\n| SAUDI ARABIA   |   1992 | 50334063.0381 |\n| UNITED KINGDOM |   1998 | 27904712.8220 |\n| UNITED KINGDOM |   1997 | 48170994.4362 |\n| UNITED KINGDOM |   1996 | 46498116.9611 |\n| UNITED KINGDOM |   1995 | 43210619.0456 |\n| UNITED KINGDOM |   1994 | 47339709.9122 |\n| UNITED KINGDOM |   1993 | 44308436.3275 |\n| UNITED KINGDOM |   1992 | 45870809.6693 |\n| UNITED STATES  |   1998 | 25856187.3719 |\n| UNITED STATES  |   1997 | 44934753.2208 |\n| UNITED STATES  |   1996 | 44826974.2915 |\n| UNITED STATES  |   1995 | 44160425.4086 |\n| UNITED STATES  |   1994 | 43193241.6843 |\n| UNITED STATES  |   1993 | 45126307.2619 |\n| UNITED STATES  |   1992 | 44205926.3317 |\n| VIETNAM        |   1998 | 28289193.6726 |\n| VIETNAM        |   1997 | 48284585.4019 |\n| VIETNAM        |   1996 | 48360225.9084 |\n| VIETNAM        |   1995 | 48742082.6165 |\n| VIETNAM        |   1994 | 49035537.3894 |\n| VIETNAM        |   1993 | 47222674.6352 |\n| VIETNAM        |   1992 | 48628336.9011 |\n+----------------+--------+---------------+\n175 rows in set\n\nQ10\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n| c_custkey | c_name             | revenue     | c_acctbal | n_name         | c_address                                | c_phone         | c_comment                                                                                                       |\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n|     95962 | Customer#000095962 | 704336.0774 |     -9.33 | MOZAMBIQUE     | 83wOMt9iAb9OJ0HbkQ1PaX3odXVBNEIMXaE      | 26-127-693-7436 | nusual theodolites maintain furiously fluffily iro                                                              |\n|     87064 | Customer#000087064 | 684037.4349 |   5244.68 | BRAZIL         | 0xej6ldT8zi7MwLdDJ1II3YWwprkvwB1 I0kwsf  | 12-930-206-2571 | de of the ironic, silent warthogs. bold, r                                                                      |\n|     56416 | Customer#000056416 | 661218.0492 |   4303.82 | INDIA          | CEuBN,xZVmP                              | 18-212-984-8331 | al waters cajole along the slyly unusual dugouts. carefully regular deposits use slyly? packages h              |\n|     46450 | Customer#000046450 | 646205.6835 |   2400.59 | UNITED STATES  | rzWQxB9iFpd8i4KUCAPdv                    | 34-765-320-4326 | ss, final deposits cajole sly                                                                                   |\n|    128713 | Customer#000128713 | 643240.1183 |   7200.30 | ARGENTINA      | mm0kxtHFCchaZX4eYSCCyQHno7vq,SRmv4       | 11-174-994-6880 | ording to the express accounts cajole carefully across the bravely special packages. carefully regular account  |\n|    102187 | Customer#000102187 | 637493.0787 |   -896.03 | ETHIOPIA       | EAi6vcGnWHUMb6rJwn,PtUgSH74tR Aixa       | 15-877-462-6534 | gular packages. carefully regular deposits cajole carefully of the regular requests. carefully special accou    |\n|     42541 | Customer#000042541 | 634546.9756 |   8082.14 | IRAN           | IccOGHgp8g                               | 20-442-159-1337 | cross the final asymptotes. final packages wake furiously ironic dec                                            |\n|     51595 | Customer#000051595 | 611926.8265 |   7236.80 | UNITED STATES  | wQFWZk 7JCpeg50O0KCzSmUFnNNwX1aEQ7V3Q    | 34-844-269-9070 | sts. always express accounts use carefully along the quickly speci                                              |\n|     66391 | Customer#000066391 | 608385.5852 |   9404.57 | UNITED STATES  | V0XvU1Nh9NU4zsyOkm,RBa                   | 34-149-224-8119 | ages cajole carefully carefully bold deposits: fluffily unusual deposits promise slyly carefully ironic co      |\n|     48358 | Customer#000048358 | 603621.4823 |   -611.15 | ETHIOPIA       | ycg3uMG7iDdwQvJ1irr                      | 15-687-936-5181 | the slyly unusual foxes-- carefully regular                                                                     |\n|     99175 | Customer#000099175 | 602125.3304 |   2218.76 | INDONESIA      | 9wbW52xx9T84E0dZ Rvz1ozQ1                | 19-125-912-6494 | ide of the slyly ironic foxes boost silently ironic, even instructions. blithe                                  |\n|    122509 | Customer#000122509 | 601580.1203 |   2613.83 | KENYA          | ZN1sc0eJrkD8t6X5Q1d3                     | 24-421-308-3881 | brave deposits haggle across the even deposits. instr                                                           |\n|    148055 | Customer#000148055 | 601003.6812 |    455.31 | PERU           | Y,RCZ3Bislx64nTsPaRL,5gjx7xgC6y, yKYnCw  | 27-473-476-4382 | uickly final accounts wake carefully sl                                                                         |\n|    117451 | Customer#000117451 | 599792.7063 |   1090.48 | UNITED STATES  | bSwr7mNPiaf1f lNK9 uTJxWCL2sn1Lak5NIB    | 34-354-586-6011 | ding to the furiously express accounts boost carefully af                                                       |\n|    104110 | Customer#000104110 | 588194.3118 |   2762.52 | JORDAN         | mm7 ZuDX5Z5nAQbKObB 80XBCy,1nyW          | 23-639-800-5768 | urts sleep furiously alongside of the packages! slyly ironic packages sleep                                     |\n|     13666 | Customer#000013666 | 579926.1679 |   7453.98 | EGYPT          | DLRUWGcprmWqdROJvmZwpE                   | 14-316-135-4381 | ross the silent requests. special theodolit                                                                     |\n|     96202 | Customer#000096202 | 571017.3398 |   4703.04 | CANADA         | 4Vcxcx3w4zMjVYNQaqrweweQY6TJO AP9rdvQaLl | 13-194-779-9597 | en packages use. fluffily regular dependencies boost. never pending requ                                        |\n|     70279 | Customer#000070279 | 561369.3650 |   9109.34 | CHINA          | ltie8o3ihwffMrqMrkvN957KZVWmH5           | 28-842-825-1717 | theodolites sleep: blithely final requests are fur                                                              |\n|     16972 | Customer#000016972 | 560435.8065 |   6408.66 | ROMANIA        | X6T8vRKy6kSO0f2wJJt                      | 29-483-958-3347 | sts. pending deposits are across the regular, express instructions. carefully daring foxes cajol                |\n|    113443 | Customer#000113443 | 557272.6706 |    -72.67 | UNITED KINGDOM | SUHbS85cYxgVkKbfh9sUpEa6ezVSlQuCKe3CV    | 33-819-742-6112 | ic foxes cajole thinly furiously stealthy instructions. pinto beans are. quickly regular accounts integrate car |\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n20 rows in set\n\nQ11\n+------------+-------------+\n| ps_partkey | value       |\n+------------+-------------+\n|     131630 | 17882680.37 |\n|     104150 | 17613017.18 |\n|     128284 | 16502418.74 |\n|       8978 | 16470438.59 |\n|     147193 | 16462742.12 |\n|      78788 | 16010246.37 |\n|      76331 | 15776882.05 |\n|     137287 | 15770471.15 |\n|      51302 | 15730620.22 |\n|     141553 | 15333540.19 |\n|     137196 | 15035435.60 |\n|     186531 | 14818272.68 |\n|     103818 | 14690943.63 |\n|      80080 | 14626441.35 |\n|       1312 | 14330729.50 |\n|       6531 | 14267308.08 |\n|      96162 | 14154396.04 |\n|      69605 | 14018927.25 |\n|      30118 | 13854726.38 |\n|      17006 | 13731495.60 |\n|      95347 | 13716648.60 |\n|      18722 | 13707978.71 |\n|     122875 | 13640341.00 |\n|     105499 | 13532912.80 |\n|     165560 | 13509536.95 |\n|       1531 | 13337454.55 |\n|      34732 | 13304041.48 |\n|     173221 | 13038078.41 |\n|     180975 | 13038039.17 |\n|      24703 | 12957050.80 |\n|      72036 | 12939426.90 |\n|     124814 | 12849842.04 |\n|     174453 | 12814999.00 |\n|      14209 | 12814858.56 |\n|     185186 | 12657201.05 |\n|     187868 | 12647101.80 |\n|     125085 | 12639931.63 |\n|      80331 | 12625007.00 |\n|     118685 | 12515185.68 |\n|     163988 | 12484272.80 |\n|     124685 | 12432747.32 |\n|      92838 | 12410071.57 |\n|     140928 | 12396673.84 |\n|       1218 | 12362877.75 |\n|      39201 | 12328085.10 |\n|      33237 | 12180622.98 |\n|     183791 | 12150040.50 |\n|       3243 | 12136315.74 |\n|      62740 | 12131313.60 |\n|     154171 | 12105470.89 |\n|      49034 | 11982382.52 |\n|      88673 | 11925499.04 |\n|      52527 | 11923653.16 |\n|      83974 | 11871084.73 |\n|      88254 | 11870393.22 |\n|        411 | 11806670.95 |\n|      14320 | 11800136.02 |\n|     164979 | 11794760.03 |\n|     166149 | 11778499.72 |\n|      74105 | 11750224.34 |\n|     169104 | 11708532.18 |\n|      15542 | 11687293.42 |\n|     161538 | 11661769.80 |\n|      63337 | 11592505.40 |\n|     117197 | 11508165.60 |\n|     102989 | 11497056.75 |\n|      10836 | 11465875.43 |\n|     199561 | 11431793.36 |\n|     134683 | 11384564.54 |\n|     136318 | 11351893.30 |\n|     166270 | 11336004.81 |\n|      32200 | 11324838.00 |\n|      57033 | 11281026.52 |\n|      18098 | 11245398.24 |\n|     135174 | 11189782.12 |\n|     181616 | 11183947.65 |\n|      85064 | 11175761.43 |\n|     120719 | 11164342.08 |\n|      99670 | 11140257.47 |\n|      46096 | 11034143.76 |\n|     195124 | 11030197.30 |\n|      78838 | 11012446.40 |\n|     151656 | 11010376.90 |\n|     156956 | 10996384.80 |\n|      34028 | 10942671.24 |\n|      15778 | 10937778.75 |\n|     199707 | 10924333.33 |\n|     118776 | 10920609.31 |\n|      27640 | 10919693.42 |\n|      15237 | 10918145.54 |\n|     148243 | 10916765.29 |\n|     111498 | 10867707.51 |\n|     132024 | 10834280.47 |\n|      35124 | 10806898.50 |\n|     196818 | 10787371.25 |\n|     197669 | 10779504.60 |\n|     110042 | 10778828.37 |\n|     197422 | 10770092.44 |\n|      75160 | 10746976.60 |\n|     191567 | 10642430.39 |\n|      34225 | 10574664.41 |\n|     102588 | 10567012.05 |\n|      44148 | 10505249.34 |\n|     126607 | 10484944.29 |\n|     172625 | 10444857.62 |\n|     157054 | 10406203.24 |\n|      19322 | 10378704.98 |\n|     136541 | 10371536.77 |\n|     167526 | 10320346.58 |\n|     136011 | 10302146.84 |\n|     107431 | 10273992.76 |\n|      16485 | 10257703.67 |\n|      52580 | 10250264.05 |\n|        839 | 10238243.36 |\n|      31704 | 10196678.94 |\n|     122558 | 10137326.18 |\n|     180386 | 10123318.07 |\n|      97705 | 10089163.37 |\n|      96327 | 10087851.88 |\n|     136143 | 10082137.97 |\n|      15174 | 10057277.55 |\n|     193324 | 10039922.93 |\n|      33593 | 10019952.10 |\n|     126288 | 10014855.05 |\n|      64123 |  9985650.90 |\n|     183712 |  9973256.18 |\n|     138831 |  9963069.10 |\n|     123694 |  9959096.38 |\n|      51734 |  9952439.73 |\n|      11861 |  9949647.12 |\n|     119127 |  9942105.69 |\n|     173308 |  9932264.52 |\n|      40986 |  9921554.40 |\n|     176970 |  9919708.65 |\n|      54316 |  9913595.16 |\n|      62644 |  9903936.27 |\n|     185354 |  9895956.52 |\n|      81468 |  9885132.60 |\n|     104687 |  9883888.05 |\n|     198959 |  9875351.28 |\n|     179767 |  9872309.86 |\n|     102835 |  9870743.52 |\n|     163221 |  9856173.04 |\n|      32633 |  9852565.04 |\n|      19605 |  9850164.48 |\n|      47378 |  9826135.11 |\n|      44026 |  9822433.44 |\n|     126629 |  9816227.30 |\n|     199665 |  9812400.23 |\n|      30989 |  9812295.52 |\n|     102177 |  9810372.32 |\n|      25765 |  9806344.88 |\n|     110721 |  9804895.23 |\n|     159532 |  9803738.34 |\n|     101640 |  9801375.65 |\n|     151569 |  9792489.20 |\n|     180629 |  9782164.34 |\n|     165528 |  9769074.10 |\n|      23772 |  9766084.22 |\n|     149727 |  9765190.96 |\n|     189605 |  9761887.80 |\n|      74703 |  9758757.28 |\n|      83382 |  9758144.21 |\n|      93775 |  9726901.71 |\n|      56192 |  9725508.16 |\n|      50060 |  9712714.65 |\n|      15409 |  9706898.91 |\n|     139104 |  9701070.72 |\n|     177435 |  9686566.09 |\n|      31351 |  9675197.98 |\n|      20495 |  9672566.31 |\n|      24537 |  9654516.03 |\n|     160528 |  9650804.70 |\n|      34706 |  9647241.90 |\n|     149039 |  9643498.32 |\n|     147139 |  9642356.34 |\n|     118629 |  9624960.80 |\n|      35359 |  9621549.92 |\n|      33854 |  9616857.73 |\n|      33707 |  9609988.84 |\n|     149055 |  9599364.32 |\n|     127429 |  9580670.49 |\n|      67575 |  9579613.26 |\n|      80727 |  9576545.81 |\n|     181650 |  9574445.40 |\n|      50176 |  9573389.08 |\n|     171093 |  9571625.20 |\n|     151342 |  9569230.21 |\n|     123052 |  9561903.68 |\n|     132633 |  9545052.14 |\n|     130419 |  9524936.49 |\n|      89241 |  9512992.32 |\n|     138255 |  9503515.93 |\n|      31680 |  9502841.07 |\n|     151986 |  9500862.59 |\n|     146390 |  9490242.96 |\n|      62275 |  9475584.10 |\n|      33518 |  9475074.40 |\n|       5286 |  9473739.88 |\n|      39020 |  9467701.22 |\n|     113281 |  9466510.94 |\n|     138789 |  9464407.24 |\n|     165040 |  9462153.75 |\n|     150766 |  9461855.88 |\n|      54341 |  9459425.45 |\n|      33464 |  9459377.37 |\n|      15251 |  9455980.84 |\n|     145308 |  9454189.29 |\n|     192621 |  9449324.14 |\n|     175218 |  9448987.35 |\n|      58992 |  9446144.40 |\n|      24548 |  9442739.03 |\n|     177563 |  9440891.04 |\n|     184482 |  9431486.10 |\n|      78961 |  9430401.05 |\n|     174167 |  9428622.96 |\n|      88265 |  9423143.28 |\n|       6057 |  9405359.37 |\n|      85387 |  9402175.55 |\n|      47053 |  9399707.66 |\n|     128973 |  9399265.92 |\n|      65668 |  9395584.45 |\n|      50222 |  9394502.96 |\n|     116534 |  9388011.08 |\n|     140959 |  9386284.56 |\n|      46897 |  9385056.21 |\n|     141872 |  9383820.48 |\n|     177181 |  9383551.92 |\n|     168265 |  9376664.16 |\n|      48974 |  9374769.12 |\n|      46218 |  9364135.50 |\n|     104039 |  9363227.03 |\n|      61538 |  9360159.08 |\n|      94688 |  9359604.98 |\n|     122393 |  9357937.19 |\n|       7323 |  9356712.30 |\n|     197892 |  9356573.44 |\n|     194056 |  9352381.73 |\n|      61285 |  9348480.54 |\n|     180336 |  9347874.15 |\n|     121930 |  9347784.74 |\n|      80652 |  9347143.50 |\n|      18549 |  9346038.72 |\n|      23992 |  9339908.16 |\n|     136583 |  9337299.56 |\n|     156151 |  9337138.10 |\n|     160572 |  9336553.40 |\n|     113391 |  9335558.10 |\n|      48068 |  9334317.92 |\n|      20409 |  9331093.65 |\n|      39712 |  9324685.28 |\n|      59364 |  9322249.86 |\n|       1344 |  9308304.39 |\n|      60549 |  9308293.20 |\n|      83854 |  9307387.25 |\n|      92092 |  9307165.64 |\n|     193306 |  9306177.31 |\n|     118265 |  9300250.20 |\n|     107568 |  9296254.34 |\n|     109127 |  9293552.10 |\n|     184688 |  9291647.92 |\n|       8718 |  9287337.37 |\n|      80433 |  9286295.52 |\n|      26670 |  9284963.44 |\n|     139548 |  9283605.21 |\n|      14736 |  9280119.20 |\n|      97886 |  9273852.42 |\n|     181442 |  9273130.50 |\n|     172360 |  9272824.92 |\n|     192714 |  9268366.36 |\n|     106726 |  9264879.90 |\n|      72157 |  9263498.40 |\n|      70445 |  9257553.92 |\n|      75148 |  9257420.83 |\n|      26170 |  9256074.12 |\n|     116531 |  9249721.71 |\n|     133665 |  9245464.80 |\n|     129041 |  9244629.48 |\n|     136486 |  9240748.92 |\n|     198924 |  9239976.06 |\n|     115254 |  9233580.37 |\n|     168135 |  9232693.98 |\n|      22480 |  9232190.78 |\n|     192018 |  9230386.58 |\n|     111889 |  9228204.96 |\n|     151661 |  9227926.90 |\n|      96482 |  9226960.85 |\n|      49198 |  9226436.40 |\n|      41219 |  9222883.52 |\n|     113502 |  9222208.59 |\n|      84009 |  9218703.22 |\n|     192788 |  9213468.00 |\n|     160251 |  9206353.32 |\n|     188162 |  9200537.88 |\n|     167589 |  9195835.03 |\n|     132673 |  9194021.22 |\n|     191105 |  9192417.12 |\n|     128748 |  9189941.55 |\n|     130423 |  9184710.96 |\n|      22639 |  9182963.16 |\n|     199034 |  9180909.86 |\n|     187644 |  9180350.20 |\n|        970 |  9175757.70 |\n|      59070 |  9170000.64 |\n|      66568 |  9166070.04 |\n|      52715 |  9161221.80 |\n|     130276 |  9161201.57 |\n|      24189 |  9160740.15 |\n|     132402 |  9144498.48 |\n|      37799 |  9142271.24 |\n|     173337 |  9140566.68 |\n|     176552 |  9135054.51 |\n|     195714 |  9133679.77 |\n|     119363 |  9123261.90 |\n|     161160 |  9122259.60 |\n|     196968 |  9111592.20 |\n|      61943 |  9111527.33 |\n|      79766 |  9109534.89 |\n|     178082 |  9105694.92 |\n|      38800 |  9105468.72 |\n|      83608 |  9099493.68 |\n|     146346 |  9098628.00 |\n|     116690 |  9098099.93 |\n|      64690 |  9095441.10 |\n|      82061 |  9095381.18 |\n|      89015 |  9092660.48 |\n|     188457 |  9091400.40 |\n|     125177 |  9090455.55 |\n|     114776 |  9088177.68 |\n|       4486 |  9087487.20 |\n|     176940 |  9086842.84 |\n|      93157 |  9084361.81 |\n|     148624 |  9083370.78 |\n|       4441 |  9079520.58 |\n|      63590 |  9079125.44 |\n|     174189 |  9078023.39 |\n|      63054 |  9075441.98 |\n|      14950 |  9073156.19 |\n|     175646 |  9072322.47 |\n|      63712 |  9067710.48 |\n|     157197 |  9067452.77 |\n|     147196 |  9064699.80 |\n|      50551 |  9062434.72 |\n|      43035 |  9061782.03 |\n|     187679 |  9056529.40 |\n|      96673 |  9056525.94 |\n|     130148 |  9054217.06 |\n|     159007 |  9053155.29 |\n|      41544 |  9052820.94 |\n|     109476 |  9048012.09 |\n|      60092 |  9045562.44 |\n|     197490 |  9044579.88 |\n|      47311 |  9037223.52 |\n|      87230 |  9033227.61 |\n|       3860 |  9030622.02 |\n|       5466 |  9029841.66 |\n|     171537 |  9024699.30 |\n|      39707 |  9022833.12 |\n|     167048 |  9022709.18 |\n|     109006 |  9022258.40 |\n|      17910 |  9019688.45 |\n|     132826 |  9017286.74 |\n|     157502 |  9016444.08 |\n|     142309 |  9016270.60 |\n|      78891 |  9005693.25 |\n|      88301 |  9002414.82 |\n|      11496 |  9000803.97 |\n|     163633 |  8996162.06 |\n|     151809 |  8993104.95 |\n|     131555 |  8988340.68 |\n|      72812 |  8985370.68 |\n|      77047 |  8981489.79 |\n|       1553 |  8977226.10 |\n|     162531 |  8973689.92 |\n|     154026 |  8973320.24 |\n|     125499 |  8969667.84 |\n|      34547 |  8966116.43 |\n|      41301 |  8965350.42 |\n|      12853 |  8959403.59 |\n|      27736 |  8957933.23 |\n|     162817 |  8956868.20 |\n|     155389 |  8955349.85 |\n|     130360 |  8952928.25 |\n|     120878 |  8952393.10 |\n|     150671 |  8952112.72 |\n|     190365 |  8951671.57 |\n|      72364 |  8950587.82 |\n|      71615 |  8949277.07 |\n|      95277 |  8947796.58 |\n|      78180 |  8946814.80 |\n|      97062 |  8945057.46 |\n|     170013 |  8944660.40 |\n|     113426 |  8943016.29 |\n|     173751 |  8942914.28 |\n|       1478 |  8941906.24 |\n|      26061 |  8941022.48 |\n|     152527 |  8939654.10 |\n|     148360 |  8939589.40 |\n|      44057 |  8939101.36 |\n|      13595 |  8936720.10 |\n|      33337 |  8935366.48 |\n|     169698 |  8931507.20 |\n|      26155 |  8927283.11 |\n|      17185 |  8927218.40 |\n|      51996 |  8926661.08 |\n|     101869 |  8919281.70 |\n|      14561 |  8910653.92 |\n|     190047 |  8909427.90 |\n|     104143 |  8909328.40 |\n|     133330 |  8907195.90 |\n|     169144 |  8904989.34 |\n|      87067 |  8900079.44 |\n|     176075 |  8898845.64 |\n|      25076 |  8895274.12 |\n|      80838 |  8895205.30 |\n|      40387 |  8890891.55 |\n|      88004 |  8888748.80 |\n|     105527 |  8888672.72 |\n|      40741 |  8886674.24 |\n|      76690 |  8880622.61 |\n|      86485 |  8880488.57 |\n|      75736 |  8877666.06 |\n|      48704 |  8876626.52 |\n|      56450 |  8872277.59 |\n|      61683 |  8870173.93 |\n|      24067 |  8867814.12 |\n|     108012 |  8863632.38 |\n|     180971 |  8862007.20 |\n|     132986 |  8861335.20 |\n|      35839 |  8859344.64 |\n|     191553 |  8857411.14 |\n|     163492 |  8855825.91 |\n|     112101 |  8851904.10 |\n|      27050 |  8847924.19 |\n|      57481 |  8845309.59 |\n|     163252 |  8842276.65 |\n|      87958 |  8840221.67 |\n|      60162 |  8838927.08 |\n|     131928 |  8838900.48 |\n|     123514 |  8833601.14 |\n|      42891 |  8830401.37 |\n|      71547 |  8829540.72 |\n|      13975 |  8826582.48 |\n|      31577 |  8825371.40 |\n|      86165 |  8816308.38 |\n|     164646 |  8815470.18 |\n|     150176 |  8814992.11 |\n|     152464 |  8814533.82 |\n|     183434 |  8813941.24 |\n|      58839 |  8808010.20 |\n|      59952 |  8801497.32 |\n|     151038 |  8800215.80 |\n|     139523 |  8800032.57 |\n|       8828 |  8798704.66 |\n|      14080 |  8797032.12 |\n|     194080 |  8792825.27 |\n|      87199 |  8788933.64 |\n|      91747 |  8785811.64 |\n|     194429 |  8776185.03 |\n|     118998 |  8776071.00 |\n|     179467 |  8771474.74 |\n|      68715 |  8771302.80 |\n|     180572 |  8771095.68 |\n|      19821 |  8770770.82 |\n|      41702 |  8770565.71 |\n|      27916 |  8769001.47 |\n|     121302 |  8763598.50 |\n|     107013 |  8762893.37 |\n|      37287 |  8761196.43 |\n|     117050 |  8758230.00 |\n|      58547 |  8757757.40 |\n|     197088 |  8749026.12 |\n|      55839 |  8747234.02 |\n|      71829 |  8744546.91 |\n|      30961 |  8743416.92 |\n|     134548 |  8741635.28 |\n|     179833 |  8738680.00 |\n|      79721 |  8737857.70 |\n|     144577 |  8736427.08 |\n|      29051 |  8729063.28 |\n|     131481 |  8728799.64 |\n|      73271 |  8727985.25 |\n|      89553 |  8725727.19 |\n|      31306 |  8724451.12 |\n|      82181 |  8724017.16 |\n|      95549 |  8723460.30 |\n|      31507 |  8722094.40 |\n|      21302 |  8722054.95 |\n|     137953 |  8721611.83 |\n|     195768 |  8721020.99 |\n|     180105 |  8718021.20 |\n|      98241 |  8717935.36 |\n|      59431 |  8715482.28 |\n|     143694 |  8713267.63 |\n|     109020 |  8713043.36 |\n|      46732 |  8711642.04 |\n|     144172 |  8711013.10 |\n|     139056 |  8710786.50 |\n|     107543 |  8706135.75 |\n|      89127 |  8705410.56 |\n|     146544 |  8704812.86 |\n|     195524 |  8699333.14 |\n|     133563 |  8698060.14 |\n|     112707 |  8694322.84 |\n|      98951 |  8690376.70 |\n|     132635 |  8689305.24 |\n|      69056 |  8688980.25 |\n|     134143 |  8688695.26 |\n|     148150 |  8687553.16 |\n|      89122 |  8686767.31 |\n|      15085 |  8685772.26 |\n|     196686 |  8682783.57 |\n|       3076 |  8672940.78 |\n|     137428 |  8672547.80 |\n|      27263 |  8671719.36 |\n|     101561 |  8667962.72 |\n|      12597 |  8662223.52 |\n|     143329 |  8661688.72 |\n|     130813 |  8659409.04 |\n|     183679 |  8658698.30 |\n|      47449 |  8658493.58 |\n|     164677 |  8658220.00 |\n|      51437 |  8654713.02 |\n|     116162 |  8649713.36 |\n|      71889 |  8645159.67 |\n|       6486 |  8639891.76 |\n|     192102 |  8638102.72 |\n|     101660 |  8634451.80 |\n|     124703 |  8633146.86 |\n|     150469 |  8631948.60 |\n|     197467 |  8630739.78 |\n|      97621 |  8630453.32 |\n|     150354 |  8630288.15 |\n|     179544 |  8630121.63 |\n|      38972 |  8626072.00 |\n|     110732 |  8625761.16 |\n|     170791 |  8625203.06 |\n|     149414 |  8617070.17 |\n|      59527 |  8616079.20 |\n|     157580 |  8615676.04 |\n|      16268 |  8615087.46 |\n|      76464 |  8610219.38 |\n|      44474 |  8607934.92 |\n|     125527 |  8607708.08 |\n|     118076 |  8602251.65 |\n|     180362 |  8601367.05 |\n|       5808 |  8599851.04 |\n|      28703 |  8599486.36 |\n|     113373 |  8597996.36 |\n|     118918 |  8597063.80 |\n|      44868 |  8596304.52 |\n|      43419 |  8596265.35 |\n|      89763 |  8595248.64 |\n|     119232 |  8594224.56 |\n|     108649 |  8590683.68 |\n|      10396 |  8588398.05 |\n|      79536 |  8587117.83 |\n|     149800 |  8587058.86 |\n|     165839 |  8582991.20 |\n|     115397 |  8581524.77 |\n|     104394 |  8581384.42 |\n|     142569 |  8581127.40 |\n|      63676 |  8580930.08 |\n|      29029 |  8580613.53 |\n|     156604 |  8580477.00 |\n|       7310 |  8579949.50 |\n|     105381 |  8576164.24 |\n|      84306 |  8573960.40 |\n|      61217 |  8570393.04 |\n|     164438 |  8569616.36 |\n|      28073 |  8565639.60 |\n|     125743 |  8563258.90 |\n|     190032 |  8561620.55 |\n|     147122 |  8561245.68 |\n|       5384 |  8558830.08 |\n|      70172 |  8558319.64 |\n|     161966 |  8556193.38 |\n|      69530 |  8554377.60 |\n|     111243 |  8553627.55 |\n|      72590 |  8551077.51 |\n|     134423 |  8550604.77 |\n|      44509 |  8547134.31 |\n|     160707 |  8546000.68 |\n|      54123 |  8545976.26 |\n|      36547 |  8540333.04 |\n|      48715 |  8537983.35 |\n|     103078 |  8537142.60 |\n|     137613 |  8536278.96 |\n|      44995 |  8532416.72 |\n|     191159 |  8532173.37 |\n|     119345 |  8532070.56 |\n|     109941 |  8531904.79 |\n|       5449 |  8528034.35 |\n|     134116 |  8526854.95 |\n|     199268 |  8523599.58 |\n|     168520 |  8523360.67 |\n|     154189 |  8521620.13 |\n|     108771 |  8513853.87 |\n|     198651 |  8511238.80 |\n|      93681 |  8510935.14 |\n|     170680 |  8509087.68 |\n|     106409 |  8506859.19 |\n|      27110 |  8499811.75 |\n|      43224 |  8499539.52 |\n|     153225 |  8499434.28 |\n|      16681 |  8498021.66 |\n|     117983 |  8496934.32 |\n|     192158 |  8492372.03 |\n|      33900 |  8491139.64 |\n|      37006 |  8489126.28 |\n|     176554 |  8488633.92 |\n|      69234 |  8484937.26 |\n|     176652 |  8484496.02 |\n|      41660 |  8480585.65 |\n|     129104 |  8480411.17 |\n|      66960 |  8478978.86 |\n|      36296 |  8472438.75 |\n|      98665 |  8471241.57 |\n|     134173 |  8467888.57 |\n|      60496 |  8467019.22 |\n|     197520 |  8466553.20 |\n|     116746 |  8465792.60 |\n|     187394 |  8458248.24 |\n|     140377 |  8455546.68 |\n|      97326 |  8450501.67 |\n|      26770 |  8449625.64 |\n|     104884 |  8446152.26 |\n|     143109 |  8443547.19 |\n|     127361 |  8441094.08 |\n|     104754 |  8436883.50 |\n|     183676 |  8436165.76 |\n|        906 |  8434608.12 |\n|      55768 |  8433763.69 |\n|     118654 |  8433465.57 |\n|      39310 |  8433214.55 |\n|     173261 |  8432992.53 |\n|      93976 |  8432605.20 |\n|      63318 |  8432149.26 |\n|     128243 |  8424182.94 |\n|     156063 |  8422743.54 |\n|     195087 |  8421279.30 |\n|      67668 |  8417594.98 |\n|      49882 |  8417237.80 |\n|     105631 |  8412628.07 |\n|      40987 |  8406033.41 |\n|     185735 |  8404112.83 |\n|     173986 |  8403050.34 |\n|      87372 |  8402838.40 |\n|      24509 |  8398807.24 |\n|     180522 |  8394989.75 |\n|      76215 |  8394433.35 |\n|     193872 |  8390435.23 |\n|     141234 |  8390180.92 |\n|      91138 |  8386645.20 |\n|      28097 |  8385577.38 |\n|       4053 |  8384952.75 |\n|      17050 |  8380304.40 |\n|      64050 |  8377921.56 |\n|      80836 |  8375803.16 |\n|      86084 |  8373551.95 |\n|     168499 |  8373348.72 |\n|     178642 |  8372218.52 |\n|       8498 |  8370557.16 |\n|     156312 |  8366249.30 |\n|     136803 |  8361949.92 |\n|      92109 |  8359503.23 |\n|     138625 |  8358135.21 |\n|     137540 |  8358031.08 |\n|     176531 |  8355437.00 |\n|      53783 |  8352395.63 |\n|     106977 |  8352334.98 |\n|      21385 |  8351786.37 |\n|     114885 |  8351582.40 |\n|     113643 |  8350530.65 |\n|      89061 |  8349422.08 |\n|      77752 |  8348730.24 |\n|      28623 |  8348321.44 |\n|      74478 |  8348064.27 |\n|      41383 |  8347223.45 |\n|     147632 |  8346967.80 |\n|      40948 |  8346743.30 |\n|     154324 |  8346521.91 |\n|      89724 |  8346034.80 |\n|     119083 |  8338084.92 |\n|     124143 |  8335841.76 |\n|      80512 |  8335705.69 |\n|     105047 |  8332249.86 |\n|      38243 |  8329017.19 |\n|      42583 |  8328613.91 |\n|      44240 |  8327684.64 |\n|      57611 |  8321693.94 |\n|       9730 |  8319725.70 |\n|      91655 |  8318837.40 |\n|      13140 |  8316216.96 |\n|     112257 |  8315169.85 |\n|      27182 |  8314740.99 |\n|     166654 |  8314332.64 |\n|      40572 |  8312654.55 |\n|      26680 |  8311626.68 |\n|     138947 |  8311347.29 |\n|     184982 |  8310393.08 |\n|      35540 |  8308058.43 |\n|     181446 |  8304851.76 |\n|      65160 |  8299581.90 |\n|       9533 |  8299139.42 |\n|      67836 |  8294228.46 |\n|     159414 |  8293114.90 |\n|     115025 |  8291746.65 |\n|      30780 |  8291580.00 |\n|     164680 |  8290263.02 |\n|       4599 |  8288816.03 |\n|      73366 |  8286818.96 |\n|     135625 |  8284930.92 |\n|      46497 |  8284638.88 |\n|      63781 |  8284447.60 |\n|      84332 |  8283372.14 |\n|     196269 |  8276407.36 |\n|     166651 |  8275663.35 |\n|        142 |  8273960.31 |\n|      56904 |  8272891.44 |\n|      46821 |  8272603.71 |\n|      76051 |  8272300.75 |\n|      19666 |  8270192.64 |\n|      92723 |  8267074.20 |\n|     125843 |  8266816.38 |\n|     158722 |  8266634.88 |\n|      28941 |  8266245.12 |\n|      39968 |  8265605.53 |\n|      41429 |  8265317.84 |\n|      61601 |  8264074.31 |\n|     179159 |  8260137.47 |\n|      15969 |  8259835.96 |\n|     121125 |  8253912.49 |\n|      66486 |  8253743.66 |\n|     181031 |  8253570.14 |\n|      43712 |  8250825.78 |\n|      13842 |  8245765.00 |\n|      76203 |  8245412.16 |\n|      68992 |  8243081.46 |\n|     119704 |  8241363.06 |\n|      86109 |  8240377.92 |\n|      29534 |  8239914.00 |\n|      68596 |  8239825.29 |\n|     168291 |  8237626.32 |\n|     183308 |  8235947.21 |\n|      78657 |  8233481.64 |\n|     193545 |  8233037.49 |\n|      23658 |  8232306.18 |\n|     179945 |  8231365.25 |\n|      53391 |  8231252.10 |\n|      71380 |  8231125.68 |\n|      53666 |  8226715.00 |\n|     118592 |  8226181.00 |\n|      67203 |  8225355.99 |\n|       1178 |  8224625.05 |\n|     147876 |  8224189.62 |\n|      80042 |  8220826.70 |\n|      48950 |  8218611.22 |\n|      43331 |  8218448.04 |\n|     177706 |  8215723.50 |\n|     145442 |  8215706.16 |\n|     197042 |  8215536.00 |\n|     169952 |  8214698.43 |\n|      57907 |  8211740.04 |\n|     145741 |  8210316.57 |\n|      91144 |  8209855.02 |\n|     160266 |  8209468.80 |\n|      31602 |  8209366.90 |\n|      98672 |  8208412.85 |\n|     199012 |  8207897.50 |\n|     151148 |  8207645.16 |\n|     116545 |  8207573.24 |\n|     122176 |  8207508.04 |\n|      11021 |  8206766.10 |\n|      47752 |  8203436.82 |\n|        124 |  8203209.30 |\n|     148126 |  8202846.66 |\n|      15753 |  8202695.55 |\n|      50833 |  8200880.16 |\n|      11523 |  8196478.02 |\n|      71478 |  8195930.68 |\n|     129262 |  8190520.80 |\n|      43023 |  8186451.85 |\n|     119193 |  8184853.14 |\n|      85067 |  8182638.86 |\n|     164534 |  8181563.04 |\n|      82556 |  8180455.14 |\n|      31813 |  8179417.14 |\n|      81345 |  8173128.69 |\n|      38413 |  8172464.04 |\n|     106014 |  8171418.35 |\n|     191180 |  8170663.97 |\n|      43274 |  8169669.72 |\n|       5837 |  8166123.50 |\n|      63332 |  8161839.60 |\n|      47668 |  8161790.04 |\n|     112468 |  8160728.40 |\n|     132541 |  8160680.00 |\n|      59457 |  8160393.33 |\n|      71751 |  8159865.19 |\n|     118395 |  8156795.00 |\n|     132390 |  8154867.54 |\n|      44792 |  8153384.22 |\n|     128838 |  8153018.30 |\n|      87197 |  8152281.72 |\n|     187978 |  8150832.56 |\n|     147419 |  8150063.60 |\n|     149166 |  8149406.78 |\n|     196012 |  8147307.42 |\n|     190519 |  8145402.96 |\n|     151511 |  8144276.58 |\n|      88891 |  8140166.24 |\n|     168056 |  8139101.96 |\n|     189186 |  8136933.25 |\n|     117326 |  8136047.82 |\n|      60575 |  8133316.80 |\n|      75452 |  8130427.37 |\n|     194126 |  8129751.80 |\n|     130199 |  8129270.88 |\n|      41680 |  8128823.40 |\n|     107624 |  8125799.20 |\n|     135069 |  8123999.10 |\n|     119032 |  8123770.24 |\n|      27635 |  8123076.65 |\n|      14317 |  8121553.23 |\n|     148018 |  8119898.16 |\n|      51152 |  8118370.26 |\n|     112643 |  8117331.37 |\n|     119526 |  8116075.80 |\n|     192084 |  8114896.38 |\n|     151385 |  8114711.28 |\n|     160836 |  8112053.68 |\n|      91468 |  8111785.50 |\n|      58877 |  8108256.25 |\n|      41885 |  8107026.81 |\n|     155542 |  8106757.18 |\n|     149968 |  8104953.78 |\n|     168380 |  8103576.00 |\n|     134641 |  8101092.32 |\n|      92470 |  8100877.70 |\n|     113610 |  8098591.93 |\n|     198538 |  8097343.20 |\n|     122506 |  8096090.76 |\n|      29082 |  8093543.55 |\n|     161345 |  8093157.93 |\n|     105743 |  8093045.53 |\n|     103572 |  8091573.66 |\n|      59514 |  8089470.48 |\n|       8801 |  8088454.15 |\n|     129062 |  8088206.58 |\n|     155464 |  8086115.79 |\n|      86363 |  8082561.00 |\n|     180836 |  8082087.30 |\n|      92558 |  8081407.80 |\n|      85120 |  8073164.00 |\n|     149026 |  8072285.40 |\n|      51138 |  8072074.48 |\n|      36306 |  8071648.86 |\n|     102380 |  8070503.00 |\n|     147597 |  8069397.60 |\n|      41382 |  8059995.35 |\n|     121856 |  8059809.11 |\n|      86644 |  8058667.76 |\n|     108481 |  8058214.81 |\n|      41685 |  8057355.39 |\n|     175712 |  8054878.30 |\n|      72815 |  8052294.24 |\n|      58794 |  8047848.00 |\n|     118769 |  8047465.14 |\n|     157192 |  8046501.96 |\n|     195708 |  8045001.94 |\n|     163683 |  8044727.02 |\n|     189018 |  8043927.54 |\n|      62904 |  8043011.65 |\n|      80095 |  8042575.59 |\n|      90500 |  8042502.65 |\n|      73281 |  8040167.52 |\n|     150710 |  8035910.80 |\n|     139282 |  8034489.36 |\n|     172904 |  8033791.68 |\n|      38881 |  8032557.38 |\n|      53055 |  8030796.15 |\n|     105816 |  8025318.24 |\n|      88304 |  8024637.06 |\n|     115565 |  8023928.25 |\n|      55376 |  8021432.16 |\n|      56334 |  8019313.12 |\n|      58875 |  8016065.00 |\n|       4688 |  8012303.00 |\n|      49117 |  8009207.80 |\n|      57173 |  8008116.27 |\n|      48176 |  8006765.85 |\n|     112191 |  8003883.39 |\n|      33265 |  8002391.76 |\n|     181788 |  8002030.50 |\n|     172799 |  8001050.55 |\n|       2084 |  7999172.30 |\n|     174747 |  7997167.48 |\n|     171184 |  7996930.11 |\n|     113271 |  7992683.04 |\n|      68662 |  7991426.30 |\n|     179375 |  7991170.88 |\n|     188383 |  7990226.27 |\n|      50208 |  7989363.27 |\n|      23653 |  7988890.87 |\n|     159419 |  7988841.36 |\n|      74581 |  7987356.50 |\n|     133590 |  7986046.81 |\n|     195820 |  7985473.14 |\n|      87903 |  7983482.88 |\n|      69032 |  7981908.18 |\n|     113975 |  7980561.00 |\n|     178678 |  7975116.93 |\n|      52316 |  7973618.16 |\n|     135546 |  7972669.80 |\n|      89425 |  7970077.44 |\n|     115937 |  7966015.20 |\n|     151483 |  7964850.88 |\n|      73974 |  7964186.23 |\n|      39976 |  7964104.24 |\n|     130168 |  7961690.88 |\n|      58973 |  7957416.76 |\n|      16354 |  7956051.07 |\n|      23988 |  7955837.92 |\n|     138467 |  7955481.05 |\n|      26096 |  7955212.32 |\n|     192216 |  7953429.18 |\n|     112833 |  7952279.26 |\n|      60599 |  7951261.80 |\n|     129116 |  7948811.85 |\n|      79529 |  7947581.91 |\n|      71616 |  7944476.54 |\n|     136821 |  7942188.24 |\n|     116204 |  7941096.90 |\n|     165298 |  7939933.31 |\n|      44009 |  7939859.65 |\n|     194487 |  7938247.20 |\n|      11299 |  7938135.81 |\n|      76488 |  7935926.86 |\n|      58998 |  7934414.04 |\n|      25175 |  7931035.11 |\n|     136144 |  7929283.23 |\n|     132829 |  7926841.62 |\n|      84176 |  7925781.05 |\n|      68592 |  7922872.98 |\n|     139280 |  7922119.48 |\n|     160669 |  7921588.43 |\n|      42938 |  7917524.56 |\n|     183183 |  7915624.86 |\n|      95449 |  7914292.08 |\n|     115390 |  7912655.54 |\n|     173723 |  7911329.40 |\n|      48992 |  7911153.12 |\n|     173464 |  7910458.65 |\n|      26098 |  7910217.75 |\n|     141115 |  7909496.38 |\n|     195218 |  7906315.56 |\n|     116608 |  7906302.60 |\n|     163793 |  7905477.33 |\n|      10419 |  7904598.30 |\n|     106312 |  7901466.72 |\n|      48674 |  7901010.24 |\n|      35198 |  7899974.88 |\n|      88954 |  7899573.52 |\n|      41505 |  7897709.99 |\n|     115586 |  7897301.88 |\n|     167431 |  7895826.00 |\n|     158787 |  7894948.50 |\n|     161712 |  7893410.70 |\n|      46930 |  7892707.77 |\n|      58633 |  7892088.15 |\n|      10599 |  7892067.69 |\n|      99523 |  7891485.16 |\n|      70126 |  7890247.41 |\n|      32476 |  7890149.34 |\n|     152617 |  7890136.50 |\n|     162639 |  7889822.70 |\n|      82056 |  7889345.05 |\n|     186450 |  7887873.56 |\n|      39082 |  7886019.89 |\n|     183217 |  7885948.48 |\n|     192551 |  7884432.48 |\n|     164801 |  7882870.10 |\n|     112804 |  7882772.00 |\n|       5956 |  7878805.04 |\n|      73054 |  7878479.63 |\n|      62593 |  7878401.44 |\n|     137687 |  7873755.91 |\n|      80526 |  7871839.50 |\n|     195354 |  7869617.75 |\n|       4122 |  7867967.09 |\n|       4057 |  7865176.80 |\n|      63195 |  7864322.16 |\n|     143370 |  7863444.54 |\n|      41473 |  7862926.89 |\n|     155060 |  7860900.96 |\n|      76875 |  7858529.64 |\n|     135778 |  7857660.51 |\n|      30534 |  7855226.08 |\n|      99405 |  7853410.95 |\n|     161551 |  7852244.40 |\n|     185034 |  7850752.00 |\n|      17264 |  7850704.88 |\n|      23652 |  7848909.16 |\n|     123681 |  7848265.36 |\n|     186170 |  7845527.50 |\n|      81496 |  7840427.40 |\n|      25407 |  7840234.72 |\n|      96662 |  7839907.41 |\n|     156407 |  7839647.75 |\n|     165843 |  7839562.80 |\n|     153361 |  7838813.07 |\n|     149362 |  7838282.52 |\n|      46057 |  7835709.81 |\n|     114341 |  7835492.25 |\n|     154823 |  7834898.61 |\n|     139538 |  7834690.64 |\n|      42853 |  7833252.60 |\n|     177659 |  7831803.58 |\n|      29158 |  7829880.80 |\n|      85583 |  7825996.64 |\n|     165714 |  7825006.46 |\n|      58662 |  7821977.76 |\n|     185839 |  7821640.74 |\n|      93559 |  7821137.52 |\n|      58481 |  7818648.16 |\n|     162217 |  7817923.47 |\n|     130014 |  7815929.34 |\n|     125640 |  7815262.90 |\n|      83723 |  7815021.48 |\n|      54314 |  7813732.94 |\n|     146652 |  7809817.39 |\n|     189256 |  7808972.00 |\n|      87994 |  7808660.48 |\n|     157067 |  7806217.25 |\n|      56859 |  7805947.60 |\n|     118132 |  7804423.69 |\n|     189457 |  7802777.91 |\n|       1509 |  7802315.42 |\n|     129101 |  7801994.70 |\n|     162285 |  7801859.52 |\n|     182358 |  7801430.46 |\n|       6288 |  7800363.30 |\n|      68972 |  7799224.95 |\n|      51684 |  7795455.46 |\n|     148645 |  7794585.92 |\n|      94359 |  7794358.92 |\n|      40451 |  7791437.70 |\n|      44019 |  7790053.76 |\n|      81470 |  7788716.85 |\n|      12731 |  7786998.38 |\n|     114393 |  7784963.34 |\n|      69323 |  7783583.08 |\n|     169794 |  7780968.30 |\n|      25378 |  7778569.60 |\n|     104509 |  7777137.62 |\n|      81874 |  7775216.80 |\n|      70859 |  7771185.07 |\n|     135768 |  7769704.84 |\n|     181960 |  7768847.90 |\n|      28481 |  7768516.61 |\n|     191604 |  7765367.68 |\n|        754 |  7762507.02 |\n|     127702 |  7761776.05 |\n|      36488 |  7761744.00 |\n|     183906 |  7759864.80 |\n|      90365 |  7759602.50 |\n|      60725 |  7759495.78 |\n|      69436 |  7759033.52 |\n|      12963 |  7756623.52 |\n|      64571 |  7755731.04 |\n|     160111 |  7753787.70 |\n|     107970 |  7753735.88 |\n|     132036 |  7753401.36 |\n|      79965 |  7748656.15 |\n|     149862 |  7747239.10 |\n|      73218 |  7745499.42 |\n|     161036 |  7742807.45 |\n|     152467 |  7742471.40 |\n|     163358 |  7742034.00 |\n|     197951 |  7741768.84 |\n|      15820 |  7740003.00 |\n|      31444 |  7739519.60 |\n|     151208 |  7738273.85 |\n|      20410 |  7737192.99 |\n|      45462 |  7736792.55 |\n|     128966 |  7736467.65 |\n|     118945 |  7735275.00 |\n|     106458 |  7734069.72 |\n|     162706 |  7730189.88 |\n|      70528 |  7730088.25 |\n|     107998 |  7728273.45 |\n|     163110 |  7728042.40 |\n|      74591 |  7727297.76 |\n|     121454 |  7726200.56 |\n|     181252 |  7724464.38 |\n|      29154 |  7724129.66 |\n|      63854 |  7720353.88 |\n|      34157 |  7719803.30 |\n|      30684 |  7718307.84 |\n|       3985 |  7715042.96 |\n|      29387 |  7714858.80 |\n|     184703 |  7712545.12 |\n|     124679 |  7712528.72 |\n|      15606 |  7710658.46 |\n|     123814 |  7709872.95 |\n|      83760 |  7709633.92 |\n|      22084 |  7707219.79 |\n|     123210 |  7706030.42 |\n|      75066 |  7704727.51 |\n|      16337 |  7704517.80 |\n|      47109 |  7704111.51 |\n|       8232 |  7702887.50 |\n|      11222 |  7702535.62 |\n|      84961 |  7701923.72 |\n|     157118 |  7700132.88 |\n|     118362 |  7699210.20 |\n|     193755 |  7698545.20 |\n|       1520 |  7697759.37 |\n|     114599 |  7697377.50 |\n|     168842 |  7696152.00 |\n|     172245 |  7694286.06 |\n|       4584 |  7693352.79 |\n|     113651 |  7689659.67 |\n|     183207 |  7687955.66 |\n|     175802 |  7686604.70 |\n|      59066 |  7685120.43 |\n|     130726 |  7684159.25 |\n|      89672 |  7684049.50 |\n|       7224 |  7683446.40 |\n|      97533 |  7680694.62 |\n|      59941 |  7680100.80 |\n|      29298 |  7676823.42 |\n|     163962 |  7675924.96 |\n|      41086 |  7674518.14 |\n|     185483 |  7673376.60 |\n|     165010 |  7672469.70 |\n|       3708 |  7671744.18 |\n|     192994 |  7671712.00 |\n|      79968 |  7668060.48 |\n|     118494 |  7666659.00 |\n|      59236 |  7666625.98 |\n|     149509 |  7665930.67 |\n|       3793 |  7664981.28 |\n|      28979 |  7664632.93 |\n|     178389 |  7662544.96 |\n|      65315 |  7661085.88 |\n|      59710 |  7657442.00 |\n|     170276 |  7656813.89 |\n|     182707 |  7656387.06 |\n|     129170 |  7655820.48 |\n|      59765 |  7655009.92 |\n|      23337 |  7654271.94 |\n|      90396 |  7653568.35 |\n|      68842 |  7652742.72 |\n|      16315 |  7652630.70 |\n|        956 |  7652174.81 |\n|      10639 |  7651375.80 |\n|     112886 |  7649534.08 |\n|       9561 |  7648502.73 |\n|      65484 |  7647789.30 |\n|      68677 |  7646879.14 |\n|     196529 |  7645482.24 |\n|       6556 |  7642116.06 |\n|       9113 |  7640163.68 |\n|     128139 |  7638760.00 |\n|     143264 |  7635499.56 |\n|      21569 |  7634785.86 |\n|     193402 |  7633576.06 |\n|      35545 |  7632210.69 |\n|      65068 |  7632188.76 |\n|      25515 |  7630952.93 |\n|     180189 |  7630887.10 |\n|     131680 |  7629593.64 |\n|      80162 |  7629440.93 |\n|     139054 |  7629417.37 |\n|       8028 |  7629134.04 |\n|      76804 |  7626731.00 |\n|      74179 |  7624974.03 |\n|     122507 |  7623903.87 |\n|     141889 |  7623552.30 |\n|     184279 |  7623048.17 |\n|       8076 |  7620897.81 |\n|     192681 |  7619802.09 |\n|      21398 |  7617942.52 |\n|      14825 |  7617843.60 |\n|      17969 |  7617524.64 |\n|     170764 |  7616119.96 |\n|     115303 |  7615914.17 |\n|      67708 |  7615306.08 |\n|      33317 |  7613417.24 |\n|     190782 |  7613203.42 |\n|     113818 |  7612852.48 |\n|     178091 |  7611457.30 |\n|      87603 |  7611343.68 |\n|     108317 |  7610509.71 |\n|     106552 |  7609868.84 |\n|      28679 |  7609292.20 |\n|     192350 |  7609140.81 |\n|     154801 |  7607944.38 |\n|       5768 |  7607785.68 |\n|     127689 |  7606313.94 |\n|      62847 |  7605651.45 |\n|     111212 |  7605052.00 |\n|     156065 |  7603327.60 |\n|     115140 |  7601161.68 |\n|      19597 |  7601153.46 |\n|      55233 |  7600940.23 |\n|      89353 |  7600929.84 |\n|      75701 |  7600492.60 |\n|      64974 |  7599754.80 |\n|     116156 |  7597452.48 |\n|      59491 |  7596352.84 |\n|       6138 |  7594861.54 |\n|      62317 |  7594854.10 |\n|     106575 |  7594520.08 |\n|     161092 |  7594454.40 |\n|       9872 |  7593734.34 |\n|      77711 |  7593431.60 |\n|      61206 |  7593153.00 |\n|     123776 |  7592736.80 |\n|     185141 |  7592617.12 |\n|       5542 |  7592513.04 |\n|     185296 |  7591439.31 |\n|      72597 |  7591142.40 |\n+------------+-------------+\n1225 rows in set\n\nQ12\n+------------+-----------------+----------------+\n| l_shipmode | high_line_count | low_line_count |\n+------------+-----------------+----------------+\n| FOB        |            6273 |           9429 |\n| TRUCK      |            6336 |           9300 |\n+------------+-----------------+----------------+\n\nQ13\n+---------+----------+\n| c_count | custdist |\n+---------+----------+\n|       0 |    50005 |\n|      10 |     6574 |\n|       9 |     6554 |\n|      11 |     6072 |\n|       8 |     5934 |\n|      12 |     5598 |\n|      13 |     5032 |\n|      19 |     4685 |\n|       7 |     4663 |\n|      20 |     4607 |\n|      17 |     4550 |\n|      18 |     4515 |\n|      14 |     4480 |\n|      15 |     4476 |\n|      16 |     4341 |\n|      21 |     4176 |\n|      22 |     3710 |\n|       6 |     3303 |\n|      23 |     3172 |\n|      24 |     2670 |\n|      25 |     2111 |\n|       5 |     1954 |\n|      26 |     1605 |\n|      27 |     1195 |\n|       4 |     1030 |\n|      28 |      898 |\n|      29 |      620 |\n|       3 |      408 |\n|      30 |      353 |\n|      31 |      225 |\n|      32 |      135 |\n|       2 |      128 |\n|      33 |       82 |\n|      34 |       54 |\n|      35 |       33 |\n|       1 |       18 |\n|      36 |       17 |\n|      37 |        7 |\n|      41 |        3 |\n|      40 |        3 |\n|      38 |        3 |\n|      39 |        1 |\n+---------+----------+\n42 rows in set\n\n\nQ14\n+-------------------+\n| promo_revenue     |\n+-------------------+\n| 16.65118731292792 |\n+-------------------+\n\nQ15\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n| s_suppkey | s_name             | s_address                        | s_phone         | total_revenue |\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n|      7895 | Supplier#000007895 | NYl,i8UhxTykLxGJ2voIRn20Ugk1KTzz | 14-559-808-3306 |  1678635.2636 |\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n\n\nQ16\n+----------+---------------------------+--------+--------------+\n| p_brand  | p_type                    | p_size | supplier_cnt |\n+----------+---------------------------+--------+--------------+\n| Brand#55 | LARGE BURNISHED TIN       |     21 |           36 |\n| Brand#25 | PROMO BRUSHED STEEL       |     24 |           28 |\n| Brand#54 | STANDARD BRUSHED COPPER   |     14 |           27 |\n| Brand#12 | MEDIUM PLATED BRASS       |     21 |           24 |\n| Brand#14 | ECONOMY PLATED TIN        |     33 |           24 |\n| Brand#24 | ECONOMY PLATED TIN        |     33 |           24 |\n| Brand#25 | MEDIUM PLATED STEEL       |     35 |           24 |\n| Brand#32 | MEDIUM POLISHED COPPER    |     20 |           24 |\n| Brand#32 | SMALL ANODIZED BRASS      |      7 |           24 |\n| Brand#33 | ECONOMY PLATED STEEL      |      7 |           24 |\n| Brand#33 | MEDIUM PLATED COPPER      |     20 |           24 |\n| Brand#33 | PROMO POLISHED STEEL      |     14 |           24 |\n...\n| Brand#31 | PROMO ANODIZED COPPER     |     20 |            3 |\n| Brand#41 | LARGE BURNISHED STEEL     |     20 |            3 |\n| Brand#43 | SMALL BRUSHED COPPER      |      7 |            3 |\n| Brand#52 | MEDIUM POLISHED BRASS     |     21 |            3 |\n| Brand#52 | SMALL POLISHED TIN        |      2 |            3 |\n+----------+---------------------------+--------+--------------+\n18341 rows in set\n\nQ17\n+-------------------+\n| avg_yearly        |\n+-------------------+\n| 348406.0542857143 |\n+-------------------+\n\nQ18\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n| c_name             | c_custkey | o_orderkey | o_orderdate | o_totalprice | sum(l_quantity) |\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n| Customer#000128120 |    128120 |    4722021 | 1994-04-07  |    544089.09 |          323.00 |\n| Customer#000144617 |    144617 |    3043270 | 1997-02-12  |    530604.44 |          317.00 |\n| Customer#000066790 |     66790 |    2199712 | 1996-09-30  |    515531.82 |          327.00 |\n| Customer#000015619 |     15619 |    3767271 | 1996-08-07  |    480083.96 |          318.00 |\n| Customer#000147197 |    147197 |    1263015 | 1997-02-02  |    467149.67 |          320.00 |\n| Customer#000117919 |    117919 |    2869152 | 1996-06-20  |    456815.92 |          317.00 |\n| Customer#000126865 |    126865 |    4702759 | 1994-11-07  |    447606.65 |          320.00 |\n| Customer#000036619 |     36619 |    4806726 | 1995-01-17  |    446704.09 |          328.00 |\n| Customer#000119989 |    119989 |    1544643 | 1997-09-20  |    434568.25 |          320.00 |\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n9 rows in set\n\nQ19\n+--------------+\n| revenue      |\n+--------------+\n| 3083843.0578 |\n+--------------+\n\nQ20\n+--------------------+------------------------------------------+\n| s_name             | s_address                                |\n+--------------------+------------------------------------------+\n| Supplier#000000035 | QymmGXxjVVQ5OuABCXVVsu,4eF gU0Qc6        |\n| Supplier#000000068 | Ue6N50wH2CwE4PPgTGLmat,ibGYYlDoOb3xQwtgb |\n| Supplier#000000080 | cJ2MHSEJ13rIL2Wj3D5i6hRo30,ZiNUXhqn      |\n| Supplier#000000100 | rIlN li8zvW22l2slbcx ECP4fL              |\n| Supplier#000000274 | usxbl9KSW41DTE6FAglxHU                   |\n| Supplier#000000406 | zMhU58CDF4aHTeodxg9IgRZgq                |\n| Supplier#000000444 | mHr2VcUpRkvyQ9rjKMaPkeWbVZmEIhxhb8F      |\n| Supplier#000000453 | bpt98PxU5HSQt61bVB695JPjBmJKUv hNzQeHvC  |\n| Supplier#000000458 | IFNkUK1H53HwUHabiONkMFAUDb               |\n| Supplier#000000622 | gCQimU1jYHoQiglDmW1FkQM9wzi YC1P15pMy1   |\n| Supplier#000000713 | DBMIf1HiYY8OyRFcbtHpKIz                  |\n| Supplier#000000767 | bHEuqKKdmCMEKOV                          |\n| Supplier#000000776 | nklfFoSkCwf,ooSuF                        |\n| Supplier#000000823 |  gC0DrEG5U,v893fp3nj mmXa6rYhJ0tjpJ      |\n| Supplier#000000828 | 0B2aPqJ6KTEr2fqxuC7z                     |\n| Supplier#000000941 | gqG2XEnVlzUhjjfQGYGlwk,jcaNsplI8Rleg     |\n| Supplier#000000973 | 5 nhBZ 03rG6EcOEDkZXvt                   |\n| Supplier#000000984 | 6H6qqye iYbYzCmwWhj                      |\n| Supplier#000001149 | Nuno37wiZOjNGHF                          |\n| Supplier#000001201 | Seh4D7pi9UdK,XQkF46A0O2N                 |\n| Supplier#000001309 | 72RNUzKzbniUnnsSs24ZzGDvmcv2Pd           |\n| Supplier#000001344 | 6iF,zVDNTykohVKcb7FKvn82s74ez            |\n| Supplier#000001351 | zXdoBMmmRx1wOD7GKoHHBtemXGuYKLDb,U2KP    |\n| Supplier#000001391 | hkWoAM561QlLjBNk,SdFdIgFx                |\n| Supplier#000001481 | ARqVvJHMxBNKl2LrfPsR  Wq9ZUXh,14         |\n| Supplier#000001584 | gJbTkijteJxSMLmdzBSzeMAH                 |\n| Supplier#000001651 | 6rJNoWL9YL                               |\n| Supplier#000001710 | J,sdOOJwUhwPv2mrEiNEA0UZlmu5IRmgz        |\n| Supplier#000001755 | QstBVfnY,93NsbWXCqO                      |\n| Supplier#000001869 | nogoCdaFQii,ri9rs3P8f5rPt1wVOMw9I7TmypxK |\n| Supplier#000001895 | lywAGDbk37fYPDS                          |\n| Supplier#000001910 | vih,zrhclXX1O9x                          |\n| Supplier#000001930 | 2jCSw3KOLHol7y5omVO13                    |\n| Supplier#000001979 | UNW7nA,IC 5igvVsgUHA7OaLL,jOzUcT         |\n| Supplier#000002046 | BiTDgHknmvQGT6FpZXfRX,xlnR               |\n| Supplier#000002071 | zLH3QAtZuuOq8AoVNM                       |\n| Supplier#000002270 | HIscbvhw8N94djn,3UbPaY4R                 |\n| Supplier#000002350 | TWsO2iJGOl7v3vSwiscXp6X                  |\n| Supplier#000002409 | oy39SaSQ,FIP pzLqblhxj                   |\n| Supplier#000002520 | 5y55UzYQKByZP3                           |\n| Supplier#000002618 | 3UtbE1kKm29kKyx09hSEBMhRLM               |\n| Supplier#000002643 | eDN6YjGtp2dcj0IF,BKEEYjElO,sUjjcNI       |\n| Supplier#000002649 | agDQi9iCt1cUaS                           |\n| Supplier#000002655 | i6v8dkQBuK0NSCeqQCE8                     |\n| Supplier#000002812 | Q9sO3wZkBU5QBe0VITRWShv                  |\n| Supplier#000002888 | 3AtRoxBFh6HIBa9kdBX,6,Ml2SZGUA           |\n| Supplier#000002910 | nlH1gjApxHkQe5SU4iVZwi2xWk88wwhTWRkSvOBB |\n| Supplier#000002914 | fUC4IkGB8pt1S                            |\n| Supplier#000003000 | JtDvRf4iWHJkj54PYxl                      |\n| Supplier#000003011 | vfL mV0MTdyozfRIPZkJbM1Z7Lcm2NCPIj6qSgBz |\n| Supplier#000003038 | F5Tz7P juuCbABDuW8JGomRFxqVHBWyQrsLwg4i  |\n| Supplier#000003150 | XwSjsmzEnANK,wAQUp4Xf5xJDqR              |\n| Supplier#000003305 | GLZJimfuzKoQcqcv4                        |\n| Supplier#000003394 | R6D7n3WrQjWNGSQTb7eN ,X0oCMkhyuTHBOSPw   |\n| Supplier#000003452 | 7tMycIKhE,pe4OL3Du                       |\n| Supplier#000003666 | ENS fE9iSrSzw,iTwA,zGorkflw              |\n| Supplier#000003698 | lnSEu64ca4B53BfznJPg                     |\n| Supplier#000003773 | UWjSotAjkAD                              |\n| Supplier#000003837 | SYXpXaKop3                               |\n| Supplier#000003846 | wl076KfcEpYLRegb1LfIf93b3n5HBabFK2R,mEM  |\n| Supplier#000003862 | 0XXFhF1IDBh                              |\n| Supplier#000003868 | 5aP4VBn0t666NbGYB                        |\n| Supplier#000003880 | DZo80mSznrhCpb8                          |\n| Supplier#000003955 | piECPB8qbn7s3XP                          |\n| Supplier#000004007 | cvlSgCCKGOwpaB iFIPx4vU2qA5b6K hz9Z91    |\n| Supplier#000004066 | TNBnJFDScUmsjBy6pSWTS sfMg9jpfKx         |\n| Supplier#000004127 | EduKm3NcCc75Cd                           |\n| Supplier#000004174 | Bk97olQYwXmjYdQjwyt N                    |\n| Supplier#000004328 | euddbWZRcVMD3W                           |\n| Supplier#000004341 | ea8KZYvO7amq8A                           |\n| Supplier#000004360 | w 7kM5J,fqjiqBu4SU0UPEDqspaUEm           |\n| Supplier#000004375 | Cmr952zcJJuW0xAYc0W0MA7N6vMcCjy          |\n| Supplier#000004391 | pcsiJBhSEHuFHNAxR3K c                    |\n| Supplier#000004398 | khZZ0CmLip49Zncec                        |\n| Supplier#000004402 | acagGfDWzwmS,,WVBsszubFs3LOA8rDRS0I      |\n| Supplier#000004714 | IKRla2xArMmR4p3Mbn8JV8g0                 |\n| Supplier#000004717 | H,Suh5pN230Ol,ggx0QEh3rrvzyQsq050Lat     |\n| Supplier#000004740 | yM0TXkhfjpObafbQhuWU                     |\n| Supplier#000004763 | W 7kS9LLh4ZgLpk2                         |\n| Supplier#000004837 | tYHMZS4XlJjzvj34mH2PCoj                  |\n| Supplier#000004882 | e,V Bo1KZEt                              |\n| Supplier#000004913 | em,yC41xEl Fst9LwEik                     |\n| Supplier#000005005 | K6 GI4WzmbsGEOh                          |\n| Supplier#000005238 | jmtI76 8RNG8Z2BZu                        |\n| Supplier#000005289 | 62XeOur9SnXgbdjGwb9E1aJIEBr5PA9          |\n| Supplier#000005317 | lPOPHufNjwZaUJGVNHCC2DE FYQcKZBzHltL5    |\n| Supplier#000005401 | eEOlCEAaIfVexStlrgTuzwQx7vjPF6ZT dm      |\n| Supplier#000005449 | fhc8lUuZdqWUujcVaWogowEq1WVL9Y8m1efwCl3G |\n| Supplier#000005472 | LlyLSmvY9GFvMN4QhHzMokW0k5d              |\n| Supplier#000005572 | o0VYozeSbEyqck                           |\n| Supplier#000005579 | ACVEMP4IwRf                              |\n| Supplier#000005661 | pq5wuxmkIW0DyWU                          |\n| Supplier#000005676 | HInJHZisl5svSU1oKsr                      |\n| Supplier#000005815 | S6cu6cspYxHlTz2                          |\n| Supplier#000005835 | rYoXzV3EZ77Z                             |\n| Supplier#000006103 | l32l8iaPdbHgRXoq,kdjFAj3hZk2d            |\n| Supplier#000006173 | hBdratcVfL4LpWxsEpCRP g0AksN0CDhBZ       |\n| Supplier#000006226 | CKuDyeGAxPHeRHwC4a                       |\n| Supplier#000006254 | g7OY1vWNUb1vxIRgEl                       |\n| Supplier#000006348 | f2KDn2rLnadX8I DZR                       |\n| Supplier#000006359 | QyUuVHYBp8sTd7Y9WveNfsz                  |\n| Supplier#000006430 | F2RrkeaNcs6po8x2PyYvcPa1rtKd,fT2AMxP     |\n| Supplier#000006516 | 89XwFOC,hLRxGq5rL0txv0EM9F               |\n| Supplier#000006700 | BWjerJH5kbEPu 8h9                        |\n| Supplier#000006785 | lyo6PpwulTeN9ZfIkvWag5NucL,XMC  89Kn7U   |\n| Supplier#000006998 | r2i3HfkSQh9dvho, NpoabdMsPBG             |\n| Supplier#000007019 | 2GQsALzRiTt2BQum6bocdeGawkOrsjNIZ        |\n| Supplier#000007114 | s9s4YLeLWo7fLRO3rdQKFfUnZhrZUPjOC        |\n| Supplier#000007170 | 9vABqu hZaciXSCQrbTj                     |\n| Supplier#000007171 | DXerxFIhNRpqF9dWNRw hDOlLX gEJFxh0       |\n| Supplier#000007213 | 2Nrby3JJHDJyWwVNiqPtm2U JGWlZpU          |\n| Supplier#000007219 | p5Ui3IGPcmotYu                           |\n| Supplier#000007229 | iwNoWdaURFzLAsQHxK,BeOPpI5TOTo           |\n| Supplier#000007263 | malQPdYc8xiup2MiFuKHa                    |\n| Supplier#000007270 | TksERECGdYZRPUjkUdDRZv5pW26cOTaA1        |\n| Supplier#000007276 | Vi9,aBg2ychZf                            |\n| Supplier#000007334 | NPXYWdJ8L9EDr20tw9CZQsEMqXlgXzI2JC Y     |\n| Supplier#000007400 | 7r9zZj8J,,hN2GRfWtDxzuGa                 |\n| Supplier#000007442 | DzycM1,T6kh2EutfPeFpv0Ro                 |\n| Supplier#000007456 | ITYEeccPVJi0HvnAwVs2Z                    |\n| Supplier#000007559 | Wmzx1vskciC                              |\n| Supplier#000007677 | OoTYQdxQyd7NukSaSRv                      |\n| Supplier#000007712 | DyTQD 3ajuOtHQTpI4LsWSF kSd2SE6U4COgYHQ  |\n| Supplier#000007715 | gZHd7Yzbtv7yb7DYCCAQPJH8FRHTqi6T4w       |\n| Supplier#000007816 | 1ejcJ545bwLWLuY6Qq4qyEExZIsp0SG          |\n| Supplier#000007845 | agwGVTzLyRKOsZxLVi,mPWZ08Qxb             |\n| Supplier#000007875 | E0CkoBYngcIoH                            |\n| Supplier#000007908 | ghhHapj7GK                               |\n| Supplier#000007972 | WW0GuiWP2N3kUo4f                         |\n| Supplier#000008162 | XASpbn08mRV0kgHRmUSKx                    |\n| Supplier#000008235 | TjVWq6bTdGJB                             |\n| Supplier#000008249 | PwUjvlMk y72zaMRtZQ8trbCmu4j             |\n| Supplier#000008309 | 6P,FQbW6sJouqunvttVO6vEeY                |\n| Supplier#000008339 | uWw8 P6u,S                               |\n| Supplier#000008343 |  BbHngAVqj0J8                            |\n| Supplier#000008349 | 8Hkx1IDd0mZCTX                           |\n| Supplier#000008377 | ,Yk0mflw2LqQCTxMYR sU2juj5DorUAG4w6i     |\n| Supplier#000008468 | 5R4jsweitleustYlE3w,u5otW                |\n| Supplier#000008523 | C4ocdfNu5I2nnnVG2xSd3016J6KNLIg          |\n| Supplier#000008580 | t5ri71bM6Sox3riP4JUZsMMNC                |\n| Supplier#000008638 | yxj50B 8aMql                             |\n| Supplier#000008642 | qnN9N9du9Dg2arf6kjD xW0DjMT9cM           |\n| Supplier#000008651 | pfw32RGA7BPXrUiavYqE                     |\n| Supplier#000008679 | JWFVoSsCwn9p8o                           |\n| Supplier#000008704 | a6DjHp0B6mifKBtqUk,C                     |\n| Supplier#000008737 | MsdGxF9Xoq9 8s                           |\n| Supplier#000008820 | uAsBvPBNsEsO                             |\n| Supplier#000008829 | lNcY7xNLDonCw TuRYL                      |\n| Supplier#000008947 | 1Ij3T0egGHnVbLich98HzY,UeCdVbxzYa ZpKDVc |\n| Supplier#000008964 | U2YJW,Y1xCbUWbjuovtzsLfsl                |\n| Supplier#000008974 | 4JCXOJ3MyPfa51mIf,MQu                    |\n| Supplier#000008997 | KY MmMEcyQ6FEDCooFj xa uCwF2GbaeA8       |\n| Supplier#000009065 | ZELuiqWrWbJV9zAuco1OnXKTJClhR            |\n| Supplier#000009114 | nkn6bcPvlP5w,lUpO0nZTBSj                 |\n| Supplier#000009125 | IQbCXbN1mmght                            |\n| Supplier#000009131 | gDBXgWtg4rTxu0WUJhhV                     |\n| Supplier#000009149 | yKX,bKryD6YtvF,cVLIKC0Z6rN               |\n| Supplier#000009182 | z56kNgeqaWQ1kHFBp                        |\n| Supplier#000009220 | N4y,vP kdArpcmdypBh,fJVVB                |\n| Supplier#000009226 | yzT10vNTFJ                               |\n| Supplier#000009288 |  251AA4ziZ3d7TTWXLGnXjb4BnXv             |\n| Supplier#000009360 | 1NVjjX8zMjyBX2UapDTP0Sz                  |\n| Supplier#000009381 | rhCTm7QehIznqd8 Np7VT,H5J5zSGr           |\n| Supplier#000009403 | 70841REghyWBrHyyg762Jh4sjCG7CKaIc        |\n| Supplier#000009504 | Rqt07,ANI92kj1oU                         |\n| Supplier#000009598 | PnTAz7rNRLVDFO3zoo2QRTlh4o               |\n| Supplier#000009609 | LV2rJUGfr0k3dPNRqufG1IoYHzV              |\n| Supplier#000009619 | K0RwcJ9S75Xil jqKukFoDNkD                |\n| Supplier#000009626 | Nm1FnIh4asUR3EnXv2Pvy3gXqI9es            |\n| Supplier#000009738 | 15RRSVTuOzwdMP LmfCtIguMGXK              |\n| Supplier#000009770 | Ag, SZfowit580QPDdbP8kmFHdpZ9ASI         |\n| Supplier#000009865 | extcOh9ZrdDCMsHhhsFTkTUAh,HM2UQ2qa8sRo   |\n| Supplier#000009866 | Auh6aZnOnQG1pPYKZ5o9ATramJBA             |\n| Supplier#000009890 | izJXemCM Ikpgxk                          |\n| Supplier#000009937 | edZ9HQJ0KJAU6EWknTiDghKfRLHq6vtFqdey,0l  |\n| Supplier#000009954 | VzElx9ihlXFJLIQw2Hn4bC2                  |\n| Supplier#000009958 | ggiiSA4CSyvhwQUYjdJhWlKEY9PAfs           |\n+--------------------+------------------------------------------+\n177 rows in set\n\n\nQ21\n+--------------------+---------+\n| s_name             | numwait |\n+--------------------+---------+\n| Supplier#000009302 |      21 |\n| Supplier#000000342 |      20 |\n| Supplier#000000632 |      19 |\n| Supplier#000002196 |      19 |\n| Supplier#000003325 |      18 |\n| Supplier#000003915 |      18 |\n| Supplier#000005045 |      18 |\n| Supplier#000006442 |      18 |\n| Supplier#000003093 |      17 |\n| Supplier#000004498 |      17 |\n| Supplier#000000906 |      16 |\n| Supplier#000001183 |      16 |\n| Supplier#000001477 |      16 |\n| Supplier#000006043 |      16 |\n| Supplier#000000689 |      15 |\n| Supplier#000001955 |      15 |\n| Supplier#000002066 |      15 |\n| Supplier#000002146 |      15 |\n| Supplier#000003253 |      15 |\n| Supplier#000003527 |      15 |\n| Supplier#000003947 |      15 |\n| Supplier#000004915 |      15 |\n| Supplier#000005248 |      15 |\n| Supplier#000006718 |      15 |\n| Supplier#000007773 |      15 |\n| Supplier#000008121 |      15 |\n| Supplier#000008169 |      15 |\n| Supplier#000008645 |      15 |\n| Supplier#000008684 |      15 |\n| Supplier#000009079 |      15 |\n| Supplier#000009956 |      15 |\n| Supplier#000000737 |      14 |\n| Supplier#000000775 |      14 |\n| Supplier#000001474 |      14 |\n| Supplier#000001502 |      14 |\n| Supplier#000003196 |      14 |\n| Supplier#000004415 |      14 |\n| Supplier#000004940 |      14 |\n| Supplier#000005253 |      14 |\n| Supplier#000005703 |      14 |\n| Supplier#000006308 |      14 |\n| Supplier#000006789 |      14 |\n| Supplier#000007161 |      14 |\n| Supplier#000007952 |      14 |\n| Supplier#000008062 |      14 |\n| Supplier#000008414 |      14 |\n| Supplier#000008442 |      14 |\n| Supplier#000008508 |      14 |\n| Supplier#000000300 |      13 |\n| Supplier#000000727 |      13 |\n| Supplier#000000921 |      13 |\n| Supplier#000000992 |      13 |\n| Supplier#000001282 |      13 |\n| Supplier#000001582 |      13 |\n| Supplier#000001662 |      13 |\n| Supplier#000001683 |      13 |\n| Supplier#000002933 |      13 |\n| Supplier#000003177 |      13 |\n| Supplier#000003428 |      13 |\n| Supplier#000003640 |      13 |\n| Supplier#000004842 |      13 |\n| Supplier#000004951 |      13 |\n| Supplier#000005795 |      13 |\n| Supplier#000005981 |      13 |\n| Supplier#000006118 |      13 |\n| Supplier#000006433 |      13 |\n| Supplier#000006484 |      13 |\n| Supplier#000007268 |      13 |\n| Supplier#000008599 |      13 |\n| Supplier#000008675 |      13 |\n| Supplier#000009474 |      13 |\n| Supplier#000009521 |      13 |\n| Supplier#000009853 |      13 |\n| Supplier#000000021 |      12 |\n| Supplier#000000211 |      12 |\n| Supplier#000000743 |      12 |\n| Supplier#000000951 |      12 |\n| Supplier#000001654 |      12 |\n| Supplier#000001868 |      12 |\n| Supplier#000002089 |      12 |\n| Supplier#000002879 |      12 |\n| Supplier#000003060 |      12 |\n| Supplier#000003215 |      12 |\n| Supplier#000003365 |      12 |\n| Supplier#000003873 |      12 |\n| Supplier#000003985 |      12 |\n| Supplier#000004452 |      12 |\n| Supplier#000004639 |      12 |\n| Supplier#000005122 |      12 |\n| Supplier#000005633 |      12 |\n| Supplier#000005671 |      12 |\n| Supplier#000005782 |      12 |\n| Supplier#000006088 |      12 |\n| Supplier#000006477 |      12 |\n| Supplier#000006508 |      12 |\n| Supplier#000006750 |      12 |\n| Supplier#000006802 |      12 |\n| Supplier#000008236 |      12 |\n| Supplier#000009294 |      12 |\n| Supplier#000009329 |      12 |\n+--------------------+---------+\n100 rows in set\n\nQ22\n+-----------+---------+------------+\n| cntrycode | numcust | totacctbal |\n+-----------+---------+------------+\n| 10        |     882 | 6606081.31 |\n| 11        |     899 | 6702253.34 |\n| 19        |     963 | 7230776.82 |\n| 20        |     916 | 6824676.02 |\n| 22        |     894 | 6636740.03 |\n| 26        |     861 | 6404695.86 |\n| 27        |     877 | 6565078.99 |\n+-----------+---------+------------+\n7 rows in set\n
        "},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/","title":"MO-Tester Specification","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#case-specifications","title":"Case specifications","text":"Specification Description File name 1. Use .sql or .test as the suffix.2. The file name has a practical meaning. For example, if you need to write a index case, you can name the index case index.sql or index_xxxx.sql. Case 1. In the specific example content in the case, all empty lines are automatically ignored during testing. You can add blank lines to make the SQLs more readable.2. Each SQL statement contains only one line. If multiple lines are required, each line must be preceded by no space. Otherwise, the SQL in the case file and the result file cannot match each other completely.3. Add a comment indicating the purpose of the test case you are currently writing.4. Add a Tag to the case that is in need."},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#tag-specifications-in-the-cases","title":"Tag specifications in the cases","text":"Annotation Start with End with Description -- @bvt:issue -- @bvt:issue#{issueNO.}] -- @bvt:issue the SQL marked with this flag will not been executed -- @sessio -- @session:id=X{ -- @session} all the SQLs enclosed by this tag will execute in a new session with id=X -- @separator / / The specified SQL statement in its result and generated the result file using the columns of the separator. There are two values. -- @separator:table / / The column separator in the result is a TAB character. \\t -- @separator:space / / The column separator in the result is four Spaces -- @sortkey -- @sortkey:1,2,3 / The results of the SQL statement are ordered, with the first, second, and third columns (starting from 0) sorted. Under normal circumstances, the tested system returns the result of the order is not fixed, so tools in comparison, the actual results, and expected results are sorted, but for some SQL, the expected results should be ordered, such as order by statement, you need to add such SQL on the tag, The tool does not reorder these columns in sortkey when comparing them."},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#result-specifications","title":"Result specifications","text":"Specification Description Normal cases generate test results 1. If a case file is created, ensure that all SQL is debuggable and use the Mo-Tester tool to generate results automatically.2. If some SQLs are added to the existing case, ensure that all SQLs has passed debugging, and use the Mo-Tester tool to generate results automatically. Cases with tags generate test results 1. If a case contains SQL with the --bvt:issue tag, use the MO-Tester tool to generate results automatically. SQL with the --bvt:issue tag in the generated result file results as' unknown result because it is related to issue#XXX\" '.2. If the results have been automatically generated by the MO-Tester tool. When the results are automatically generated by the MO-Tester tool again, the SQL with the tag --bvt:issue will retain the original value in the generated result file, no more updates. Write results manually 1. If the result is writed manually, do not have empty lines. Otherwise, a parsing error occurs.2. If there are tabs or more than 4 consecutive spaces in the expected execution result of a certain SQL, the corresponding SQL statement in the test case file must be added with Tag -- @separator:, otherwise the parsing will fail. For example, if the SQL in the case file contains 4 consecutive spaces, you need to specify the Tag label -- @separator:space; if it contains tab characters, specify the Tag label -- @separator:table."},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#set-tags-in-case-scripts","title":"Set tags in case scripts","text":"

        Sometimes, to achieve some specific purposes, such as pausing or creating a new connection, you can add some special tags to the script file. The mo tester provides the following tags for use:

        Tags Description -- @skip:issue#{IssueNo.} If set, the whole script file will be skipped, and not be executed any more for issue{IssueNo.} -- @bvt:issue#{IssueNo.}-- @bvt:issue The sql statements between those two tags will be not executed for issue{IssueNo.} -- @sleep:{time} The mo-tester will wait for {time} s -- @session:id=2&user=root&password=111 -- @session The mo-tester will create a new connetion to execute sql statements between those two tags.Default value of id is 1, max is 10.Defualt value of user and password is configured in mo.yml. -- @sortkey: If the result is sorted, need set this tag for the sql statement. e.g. -- @sortkey:0,1: means sort keys are first column and second colum."},{"location":"MatrixOne/Test/testing-tool/mo-tester/","title":"What's in MO-Tester?","text":"

        From the 0.5.0 version, MatrixOne introduces an automatic testing framework MO-Tester.

        This tester is designed to test MatrixOne or other database functionalities with SQL.

        MO-Tester is a java-based tester suite for MatrixOne. It has built a whole toolchain to run automatic SQL tests. It contains the test cases and results. Once launched, MO-Tester runs all SQL test cases with MatrixOne, and compares all output SQL results with expected results. All successful and failed cases will be logged into reports.

        MO-Tester content locations:

        • Cases: https://github.com/matrixorigin/matrixone/tree/main/test/distributed/cases

        • Result is generated in the path of /cases, for example, /cases/auto_increment.

        • Report: once finished running, a mo-tester/report will be generated in the local directory.

        The Cases and Results are 1-1 correspondence, and they are actually git submodules from MatrixOne repository. Adding new cases and results should be in MatrixOne repo: https://github.com/matrixorigin/matrixone/tree/main/test

        "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#how-to-use-mo-tester","title":"How to use MO-Tester?","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester/#1-prepare-the-testing-environment","title":"1. Prepare the testing environment","text":"
        • Make sure you have installed jdk8.

        • Launch MatrixOne or other database instance. Please refer to more information about how to install and launch MatrixOne.

        • Clone mo-tester repository.

        git clone https://github.com/matrixorigin/mo-tester.git\n
        • Clone matrixOne repository.
        git clone https://github.com/matrixorigin/matrixone.git\n
        "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#2-configure-mo-tester","title":"2. Configure mo-tester","text":"
        • In mo.yml file, configure the server address, default database name, username, and password, and so on. MO-tester is based on java, so these parameters are required for the JDBC(JDBC,Java Database Connectivity) driver. Below is a default example for a local standalone version MatrixOne.
        #jdbc\njdbc:\n  driver: \"com.mysql.cj.jdbc.Driver\"\n  server:\n  - addr: \"127.0.0.1:6001\"\n  database:\n    default: \"test\"\n  paremeter:\n    characterSetResults: \"utf8\"\n    continueBatchOnError: \"false\"\n    useServerPrepStmts: \"true\"\n    alwaysSendSetIsolation: \"false\"\n    useLocalSessionState: \"true\"\n    zeroDateTimeBehavior: \"CONVERT_TO_NULL\"\n    failoverReadOnly: \"false\"\n    serverTimezone: \"Asia/Shanghai\"\n    socketTimeout: 30000\n#users\nuser:\n  name: \"root\"\n  passwrod: \"111\"\n
        "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#3-run-mo-tester","title":"3. Run mo-tester","text":"
        • With the simple below command, all the SQL test cases will automatically run and generate reports and error messages to report/report.txt and report/error.txt.
        > ./run.sh -p {path_name}/matrixone/test/cases\n

        If you'd like to adjust the test range, you can just change the path parameter of run.yml. And you can also specify some parameters when executing the command ./run.sh, parameters are as followings:

        Parameters Description -p set the path of test cases needed to be executed by mo-tester, the default value is configured by the path in run.yaml -m set the method that mo-tester will run with, the default value is configured by the method in run.yaml -t set the type of the format that mo-tester executes the SQL command in, the default value is configured by the type in run.yaml -r set The success rate that test cases should reach, the default value is configured by the rate in run.yaml -i set the including list, and only script files in the path whose name contains one of the lists will be executed, if more than one, separated by ,, if not specified, refers to all cases included -e set the excluding list, and script files in the path whose name contains one of the lists will not be executed, if more than one, separated by ,, if not specified, refers to none of the cases excluded -g means SQL commands which is marked with [bvt:issue] flag will not be executed,this flag starts with [-- @bvt:issue#{issueNO.}],and ends with [-- @bvt:issue],eg:-- @bvt:issue#3236select date_add(\"1997-12-31 23:59:59\",INTERVAL \"-10000:1\" HOUR_MINUTE);select date_add(\"1997-12-31 23:59:59\",INTERVAL \"-100 1\" YEAR_MONTH);-- @bvt:issueThose two sql commands are associated with issue#3236, and they will not be executed in bvt test, until the flag is removed when issue#3236 is fixed. -n means the metadata of the resultset will be ignored when comparing the result -c only check whether the case file matches the related result file

        Examples:

        ./run.sh -p {path_name}/matrixone/test/cases -m run -t script -r 100 -i select,subquery -e substring -g\n

        If you want to automatically generate SQL results for the new SQL cases, you can just change the method parameter of run.yml file to genrs, or you can just change the command -m run to -m genrs, then running the ./run.sh scripts will directly record test results in the same path of the new SQL case file. For more information on example, see Example 4.

        Note

        Every time running run.sh will overwrite the report of the error.txt file, report.txt file, and success.txt file in the mo-tester repository.

        "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#4-check-the-report","title":"4. Check the report","text":"
        • Once the test is finished, mo-tester generates error.txt file, report.txt file and success.txt file reports.

        • An example of report.txt file looks like this:

        [SUMMARY] COST : 98s, TOTAL :12702, SUCCESS : 11851, FAILED :13, IGNORED :838, ABNORAML :0, SUCCESS RATE : 99%\n[{path_name}/matrixone/test/cases/auto_increment/auto_increment_columns.sql] COST : 2.159s, TOTAL :185, SUCCESS :163, FAILED :0, IGNORED :22, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/benchmark/tpch/01_DDL/01_create_table.sql] COST : 0.226s, TOTAL :11, SUCCESS :11, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/benchmark/tpch/02_LOAD/02_insert_customer.sql] COST : 0.357s, TOTAL :16, SUCCESS :16, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
        Report Keywords Description TOTAL the total number of executed test cases (SQL) SUCCESS The total number of successfully executed test cases(SQL) FAILED the total number of failed executed test case(SQL) IGNORED the total number of ignored executed test cases (SQL), especially with the --bvt:issue tag test cases (SQL) ABNORAML the total number of abnormal executed test cases (SQL), such as the execution of MatrixOne can't determine the actual result is a system exception or .result file parsing error, etc SUCCESS RATE success rate: SUCCESS/(TOTAL - IGNORED)
        • An example of error.txt file looks like this:
        [ERROR]\n[SCRIPT   FILE]: cases/transaction/atomicity.sql\n[ROW    NUMBER]: 14\n[SQL STATEMENT]: select * from test_11 ;\n[EXPECT RESULT]:\nc   d\n1   1\n2 2\n[ACTUAL RESULT]:\nc   d\n1   1\n
        "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#5-test-examples","title":"5. Test Examples","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester/#example-1","title":"Example 1","text":"

        Example Description: Run all test cases in the /cases path of the matrixone repository.

        Steps:

        1. Get the latest matrixone code.
        cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n
        1. To run all the test cases of the matrixone repository, you need switch into the mo-tester repository first, see the following commands:
        cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases\n
        1. Check the result reports in the error.txt file, report.txt file, and success.txt file in the mo-tester/report/ path.
        "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#example-2","title":"Example 2","text":"

        Example Description: Run the test cases in the /cases/transaction/ path of the matrixone repository.

        Steps:

        1. Get the latest matrixone code.
        cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n
        1. To run the test cases in the cases/transaction/ path of the matrixone repository, you need switch into the mo-tester repository first, see the following commands:
        cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/transaction/\n
        1. Check the result reports in the error.txt file, report.txt file, and success.txt file in the mo-tester/report/ path. The example of the expected report.txt looks like this:
        [SUMMARY] COST : 5s, TOTAL :1362, SUCCESS : 1354, FAILED :0, IGNORED :8, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.575s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit.test] COST : 0.175s, TOTAL :50, SUCCESS :50, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_1.sql] COST : 1.141s, TOTAL :296, SUCCESS :288, FAILED :0, IGNORED :8, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_atomicity.sql] COST : 0.52s, TOTAL :75, SUCCESS :75, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_isolation.sql] COST : 1.607s, TOTAL :215, SUCCESS :215, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_isolation_1.sql] COST : 1.438s, TOTAL :241, SUCCESS :241, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/isolation.sql] COST : 1.632s, TOTAL :202, SUCCESS :202, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/isolation_1.sql] COST : 1.512s, TOTAL :217, SUCCESS :217, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
        "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#example-3","title":"Example 3","text":"

        Example Description: Run the single test case cases/transaction/atomicity.sql.

        Steps:

        1. Get the latest matrixone code.
        cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n
        1. To run the test cases cases/transaction/atomicity.sql, you need switch into the mo-tester repository first, see the following commands:
        cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/transaction/atomicity.sql\n
        1. Check the result reports in the error.txt file, report.txt file, and success.txt file in the mo-tester/report/ path. The example of the expected report.txt looks like this:
        [SUMMARY] COST : 0s, TOTAL :66, SUCCESS : 66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.56s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
        "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#example-4","title":"Example 4","text":"

        Example Description:

        • Create a new folder named local_test and place it in {path_name}/matrixone/test/cases
        • Add a test file named new_test.sql to {path_name}/matrixone/test/cases/local_test/
        • Only run the single test case new_test.sql*

        Steps

        1. Get the latest matrixone code.
        cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n
        1. Generate test results:

        2. Method 1: To generate the test result, you need switch into the mo-tester repository first, then, run the following command.

          cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/local_test/new_test.sql -m genrs -g\n
        3. Method 2: Open the run.yml file in the mo-tester repository, change the method parameter from the default run to genrs, and run the following command to generate the test result.

          cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/local_test/new_test.sql\n
        4. Check the result file in the test/cases,result/ path of the matrixone repository.

        5. Check the result reports in the error.txt file, report.txt file, and success.txt file in the mo-tester/report/ path. The example of the expected report.txt looks like this:

        [SUMMARY] COST : 0s, TOTAL :66, SUCCESS : 66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.56s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
        "},{"location":"MatrixOne/Test/testing-tool/mo-tester/#reference","title":"Reference","text":"

        For more information on the annotations of MO-Tester, see MO-Tester Annotations.

        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/","title":"Common statistic data query","text":"

        Statistic data is a common query periodically performed during the operation and maintenance of a database. It helps the users intuitively and accurately grasp the current database status and health status.

        In MatrixOne, statistics include the following:

        • Metadata: data that describes the database, including database information, table information, and column information.

        • SQL Statistics: indicates whether the SQL is executed successfully, by whom, and at the start and stop time in a specific time range.

        • Role and Permission information: You can query the authorization, permission, inheritance, execution time, and authorization person of all roles in a MatrixOne.

        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#check-basic-information-on-all-databases","title":"Check basic information on all databases","text":"

        To view the basic information on all databases of the current account, execute the SQL as below:

        > select md.datname as database_name,md.created_time as created_time,mu.user_name as creator, mr.role_name as owner_role, count(mt.reldatabase) as total_tables\nfrom mo_catalog.mo_database md,mo_catalog.mo_role mr, mo_catalog.mo_user mu, mo_catalog.mo_tables mt\nwhere md.creator=mu.user_id and md.owner=mr.role_id and mt.reldatabase_id=md.dat_id\ngroup by mt.reldatabase,md.datname,md.created_time,mu.user_name,mr.role_name\norder by md.created_time asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-auto-increment-columns","title":"View the information on all auto increment columns","text":"

        To view the information on all the auto increment columns, execute the SQL as below:

        > select att_database as database_name,att_relname as table_name,attname as column_name\nfrom mo_catalog.mo_columns\nwhere att_is_auto_increment=1\norder by att_database, att_relname asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-the-views","title":"View the information on all the views","text":"

        To view the information on all the views, execute the SQL as below:

        > select mt.relname as view_name, mt.reldatabase as database_name,mu.user_name as created_user,mr.role_name as owner_role,mt.created_time\nfrom mo_catalog.mo_tables mt, mo_catalog.mo_user mu, mo_catalog.mo_role mr\nwhere mt.relkind='v' and mt.creator=mu.user_id and mt.owner=mr.role_id\norder by 1,2 asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-the-external-tables","title":"View the information on all the external tables","text":"

        To view the information on all the external tables, execute the SQL as below:

        > select mt.relname as view_name, mt.reldatabase as database_name,mu.user_name as created_user,mr.role_name as owner_role,mt.created_time\nfrom mo_catalog.mo_tables mt, mo_catalog.mo_user mu, mo_catalog.mo_role mr\nwhere mt.relkind='e' and mt.creator=mu.user_id and mt.owner=mr.role_id\norder by 1,2 asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-the-primary-keys-of-tables","title":"View the information on all the primary keys of tables","text":"

        To view the information on all the primary keys of tables, execute the SQL as below:

        > select att_database as database_name,att_relname as table_name,attname as column_name\nfrom mo_catalog.mo_columns\nwhere att_constraint_type='p' and att_relname not like '%!%'\norder by att_database, att_relname asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-the-tables-without-primary-keys","title":"View the information on all the tables without primary keys","text":"

        To view the information on all the tables without primary keys, execute the SQL as below:

        > select distinct att_database as database_name,att_relname as table_name\nfrom mo_catalog.mo_columns\nminus\nselect att_database as database_name,att_relname as table_name\nfrom mo_catalog.mo_columns\nwhere att_constraint_type='p'\norder by database_name,table_name asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-sql-statistics-of-the-last-24-hours-not-supported-for-non-sys-account","title":"View the sql statistics of the last 24 hours (not supported for non-sys account)","text":"
        > select user,host,status,count(status) as count, date_sub(now(), interval 24 hour) as start_time, now() as end_time\nfrom system.statement_info\nwhere status in ('Success','Failed') and user <> 'internal'\nand request_at between date_sub(now(), interval 24 hour) and now()\ngroup by status,user,host\norder by user,status asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-information-on-all-role-grant-users","title":"View the information on all role grant users","text":"

        To view the information on all role grant users, execute the SQL as below:

        > select mu.user_name as user_name,mr.role_name as role_name,mug.with_grant_option\nfrom mo_catalog.mo_user mu, mo_catalog.mo_role mr, mo_catalog.mo_user_grant mug\nwhere mu.user_id=mug.user_id and mr.role_id=mug.role_id\norder by mu.user_name,mr.role_name asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-the-promission-of-all-roles","title":"View the promission of all roles","text":"

        To view the promission of all roles, execute the SQL as below:

        > select mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,md.datname as object_name,with_grant_option\nfrom mo_catalog.mo_role_privs mrp, mo_catalog.mo_database md\nwhere mrp.obj_id=md.dat_id and mrp.obj_type='database'\nunion\nselect mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,'*',with_grant_option\nfrom mo_catalog.mo_role_privs mrp\nwhere obj_id=0\nunion\nselect mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,mt.relname as object_name,with_grant_option\nfrom mo_catalog.mo_role_privs mrp, mo_catalog.mo_tables mt\nwhere mrp.obj_id=mt.rel_id and mrp.obj_type='table'\norder by 1,2 asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#view-all-role-inheritance-information","title":"View all role inheritance information","text":"

        To view all role inheritance information, execute the SQL as below:

        > select mr1.role_name as inheritor_role,mr2.role_name as inheritee_role,mu.user_name as operator_user,mrg.granted_time,mrg.with_grant_option\nfrom mo_catalog.mo_user mu, mo_catalog.mo_role mr1, mo_catalog.mo_role mr2,mo_catalog.mo_role_grant mrg\nwhere mu.user_id=mrg.operation_user_id and mr1.role_id=mrg.grantee_id and mr2.role_id=mrg.granted_id\norder by mr1.role_name,mr2.role_name asc;\n
        "},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#reference","title":"Reference","text":"

        MatrixOne system database and tables are where MatrixOne stores system information, so if you want to see more information on the system, refer MatrixOne System Database and Tables.

        "},{"location":"MatrixOne/Troubleshooting/error-code/","title":"Error Code","text":"

        In MatrixOne, the error information is classified according to the error code. A specific type of error code will be unified into a specific error code for troubleshooting. All messages sent by the MatrixOne database service are assigned a five-character error code, which contains both the type of error code and the specific category of error code.

        During actual use, you can first check the error code and use the text error message attached to the error code to determine what kind of error occurred. Error encodings do not change across versions and do not change due to the localization of error messages.

        Note

        The SQL standard defines some of the error codes generated by MatrixOne; some additional error codes for conditions not defined by the standard were invented or borrowed from other databases.

        Error encoding head Type 201 Internal Error 202 Number and function error 203 Invalid Operation 204 Unknown Error or IO Error 205 RPC Timeout 206 Transaction Error or Storage Engine Error

        For more information on the details of these errors, please refer to the following table:

        Error code Error number Description Error type 20100 ErrStart internal error code start Internal error 20101 ErrInternal Internal error Internal error 20103 ErrNYI not yet implemented Internal error 20104 ErrOOM out of memory Internal error 20105 ErrQueryInterrupted query interrupted Internal error 20106 ErrNotSupported not supported Internal error 20200 ErrDivByZero division by zero Numbers and functions 20201 ErrOutOfRange data out of range Numbers and functions 20202 ErrDataTruncated data truncated Numbers and functions 20203 ErrInvalidArg invalid argument Numbers and functions 20204 ErrTruncatedWrongValueForField truncated wrong value for column Numbers and functions 20300 ErrBadConfig invalid configuration Invalid operation 20301 ErrInvalidInput invalid input Invalid operation 20302 ErrSyntaxError SQL syntax error Invalid operation 20303 ErrParseError SQL parser error Invalid operation 20304 ErrConstraintViolation constraint violation Invalid operation 20305 ErrDuplicate tae data duplicated Invalid operation 20306 ErrRoleGrantedToSelf cannot grant role Invalid operation 20307 ErrDuplicateEntry duplicate entry for key Invalid operation 20400 ErrInvalidState invalid state Unknown status or I/O error 20401 ErrLogServiceNotReady log service not ready Unknown status or I/O error 20402 ErrBadDB invalid database Unknown status or I/O error 20403 ErrNoSuchTable no such table Unknown status or I/O error 20404 ErrEmptyVector empty vector Unknown status or I/O error 20405 ErrFileNotFound file is not found Unknown status or I/O error 20406 ErrFileAlreadyExists file alread exists Unknown status or I/O error 20407 ErrUnexpectedEOF unexpteded end of file Unknown status or I/O error 20408 ErrEmptyRange empty range of file Unknown status or I/O error 20409 ErrSizeNotMatch file size does not match Unknown status or I/O error 20410 ErrNoProgress file has no io progress Unknown status or I/O error 20411 ErrInvalidPath invalid file path Unknown status or I/O error 20412 ErrShortWrite file io short write Unknown status or I/O error 20413 ErrInvalidWrite file io invalid write Unknown status or I/O error 20414 ErrShortBuffer file io short buffer Unknown status or I/O error 20415 ErrNoDB not connect to a database Unknown status or I/O error 20416 ErrNoWorkingStore no working store Unknown status or I/O error 20417 ErrNoHAKeeper cannot locate ha keeper Unknown status or I/O error 20418 ErrInvalidTruncateLsn invalid truncate lsn, shard already truncated Unknown status or I/O error 20419 ErrNotLeaseHolder not lease holder, current lease holder ID xxx Unknown status or I/O error 20420 ErrDBAlreadyExists database already exists Unknown status or I/O error 20421 ErrTableAlreadyExists table already exists Unknown status or I/O error 20422 ErrNoService service not found Unknown status or I/O error 20423 ErrDupServiceName duplicate service name Unknown status or I/O error 20424 ErrWrongService wrong service, expecting A, got B Unknown status or I/O error 20425 ErrBadS3Config bad s3 config Unknown status or I/O error 20426 ErrBadView invalid view Unknown status or I/O error 20427 ErrInvalidTask invalid task Unknown status or I/O error 20428 ErrInvalidServiceIndex invalid service idx Unknown status or I/O error 20429 ErrDragonboatTimeout Dragonboat timeout Unknown status or I/O error 20430 ErrDragonboatTimeoutTooSmall Dragonboat timeout too small Unknown status or I/O error 20431 ErrDragonboatInvalidDeadline Dragonboat invalid deadline Unknown status or I/O error 20432 ErrDragonboatRejected Dragonboat rejected Unknown status or I/O error 20433 ErrDragonboatInvalidPayloadSize invalid payload size Unknown status or I/O error 20434 ErrDragonboatShardNotReady shard not ready Unknown status or I/O error 20435 ErrDragonboatSystemClosed Dragonboat system closed Unknown status or I/O error 20436 ErrDragonboatInvalidRange Dragonboat invalid range Unknown status or I/O error 20437 ErrDragonboatShardNotFound shard not found Unknown status or I/O error 20438 ErrDragonboatOtherSystemError other system error Unknown status or I/O error 20439 ErrDropNonExistsDB Can't drop database ; database doesn't exist Unknown status or I/O error 20500 ErrRPCTimeout rpc timeout RPC Timeout 20501 ErrClientClosed client closed RPC Timeout 20502 ErrBackendClosed backend closed RPC Timeout 20503 ErrStreamClosed stream closed RPC Timeout 20504 ErrNoAvailableBackend no available backend RPC Timeout 20600 ErrTxnClosed the transaction has been committed or aborted Transaction 20601 ErrTxnWriteConflict transaction write conflict Transaction 20602 ErrMissingTxn missing transaction Transaction 20603 ErrUnresolvedConflict unresolved conflict Transaction 20604 ErrTxnError transaction error Transaction 20605 ErrDNShardNotFound TN shard not found Transaction 20606 ErrShardNotReported TN shard not reported Transaction 20607 ErrTAEError tae error TAE Error 20608 ErrTAERead tae read error TAE Error 20609 ErrRpcError rpc error TAE Error 20610 ErrWaitTxn transaction wait error TAE Error 20611 ErrTxnNotFound transaction not found TAE Error 20612 ErrTxnNotActive transaction not active TAE Error 20613 ErrTAEWrite tae write error TAE Error 20614 ErrTAECommit tae commit error TAE Error 20615 ErrTAERollback tae rollback error TAE Error 20616 ErrTAEPrepare tae prepare error TAE Error 20617 ErrTAEPossibleDuplicate tae possible duplicate TAE Error 20618 ErrTxnRWConflict r-w conflict TAE Error 20619 ErrTxnWWConflict w-w conflict TAE Error 20620 ErrNotFound transaction not found TAE Error 20621 ErrTxnInternal transaction internal error TAE Error 20622 ErrTxnReadConflict transaction read conflict TAE Error 20623 ErrPrimaryKeyDuplicated duplicated primary key TAE Error 20624 ErrAppendableSegmentNotFound appendable segment not found TAE Error 20625 ErrAppendableBlockNotFound appendable block not found TAE Error 20626 ErrTAEDebug TAE debug TAE Error"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/","title":"MatrixOne database statistics","text":"

        MatrixOne database statistics refer to the related information of tables and columns obtained through sampling and statistics of the database, for example, the number of tables, the number of columns of tables, the storage space occupied by tables, and so on. When MatrixOne database generates an execution plan, it needs to estimate based on statistical information to calculate the optimal execution plan.

        The statistics dimensions of the MatrixOne database are as follows:

        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-number-of-tables-in-the-database","title":"The number of tables in the database","text":"

        This command shows the total number of tables in the specified database.

        Syntax:

        SHOW TABLE_NUMBER FROM {DATABASE_NAME}\n
        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example","title":"Example","text":"
        • Example 1: Check the total number of tables in the system database mo_catalog:
        mysql> show table_number from mo_catalog;\n+--------------------------------+\n| Number of tables in mo_catalog |\n+--------------------------------+\n|                             11 |\n+--------------------------------+\n\n-- Verify which tables in mo_catalog\nmysql> use mo_catalog;\nmysql> show tables;\n+----------------------------+\n| Tables_in_mo_catalog       |\n+----------------------------+\n| mo_user                    |\n| mo_account                 |\n| mo_role                    |\n| mo_user_grant              |\n| mo_role_grant              |\n| mo_role_privs              |\n| mo_user_defined_function   |\n| mo_columns                 |\n| mo_mysql_compatbility_mode |\n| mo_tables                  |\n| mo_database                |\n+----------------------------+\n11 rows in set (0.01 sec)\n
        • Example 2: Create a new database, and create new tables, check the number of tables in the specific database:
        create database demo_1;\nuse demo_1;\n-- Create three new tables\nCREATE TABLE t1(a bigint, b varchar(10), c varchar(10));\nCREATE TABLE t2(a bigint, b int);\nCREATE TABLE t3(a int, b varchar(10), c varchar(10));\n\n-- Query out that there are three tables in the database demo_1\nmysql> show table_number from demo_1;\n+----------------------------+\n| Number of tables in demo_1 |\n+----------------------------+\n|                          3 |\n+----------------------------+\n1 row in set (0.01 sec)\n
        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-number-of-columns-in-the-table","title":"The number of columns in the table","text":"

        This command shows the total number of columns in the specified table.

        Syntax:

        SHOW COLUMN_NUMBER FROM {[DATABASE_NAME.]TABLE_NAME}\n
        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example_1","title":"Example","text":"
        use mo_catalog;\nuse mo_user;\nmysql> show column_number from mo_user;\n+------------------------------+\n| Number of columns in mo_user |\n+------------------------------+\n|                           11 |\n+------------------------------+\n\n-- Or use the following command\nmysql> show column_number from mo_catalog.mo_user;\n+------------------------------+\n| Number of columns in mo_user |\n+------------------------------+\n|                           11 |\n+------------------------------+\n\n-- Verify which columns in the table\nmysql> desc mo_catalog.mo_user;\n+-----------------------+--------------+------+------+---------+-------+---------+\n| Field                 | Type         | Null | Key  | Default | Extra | Comment |\n+-----------------------+--------------+------+------+---------+-------+---------+\n| user_id               | INT          | YES  |      | NULL    |       |         |\n| user_host             | VARCHAR(100) | YES  |      | NULL    |       |         |\n| user_name             | VARCHAR(300) | YES  |      | NULL    |       |         |\n| authentication_string | VARCHAR(100) | YES  |      | NULL    |       |         |\n| status                | VARCHAR(8)   | YES  |      | NULL    |       |         |\n| created_time          | TIMESTAMP    | YES  |      | NULL    |       |         |\n| expired_time          | TIMESTAMP    | YES  |      | NULL    |       |         |\n| login_type            | VARCHAR(16)  | YES  |      | NULL    |       |         |\n| creator               | INT          | YES  |      | NULL    |       |         |\n| owner                 | INT          | YES  |      | NULL    |       |         |\n| default_role          | INT          | YES  |      | NULL    |       |         |\n+-----------------------+--------------+------+------+---------+-------+---------+\n11 rows in set (0.01 sec)\n
        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-maximum-and-minimum-values-contained-in-all-columns-in-the-table","title":"The maximum and minimum values \u200b\u200bcontained in all columns in the table","text":"

        This command shows the maximum and minimum values \u200b\u200bof each column in the specified table.

        Note: If the data types of the column values \u200b\u200bin the specified table are inconsistent, the sorting rules are: numbers are sorted according to the size of numbers; dates are sorted according to time; characters are sorted according to ASCII code; when several data types are mixed, then First convert to character type, and then sort according to ASCII code.

        Syntax:

        SHOW TABLE_VALUES FROM {[DATABASE_NAME.]TABLE_NAME}\n
        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example_2","title":"Example","text":"
        create table t1(\ncol1 int,\ncol2 float,\ncol3 varchar\n);\ninsert into t1 values(1,1.11,'1.111'),(2,2.22,'1.222'),(3,0,'abc');\n\nmysql> show table_values from t1;\n+-----------+-----------+-----------+-----------+-----------+-----------+\n| max(col1) | min(col1) | max(col2) | min(col2) | max(col3) | min(col3) |\n+-----------+-----------+-----------+-----------+-----------+-----------+\n|         3 |         1 |      2.22 |         0 | abc       | 1.111     |\n+-----------+-----------+-----------+-----------+-----------+-----------+\n
        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-total-number-of-rows-of-data-in-the-table","title":"The total number of rows of data in the table","text":"

        This command shows the total number of rows of data in a table in the database.

        Syntax:

        SELECT MO_TABLE_ROWS({DATABASE_NAME},{TABLE_NAME})\n
        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example_3","title":"Example","text":"
        -- Query the total number of rows of mo_tables in mo_catalog\nmysql> select mo_table_rows('mo_catalog','mo_tables');\n+--------------------------------------+\n| mo_table_rows(mo_catalog, mo_tables) |\n+--------------------------------------+\n|                                   64 |\n+--------------------------------------+\n
        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#the-space-occupied-by-the-table-in-storage","title":"The space occupied by the table in storage","text":"

        This command shows the storage space occupied by a specific table in the database can be obtained, and the unit is the number of bytes.

        Syntax:

        SELECT MO_TABLE_SIZE({DATABASE_NAME},{TABLE_NAME})\n
        "},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#example_4","title":"Example","text":"
        -- Query the storage space occupied by the table mo_tables in the database mo_catalog\nmysql> select mo_table_size('mo_catalog','mo_tables');\n+--------------------------------------+\n| mo_table_size(mo_catalog, mo_tables) |\n+--------------------------------------+\n|                                16128 |\n+--------------------------------------+\n
        "},{"location":"MatrixOne/Troubleshooting/slow-queries/","title":"Slow Query","text":"

        Slow query: record the SQL statement that runs slowly in the log. Slow queries are recorded in the slow query log. Through the slow query log, you can find out which query statements have low execution efficiency for optimization.

        Currently, the slow queries on a MatrixOne are longer than 1000 milliseconds and cannot be directly output to corresponding log files. You need to create a view to filter the query information.

        "},{"location":"MatrixOne/Troubleshooting/slow-queries/#enable-slow-query","title":"Enable Slow Query","text":"

        The slow query log is disabled by default. To use the slow query log function, you must first enable the slow query log function.

        MatrixOne slow query feature is available with the following basic information:

        • statement: indicates the SQL text that provides the complete SQL statement.
        • request_at: indicates the start time of the SQL statement.
        • duration_second: indicates the actual execution time of the SQL statement.
        • exec_plan: indicates the detailed execution plan of the SQL statement.

        To enable the slow query, execute the following SQL statements:

        drop database if exists mo_ts;\ncreate database mo_ts;\nuse mo_ts;\ncreate view slow_query as select statement,request_at,duration/1000000000 as duration_second from system.statement_info where statement like 'select%' and duration/1000000000>1  order by request_at desc;\ncreate view slow_query_with_plan as select statement,request_at,duration/1000000000 as duration_second,exec_plan from system.statement_info where statement like 'select%' and duration/1000000000>1  order by request_at desc;\n

        For all queries longer than 1 second, execute the following SQL statement to view them:

        > select * from mo_ts.slow_query;\n> select * from mo_ts.slow_query_with_plan;\n

        Explanations

        • select * from mo_ts.slow_query;: slow query without plan.

        • select * from mo_ts.slow_query_with_plan;: slow query with plan..

        "},{"location":"MatrixOne/Troubleshooting/slow-queries/#error-log","title":"Error Log","text":"

        When slow query is enabled, you can enable error logs, check logs, and locate error information.

        "},{"location":"MatrixOne/Troubleshooting/slow-queries/#enable-error-log","title":"Enable Error Log","text":"

        To enable the error log, , execute the following SQL statements:

        create database mo_ts if not exists mo_ts;\nuse mo_ts;\ncreate view error_message as select timestamp,message from system.log_info where level in ('error','panic','faltal');\ncreate view error_sql as select si.request_at time_stamp,si.statement,si.error as SQL from system.statement_info si where si.user<>'internal' and si.status='Failed' ;\n
        "},{"location":"MatrixOne/Troubleshooting/slow-queries/#query-the-error-message-of-database","title":"Query the error message of database","text":"

        To query the error message of database, execute the following SQL statements:

        > select * from mo_ts.error_message;\n

        The query result example is as follows:

        +----------------------------+-------------------------------------------------------------------------+\n| timestamp                  | message                                                                 |\n+----------------------------+-------------------------------------------------------------------------+\n| 2022-11-28 14:47:31.324762 | error: SQL parser error: table \"error_sql\" does not exist               |\n| 2022-11-28 14:47:31.324837 | SQL parser error: table \"error_sql\" does not exist                      |\n| 2022-11-28 14:47:31.324872 | query trace status                                                      |\n| 2022-11-28 14:40:06.579795 | read loop stopped                                                       |\n| 2022-11-28 14:40:06.585220 | gc inactive backends task stopped                                       |\n| 2022-11-28 14:40:06.591082 | error: cannot locate ha keeper                                          |\n| 2022-11-28 14:40:08.442515 | failed to propose initial cluster info                                  |\n| 2022-11-28 14:40:08.442667 | failed to set initial cluster info                                      |\n| 2022-11-28 14:40:09.411286 | error: timeout, converted to code 20429                                 |\n| 2022-11-28 14:40:09.411508 | read loop stopped                                                       |\n| 2022-11-28 14:40:09.416557 | gc inactive backends task stopped                                       |\n| 2022-11-28 14:40:10.052585 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:10.052630 | failed to create init tasks                                             |\n| 2022-11-28 14:40:11.053926 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:11.054059 | failed to create init tasks                                             |\n| 2022-11-28 14:40:12.054578 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:12.054630 | failed to create init tasks                                             |\n| 2022-11-28 14:40:13.055828 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:13.055896 | failed to create init tasks                                             |\n| 2022-11-28 14:40:14.057102 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:14.057208 | failed to create init tasks                                             |\n| 2022-11-28 14:40:15.058425 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:15.058563 | failed to create init tasks                                             |\n| 2022-11-28 14:40:16.059867 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:16.060031 | failed to create init tasks                                             |\n| 2022-11-28 14:40:16.443234 | read loop stopped                                                       |\n| 2022-11-28 14:40:16.443162 | read from backend failed                                                |\n| 2022-11-28 14:40:16.448858 | gc inactive backends task stopped                                       |\n| 2022-11-28 14:40:16.457276 | error: file tnservice/dd4dccb4-4d3c-41f8-b482-5251dc7a41bf is not found |\n| 2022-11-28 14:40:17.061260 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:17.061323 | failed to create init tasks                                             |\n| 2022-11-28 14:40:18.062165 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:18.062249 | failed to create init tasks                                             |\n| 2022-11-28 14:40:18.642097 | error: TN shard uuid , id 2 not reported                                |\n| 2022-11-28 14:40:19.062775 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:19.062937 | failed to create init tasks                                             |\n| 2022-11-28 14:40:20.063237 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:20.063252 | failed to create init tasks                                             |\n| 2022-11-28 14:40:21.064529 | failed to create init tasks                                             |\n| 2022-11-28 14:40:21.064457 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:21.463193 | read loop stopped                                                       |\n| 2022-11-28 14:40:21.468423 | gc inactive backends task stopped                                       |\n| 2022-11-28 14:40:21.474688 | error: file cnservice/dd1dccb4-4d3c-41f8-b482-5251dc7a41bf is not found |\n| 2022-11-28 15:24:56.210577 | error: SQL parser error: table \"error_sql\" does not exist               |\n| 2022-11-28 15:24:56.210773 | SQL parser error: table \"error_sql\" does not exist                      |\n| 2022-11-28 15:24:56.210898 | query trace status                                                      |\n| 2022-11-28 14:40:22.065723 | error: internal error: failed to get task service                       |\n| 2022-11-28 14:40:22.065838 | failed to create init tasks                                             |\n| 2022-11-28 14:40:22.478229 | error: invalid state no cn in the cluster                               |\n| 2022-11-28 14:40:22.478846 | failed to refresh task storage                                          |\n| 2022-11-28 14:40:23.090160 | error: invalid database mo_task                                         |\n| 2022-11-28 14:40:23.090274 | invalid database mo_task                                                |\n| 2022-11-28 14:40:23.090604 | query trace status                                                      |\n| 2022-11-28 15:32:30.354364 | error: SQL parser error: table \"slow_query\" does not exist              |\n| 2022-11-28 15:32:30.354485 | SQL parser error: table \"slow_query\" does not exist                     |\n| 2022-11-28 15:32:30.354605 | query trace status                                                      |\n| 2022-11-28 15:26:59.639892 | error: SQL parser error: table \"error_sql\" does not exist               |\n| 2022-11-28 15:26:59.640039 | SQL parser error: table \"error_sql\" does not exist                      |\n| 2022-11-28 15:26:59.640208 | query trace status                                                      |\n| 2022-11-28 15:37:29.289457 | error: table slow_query already exists                                  |\n| 2022-11-28 15:37:29.289486 | table slow_query already exists                                         |\n| 2022-11-28 15:37:29.289518 | query trace status                                                      |\n| 2022-11-28 15:37:45.773829 | error: table slow_query_with_plan already exists                        |\n| 2022-11-28 15:37:45.773856 | table slow_query_with_plan already exists                               |\n| 2022-11-28 15:37:45.773888 | query trace status                                                      |\n| 2022-11-28 14:45:48.821324 | error: not supported: function or operator 'interval'                   |\n| 2022-11-28 14:45:48.823261 | error: not supported: function or operator 'interval'                   |\n| 2022-11-28 14:45:48.823426 | error: not supported: function or operator 'interval'                   |\n| 2022-11-28 14:45:48.823525 | error: not supported: function or operator 'interval'                   |\n| 2022-11-28 14:47:14.513831 | error: SQL parser error: table \"statement_info\" does not exist          |\n| 2022-11-28 14:47:14.513929 | SQL parser error: table \"statement_info\" does not exist                 |\n| 2022-11-28 14:47:14.513962 | query trace status                                                      |\n+----------------------------+-------------------------------------------------------------------------+\n72 rows in set (0.13 sec)\n
        "},{"location":"MatrixOne/Troubleshooting/slow-queries/#query-the-error-of-sql","title":"Query the error of SQL","text":"

        To query the error of SQL, execute the following SQL statements:

        > select * from mo_ts.error_sql;\n

        The query result example is as follows:

        +----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n| time_stamp                 | statement                                                                                                                                                                                                                              | sql                                                     |\n+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n| 2022-11-28 14:40:23.073188 | use mo_task                                                                                                                                                                                                                            | invalid database mo_task                                |\n| 2022-11-28 15:26:59.637130 | select * from mo_ts.error_sql                                                                                                                                                                                                          | SQL parser error: table \"error_sql\" does not exist      |\n| 2022-11-28 15:37:29.283683 | create view slow_query as select statement, request_at, duration / 1000000000 as duration_second from system.statement_info where statement like \"select%\" and duration / 1000000000 > 1 order by request_at desc                      | table slow_query already exists                         |\n| 2022-11-28 15:37:45.765394 | create view slow_query_with_plan as select statement, request_at, duration / 1000000000 as duration_second, exec_plan from system.statement_info where statement like \"select%\" and duration / 1000000000 > 1 order by request_at desc | table slow_query_with_plan already exists               |\n| 2022-11-28 15:32:30.351695 | select * from mo_ts.slow_query                                                                                                                                                                                                         | SQL parser error: table \"slow_query\" does not exist     |\n| 2022-11-28 14:47:14.510060 | create view error_sql as select si.request_at as time_stamp, si.statement as sql, el.err_code from statement_info as si cross join error_info as el where si.statement_id = el.statement_id and user != \"internal\"                     | SQL parser error: table \"statement_info\" does not exist |\n| 2022-11-28 14:47:31.323884 | select * from mo_ts.error_sql                                                                                                                                                                                                          | SQL parser error: table \"error_sql\" does not exist      |\n| 2022-11-28 15:24:56.208171 | select * from mo_ts.error_sql                                                                                                                                                                                                          | SQL parser error: table \"error_sql\" does not exist      |\n+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n8 rows in set (0.14 sec)\n
        "},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/","title":"Golang CRUD demo","text":""},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/#setup-your-environment","title":"Setup your environment","text":"
        1. Make sure you have already installed and launched MatrixOne.
        2. Make sure you have already installed Golang 1.18 and plus.

          #To check with Golang installation and its version\ngo version\n
        3. Make sure you have already installed MySQL client.

        4. Download and install Go-MySQL-Driver tool.
        "},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/#develop-your-code","title":"Develop your code","text":"
        1. Connect to MatrixOne by MySQL client. Create a new database named test.

          mysql> create database test;\n
        2. Create a plain text file golang_crud_matrixone.go and put the code below.

          package main\n\nimport (\n    \"database/sql\"\n    \"fmt\"\n    \"log\"\n    _ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc main() {\n    //Open a new connection to MatrixOne\n    db, err := sql.Open(\"mysql\", \"root:111@tcp(127.0.0.1:6001)/test\")\n    checkErr(err)\n\n    //Create a table\n    _, err2 := db.Exec(\"CREATE TABLE `userinfo` (`uid` INT(10) NOT NULL AUTO_INCREMENT,`username` VARCHAR(64) NULL DEFAULT NULL,`department` VARCHAR(64) NULL DEFAULT NULL,`created` DATETIME NULL DEFAULT NULL, PRIMARY KEY (`uid`));\")\n    if err2 != nil {\n        log.Fatal(err2)\n    }\n    fmt.Print(\"Successfully Created\\n\")\n\n    // Insert a record\n    stmt, err := db.Prepare(\"INSERT userinfo SET username=?,department=?,created=?\")\n    checkErr(err)\n\n    res, err := stmt.Exec(\"Alex\", \"r&d\", \"2023-01-01\" 12:00:00\")\n    checkErr(err)\n\n    id, err := res.LastInsertId()\n    checkErr(err)\n\n    fmt.Println(id)\n    //Update a record\n    stmt, err = db.Prepare(\"update userinfo set username=? where uid=?\")\n    checkErr(err)\n\n    res, err = stmt.Exec(\"Mark\", id)\n    checkErr(err)\n\n    affect, err := res.RowsAffected()\n    checkErr(err)\n\n    fmt.Println(affect)\n\n    // Query all records\n    rows, err := db.Query(\"SELECT * FROM userinfo\")\n    checkErr(err)\n\n    for rows.Next() {\n        var uid int\n        var username string\n        var department string\n        var created string\n        err = rows.Scan(&uid, &username, &department, &created)\n        checkErr(err)\n        fmt.Println(uid)\n        fmt.Println(username)\n        fmt.Println(department)\n        fmt.Println(created)\n    }\n\n    // Delete a record\n    stmt, err = db.Prepare(\"delete from userinfo where uid=?\")\n    checkErr(err)\n\n    res, err = stmt.Exec(id)\n    checkErr(err)\n\n    affect, err = res.RowsAffected()\n    checkErr(err)\n\n    fmt.Println(affect)\n\n    db.Close()\n\n}\n\nfunc checkErr(err error) {\n    if err != nil {\n        panic(err)\n    }\n}\n
        3. Execute this Golang file in the command line terminal.

          > go run golang_crud_matrixone.go\nSuccessfully Created\n1\n1\n1\nMark\nr&d\n2023-01-01\n1\n
        "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/","title":"Java CRUD demo","text":"

        Note

        The source code of this demo can be downloaded at Java CRUD Example.

        "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#setup-your-environment","title":"Setup your environment","text":"

        Before you start, make sure you have downloaded and installed the following software.

        • Install and deployed standalone MatrixOne. Create a database by MySQL client.
        mysql> create database test;\n
        • lntelliJ IDEA(2022.2.1 or later version).
        • JDK 8+ version: Choose the version according to your OS.
        • MySQL JDBC connector 8.0+ version: It's recommanded to download the platform independent version, and unzip the downloaded file.

        Note

        We take IDEA as an IDE example to demonstrate the process, you are free to choose Eclipse or other IDE tools for the same purpose.

        "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#initialize-a-new-java-project","title":"Initialize a new Java project","text":"

        Launch IDEA, and create a new Java project as below:

        In your Project Setting > Libraries, import the mysql-connector-java-8.0.30.jar file.

        "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#write-java-code-to-connect-with-matrixone","title":"Write Java code to connect with MatrixOne","text":"

        Firstly we create a Java class named as JDBCUtils as a connection utility. This class will serve as a tool to connect with MatrixOne and execute SQL queries.

        Under the src directory, create a file named JDBCUtils.java, and edit this file with the following code.

        import java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.SQLException;\n\npublic class JDBCUtils {\n    private static String jdbcURL = \"jdbc:mysql://127.0.0.1:6001/test\";\n    private static String jdbcUsername = \"root\";\n    private static String jdbcPassword = \"111\";\n\n    public static Connection getConnection() {\n        Connection connection = null;\n        try {\n            connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);\n        } catch (SQLException e) {\n            // TODO Auto-generated catch block\n            e.printStackTrace();\n        }\n        return connection;\n    }\n\n    public static void printSQLException(SQLException ex) {\n        for (Throwable e : ex) {\n            if (e instanceof SQLException) {\n                e.printStackTrace(System.err);\n                System.err.println(\"SQLState: \" + ((SQLException) e).getSQLState());\n                System.err.println(\"Error Code: \" + ((SQLException) e).getErrorCode());\n                System.err.println(\"Message: \" + e.getMessage());\n                Throwable t = ex.getCause();\n                while (t != null) {\n                    System.out.println(\"Cause: \" + t);\n                    t = t.getCause();\n                }\n            }\n        }\n    }\n}\n

        Secondly we write example code for Create/Insert/Update/Delete operations with MatrixOne.

        We need to create corresponding java source code files as Create.java, Insert.java, Select.java, Update.java under the src directory, and put the code below in these files.

        "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#create","title":"Create","text":"
        import java.sql.Connection;\nimport java.sql.SQLException;\nimport java.sql.Statement;\n\npublic class Create {\n    private static final String createTableSQL = \"create table student (\\r\\n\" + \"  id int primary key,\\r\\n\" +\n            \"  name varchar(20),\\r\\n\" + \"  email varchar(20),\\r\\n\" + \"  country varchar(20),\\r\\n\" +\n            \"  age int\\r\\n\" + \"  );\";\n\n    public static void main(String[] argv) throws SQLException {\n        Create createTable = new Create();\n        createTable.createTable();\n    }\n\n    public void createTable() throws SQLException {\n\n        System.out.println(createTableSQL);\n        // Step 1: Establishing a Connection\n        try (Connection connection = JDBCUtils.getConnection();\n             // Step 2:Create a statement using connection object\n             Statement statement = connection.createStatement();) {\n\n            // Step 3: Execute the query or update query\n            statement.execute(createTableSQL);\n        } catch (SQLException e) {\n\n            // print SQL exception information\n            JDBCUtils.printSQLException(e);\n        }\n\n        // Step 4: try-with-resource statement will auto close the connection.\n    }\n}\n

        Executing this code will create a table in the test database, then we verify in mysql client to check if the table is created.

        mysql> show create table student;\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table   | Create Table                                                                                                                                                                                        |\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| student | CREATE TABLE `student` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(20) DEFAULT NULL,\n`email` VARCHAR(20) DEFAULT NULL,\n`country` VARCHAR(20) DEFAULT NULL,\n`age` INT DEFAULT NULL,\nPRIMARY KEY (`id`)\n) |\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
        "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#insert","title":"Insert","text":"
        import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.SQLException;\n\npublic class Insert {\n    private static final String INSERT_STUDENT_SQL = \"INSERT INTO student\" +\n            \"  (id, name, email, country, age) VALUES \" +\n            \" (?, ?, ?, ?, ?);\";\n\n    public static void main(String[] argv) throws SQLException {\n        Insert insertTable = new Insert();\n        insertTable.insertRecord();\n    }\n\n    public void insertRecord() throws SQLException {\n        System.out.println(INSERT_STUDENT_SQL);\n        // Step 1: Establishing a Connection\n        try (Connection connection = JDBCUtils.getConnection();\n             // Step 2:Create a statement using connection object\n             PreparedStatement preparedStatement = connection.prepareStatement(INSERT_STUDENT_SQL)) {\n            preparedStatement.setInt(1, 1);\n            preparedStatement.setString(2, \"Tony\");\n            preparedStatement.setString(3, \"tony@gmail.com\");\n            preparedStatement.setString(4, \"US\");\n            preparedStatement.setString(5, \"20\");\n\n            System.out.println(preparedStatement);\n            // Step 3: Execute the query or update query\n            preparedStatement.executeUpdate();\n        } catch (SQLException e) {\n\n            // print SQL exception information\n            JDBCUtils.printSQLException(e);\n        }\n\n        // Step 4: try-with-resource statement will auto close the connection.\n    }\n\n}\n

        Execution result:

        mysql> select * from student;\n+------+------+----------------+---------+------+\n| id   | name | email          | country | age  |\n+------+------+----------------+---------+------+\n|    1 | Tony | tony@gmail.com | US      |   20 |\n+------+------+----------------+---------+------+\n1 row in set (0.01 sec)\n
        "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#update","title":"Update","text":"
        import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.SQLException;\n\npublic class Update {\n    private static final String UPDATE_STUDENT_SQL = \"update student set name = ? where id = ?;\";\n\n    public static void main(String[] argv) throws SQLException {\n        Update updateTable = new Update();\n        updateTable.updateRecord();\n    }\n\n    public void updateRecord() throws SQLException {\n        System.out.println(UPDATE_STUDENT_SQL);\n        // Step 1: Establishing a Connection\n        try (Connection connection = JDBCUtils.getConnection();\n             // Step 2:Create a statement using connection object\n             PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_STUDENT_SQL)) {\n            preparedStatement.setString(1, \"Ram\");\n            preparedStatement.setInt(2, 1);\n\n            // Step 3: Execute the query or update query\n            preparedStatement.executeUpdate();\n        } catch (SQLException e) {\n\n            // print SQL exception information\n            JDBCUtils.printSQLException(e);\n        }\n\n        // Step 4: try-with-resource statement will auto close the connection.\n    }\n}\n

        Execution result:

        mysql> select * from student;\n+------+------+----------------+---------+------+\n| id   | name | email          | country | age  |\n+------+------+----------------+---------+------+\n|    1 | Ram  | tony@gmail.com | US      |   20 |\n+------+------+----------------+---------+------+\n1 row in set (0.00 sec)\n
        "},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#select","title":"SELECT","text":"
        import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n\npublic class Select {\n    private static final String QUERY = \"select id,name,email,country,age from student where id =?\";\n\n    public static void main(String[] args) {\n\n        // using try-with-resources to avoid closing resources (boiler plate code)\n\n        // Step 1: Establishing a Connection\n        try (Connection connection = JDBCUtils.getConnection();\n\n             // Step 2:Create a statement using connection object\n             PreparedStatement preparedStatement = connection.prepareStatement(QUERY);) {\n            preparedStatement.setInt(1, 1);\n            System.out.println(preparedStatement);\n            // Step 3: Execute the query or update query\n            ResultSet rs = preparedStatement.executeQuery();\n\n            // Step 4: Process the ResultSet object.\n            while (rs.next()) {\n                int id = rs.getInt(\"id\");\n                String name = rs.getString(\"name\");\n                String email = rs.getString(\"email\");\n                String country = rs.getString(\"country\");\n                String password = rs.getString(\"age\");\n                System.out.println(id + \",\" + name + \",\" + email + \",\" + country + \",\" + password);\n            }\n        } catch (SQLException e) {\n            JDBCUtils.printSQLException(e);\n        }\n        // Step 4: try-with-resource statement will auto close the connection.\n    }\n}\n

        Execution result:

        "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/","title":"Python CRUD demo","text":""},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#before-you-start","title":"Before you start","text":""},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#setup-your-environment","title":"Setup your environment","text":"

        Before you start, make sure you have downloaded and installed the following software.

        1. Make sure you have already installed and launched MatrixOne.
        2. Make sure you have already installed Python 3.8(or plus) version.

          #To check with Python installation and its version\npython3 -V\n
        3. Make sure you have already installed MySQL.

        4. Download and install pymysql and cryptography tool.

          pip3 install pymysql\npip3 install cryptography\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\n

        As we have explained how to connect to MatrixOne by pymysql in the other tutorial, we will focus on the CRUD(Create, Read, Update, Delete) implementations in this tutorial.

        "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#create-table","title":"Create Table","text":"

        Firstly we create a text file named create.py, and put the following code:

        #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n    port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"CREATE TABLE cars (id INT NOT NULL AUTO_INCREMENT, car_model VARCHAR(45) NULL,car_brand VARCHAR(45) NULL,PRIMARY KEY (`id`))\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        print(\"Table created\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

        Execute this python file by a terminal with the command line below. This will create a table cars in MatrixOne inside database test.

        > python3 create.py\nTable created\n

        We can verify the table creation with MySQL client.

        mysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| cars           |\n+----------------+\n1 row in set (0.03 sec)\nmysql> show create table cars;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                             |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| cars  | CREATE TABLE `cars` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`car_model` VARCHAR(45) DEFAULT NULL,\n`car_brand` VARCHAR(45) DEFAULT NULL,\nPRIMARY KEY (`id`)\n) |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.03 sec)\n
        "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#insert","title":"Insert","text":"

        Secondly we create a text file named insert.py, and put the following code:

        #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"INSERT INTO cars(car_model, car_brand) VALUES ('accord', 'honda')\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        if sql_exec:\n            print(sql_exec)\n            print(\"Record Added\")\n        else:\n            print(sql_exec)\n            print(\"Not Added\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

        Executing the following code will insert a record in the cars table, then we verify in mysql client to check if the record is inserted.

        > python3 insert.py\n1\nRecord Added\n
        mysql> select * from cars;\n+------+-----------+-----------+\n| id   | car_model | car_brand |\n+------+-----------+-----------+\n|    1 | accord    | honda     |\n+------+-----------+-----------+\n1 row in set (0.03 sec)\n
        "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#select","title":"Select","text":"

        Thirdly we create a text file named read.py, and put the following code:

        #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"SELECT * FROM cars\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        if sql_exec:\n            print(sql_exec)\n            print(cursor.fetchall())\n        else:\n            print(sql_exec)\n            print(\"No Record\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

        Executing this code will select and return all records in the cars table.

        > python3 read.py\n1\n[{'id': 1, 'car_model': 'accord', 'car_brand': 'honda'}]\n
        "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#update","title":"Update","text":"

        Fourthly we create a text file named update.py, and put the following code:

        #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"UPDATE cars SET car_model = 'explorer', car_brand = 'ford' WHERE id = '1'\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        if sql_exec:\n            print(sql_exec)\n            print(\"Record Updated\")\n        else:\n            print(sql_exec)\n            print(\"Not Updated\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

        Executing this code will update the record with id 1, then we verify in mysql client to check if the record is updated.

        > python3 update.py\n1\nRecord Updated\n
        mysql> select * from cars;\n+------+-----------+-----------+\n| id   | car_model | car_brand |\n+------+-----------+-----------+\n|    1 | explorer  | ford      |\n+------+-----------+-----------+\n1 row in set (0.02 sec)\n
        "},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#delete","title":"Delete","text":"

        Finally we create a text file named delete.py, and put the following code:

        #!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n        host='127.0.0.1',\n        port=6001,\n        user='root',\n        password = \"111\",\n        db='test',\n        cursorclass=pymysql.cursors.DictCursor,\n        autocommit=True\n        )\n\nSQL = \"DELETE FROM cars WHERE id = '1'\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n    try:\n        sql_exec = cursor.execute(SQL)\n        if sql_exec:\n            print(sql_exec)\n            print(\"Record Deleted\")\n        else:\n            print(sql_exec)\n            print(\"Not Deleted\")\n    except (pymysql.Error, pymysql.Warning) as e:\n        print(f'error! {e}')\n\n    finally:\n        SQL_CONNECTION.close()\n

        Executing this code will delete the record with id 1, then we verify in mysql client to check if the record is updated.

        > python3 delete.py\n1\nRecord Deleted\n
        mysql> select * from cars;\nEmpty set (0.03 sec)\n
        "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/","title":"Gorm CRUD demo","text":"

        This tutorial shows you how to build a simple GO+Gorm CRUD(Create, Read, Update, Delete) application with MatrixOne. Gorm is one of the most popular ORM tools in GO language.

        "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#before-you-start","title":"Before you start","text":"

        A brief introduction about these softwares concerned:

        • Gorm: The fantastic ORM library for Golang aims to be developer friendly. gorm.io/gorm and gorm.io/driver/mysql will vbe used to make Go connect to MYSQL.
        "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#setup-your-environment","title":"Setup your environment","text":"

        Before you start, make sure you have downloaded and installed the following software.

        1. Make sure you have already installed and launched MatrixOne. Connect to MatrixOne and create a database by MySQL client.

          mysql> create database test;\n
        2. Make sure you have already installed Golang 1.18 (or plus) version.

          #To check with Golang installation and its version\ngo version\n
        3. Make sure you have already installed MySQL.

        4. Use command go get to install gorm.io/gorm and gorm.io/driver/mysql.

          go get -u gorm.io/gorm\ngo get -u gorm.io/driver/mysql\n

        As we have explained how to connect to MatrixOne by Gorm in the other tutorial, we will focus on the CRUD(Create, Read, Update, Delete) implementations in this tutorial.

        "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#create","title":"Create","text":"

        As an Object Relational Mapper(ORM) tool, Gorm allows developers to create go class to map the table in relational database. In the example below, we will create a User class. The class name and the attribute name must starts with a capital letter to make public access.

        Create a go file gorm_create.go and put the code below.

        package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{\n// Logger: logger.Default.LogMode(logger.Info), //print SQL\n})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n}\n

        To enable the logging of converted SQL output, you can uncomment the following line:Logger: logger.Default.LogMode(logger.Info)

        To run the Go file, open a terminal and use the following command:

        go run gorm_create.go\n

        You can use a MySQL client to verify if the table has been successfully created.

        mysql> show tables;\n+----------------+\n| Tables_in_test |\n+----------------+\n| users          |\n+----------------+\n1 row in set (0.01 sec)\n
        "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#inserting-data","title":"Inserting Data","text":"

        In the following example, you will be guided on how to insert two records into the users table that was created earlier. The ID column is assumed to be auto-incremented, but you can also specify a fixed value.

        Create a new text file named gorm_insert.go and copy the following code into the file:

        package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Insert users**\nusers := []USER{\n{\n// ID: 1, //autoincrement\nCNAME:    \"lili\",\nCADDRESS: \"Shanghai\"},\n{\nID:       111,\nCNAME:    \"zhang\",\nCADDRESS: \"Biejing\",\n},\n}\n\ndb.Create(users)\n\n}\n

        Open your terminal and execute the following command to run the go file:

        go run gorm_insert.go\n

        Similarly, you can use a MySQL client to verify if the data has been successfully inserted into the table.

        mysql> select * from users;\n+------+-------+----------+\n| id   | cname | caddress |\n+------+-------+----------+\n|    1 | lili  | Shanghai |\n|  111 | zhang | Biejing  |\n+------+-------+----------+\n2 rows in set (0.01 sec)\n
        "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#querying-data","title":"Querying Data","text":"

        In the following example, you will be guided on how to query a subset of data based on a condition, specifically querying data where CNAME=zhang .

        Create a new text file named gorm_query.go and copy the following code into the file:

        package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Query\u2014\u2014 String condition** \nres := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&res)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nfmt.Println(res)\n\n}\n

        Open your terminal and execute the following command to run the go file:

        go run gorm_query.go\n

        The output of the terminal will include the following data.

        {111 zhang Biejing}\n
        "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#updating-data","title":"Updating Data","text":"

        In the following demonstration, you will be guided on how to update data. Create a text file named gorm_update.go and copy-paste the following code into the file:

        package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Update** \naUser := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&aUser)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nres:=db.Model(&aUser).Update(\"CADDRESS\", \"HongKong\")\nif res.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\n\n}\n

        Open your terminal and execute the following command to run the go file:

        go run gorm_update.go\n

        You can use the MySQL client to verify if the table has been updated successfully:

        mysql> select * from users;\n+------+-------+----------+\n| id   | cname | caddress |\n+------+-------+----------+\n|  111 | zhang | HongKong |\n|    1 | lili  | Shanghai |\n+------+-------+----------+\n2 rows in set (0.00 sec)\n
        "},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#deleting-data","title":"Deleting Data","text":"

        In the following demonstration, you will be guided on how to delete a single data record. It is important to note that when deleting a single record, you need to specify the primary key, otherwise it may trigger a batch delete. Create a text file named gorm_delete.go and copy-paste the following code into the file:

        package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID       uint `gorm:\"primaryKey\"`\nCNAME    string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Delete** \naUser := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&aUser)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nres := db.Delete(&aUser)\nif res.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\n\n}\n

        Open your terminal and execute the following command to run the go file:

        go run gorm_delete.go\n

        You can use the MySQL client to verify if the table has been deleted successfully:

        mysql> select * from users;\n+------+-------+----------+\n| id   | cname | caddress |\n+------+-------+----------+\n|    1 | lili  | Shanghai |\n+------+-------+----------+\n1 row in set (0.00 sec)\n

        The above is just a partial demonstration of CRUD operations in GORM. For more usage and examples, please refer to the GORM Official Guides.

        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/","title":"SpringBoot and JPA CRUD demo","text":"

        This tutorial completes a simple Demo based on SpringBoot+Spring Data JPA+MatrixOne+Intellij IDEA , and realizes the basic CRUD function.

        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#before-you-start","title":"Before you start","text":"

        A brief introduction about these softwares concerned:

        • Spring Data JPA: JPA is a specification that defines an API for object-relational mappings and for managing persistent objects. Spring Data JPA is an object\u2013relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain model to a relational database.
        • Intellij IDEA: IntelliJ IDEA is a popular IDE for Java developers. It has a lot of plugins that can enhance our efficiency.
        • Maven: Maven is a powerful management tool in Java that can automatically download and import Jar file according to the configuration in the pom.xml file. This feature reduces the conflicts between different versions of Jar files.
        • Spring: Spring is one of the most popular frameworks in Java and more and more enterprise is using the Spring framework to build their project. Spring Boot is built on top of the conventional spring framework. So, it provides all the features of spring and is yet easier to use than spring.
        • Postman: Postman is an application used for API testing. It is an HTTP client that tests HTTP requests, utilizing a graphical user interface, through which we obtain different types of responses that need to be subsequently validated.
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#set-up-environment","title":"Set up environment","text":""},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-install-and-launch-matrixone","title":"1. Install and Launch MatrixOne","text":"

        Follow the installation instruction and launch MatrixOne. Create a database test by MySQL client.

        mysql> create database test;\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-create-a-new-spring-boot-project-using-intellij-idea","title":"2. Create a new Spring Boot Project Using IntelliJ IDEA","text":"

        Choose Spring Initializer, and name the project as you want.

        Choose Spring Web, JDBC API, Spring Data JPA, and MySQL Driver as dependencies for this project.

        Click Create, the project will be created. The dependencies are listed in the pom.xml file. Usually you don't need to modify anything.

        <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n    <groupId>com.example</groupId>\n    <artifactId>jpademo</artifactId>\n    <version>0.0.1-SNAPSHOT</version>\n    <name>jpademo</name>\n    <description>jpademo</description>\n\n    <properties>\n        <java.version>1.8</java.version>\n        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n        <spring-boot.version>2.3.7.RELEASE</spring-boot.version>\n    </properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-data-jpa</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-jdbc</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-web</artifactId>\n        </dependency>\n\n        <dependency>\n            <groupId>mysql</groupId>\n            <artifactId>mysql-connector-java</artifactId>\n            <scope>runtime</scope>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-test</artifactId>\n            <scope>test</scope>\n            <exclusions>\n                <exclusion>\n                    <groupId>org.junit.vintage</groupId>\n                    <artifactId>junit-vintage-engine</artifactId>\n                </exclusion>\n            </exclusions>\n        </dependency>\n    </dependencies>\n\n    <dependencyManagement>\n        <dependencies>\n            <dependency>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-dependencies</artifactId>\n                <version>${spring-boot.version}</version>\n                <type>pom</type>\n                <scope>import</scope>\n            </dependency>\n        </dependencies>\n    </dependencyManagement>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <version>3.8.1</version>\n                <configuration>\n                    <source>1.8</source>\n                    <target>1.8</target>\n                    <encoding>UTF-8</encoding>\n                </configuration>\n            </plugin>\n            <plugin>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-maven-plugin</artifactId>\n                <version>2.3.7.RELEASE</version>\n                <configuration>\n                    <mainClass>com.example.jpademo.JpademoApplication</mainClass>\n                </configuration>\n                <executions>\n                    <execution>\n                        <id>repackage</id>\n                        <goals>\n                            <goal>repackage</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n        </plugins>\n    </build>\n\n</project>\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-modify-the-applicationproperties-file","title":"3. Modify the application.properties file","text":"

        Under resources folder, the MatrixOne connection and Hibernate need to be configured in application.properties file.

        # Application Name\nspring.application.name=jpademo\n# Database driver\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\n# Data Source name\nspring.datasource.name=defaultDataSource\n\n# Database connection url, modify to MatrixOne address and port, with parameters\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\n# Database username and password\nspring.datasource.username=root\nspring.datasource.password=111\n# Web application port\nserver.port=8080\n\n# Hibernate configurations\nspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect\nspring.jpa.properties.hibernate.id.new_generator_mappings = false\nspring.jpa.properties.hibernate.format_sql = true\nspring.jpa.hibernate.ddl-auto = validate\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-create-table-and-insert-some-data-in-matrixone","title":"4. Create table and insert some data in MatrixOne","text":"

        Connect to MatrixOne with MySQL client and execute the following SQL statements. You can save these SQL statements in a book.sql under /resource/database/.

        mysql> USE test;\nmysql> CREATE TABLE IF NOT EXISTS `book` (\n    `id` int(11) NOT NULL AUTO_INCREMENT,\n    `author` varchar(255) DEFAULT NULL,\n    `category` varchar(255) DEFAULT NULL,\n    `name` varchar(255) DEFAULT NULL,\n    `pages` int(11) DEFAULT NULL,\n    `price` int(11) DEFAULT NULL,\n    `publication` varchar(255) DEFAULT NULL,\n    PRIMARY KEY (`id`)\n    );\nmysql> INSERT INTO `book` (`id`, `author`, `category`, `name`, `pages`, `price`, `publication`) VALUES\n(1, 'Antoine de Saint-Exupery', 'Fantancy', 'The Little Prince', 100, 50, 'Amazon'),\n(2, 'J. K. Rowling', 'Fantancy', 'Harry Potter and the Sorcerer''s Stone', 1000, 200, 'Amazon'),\n(3, 'Lewis Carroll', 'Fantancy', 'Alice''s Adventures in Wonderland', 1500, 240, 'Amazon');\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#write-code","title":"Write Code","text":"

        After setting up the environment, we write code to implement a simple CRUD application. After finishing coding, you'll have a project structure as below. You can create these packages and java class in advance. We will code the Create, Update, Insert, Delete, Select operations for this demo application.

        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-bookstorecontrollerjava","title":"1. BookStoreController.java","text":"
        package com.example.jpademo.controller;\n\nimport com.example.jpademo.entity.Book;\nimport com.example.jpademo.services.IBookStoreService;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\n\n@Controller\n@RequestMapping(\"bookservice\")\npublic class BookStoreController {\n\n    @Autowired\n    private IBookStoreService service;\n\n    @GetMapping(\"books\")\n    public ResponseEntity<List<Book>> getBooks(){\n\n        List<Book> books = service.getBooks();\n        return new ResponseEntity<List<Book>>(books, HttpStatus.OK);\n\n    }\n\n    @GetMapping(\"books/{id}\")\n    public ResponseEntity<Book> getBook(@PathVariable(\"id\") Integer id){\n        Book book = service.getBook(id);\n        return new ResponseEntity<Book>(book, HttpStatus.OK);\n    }\n\n    @PostMapping(\"books\")\n    public ResponseEntity<Book> createBook(@RequestBody Book book){\n        Book b = service.createBook(book);\n        return new ResponseEntity<Book>(b, HttpStatus.OK);\n\n    }\n\n    @PutMapping(\"books/{id}\")\n    public ResponseEntity<Book> updateBook(@PathVariable(\"id\") int id, @RequestBody Book book){\n\n        Book b = service.updateBook(id, book);\n        return new ResponseEntity<Book>(b, HttpStatus.OK);\n    }\n\n    @DeleteMapping(\"books/{id}\")\n    public ResponseEntity<String> deleteBook(@PathVariable(\"id\") int id){\n        boolean isDeleted = service.deleteBook(id);\n        if(isDeleted){\n            String responseContent = \"Book has been deleted successfully\";\n            return new ResponseEntity<String>(responseContent,HttpStatus.OK);\n        }\n        String error = \"Error while deleting book from database\";\n        return new ResponseEntity<String>(error,HttpStatus.INTERNAL_SERVER_ERROR);\n    }\n\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-boostoredaojava","title":"2. BooStoreDAO.java","text":"
        package com.example.jpademo.dao;\n\nimport com.example.jpademo.entity.Book;\nimport org.springframework.stereotype.Repository;\nimport org.springframework.transaction.annotation.Transactional;\n\nimport javax.persistence.EntityManager;\nimport javax.persistence.PersistenceContext;\nimport javax.persistence.Query;\nimport java.util.List;\n\n@Transactional\n@Repository\npublic class BookStoreDAO implements IBookStoreDAO {\n\n    @PersistenceContext\n    private EntityManager entityManager;\n\n    /**\n     * This method is responsible to get all books available in database and return it as List<Book>\n     */\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public List<Book> getBooks() {\n\n        String hql = \"FROM Book as atcl ORDER BY atcl.id\";\n        return (List<Book>) entityManager.createQuery(hql).getResultList();\n    }\n\n    /**\n     * This method is responsible to get a particular Book detail by given book id\n     */\n    @Override\n    public Book getBook(int bookId) {\n\n        return entityManager.find(Book.class, bookId);\n    }\n\n    /**\n     * This method is responsible to create new book in database\n     */\n    @Override\n    public Book createBook(Book book) {\n        entityManager.persist(book);\n        Book b = getLastInsertedBook();\n        return b;\n    }\n\n    /**\n     * This method is responsible to update book detail in database\n     */\n    @Override\n    public Book updateBook(int bookId, Book book) {\n\n        //First We are taking Book detail from database by given book id and\n        // then updating detail with provided book object\n        Book bookFromDB = getBook(bookId);\n        bookFromDB.setName(book.getName());\n        bookFromDB.setAuthor(book.getAuthor());\n        bookFromDB.setCategory(book.getCategory());\n        bookFromDB.setPublication(book.getPublication());\n        bookFromDB.setPages(book.getPages());\n        bookFromDB.setPrice(book.getPrice());\n\n        entityManager.flush();\n\n        //again i am taking updated result of book and returning the book object\n        Book updatedBook = getBook(bookId);\n\n        return updatedBook;\n    }\n\n    /**\n     * This method is responsible for deleting a particular(which id will be passed that record)\n     * record from the database\n     */\n    @Override\n    public boolean deleteBook(int bookId) {\n        Book book = getBook(bookId);\n        entityManager.remove(book);\n\n        //we are checking here that whether entityManager contains earlier deleted book or not\n        // if contains then book is not deleted from DB that's why returning false;\n        boolean status = entityManager.contains(book);\n        if(status){\n            return false;\n        }\n        return true;\n    }\n\n    /**\n     * This method will get the latest inserted record from the database and return the object of Book class\n     * @return book\n     */\n    private Book getLastInsertedBook(){\n        String hql = \"from Book order by id DESC\";\n        Query query = entityManager.createQuery(hql);\n        query.setMaxResults(1);\n        Book book = (Book)query.getSingleResult();\n        return book;\n    }\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-ibookstoredaojava","title":"3. IBookStoreDAO.java","text":"
        package com.example.jpademo.dao;\n\nimport com.example.jpademo.entity.Book;\n\nimport java.util.List;\n\npublic interface IBookStoreDAO {\n\n    List<Book> getBooks();\n    Book getBook(int bookId);\n    Book createBook(Book book);\n    Book updateBook(int bookId,Book book);\n    boolean deleteBook(int bookId);\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-bookjava","title":"4. Book.java","text":"
        package com.example.jpademo.entity;\n\nimport javax.persistence.*;\nimport java.io.Serializable;\n\n@Entity\n@Table(name=\"book\")\npublic class Book implements Serializable {\n\n    private static final long serialVersionUID = 1L;\n    @Id\n    @GeneratedValue(strategy= GenerationType.AUTO)\n    @Column(name=\"id\")\n    private int id;\n\n    @Column(name=\"name\")\n    private String name;\n\n    @Column(name=\"author\")\n    private String author;\n\n    @Column(name=\"publication\")\n    private String publication;\n\n    @Column(name=\"category\")\n    private String category;\n\n    @Column(name=\"pages\")\n    private int pages;\n\n    @Column(name=\"price\")\n    private int price;\n\n    public int getId() {\n        return id;\n    }\n\n    public void setId(int id) {\n        this.id = id;\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    public String getAuthor() {\n        return author;\n    }\n\n    public void setAuthor(String author) {\n        this.author = author;\n    }\n\n    public String getPublication() {\n        return publication;\n    }\n\n    public void setPublication(String publication) {\n        this.publication = publication;\n    }\n\n    public String getCategory() {\n        return category;\n    }\n\n    public void setCategory(String category) {\n        this.category = category;\n    }\n\n    public int getPages() {\n        return pages;\n    }\n\n    public void setPages(int pages) {\n        this.pages = pages;\n    }\n\n    public int getPrice() {\n        return price;\n    }\n\n    public void setPrice(int price) {\n        this.price = price;\n    }\n\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#5-bookstoreservicejava","title":"5. BookStoreService.java","text":"
        package com.example.jpademo.services;\n\nimport com.example.jpademo.dao.IBookStoreDAO;\nimport com.example.jpademo.entity.Book;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\n\nimport java.util.List;\n\n@Service\npublic class BookStoreService implements IBookStoreService {\n\n    @Autowired\n    private IBookStoreDAO dao;\n\n    @Override\n    public List<Book> getBooks() {\n        return dao.getBooks();\n    }\n\n    @Override\n    public Book createBook(Book book) {\n        return dao.createBook(book);\n    }\n\n    @Override\n    public Book updateBook(int bookId, Book book) {\n        return dao.updateBook(bookId, book);\n    }\n\n    @Override\n    public Book getBook(int bookId) {\n        return dao.getBook(bookId);\n    }\n\n    @Override\n    public boolean deleteBook(int bookId) {\n        return dao.deleteBook(bookId);\n    }\n\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#6-ibookstoreservicejava","title":"6. IBookStoreService.java","text":"
        package com.example.jpademo.services;\n\nimport com.example.jpademo.entity.Book;\n\nimport java.util.List;\n\npublic interface IBookStoreService {\n\n    List<Book> getBooks();\n    Book createBook(Book book);\n    Book updateBook(int bookId, Book book);\n    Book getBook(int bookId);\n    boolean deleteBook(int bookId);\n\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#7-jpademoapplication","title":"7. JpademoApplication","text":"
        package com.example.jpademo;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@SpringBootApplication\npublic class JpademoApplication {\n\n    public static void main(String[] args) {\n        SpringApplication.run(JpademoApplication.class, args);\n    }\n\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#test","title":"Test","text":"

        Build and test this project.

        When you see the following example messages, the application is well launched; we can call REST endpoints using POSTMAN.

        2022-10-27 11:16:16.793  INFO 93488 --- [           main] com.example.jpademo.JpademoApplication   : Starting JpademoApplication on username-macbookpro.local with PID 93488 (/Users/username/IdeaProjects/jpademo/target/classes started by username in /Users/username/IdeaProjects/jpademo)\n2022-10-27 11:16:16.796  INFO 93488 --- [           main] com.example.jpademo.JpademoApplication   : No active profile set, falling back to default profiles: default\n2022-10-27 11:16:18.022  INFO 93488 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.\n2022-10-27 11:16:18.093  INFO 93488 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 50ms. Found 0 JPA repository interfaces.\n2022-10-27 11:16:18.806  INFO 93488 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)\n2022-10-27 11:16:18.814  INFO 93488 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]\n2022-10-27 11:16:18.814  INFO 93488 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]\n2022-10-27 11:16:18.886  INFO 93488 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext\n2022-10-27 11:16:18.886  INFO 93488 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2005 ms\n2022-10-27 11:16:19.068  INFO 93488 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]\n2022-10-27 11:16:19.119  INFO 93488 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.25.Final\n2022-10-27 11:16:19.202  INFO 93488 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}\n2022-10-27 11:16:19.282  INFO 93488 --- [           main] com.zaxxer.hikari.HikariDataSource       : defaultDataSource - Starting...\n2022-10-27 11:16:20.025  INFO 93488 --- [           main] com.zaxxer.hikari.HikariDataSource       : defaultDataSource - Start completed.\n2022-10-27 11:16:20.035  INFO 93488 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect\n2022-10-27 11:16:21.929  INFO 93488 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]\n2022-10-27 11:16:21.937  INFO 93488 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'\n2022-10-27 11:16:22.073  WARN 93488 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning\n2022-10-27 11:16:22.221  INFO 93488 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'\n2022-10-27 11:16:22.415  INFO 93488 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''\n2022-10-27 11:16:22.430  INFO 93488 --- [           main] com.example.jpademo.JpademoApplication   : Started JpademoApplication in 6.079 seconds (JVM running for 8.765)\n2022-10-27 11:16:40.180  INFO 93488 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'\n2022-10-27 11:16:40.183  INFO 93488 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'\n2022-10-27 11:16:40.249  INFO 93488 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 66 ms\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-to-get-list-of-books-call-following-endpoint-with-get-request","title":"1. To get list of books call following endpoint with GET Request","text":"
         http://localhost:8080/bookservice/books\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-to-create-new-book-use-following-url-with-post-request","title":"2. To Create New Book use following url with POST Request","text":"
        http://localhost:8080/bookservice/books\n

        Set content type as in header as application/json, set request body as raw with JSON payload

          {\n    \"name\": \"The Lion, the Witch and the Wardrobe\",\n    \"author\": \"C. S. Lewis\",\n    \"publication\": \"Amazon\",\n    \"category\": \"Fantancy\",\n    \"pages\": 123,\n    \"price\": 10\n  }\n

        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-to-get-a-particular-book-use-following-url-with-get-request-type-in-postman","title":"3. To get a particular book, use following url with GET request type in postman","text":"
          http://localhost:8080/bookservice/books/<id>\n
        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-to-update-book-in-database-use-following-url-with-put-request-type-in-postman","title":"4. To update Book in database, use following url with PUT request type in postman","text":"
            http://localhost:8080/bookservice/books/<id>\n
        • Set content type as in header as application/json

        • Set request body as raw with JSON payload

         {\n    \"name\": \"Black Beauty\",\n    \"author\": \"Anna Sewell\",\n    \"publication\": \"Amazon\",\n    \"category\": \"Fantancy\",\n    \"pages\": 134,\n    \"price\": 12\n  }\n

        "},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#5-to-delete-a-particular-book-from-database-use-following-url-with-delete-request-type-in-postman","title":"5. To delete a particular Book from database, use following url with DELETE request type in postman","text":"
          http://localhost:8080/bookservice/books/<id>\n
        mysql> select * from book;\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n| id | author                   | category | name                             | pages | price | publication |\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n|  1 | Antoine de Saint-Exupery | Fantancy | The Little Prince                |   100 |    50 | Amazon      |\n|  2 | Anna Sewell              | Fantancy | Black Beauty                     |   134 |    12 | Amazon      |\n|  3 | Lewis Carroll            | Fantancy | Alice's Adventures in Wonderland |  1500 |   240 | Amazon      |\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n3 rows in set (0.02 sec)\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/","title":"SpringBoot and MyBatis CRUD demo","text":"

        This tutorial completes a simple Demo based on SpringBoot+Mybatis+MatrixOne+Intellij IDEA , and realizes the basic CRUD function.

        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#before-you-start","title":"Before you start","text":"

        A brief introduction about these softwares concerned:

        • MyBatis: It is a popular persistence framework that can customize SQL and support for complex reports and advanced mappings. We only need to focus on the SQL itself in our project.
        • Intellij IDEA: IntelliJ IDEA is a popular IDE for Java developers. It has a lot of plugins that can enhance our efficiency.
        • Maven: Maven is a powerful management tool in Java that can automatically download and import Jar file according to the configuration in the pom.xml file. This feature reduces the conflicts between different versions of Jar files.
        • Spring: Spring is one of the most popular frameworks in Java and more and more enterprise is using the Spring framework to build their project. Spring Boot is built on top of the conventional spring framework. So, it provides all the features of spring and is yet easier to use than spring.
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#set-up-environment","title":"Set up environment","text":""},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1-install-and-launch-matrixone","title":"1. Install and Launch MatrixOne","text":"

        Follow the installation instruction and launch MatrixOne. Create a database test by MySQL client.

        mysql> create database test;\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-create-a-new-spring-boot-project-using-intellij-idea","title":"2. Create a new Spring Boot Project Using IntelliJ IDEA","text":"

        Choose Spring Initializer, and name the project as you want.

        Choose Spring Web, MyBatis Framework, JDBC API and MySQL Driver as dependencies for this project.

        Click Create, the project will be created. The dependencies are listed in the pom.xml file. Usually you don't need to modify anything.

        <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n    <groupId>com.example</groupId>\n    <artifactId>mybatis-demo</artifactId>\n    <version>0.0.1-SNAPSHOT</version>\n    <name>mybatis-demo</name>\n    <description>mybatis-demo</description>\n\n    <properties>\n        <java.version>1.8</java.version>\n        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n        <spring-boot.version>2.3.7.RELEASE</spring-boot.version>\n    </properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-jdbc</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-web</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.mybatis.spring.boot</groupId>\n            <artifactId>mybatis-spring-boot-starter</artifactId>\n            <version>2.1.4</version>\n        </dependency>\n\n        <dependency>\n            <groupId>mysql</groupId>\n            <artifactId>mysql-connector-java</artifactId>\n            <scope>runtime</scope>\n        </dependency>\n        <dependency>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-test</artifactId>\n            <scope>test</scope>\n            <exclusions>\n                <exclusion>\n                    <groupId>org.junit.vintage</groupId>\n                    <artifactId>junit-vintage-engine</artifactId>\n                </exclusion>\n            </exclusions>\n        </dependency>\n    </dependencies>\n\n    <dependencyManagement>\n        <dependencies>\n            <dependency>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-dependencies</artifactId>\n                <version>${spring-boot.version}</version>\n                <type>pom</type>\n                <scope>import</scope>\n            </dependency>\n        </dependencies>\n    </dependencyManagement>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <version>3.8.1</version>\n                <configuration>\n                    <source>1.8</source>\n                    <target>1.8</target>\n                    <encoding>UTF-8</encoding>\n                </configuration>\n            </plugin>\n            <plugin>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-maven-plugin</artifactId>\n                <version>2.3.7.RELEASE</version>\n                <configuration>\n                    <mainClass>com.example.mybatisdemo.MybatisDemoApplication</mainClass>\n                </configuration>\n                <executions>\n                    <execution>\n                        <id>repackage</id>\n                        <goals>\n                            <goal>repackage</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n        </plugins>\n    </build>\n\n</project>\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-modify-the-applicationproperties-file","title":"3. Modify the application.properties file","text":"

        Under resources folder, the MatrixOne connection need to be configured in application.properties file.

        # Application Name\nspring.application.name=MyBatisDemo\n# Database driver\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\n# Data Source name\nspring.datasource.name=defaultDataSource\n\n# Database connection url, modify to MatrixOne address and port, with paratemers\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\n# Database username and password\nspring.datasource.username=root\nspring.datasource.password=111\n\n# Mybatis mapper location\nmybatis.mapper-locations=classpath:mapping/*xml\n# Mybatis entity package\nmybatis.type-aliases-package=com.example.mybatisdemo.entity\n# Web application port\nserver.port=8080\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#write-code","title":"Write Code","text":"

        After setting up the environment, we write code to implement a simple CRUD application. After finishing coding, you'll have a project structure as below. You can create these packages and java class in advance. We will code the Create, Update, Insert, Delete, Select operations for this demo application.

        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1-usercontrollerjava","title":"1. UserController.java","text":"
        package com.example.mybatisdemo.controller;\n\nimport com.example.mybatisdemo.entity.User;\nimport com.example.mybatisdemo.service.UserService;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.ResponseBody;\nimport org.springframework.web.bind.annotation.RestController;\n\n@RestController\n@RequestMapping(\"/test\")\npublic class UserController {\n\n    String tableName = \"user\";\n    @Autowired\n    private UserService userService;\n\n    @RequestMapping(value = \"/create\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    @ResponseBody\n    public String createTable(){\n        return userService.createTable(tableName);\n    }\n\n    @RequestMapping(value = \"/selectUserByid\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    @ResponseBody\n    public String GetUser(User user){\n        return userService.Sel(user).toString();\n    }\n\n    @RequestMapping(value = \"/add\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    public String Add(User user){\n        return userService.Add(user);\n    }\n\n    @RequestMapping(value = \"/update\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    public String Update(User user){\n        return userService.Update(user);\n    }\n\n    @RequestMapping(value = \"/delete\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n    public String Delete(User user){\n        return userService.Delete(user);\n    }\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-userjava","title":"2. User.java","text":"
        package com.example.mybatisdemo.entity;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\n\npublic class User {\n    private Integer id;\n    private String username;\n    private String password;\n    private String address;\n\n    public User(Integer id, String username, String password, String address) {\n        this.id = id;\n        this.username = username;\n        this.password = password;\n        this.address = address;\n    }\n\n    public Integer getId() {\n        return id;\n    }\n\n    public String getUsername() {\n        return username;\n    }\n\n    public String getPassword() {\n        return password;\n    }\n\n    public String getAddress() {\n        return address;\n    }\n\n    public void setId(Integer id) {\n        this.id = id;\n    }\n\n    public void setUsername(String username) {\n        this.username = username;\n    }\n\n    public void setPassword(String password) {\n        this.password = password;\n    }\n\n    public void setAddress(String address) {\n        this.address = address;\n    }\n\n    @Override\n    public String toString() {\n        return \"User{\" +\n                \"id=\" + id +\n                \", username='\" + username + '\\'' +\n                \", password='\" + password + '\\'' +\n                \", address='\" + address + '\\'' +\n                '}';\n    }\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-usermapperjava","title":"3. UserMapper.java","text":"
        package com.example.mybatisdemo.mapper;\n\nimport com.example.mybatisdemo.entity.User;\nimport org.apache.ibatis.annotations.Param;\nimport org.springframework.stereotype.Repository;\n\n@Repository\npublic interface UserMapper {\n\n    int createTable(@Param(\"tableName\") String tableName);\n\n    User Sel(@Param(\"user\")User user);\n\n    int Add(@Param(\"user\")User user);\n\n    int Update(@Param(\"user\")User user);\n\n    int Delete(@Param(\"user\")User user);\n\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#4-userservicejava","title":"4. UserService.java","text":"
        package com.example.mybatisdemo.service;\n\nimport com.example.mybatisdemo.entity.User;\nimport com.example.mybatisdemo.mapper.UserMapper;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\n\n@Service\npublic class UserService {\n    @Autowired\n    UserMapper userMapper;\n\n    public String createTable(String table){\n        int a = userMapper.createTable(table);\n        if (a == 1) {\n            return \"Create table failed\";\n        } else {\n            return \"Create table successfully\";\n        }\n    }\n\n    public User Sel(User user) {\n        return userMapper.Sel(user);\n    }\n\n    public String Add(User user) {\n        int a = userMapper.Add(user);\n        if (a == 1) {\n            return \"Add user successfully\";\n        } else {\n            return \"Add user failed\";\n        }\n    }\n\n    public String Update(User user) {\n        int a = userMapper.Update(user);\n        if (a == 1) {\n            return \"Update user successfully\";\n        } else {\n            return \"Update user failed\";\n        }\n    }\n\n    public String Delete(User user) {\n        int a = userMapper.Delete(user);\n        if (a == 1) {\n            return \"Delete user successfully\";\n        } else {\n            return \"Delete user failed\";\n        }\n    }\n\n};\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#5-mybatisdemoapplicationjava","title":"5. MyBatisDemoApplication.java","text":"
        package com.example.mybatisdemo;\n\nimport org.mybatis.spring.annotation.MapperScan;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@MapperScan(\"com.example.mybatisdemo.mapper\")\n@SpringBootApplication\npublic class MyBatisDemoApplication {\n    public static void main(String[] args) {\n        SpringApplication.run(MyBatisDemoApplication.class, args);\n    }\n}\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#6-usermapperxml","title":"6. UserMapper.xml","text":"
        <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">\n\n<mapper namespace=\"com.example.mybatisdemo.mapper.UserMapper\">\n\n    <resultMap id=\"BaseResultMap\" type=\"com.example.mybatisdemo.entity.User\">\n        <result column=\"id\" jdbcType=\"INTEGER\" property=\"id\"/>\n        <result column=\"userName\" jdbcType=\"VARCHAR\" property=\"username\"/>\n        <result column=\"passWord\" jdbcType=\"VARCHAR\" property=\"password\"/>\n        <result column=\"realName\" jdbcType=\"VARCHAR\" property=\"address\"/>\n    </resultMap>\n\n    <update id=\"createTable\" parameterType=\"string\">\n        CREATE TABLE ${tableName} (\n            `id` int(11) NOT NULL AUTO_INCREMENT,\n            `username` varchar(255) DEFAULT NULL,\n            `password` varchar(255) DEFAULT NULL,\n            `address` varchar(255) DEFAULT NULL,\n            PRIMARY KEY (`id`)\n        );\n    </update>\n\n    <select id=\"Sel\" resultType=\"com.example.mybatisdemo.entity.User\">\n        select * from user where 1=1\n        <if test=\"user.id != null\">\n            AND id = #{user.id}\n        </if>\n    </select>\n\n    <insert id=\"Add\" parameterType=\"com.example.mybatisdemo.entity.User\">\n        INSERT INTO user\n        <trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">\n            <if test=\"user.username != null\">\n                username,\n            </if>\n            <if test=\"user.password != null\">\n                password,\n            </if>\n            <if test=\"user.address != null\">\n                address,\n            </if>\n        </trim>\n        <trim prefix=\"VALUES (\" suffix=\")\" suffixOverrides=\",\">\n            <if test=\"user.username != null\">\n                #{user.username,jdbcType=VARCHAR},\n            </if>\n            <if test=\"user.password != null\">\n                #{user.password,jdbcType=VARCHAR},\n            </if>\n            <if test=\"user.address != null\">\n                #{user.address,jdbcType=VARCHAR},\n            </if>\n        </trim>\n    </insert>\n\n    <update id=\"Update\" parameterType=\"com.example.mybatisdemo.entity.User\">\n        UPDATE user\n        <set>\n            <if test=\"user.username != null\">\n                username = #{user.username},\n            </if>\n            <if test=\"user.password != null\">\n                password = #{user.password},\n            </if>\n            <if test=\"user.address != null\">\n                address = #{user.address},\n            </if>\n        </set>\n        WHERE\n        id=#{user.id}\n    </update>\n\n    <delete id=\"Delete\"  parameterType=\"com.example.mybatisdemo.entity.User\">\n        DELETE FROM user WHERE id = #{user.id}\n    </delete>\n\n</mapper>\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#test","title":"Test","text":"

        Build and launch this project.

        When you see the following example messages, the application is well-launched, and you can open your browser and send HTTP requests.

        2022-10-26 16:13:24.030  INFO 60253 --- [           main] c.e.mybatisdemo.MyBatisDemoApplication   : Starting MyBatisDemoApplication on username-macbookpro.local with PID 60253 (/Users/username/IdeaProjects/MyBatisDemo/target/classes started by username in /Users/username/IdeaProjects/MyBatisDemo)\n2022-10-26 16:13:24.035  INFO 60253 --- [           main] c.e.mybatisdemo.MyBatisDemoApplication   : No active profile set, falling back to default profiles: default\n2022-10-26 16:13:25.415  INFO 60253 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)\n2022-10-26 16:13:25.421  INFO 60253 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]\n2022-10-26 16:13:25.421  INFO 60253 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]\n2022-10-26 16:13:25.476  INFO 60253 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext\n2022-10-26 16:13:25.477  INFO 60253 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1390 ms\n2022-10-26 16:13:26.020  INFO 60253 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'\n2022-10-26 16:13:26.248  INFO 60253 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''\n2022-10-26 16:13:26.272  INFO 60253 --- [           main] c.e.mybatisdemo.MyBatisDemoApplication   : Started MyBatisDemoApplication in 2.669 seconds (JVM running for 3.544)\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1-test-create-table","title":"1. Test Create Table","text":"

        Launch your browser and type the following url:

        http://localhost:8080/test/create\n

        In MySQL client, we can verify if the table has been successfully created.

        mysql> use test;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nmysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| user           |\n+----------------+\n1 row in set (0.00 sec)\n\nmysql> show create table user;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                                                                                                  |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| user  | CREATE TABLE `user` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`username` VARCHAR(255) DEFAULT null,\n`password` VARCHAR(255) DEFAULT null,\n`address` VARCHAR(255) DEFAULT null,\nPRIMARY KEY (`id`)\n) |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-test-add-user","title":"2. Test Add User","text":"

        Launch your browser and type the following url:

        http://localhost:8080/test/add?username=tom&password=123456&address=shanghai\n

        In MySQL client, we can verify if the record is added.

        mysql> select * from user;\n+------+----------+----------+----------+\n| id   | username | password | address  |\n+------+----------+----------+----------+\n|    1 | tom      | 123456   | shanghai |\n+------+----------+----------+----------+\n1 row in set (0.00 sec)\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-test-select-user","title":"3. Test Select User","text":"

        Launch your browser and type the following url:

        http://localhost:8080/test/selectUserByid?id=1\n

        We can directly get the queried result from the browser.

        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#4-test-update-user","title":"4. Test Update User","text":"

        Launch your browser and type the following url:

        http://localhost:8080/test/update/username=tom&password=654321&address=beijing\n

        In MySQL client, we can verify if the record is updated.

        mysql> select * from user;\n+------+----------+----------+---------+\n| id   | username | password | address |\n+------+----------+----------+---------+\n|    1 | tom      | 654321   | beijing |\n+------+----------+----------+---------+\n1 row in set (0.00 sec)\n
        "},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#5-test-delete-user","title":"5. Test Delete User","text":"

        Launch your browser and type the following url:

        http://localhost:8080/test/delete?id=1\n

        In MySQL client, we can verify if the record is deleted.

        mysql> select * from user;\nEmpty set (0.00 sec)\n
        "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/","title":"SQLAlchemy CRUD demo","text":"

        This tutorial shows you how to build a simple Python+SQLAlchemy CRUD(Create, Read, Update, Delete) application with MatrixOne. SQLAlchemy is one of the most popular ORM tools in python language.

        "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#before-you-start","title":"Before you start","text":"

        A brief introduction about these softwares concerned:

        • SQLAlchemy: SQLAlchemy is a python library that facilitates the communication between Python programs and databases. Most of the times, this library is used as an Object Relational Mapper (ORM) tool that translates Python classes to tables on relational databases and automatically converts function calls to SQL statements.
        • Faker: Faker is a Python library that generates fake data. Fake data is often used for testing or filling databases with some dummy data.
        "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#setup-your-environment","title":"Setup your environment","text":"

        Before you start, make sure you have downloaded and installed the following software.

        1. Make sure you have already installed and launched MatrixOne. Connect to MatrixOne and create a database by MySQL client.

          mysql> create database test;\n
        2. Make sure you have already installed Python 3.8(or plus) version.

          #To check with Python installation and its version\npython3 -V\n
        3. Make sure you have already installed MySQL.

        4. Download and install sqlalchemy, pymysql, cryptography and faker tool.

          pip3 install sqlalchemy\npip3 install pymysql\npip3 install cryptography\npip3 install faker\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install sqlalchemy -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install faker -i https://pypi.tuna.tsinghua.edu.cn/simple\n

        As we have explained how to connect to MatrixOne by SQLAlchemy in the other tutorial, we will focus on the CRUD(Create, Read, Update, Delete) implementations in this tutorial.

        "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#create","title":"Create","text":"

        As an Object Relational Mapper(ORM) tool, SQLAlchemy allows developers to create python class to map the table in relational database. In the example below, we will create a User class which is a representation of User table in MatrixOne, the code which defines User is equal to a SQL statement as:

        CREATE TABLE `User` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`cname` VARCHAR(64) DEFAULT NULL,\n`caddress` VARCHAR(512) DEFAULT NULL,\nPRIMARY KEY (`id`)\n)\n

        Let's now create this example in a text file named sqlalchemy_create.py, and put the following code:

        from faker import Factory\nfrom sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nfaker = Factory.create()\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\n\nclass Customer(Base):\n    __tablename__ = \"Customer\"\n    id = Column(Integer, primary_key=True,autoincrement=True)\n    cname = Column(String(64))\n    caddress = Column(String(512))\n\n    def __init__(self,name,address):\n        self.cname = name\n        self.caddress = address\n\n    def __str__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n    def __repr__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# Generate 10 Customer records\nCustomers = [Customer(name= faker.name(),address = faker.address()) for i in range(10)]\n\n# Create the table\nBase.metadata.create_all(engine)\n\n# Insert all customer records to Customer table\nsession.add_all(Customers)\n\nsession.commit()\n

        Execute this file in a terminal with such command:

        > python3 sqlalchemy_create.py\n

        Then we verify the table creation in MySQL client:

        mysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| Customer       |\n+----------------+\n1 row in set (0.04 sec)\nmysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id   | cname            | caddress                                            |\n+------+------------------+-----------------------------------------------------+\n|    1 | Wendy Luna       | 002 Brian Plaza\nAndrewhaven, SC 88456               |\n|    2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249                            |\n|    3 | Angela Ramos     | 029 Todd Curve Apt. 352\nMooreville, FM 15950        |\n|    4 | Lisa Bruce       | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853     |\n|    5 | Julie Moore      | Unit 1117 Box 1029\nDPO AP 87468                     |\n|    6 | David Massey     | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549    |\n|    7 | David Mccann     | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n|    8 | Morgan Price     | 57463 Lisa Drive\nThompsonshire, NM 88077            |\n|    9 | Samuel Griffin   | 186 Patel Crossing\nNorth Stefaniechester, WV 08221  |\n|   10 | Tristan Pierce   | 593 Blankenship Rapids\nNew Jameshaven, SD 89585     |\n+------+------------------+-----------------------------------------------------+\n10 rows in set (0.03 sec)\n
        "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#read","title":"Read","text":"

        In the following example, we read data from the Customer table by two ways.

        The first one is a full scan, which equals to a query as:

        select * from `Customer`\n

        The second one is a point query, which equals to a query as:

        select * from `Customer` where `cname` = 'David Mccann';\n

        We create this example in a text file named sqlalchemy_read.py, and put the following code:

        from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n    __tablename__ = \"Customer\"\n    id = Column(Integer, primary_key=True,autoincrement=True)\n    cname = Column(String(64))\n    caddress = Column(String(512))\n\n    def __init__(self,name,address):\n        self.cname = name\n        self.caddress = address\n\n    def __str__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n    def __repr__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# query all data\ncustomers = session.query(Customer).all()\n\nfor customer in customers:\n     print(customer.__str__() +\"\\n--------------------------\\n\")\n\n# query with a filter condition\nMccann = session.query(Customer).filter_by(cname='David Mccann').first()\nprint(Mccann)\nprint(\"\\n------------------------\\n\")\n

        Execute this file in a terminal with such command and we will see the query result:

        > python3 sqlalchemy_read.py\ncname:Wendy Luna caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n--------------------------\n\ncname:Meagan Rodriguez caddress:USCGC Olson\nFPO AP 21249\n--------------------------\n\ncname:Angela Ramos caddress:029 Todd Curve Apt. 352\nMooreville, FM 15950\n--------------------------\n\ncname:Lisa Bruce caddress:68103 Mackenzie Mountain\nNorth Andrew, UT 29853\n--------------------------\n\ncname:Julie Moore caddress:Unit 1117 Box 1029\nDPO AP 87468\n--------------------------\n\ncname:David Massey caddress:207 Wayne Groves Apt. 733\nVanessashire, NE 34549\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n--------------------------\n\ncname:Morgan Price caddress:57463 Lisa Drive\nThompsonshire, NM 88077\n--------------------------\n\ncname:Samuel Griffin caddress:186 Patel Crossing\nNorth Stefaniechester, WV 08221\n--------------------------\n\ncname:Tristan Pierce caddress:593 Blankenship Rapids\nNew Jameshaven, SD 89585\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n\n------------------------\n
        "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#update","title":"Update","text":"

        In the following example, we update the first cname column of Customer table by another value. We create this example in a text file named sqlalchemy_update.py, and put the following code:

        from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n    __tablename__ = \"Customer\"\n    id = Column(Integer, primary_key=True,autoincrement=True)\n    cname = Column(String(64))\n    caddress = Column(String(512))\n\n    def __init__(self,name,address):\n        self.cname = name\n        self.caddress = address\n\n    def __str__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n    def __repr__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\ncustomer = session.query(Customer).first()\nprint(customer)\nprint(\"\\n---------------------\\n\")\n\n# Rename customer\ncustomer.cname = \"Coby White\"\n\n\nsession.commit()\n\n# See the updated result\ncustomer = session.query(Customer).first()\nprint(customer)\n

        Execute this file in a terminal with such command and we will see the query result:

        > python3 sqlalchemy_update.py     \ncname:Wendy Luna caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n\n---------------------\n\ncname:Coby White caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n

        Then we verify the record being updated in MySQL client:

        mysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id   | cname            | caddress                                            |\n+------+------------------+-----------------------------------------------------+\n|    1 | Coby White       | 002 Brian Plaza\nAndrewhaven, SC 88456               |\n|    2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249                            |\n|    3 | Angela Ramos     | 029 Todd Curve Apt. 352\nMooreville, FM 15950        |\n|    4 | Lisa Bruce       | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853     |\n|    5 | Julie Moore      | Unit 1117 Box 1029\nDPO AP 87468                     |\n|    6 | David Massey     | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549    |\n|    7 | David Mccann     | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n|    8 | Morgan Price     | 57463 Lisa Drive\nThompsonshire, NM 88077            |\n|    9 | Samuel Griffin   | 186 Patel Crossing\nNorth Stefaniechester, WV 08221  |\n|   10 | Tristan Pierce   | 593 Blankenship Rapids\nNew Jameshaven, SD 89585     |\n+------+------------------+-----------------------------------------------------+\n10 rows in set (0.02 sec)\n
        "},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#delete","title":"Delete","text":"

        In the following example, we delete the first record of the Customer table. We create this example in a text file named sqlalchemy_detele.py, and put the following code:

        from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n    __tablename__ = \"Customer\"\n    id = Column(Integer, primary_key=True,autoincrement=True)\n    cname = Column(String(64))\n    caddress = Column(String(512))\n\n    def __init__(self,name,address):\n        self.cname = name\n        self.caddress = address\n\n    def __str__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n    def __repr__(self):\n        return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# delete the first record\ncustomer = session.query(Customer).first()\n\nsession.delete(customer)\nsession.commit()\n\n# query all data\ncustomers = session.query(Customer).all()\n\nfor customer in customers:\n     print(customer.__str__() +\"\\n--------------------------\\n\")\n

        Execute this file in a terminal with such command and we will see the query result:

        > python3 sqlalchemy_delete.py         \ncname:Meagan Rodriguez caddress:USCGC Olson\nFPO AP 21249\n--------------------------\n\ncname:Angela Ramos caddress:029 Todd Curve Apt. 352\nMooreville, FM 15950\n--------------------------\n\ncname:Lisa Bruce caddress:68103 Mackenzie Mountain\nNorth Andrew, UT 29853\n--------------------------\n\ncname:Julie Moore caddress:Unit 1117 Box 1029\nDPO AP 87468\n--------------------------\n\ncname:David Massey caddress:207 Wayne Groves Apt. 733\nVanessashire, NE 34549\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n--------------------------\n\ncname:Morgan Price caddress:57463 Lisa Drive\nThompsonshire, NM 88077\n--------------------------\n\ncname:Samuel Griffin caddress:186 Patel Crossing\nNorth Stefaniechester, WV 08221\n--------------------------\n\ncname:Tristan Pierce caddress:593 Blankenship Rapids\nNew Jameshaven, SD 89585\n--------------------------\n

        Then we verify the record being deleted in MySQL client:

        mysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id   | cname            | caddress                                            |\n+------+------------------+-----------------------------------------------------+\n|    2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249                            |\n|    3 | Angela Ramos     | 029 Todd Curve Apt. 352\nMooreville, FM 15950        |\n|    4 | Lisa Bruce       | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853     |\n|    5 | Julie Moore      | Unit 1117 Box 1029\nDPO AP 87468                     |\n|    6 | David Massey     | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549    |\n|    7 | David Mccann     | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n|    8 | Morgan Price     | 57463 Lisa Drive\nThompsonshire, NM 88077            |\n|    9 | Samuel Griffin   | 186 Patel Crossing\nNorth Stefaniechester, WV 08221  |\n|   10 | Tristan Pierce   | 593 Blankenship Rapids\nNew Jameshaven, SD 89585     |\n+------+------------------+-----------------------------------------------------+\n9 rows in set (0.04 sec)\n
        "}]} \ No newline at end of file diff --git a/dev/sitemap.xml.gz b/dev/sitemap.xml.gz index 1ae04045a..c41d6103b 100644 Binary files a/dev/sitemap.xml.gz and b/dev/sitemap.xml.gz differ