UDDT and UID at MySQL

emi_sastra
emi_sastra used Ask the Experts™
on
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

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Bill PrewIT / Software Engineering Consultant
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 PrewIT / Software Engineering Consultant
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
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

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

Thank you.
Bill PrewIT / Software Engineering Consultant
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 PrewIT / Software Engineering Consultant
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.
IT / Software Engineering Consultant
Top Expert 2016
Commented:
MySQL has a UUID() function, and some related functions, take a look at that.

https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid


»bp

Author

Commented:
Hi Bill,

Thank you very much for your help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial