How to Add Primary Key and Foreign key in SQL Table by SQL Script
In this video I have shown how to add a Primary Key and foreign key relation in SQL Server table field by SQL Script
For this case we can set it by creating Primary key and foreign constraint by which every data will have a relation to other related table data through the Constraint and will show an error if any extra data tried to insert.
Which table contain only primary key is called parent table and another table is called child table which consist of Primary key and foreign key reference.
Foreign key increase the integrity and reduce the complexity.
These process can be done by two ways: by design view and SQL script.
Here is the Syntax of SQL Script:
SYNTAX:
Parent table :
CREATE TABLE TableName01
(
FieldnameABCD datatype PRIMARY KEY NOT NULL,
- - - - - - -
Fieldname nth datatype,
)
CREATE TABLE TableName02
(
Fieldname01 datatype PRIMARY KEY NOT NULL,
- - - - - - -
Fieldname nth datatype,
FieldnameABCD FOREIGN KEY REFERNCES TableName01 (FieldnameABCD)
)
DESIGN VIEW:
Process Steps:
1. Create Two table with primary key
2. Right Mouse Click on Child table – Relations – Add
3. Click on – Table and Column Specific -- Select Primary Key Table and field and on right side select foreign key table corresponding field – OK – Close
4. Then Save the table Again with changes.
To delete the unique constraint: Expand Table from Object explorer - - Select Created Constraint under Key Tab – Right mouse -- Delete
To find the code I have written in this video, join to our facebook group by clicking following link:
https://www.facebook.com/groups/ITSolution365/permalink/2720373388004881/
You can also like to our facebook Page to get all video code clicking on following link:
https://www.facebook.com/permalink.php?story_fbid=587401285061843&id=562632724205366
You can follow us on twitter clicking on following link:
https://twitter.com/ITSolut62078624
We will create thousands of video related with information technology from our practical experience and those are used in our daily work and development. Stay with us.
Do like, share and comments and subscribe to my channel and click on bell button to get notification when new video uploaded. You may suggest me to make new video with new topic.
My Channel Subscription link:
https://www.youtube.com/channel/UCoARYODbMPNO26wMpPE0R6g?sub_confirmation=1
Thanks again
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «How to Add Primary Key and Foreign key in SQL Table by SQL Script», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.