1

Is there any way to create a column of data type 'array' in mysql table ? like this below :

create table tb_name (
-> column_name INT ARRAY[1000] NOT NULL);
1

1 Answer 1

0

There is no data type to store an array in MySQL. but you can convert your array to JSON and store it in the table and convert it back to an array when you need it.
Also, you can create a multiple tables to store your array of data.

Your main table,

CREATE TABLE tb_name (
`id` INT NOT NULL PRIMARY KEY,
`column_name` VARCHAR(100),
`column_name` VARCHAR(100)
);

Your array data table

CREATE TABLE array_data (
`id` INT NOT NULL PRIMARY KEY,
`pf_tb_table` INT NOT NULL, 
`array_index` INT,
`array_data` VARCHAR(100),
FOREIGN KEY (pf_tb_table) REFERENCES tb_name (id),
);

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.