How do I alter an existing column and add a foreign key which is aPrimary key to a table?
В списке pgsql-admin по дате отправления:
| От | Karen Goh |
|---|---|
| Тема | How do I alter an existing column and add a foreign key which is aPrimary key to a table? |
| Дата | |
| Msg-id | 820008379.2579287.1563670685484@mail.yahoo.com обсуждение исходный текст |
| Ответы |
Re: How do I alter an existing column and add a foreign key which isa Primary key to a table?
Re: How do I alter an existing column and add a foreign key which is a Primary key to a table? |
| Список | pgsql-admin |
Hi all,
I used to write a script in MYSQL and foreign and primary key will be created.
With PG4Admin, I am lost.
I realised now that the keys are not created and perhaps that is why the join query is not working out.
Please let me know what is the correct way to alter a column in a table to have foreign key to a tutor_id which is also
theprimary key of that table.
So, meaning I need to create a foreign key as well as primary key for tutor_id.
So far, this is what I have attempted but it is not working.
ALTER TABLE tutor_subject
ADD CONSTRAINT tutor_subject_pk
PRIMARY KEY (tutor_id)
ADD CONSTRAINT tutor_subject_fk
FOREIGN KEY (tutor_id)
Please help me on this.
Thanks.
В списке pgsql-admin по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера