Database Reference
In-Depth Information
Updating data
Once we have inserted data in our table, we should know how to update it. This can
be done using the following statement:
warehouse_db=# UPDATE warehouse_tbl
SET year_created=2010
WHERE year_created=2009;
To verify that a record is updated, let's perform a SELECT query on the warehouse_
tbl table as follows:
warehouse_db=# SELECT warehouse_id, year_created FROM
warehouse_tbl;
warehouse_id | year_created
--------------+--------------
1 | 2010
(1 row)
Deleting data
To delete data from a table, we can use the DELETE command. Let's add a few records
to the table and then later on delete data on the basis of certain conditions:
warehouse_db=# INSERT INTO warehouse_tbl
(
warehouse_id,
warehouse_name,
year_created,
street_address,
city,
state,
zip
)
VALUES
(
2,
'Bill & Co',
2014,
'Lilly Road',
'New London',
'CT',
4321
);
warehouse_db=# INSERT INTO warehouse_tbl
 
Search WWH ::




Custom Search