Solved

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

Posted on 2007-11-22
4
209 Views
Last Modified: 2012-06-27
is there a possibility to have a columns that receives only values between  0 and 100?
0
Comment
Question by:toshi_
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:Tomas Helgi Johannsson
ID: 20333792
   Hi!


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

Regards,
   Tomas Helgi
0
 

Author Comment

by:toshi_
ID: 20334205
ok, but i'd like to control that values are not higher than 100, and not negatives.
0
 
LVL 25

Accepted Solution

by:
Tomas Helgi Johannsson earned 500 total points
ID: 20334266
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
 

Author Comment

by:toshi_
ID: 20334345
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

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now