A question about inheritance and sequence

Поиск
Список
Период
Сортировка
От Marko Pahić
Тема A question about inheritance and sequence
Дата
Msg-id 4ae2a0950906240443t20f30de1hd2a78ac51715a9d9@mail.gmail.com
обсуждение исходный текст
Ответы Re: A question about inheritance and sequence  (Filip Rembiałkowski <plk.zuber@gmail.com>)
Re: A question about inheritance and sequence  (Joshua Tolley <eggyknap@gmail.com>)
Список pgsql-general
Hello,
I have two databases, and I want the same structure, and if I change the structure of one database it changes the structure of the other. In documentation I saw that the syntax goes something like this: CREATE TABLE "User" () INHERITS database2."User"; But it's not working like this, and I couldn't find the example. Can you please write the correct example?

The other problem I have if with sequence. I have this table structure:
CREATE TABLE "Notes" (
    userkey character(40) NOT NULL,
    noteid SERIAL NOT NULL,
    note text,
    PRIMARY KEY (userkey, noteid),
    FOREIGN KEY (userkey) REFERENCES "User"(userkey) ON UPDATE CASCADE ON DELETE CASCADE
);

How can I make the noteid go from 1 to max for each user? Because if I add a row it goes +1 for all users? How would I do that the note id would go +1 for each userkey. Do I have to make nested queries and where would I do it?
Thank you for help.

Regards,
Marko Pahić

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

Предыдущее
От: Gus Gutoski
Дата:
Сообщение: Re: help with data recovery from injected UPDATE
Следующее
От: Jasen Betts
Дата:
Сообщение: Re: Inserting Values into Interval