Re: Need a sample Postgre SQL script

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Need a sample Postgre SQL script
Дата
Msg-id 486A4268.3080107@archonet.com
обсуждение исходный текст
Ответ на Need a sample Postgre SQL script  ("Dhanushka Samarakoon" <dhanu80@gmail.com>)
Ответы Re: Need a sample Postgre SQL script  ("Dhanushka Samarakoon" <dhanu80@gmail.com>)
Список pgsql-sql
Dhanushka Samarakoon wrote:
> Hi All,
> 
> I'm kind of new to Postgre and I need some advice.

No problem. It's PostgreSQL or Postgres by the way.

> I have the following table.
> metadata (value:integer , field:integer , mydate:text)
> 
> given below is a sample record from that.
> ( 2 , 16 , Augest 2009)
> 
> I need a script that will read the above table and for each such row it will
> insert two rows as below.
> 
> ( 2 , 91 , Augest )
> ( 2 , 86 , 2009 )
> 
> 16, 91 and 86 are static values. *value and field together* creates the
> primary key.

CREATE TEMP TABLE staticfields (f integer);
INSERT INTO staticfields VALUES (91);
INSERT INTO staticfields VALUES (86);

INSERT INTO metadata (value, field, mydate)
SELECT value, f, mydate
FROM metadata, staticfields;

--   Richard Huxton  Archonet Ltd


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

Предыдущее
От: "Dhanushka Samarakoon"
Дата:
Сообщение: Need a sample Postgre SQL script
Следующее
От: "Dhanushka Samarakoon"
Дата:
Сообщение: Re: Need a sample Postgre SQL script