Is there any array data type in MySQL like in PostgreSQL?

14,476

Solution 1

No, there is no such thing. There is an open worklog for that, but no progress has been made on implementing this feature.

You have to emulate this somehow, using either multiple fields (9 in your case) or pack the integers together into a larger datatype (blob for example).

Solution 2

Store them in a text format using proper delimiters. ex:- If you want to store numbers from 1 to 9, store them in text format as 1-2-3-4-5-6-7-8-9 where '-' is a delimiter. Explode the string and get the desired numbers.

Solution 3

No there is not. Short answer but without knowing what you have do that is the answer.

Share:
14,476

Related videos on Youtube

Francisco R
Author by

Francisco R

Freelance PHP, Wordpress, Gravity Forms developer.

Updated on June 04, 2020

Comments

  • Francisco R
    Francisco R almost 4 years

    I need to store arrays of integers in a MySQL database. In there something equivalent to this in MySQL?

     CREATE TABLE tictactoe (
        squares   integer[3][3]
    );
    

    I want to store matrices with dimension 20x6. I don't feel like creating a table with 120 columns. There is no need to query on this field, just need to store and retrieve full matrices.

    If it matters, i use Perl.

  • chantheman
    chantheman about 13 years
    Unfortunately you will just need to handle it on your application side. There are some tricks out there but it is best to just adapt your application.
  • Francisco R
    Francisco R about 13 years
    Thanks! Pack the data into blob seems to be a valid workaround for my needs.
  • wobbily_col
    wobbily_col about 9 years
    Would a delimited string not be easier to parse than a blob?

Related