Thread: Column data type in doc example may be changed to VARCHAR from TEXT

Column data type in doc example may be changed to VARCHAR from TEXT

From
Muhammad Ikram
Date:

Hi,

IMHO, a minor issue in the doc. As a good practice we use TEXT data type when we expect longer text e.g. comments, doc kind of columns.
For columns where we know what can be a maximum Text size though variable, we use VARCHAR to limit accidental long text or for other worthy reasons.

Following example may be revised.
From
CREATE TABLE products (    product_no integer,    name text,    price numeric
);
To
CREATE TABLE products (    product_no integer,    name varchar(expected length),    price numeric
);
Muhammad Ikram,
Bitnine Global.

Re: Column data type in doc example may be changed to VARCHAR from TEXT

From
"David G. Johnston"
Date:
On Wednesday, July 17, 2024, Muhammad Ikram <mmikram@gmail.com> wrote:


IMHO, a minor issue in the doc. As a good practice we use TEXT data type when we expect longer text e.g. comments, doc kind of columns.

Who is we in this conversation?  If it’s the documentation please reference existing work.  Text is our preferred type and we are fairly consistent in using it to my knowledge.

David J.
Thanks David for clarifying. I am coming from an Oracle background, so there we(developers) mostly use CHAR or VARCHAR2 data types for such identifiers instead of CLOB.
Sorry for my naiveness about PostgreSQL doc practices.

Regards,
Muhammad Ikram
Bitnine global.


On Thu, Jul 18, 2024 at 10:17 AM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Wednesday, July 17, 2024, Muhammad Ikram <mmikram@gmail.com> wrote:


IMHO, a minor issue in the doc. As a good practice we use TEXT data type when we expect longer text e.g. comments, doc kind of columns.

Who is we in this conversation?  If it’s the documentation please reference existing work.  Text is our preferred type and we are fairly consistent in using it to my knowledge.

David J.


--
Muhammad Ikram

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wednesday, July 17, 2024, Muhammad Ikram <mmikram@gmail.com> wrote:
>> IMHO, a minor issue in the doc. As a good practice we use TEXT data type
>> when we expect longer text e.g. comments, doc kind of columns.

> Who is we in this conversation?  If it’s the documentation please reference
> existing work.  Text is our preferred type and we are fairly consistent in
> using it to my knowledge.

Even granting the premise, who's to say what an appropriate maximum
length for "products.name" would be?

IMNSHO, both char(N) and varchar(N) are hangovers from punched-card
days.  The number of cases where you can actually specify a limit
that wasn't pulled out of the air can be counted without running out
of fingers.  Moreover, most of those cases can be traced to standards
that were written when punched cards were au courant (postal codes for
example) and hence thought that an arbitrary limit was a good thing.
Time to move on.

            regards, tom lane