Introducing DDLs that Cannot Be Synchronized
- After a database synchronization task, only tables and data can be synchronized. Operations for databases, tablespaces, indexes, foreign keys, functions, stored procedures, triggers, views, partitions (DELETE operations), primary keys (INSERT/DELETE/ALTER operations), transactions, users, roles, and permissions, events cannot be synchronized.
Index- and partitioned table- related operations in Table 1 and Table 2 cannot be synchronized, but they do not affect data query and analysis on HTAP instance
- Table creation statements cannot contain CHECK or table options.
- During data synchronization, operations in Table 3 may cause data inconsistency between the HTAP and GaussDB(for MySQL) instances. You are not advised to use these operations.
DDL Name |
SQL Example |
---|---|
Adding an index |
ALTER TABLE tbl_name ADD INDEX name; |
Renaming an index |
ALTER TABLE tbl_name RENAME INDEX old_index_name TO new_index_name; |
Deleting an index |
DROP INDEX name ON table; |
Adding a full-text index |
CREATE FULLTEXT INDEX name ON table(column); |
Adding a spatial index |
ALTER TABLE geom ADD SPATIAL INDEX(g); |
Modifying the type of an index |
ALTER TABLE tbl_name DROP INDEX i1, ADD INDEX i1(key_part,...) USING BTREE; |
Adding an index constraint |
ALTER TABLE tbl_name ADD CONSTRAINT UNIQUE USING BTREE (column); ALTER TABLE tbl_name ADD CONSTRAINT UNIQUE USING HASH(column); |
DDL Name |
SQL Example |
---|---|
Analyzing a table partition |
ALTER TABLE {db}.tp ANALYZE PARTITION p0; |
Checking a table partition |
ALTER TABLE {db}.tp CHECK PARTITION p0; |
Optimizing table partitions |
ALTER TABLE {db}.tp OPTIMIZE PARTITION p0; |
Re-building a table partition |
ALTER TABLE {db}.tp REBUILD PARTITION p0; |
Repairing a table partition |
ALTER TABLE {db}.tp REPAIR PARTITION p0; |
Creating a database |
CREATE DATABASE ddl_test_2; |
Modify the row format |
ALTER TABLE tbl_name ROW_FORMAT = row_format; |
Setting persistent table statistics |
ALTER TABLE tbl_name STATS_PERSISTENT=0, STATS_SAMPLE_PAGES=20,STATS_AUTO_RECALC=1, ALGORITHM=INPLACE, LOCK=NONE; |
Setting table character set |
ALTER TABLE tbl_name CHARACTER SET = charset_name; |
Converting table character set |
ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name; |
Optimizing a table |
OPTIMIZE TABLE tbl_name; |
Rebuilding a table using the FORCE option |
ALTER TABLE tbl_name FORCE; |
Rebuilding a table without data |
ALTER TABLE tbl_name ENGINE=InnoDB; |
Renaming a tablespace |
ALTER TABLESPACE tablespace_name RENAME TO new_tablespace_name; |
Adding a table partition |
ALTER TABLE {db}.tp ADD PARTITION (PARTITION p3 VALUES LESS THAN (2006) ); |
Specifying a sorting rule |
ALTER TABLE tbl_name DEFAULT CHARACTER SET = utf8 COLLATE = utf8_general_ci; |
DDL Name |
SQL Example |
---|---|
Deleting a primary key |
ALTER TABLE tbl_name DROP PRIMARY KEY; |
Adding a primary key |
ALTER TABLE {db}.t1 ADD PRIMARY KEY (id); |
Adding a primary key and deleting a primary key |
ALTER TABLE tbl_name DROP PRIMARY KEY, ADD PRIMARY KEY (column); |
Setting a primary key to NULL |
ALTER TABLE tbl_name MODIFY COLUMN key_column_name data_type; |
Changing the type of a primary key |
ALTER TABLE tbl_name MODIFY COLUMN key_column_name data_type not null; |
Adding a foreign key |
ALTER TABLE tbl1 ADD CONSTRAINT fk_name FOREIGN KEY index (col1)REFERENCES tbl2(col2) referential_actions; |
Deleting a foreign key |
ALTER TABLE tbl DROP FOREIGN KEY fk_name; |
Adding a column
NOTE:
Common columns can be added. If columns contain the following default values, they cannot be added.
|
ALTER TABLE tbl_name ADD COLUMN column_name column_definition c VARCHAR(10) DEFAULT (CONCAT('1', '2')); |
Setting the default value of a column
NOTE:
If columns contain the following default values, you cannot reset default values for the columns.
|
ALTER TABLE tbl_name ALTER COLUMN col SET DEFAULT literal; |
Changing NULL in tables to NOT NULL |
ALTER TABLE tbl_name MODIFY COLUMN column_name data_type NOT NULL; |
Changing the column name and type at the same time |
ALTER TABLE t1 CHANGE b b1 VARCHAR(100); |
Creating a table with a primary key |
ALTER TABLE t1 ADD COLUMN (c2 INT GENERATED ALWAYS AS (c1 + 1)STORED); |
Adding a STORED derived column |
ALTER TABLE {db}.t1 ADD COLUMN (st2 INT GENERATED ALWAYS AS (c2 + 2)STORED), ALGORITHM=COPY; |
Adding a VIRTUAL derived column |
ALTER TABLE t1 ADD COLUMN (c2 INT GENERATED ALWAYS AS (c1 + 1)VIRTUAL); |
Dropping a table partition |
ALTER TABLE {db}.tp DROP PARTITION p4; |
Discarding a table partition |
ALTER TABLE {db}.tp DISCARD PARTITION p2 TABLESPACE; |
Importing a table partition |
ALTER TABLE {db}.tp IMPORT PARTITION p2 TABLESPACE; |
Truncating a table partition |
ALTER TABLE {db}.tp TRUNCATE PARTITION p2; |
Truncating a partitioned table |
TRUNCATE {db}.tp; |
Coalescing table partitions |
ALTER TABLE {db}.tp_hash COALESCE PARTITION 2; |
Reorganizing table partitions |
ALTER TABLE {db}.tp REORGANIZE PARTITION p0,p1,p2,p3 INTO ( ... ); |
Exchanging partitions |
ALTER TABLE {db}.tp EXCHANGE PARTITION p0 WITH TABLE {db}.tp2; |
Removing a table partition |
ALTER TABLE {db}.tp REMOVE PARTITIONING; |
Using a REPLACE clause |
CREATE OR REPLACE TABLE; |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot