views:

42

answers:

4

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.

A: 

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;
rfusca
+2  A: 

UPDATE myTable SET myColumn='newValue'

newValue can be an expression

see http://www.postgresql.org/docs/8.4/interactive/sql-update.html

dweeves
A: 

Seems like you ought to be able to do something like this:

INSERT INTO films (title) VALUES ('Tampopo'), WHERE TRUE;

(Adapted from: http://www.postgresql.org/docs/8.2/static/sql-insert.html )

Curtis
+1  A: 

I would think you're trying to UPDATE.

UPDATE myTable set myColumn = 'WHATEVER'
Fosco