Search code examples
mysqlnumeric

What does `NUMERIC maxsize 256` mean in mysql?


Here is a data fields definition:

Field Name Field Description Field Type (format) Max Size May be NULL Key
tag The unique identifier (name) for a tag in a specific taxonomy release. ALPHANUMERIC 256 No *
version For a standard tag, an identifier for the taxonomy; otherwise the accession number where the tag was defined. ALPHANUMERIC 20 No *
ddate The end date for the data value, rounded to the nearest month end. DATE (yyyymmdd) 8 No *
qtrs The count of the number of quarters represented by the data value, rounded to the nearest whole number. “0” indicates it is a point-in-time value. NUMERIC 8 No *
uom The unit of measure for the value. ALPHANUMERIC 20 No *
coreg If specified, indicates a specific co-registrant, the parent company, or other entity (e.g., guarantor).  NULL indicates the consolidated entity. NUMERIC 256 Yes *
value The value. This is not scaled, it is as found in the Interactive Data file, but is limited to four digits to the right of the decimal point. NUMERIC(28,4) 16 Yes
footnote The text of any superscripted footnotes on the value, as shown on the statement page, truncated to 512 characters, or if there is no footnote, then this field will be blank. ALPHANUMERIC 512 Yes

The field definition is SEC U.S. Securities and Exchange Commission's official material:

sec official material

For coreg ,it's field type is numeric ,max size 256 ,how to write the create statement?

CREATE TABLE `num` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `tag` VARCHAR(256) NOT NULL,
    `version` VARCHAR(20) NOT NULL,
    `ddate` DATE NOT NULL,
    `qtrs` DECIMAL(8) NOT NULL,
    `uom` VARCHAR(20) NOT NULL,
    `coreg` ?,
    `value` DECIMAL(28,4),
    `footnote` VARCHAR(512),
    PRIMARY KEY (id)
);

To write the field definiton as below?

`coreg` NUMERIC(256) 

Solution

  • In MySQL the maximum number of digits for decimal (numeric) type is 65.

    So, you can't technically define a column as NUMERIC(256).

    11.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC

    The maximum number of digits for DECIMAL is 65


    It doesn't really make sense to me to have the "the parent company, or other entity (e.g., guarantor)" defined as a number, even as a really long number.

    Maybe there is a typo and really it should read "ALPHANUMERIC", i.e. a text value.

    If this value will never be interpreted as a number and there will never be attempts to make some calculations with this number (as the field description implies), then it should be stored as a text (varchar(256)); maybe with some extra checks that you can store only digits 0-9 and not any symbol there.