0

I'm creating a table using Postgres and I've received a data dictionary for a table where a certain column name Price will have a type Real, Dec = 2 and can be NULL. Can someone explain what is meant by the data dictionary saying Real, Dec = 2? Does this mean this value will have a precision of 2 decimal places (e.g. 34.456654)?

When declaring this column inside the table should I do: Price REAL NULL?

2 Answers 2

1

I would think DEC=2 would be 34.46. You can't specify that with real. You would need to use something like numeric(4, 2) assuming you are only going to have two places to left of decimal point. For more information see Numbers 8.1.2. Arbitrary Precision Numbers. I would confirm that the goal is to have values out to only two decimal places. FYI, NULL is the default for a field specification. so you don't have to include it.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I was thinking the same thing -- the dec=2 means the scale of the number. The bad thing is, I don't know the precision of the number, only its scale (which is 2).
That would require some knowledge of the data being passed in. Remember it is possible to change the precision and scale later. This being easier if you go from smaller to larger.
0

The question means that the precision of the number must be of two decimal places. For example: 3445.22 or 12.23. Thank you all for your responses!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.