A question about inheritance and sequence - Mailing list pgsql-general

From Marko Pahić
Subject A question about inheritance and sequence
Date
Msg-id 4ae2a0950906240443t20f30de1hd2a78ac51715a9d9@mail.gmail.com
Whole thread Raw
Responses Re: A question about inheritance and sequence
Re: A question about inheritance and sequence
List 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 by date:

Previous
From: Gus Gutoski
Date:
Subject: Re: help with data recovery from injected UPDATE
Next
From: Jasen Betts
Date:
Subject: Re: Inserting Values into Interval