首页 > 解决方案 > How to create a positive integer column in Oracle?

问题描述

Is it possible to create a positive integer in Oracle ?

I tried the following SQL but none of them is working :

ALTER TABLE testtable ADD TestColumn UNSIGNED;

ALTER TABLE testtable ADD TestColumn UNSIGNED Int;

ALTER TABLE testtable ADD TestColumn Int(Unsigned);

Thanks, Cheers,

标签: oracleconstraints

解决方案


您可以使用CHECK约束:

ALTER TABLE testtable ADD TestColumn Int CHECK(TestColumn > 0);

db<>小提琴演示


推荐阅读