Navicat cannot add foreign key constraint或者添加外键后不显示

Navicat外键约束实战:从表设计到引用操作详解 本文详细介绍了如何使用Navicat进行外键约束的实战操作,从表设计到引用操作的全流程解析。通过可视化表设计器,开发者可以轻松设置外键约束,确保MySQL和PostgreSQL数据库的数据一致性。文章还涵盖了更新与删除规则、常见错误排查及性能优化建议,帮助用户高效管理数据库关系。 阅读详情

    首先我们要明确不能添加外键的原因有很多种,我遇到的也只是其中一种在这里分享出来。如果能帮到大家就再好不过了。

  • 右键—>设计表。 检查你的数据库引擎是什么, 因为我建的表数据库默认引擎是MyISAM,所以我添加外键后并不会在外键栏里面显示我添加的外键。
    这里写图片描述

  • 那我们就要改为下图所示,然后再添加外键:

这里写图片描述


  • 就可以成功了

    这里写图片描述

如果你的还是报错不能添加外键,那么有可能还有其他原因。比如你的数据表里有数据,你可以尝试清除数据再试试。

小程序选项卡以及swiper套用(跨页面) 选项卡tab和swpier之间的套用 其实我之前写过一篇选项卡的切换demo,大家阔以参考一下 小程序多个选项卡切换 那今天写这个demo呢,是因为项目需求,所以仅供参考。 我是拿到了home.wxml的数组下标, 通过url传参的方式去将这个id传到下一个页面, 下一个页面接收以后再将id赋值给对应的tabI或者currentId(swiper 的下标) 实现上一个页面进来以后直接进入对应的页... 阅读详情

相关推荐

DRAM内存模拟持久化设备的方法

