To add svick's answer, here is an example sample SQL query:
SELECT old_text, old_flags FROM page JOIN revision ON rev_id = page_latest JOIN text ON old_id = rev_text_id WHERE page_title = 'Main_Page' AND page_namespace = 0;
(Note that you will need the old_flags field to understand the contents of old_text . At least you need to make sure the flags field contains the value that you expect from it.)
source share