Re: Column name beginning with underscore ("_")?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Jim Rosenberg <jr(at)amanue(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Column name beginning with underscore ("_")?
Date: 2024-11-04 20:33:42
Message-ID: e70653cd-0bb2-4861-8664-7fc8243846b7@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/4/24 12:02, Jim Rosenberg wrote:
> Is it considered bad Postgresql practice to have a column name that begins
> with the underscore character ("_")?
>
> I'm not sure where this is documented, but I'm seeing that Postgresql
> accepts prepending an underscore to a data type name as a kind of alias for
> appending [] to define an array data type. So even though Postgresql
> doesn't seem to have this problem, a human reader might confuse a column
> name beginning with _ as an array data type reference.
>
> Here is why I want to have some column names beginning with "_". I'm
> designing a database to shadow a public agency's data. I need some columns
> that reflect *my* shadow copy of the data, (like say download date) that
> don't have any semantic import with respect to the original data.
> Beginning such columns with "_" is a simple way to keep the column names
> uncluttered but indicate to the reader that the column applies to *my
> copy* but are not columns in the original data.

To reduce confusion something like?:

my_* or l(ocal)_*

>
> Comments?
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter J. Holzer 2024-11-04 20:45:54 Re: Used memory calculation in containers - docker stats and file cache
Previous Message Tom Lane 2024-11-04 20:10:53 Re: Column name beginning with underscore ("_")?