According to https://dba.stackexchange.com/a/307373/156984, both text[] and text[][] have the same internal type _text. If the internal type of both is the same, how can I then actually differentiate them?

SELECT * FROM pg_type; just returns one row, representing both types. I would expect it to return two, one for text[] and one for text[][].

EDIT: The reason I need this information is that i kind of want to reverse engineer text[] or text[][] from _text to then send the type information as a String to a client.

  • array_dims ( anyarray ) → text
    – Akina
    Mar 29 at 10:26
  • For this to work I need to have an instance of a specific array, however I don't have this at the time. Mar 29 at 10:33

1 Answer 1


According to Postgres array documentation, Postgres does not differentiate between one- and multidimensional arrays in its type.

The current implementation does not enforce the declared number of dimensions either. Arrays of a particular element type are all considered to be of the same type, regardless of size or number of dimensions. So, declaring the array size or number of dimensions in CREATE TABLE is simply documentation; it does not affect run-time behavior.

For example, both int[] and int[][] have the same type _int.

It is possible to get the dimensions of an array from pg_attribute.attndims.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.