En/na [EMAIL PROTECTED] ha escrit:: > Is it possible to store a list of integers inside a table column? I > want to create a table as follows: > > col x col y col z > ================== > xxxx yyyy [z,z,z] > xxxx yyyy [z,z,z,z,z,z,z] > xxxx yyyy [z,] > > As you can see each row has a col z which i s a list of values. > I tried to pickle my python list and store it in a column where type is > CharType. This works fine but I have to specify the length of the > column. This means that I have to "guess" the maximum length of the > pickled data. > > Is there a better way to store a list of intergers inside a column?
Until we find the time (and/or funding) to implement variable width tables, there is no trivial way to do what you suggest. You can look for alternatives, though. The pickling one has the added problem of being inefficient. Two alternatives come to my mind. First, you can take column *z* out into a separate VLArray object, where element *i* corresponds to element *i* in the table. VLArrays are specially devised for data shaped in this way, but you'd have to manually keep the table and the array consistent. Second, you could define *z* as a sufficiently oversized one-dimensional field, and use an extra field (say *zlen*) to store the actual length of the stored data, like this: col x col y col z col zlen ===== ===== ============= ======== xxxx yyyy [1,2,0,...,0] 2 xxxx yyyy [1,0,0,...,0] 1 xxxx yyyy [1,2,3,...,0] 3 Of course, some (maybe a lot of) space is wasted, but consistency is easily handled. Using compression on this table may save you some space. Just try it and see which solution fits your particular case. Hope that helps, :: Ivan Vilata i Balaguer >qo< http://www.carabos.com/ Cárabos Coop. V. V V Enjoy Data ""
signature.asc
Description: OpenPGP digital signature