Rechercher dans le manuel MySQL
25.6 The INFORMATION_SCHEMA COLUMNS Table
The COLUMNS
table provides
information about columns in tables. The related
ST_GEOMETRY_COLUMNS
table provides
information about table columns that store spatial data. See
Section 25.27, “The INFORMATION_SCHEMA ST_GEOMETRY_COLUMNS Table”.
The COLUMNS
table has these columns:
TABLE_CATALOG
The name of the catalog to which the table containing the column belongs. This value is always
def
.TABLE_SCHEMA
The name of the schema (database) to which the table containing the column belongs.
TABLE_NAME
The name of the table containing the column.
COLUMN_NAME
The name of the column.
ORDINAL_POSITION
The position of the column within the table.
ORDINAL_POSITION
is necessary because you might want to sayORDER BY ORDINAL_POSITION
. UnlikeSHOW COLUMNS
,SELECT
from theCOLUMNS
table does not have automatic ordering.COLUMN_DEFAULT
The default value for the column. This is
NULL
if the column has an explicit default ofNULL
, or if the column definition includes noDEFAULT
clause.IS_NULLABLE
The column nullability. The value is
YES
ifNULL
values can be stored in the column,NO
if not.DATA_TYPE
The column data type.
The
DATA_TYPE
value is the type name only with no other information. TheCOLUMN_TYPE
value contains the type name and possibly other information such as the precision or length.CHARACTER_MAXIMUM_LENGTH
For string columns, the maximum length in characters.
CHARACTER_OCTET_LENGTH
For string columns, the maximum length in bytes.
NUMERIC_PRECISION
For numeric columns, the numeric precision.
NUMERIC_SCALE
For numeric columns, the numeric scale.
DATETIME_PRECISION
For temporal columns, the fractional seconds precision.
CHARACTER_SET_NAME
For character string columns, the character set name.
COLLATION_NAME
For character string columns, the collation name.
COLUMN_TYPE
The column data type.
The
DATA_TYPE
value is the type name only with no other information. TheCOLUMN_TYPE
value contains the type name and possibly other information such as the precision or length.COLUMN_KEY
Whether the column is indexed:
If
COLUMN_KEY
is empty, the column either is not indexed or is indexed only as a secondary column in a multiple-column, nonunique index.If
COLUMN_KEY
isPRI
, the column is aPRIMARY KEY
or is one of the columns in a multiple-columnPRIMARY KEY
.If
COLUMN_KEY
isUNI
, the column is the first column of aUNIQUE
index. (AUNIQUE
index permits multipleNULL
values, but you can tell whether the column permitsNULL
by checking theNull
column.)If
COLUMN_KEY
isMUL
, the column is the first column of a nonunique index in which multiple occurrences of a given value are permitted within the column.
If more than one of the
COLUMN_KEY
values applies to a given column of a table,COLUMN_KEY
displays the one with the highest priority, in the orderPRI
,UNI
,MUL
.A
UNIQUE
index may be displayed asPRI
if it cannot containNULL
values and there is noPRIMARY KEY
in the table. AUNIQUE
index may display asMUL
if several columns form a compositeUNIQUE
index; although the combination of the columns is unique, each column can still hold multiple occurrences of a given value.EXTRA
Any additional information that is available about a given column. The value is nonempty in these cases:
auto_increment
for columns that have theAUTO_INCREMENT
attribute.on update CURRENT_TIMESTAMP
forTIMESTAMP
orDATETIME
columns that have theON UPDATE CURRENT_TIMESTAMP
attribute.VIRTUAL GENERATED
orVIRTUAL STORED
for generated columns.DEFAULT_GENERATED
for columns that have an expression default value.
PRIVILEGES
The privileges you have for the column.
COLUMN_COMMENT
Any comment included in the column definition.
GENERATION_EXPRESSION
For generated columns, displays the expression used to compute column values. Empty for nongenerated columns. For information about generated columns, see Section 13.1.20.9, “CREATE TABLE and Generated Columns”.
SRS_ID
This value applies to spatial columns. It contains the column
SRID
value that indicates the the spatial reference system for values stored in the column. See Section 11.5.1, “Spatial Data Types”, and Section 11.5.5, “Spatial Reference System Support”. The value isNULL
for nonspatial columns and spatial columns with noSRID
attribute.
Notes
In
SHOW COLUMNS
, theType
display includes values from several differentCOLUMNS
columns.CHARACTER_OCTET_LENGTH
should be the same asCHARACTER_MAXIMUM_LENGTH
, except for multibyte character sets.CHARACTER_SET_NAME
can be derived fromCOLLATION_NAME
. For example, if you saySHOW FULL COLUMNS FROM t
, and you see in theCOLLATION_NAME
column a value ofutf8_swedish_ci
, the character set is what is before the first underscore:utf8
.
Column information is also available from the
SHOW COLUMNS
statement. See
Section 13.7.6.5, “SHOW COLUMNS Syntax”. The following statements are
nearly equivalent:
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-columns-table.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.