How E-mail Works

拆解一个800G光模块:手把手带你认识里面的MT插芯和光纤阵列(FA) 本文详细拆解了800G光模块中的关键组件MT插芯和光纤阵列(FA),揭示了并行光学技术如何实现高速数据传输。通过显微镜下的精密观察,展示了MT插芯的高精度构造和光纤阵列的连接奥秘,同时解析了高精度研磨工艺对光信号传输的重要性。这些微型组件是高速收发模块实现800Gbps带宽的核心技术。 阅读详情
 

Every day the citizens of the Internet send each other billions of e-mail messages. If you are online a lot, you yourself may send a dozen or two e-mails each day without even thinking about it. Obviously, e-mail has become an extremely popular communication tool in a very short time!

Have you ever wondered how e-mail gets from your desktop to a friend halfway around the world? What is a POP3 server, and how does it hold your mail? The answers may surprise you, because it turns out that e-mail is an incredibly simple system at its core!

What is an E-mail Message?
Apparently, the first e-mail message was sent in 1971 by an engineer named Ray Tomlinson. Prior to this, you could only send messages to users on a single machine. Tomlinson's breakthrough was the ability to send messages to other machines on the Internet, using the @ sign to designate the receiving machine.

An e-mail message has always been nothing more than a simple text message, a piece of text sent to a recipient. When you send an e-mail message to a friend, you are sending a piece of text. In the beginning and even today, e-mail messages tend to be short pieces of text, although the ability to add attachments now makes many e-mail messages quite long. Even with attachments, however, e-mail messages continue to be text messages -- we'll see why when we get to attachments.

Understanding E-mail Clients
You have probably already received several e-mail messages today. To look at them you use some sort of e-mail client. Examples include stand-alone software, free Web e-mail service, and e-mail service that requires payments. No matter which type of client you are using, you know that an e-mail client generally does four things:

  • It shows you a list of all of the messages in your mailbox by displaying the message headers. The header shows you who sent the mail and the subject of the mail, and may also show the time and date of the message and the message size.
  • It lets you select a message header and read the body of the e-mail message.
  • It lets you create new messages and send them. You type in the e-mail address of the recipient and the subject for the message, and then type the body of the message.
  • Most e-mail clients also let you add attachments to messages you send and save the attachments from messages you receive.

    Sophisticated e-mail clients may have all sorts of bells and whistles, but at the core, this is all that an e-mail client does.

    Understanding a Simple E-mail Server
    Given that you have an e-mail client on your machine, you are ready to send and receive e-mail. All that you need is an e-mail server for the client to connect to. Let's imagine what the simplest possible e-mail server would look like in order to get a basic understanding of the process. Then we will look at the real thing.

    If you have read the How Stuff Works article entitled How Web Servers and the Internet Work, then you know that machines on the Internet can run software applications that act as servers. There are Web servers, FTP servers, telnet servers and e-mail servers running on millions of machines on the Internet right now. These applications run all the time on the server machine and they listen to specific ports waiting for people or programs to attach to the port. The simplest possible e-mail server might look like this:

  • It would have a list of e-mail accounts, with one account for each person who can receive e-mail on the server. My account name might be mbrain, John Smith's might be jsmith, and so on.
  • It would have a text file for each account in the list. So the server would have a text file in its directory named MBRAIN.TXT, another named JSMITH.TXT, and so on.
  • When someone wants to send me a message, the person composes a text message ("Marshall, Can we have lunch Monday? John") in an e-mail client, and indicates that the message should go to mbrain.
  • When the person presses the Send button, the e-mail client would attach to the e-mail server and pass to the server the name of the recipient (mbrain), the name of the sender (jsmith) and the body of the message.
  • The server would format those pieces of information and append them to the bottom of the MBRAIN.TXT file. The entry in the file might look like this:
    • From: jsmith
      To: mbrain
      Marshall, Can we have lunch Monday? John
 

There are several other pieces of information that the server might save into the file, like the time and date of receipt and a subject line, but overall you can see that this is an extremely simple process!

