Re: in PostgreSQL 9.0.2 / pgAdmin III - ERROR: relation "[table name]" already exists

Поиск
Список
Период
Сортировка
От Mark Kelly
Тема Re: in PostgreSQL 9.0.2 / pgAdmin III - ERROR: relation "[table name]" already exists
Дата
Msg-id 201012251539.28830.pgsql@wastedtimes.net
обсуждение исходный текст
Ответ на in PostgreSQL 9.0.2 / pgAdmin III - ERROR: relation "[table name]" already exists  (thewhitelantern <thewhitelantern@gmail.com>)
Список pgsql-novice
Hi.

On Saturday 25 Dec 2010 at 15:10 thewhitelantern wrote:

[snip]

> However, I'm called to put a WHERE filter on the code at the end
>
> WHERE
>   id = 524
> ;
>
> THen when I try to execute it again, it gives this error message
>
> ERROR:  relation "entries" already exists

I suspect that you are running ALL of the code above again, with the "WHERE"
clause appended. What you actually need to do is ONLY run the SELECT
instruction again. The error is because you are trying to create the table
(called a "relation" in this context) again.

Instead of running the whole lot again the second time, just run the query:

SELECT
  title
, category
FROM
  entries
WHERE
  id = 524
;

All the stuff before that only has to be done once.

> So does this mean that I have to delete the database EVERY TIME I CHANGE
>  THE CODE?!?

No :)

Cheers,

Mark

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

Предыдущее
От: thewhitelantern
Дата:
Сообщение: in PostgreSQL 9.0.2 / pgAdmin III - ERROR: relation "[table name]" already exists
Следующее
От: Lew
Дата:
Сообщение: Re: Problem with select statement for duplicate data