当前位置:网站首页>Mysql增删改查、检索与约束(详细教学)
Mysql增删改查、检索与约束(详细教学)
2022-07-24 16:41:00 【@_猿来如此】
大家都知道进行增删改查检索与约束的前提是自己先创建一个数据库,然后在数据库建一个表格,下图为例,这是表的原始数据。
一、增加数据
我们要添加管理员3、4、5,SQL语句如下:
刷新一下表格,这样就成功了。
二、删除数据
比如我们想删除管理员5,SQL语句如下:

这就表明操作成功了。
三、修改数据
将管理员4的密码修改为456123,SQL语句如下:

成功示例:

四、查询数据
查询管理员1的信息,如果存在则查询用户表中信息,SQL语句如下:
五、检索(上图为例)
- 单个列Select name from 用户表 ;
- 多个列Select id,name from 用户表 ;
- 所有列Select*from 用户表 ;
六、约束
1.主键约束:
mysql>alter table 用户表
->ADD PRIMARY KEY (id);
2.外键约束:
mysql>ALTER TABLE 收银结构
->ADD CONSTRAINT fk_商品结构
->FOREIGN KEY (sum)
->REFERENCES 商品结构(id);
3.唯一约束:
mysql>ALTER TABLE 用户表
->ADD CONSTRAINT unique_id UNIQUE (id);
点赞加关注,知识不迷路
边栏推荐
- ZBar project introduction and installation configuration| [email protected]
- Microsoft Visio professional 2013 cannot be opened or uninstalled. Solution
- Codeforces round 690 (Div. 3) C. unique number conventional solution
- 15. ARM embedded system: how to debug single board with PC
- You really should go to the factory to move bricks!
- EF miscellaneous
- What are the safe securities companies? I want to buy stocks on my mobile phone
- Sword finger offer 22. the penultimate node in the linked list
- hping3安装使用
- Creation and inheritance of JS class
猜你喜欢

会议OA项目进度(二)

VSCode如何鼠标滚轮放大界面

Implementation of side list menu (side menu) of wechat applet

1184. 公交站间的距离

jvm类加载子系统

TCP协议调试工具TcpEngine V1.3.0使用教程

.NET 测试框架 xUnit,MSTest, Specflow 使用经验汇总

AXI协议(1):AMBA总线介绍,AXI概念与背景介绍,AXI协议特点与功能

Envi grid resampling

EMQ Yingyun technology was listed on the 2022 "cutting edge 100" list of Chinese entrepreneurs
随机推荐
TCP protocol debugging tool tcpengine v1.3.0 tutorial
JS, call in the for loop is asynchronously converted to synchronous execution
Duplicate content in lookup table
ZBar project introduction and installation configuration| [email protected]
Custom types: Enumeration
【技术】uniapp之聊天室 demo
“天上天下,唯我独尊”——单例模式
What is the difference between cookies, localstorage and sessionstorage?
详解 Apache Hudi Schema Evolution(模式演进)
我们为什么要推出Getaverse?
Intel plans to sell baseband chip business, but Apple has given up?
Jenkins cli command details
剑指 Offer 22. 链表中倒数第k个节点
thinkphp3.2.5无法跳转到外部链接
QT keyboard event (II) -- long press the key to trigger the event event repeatedly, and the problem is solved
AXI协议(3):AXI架构的握手机制和实现细节
With regard to performance testing, dry goods hit "suggestions collection"
PS pull out logo
Enter a URL to this page to show it. What happened in this process?
Codeforces round 690 (Div. 3) B. last year's substring conventional solution