7

I am trying to figure out how to insert the same value into the entire column of a table? The table already exists and I have an empty column into which I would like to insert a certain value, for example, today's date. I have only found sources explaining how to insert values into an entire row.

3 Answers 3

14
UPDATE myTable SET myColumn='newValue'

newValue can also be an expression.

see http://www.postgresql.org/docs/current/static/sql-update.html

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

Comments

7

I think we need a bit more info to understand the issue, it sounds like you just want...

INSERT INTO table_foo (my_empty_column_name) values (current_date);

If you've already got data there and you want to UPDATE that column for all rows then...

UPDATE table_foo SET my_empty_column_name = current_date;

Comments

4

I would think you're trying to UPDATE.

UPDATE myTable set myColumn = 'WHATEVER'

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.