As other people send mail to mbrain, the server would simply append those messages to the bottom of the file in the order that they arrive. The text file would accumulate a series of five or 10 messages, and eventually I would log in to read them. When I want to look at my e-mail, my e-mail client would connect to the server machine. In the simplest possible system it would:

  • Ask the server to send a copy of the MBRAIN.TXT file.
  • Ask the server to erase and reset the MBRAIN.TXT file.
  • Save the MBRAIN.TXT file on my local machine.
  • Parse the file into the separate messages (using the word "From:" as the separator).
  • Show me all of the message headers in a list.

    When I double-click on a message header, it would find that message in the text file and show me its body.

    You have to admit that this is a VERY simple system. Surprisingly, the real e-mail system that you use every day is not much more complicated than this!

    Understanding the Real E-mail System
    For the vast majority of people right now, the real e-mail system consists of two different servers running on a server machine. One is called the SMTP Server, where SMTP stands for Simple Mail Transfer Protocol. The SMTP server handles outgoing mail. The other is a POP3 Server, where POP stands for Post Office Protocol. The POP3 server handles incoming mail. The SMTP server listens on well-known port number 25, while POP3 listens on port 110 . A typical e-mail server looks like this:

     

    e-mail server

    Understanding SMTP
    Whenever you send a piece of e-mail, your e-mail client interacts with the SMTP server to do the sending. The SMTP server on your host may have conversations with other SMTP servers to actually deliver the e-mail.

     

    SMTP Diagram

    Let's assume that I want to send a piece of e-mail. My e-mail ID is brain and I have my account on howstuffworks.com. I want to send e-mail to jsmith@mindspring.com. I am using a stand-alone e-mail client like Outlook Express.

    When I set up my account at howstuffworks, I told Outlook Express the name of the mail server -- mail.howstuffworks.com. When I compose a message and press the Send button, here is what happens:

  • Outlook Express connects to the SMTP server at mail.howstuffworks.com using port 25.
  • Outlook Express has a conversation with the SMTP server. The conversation is an extremely simple set of text commands and responses (see below). Outlook express tells the SMTP server the address of the sender and the address of the recipient, as well as the body of the message.
  • The SMTP server takes the "TO" address (for example, jsmith@mindspring.com) and breaks it into two parts: 1) the recipient name (jsmith) and 2) the domain name (mindspring.com). If the TO address had been another user at howstuffworks.com, the SMTP server would simply hand the message to the POP3 server for howstuffworks.com (using a little program called the delivery agent). Since the recipient is at another domain, SMTP needs to communicate with that domain.
  • The SMTP server has a conversation with a Domain Name Server and says, "Can you give me the IP address of the SMTP server for mindspring.com?" The DNS replies with the one or more IP addresses for the SMTP server(s) that Mindspring operates.
  • The SMTP server at howstuffworks.com connects with the SMTP server at Mindspring using port 25. It has the same simple text conversation that my e-mail client had with the SMTP server for How Stuff Works, and gives the message to the Mindspring server. The Mindspring server recognizes that the domain name for jsmith is at Mindspring, so it hands the message to Mindspring's POP3 server, which puts the message in jsmith's mailbox.

    If, for some reason, the SMTP server at How Stuff Works cannot connect with the SMTP server at Mindspring, then the message goes into a queue. The SMTP server on most machines uses a program called sendmail to do the actual sending, so this queue is called the sendmail queue. Sendmail will periodically try to resend the messages in its queue. For example, it might retry every 15 minutes. After four hours it will usually send you a piece of mail so that you know there is some sort of problem. After five days, most sendmail configurations give up and return the mail to you undelivered.

    The actual conversation that an e-mail client has with an SMTP server is incredibly simple and human readable. It is specified in public documents called Requests For Comments (RFC) and a typical conversation might look something like this:

    • helo test 250 mx1.mindspring.com Hello abc.sample.com [220.57.69.37], pleased to meet you mail from: test@sample.com 250 2.1.0 test@sample.com... Sender ok rcpt to: jsmith@mindspring.com 250 2.1.5 jsmith... Recipient ok data 354 Enter mail, end with "." on a line by itself from: test@sample.com to:jsmith@mindspring.com subject: testing John, I am testing... . 250 2.0.0 e1NMajH24604 Message accepted for delivery quit 221 2.0.0 mx1.mindspring.com closing connection Connection closed by foreign host.

    What the e-mail client says is in red, and what the SMTP server replies with is in green. The e-mail client introduces itself, indicates the from and to addresses, delivers the body of the message and then quits. You can, in fact, telnet to a mail server machine at port 25 and have one of these dialogs yourself -- this is how people "spoof" e-mail.

 

