Re: PostgreSQL 9.6: view based on sequence - Mailing list pgsql-general

From Vincenzo Romano
Subject Re: PostgreSQL 9.6: view based on sequence
Date
Msg-id CAHjZ2x5RvdSOvZrM9JA_0z6ihvbTRbKwO63aQ3gkwecvpthcjg@mail.gmail.com
Whole thread Raw
In response to PostgreSQL 9.6: view based on sequence  (Enrico Pirozzi <e.pirozzi@nbsgroup.it>)
Responses Re: PostgreSQL 9.6: view based on sequence  (Enrico Pirozzi <e.pirozzi@nbsgroup.it>)
Re: PostgreSQL 9.6: view based on sequence  (Enrico Pirozzi <e.pirozzi@nbsgroup.it>)
List pgsql-general
2018-01-24 12:52 GMT+01:00 Enrico Pirozzi <e.pirozzi@nbsgroup.it>:
> Hi, I was doing a test on a 9.6 and I've seen a strange thing
>
> if I run
>
> create sequence test_sequence;
> create view v_test_sequence as select * from test_sequence;
>
> PostgreSQL creates a view based on the sequence and the strange thing  is
> that, among the various fields that are created in the view,
> there is a field named  sequence_name  with datatype  name.
>
> I've seen in the docs
> https://www.postgresql.org/docs/9.6/static/datatype-character.html
> and the datatype name should be reserved only for structures internal of PG.
>
> Does anyone help me?
>
> Enrico
>
>
>
> --
> Enrico Pirozzi
> e.pirozzi@nbsgroup.it
>
>

tmp1=# create sequence x;
CREATE SEQUENCE
Time: 69,857 ms
tmp1=# select * from x;
last_value | log_cnt | is_called
------------+---------+-----------
         1 |       0 | f
(1 row)

Maybe what you want to do is

create view v_test_sequence as select nextval( 'test_sequence' );

Ciao.

-- 
Vincenzo Romano - NotOrAnd.IT
Information Technologies
--
NON QVIETIS MARIBVS NAVTA PERITVS


pgsql-general by date:

Previous
From: Enrico Pirozzi
Date:
Subject: PostgreSQL 9.6: view based on sequence
Next
From: Enrico Pirozzi
Date:
Subject: Re: PostgreSQL 9.6: view based on sequence