Sql – How toNSERT data into a specific column without NULLs in the other columns

insertpostgresqlsql

I have a table ("table1") with 3 columns called col1, col2 and col3 (each is VARCHAR) with 4 values as shown below:

col1   col2   col3
datA1  datB1  datC1
datA2  

I need an ability to add a data at any time into any column NOT affecting on the other ones. The very popular code in the Internet is that (say, we need to add data only to the columns col2 and col3):

INSERT INTO table1 (col2, col3)
VALUES ('datB2', 'datC2');

But it adds new rows, like below:

col1   col2   col3
datA1  datB1  datC1
datA2
NULL   datB2  datC2

What I really need is to fill the row starting with value "datA2" at the column "col1" with new values and get the table like below:

col1   col2   col3
datA1  datB1  datC1
datA2  datB2  datC2

The table has 3 columns and each column responses for a particular type of values (say: name, colour, size). What I need is just a possibility to add new values at any time in a particular column and have them without Null and new rows if it has a free cell before.

Best Solution

UPDATE table1
SET col2 = dataB2, col3 = dataC2
WHERE col1 = dataA2;

This may serve your purpose.