当前位置:网站首页>mysql约束之_非空约束
mysql约束之_非空约束
2022-07-22 06:00:00 【Camellia——】
-- 非空约束 not null(限制插入数据时候,不能插入null)
-- 创建表的时候添加了非空约束
CREATE TABLE stu(
id INT,
NAME VARCHAR(20) NOT NULL
);-- 插入数据
INSERT INTO stu(id,NAME)VALUES(1,'高圆圆');
INSERT INTO stu(id,NAME)VALUES(2,NULL);-- Column 'name' cannot be null
INSERT INTO stu(id)VALUES(2);-- 这种情况也不能出现-- 将表的非空约束删除掉(修改当前表中的字段类型)
ALTER TABLE stu MODIFY NAME VARCHAR(20);DELETE FROM stu WHERE id=2;
SELECT *FROM stu;-- 添加表中的非空约束
ALTER TABLE stu MODIFY NAME VARCHAR(20) NOT NULL;
边栏推荐
- STL map
- Spark advanced features, 220720,
- pytorch优化器: optim.SGD && optimizer.zero_grad()
- Principle and performance analysis of lepton lossless compression
- 利用二分法查找数组的元素
- NVIDIA hardware architecture
- GMT 0009-2012 data format go language operation
- 一种跳板机的实现思路
- 重装Win11系统如何在线一键进行?
- How to implement Apache's built-in AB stress testing tool
猜你喜欢
JS的DOM操作——事件链(冒泡目标捕获)
Pytorch深度学习实践 第11讲(CNN)
Principle and performance analysis of lepton lossless compression
Win11遇到问题需要重启怎么办?
UE4 enters the designated area to realize the trigger acceleration function
力扣刷题:dfs递归解决二叉树剪枝
Gd32f470 serial port idle interrupt +dma
【外部排序】快排思想完成外部排序
JS的DOM操作——阻止事件冒泡和阻止默认事件
How to download and install xshell plus6
随机推荐
【外部排序】归并思想完成外部排序
Add asynchronous task processing model task to flask framework
Activity recommendation | Apache pulsar's exploration and practice in vivo will be broadcast soon
分支语句和循环语句
Crack PLSQL by deleting the registry
Tensorflow predicts daily sales
BigInteger: what does new BigInteger (tokenjason. Getbytes()). ToString (16) mean
final、finally、finalize的区别
JSON_EXTRACT返回不正确问题
[C language interesting experiment]
Spark高级特性,220720,
July 19, 2022 daily
Blob URL DataURL
The aboveboard water stickers come from people's perception of summer vacation
Reading papers [6] autoassembly: learning augmentation strategies from data
【转载】UE4 面试基础知识(二)
活动推荐| Apache Pulsar 在 vivo 的探索与实践 即将开播
Upgrade MySQL 5.6 to 8.0 on Windows
LVS, this is enough
一文带你了解redux的工作流程——action/reducer/store