为什么我无法在 Vertica 中删除列
Why am I not able to drop a column in Vertica
我在 vertica
中创建了一个 table
select * from my_faithful_test;
id | eruptions
----+-----------
1 | 3.4
我想删除 eruptions
列但是当我 运行 这个命令时,我得到错误
alter table my_faithful_test drop eruptions cascade;
ROLLBACK 4122: No up-to-date super projection left on the anchor table of projection my_faithful_test_super
HINT: Use DROP TABLE ... CASCADE to drop the anchor table and its last projection, or create a replacement super projection instead
我不想放弃整个 table。删除列或重命名列的方法是什么?
如果您不注意 table 的第一个超级投影的创建方式,Vertica 将对 ORDER BY
和 SEGMENTED BY HASH()
使用前 8 列。
看这里:
CREATE TABLE my_faithful_test(id,eruptions) AS
SELECT 1, 3.2
UNION ALL SELECT 2, 4.3
;
-- out CREATE TABLE
-- out Time: First fetch (0 rows): 40.831 ms. All rows formatted: 41.480 ms
SELECT EXPORT_OBJECTS('','my_faithful_test',FALSE);
-- out EXPORT_OBJECTS
-- out ---------------
-- out
-- out CREATE TABLE dbadmin.my_faithful_test
-- out (
-- out id int,
-- out eruptions numeric(2,1)
-- out );
-- out
-- out
-- out CREATE PROJECTION dbadmin.my_faithful_test_super /*+basename(my_faithful_test),createtype(A)*/
-- out (
-- out id,
-- out eruptions
-- out )
-- out AS
-- out SELECT my_faithful_test.id,
-- out my_faithful_test.eruptions
-- out FROM dbadmin.my_faithful_test
-- out ORDER BY my_faithful_test.id,
-- out my_faithful_test.eruptions
-- out SEGMENTED BY hash(my_faithful_test.id, my_faithful_test.eruptions) ALL NODES OFFSET 0;
如果你真的想保留 table,你有这些选择:
- 重命名要删除的列,将其停放
- 创建一个没有用于排序或分段的违规列的新超级投影;刷新 table;
SELECT MAKE_AHM_NOW()
为了安全起见,删除任何剩余的删除向量 ROS 容器;删除有问题的超级投影(有问题的列处于“重要”角色;最后,删除不需要的列。
这是我的做法:
ALTER PROJECTION dbadmin.my_faithful_test_super
RENAME TO my_faithful_test_dropme;
-- out ALTER PROJECTION
CREATE PROJECTION dbadmin.my_faithful_test_super
AS SELECT * FROM dbadmin.my_faithful_test
ORDER BY id UNSEGMENTED ALL NODES;
-- out WARNING 4468: Projection <dbadmin.my_faithful_test_super> is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
-- out The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh
-- out CREATE PROJECTION
SELECT REFRESH('dbadmin.my_faithful_test');
-- out REFRESH
-- out --------
-- out Refresh completed with the following outcomes:
-- out Projection Name: [Anchor Table] [Status] [Refresh Method] [Error Count] [Duration (sec)]
-- out ----------------------------------------------------------------------------------------
-- out "dbadmin"."my_faithful_test_super": [my_faithful_test] [refreshed] [scratch] [0] [0]
SELECT MAKE_AHM_NOW();
-- out MAKE_AHM_NOW
-- out --------------------------------
-- out AHM set (New AHM Epoch: 37482)
DROP PROJECTION dbadmin.my_faithful_test_dropme;
-- out DROP PROJECTION
ALTER TABLE my_faithful_test DROP COLUMN eruptions;
-- out ALTER TABLE
我在 vertica
select * from my_faithful_test;
id | eruptions
----+-----------
1 | 3.4
我想删除 eruptions
列但是当我 运行 这个命令时,我得到错误
alter table my_faithful_test drop eruptions cascade;
ROLLBACK 4122: No up-to-date super projection left on the anchor table of projection my_faithful_test_super
HINT: Use DROP TABLE ... CASCADE to drop the anchor table and its last projection, or create a replacement super projection instead
我不想放弃整个 table。删除列或重命名列的方法是什么?
如果您不注意 table 的第一个超级投影的创建方式,Vertica 将对 ORDER BY
和 SEGMENTED BY HASH()
使用前 8 列。
看这里:
CREATE TABLE my_faithful_test(id,eruptions) AS
SELECT 1, 3.2
UNION ALL SELECT 2, 4.3
;
-- out CREATE TABLE
-- out Time: First fetch (0 rows): 40.831 ms. All rows formatted: 41.480 ms
SELECT EXPORT_OBJECTS('','my_faithful_test',FALSE);
-- out EXPORT_OBJECTS
-- out ---------------
-- out
-- out CREATE TABLE dbadmin.my_faithful_test
-- out (
-- out id int,
-- out eruptions numeric(2,1)
-- out );
-- out
-- out
-- out CREATE PROJECTION dbadmin.my_faithful_test_super /*+basename(my_faithful_test),createtype(A)*/
-- out (
-- out id,
-- out eruptions
-- out )
-- out AS
-- out SELECT my_faithful_test.id,
-- out my_faithful_test.eruptions
-- out FROM dbadmin.my_faithful_test
-- out ORDER BY my_faithful_test.id,
-- out my_faithful_test.eruptions
-- out SEGMENTED BY hash(my_faithful_test.id, my_faithful_test.eruptions) ALL NODES OFFSET 0;
如果你真的想保留 table,你有这些选择:
- 重命名要删除的列,将其停放
- 创建一个没有用于排序或分段的违规列的新超级投影;刷新 table;
SELECT MAKE_AHM_NOW()
为了安全起见,删除任何剩余的删除向量 ROS 容器;删除有问题的超级投影(有问题的列处于“重要”角色;最后,删除不需要的列。
这是我的做法:
ALTER PROJECTION dbadmin.my_faithful_test_super
RENAME TO my_faithful_test_dropme;
-- out ALTER PROJECTION
CREATE PROJECTION dbadmin.my_faithful_test_super
AS SELECT * FROM dbadmin.my_faithful_test
ORDER BY id UNSEGMENTED ALL NODES;
-- out WARNING 4468: Projection <dbadmin.my_faithful_test_super> is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
-- out The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh
-- out CREATE PROJECTION
SELECT REFRESH('dbadmin.my_faithful_test');
-- out REFRESH
-- out --------
-- out Refresh completed with the following outcomes:
-- out Projection Name: [Anchor Table] [Status] [Refresh Method] [Error Count] [Duration (sec)]
-- out ----------------------------------------------------------------------------------------
-- out "dbadmin"."my_faithful_test_super": [my_faithful_test] [refreshed] [scratch] [0] [0]
SELECT MAKE_AHM_NOW();
-- out MAKE_AHM_NOW
-- out --------------------------------
-- out AHM set (New AHM Epoch: 37482)
DROP PROJECTION dbadmin.my_faithful_test_dropme;
-- out DROP PROJECTION
ALTER TABLE my_faithful_test DROP COLUMN eruptions;
-- out ALTER TABLE