sqlamazon-web-serviceshadoophbaseapache-phoenix

Apache Pheonix add a covered column to index table


I built a pheonix table using the shell command:

CREATE TABLE Student (Id VARCHAR, Grade VARCHAR, Name VARCHAR, College VARCHAR, Age VARCHAR, CONSTRAINT PK_CONSTRAINT PRIMARY KEY(Id));

I built an index table over the field Age:

CREATE INDEX StudentIndex ON Student (Age) INCLUDE(Id, Grade, Name);

Now I want to cover the College field of Student table as well in the StudentIndex table. Is there any Alter command that can help me add this column to covered fields in the index. Can anyone help me on this.


Solution

  • You cannot alter an index. Since you need to rebuild index, just drop the previous one and create a new index:

    DROP INDEX StudentIndex ON Student 
    CREATE INDEX StudentIndex ON Student (Age) INCLUDE(Id, Grade, Name, College);