博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
flask sql外键使用_如何在SQL中使用外键?
阅读量:2529 次
发布时间:2019-05-11

本文共 1144 字,大约阅读时间需要 3 分钟。

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.

在本文中,我们学习了如何使用外键以及它如何工作以及对我们从关系数据库中检索数据有用吗? 希望您理解这个概念; 如果您有任何疑问,请随时在评论部分提问。

翻译自:

flask sql外键使用

转载地址:http://kvtzd.baihongyu.com/

你可能感兴趣的文章
函数指针与回调函数
查看>>
你所不知道的 CSS 滤镜技巧与细节
查看>>
hack reviewboard 让 FireFox 把 tab 显示为 4 或 2 个空格
查看>>
css 学习整理
查看>>
录制游戏视频——fraps
查看>>
jQuery 停止动画
查看>>
HTML基础之JS
查看>>
01背包问题python 2.7实现
查看>>
E - Kagome Kagome
查看>>
Android Studio Errors
查看>>
软件工程第二次作业—结对编程
查看>>
【字符编码】Java字符编码详细解答及问题探讨
查看>>
学习操作系统导图
查看>>
在线的JSON formate工具
查看>>
winform非常实用的程序退出方法!!!!!(转自博客园)
查看>>
xml解析
查看>>
centos安装vim
查看>>
linux工作调度(计划任务)
查看>>
HTTP协议形象展现
查看>>
hdu--1698 Just a Hook(线段树+区间更新+懒惰标记)
查看>>