How do I insert a decimal in postgres sql

Viewed 34

I am trying to insert into a numeric column a decimal but I keep getting an error. Below is my statement

INSERT INTO blse VALUES (2082.7, 'Total Nonfarm' ,'Alabama','01/31/2020');

it basically says i need to cast this statement. I do not know what I am doing wrong.. I am beginner taking this class.

and this is the error:

error you get when supplying a number for a date

1 Answers

It is highly recommended that you specify the columns in an INSERT statement:

INSERT INTO tab (col1, col2, col3)
VALUES (val1, val2, val3);

That way, you can be certain what value is inserted where.

Since you didn't do that, the first value in the VALUES clause gets inserted into the first table column, which is of type date. That causes the error you observe.

Related