Is it possible to make a workflow to delete old packages using query and Delete activity or using script? I am getting an error when I try to query specFile schema.
What do you mean by old packages?
In general, removing structural elements from the DB is risky (for example, this is why there is no option to remove a standard package using the UI, once installed).
General recommendation in that case is to use a fresh instance.
If you only want to clear some data, you can use the update activity in a workflow (set to 'delete').