Subject: Re: Cannot drop column

From: Viral Shah <[email-masked]>
Date: Wed, 18 Dec 2024 13:51:41 -0500

Since your column name has an Upper case character, you will have to use
double quotes to drop it. Try alter table statustypes drop column "Suspect";

Thanks,
Viral

On Wed, Dec 18, 2024 at 1:47 PM Rich Shepard <[email-masked]>
wrote:

> I'm not seeing why postgres won't drop a table's column:
>
> bustrac=# select * from statustypes order by stat_name;
>       stat_name
> --------------------
>   Client
>   Lead
>   No further contact
>   Opportunity
>   Proposal submitted
>   Prospect
>   Qualified
>   Referral
>   Suspect
> (9 rows)
>
> bustrac=# alter table statustypes drop column Suspect;
> ERROR:  column "suspect" of relation "statustypes" does not exist
> bustrac=#
>
> What have I done incorrectly?
>
> TIA,
>
> Rich
>
>
>

---

From: Rich Shepard <[email-masked]>
Date: Wed, 18 Dec 2024 11:04:26 -0800 (PST)

> double quotes to drop it. Try alter table statustypes drop column "Suspect";

Viral,

Huh! I've not before encountered this in the 30+ years I've used postgres.

Thanks for the lesson.

Regards,

Rich

---

From: Rich Shepard <[email-masked]>
Date: Wed, 18 Dec 2024 11:09:05 -0800 (PST)

> Thanks for the lesson.

But,

bustrac=# alter table statustypes drop column "Suspect"; 
ERROR:  column "Suspect" of relation "statustypes" does not exist
bustrac=#

Double quoting didn't resolve the issue.

Rich

---

From: "David G. Johnston" <[email-masked]>
Date: Wed, 18 Dec 2024 12:09:46 -0700

On Wednesday, December 18, 2024, Rich Shepard <[email-masked]>
wrote:

> bustrac=# alter table statustypes drop column "Suspect"; ERROR:  column
> "Suspect" of relation "statustypes" does not exist
> bustrac=#
>

Red Ron’s email…

David J.

---

From: Adrian Klaver <[email-masked]>
Date: Wed, 18 Dec 2024 13:34:07 -0800

> Huh! I've not before encountered this in the 30+ years I've used postgres.

It has been that way for a long time:

https://www.postgresql.org/docs/7.0/syntax525.htm

Your issue though is as Ron pointed out:

alter table statustypes drop column Suspect

That is trying to drop a column named "Suspect" when in fact the column 
name is stat_name. 'Suspect' is a value in the column.

-- 
Adrian Klaver
[email-masked]