You can see that the SMTP server understands very simple text commands like HELO, MAIL, RCPT and DATA. The list of most common commands is:

  • HELO - introduce yourself
  • EHLO - introduce yourself and request extended mode
  • MAIL FROM: - specify the sender
  • RCPT TO: - specify the recipient
  • DATA - specify the body of the message. To:, From: and Subject: should be the first three lines.
  • RSET - reset
  • QUIT - quit the session
  • HELP - get help on commands
  • VRFY - verify an address
  • EXPN - expand an address
  • VERB - verbose

    Understanding the POP3 Server
    In the simplest implementations of POP3, the server really does maintain a collection of text files -- one for each e-mail account. When a message arrives, the POP3 server simply appends it to the bottom of the recipient's file!

    When you check your e-mail, your e-mail client connects to the POP3 server using port 110. The POP3 server requires an account name and a password. Once you have logged in, the POP3 server opens your text file and allows you to access it. Like the SMTP server, the POP3 server understands a very simple set of text commands. Here are the most common commands:

  • USER - enter your user ID
  • PASS - enter your password
  • QUIT - quit the POP3 server
  • LIST - list the messages and their size
  • RETR - retrieve a message number, pass it a message number
  • DELE - delete a message, pass it a message number
  • TOP - shows the top x lines of a message, pass it a message number and the number of lines

    Your e-mail client connects to the POP3 server and issues a series of commands to bring copies of your e-mail messages to your local machine. Generally it will then delete the messages from the server (unless you've told the e-mail client not to).

    You can see that the POP3 server simply acts as an interface between the e-mail client and the text file containing your messages. And again you can see that the POP3 server is extremely simple! You can connect to it through telnet at port 110 and issue the commands yourself if you would like .

    Understanding Attachments
    Your e-mail client allows you to add attachments to e-mail messages you send, and also lets you save attachments from messages that you receive. Attachments might include word processing documents, spreadsheets, sound files, snapshots, pieces of software, etc. Usually an attachment is not text (if it was, you would simply include it in the body of the message). Since e-mail messages can contain only text information and since attachments are not text, there is a problem that needs to be solved.

    In the early days of e-mail, you solved this problem by hand using a program called uuencode. The uuencode program assumes that the file contains binary information. It extracts three bytes from the binary file and converts them to four text characters (that is, it takes 6 bits at a time, adds 32 to the value of the 6 bits and creates a text character). What uuencode produces, therefore, is an encoded version of the original binary file that contains only text characters. In the early days of e-mail, you would run uuencode yourself and paste the uuencoded file into your e-mail message.

    Here is typical output from the uuencode program:

    • begin 644 reports
      M9W)E<" B<&P_(B O=F%R+VQO9R]H='1P9"]W96(V-C1F- BYA8V-<W,N;&]GM('P@8W5T("UF(#(@+60@(C/B('P@8W5T ("UF(#$@+60@(B8B(#X@<V5A<F-HM+61A=&$M)#$*?B]C; W5N="UP86=E<R!/('-O<G0@/B!S=&%T<RTD,0IC< " @M?B]W96)S:71E+V-G:2UB:6XO<W5G9V5S="UD871A+V1A= &$@<W5G9V5S="TDM,0IC<"!^+W=E8G-I=&4O8V=I+6)I;B ]W:&5R92UD871A+V1A=&$@=VAE<F4MM)#$*8W @?B]W96)S:7 1E+V-G:2UB:6XO96UA:6QE<BUD871A+V1A=&$@96UAL:6PM)# $*?B]G971L;V<@/B!L;V=S+20Q
      End
    The recipient would then save the uuencoded portion of the message to a file and run uudecode on it to translate it back to binary. The word "reports" in the first line tells uudecode what to name the output file.

    Modern e-mail clients are doing exactly the same thing, but they run uuencode and uudecode for you automatically. If you were to look at a raw e-mail file that contains attachments, you would find that the attachment is represented in the same uuencoded text format shown above!

    The Simplicity of E-mail
    From this description, you can see that today's e-mail system is one of the simplest things ever devised! There truly is nothing to it. There are parts of the system -- like the routing rules in sendmail -- that get complicated, but overall the system is as simple as it can possibly be.

    The next time you send an e-mail, you will now have the comfort of knowing exactly what is going on behind the scenes!

 
YOLO26 多模态融合技术:RGB+红外/深度/雷达融合 YOLO(You Only Look Once)是一种流行的目标检测算法,其最大特点是快速且端到端地完成图像中所有目标的检测与分类任务。YOLO首次在2016年由Joseph Redmon等人提出,彻底改变了传统目标检测(如R-CNN系列)的思路,被广泛应用于自动驾驶、视频监控、工业质检等场景。 阅读详情

相关推荐

工业视觉开发者的福音:用C#玩转VisionMaster算子(非方案版完整教程)

本文为工业视觉开发者提供了一份完整的C#与VisionMaster算子二次开发教程,详细介绍了环境配置、算子调用原理、性能优化技巧及实战案例。通过模板匹配和二维码识别等实例,展示了如何高效集成VisionMaster算子到现有框架中,提升工业自动化视觉检测系统的灵活性和性能。

weixin_29280657的博客 280

【Meta开源大模型Meta-Llama-3.1微调SFT】

Meta开源大模型Meta-Llama-3.1微调

AI最前沿 993

Ollama+FAISS+Embedding+Rerank+LLM 详细部署指南

下载安装Ollama 双击运行安装程序 安装完成后会自动启动服务 修改默认安装路径(避免C盘爆满) 或使用PowerShell: 验证安装 Linux系统部署: (二)准备模型 1. 拉取Embedding模型 2. 拉取LLM模型 注意:原文中提到的可能需要从自定义仓库拉取: 3. 下载Rerank模型 (三)安装依赖库 创建项目目录和虚拟环境: 二、主要功能实现 项目结构 (一)配置文件(config/config.yaml) (二)文本分块策略实现 创建 : (三)文档读取

AI技术改变世界 1601

mysql foreign key 用法_[转]MYSQL外键(Foreign Key)的使用

好久没有接触MySQL了,最近接到一个任务一来就是一大堆InnoDB,还有外键- - 网上发现了一篇很有意思的文章,转过来娱乐娱乐:) 外键的使用条件: 1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持); 2.外键好久没有接触MySQL了,最近接到一个任务一来就是一大堆InnoDB,还有外键- -网上发现了一篇很有意思的文章,转过来娱乐娱乐...

weixin_39522170的博客 190

CodeBuddy Code CLI 常用工作流:17个实战场景全解析

CodeBuddy Code CLI 17个实战场景解析 本文详细介绍了CodeBuddy Code CLI在17个开发场景中的高效应用,包括: 快速理解新代码库 高效修复Bug 安全重构代码 使用子代理系统处理专业任务 Plan Mode安全分析 自动化测试处理 创建合并请求 文档生成与维护 图片内容分析 文件目录快速引用 每个场景都配有具体命令示例和最佳实践,帮助开发者提升工作效率。

简简单单Onlinezuozuo 1106

企业数字化建设之——制造领域500强IT架构&落地

1.0 概念到市场,Idea to Market (ITM) ,集成产品开发 Integrated Product Development (IPD) ,产品从概念到上市的全生命周期管理,从客户中来,到客户中去,解决产品从0 - 1 的问题。14.0 流程、IT与变革管理,Manage Business Transformation & IT (MBT & IT),管理公司的业务流程、IT建设与组织变革。8.0 供应链管理,Supply Chain (SC),集成供应链管理,确保高效可靠的供应能力。

java_zhong1990的专栏 6225

mysql书外键_[转] mysql 外键(Foreign Key)的详解和实例

摘要: 外键具有保持数据完整性和一致性的机制,业务处理有着很好的校验作用。目前MySQL只在InnoDB引擎下支持,下面实例下一个小操作来说明下外键的关联操作,用来保持数据的完整性和一致性。============正文===============1、表引擎必须为InnoDB,MyISAM不支持2、外键必须建立索引(可以为普通、主键、唯一,事先不建立的话会自动创建一个普通索引),你要用的外键和参照...

weixin_33740934的博客 345

【CVPR2025 DEIM】超详细!手把手训练自己的数据集教学:从源码下载,配置虚拟环境,准备数据集、训练、验证、推理测试 ,实现0到1的完整教学过程。本文在win系统上训练,最强实时目标检测算法!

本文详细介绍了CVPR2025 DEIM目标检测模型的完整使用流程。内容包含:1)源码下载与虚拟环境配置;2)Visdrone2019数据集准备与配置文件修改;3)训练参数设置及Windows系统常见问题解决方案;4)模型验证、推理测试及热力图生成方法。特别针对Windows用户提供了虚拟环境配置指导,并详细说明了数据集路径设置、参数调整等关键步骤。通过本文的指导,小伙伴可以快速掌握DEIM模型的使用方法,用于学术论文研究和实验分析。

