Avatar of emi_sastra
emi_sastra
 asked on

UDDT and UID at MySQL

Dear All,

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

Thank you.
Microsoft SQL ServerMySQL Server

Avatar of undefined
Last Comment
emi_sastra

8/22/2022 - Mon
Bill Prew

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
emi_sastra

ASKER
Hi Bill,

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

Is there any substitution for it/

Thank you.
Bill Prew

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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
emi_sastra

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

Thank you.
Bill Prew

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
emi_sastra

ASKER
UID = UniqueIdentifier.

Thank you.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Bill Prew

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


»bp
emi_sastra

ASKER
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.
ASKER CERTIFIED SOLUTION
Bill Prew

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
emi_sastra

ASKER
Hi Bill,

Thank you very much for your help.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23