flask sql外键使用_如何在SQL中使用外键?
flask sql外鍵使用
Basically, Foreign Key represents relationship between tables.
基本上, 外鍵代表表之間的關系 。
Syntax:
句法:
column-name data_type (size) CONSTRAINT constraint-name References Table-name (Column-name)Example:
例:
Table 1:
表格1:
Table 2:
表2:
First create a primary key in first table which is also called unique key.
首先在第一個表中創(chuàng)建一個主鍵,也稱為唯一鍵。
Like this:
像這樣:
create table student (enroll number(6) primary key, s_name varchar(25), address varchar2(20), contact number(10) );Second create foreign key by using second table.
第二個通過使用第二個表創(chuàng)建外鍵。
Like this:
像這樣:
create table student_fees (enroll number(6) constraint en_fk References Student (enroll) , course_fee number(8), status varchar2(6), amount number(10) );Query to find student name, address, contact from the database.
查詢以從數(shù)據(jù)庫中找到學生的姓名,地址和聯(lián)系方式。
Conclusion:
結論:
In this article, we have learnt how to use foreign key and how it works and useful for us to retrieve data from the relational database? I hope you understand the concept; if you have any query, feel free to ask in the comment section.
在本文中,我們學習了如何使用外鍵以及它如何工作以及對我們從關系數(shù)據(jù)庫中檢索數(shù)據(jù)有用嗎? 希望您理解這個概念; 如果您有任何疑問,請隨時在評論部分提問。
翻譯自: https://www.includehelp.com/sql/how-to-use-foreign-key-in-sql.aspx
flask sql外鍵使用
總結
以上是生活随笔為你收集整理的flask sql外键使用_如何在SQL中使用外键?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [转载] 【python魔术方法】迭代器
- 下一篇: c语言存储类_C编程语言的存储类