当前位置:网站首页>Initial experience of creating partitioned tables under MySQL cases tdsql for MySQL (I)
Initial experience of creating partitioned tables under MySQL cases tdsql for MySQL (I)
2022-06-24 02:18:00 【Yaochong】
installed TDSQL for MySQL after , Log in to the red rabbit platform , The first thing that comes into view is the overview of the cluster , Display the overall information of the cluster , For example, the amount used 、 Total capacity, etc , You can click in “ Get into ”, Enter instance management .
Or click instance management to enter the instance , We choose 【 Distributed 】 example , Click to enter
After entering, it will display , Example details 、SET management 、 Database management 、DB monitor 、Proxy Monitoring and other information , The following figure shows the example details
The following figure for SET management
You can see , The current two SET, The cluster is set to 4 A shard , Then we create tables based on the sharding
Let's change the following table into a distributed table , According to the customer ID Slice
CREATE TABLE `orders` ( `o_orderkey` int(11) NOT NULL, `O_CUSTKEY` int(11) NOT NULL, `O_ORDERSTATUS` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `O_TOTALPRICE` decimal(15,2) NOT NULL, `O_ORDERDATE` date NOT NULL, `O_ORDERPRIORITY` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `O_CLERK` char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `O_SHIPPRIORITY` int(11) NOT NULL, `O_COMMENT` varchar(79) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, PRIMARY KEY (`o_orderkey`), KEY `orders_fk1` (`O_CUSTKEY`), KEY `i_orders_date_clerk` (`O_ORDERDATE`,`O_CLERK`), KEY `i_orders_clerk_date` (`O_CLERK`,`O_ORDERDATE`), CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`O_CUSTKEY`) REFERENCES `customer` (`c_custkey`) ON DELETE RESTRICT ON UPDATE RESTRICT ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
The list is as follows
The index section is as follows , No foreign key options
Click Create , as for DATE type , What default values need to be added , I didn't know how to specify the default value !!! So it's changed to datetime type , And in the attribute on update current_timestamp
If you encounter Tips :A PRIMARY KEY must include all columns in the table's partitioning function
For the above problem, add the partition key to the primary key !!!
View the table creation statement
CREATE TABLE `orders` ( `o_orderkey` int(11) NOT NULL, `O_CUSTKEY` int(11) NOT NULL, `O_ORDERSTATUS` char(1) NOT NULL DEFAULT '', `O_TOTALPRICE` decimal(15,2) NOT NULL, `O_ORDERDATE` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, `O_ORDERPRIORITY` char(15) NOT NULL DEFAULT '', `O_CLERK` char(15) NOT NULL DEFAULT '', `O_SHIPPRIORITY` int(11) NOT NULL, `O_COMMENT` varchar(79) NOT NULL DEFAULT '', PRIMARY KEY (`o_orderkey`,`O_CUSTKEY`), KEY `orders_fk1` (`O_CUSTKEY`), KEY `i_orders_date_clerk` (`O_ORDERDATE`,`O_CLERK`), KEY `i_orders_clerk_date` (`O_CLERK`,`O_ORDERDATE`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 shardkey=o_custkey
You can see shardkey=o_custkey keyword
summary
1、TDSQL You need to specify keywords when creating a sub table shardkey, And the primary key should contain the fragment field .
2、 The production environment can be created in batches by script .
More articles are welcome to follow my official account , search dbachongzi Or scan QR code
author : Yao Chong Oracle OCM、MySQL OCP、Oceanbase OBCA、PingCAP PCTA authentication , Good at based on Oracle、MySQL Performance Turning And a variety of relational NoSQL database .
边栏推荐
- What is the backbone of marketing website construction? What does it do?
- Development status of industrial Internet
- Leetcode problem solving notes for slow ploughing of stupid cattle (dynamic update...)
- What is the industrial Internet? What is the industrial Internet platform?
- What is the relationship between cloud desktop and cloud server? How to understand the relationship between the two
- The cloud University of "digital and real integration, CO building authentic Internet" is surging forward
- Embedded hardware development tutorial -- Xilinx vivado HLS case (3)
- What is a port? The most complete and strongest port number in history, collection!
- What is the domain name trademark? What are the registration conditions for domain names and trademarks?
- How to improve the success rate of trademark registration? How long does it take to register a trademark?
猜你喜欢

Stm32g474 infrared receiving based on irtim peripherals

application. Yaml configuring multiple running environments

Introduction to development model + test model

2020 language and intelligent technology competition was launched, and Baidu provided the largest Chinese data set

Advanced BOM tool intelligent packaging function

If there are enumerations in the entity object, the conversion of enumerations can be carried out with @jsonvalue and @enumvalue annotations

How to fill in and register e-mail, and open mass mailing software for free

163 mailbox login portal display, enterprise mailbox computer version login portal

layer 3 switch

BIM model example
随机推荐
Gin framework: implementing service end flow limiting Middleware
What is the cloud desktop server configuration? What are the application scenarios of cloud desktop?
How to register a trademark? How to improve the passing rate of trademark registration?
Vivo global mall: design and practice of commodity system architecture
2021-11-10:o (1) time inserts, deletes and obtains random elements. Implement ra
How to batch output ean 13 code to pictures
Are cloud game servers expensive to rent? Factors to consider in cloud game server leasing
[Tencent cloud double 12 audio and video communication special session] from 9 yuan for Q4 counter attack artifact, SMS and security (New) package!
Looking at the future development direction of industrial Internet from the transformation of circulation links of large building materials
What are the general contents of the enterprise website construction scheme
Introduction to development model + test model
Super parameter tuning of neural network using keras tuner
Modify the original place where the method needs to be called and triggered
Layout use case
Tencent cloud won the first place in the cloud natural language understanding classification task
Xmlmap port practice - X12 to CSV
Gin framework: adding tracing Middleware
How about Tencent cloud game server? Can the cloud game server play games
Does the cloud game server only provide one player? Cloud game server defense capability
Custom form dynamic form form designer process engine design scheme