由于持久化内存介质NVM技术的发展,越来越多的科研工作者投身到NVM相关的研究当中。但由于目前工业界并没有推出广泛使用的NVM介质设备,所以科研工作都需要自己以现有的条件,模拟NVM设备使用场景。一个简单的方法是:通过修改DRAM模拟器,达到模拟NVM的目的(可以参考:DRAMSim2模拟器分析与应用)。更高端的方式是:在真实系统中,将内存划分出一块儿,用来模拟NVM设备(类似于传统的ramdis

酷炫人笨笨熊 1898

navicat 添加外键保存后消失

后发现是因为新建表的时候默认引擎是MyISAM,不支持外键。使用navicat 添加外键保存后消失,并且没有任何提示。在设计表选项->引擎 中修改为InnoDB即可。

weixin_54143609的博客 1644

ArcGIS栅格拼接全攻略:从核心原理到色彩平衡与大数据处理

在GIS数据处理中,栅格拼接是一项基础且关键的操作,其本质是将多幅具有重叠区域的栅格图像无缝整合为一张完整地图。该技术涉及空间参考统一、像元对齐与色彩融合等核心原理,是构建连续地理空间数据的基石。其技术价值在于保障数据完整性、提升可视化效果,并为后续的空间分析提供可靠底图。在遥感影像处理、数字高程模型构建及地图制图等应用场景中,高质量的拼接成果至关重要。本文聚焦于ArcGIS平台,深入解析其栅格拼接工具,并针对常见的色彩不一致与大数据量处理难题,提供了基于**色彩平衡**和**金字塔**优化的实战解决方案,

weixin_33158887的博客 261

在navicat中建外键时,保存后就全部消失的解决方法

1、注意在设计表的时候,要把选项里面的引擎选为InnoDB,因为InnoDB提供事务支持已及外部键等高级数据库功能。关于MySQL表的类型可以参见 浅谈mysql表类型。 2、然后在一个表中建立外键,选中“外键”选项卡,输入参照完整性的名称,选择哪个属性为外键,选择以哪个表中的主键作为外键等等。然后点击保存。注意如果这时出现问题,可以查看主键外键是否是相同类型,如果主键外键都是数值型则要在设计表...

xiaoxuan1025的博客 2435

组态王|组态王通过选择日期实现历史数据的查询

②在弹出的【插入通用控件】对话框选择【Calender Control】控件,然后点击【确定】按钮,关闭对话框,然后在画面上适当的位置按住鼠标左键并拖动,绘制出一个矩形框,放开鼠标,就完成了控件的绘制。此函数将指定的时间格式(年,月,日,时,分,秒)转换为以秒为单位的长整型数,转换的时间基准是UTC(格林尼治)1970年1月1日00:00:00。实现内容,通过两个日历控件选择开始日期和结束日期,然后点击【历史数据查询】按钮,在报表中显示对应时间段的数据集。另外你用过哪些组态软件?

做有价值的事,积累有价值的笔记! 4557

GBASE南大通用GBase 8s数据库-从零开始的手动安装与实例配置指南

本文详细介绍了GBASE南大通用GBase 8s数据库的手动安装与实例配置全过程,包括环境准备、用户创建、安装包准备、实例创建、环境变量配置等关键步骤。通过实战经验分享和常见问题解决方案,帮助用户快速掌握GBase 8s数据库的安装与配置技巧,确保数据库稳定运行。

weixin_29209825的博客 454

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

前言: 用Navicat为mysql数据库的两个表之间建立外键关系,出现“cannot add foreign key constraint”错误,当时真的不知道是怎么回事儿,~~~~(>_ 外键建立: 把表t_stuschoolregisterinfo的IDCard字段设成外键,关联表t_stupersoninfo的IDCard字段。 打开Navicat找到t_stuschoolre

一路向前! 2万+

别再手动算了!用Excel函数一键搞定AQI和首要污染物分析(附完整公式模板)

本文介绍如何利用Excel函数自动化计算AQI和首要污染物分析,大幅提升数据处理效率。通过构建标准化输入模板、智能计算IAQI、自动判定AQI与首要污染物,并生成可视化仪表盘,帮助环保工作者快速完成每日监测报告。

weixin_30443075的博客 343

MySQL报错cannot add foreign key constraint解决方法

MySQL报错cannot add foreign key constraint解决方法

吴名氏的博客 10万+

PSpice 导入 LTspice 仿真实验 --(如何解决PSpice模型无法使用的错误)

参考了网上第三方器件导入LTspice的博客和资料,不论是哪个公司下载的SPICE模型导入LTspice的方法都类似。如果遇到导入报错的情况可以先看一下报错提示,如果通过语法修改实现功能的则说明可以进行仿真,当然性能可能与官方给的模型存在一点出入,但做一个基本的功能验证本人认为还是可以的,总比做出板子用不了或者完全不匹配的要好一些。

伊丽莎白的学习之路 8997

51单片机 步进电机正反转控制+Proteus仿真

51单片机 步进电机正反转控制+Proteus仿真 Proteus仿真 实例代码 /*************** ******************/ #include <reg52.h> #define uint unsigned int #define uchar unsigned char uchar code FFW[]= { 0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x09 }; uchar code REV[]= { 0x09,0x

perseverance51博客 2787

mysql外键的使用foreign key

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

qq_36961508的博客 1323

【系列05】端侧AI:构建与部署高效的本地化AI模型 第4章:模型量化(Quantization)

量化的基本思想是减少模型中用于表示参数和激活值的比特数。在模型训练时,参数通常使用32位浮点数(FP32)进行存储,这提供了高精度,但也消耗大量的内存和计算资源。量化则将这些32位浮点数转换成低比特数表示,通常是8位整数(INT8)。量化的原理可以概括为:对浮点数范围进行校准,并将其映射到更小的整数范围内。例如,将一个FP32的权重(如-1.5到1.5)映射到INT8的范围(-128到127)。在推理过程中,模型将使用这些低精度的整数进行计算,从而大大减少了所需的计算量。量化带来的主要收益减少模型大小。

学习,输出==》再学习再输出 1212

mysql创建表时添加外键约束产生Cannot add foreign key constraint

mysql创建表时添加外键约束产生Cannot add foreign key constraint 例如创建了user(user_id pk)表和role(role_id pk)表,当创建user_role(user_id fk,role_id fk)关联表的时候就出现问题。 1.所添加外键必须是另一个表的主键。 2.所关联的外键的类型必须和另一个表的主键相同.user中的user_id的类型必...

qq_39890111的博客 1817

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

1215 - cannot add foreign key constraint的解决办法

1215 - cannot add foreign key constraint发生在为数据表添加外键时,一旦发生,还是挺痛苦的。在此,参考相关文章及本人经验做一下总结: 情况一:数据表存储引擎不一致 我们看到,只有InnoDB是支持外键的。这就要求在指定外键时,两张表的引擎都要保证是InnoDB。如果这两张表任意一张表的引擎不是InnoDB,那么都会报1215 - cannot a...

Fayeni的博客 3252

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Navicat 还原备份时 Cannot add or update a child row: a foreign key constraint fails

Navicat 还原备份时 Cannot add or update a child row: a foreign key constraint fails

qq_35752389的博客 1294

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导入.sql文件时外键报错,a foreign key constraint fails,Cannot add foreign key constraint

MySql导入.sql文件时外键报错 通过Navicat for MySQL或者SQLyog等数据库操作工具导出.sql文件时,会发现再次导入的时候会报错: Error Code: 1217 - Cannot delete or update a parent row: a foreign key constraint fails ...

BUG的博客 4663

解决 Cannot add foreign key constraint 无法添加外键约束的问题

解决 Cannot add foreign key constraint 无法添加外键约束的问题。

念兮为美 379

MySQL | Navicat | 运行SQL文件时出现cannot add foreign key constraint问题

导入SQL文件时,出现错误如下: 上网查询后,此错误的出现是由于两张表想要进行外键关联时候出错而导致的错误,与外键相关的错误,这个错误不是导入的原因,而是导出数据发生的错误,导出数据如果涉及表内涉及外键关系的表,会使Mysql进行关系检查,如果导入子表检查外键如果检查不到,就会报错。 方法一(亲测可用): 解决此问题,需要关闭关系检查 FOREIGN_KEY_CHECKS=0 ,在导入的sql文...

qq_43604667的博客 1715

解决 1215 - Cannot add foreign key constraint

解决 1215 - Cannot add foreign key constraint 描述 今天在创建表单的时候添加外键约束,点击保存的时候出现报错1215 - Cannot add foreign key constraint 分析 出现这种情况报错主要有三个原因 外键对应的字段数据类型不一致 设置外键时“删除时”设置为“SET NULL” 两张表的存储引擎不一致 我在创建user表和role表的时候确定设置了存储引擎都是Innodb,这里排除了第三个可能。 同时我在设置外键删除时没有

weixin_42914989的博客 1029

[Mysql]---Navicat --外键建立与cannot add foreign key constraint分析

用Navicat为MySQL数据库的两个表之间建立外键关系,出现“cannot add foreign key constraint”错误. 设计外键的界面,有七列: 名(name):可以不填,保存时会自动生成。 栏位(FieldName):要设置的外键,如:t_stuschoolregisterinfo 里的IDCard 参考数据库(Reference DataBase):外键关联的数据库 被参考

minGW_Lee on the way 4936

MySQL 创建外键 报错 1452 - Cannot add or update a child row: a foreign key constraint fails

大致报错内容 1452 - Cannot add or update a child row: a foreign key constraint fails 背景 navicat创建外键时报错   关于navicat创建外键具体步骤,参见此文:navicat 数据表添加外键 原因 两张表的数据不匹配(参见下图)     例子: myorder表中userId字段是外键,关联user表中的userId字段。   myorder表中userId字段的值是0,而use

向来萧瑟也无畏 3007

mysql新建外键时1215 - Cannot add foreign key constraint错误处理

(2)设置外键时“删除时”设置为“SET NULL”3、设置外键时“删除时”设置为“SET NULL”用Navicat在新建表的外键时,弹出如下窗口。1、检查两张关联表对应的字段数据类型是否一致。(1)外键对应的字段数据类型不一致。(3)两张表的存储引擎不一致。2、查询存储引擎是否相同。

LP'S Blog 2908

navicat for mysql外键_Navicat For MySQL--外键建立与cannot add foreign key constraint分析

1.主键主键:表中经常有一个列或多列的组合,其值能唯一地标识表中的每一行。这样的一列或多列称为表的主键,通过它可强制表的实体完整性。当创建或更改表时可通过定义 PRIMARY KEY 约束来创建主键。一个表只能有一个 PRIMARY KEY 约束,而且 PRIMARY KEY 约束中的列不能接受空值。由于 PRIMARY KEY 约束确保唯一数据,所以经常用来定义标识列。作用:1)保证实体的完整性...

weixin_39737001的博客 521

navicat+MySQL设置外键MySQL “Cannot add or update a child row: a foreign key constraint fails”

MySQL “Cannot add or update a child row: a foreign key constraint fails” MySQL“无法添加或更新子行:外键约束失败” 博客翻译自StackOverflow上一个回答:网址如下: MySQL “Cannot add or update a child row: a foreign key constraint fails” ...

小蜉蝣星蔚的博客 2074

mysql> 1452 - Cannot add or update a child row: a foreign key constraint fails

> 1452 - Cannot add or update a child row: a foreign key constraint fails 工具:navicat 错误情况:>1452 - Cannot add or update a child row: a foreign key constraint fails 具体SQL命令 #年级 CREATE TABLE IF NOT EXISTS `grade`( `gradeid` INT(10) NOT NULL ...

weixin_45587527的博客 1237
上一篇: SpringBoot热部署
下一篇: 软考之项目网络图(活动图)
Aslan___
博客等级 码龄10年 10粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值