How can I select a bunch of rows with the partition name in each row?
I have a MySQL table with range partitioning. In PostgreSQL, I could
select the tableoid column to see which partition each row is in (because
with PostgreSQL I have to explicitly use table inheritance to implement
partitioning). Is there a similar way to do this in MySQL? Here's roughly
what I want (let's assume I have the orders table partitioned by year
using range partitioning):
SELECT orders.cost_usd, orders.partition_name
FROM orders
WHERE orders.year > 2005;
And the results would be:
+-----------------+-----------------------+
| orders.cost_usd | orders.partition_name |
+-----------------+-----------------------+
| 1039.90 | p_2005 |
| 459.06 | p_2006 |
| 033.77 | p_2006 |
| 6473.36 | p_2008 |
| 240.17 | p_2009 |
| 1011.20 | p_2013 |
+-----------------+-----------------------+
No comments:
Post a Comment