Ai缝合怪、助力小伙伴高效发论文 7761

mysql global foreign_MYSQL外键(Foreign Key)的使用[转]

在MySQL 3.23.44版本后,InnoDB引擎类型的表支持了外键约束。外键的使用条件:1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持);2.外键列必须建立了索引,MySQL4.1.2以后的版本在建立外键时会自动创建索引,但如果在较早的版本则需要显示建立;3.外键关系的两个表的列必须是数据类型相似,也就是可以相互转换类型的列,比如int...

weixin_32827751的博客 133

FPGA实现PID算法

PID 控制器表达式如下(引用某硕士论文 《基于FPGA的PID控制器研究与实现》): 其中,Kp为比例增益,Ti为积分时间常数,Td为微分时间常数,u(t)为控制量,e(t)为偏差。 在数字控制系统中,PID控制规律的实现必须用数值逼近的方法。当采样周期相当短时,用求和代替积分、用后向差分代替微分,使模拟PID离散化变为差分方程。 本文使用并行结构来实现。具有延时小,计算速度快的特点,但需要资源比较多。 利用图3.2所示并行结构实现方法 ,进一步将3.8式分解: ...

nxin168的博客 1万+

RDKit | 基于Pytorch和RDKit建立QSAR模型

QSAR 定量构效方法(quantitative structure-activity relationship, QSAR)是应用最为广泛的药物设计方法。所谓定量构效方法就是通过一些数理统计方法建立其一系列化合物的生理活性或某种性质与其物理化学性质之间的定量关系,通过这些定量关系。可以预测化合物的生理活性或某些性质,指导我们设计出具有更高活性的化合物。 早在...

