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ć