VillageSQL is a drop-in replacement for MySQL with extensions.
All examples in this guide work on VillageSQL. Install Now →
INFORMATION_SCHEMA is a virtual database that exposes MySQL server metadata through standard SQL queries. Everything that SHOW TABLES, SHOW COLUMNS, and DESCRIBE can tell you, INFORMATION_SCHEMA can too — and with the full power of WHERE, JOIN, and aggregation.
Tables and Columns
List all tables in a database:table_rows is an estimate for InnoDB tables (derived from index statistics), not an exact count. Use SELECT COUNT(*) for precision.
List all columns for a table:
Indexes
List all indexes on a table:Constraints
List all constraints (PRIMARY KEY, UNIQUE, FOREIGN KEY, CHECK):Stored Routines
List all stored procedures and functions:Views and Triggers
List all views:Privileges
View effective privileges for the current user:Key Tables Reference
INFORMATION_SCHEMA vs SHOW Commands
SHOW commands are shorthand that often have an INFORMATION_SCHEMA equivalent:
INFORMATION_SCHEMA queries are better when you need filtering, joining, or aggregation. SHOW commands are fine for interactive inspection.
Frequently Asked Questions
Are INFORMATION_SCHEMA queries slow?
For InnoDB tables, some queries (especially againstTABLES and STATISTICS) trigger index statistics updates, which can be slow on large schemas. If you’re querying metadata frequently, use mysql.innodb_table_stats and mysql.innodb_index_stats for faster access to cached statistics.
Why do table_rows values look wrong?
information_schema.tables.table_rows is an estimate from InnoDB’s index statistics, not a live count. It can be off by 40-50% for large tables. Run ANALYZE TABLE tablename to refresh the statistics, or use SELECT COUNT(*) for an exact count.
Troubleshooting
See also
- MySQL User Management — INFORMATION_SCHEMA.USER_PRIVILEGES for auditing grants
- Schema Migrations in MySQL — querying INFORMATION_SCHEMA to inspect schema before migrating