DrugOne 5083

[转]MYSQL外键(Foreign Key)的使用

在MySQL 3.23.44版本后,InnoDB引擎类型的表支持了外键约束。 外键的使用条件: 1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持); 2.外键列必须建立了索引,MySQL 4.1.2以后的版本在建立外键时会自动创建索引,但如果在较早的版本则需要显示建立; 3.外键关系的两个表的列必须是数据类型相似,也就是可以相互转换类...

php程序员日志 288

【DEIM创新改进】 独家创新首发、注意力改进篇 | CVPR2025 | DEIM模型引入分层多头注意力 (HMHA) 机制, 从而捕获更具多样性的特征,含多种不同基准改进点,助力目标检测有效涨点

本文提出了一种基于分层多头注意力(HMHA)的改进DEIM网络模型。HMHA通过重排序和分层子空间划分使注意力头学习多样化特征,并结合查询-键缓存更新(QKCU)机制增强注意力头之间的交互。该方法包含HMHA和QKCU两个模块,有效解决了传统多头注意力(MHA)的冗余问题。文章详细介绍了HMHA模块的结构、优势及核心代码实现,并提供了改进模块的添加步骤和配置文件示例。该改进方案能有效提升特征多样性,增强头间交互性,提高模型可解释性,适用于各种计算机视觉复杂场景任务。

Ai缝合怪、助力小伙伴高效发论文 267

MYSQL外键(Foreign Key)的使用[转]

MYSQL外键(Foreign Key)的使用 在MySQL 3.23.44版本后,InnoDB引擎类型的表支持了外键约束。外键的使用条件:1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持);2.外键列必须建立了索引,MySQL 4.1.2以后的版本在建立外键时会自动创建索引,但如果在较早的版本则需要显示建立; 3.外...

weixin_30278311的博客 71

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

MYSQL外键(Foreign Key)的使用(转)

在MySQL 3.23.44版本后,InnoDB引擎类型的表支持了外键约束。 外键的使用条件: 1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持); 2.外键列必须建立了索引,MySQL 4.1.2以后的版本在建立外键时会自动创建索引,但如果在较早的版本则需要显示建立;  3.外键关系的两个表的列必须是数据类型相似,也就是可以相互转换

381

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

MYSQL外键(Foreign Key)的使用(转)

在MySQL 3.23.44版本后,InnoDB引擎类型的表支持了外键约束。外键的使用条件:1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持);2.外键列必须建立了索引,MySQL 4.1.2以后的版本在建立外键时会自动创建索引,但如果在较早的版本则需要显示建立;3.外键关系的两个表的列必须是数据类型相似,也就是可以相互转换类型的列,比如i...

weixin_30363509的博客 100

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

【转】【mysql】---Navicat --外键建立与cannot add foreign key constraint分析

【mysql】---Navicat --外键建立与cannot add foreign key constraint分析

