0

Is it possible to add array data type to the postgreSQL database?

Like this :

   ALTER TABLE table_name
ADD COLUMN new_column_name ARRAY;

2 Answers 2

3

You will need to define the type of the array, e.g. if you want an array of integers, use int[]

ALTER TABLE table_name
  ADD COLUMN new_column_name int[];

(or use the ARRAY keyword as shown in Sebastian's answer)

For more details, see the manual

Sign up to request clarification or add additional context in comments.

Comments

3

You can use ARRAY on any built-in or user-defined base type, enum type, or composite type like this:

ALTER TABLE table_name ADD COLUMN new_column_name INTEGER ARRAY;

demo on dbfiddle.uk

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.