Results 1 to 3 of 3
  1. #1
    Join Date
    May 2010
    Posts
    3

    Unanswered: Selecting all the object with more than five indexes

    Hello everybody,

    I searched the forum, but have not found similar problem.
    I would like to select all object from my local mysql installation which have more than five indexes. Is this possible?

    I have tried to find some solutions via information_schema database, but nothing helped. Basically, I would like to ask following:

    SELECT ALL OBJECTS WHERE MORE THAN FIVE INDEXES.

    Thanks a lot in advance for resoponses

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT constraint_schema
         , table_name
         , COUNT(DISTINCT constraint_name) AS x
     FROM information_schema.key_column_usage 
    GROUP 
        BY constraint_schema
         , table_name
    HAVING x >= 5     
    ORDER 
        BY x DESC
    results: sakila rental 5

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2010
    Posts
    3
    Thanks a lot r937!
    With small modification works like a charm!
    Just one additional question: Are the all records in key_column_usage table indexes?

    Best

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •