Alex Rivera | Logout

How to find the size of an array in postgresql

Asked 2012-06-25T11:45:23.723
191

Is there any way to find a size of an array?

For Example,

CREATE TABLE example (id integer[]) ;

INSERT INTO example VALUES ( '{}');

INSERT INTO example VALUES ( '{5,6,7}');

From this, is there any possibilities to get a result like following,

size
---
0
3
Edit
Report

1 Answer

125

It's trivial reading docs:

SELECT array_length(id, 1) FROM example;
answered 2012-06-25T12:15:33.403

Your Answer