integer column to serial "type"

Поиск
Список
Период
Сортировка
От Linos
Тема integer column to serial "type"
Дата
Msg-id 50895B97.4070008@linos.es
обсуждение исходный текст
Ответы Re: integer column to serial "type"  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: integer column to serial "type"  (Raymond O'Donnell <rod@iol.ie>)
Список pgsql-general
Hello,
    there is some way to get and old integer primary key column to show the "type"
serial at table description?

I had a table like this:

CREATE TABLE test
(
  test_id integer NOT NULL,
  CONSTRAINT test_pkey PRIMARY KEY (test_id),
);


that i would like to see as:

CREATE TABLE test
(
  test_id serial NOT NULL,
  CONSTRAINT test_pkey PRIMARY KEY (test_id),
);


i have tried with:

CREATE SEQUENCE test_test_id_seq;
ALTER TABLE test ALTER COLUMN test_id SET DEFAULT
nextval('test_test_id_seq'::regclass);
ALTER SEQUENCE test_test_id_seq OWNED BY test.test_id;


and now i have this table:

CREATE TABLE test
(
  test_id integer NOT NULL DEFAULT nextval('test_test_id_seq'::regclass),
  CONSTRAINT test_pkey PRIMARY KEY (test_id),
);


i know this works the same as serial but do i have some way to get this table to
show me test_id column as "serial" type without have to recreate the table and
restore original rows?

Regards,
Miguel Angel.


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

Предыдущее
От: Martin Gainty
Дата:
Сообщение: Re: migrate from PostgreSQL to Oracle
Следующее
От: Tom Lane
Дата:
Сообщение: Re: integer column to serial "type"