Обсуждение: type list

Поиск
Список
Период
Сортировка

type list

От
"Jean-Yves F. Barbier"
Дата:
Hi list,

How can I list all values I gave to a type I created?

JY
--
We are the people our parents warned us about.

Re: type list

От
Merlin Moncure
Дата:
On Mon, Dec 12, 2011 at 3:29 PM, Jean-Yves F. Barbier <12ukwn@gmail.com> wrote:
> Hi list,
>
> How can I list all values I gave to a type I created?

what kind of type -- an enum?

in psql, you can break down enums with \dT+

postgres=# create type foo as enum ('a', 'b', 'c');
CREATE TYPE
Time: 13.000 ms
postgres=# \dT+ foo
                      List of data types
 Schema | Name | Internal name | Size | Elements | Description
--------+------+---------------+------+----------+-------------
 public | foo  | foo           | 4    | a       +|
        |      |               |      | b       +|
        |      |               |      | c        |
(1 row)


merlin

getting auto increment id value

От
M. Emre Çolak
Дата:
Hi,
    I have a table and it's only distinct value is it's auto incremented id.
I need to insert like 80.000 rows at ones so I have some time issues.
Problem is I need a way to get a return value which is id of my inserted row
since I need that id for another insert action. I think I should use a
function for this but I am not sure how I can get Id of my inserted row.
Thanks.
M. Emre Çolak


Re: type list

От
"Jean-Yves F. Barbier"
Дата:
On Mon, 12 Dec 2011 17:20:15 -0600
Merlin Moncure <mmoncure@gmail.com> wrote:

Sorry for the late answer.

> On Mon, Dec 12, 2011 at 3:29 PM, Jean-Yves F. Barbier <12ukwn@gmail.com> wrote:
> > Hi list,
> >
> > How can I list all values I gave to a type I created?
>
> what kind of type -- an enum?

Yep

> in psql, you can break down enums with \dT+
>
> postgres=# create type foo as enum ('a', 'b', 'c');
> CREATE TYPE
> Time: 13.000 ms
> postgres=# \dT+ foo
>                       List of data types
>  Schema | Name | Internal name | Size | Elements | Description
> --------+------+---------------+------+----------+-------------
>  public | foo  | foo           | 4    | a       +|
>         |      |               |      | b       +|
>         |      |               |      | c        |

Thanks, I'm gonna log and analyse the corresponding query.

--
It's all right letting yourself go as long as you can let yourself
back. -- Mick Jagger

Re: type list

От
Merlin Moncure
Дата:
On Sun, Dec 18, 2011 at 10:43 AM, Jean-Yves F. Barbier <12ukwn@gmail.com> wrote:
> On Mon, 12 Dec 2011 17:20:15 -0600
> Merlin Moncure <mmoncure@gmail.com> wrote:
>
> Sorry for the late answer.
>
>> On Mon, Dec 12, 2011 at 3:29 PM, Jean-Yves F. Barbier <12ukwn@gmail.com> wrote:
>> > Hi list,
>> >
>> > How can I list all values I gave to a type I created?
>>
>> what kind of type -- an enum?
>
> Yep
>
>> in psql, you can break down enums with \dT+
>>
>> postgres=# create type foo as enum ('a', 'b', 'c');
>> CREATE TYPE
>> Time: 13.000 ms
>> postgres=# \dT+ foo
>>                       List of data types
>>  Schema | Name | Internal name | Size | Elements | Description
>> --------+------+---------------+------+----------+-------------
>>  public | foo  | foo           | 4    | a       +|
>>         |      |               |      | b       +|
>>         |      |               |      | c        |
>
> Thanks, I'm gonna log and analyse the corresponding query.

yeah...another way to do that is via psql -E, which echos internally
thrown queries to the console.

merlin

Re: getting auto increment id value

От
Josh Kupershmidt
Дата:
On Tue, Dec 13, 2011 at 3:52 AM, M. Emre Çolak <memrecolak@hotmail.com> wrote:

>   I have a table and it's only distinct value is it's auto incremented id. I
> need to insert like 80.000 rows at ones so I have some time issues. Problem
> is I need a way to get a return value which is id of my inserted row since I
> need that id for another insert action. I think I should use a function for
> this but I am not sure how I can get Id of my inserted row.

Use INSERT INTO tbl ... RETURNING your_auto_inc_column. See also the
docs for the RETURNING clause at:
  http://www.postgresql.org/docs/current/static/sql-insert.html

Josh