MySQL Forums
Forum List  »  General

Semantic usage of Insert and Update is wrong
Posted by: Richard Dunne
Date: April 14, 2025 03:56PM

From a semantic standpoint:
Insert should only be used to insert data into any empty or partially empty record(s).
Update should only be use to update (change) existing data.

Taking a 5 column table as an example:

Either
Insert into table (Column1,Column2,Column3) values (value1,value2,value3)

Or
Insert into table values (value1, value2, value3, value4, value5)

In the first example, a partial insert, multiple columns remain unpopulated.
As I stated above, semantically speaking, it makes sense to use insert to populate columns for the first time.

If column1 is Email:
Insert into tableName (column4, column5) values (value4,value5) where column1 = "EmailAddress"

Then
Update table tableName set columnName = "newValue" where Column1 = "EmailAddress"

Semantically correct, but unfortunately, not how SQL was designed or implemented.

Options: ReplyQuote


Subject
Written By
Posted
Semantic usage of Insert and Update is wrong
April 14, 2025 03:56PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.