DEV4 Blog

  • Home
  • /
  • Blog
  • /
  • Get the total field Count in a database

If you need to retrieve the total number of fields in your database, use the following query.

select count(*),c.table_name 
from information_schema.COLUMNS c
JOIN information_schema.tables t ON c.TABLE_NAME = t.TABLE_NAME
AND c.TABLE_Schema = t.TABLE_Schema
WHERE TABLE_TYPE = 'base table'  
GROUP BY c.table_name

Note - this query does not provide system table or their associated column collections.

Published on 28 Jun 2019

Add new comment...