Re: Can't find the right generated column syntax
"David G. Johnston" <[email protected]> Mon, 25 Nov 2019 19:41:00 -0700
| Newsgroups | gmane.comp.db.postgresql.novice |
|---|---|
| Message-ID | <CAKFQuwbJtPX4ZBACxCD=b61B2ykG7UT-evFfJcwJW_PVYnpC3Q@mail.gmail.com> |
--0000000000008dc9c2059836cfc1 Content-Type: text/plain; charset="UTF-8" On Monday, November 25, 2019, Bzzzz <[email protected]> wrote: > Hi list, > > I've got this table: > date_start timestamptz, > date_end temstamptz > > and I'd like to auto-generate a 3rd column with a tstzrange: > date_start timestamptz, > date_end temstamptz, > duration tstzrange GENERATED ALWAYS AS ( ? ) STORED > > but I can't find the right syntax to do so :/ (is it even possible ?) > > You should provide actual SQL without typos and also show which version your are using. Provide the error your are getting as well. Also: https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-CONSTRUCT David J. --0000000000008dc9c2059836cfc1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, November 25, 2019, Bzzzz <<a href=3D"mailto:[email protected]= ">[email protected]</a>> wrote:<br><blockquote class=3D"gmail_quote" sty= le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi lis= t,<br> <br> I've got this table:<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 date_start=C2=A0 =C2=A0 =C2=A0 timestamptz,<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 date_end=C2=A0 =C2=A0 =C2=A0 =C2=A0 temstamptz<= br> <br> and I'd like to auto-generate a 3rd column with a tstzrange:<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 date_start=C2=A0 =C2=A0 =C2=A0 timestamptz,<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 date_end=C2=A0 =C2=A0 =C2=A0 =C2=A0 temstamptz,= <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 duration=C2=A0 =C2=A0 =C2=A0 =C2=A0 tstzrange G= ENERATED ALWAYS AS ( ? ) STORED<br> <br> but I can't find the right syntax to do so :/ (is it even possible ?)<b= r><br> </blockquote><div><br></div><div>You should provide actual SQL without typo= s and also show which version your are using.=C2=A0 Provide the error your = are getting as well.</div><div><br></div><div>Also:</div><div><br></div><di= v><a href=3D"https://www.postgresql.org/docs/current/rangetypes.html#RANGET= YPES-CONSTRUCT">https://www.postgresql.org/docs/current/rangetypes.html#RAN= GETYPES-CONSTRUCT</a><br></div><div><br></div><div>David J.</div><div>=C2= =A0</div> --0000000000008dc9c2059836cfc1--