How to limit the maximum display length of a column in PostgreSQL

后端 未结 2 1835
北恋
北恋 2021-02-20 07:31

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

Something lik

2条回答
  •  春和景丽
    2021-02-20 08:36

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

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

提交回复
热议问题