How to limit the maximum column display length in PostgreSQL

I use PostgreSQL, and I have a column in the table that contains very long text. I want to select this column in the query, but limit its display length.

Sort of:

select longcolumn (only 10 chars) from mytable; 

How can I do it?

+6
source share
1 answer

What you can do is use the PostgreSQL substring () method. One of the two commands below will work:

 SELECT substring(longcolumn for 10) FROM mytable; SELECT substring(longcolumn from 1 for 10) FROM mytable; 
+12
source

Source: https://habr.com/ru/post/944636/


All Articles