如何在Oracle SQL中添加约束以限制值? [英] How do i add a constraint in Oracle SQL to limit a value?

查看:425
本文介绍了如何在Oracle SQL中添加约束以限制值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在oracle中设置一列以不接受大于10000且小于0的数字?

How can i set a column in oracle to not accept numbers above 10000 and below 0?

推荐答案

您正在寻找check约束:

alter table t add constraint chk_t_col check (col >= 0 and col <= 10000);

这将防止在列中插入或更新不在指定范围内的任何值.

This will prevent inserting or updating any values in the column that are not in the specified range.

这篇关于如何在Oracle SQL中添加约束以限制值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