Re: [HACKERS] create table and default 'now' problem ?
От | Thomas Lockhart |
---|---|
Тема | Re: [HACKERS] create table and default 'now' problem ? |
Дата | |
Msg-id | 37E72234.DDA960FE@alumni.caltech.edu обсуждение исходный текст |
Ответ на | Re: [HACKERS] create table and default 'now' problem ? (Mike Mascari <mascarim@yahoo.com>) |
Ответы |
Re: [HACKERS] create table and default 'now' problem ?
|
Список | pgsql-hackers |
> > how I could create table with datetime field default > > to 'now'::text in a way Jan did in his shoes rule example ? > > If I do: > > test=> create table test ( a datetime default 'now', > > b int4); > > CREATE > > I always get datetime of the moment I created the > > table, but I'd like to have datetime of moment I insert. > One way around this bug is to create a SQL function > which returns now() and use it as the default value: Not necessary, though this does work well. A simpler way is to actually do what Oleg asks about: create table test ( a datetime default text 'now',...) or create table test ( a datetime default 'now'::text,...) which should force the string to *stay* as a string, rather than getting converted to a date value when the table is created. Once it is forced to be a string, then it will be converted at insert time instead. - Thomas -- Thomas Lockhart lockhart@alumni.caltech.edu South Pasadena, California
В списке pgsql-hackers по дате отправления: