is there a built-in type in postgres for a columns which can receive values in percent : 0-100?

is there a possibility to have a columns that receives only values between  0 and 100?
toshi_Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Tomas Helgi JohannssonConnect With a Mentor Commented:
WHen you create your table you can issue a check
like the attached code snippet shows

Regards,
  Tomas Helgi
postgres=# CREATE TABLE mytable (
postgres(#    nr integer,
postgres(#    percentige numeric,  CHECK (percentige > 0 and percentige <= 100)
postgres(# );
CREATE TABLE

Open in new window

0
 
Tomas Helgi JohannssonCommented:
   Hi!


Percentage is usually stored in a database either as an Integer value or as Float/Double value.

Regards,
   Tomas Helgi
0
 
toshi_Author Commented:
ok, but i'd like to control that values are not higher than 100, and not negatives.
0
 
toshi_Author Commented:
wonderful,
as i'm using pgAdminIII, i can add ckeck as constraints with graphical interface.
i never took notice of it.

thanks a lot.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.