Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is creating db user defined data types best practice?

Is creating user defined types instead of using existing types best practice? In my previews work place all basic types were predefined, is it best practice? what advantages and what disadvantage it has.
Thanks a lot!

like image 970
Arsen Mkrtchyan Avatar asked Apr 23 '26 22:04

Arsen Mkrtchyan


1 Answers

In MS SQL Server - the idea is great. However, there's a BIG but to them: you can't change them once they're in use, since there's no ALTER TYPE .... statement. This can be a major hassle.

Consider this: you have a bookstore app which has a user-defined type ISBN = VARCHAR(10) - works like a charm. Now the international committee decided to increate the ISBN field to 13 characters - unfortunately, there's no ALTER TYPE ISBNType..... so your only choice is to basically drop all the columns of that type in all of your database, then re-create the type in its new form, and re-create all those columns again.

The idea is great and I would love to use it - but in its current state, it's next to unusable, in my opinion, which is unfortunate.

Marc

like image 140
marc_s Avatar answered Apr 26 '26 03:04

marc_s



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!