patternsqlMinor
Renaming a column in a materialized view with an unknown name
Viewed 0 times
columnwithunknownmaterializedviewrenamingname
Problem
I have a materialized view with an unknown column name, and I need to give that column a name. I can't just recreate the view because it took a long time to create.
That
dba=# \d temp_name_relationships;
Materialized view "temp_name_relationships"
Column | Type | Modifiers
----------+------------------+-----------
id | bigint |
source | integer |
name1 | text |
name2 | text |
?column? | double precision |
sum | bigint |That
?column? in there is the offender. How do I rename it? I've tried:ALTER MATERIALIZED VIEW temp_name_relationships RENAME COLUMN ?column? TO score;
ERROR: syntax error at or near "?"Solution
I just remembered you can quote table names, and I guess this works to escape the question marks.
ALTER MATERIALIZED VIEW temp_name_relationships RENAME COLUMN "?column?" TO score;Code Snippets
ALTER MATERIALIZED VIEW temp_name_relationships RENAME COLUMN "?column?" TO score;Context
StackExchange Database Administrators Q#141875, answer score: 2
Revisions (0)
No revisions yet.