How to create a positive integer column in Oracle?

Viewed 1485

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,

1 Answers

You could use CHECK constraint:

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

db<>fiddle demo

Related