0

Consider tables cats and dogs in ani animals schema.

During sequences creation, sequence for cats.id used schema, whereas sequence for dogs.id didn't use schema:

create sequence ani.cats_id_seq
create sequence dogs_id_seq

How can I modify the dogs_id_seq so it also uses schema?

For example: ALTER SEQUENCE dogs_id_seq RENAME TO ani.dogs_id_seq this won't work.

2

See the documentation:

ALTER SEQUENCE dogs_id_seq SET SCHEMA ani;
2
  • Thanks. P.S. Would anyone share opinion whether it's better to use sequences with or without schemas, please?
    – weno
    Nov 17 '20 at 15:48
  • 1
    There are no sequences without schema. Perhaps you were creating it in the public schema. I'd always keep the sequences in the same schema as the tables they are used with. Nov 17 '20 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.