了解—学习—进步—满足 179

[转]MySQL开发中的外键(foreign key)与参照完整性(Referential integrity)

转载自: 网络 参照完整性(Referential integrity)是数据库设计中一个重要的概念。在系统不同的列表中,当数据库所有参照合法或非合法关联时都会涉及到参照完整性。当参照完整性存在时,任何与不存在记录的关联将变得无效化,由此可防止用户出现各种错误,从而提供更为准确和实用的数据库。 参照完整性通常通过外键(foreign key)的使用而被广泛应用。长久以来,流行工具开源RDBMS...

weixin_34007886的博客 96

MySQL中的外键(foreign key)

MySQL中的外键(foreign key)

wgchen 4万+

mysql 外键(foreign key)的详解和实例

一、基本概念1、MySQL中“键”和“索引”的定义相同,所以外键和主键一样也是索引的一种。不同的是MySQL会自动为所有表的主键进行索引,但是外键字段必须由用户进行明确的索引。用于外键关系的字段必须在所有的参照表中进行明确地索引,InnoDB不能自动地创建索引。2、外键可以是一对一的,一个表的记录只能与另一个表的一条记录连接,或者是一对多的,一个表的记录与另一个表的多条记录连接。3、如果需要更好的...

差不多先生 12万+

MySQL的外键约束FOREIGN KEY

一、建立外键约束 语法如下: [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (col_name, ...) REFERENCES tbl_name (col_name,...) [ON DELETE reference_option] [ON UPDATE reference_option] reference_option: RESTRI...

灯火觅阑珊 6570

MYSQL外键(Foreign Key)的创建及使用

在MySQL 3.23.44版本后,InnoDB引擎类型的表支持了外键约束。 外键的使用条件: 1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持); 2.外键列必须建立了索引,MySQL 4.1.2以后的版本在建立外键时会自动创建索引,但如果在较早的版本则需要显示建立;  3.外键关系的两个表的列必须是数据类型相似,也就是可以相互转换

常思考->有目标->重实践->善反思 1万+

mysql启动和关闭外键约束的方法(FOREIGN_KEY_CHECKS)

在MySQL中删除一张表或一条数据的时候,出现[Err] 1451 -Cannot deleteor update a parent row: a foreign key constraint fails (...)这是因为MySQL中设置了foreign key关联,造成无法更新或删除数据。可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况。我们可以使用 SET FORE...

程序员囧辉 8万+

mysql外键的使用foreign key

一般来说,哪张表添加了外键约束foreign key,哪张表就是子表,而关键字references后面跟的就是主表。3、有表,有数据但没有外键的情况下添加外键:要注意,要选定作为外键列的数据和对应主表列的数据相匹配。2、有空表,有外键约束的情况下插入数据:要先给主表插入数据,在给子表插入数据。创建/添加外键约束,外键约束的名字是系统生成的,需要注意,而且我们再创建活添加的时候不需要给外键约束取名。cascade 同步主表动作,主表删除,子表同步删除,主表更新,子表也跟着更新。

qq_36961508的博客 1324

MySQL||外键约束(FOREIGN KEY)

外键 MySQL外键约束(FOREIGN KEY)用来在两个表的数据之间建立链接,它可以是一列或者多列。一个表可以有一个或多个外键。 外键的主要作用是保持数据的一致性、完整性。例如,学生表的主键是 code,成绩表中score 与这个 code关联。 主表(父表):对于两个具有关联关系的表而言,相关联字段中主键所在的表就是主表。 从表(子表):对于两个具有关联关系的表而言,相关联字段中...

JockLiu的博客 875

mysql外键约束案例_SQLServer FOREIGN KEY外键约束讲解及使用实例

FOREIGN KEY约束添加规则1、外键约束并不仅仅可以与另一表的主键约束相链接,它还可以定义为引用另一个表中 UNIQUE 约束的列。2、如果在 FOREIGN KEY 约束的列中输入非 NULL 值,则此值必须在被引用列中存在;否则,将返回违反外键约束的错误信息。若要确保验证了组合外键约束的所有值,请对所有参与列指定 NOT NULL。3、FOREIGN KEY 约束仅能引用位于同一服务器...

weixin_35715335的博客 1407
上一篇: 用VC写Assembly代码(5) --循环的使用(一)
下一篇: A sample that using the completion port I/O model
普通网友
博客等级 码龄22年 1万+粉丝 3156原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址