5
I need to set in a column on postgresql
the current date of insertion as the default value for the field.
How can I do that?
5
I need to set in a column on postgresql
the current date of insertion as the default value for the field.
How can I do that?
4
You can set the default value in column creation, for example:
my_date date not null default CURRENT_DATE
1
If your table already exists you need to update it
alter table minha_table
alter column minha_date set default current_timestamp
If you are creating you can already create the column with the default value
create table minha_table
(
minha_date date not null default CURRENT_DATE
);
(CURRENT_DATE is basically a synonym for now() and a cast to date).
Browser other questions tagged sql postgresql date
You are not signed in. Login or sign up in order to post.
See if it helps you: http://stackoverflow.com/questions/910763/how-to-set-a-postgresql-default-value-datestamp-like-yyyymm
– adelmo00