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

Started by Muhammad Ikramover 1 year ago4 messagesdocs
Jump to latest
#1Muhammad Ikram
mmikram@gmail.com

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.

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Muhammad Ikram (#1)
Re: Column data type in doc example may be changed to VARCHAR from TEXT

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.

#3Muhammad Ikram
mmikram@gmail.com
In reply to: David G. Johnston (#2)
Re: Column data type in doc example may be changed to VARCHAR from TEXT

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

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: David G. Johnston (#2)
Re: Column data type in doc example may be changed to VARCHAR from TEXT

"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