$sth = $dbh->column_info( $catalog, $schema, $table, $column );
The statement handle returned has at least the following fields in the order shown below. Other fields, after these, may also be present.
TABLE_CAT: The catalog identifier. This field is NULL (undef) if not applicable to the data source, which is often the case. This field is empty if not applicable to the table.
TABLE_SCHEM: The schema identifier. This field is NULL (undef) if not applicable to the data source, and empty if not applicable to the table.
TABLE_NAME: The table identifier. Note: A driver may provide column metadata not only for base tables, but also for derived objects like SYNONYMS etc.
COLUMN_NAME: The column identifier.
DATA_TYPE: The concise data type code.
TYPE_NAME: A data source dependent data type name.
COLUMN_SIZE: The column size. This is the maximum length in characters for character data types, the number of digits or bits for numeric data types or the length in the representation of temporal types. See the relevant specifications for detailed information.
BUFFER_LENGTH: The length in bytes of transferred data.
DECIMAL_DIGITS: The total number of significant digits to the right of the decimal point.
NUM_PREC_RADIX: The radix for numeric precision. The value is 10 or 2 for numeric data types and NULL (undef) if not applicable.
NULLABLE: Indicates if a column can accept NULLs. The following values are defined:
REMARKS: A description of the column.
COLUMN_DEF: The default value of the column, in a format that can be used directly in an SQL statement.
Note that this may be an expression and not simply the text used for the default value in the original CREATE TABLE statement. For example, given:
col1 char(30) default current_user -- a 'function'
col2 char(30) default 'string' -- a string literal
where "current_user" is the name of a function, the corresponding COLUMN_DEF values would be:
Database col1 col2
-------- ---- ----
Oracle: current_user 'string'
Postgres: "current_user"() 'string'::text
MS SQL: (user_name()) ('string')
SQL_DATA_TYPE: The SQL data type.
SQL_DATETIME_SUB: The subtype code for datetime and interval data types.
CHAR_OCTET_LENGTH: The maximum length in bytes of a character or binary data type column.
ORDINAL_POSITION: The column sequence number (starting with 1).
IS_NULLABLE: Indicates if the column can accept NULLs. Possible values are: 'NO', 'YES' and ''.
SQL/CLI defines the following additional columns:
Drivers capable of supplying any of those values should do so in the corresponding column and supply undef values for the others.
Where is a list of translations for the codes appearing in some fields?
Based on my searching, they are not readily available. You probably need to go to an SQL forum and ask some experts where those can be found.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||