Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4991

Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4993
Question 42: How do you find the largest table? – MySQL Question of the Day

Skip to content

By plogi in mysql questions

 

Find as many ways as possible to determine the name and schema of the table with the most rows inside your mysql-instance.

Hint: Use the information schema.

[ Obtaining Database Metadata (10%) - Using INFORMATION_SCHEMA to Obtain Metadata ]

Tags: , ,

Comment Feed

One Response

  1. plogi17. May 2010 @ 19:22:33


     
    Here are some possibilities:
     

    select * from information_schema.tables
      where table_rows=
      (select max(table_rows) from information_schema.tables);
    
    select * from information_schema.tables
      order by table_rows desc limit 1;
    
    select v1.* from information_schema.tables v1,
      (select max(table_rows) as mtr from information_schema.tables) v2
      where v1.table_rows=v2.mtr;
    
    set @a=(select max(table_rows) from information_schema.tables);
    select * from information_schema.tables where table_rows=@a;
    

     

    What kind of solutions did you find?

You must be logged in to post a comment.