Name

ANALYSE()

Synopsis

ANALYSE([maximum_elements[, maximum_memory]])

This function returns an analysis of a results table from a SELECT statement. Use this function only as part of a PROCEDURE clause. The first parameter is the maximum number of unique values that may be analyzed for each column; the default is 256. The second parameter is the maximum memory that should be allocated for each column during analysis; the default is 8,192 bytes (8 MB). Here is an example:

SELECT col1
FROM table1
PROCEDURE ANALYSE( ) \G
*************************** 1. row ***************************
             Field_name: table1.col1
              Min_value: 1
              Max_value: 82
             Min_length: 1
             Max_length: 2
       Empties_or_zeros: 0
                  Nulls: 0
Avg_value_or_avg_length: 42.8841
                    Std: 24.7600
      Optimal_fieldtype: TINYINT(2) UNSIGNED NOT NULL

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.