如何计算Postgres整数数据类型中的位数? [英] How to count number of digits in Postgres integer data type?
本文介绍了如何计算Postgres整数数据类型中的位数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在postgres中将整数类型字段中的位数限制为6或7。
I need to restrict the number of digits in the 'integer' type fields to 6 or 7 in postgres.
基本上它应该接受123456或1234567,但应该不接受12345或12345678。
如何实现??
Basically it should accept 123456 or 1234567 but it should not accept 12345 or 12345678. How can I achieve this??
推荐答案
具有检查约束
check (value>99999 and value<=9999999)
这篇关于如何计算Postgres整数数据类型中的位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文