Google News
logo
PostgreSQL - Interview Questions
How Do You Change Data in a PostgreSQL Database?
Thankfully, PostgreSQL provides us with many methods of modifying the data that is in our database. You have probably heard of these commands before. They are the INSERT, UPDATE, and DELETE commands. Each of these operations has a different impact on the data inside your tables. Let’s take a look at the syntax of each of these statements.
 
SQL UPDATE Syntax

The syntax of the UPDATE statement is:
UPDATE table_name
SET column1 = value1,
        column2 = value2,
        …
[WHERE conditions]

 

SQL INSERT Syntax

You can write an INSERT statement with or without explicitly declaring the column names. The syntax for using INSERT without column names is:

INSERT INTO table_name

VALUES (value1, value2, value3, ...);

Note that you’ll need to provide a value for every column in the table if you omit the column names.

If you want to add data to some or all the columns in a table, use INSERT with column names:

INSERT INTO table_name (column1, column2, column3, ...)

VALUES (value1, value2, value3, ...);


SQL DELETE Syntax

The syntax for using DELETE is : 

DELETE FROM table_name

[WHERE condition]
Advertisement