{"id":130,"date":"2007-10-15T18:54:59","date_gmt":"2007-10-16T02:54:59","guid":{"rendered":"http:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/"},"modified":"2007-10-15T18:54:59","modified_gmt":"2007-10-16T02:54:59","slug":"database-query-analysis","status":"publish","type":"post","link":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/","title":{"rendered":"Database Query Analysis"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/raffy.ch\/blog\/wp-content\/uploads\/2007\/10\/icon.thumbnail.jpg\" alt=\"icon.jpg\" style=\"margin: 0pt 10px 10px 0pt; float: left\" border=\"0\" \/>I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know which tables were touched. I was trying to build some regular expressions to extract that information from the query, but I gave up pretty quickly. It&#8217;s just too complicated for a regex. I was wondering whether there is a way to take a SQL query, for example:<\/p>\n<p><code>select * from a.table1 a, b.tabl2 b join c.table3 on b.id1=c.id2 where a.foo='bar'<\/code><\/p>\n<p>and extract all the table names: a.table1, b.table2, c.table3. Are there tools to do that? Remember, I don&#8217;t have the database with these tables. I only have a log from some database. The script should support all the SQL perks like joins, nested selects, etc. Anyone have a good way to do this?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,5,2],"tags":[],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-log-analysis","category-unix-scripting","category-visualization"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Raffael Marty\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Future of Tech and Security: Strategy &amp; Innovation with Raffy \u2013 Insights at the intersection of cybersecurity, strategy, and innovation.\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Database Query Analysis \u2013 Future of Tech and Security: Strategy &amp; Innovation with Raffy\" \/>\n\t\t<meta property=\"og:description\" content=\"I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/raffy.ch\/blog\/wp-content\/uploads\/2025\/09\/ogimage.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/raffy.ch\/blog\/wp-content\/uploads\/2025\/09\/ogimage.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2007-10-16T02:54:59+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2007-10-16T02:54:59+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@raffaelmarty\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Database Query Analysis \u2013 Future of Tech and Security: Strategy &amp; Innovation with Raffy\" \/>\n\t\t<meta name=\"twitter:description\" content=\"I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@raffaelmarty\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/raffy.ch\/blog\/wp-content\/uploads\/2025\/09\/ogimage.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#blogposting\",\"name\":\"Database Query Analysis \\u2013 Future of Tech and Security: Strategy & Innovation with Raffy\",\"headline\":\"Database Query Analysis\",\"author\":{\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/author\\\/raffy\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"http:\\\/\\\/raffy.ch\\\/blog\\\/wp-content\\\/uploads\\\/2007\\\/10\\\/icon.thumbnail.jpg\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#articleImage\"},\"datePublished\":\"2007-10-15T18:54:59-06:00\",\"dateModified\":\"2007-10-15T18:54:59-06:00\",\"inLanguage\":\"en-US\",\"commentCount\":5,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#webpage\"},\"articleSection\":\"Log Analysis, UNIX Scripting, Visualization\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/raffy.ch\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/category\\\/visualization\\\/#listItem\",\"name\":\"Visualization\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/category\\\/visualization\\\/#listItem\",\"position\":2,\"name\":\"Visualization\",\"item\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/category\\\/visualization\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#listItem\",\"name\":\"Database Query Analysis\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#listItem\",\"position\":3,\"name\":\"Database Query Analysis\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/category\\\/visualization\\\/#listItem\",\"name\":\"Visualization\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/#person\",\"name\":\"Raffael Marty\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1a1923877d9dbd00d99847074d62faab586cce0a9ee6a4c85e8bb7c46d7418ac?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Raffael Marty\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/author\\\/raffy\\\/#author\",\"url\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/author\\\/raffy\\\/\",\"name\":\"Raffael Marty\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1a1923877d9dbd00d99847074d62faab586cce0a9ee6a4c85e8bb7c46d7418ac?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Raffael Marty\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#webpage\",\"url\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/\",\"name\":\"Database Query Analysis \\u2013 Future of Tech and Security: Strategy & Innovation with Raffy\",\"description\":\"I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/2007\\\/10\\\/15\\\/database-query-analysis\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/author\\\/raffy\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/author\\\/raffy\\\/#author\"},\"datePublished\":\"2007-10-15T18:54:59-06:00\",\"dateModified\":\"2007-10-15T18:54:59-06:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/\",\"name\":\"Cyber Security - Strategy and Innovation\",\"description\":\"Insights at the intersection of cybersecurity, strategy, and innovation.\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/raffy.ch\\\/blog\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Database Query Analysis \u2013 Future of Tech and Security: Strategy & Innovation with Raffy","description":"I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know","canonical_url":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#blogposting","name":"Database Query Analysis \u2013 Future of Tech and Security: Strategy & Innovation with Raffy","headline":"Database Query Analysis","author":{"@id":"https:\/\/raffy.ch\/blog\/author\/raffy\/#author"},"publisher":{"@id":"https:\/\/raffy.ch\/blog\/#person"},"image":{"@type":"ImageObject","url":"http:\/\/raffy.ch\/blog\/wp-content\/uploads\/2007\/10\/icon.thumbnail.jpg","@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#articleImage"},"datePublished":"2007-10-15T18:54:59-06:00","dateModified":"2007-10-15T18:54:59-06:00","inLanguage":"en-US","commentCount":5,"mainEntityOfPage":{"@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#webpage"},"isPartOf":{"@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#webpage"},"articleSection":"Log Analysis, UNIX Scripting, Visualization"},{"@type":"BreadcrumbList","@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/raffy.ch\/blog#listItem","position":1,"name":"Home","item":"https:\/\/raffy.ch\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/raffy.ch\/blog\/category\/visualization\/#listItem","name":"Visualization"}},{"@type":"ListItem","@id":"https:\/\/raffy.ch\/blog\/category\/visualization\/#listItem","position":2,"name":"Visualization","item":"https:\/\/raffy.ch\/blog\/category\/visualization\/","nextItem":{"@type":"ListItem","@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#listItem","name":"Database Query Analysis"},"previousItem":{"@type":"ListItem","@id":"https:\/\/raffy.ch\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#listItem","position":3,"name":"Database Query Analysis","previousItem":{"@type":"ListItem","@id":"https:\/\/raffy.ch\/blog\/category\/visualization\/#listItem","name":"Visualization"}}]},{"@type":"Person","@id":"https:\/\/raffy.ch\/blog\/#person","name":"Raffael Marty","image":{"@type":"ImageObject","@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/1a1923877d9dbd00d99847074d62faab586cce0a9ee6a4c85e8bb7c46d7418ac?s=96&d=mm&r=g","width":96,"height":96,"caption":"Raffael Marty"}},{"@type":"Person","@id":"https:\/\/raffy.ch\/blog\/author\/raffy\/#author","url":"https:\/\/raffy.ch\/blog\/author\/raffy\/","name":"Raffael Marty","image":{"@type":"ImageObject","@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/1a1923877d9dbd00d99847074d62faab586cce0a9ee6a4c85e8bb7c46d7418ac?s=96&d=mm&r=g","width":96,"height":96,"caption":"Raffael Marty"}},{"@type":"WebPage","@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#webpage","url":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/","name":"Database Query Analysis \u2013 Future of Tech and Security: Strategy & Innovation with Raffy","description":"I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/raffy.ch\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/#breadcrumblist"},"author":{"@id":"https:\/\/raffy.ch\/blog\/author\/raffy\/#author"},"creator":{"@id":"https:\/\/raffy.ch\/blog\/author\/raffy\/#author"},"datePublished":"2007-10-15T18:54:59-06:00","dateModified":"2007-10-15T18:54:59-06:00"},{"@type":"WebSite","@id":"https:\/\/raffy.ch\/blog\/#website","url":"https:\/\/raffy.ch\/blog\/","name":"Cyber Security - Strategy and Innovation","description":"Insights at the intersection of cybersecurity, strategy, and innovation.","inLanguage":"en-US","publisher":{"@id":"https:\/\/raffy.ch\/blog\/#person"}}]},"og:locale":"en_US","og:site_name":"Future of Tech and Security: Strategy &amp; Innovation with Raffy \u2013 Insights at the intersection of cybersecurity, strategy, and innovation.","og:type":"article","og:title":"Database Query Analysis \u2013 Future of Tech and Security: Strategy &amp; Innovation with Raffy","og:description":"I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know","og:url":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/","og:image":"https:\/\/raffy.ch\/blog\/wp-content\/uploads\/2025\/09\/ogimage.png","og:image:secure_url":"https:\/\/raffy.ch\/blog\/wp-content\/uploads\/2025\/09\/ogimage.png","og:image:width":512,"og:image:height":512,"article:published_time":"2007-10-16T02:54:59+00:00","article:modified_time":"2007-10-16T02:54:59+00:00","twitter:card":"summary","twitter:site":"@raffaelmarty","twitter:title":"Database Query Analysis \u2013 Future of Tech and Security: Strategy &amp; Innovation with Raffy","twitter:description":"I was playing with database audit logs for a bit to try and visualize some aspects of them. While doing so, I came across a pretty interesting problem. The audit logs contain entries that indicate what exact SQL query was executed. Now, I am not interested in the entire query, but I need to know","twitter:creator":"@raffaelmarty","twitter:image":"https:\/\/raffy.ch\/blog\/wp-content\/uploads\/2025\/09\/ogimage.png"},"aioseo_meta_data":{"post_id":"130","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-06-08 17:06:18","updated":"2025-06-12 20:01:56","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/raffy.ch\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/raffy.ch\/blog\/category\/visualization\/\" title=\"Visualization\">Visualization<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tDatabase Query Analysis\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/raffy.ch\/blog"},{"label":"Visualization","link":"https:\/\/raffy.ch\/blog\/category\/visualization\/"},{"label":"Database Query Analysis","link":"https:\/\/raffy.ch\/blog\/2007\/10\/15\/database-query-analysis\/"}],"_links":{"self":[{"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":0,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"wp:attachment":[{"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raffy.ch\/blog\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}