Well, this is a fine statement to delete duplicates in a table :
A.ID = B.ID and
any additional condition
and other conditions on...
Here goes a simple SQL to retrieve the amount of space that a partioned takes (partion by partition) in MB.
select partition_name, bytes/1024/1024 as size_mb
where segment_name = 'YOUR_TABLE'
order by 1
There you all your partions in MB.
Here goes a tiny snippet that should get you started by using Oracle as your database instead of the classic MySql RDBMS.
// At first, get connected to the instance of your RDBMS
$conn = oci_connect("user", "password",...