View column quantities in each table

Asked

Viewed 2,979 times

1

How do I get phpmyadmin to show me this:

--- tabelas ---

usuarios(5)
clientes(20)
admins(2)

for example using some mysql command or even some phpmyadmin functionality?

2 answers

2

In Phpmyadmin you just select the database and click on (+) and it will expand and display all tables of the selected database, re-apply on (+) next to the table will display its fields. See:

inserir a descrição da imagem aqui

If you wanted to do it via Mysql, use the SHOW TABLES command, as the friend NULL has already replied:

SHOW TABLES FROM database;

@Edit

You also want to count records from each table, is that right? If it is, use the command below:

SELECT TABLE_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'seu_database'
  • Good answer but he brought me the amount of record in each table and I want to know the amount of column.. but still it was worth it

1


To view the tables of a given Database in Mysql with the number of columns use SQL below:

Obs: 'Generics' is the name of the Bank, then switch to the name of your bank

SELECT a.TABLE_NAME,
       a.TABLE_SCHEMA, 
       (SELECT count(*) FROM information_schema.COLUMNS b
            WHERE b.TABLE_SCHEMA = a.TABLE_SCHEMA and b.TABLE_NAME = a.TABLE_NAME)
       TABLE_COLUMNS_COUNT  
FROM INFORMATION_SCHEMA.TABLES a        
WHERE a.TABLE_TYPE = 'BASE TABLE' and a.TABLE_SCHEMA = 'generics'

inserir a descrição da imagem aqui

Another would be with Group By (Note: will bring the views also)

SELECT  b.TABLE_NAME,
        b.TABLE_SCHEMA,
        count(b.TABLE_SCHEMA) TABLE_COLUMNS_COUNT
FROM information_schema.COLUMNS b
WHERE b.TABLE_SCHEMA = 'generics'
GROUP BY b.TABLE_SCHEMA, b.TABLE_NAME

Source: Click here

  • 1

    Good answer, that’s right Thank you..

  • Vlw @Silvioandorinha

Browser other questions tagged

You are not signed in. Login or sign up in order to post.