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:

Foreign-table-1

Table 2:

表2:

Foreign-table-2

First create a primary key in first table which is also called unique key.

首先在第一個表中創建一個主鍵,也稱為唯一鍵。

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.

第二個通過使用第二個表創建外鍵。

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.

查詢以從數據庫中找到學生的姓名,地址和聯系方式。

Foreign result

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.

在本文中,我們學習了如何使用外鍵以及它如何工作以及對我們從關系數據庫中檢索數據有用嗎? 希望您理解這個概念; 如果您有任何疑問,請隨時在評論部分提問。

翻譯自: https://www.includehelp.com/sql/how-to-use-foreign-key-in-sql.aspx

flask sql外鍵使用

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/540921.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/540921.shtml
英文地址,請注明出處:http://en.pswp.cn/news/540921.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

php發展歷,PHP的發展歷程

PHP的發展歷程了解一門語言,我們必須知道這門語言的發展史,現在我通過版本的變化以時間軸的形式來說明PHP的發展歷程。1.1995年初PHP1.0誕生Rasmus Lerdof發明了PHP,這是簡單的一套Perl腳本,用來跟蹤訪問者的信息。這個時候的PHP只…

中國互聯網安全大會將召開 網絡安全再獲關注

從2016中國互聯網安全大會籌委會獲悉,將于8月16日在國家會議中心召開的第四屆中國互聯網安全大會籌備工作已全部就緒。 據經濟參考報7月15日消息,中國網絡空間安全協會副理事長、360公司總裁兼企業安全集團董事長齊向東表示,此次中國互聯網安…

合并排序算法排序過程_外部合并排序算法

合并排序算法排序過程外部分類 (External sorting) External sorting is a technique in which the data is stored on the secondary memory, in which part by part data is loaded into the main memory and then sorting can be done over there. Then this sorted data wi…

php榛子云短信驗證,java + maven +榛子云短信 實現發送短信驗證碼功能

如何使用java maven的項目環境發送短信驗證碼,本文使用的是榛子云短信的接口。下載下來是jar文件,需要將jar發布到本地的maven倉庫中, 在cmd環境下輸入:mvn install:install-file -DgroupIdcom.zhenzi -DartifactIdsms -Dversion1.0.0 -Dpac…

django css_在應用程序上實現CSS Django的

django cssCSS (Cascade Style Sheets) are used to implement design. CSS(級聯樣式表)用于實現設計。 Step 1: Create a Sandbox, Activate it, Install Django and Create Sample Project 步驟1:創建一個沙箱,將其激活,安裝Django并創建示…

PHPWeb開發入門體驗學習筆記

PHPWeb開發入門體驗學習筆記4一、PHP web應用開發須知1.入門要點程序員三個階段:碼農(速成技能)->工程師(長期知識)->專家(研究論文)編程三要素:聲明變量(系統、全…

vb mysql 表格顯示,在VB中編輯數據庫和電子表格

在VB50中有很多功能強大的控件,其中數據控件與一些綁定控件(如文本框,圖片框及 ActiveX控件)的相互協作,能夠方便地實現對各種數據庫記錄、表格乃至電子表格的瀏覽和編輯操作。下面介紹實例,其中數據控件用于記錄的瀏覽、移動、…

c# datetime._C#| DateTime.AddTicks()方法與示例

c# datetime.DateTime.AddTicks()方法 (DateTime.AddTicks() Method) DateTime.AddTicks() method is used to return a new date-time object that adds ticks value of this instance. This object does not change the original value of date-time but it returns an objec…

12345組成三個不重復數java,求大神幫忙!五子棋!只能識別按順序識別!例如 12345 不能...

該樓層疑似違規已被系統折疊 隱藏此樓查看此樓import java.util.Arrays;import java.util.Scanner;public class Gobang {public static void main(String[] args) {Scanner sc new Scanner(System.in);boolean finish false;// 有戲是否結束int flagNum 1;// 當前下棋者標記…

[轉]Visual Studio 各版本下載

原文地址:[置頂] Visual Studio 各版本下載 文件名稱文件大小百度網盤下載微軟官方下載Visual Studio 2015 Enterprise - 企業版 - 簡體中文3.89GBhttp://pan.baidu.com/s/1bnAY68Bvs2015.ent_chs.isoVisual Studio 2015 Professional - 專業版 - 簡體中文3.84GBht…

JavaScript中的“ this”關鍵字

JavaScriptthis關鍵字 (JavaScript this keyword) The this keyword is widely used in JavaScript. It has many use cases and is also one of the most intimidating features of JavaScript. In most of the programming languages, this is used to refer to the current …

oracle 列級外鍵,Oracle外鍵列上是否需要索引?

外鍵列上缺少索引會帶來兩個問題,限制并發性、影響性能。而這兩個問題中的任意一個都可能會造成嚴重性能問題。 無論是Or外鍵列上缺少索引會帶來兩個問題,限制并發性、影響性能。而這兩個問題中的任意一個都可能會造成嚴重性能問題。無論是Oracle的官方文…

python 改變詞典順序_按詞典順序排列的功率集

python 改變詞典順序Description: 描述: This is a standard interview problem to find out the power sets in lexicographic order of a given set of numbers using backtracking. 這是一個標準的面試問題,它使用回溯來按給定數字集的字典順序查找能…

oracle創建用戶名了,oracle創建用戶名

創建用戶//創建用戶名create user username identified by password‘’//賦權限Grant Connect,Resource,DBA to UserName;plsql developer配置下載地址http://ah1.down.chinaz.com/201011/plsql8.04cn.zip右擊"我的電腦" - "屬性" - "高級" - &…

webpack學習筆記1

webpack學習筆記1:基本概念 前言: 現在在日常的開發中,webpack已經是必不可少的東西了,現在的需求基本都是用webpack對資源進行打包整合,所以打算寫一點關于webpack的東西,這是第一篇,主要是介紹…

ruby 嵌套函數_Ruby嵌套有示例的循環

ruby 嵌套函數嵌套循環 (Nested for loop) Nesting of for loop means one for loop is available inside another for loop. It means that there are two loops, then the first one is an outer loop and the second one is the inner loop. Execution will take place in t…

oracle10數據庫鏈接失敗,Oracle10g出現Enterprise Manager 無法連接到數據庫實例解決辦法...

剛裝好 10g 時,把的監聽端口是1521.后來把端口改成了1568了,登上em發現Enterprise Manager 無法連接到數據庫實例 ,連接字符串的端口仍是1521,如何解決這個問題。登陸:出現下面錯誤:Enterprise …

springJdbc in 查詢,Spring namedParameterJdbcTemplate in查詢

springJdbc in 查詢,Spring namedParameterJdbcTemplate in查詢, SpringJdbc命名參數in查詢,namedParameterJdbcTemplate in查詢 >>>>>>>>>>>>>>>>>>>>>>>>>>…

oracle 11g r2版本號,Oracle 11g r2新增版本功能(二)

在11.2中,Oracle數據庫引入的版本的概念,這為應用程序的升級提供了極大的方便。這篇簡單描述版本的實現和查詢方式。前一篇簡單描述了版本,下面接著上面的例子看看Oracle是如何實現這個功能的:SQL> select synonym_name, table…

python 添加圖例_Python | 在圖例標簽中添加Sigma

python 添加圖例Sigma (𝜎) is very often used greek mathematical letters and has a higher repetition in probability. In this article, we are going to add 𝜎 using a command in matplotlib. Sigma(𝜎)是希臘數學字母中經常使用的字…