当前位置:网站首页>Gbase8s how to delete data in a table with a foreign key relationship
Gbase8s how to delete data in a table with a foreign key relationship
2022-07-28 02:52:00 【Victory of thumb】
GBase8s How to delete data in a table with a foreign key relationship
Other answers 1:
There are two ways :
1、 First delete the data in the foreign key table , Then delete the current data
give an example :
drop table if exists t1;
drop table if exists t2;
create table t1(id int primary key , s1 float);
create table t2(id int , id1 int ,s1 float,foreign key(id1) references t1(id) );
insert into t1 values(1,20);
insert into t1 values(2,30);
insert into t2 values(1,1,50);
-- If you delete t1 The data of , False report
delete t1;
692: Key value for constraint (root.u143_565) is still being referenced.
Error in line 1
Near character position 8
-- You need to delete t2 Table data , To delete t1 Table data
delete t2;
delete t1;
2、 Cascading deletion can be set through foreign keys
-- When setting foreign keys , Set cascade delete
drop table t2;
drop table t1;
create table t1(id int primary key , s1 float);
create table t2(id int , id1 int ,s1 float,foreign key(id1) references t1(id) on delete cascade);
insert into t1 values(1,20);
insert into t1 values(2,30);
insert into t2 values(1,1,50);
-- Delete... At this time t1 The data of , Delete t1 And t2 Data in the
> delete t1;
2 row(s) deleted.
> select * from t2;
id id1 s1
No rows found.
边栏推荐
猜你喜欢

Deep residual learning for image recognition shallow reading and Implementation

How do you use the jar package sent by others (how to use the jar package sent by others)
![[leetcode] 13. linked list cycle · circular linked list](/img/58/c8796bb5ed96d09325b8f2fa6a709e.png)
[leetcode] 13. linked list cycle · circular linked list

初识C语言 -- 结构体,分支和循环语句

第三章 队列

"The faster the code is written, the slower the program runs"

Redis aof日志持久化
![[image defogging] image defogging based on dark channel and non-mean filtering with matlab code](/img/39/6266eb14deac9f38b7e95f7291067e.png)
[image defogging] image defogging based on dark channel and non-mean filtering with matlab code

Newline required at end of file but not found.

Which users are suitable for applying for rapidssl certificate
随机推荐
IO flow: node flow and processing flow are summarized in detail.
Retainface use error: modulenotfounderror: no module named'rcnn.cyton.bbox'
软件产品第三方测试费用为什么没有统一的报价?
Introduction to the reduce() function in JS
[image hiding] digital image information hiding system based on DCT, DWT, LHA, LSB, including various attacks and performance parameters, with matlab code
P6118 [joi 2019 final] solution to the problem of Zhenzhou City
【自我成长网站收集】
【信号处理】基于高阶统计量特征的通信系统中微弱信号检测附matlab代码
"The faster the code is written, the slower the program runs"
ps 简单使用
TypeScript(零) —— 简介、环境搭建、第一个实例
1313_ Pyserial installation and document generation
Interpretation of cesium3dtilesets using customshader and examples of Omni effects
Newline required at end of file but not found.
JVM tuning -xms -xmx -xmn -xss
Pytorch optimizer settings
P6118 [JOI 2019 Final]珍しい都市 题解
数据中台建设(三):数据中台架构介绍
【图像隐藏】基于DCT、DWT、LHA、LSB的数字图像信息隐藏系统含各类攻击和性能参数附matlab代码
第二季度邮件安全报告:邮件攻击暴增4倍,利用知名品牌获取信任