Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a way to effect user defined data types in MySQL?
    primarykey
    data
    text
    <p>I have a database which stores (among other things), the following pieces of information:</p> <ul> <li>Hardware IDs <code>BIGINT</code>s</li> <li>Storage Capacities <code>BIGINT</code>s</li> <li>Hardware Names <code>VARCHAR</code>s</li> <li>World Wide Port Names <code>VARCHAR</code>s</li> </ul> <p>I'd like to be able to capture a more refined definition of these datatypes. For instance, the hardware IDs have no numerical significance, so I don't care how they are formatted when displayed. The Storage Capacities, however, are cardinal numbers and, at a user's request, I'd like to present them with thousands and decimal separators, e.g. 123,456.789. Thus, I'd like to refine <code>BIGINT</code> into, say <code>ID_NUMBER</code> and <code>CARDINAL</code>.</p> <p>The same with Hardware Names, which are simple text and WWPNs, which are hexstrings, e.g. 24:68:AC:E0. Thus, I'd like to refine <code>VARCHAR</code> into <code>ENGLISH_WORD</code> and <code>HEXSTRING</code>.</p> <p>The specific datatypes I made up are just for illustrative purposes.</p> <p>I'd like to keep all this information in one place and I'm wondering if anybody knows of a good way to hold this all in my MySQL table definitions. I <em>could</em> use the Comment field of the table definition, but that smells fishy to me.</p> <p>One approach would be to define the data structure elsewhere and use that definition to generate my <code>CREATE TABLE</code>s, but that would be a major rework of the code that I currently have, so I'm looking for alternatives.</p> <p>Any suggestions? The application language in use is Perl, if that helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload