Does MySQL support user defined data types

前端 未结 2 604
一整个雨季
一整个雨季 2020-12-18 23:54

Is it possible to define (alias) a base data type in MySQL?

Currently I would like to define UUID as char(32), and then use UUID as the type throughout the schema de

相关标签:
2条回答
  • 2020-12-19 00:09

    In this case a text preprocesor like M4 or any C-language preprocesor may be useful.

    If you have the following in file tables.sql:

    define(UUID, char(32))
    create table mytable1 (my_uuid UUID);
    create table mytable2 (my_uuid UUID);
    

    Running

    $ m4 tables.sql
    

    you'll get:

    create table mytable1 (my_uuid char(32));
    create table mytable2 (my_uuid char(32));
    
    0 讨论(0)
  • 2020-12-19 00:23

    well ENUM does the work until certain expectation of your custom data types, but i'm too hoping to look forward to this topic

    0 讨论(0)
提交回复
热议问题