数据仓库服务 GAUSSDB(DWS)-ALTER TABLE:表操作示例
表操作示例
重命名表:
1
|
ALTER TABLE CUSTOMER RENAME TO CUSTOMER_t; |
给表增加一个新的约束:
1
|
ALTER TABLE customer_address ADD PRIMARY KEY(ca_address_sk); |
根据已有唯一索引为表增加主键约束或唯一约束。
先给表CUSTOMER创建唯一索引CUSTOMER_constraint1,然后根据已有唯一索引增加主键约束,并对前面创建的索引rename:
1 2 |
CREATE UNIQUE INDEX CUSTOMER_constraint1 ON CUSTOMER(C_CUSTKEY); ALTER TABLE CUSTOMER ADD CONSTRAINT CUSTOMER_constraint2 PRIMARY KEY USING INDEX CUSTOMER_constraint1; |
重命名表约束:
1
|
ALTER TABLE CUSTOMER RENAME CONSTRAINT CUSTOMER_constraint2 TO CUSTOMER_constraint; |
删除表约束:
1
|
ALTER TABLE CUSTOMER DROP CONSTRAINT CUSTOMER_constraint; |
给表增加一个索引:
1
|
ALTER TABLE CUSTOMER ADD INDEX CUSTOMER_index(C_CUSTKEY); |
删除表索引:
1 2 |
ALTER TABLE CUSTOMER DROP INDEX CUSTOMER_index; ALTER TABLE CUSTOMER DROP KEY CUSTOMER_index; |
向在一个列存表中添加局部聚簇列:
1
|
ALTER TABLE customer_address ADD CONSTRAINT customer_address_cluster PARTIAL CLUSTER KEY(ca_address_sk); |
删除一个列存表中的局部聚簇列:
1
|
ALTER TABLE customer_address DROP CONSTRAINT customer_address_cluster; |
切换列存表的存储格式:
1
|
ALTER TABLE customer_address SET (COLVERSION = 1.0); |
修改表的分布方式:
1
|
ALTER TABLE customer_address DISTRIBUTE BY REPLICATION; |
修改表模式:
1
|
ALTER TABLE customer_address SET SCHEMA tpcds; |
单表冷热切换:
1
|
ALTER TABLE cold_hot_table REFRESH STORAGE; |
列存分区表修改为冷热表:
1 2 3 4 5 6 7 |
CREATE table test_1(id int,d_time date) WITH(ORIENTATION=COLUMN) DISTRIBUTE BY HASH (id) PARTITION BY RANGE (d_time) (PARTITION p1 START('2022-01-01') END('2022-01-31') EVERY(interval '1 day')) ALTER TABLE test_1 SET (storage_policy = 'LMT:100'); |
修改表缓存策略(仅云原生3.0版本支持):
ALTER TABLE orders SET (cache_policy = 'NONE');
- GaussDB(DWS)常用SQL_常用SQL命令_SQL语法
- 数据仓库服务GaussDB(DWS)_SQL on Anywhere
- 调用GaussDB(DWS) API接口_数据仓库服务调用API_如何调用API_在DWS中调用API
- DWS安全_数据仓库服务安全_DWS数据安全管理_DWS安全保障_DWS安全策略
- GaussDB主键生成_GaussDB存储过程_高斯数据库主键生成_华为云
- GAUSS(DWS)工具_gsql工具_DataStudio工具_DSC工具
- DWS资源管理_GaussDB(DWS)资源管理作用_DWS资源管控
- DWS产品介绍_DWS产品优势_DWS功能_DWS使用场景_DWS是什么
- GaussDB操作_GaussDB版本_高斯数据库操作
- RDS for MySQL审计日志_开启日志审计_数据库审计_华为云数据库RDS