Database Reference
In-Depth Information
A SELECT operation on the parent/master table will grab data from all child tables.
This can be seen using the following statement:
warehouse_db=# SELECT * FROM sales_record;
id | sales_amount | sales_date
----+--------------+------------
1 | 500 | 2014-02-12
2 | 1500 | 2014-03-10
3 | 2500 | 2014-05-15
4 | 2000 | 2014-07-25
5 | 2200 | 2014-09-15
6 | 1200 | 2014-11-15
(6 rows)
Handling the UPDATE and DELETE
statements on a partition table
We don't need any UPDATE or DELETE triggers, the INSERT trigger is self-suficient to
handle the UPDATE or DELETE statement as well. First, let's perform an UPDATE action
and verify the impact on the child table in the following manner:
warehouse_db=# UPDATE sales_record SET sales_date='2014-9-13'
WHERE id = 5;
The preceding query will update the record of the date 2014-9-15 with id = 5 .
Let's perform a SELECT operation to verify the update of the record in the
following manner:
warehouse_db=# SELECT * FROM sales_record_m9_to_m10;
id | sales_amount | sales_date
----+--------------+------------
5 | 2200 | 2014-09-13
(1 row)
We can now verify that the record is updated and sales_date is changed to a new
date, that is, 2014-09-13 .
An update on a table that can cause row movement
between children requires an UPDATE trigger.
 
Search WWH ::




Custom Search