I have a an sql Postgres table with a composite ID and I want to fill wide range of value on this table, if the data aren't already exist. I have a table
CREATE TABLE MyTable ( idCol1 VARCHAR(256) NOT NULL, idCol2 VARCHAR(256) NOT NULL, idCol3 VARCHAR(256) NOT NULL, amount VARCHAR(256) NOT NULL, ) And for all the value of idCol1 in ['A','B','C'], idCol2 in ['D','E','F'], idCol3 in ['G','H','I'] I want to set an amount value, if the row don't already exist.
The issue is the idCol1, idCol2 and idCol3 aren't foreing key and their value is not in any table. I have to fill those directly into the sql query.
I have trouble to write a request who simultaneously insert data, do a join on 3 differentes array of data and don't erase existing data.
How can I do-it?
varchar(256)offers no performance or storage advantages over e.g.varchar(321)orvarchar(258)['A','B','C'](including the square brackets) in those columns?