If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Multi-dimensional columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Nov 2012
Posts: 3
Multi-dimensional columns

Hi guys

I'm a little confused about creating multi-dimensional columns.

Is the two CREATE TABLE statements below the same?

CREATE TABLE t_test ( id BIGSERIAL, sa1 text[]);

CREATE TABLE t_test ( id BIGSERIAL, sa1 text[][]);

sa1 is declared one-dimensional in the first and two-diamensional in the second.

BUT taking a pg_dump of the two-dimensional sa1 is ONLY showing up as one-dimensional?

Using pgAdmin also shows the two-dimensional sa1 as one-dimensional.

Only EMS SQL Manager is showing sa1 as a two-dimensional.

My question is: is there no need to declare an array as multidimensional? can you just use a single-dimensional array as a multi-dimensional?


Kind regards, Ole
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Posts: 2,807
I think this is by design:
Quote:
Originally Posted by The fine manual
The current implementation does not enforce the declared number of dimensions either. [...] So, declaring the array size or number of dimensions in CREATE TABLE is simply documentation; it does not affect run-time behavior.
From: http://www.postgresql.org/docs/curre...ic/arrays.html
__________________
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

Tips for good questions:

http://tkyte.blogspot.de/2005/06/how...questions.html
http://wiki.postgresql.org/wiki/SlowQueryQuestions
http://catb.org/esr/faqs/smart-questions.html
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Nov 2012
Posts: 3
Quote:
Originally Posted by shammat View Post
I think this is by design:
From: PostgreSQL: Documentation: 9.2: Arrays
Thanks shammat

Your right and shame on me.. I was browsing through this doc but obviously too fast.

The funny thing is that EMS Manager somehow is able to save information about multidimensional arrays. But browsing information_schema.element_columns and information_schema.element_types does not reveal any information on multidimensional.

Anyway, thanks again for showing me the light. Ole
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Posts: 2,807
Quote:
Originally Posted by tetzschner View Post
The funny thing is that EMS Manager somehow is able to save information about multidimensional arrays. But browsing information_schema.element_columns and information_schema.element_types does not reveal any information on multidimensional.
That's interesting indeed. psql also only shows integer[]. The JDBC driver simply returns _int4 for those kind of columns.
I guess EMS Manager gets it from pg_attribute.attndims
__________________
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

Tips for good questions:

http://tkyte.blogspot.de/2005/06/how...questions.html
http://wiki.postgresql.org/wiki/SlowQueryQuestions
http://catb.org/esr/faqs/smart-questions.html

Last edited by shammat; 11-08-12 at 04:16.
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Nov 2012
Posts: 3
Quote:
Originally Posted by shammat View Post
That's interesting indeed. psql also only shows integer[]. The JDBC driver simply returns _int4 for those kind of columns.
I guess EMS Manager gets it from pg_attribute.attndims
Shammat you are sharp as a razorblade. It is in pg_attribute.attndims this information is stored.

I'm not familiar with JDBC (using dotConnect from Devart and Npgsql) but looking in information_schema.columns, data_type=ARRAY and udt_name=_int4, so maybe JDBC is taking the information from udt_name.

Anyway you can get the correct information from information_schema.element_types.

PostgreSQL: Documentation: 9.2: element_types

Kind regards, Ole
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On