tar cvzf rpmdb-backup.tar.gz /var/lib/rpm
rpm -qa | sort
The first line is to backup your database
The second to remove locks
The third to rebuild your database
The fourth to check if all is ok
I hate select max clauses with Oracle. My company used to write subqueries which such expressions. It's slow and unreadable. Conditions ...