Thomas Carlton
Thomas Carlton

Reputation: 5968

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,

Upvotes: 4

Views: 2777

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175994

You could use CHECK constraint:

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

db<>fiddle demo

Upvotes: 8

Related Questions