You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: partitioned-table.md
+40Lines changed: 40 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1131,6 +1131,46 @@ ALTER TABLE example TRUNCATE PARTITION p0;
1131
1131
Query OK, 0 rows affected (0.03 sec)
1132
1132
```
1133
1133
1134
+
### Convert a partitioned table to a non-partitioned table
1135
+
1136
+
To convert a partitioned table to a non-partitioned table, you can use the following statement, which removes the partitioning, copies all rows of the table, and recreates the indexes online for the table:
1137
+
1138
+
```sql
1139
+
ALTERTABLE<table_name> REMOVE PARTITIONING
1140
+
```
1141
+
1142
+
For example, to convert the `members` partitioned table to the non-partitioned table, you can execute the following statement:
1143
+
1144
+
```sql
1145
+
ALTERTABLE members REMOVE PARTITIONING
1146
+
```
1147
+
1148
+
### Partition an existing table
1149
+
1150
+
To partition an existing non-partitioned table or modify the partition type of an existing partitioned table, you can use the following statement, which copies all rows and recreates the indexes online according to the new partition definitions:
1151
+
1152
+
```sql
1153
+
ALTERTABLE<table_name> PARTITION BY <new partition type and definitions>
1154
+
```
1155
+
1156
+
Examples:
1157
+
1158
+
To convert the existing `members` table to a HASH partitioned table with 10 partitions, you can execute the following statement:
1159
+
1160
+
```sql
1161
+
ALTERTABLE members PARTITION BY HASH(id) PARTITIONS 10;
1162
+
```
1163
+
1164
+
To convert the existing `member_level` table to a RANGE partitioned table, you can execute the following statement:
1165
+
1166
+
```sql
1167
+
ALTERTABLE member_level PARTITION BY RANGE(level)
1168
+
(PARTITION pLow VALUES LESS THAN (1),
1169
+
PARTITION pMid VALUES LESS THAN (3),
1170
+
PARTITION pHigh VALUES LESS THAN (7)
1171
+
PARTITION pMax VALUES LESS THAN (MAXVALUE));
1172
+
```
1173
+
1134
1174
## Partition pruning
1135
1175
1136
1176
[Partition pruning](/partition-pruning.md) is an optimization which is based on a very simple idea - do not scan the partitions that do not match.
0 commit comments