What is the difference between INSERT and UPDATE statements in PHP when interacting with a PostgreSQL database?

When interacting with a PostgreSQL database in PHP, the main difference between INSERT and UPDATE statements is that INSERT is used to add new records to a table, while UPDATE is used to modify existing records in a table. To insert data into a table, you use the INSERT statement followed by the table name and values to be inserted. To update data in a table, you use the UPDATE statement followed by the table name, SET keyword, and the column values to be updated, along with a WHERE clause to specify which records to update.

// INSERT statement example
$sql = "INSERT INTO table_name (column1, column2) VALUES ('value1', 'value2')";
$result = pg_query($conn, $sql);

// UPDATE statement example
$sql = "UPDATE table_name SET column1 = 'new_value' WHERE condition";
$result = pg_query($conn, $sql);