I have a passion for meta-queries, by which I mean queries that answer questions about data rather than answering with data.
Before I get a lot of justified criticism, I do realize that the approach of meta-queries is not ideal, as eloquently described here for example. Nevertheless, I believe they do have their place. (So much so that I created a WinForms user control that supports parameterized meta-queries for SQL Server, Oracle, and MySql, and I describe extensively the design and use of this QueryPicker in a three-part series published on Simple-Talk.com.)
My motivation for using meta-queries:
Sure there are other (better?) ways to get meta-information--for a given database type. SQL Server, particularly, provides SQL Server Management Studio. Oracle and MySql tools do not seem to provide the same usefulness. (I freely admit that I make this claim with my SQL-Server-leaning-view of the universe. :-) Even if they did, they would be be different--I want a uniform approach across database types.
What SQL Server, Oracle, or MySql meta-queries do you find useful?
This first view summarizes my collection thus far by database type (and, as I said, heavily weighted toward SQL Server).
Query SQL Server Oracle MySql DB Version yes yes yes Databases with properties yes yes Databases with space usage yes National Language Support yes Procedures and functions yes yes Primary keys yes yes Primary to foreign keys yes Session Information/brief yes Session Information/details yes Session SET options yes Users and Roles yes Currently running statements yes Constraints yes Indexes yes Column info/brief yes yes yes Column info/details yes yes yes Object level details yes Rows and space used yes Row/column counts yes Non-empty tables yes yes yes Show table schema yes yes Seed/max values yes
I have developed some of these meta-queries myself but many have come from community forums. This second view itemizes the source URLs where appropriate.
System Category
-----------------
    DB Version
    Databases with properties    http://www.mssqltips.com/tip.asp?tip=1033
    Databases with space usage   http://www.sqlservercentral.com/Forums/Topic261080-5-1.aspx
    Procedures and functions
    Primary keys                 http://databases.aspfaq.com/schema-tutorials/schema-how-do-i-show-all-the-primary-keys-in-a-database.html
    Primary to foreign keys      http://www.sqlservercentral.com/scripts/Miscellaneous/61481/
    Session Information/brief    http://www.sqlservercentral.com/blogs/glennberry/archive/2009/12/28/how-to-get-a-count-of-sql-connections-by-ip-address.aspx
    Session Information/details  http://www.mssqltips.com/tip.asp?tip=1817
    Session SET options
    Users and Roles              http://www.sqlservercentral.com/scripts/users/69379/
    Currently running statements http://www.sqlservercentral.com/articles/DMV/64425/
    Constraints
    Indexes                      http://www.sqlservercentral.com/scripts/Index+Management/63932/
Column Category
-----------------
    Column info/brief
    Column info/details
Table Category
-----------------
    Object level details
    Rows and space used          http://www.mssqltips.com/tip.asp?tip=1177
    Row/column counts
    Non-empty tables
DDL Category
-----------------
    Show table schema            http://www.sqlservercentral.com/scripts/Create+DDL+sql+statements/65863/
Data Category
-----------------
    Seed/max values
System Category
-----------------
    DB Version
    National Language Support
Column Category
-----------------
    Column info/brief
    Column info/details
Table Category
-----------------
    Non-empty tables
DDL Category
-----------------
    Show table schema
System Category
-----------------
    DB Version
    Databases
    Procedures and functions
    Primary keys                 http://databases.aspfaq.com/schema-tutorials/schema-how-do-i-show-all-the-primary-keys-in-a-database.html
Column Category
-----------------
    Column info/brief
    Column info/details
DDL Category
-----------------
    Show table schema
                Oracle SQL Developer has a set of built-in reports that include these categories. I have expanded one of the categories.
About Your Database
All Objects
Application Express
ASH and AWR
Database Administration
  All Tables
  Cursors
  Database Parameters
  Locks
  Memory
  Sessions
  Storage
  Top SQL
  Users
  Waits and Events
Data Dictionary
Jobs
PLSQL
Security
Streams
Table
XML
These are a few of the actual report names,
Tables without Indexes
Tables without Primary Keys
Tables with Unindexed Foreign Keys
Largest Average Row Length
Most Rows
Unusable Indexes
There are many more reports available.
I have a number of these I use regularly on SQL Server, including, but not limited to:
System-specific:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With