How to query out all information by a contextinstanceid?

@Don, thank you for providing the ad-hoc SQL queries page, that's really what I want. The info retrieved with Event 2 API is very insufficient. However, unfortunately, the only one SQL query containing contextinstanceid on that page is applicable to "Considering only several modules: url, resource, forum, quiz, questionnaire", it is not universal to all activities. I'm not familar with Moodle SQL schema, what should I then do?