Created
October 4, 2017 10:09
-
-
Save nilsmeyer/2e1396fe5e504b2af20dd54054b3dca5 to your computer and use it in GitHub Desktop.
Get the maximum size for an index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$database would be the database/schema... | |
SELECT c.TABLE_NAME, CONSTRAINT_NAME, SUM(CHARACTER_OCTET_LENGTH) AS length FROM KEY_COLUMN_USAGE kcu INNER JOIN COLUMNS c ON c.TABLE_SCHEMA = kcu.TABLE_SCHEMA AND c.TABLE_NAME = kcu.TABLE_NAME AND c.COLUMN_NAME = kcu.COLUMN_NAME WHERE kcu.TABLE_SCHEMA='$database' GROUP BY CONSTRAINT_NAME, c.TABLE_NAME ORDER BY length; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment