2

Is it necessary or important to rename table sequences and primary keys when we rename a table in PostgreSQL? Does it affect something?

2 Answers 2

1

Technically your database will keep working as always without the rename so I would say it depends. If your primary key has a generic name like id obviously it is still valid regardless of the new table name. If the name is in the form old_table_name_id or something like that then you have semantic inconsistency. In larger projects this can be confusing for humans. Good names are important just like they are in code so I would rename in this case. Same goes for sequences.

Sign up to request clarification or add additional context in comments.

Comments

1

No, unless you want to keep the names in sync to avoid confusing people.

The identity of an object is its Oid.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.