Following up this question: "Database enums - pros and cons", I'd like to know which database systems support enumeration data types, and a bit of detail on how they do it (e.g. what is stored internally, what are the limits, query syntax implications, indexing implications, ...).
Discussion of use cases or the pros and cons should take place in the other questions.
Porting it to other RDBMS could be a hard task because ENUM is not an SQL's standard datatype and not many database systems provide support to it. It isn't possible to insert more values to the enumerated column.
An ENUM is a string object with a value chosen from a list of permitted values that are enumerated explicitly in the column specification at table creation time. See Section 11.3. 1, “String Data Type Syntax” for ENUM type syntax and length limits.
6. You can't reuse the member-list of an ENUM column in other tables. When you create a list of possible members in an ENUM column, there's no easy and consistent way to re-use that list in other tables. With a reference table, the same set of data can be related to as many other tables as required.
First of all, in order to save enum values in a relational database using JPA, you don't have to do anything. By default, when an enum is a part of an entity, JPA maps its values into numbers using the ordinal() method. What it means is that without customizations JPA stores enum value as numbers.
I know that MySQL does support ENUM:
SELECT enum_col+0
"ENUM('0','1','2')
should be avoided, because '0'
would have integer value 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With