我正在从我所看到的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
更多推荐
发布评论