Oleg Ovcharenko
Oleg Ovcharenko

Reputation: 537

I always get a value of 255 characters

I have a table in my Postgres DB. In this table, there is a column city this column has type character and length 255.

When I try to add a city in this column, for example, London and after that, I try to get this city I get a value with 255 lengths.

Looks likes [London....................-255] where dots are empty characters

When I add value in db always doing trim.

I use pg for node js

Upvotes: 0

Views: 888

Answers (1)

AKX
AKX

Reputation: 169268

As the comment says, you don't want to use character(255) as the field type, which is always 255 characters, padded with whitespace.

Instead, you might consider using varchar(255), but even so, you probably don't actually want to limit the length here – Postgres doesn't care, storage-wise!, whereas MySQL does – so just use text.

Upvotes: 1

Related Questions