Re: Insert UUID GEN 4 Value

Поиск
Список
Период
Сортировка
От tango ward
Тема Re: Insert UUID GEN 4 Value
Дата
Msg-id CAA6wQLJr6fjzx+ZK6N4yiViZYdFuGGkMT27zsp-mR1SjAzbGEg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Insert UUID GEN 4 Value  (Laurenz Albe <laurenz.albe@cybertec.at>)
Ответы Re: Insert UUID GEN 4 Value  (tango ward <tangoward15@gmail.com>)
Re: Insert UUID GEN 4 Value  (Laurenz Albe <laurenz.albe@cybertec.at>)
Список pgsql-general
Hi,

thanks.

I found this:

CREATE
EXTENSION IF NOT EXISTS "uuid-ossp";
SELECT uuid_generate_v4();

My problem is I have a table like this:
CREATE TABLE enrollmentinfo (
    id integer NOT NULL,
    created timestamp with time zone NOT NULL,
    modified timestamp with time zone NOT NULL,
    secure_id uuid NOT NULL,
    relationship character varying(50) NOT NULL,
    tuition_bill character varying(255) NOT NULL
);

Now I need to insert data into this table, I just don't know if I can use something like this "INSERT INTO enrollmentinfo (current_timestamp, current_timestamp, uuid_generate_v4(), '', ''); I haven't tried this but also not sure if I can call the function inside INSERT.




On Thu, May 31, 2018 at 11:41 AM, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
tango ward wrote:
> I would like to know how to properly use uuid_generate_v4 when inserting data into PostgreSQL table.
>
> When I run the command select * from pg_available_extensions;
> I can see this uuid-ossp          | 1.0             |                   | generate universally unique identifiers (UUIDs)
>
> I am trying to find a basic and easy to understand documentation of it on how to use
> when inserting data because I have a column that is a uuid type.

Are you looking for this?

   ALTER TABLE tab ALTER col SET DEFAULT uuid_generate_v1();

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

В списке pgsql-general по дате отправления:

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: Insert UUID GEN 4 Value
Следующее
От: tango ward
Дата:
Сообщение: Re: Insert UUID GEN 4 Value