emonz
emonz

Reputation: 4744

Defining Data Type for Postgres Table Question

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?

Upvotes: 0

Views: 93

Answers (2)

emonz
emonz

Reputation: 4744

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!

Upvotes: 0

Adrian Klaver
Adrian Klaver

Reputation: 19665

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.

Upvotes: 1

Related Questions