Skip to content
Advertisement

How to add a column default?

I created a Postgres DB which contains 5 tables. Then I realized that the column student.student_id lacks a column default to generate an UUID:

Knowing that some tables are linked to the student table, how can I add to the function as column default for student_id so that the result will be:

Advertisement

Answer

Use ALTER TABLE:

Column defaults do not conflict with FOREIGN KEY references.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement