Re: is there any difference DROP PRIMARY KEY in oracle and postgres?

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: is there any difference DROP PRIMARY KEY in oracle and postgres?
Дата
Msg-id n1hkld$es3$1@ger.gmane.org
обсуждение исходный текст
Ответ на is there any difference DROP PRIMARY KEY in oracle and postgres?  (M Tarkeshwar Rao <m.tarkeshwar.rao@ericsson.com>)
Ответы Re: is there any difference DROP PRIMARY KEY in oracle and postgres?  (John R Pierce <pierce@hogranch.com>)
Список pgsql-general
M Tarkeshwar Rao schrieb am 06.11.2015 um 04:52:
> one thing in oracle is there any difference between “DROP PRIMARY
> KEY” used directly in oracle to drop primary key, or “DROP CONSTRAINT
> CDRAUDITPOINT_pk”, as first syntax is not available in postgres and
> we need to give primary key name as constraint to delete a key. SO
> right now to delete primary key I am using second approach, so is
> there any difference between two?


Unlike Oracle, Postgres gives the PK constraint a sensible (and reproducible) name.

So even if you did not specify a constraint name when creating the index, you know the name: it's always
"tablename_pkey".

The statement:

   create table foo (id integer primary key);

will create a PK constraint named "foo_pkey", and therefore you can drop it using:

   alter table foo drop constraint foo_pkey;

I don't know which name gets chosen when the table name is so long that adding _pkey it would yield an identifier that
istoo long (>63 characters) 

But having an "alter table drop primary key" would indeed be nice.

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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Deadlock detected after pg_repack receives SIGINT
Следующее
От: John R Pierce
Дата:
Сообщение: Re: is there any difference DROP PRIMARY KEY in oracle and postgres?