Find number of columns in Vertica database

Query returns basic statistics of numbers of columns in a database.

Query

select count(distinct table_id) as tables,
       count(*) as columns,
       round(count(*)/count(distinct table_id),2) as avg_column_count
from v_catalog.columns;

Columns

  • tables - number of tables in a database
  • columns - total number of columns in a database
  • avg_column_count - average number of columns in a table in a database

Rows

  • Query returns just one row

Sample results

Result from VMart sample database