且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在枚举字段上设置索引

更新时间:2021-08-28 15:57:13

不幸的是,这是不可能的. 手册本身没有希望的余地:

Unfortunately this is not possible. The manual itself leaves no room for hope:

每个枚举值都有一个索引:

Each enumeration value has an index:

•列中允许的元素列表中的值 规范从1开始编号.

• Values from the list of permissible elements in the column specification are numbered beginning with 1.

鉴于您对此无能为力,我不得不问:为什么要将它设为enum?我还没有遇到这样的情况:enum提供了 any ,这给那些通过眼睛查看查询结果的程序员带来了极大的便利.您希望获得什么好处?我不是专家,但是恕我直言,无论您想要实现什么,除了使用enum之外,还有另一种(更好的)方法.

Seeing as there's nothing you can do about that, I have to ask: why do you need to make this an enum? I have yet to come across a situation where an enum provided any benefit apart convenience to programmers who look at query results by eye. What is the benefit you are looking to gain? I am no guru, but IMHO no matter what you want to achieve there is another (better) way than using an enum.