Rename Table Column From Upper Case to Lower case?

Moderator: NorbertKrupa

Post Reply
Brett
Beginner
Beginner
Posts: 49
Joined: Fri Oct 11, 2013 1:19 am

Rename Table Column From Upper Case to Lower case?

Post by Brett » Tue Dec 10, 2013 5:57 pm

Is there a way to rename a column in a table that has uppercase characters to lower case?

I tried to do it like in the following example, but I get an error saying the column already exists:

Code: Select all

dbadmin=> create table t (Capital_Letter int);
CREATE TABLE
dbadmin=> \d t;
                                     List of Fields by Tables
  Schema  | Table |     Column     | Type | Size | Default | Not Null | Primary Key | Foreign Key
----------+-------+----------------+------+------+---------+----------+-------------+-------------
 testdb01 | t     | Capital_Letter | int  |    8 |         | f        | f           |
(1 row)

dbadmin=> alter table t rename column Capital_Letter to capital_letter;
ROLLBACK 2662:  Column name "capital_letter" already exists

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Rename Table Column From Upper Case to Lower case?

Post by JimKnicely » Tue Dec 10, 2013 6:04 pm

I think you may have to do that in a two step process...

Code: Select all

dbadmin=> create table t (Capital_Letter int);
CREATE TABLE
dbadmin=> \d t;
                                     List of Fields by Tables
  Schema  | Table |     Column     | Type | Size | Default | Not Null | Primary Key | Foreign Key
----------+-------+----------------+------+------+---------+----------+-------------+-------------
 joshua01 | t     | Capital_Letter | int  |    8 |         | f        | f           |
(1 row)

dbadmin=> alter table t rename column capital_letter to capital_letter1;
ALTER COLUMN
dbadmin=> alter table t rename column capital_letter1 to capital_letter;
ALTER COLUMN
dbadmin=> \d t;
                                     List of Fields by Tables
  Schema  | Table |     Column     | Type | Size | Default | Not Null | Primary Key | Foreign Key
----------+-------+----------------+------+------+---------+----------+-------------+-------------
 joshua01 | t     | capital_letter | int  |    8 |         | f        | f           |
(1 row)
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “New to Vertica Database Administration”