Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have two columns, material_size (text type) and material_size_temp (text[] array type).

When I ran UPDATE parts SET material_size_temp[0] = material_size; I would get values like [0:0]={".021 x 2.450"} instead of {".021 x 2.450"}.

How do I clone the text type column to text[] array type column?

share|improve this question
    
Do you want to replace the existing value in material_size_temp (the whole array) or just the first element? Or do you want to prepend the array with the text from material_size? –  Erwin Brandstetter Mar 17 at 0:03
    
@ErwinBrandstetter Most rows have data (just a single measurement) and some no data. I was just trying to move the data in to an array. Now that I've gotten that far (I still have the original column) I'm stuck on the following SO question: stackoverflow.com/questions/29086673/… –  John Mar 17 at 14:47

1 Answer 1

up vote 0 down vote accepted

I was close, unlike JavaScript and PHP it seems PostgreSQL array key numbers start with 1, not 0.

UPDATE parts SET material_size_temp[1] = material_size;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.