We help IT Professionals succeed at work.

UDDT and UID at MySQL

77 Views
Last Modified: 2019-04-10
Dear All,

I use MS SQL and usually create User Defined Data Types and UID.
Could I do it using MySQL ?

Thank you.
Comment
Watch Question

Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
There is no support in MySQL for User Defined Data Types.

I don't believe there is a data type for UID's either, but there is one or more functions related to generating UID's as I recall (have been working mostly in MS SQL Server lately).


»bp

Author

Commented:
Hi Bill,

I am sorry, i think I had response to this question.

Is there any substitution for it/

Thank you.
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
About all you can do for custom data types is include as many columns as you need using the supported datatypes in MySQL to store the same data you would have stored in a custom data type.  Sometimes you can just format it into a varchar, other times you may want to use multiple columns.


»bp

Author

Commented:
Please provide sample of datatype in MySQL that could replace UDDT and UID

Thank you.
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
A UDDT in Sql Server is just an alias for an existing data type.  So for example we could have:

Create Type SSN from varchar(11) NOT NULL

To store something like '123-45-6789'

In MySQL you would just have to use varchar(11) since you can't define a UDDT in MySQL.

Not sure what you are meaning by UID, can you be more specific?


»bp

Author

Commented:
UID = UniqueIdentifier.

Thank you.
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
uniqueidentifier  in SQL Server is a 16 character string, so I would use varchar(16) to store that in MySQL.


»bp

Author

Commented:
I know the length of UID.
What I want to find out is similar type to MS SQL, where it create automatically by using NewID()

Is there auto generated ID in MySQL?

Thank you.
Test your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Hi Bill,

Thank you very much for your help.