postgresql域检查数组值(postgresql domain check array values)

编程入门 行业动态 更新时间:2024-10-27 10:31:13
postgresql域检查数组值(postgresql domain check array values)

我正在从我所看到的MySQL / Maria的简单世界转向更复杂的PostgreSQL世界。 我正在创建一个相当传统的个人联系信息表。 其中一列是电话号码,应该是一个数组。 (这样做是有意义的,而不是三个表,一个用于联系,一个用于电话号码,一个用于连接两个。)我想确保每个电话号码(定义为“文本” - 尽管仅由数字组成)电话号码不是数字),仅包含数字。

我无法解决如何为列定义或域规范构造CHECK子句。 域将被定义为“text”或“char”的数组。

有人可以帮忙吗?

I am moving from what I see as the simple world of MySQL/Maria to the more complex world of PostgreSQL. I am creating a fairly conventional table of a person's contact details. One of the columns is the telephone numbers, which should be an array. (It makes sense to do this rather than three tables, one for the contact, one for the telephone number and one joining the two.) I would like to ensure that every telephone number (defined as "text" - although comprised solely of digits a telephone number is not a number), contains only digits.

I cannot work out how to construct the CHECK clause either for the column definition or for domain specification. The domain would be defined as an array of "text" or "char".

Can anyone help?

最满意答案

我在postgresql中发现了一篇很好的文章,它解决了我在合并和操作数组中遇到的问题

I found an excellent article that addresses my own question at merging-and-manipulating-arrays-in postgresql

更多推荐

本文发布于:2023-07-20 20:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1203711.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   domain   postgresql   values   array

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!