Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to declare an array data type column? SQL

CREATE TABLE user (
...
columnName int ARRAY[7][7] DEFAULT null,
...
)

I have to create a table where one of the columns has to store a 7x7 array, but i can't figure it out!

Is it even possible in SQL?

-- UPDATE So, I've decided I am going to cheat it and store it as a TEXT and then with code I'll work with that string

like image 748
Laura C. Cencerrado Avatar asked Sep 28 '22 17:09

Laura C. Cencerrado


1 Answers

SQL 2003 (and to a lesser extent SQL 99) provide array types, see for instance here: http://farrago.sourceforge.net/design/CollectionTypes.html I've used them extensively with PostgreSQL to simplify my designs. For clients that don't support array semantics yet, it's possible to provide views which "unnest" the arrays.

like image 120
Isac Casapu Avatar answered Sep 30 '22 13:09

Isac Casapu