What is the best way to add an element to an array when the size of the array is not provided?
有了array_append
,这就是我能想到的:
UPDATE table SET array = array_append((SELECT array FROM table WHERE ...), 'element') WHERE ...;
有了array_length
,这就是我能想到的:
UPDATE table SET array[array_length((SELECT array FROM table WHERE ...), 1)+1] = element;