tencent cloud

Tencent Cloud TCHouse-D

Product Introduction
Overview
Concepts
Cluster Architecture
Strengths
Scenarios
Purchase Guide
Billing Overview
Renewal Instructions
Overdue Policy
Refund Instructions
Configuration Adjustment Billing Instructions
Getting Started
Using Tencent Cloud TCHouse-D Through the Console
Using Tencent Cloud TCHouse-D Through a Client
Operation Guide
Cluster Operation
Monitoring and Alarm Configuration
Account Privilege Management
Data Management
Query Management
Modify Configurations
Node Management
Log Analysis
SQL Studio
Enabling Resource Isolation
Development Guide
Design of Data Table
Importing Data
Exporting Data
Basic Feature
Query Optimization
Ecological Expansion Feature
API Documentation
History
Introduction
API Category
Making API Requests
Cluster Operation APIs
Database and Table APIs
Cluster Information Viewing APIs
Hot-Cold Data Layering APIs
Database and Operation Audit APIs
User and Permission APIs
Resource Group Management APIs
Data Types
Error Codes
Cloud Ecosystem
Granting CAM Policies to Sub-accounts
Query Acceleration for Tencent Cloud DLC
Practical Tutorial
Basic Feature Usage
Advanced Features Usage
Resource Specification Selection and Optimization Suggestions
Naming Specifications and Limits to the Database and Data Table
Table Design and Data Import
Query Optimization
Suggested Usage to Avoid
Accessing TCHouse-D via JDBC over the Public Network
Performance Testing
TPC-H Performance Testing
SSB Performance Testing
TPC-DS Performance Testing
FAQs
Common Operational Issues
Common Errors
Contact Us
Glossary
Product Policy
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement

Two Tables of Atomic Swap (Swap)

PDF
フォーカスモード
フォントサイズ
最終更新日: 2024-06-27 11:08:50
From version 0.14, Doris supports atomic replacement operations between two tables. This operation is only suitable for OLAP tables. For partition-level replacement operations, refer to Temporary Partition.

Syntax Description

ALTER TABLE [db.]tbl1 REPLACE WITH TABLE tbl2
[PROPERTIES('swap' = 'true')];
Replace table tbl1 with table tbl2.
If the swap parameter is true, after replacement, the data in the tbl1 table is the original data in the tbl2 table. The data in the tbl2 table is the original data in the tbl1 table. The data of the two tables is swapped.
If the swap parameter is false, after replacement, the data in the tbl1 table is the original data in the tbl2 table. The tbl2 table is deleted.

Principles

The table replacement feature, in fact, is to aggregate the following operations into one atomic operation. Assuming table A is to be replaced with table B, and swap is true, the operations are as follows:
1. Rename table B to table A.
2. Rename table A to table B.
If swap is false, the operations are as follows:
1. Delete table A.
2. Rename table B to table A.

Notes

1. The swap parameter defaults to true. Replacing a table is equivalent to swapping the data of the two tables.
2. If the swap parameter is false, the replaced table (Table A) will be deleted and cannot be recovered.
3. The replacement operation can only occur between two OLAP tables, and it does not check whether the table structures of the two tables are the same.
4. The replacement operation does not change the original permission settings. Because permission checks are table name-based.

Best Practice

1. Atomic overwrite operation. In some cases, users may want to overwrite the data of a table. However, if deleting first and then importing is adopted, there will be a period of time when the data cannot be viewed. At this time, users can first use the CREATE TABLE LIKE statement to create a new table with the same structure, import the new data into the new table, and then replace the old table atomically through the replace operation to achieve the goal. For atomic overwrite operations at the partition level, refer to Temporary Partition.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック