当前位置:网站首页>Default constraint of MySQL constraint default
Default constraint of MySQL constraint default
2022-07-22 17:27:00 【Camellia——】
-- Database Constraints ( Some fields in the constraint table )
-- Multi-table query : Cartesian product , Internal connection , External connection ( Left lateral / Right outside ), Subquery-- mysql constraint
-- Default constraint :default
-- Non empty constraint :not null
-- Unique constraint :unique
-- Primary key constraint :primary key( Non empty constraint unique )------- Self growth constraints auto_increment( Record the number of records currently inserted )
-- Foreign keys :foreign keyUSE mydb_01;
-- Default constraint defaultCREATE TABLE stu (
id INT,
NAME VARCHAR (20),
gender VARCHAR (10)
) ;SELECT * FROM stu;
-- Insert data normally
INSERT INTO stu (id, NAME, gender)
VALUES
(1, ' Zhang San ', ' male '),
(2, ' Li Si ', ' male ');-- If you insert data , No data is inserted into a field , The default value is null
INSERT INTO stu (id, NAME)
VALUES
(3, ' Lisa ') ;
-- Add a default constraint to the current field , If you do not insert data into the current field , The default constraint will work
-- Modify the field type in the table
ALTER TABLE stu MODIFY gender VARCHAR(10) DEFAULT ' male ';DELETE FROM stu WHERE id=3;
DROP TABLE stu;-- Add default constraints when creating tables
CREATE TABLE stu(
id INT,
NAME VARCHAR(20),
gender VARCHAR(10) DEFAULT ' male '
);
边栏推荐
- 【C】分支和循环语句
- Vivo official website app full model UI adaptation scheme
- Pytoch deep learning practice lesson 11 (CNN)
- Spark高级特性,220720,
- Activity recommendation | Apache pulsar's exploration and practice in vivo will be broadcast soon
- 【学习笔记之菜Dog学C】深入理解数组与指针
- LVS load balancing cluster
- How to reinstall win11 system online with one click?
- 354. 俄罗斯套娃信封问题
- [C language interesting experiment]
猜你喜欢
354. 俄罗斯套娃信封问题
Recommendation of selected topics for completed topics of Electronic Information Engineering
Spark advanced features, 220720,
Reading papers [6] autoassembly: learning augmentation strategies from data
广度优先遍历(Breath First Search)
ssrf漏洞攻击内网Redis复现
JS的DOM操作——阻止事件冒泡和阻止默认事件
DOF depth of field Foundation
了解 5 种流行的 NFT 投放方式及其优缺点
This competition is a bit against the sky! Kunpeng application innovation competition openeuler track is fully opened
随机推荐
Breadth first search
matlab混频器的实现
CASTOR 通过 Polygonica 3D引擎实现云端大型装配进行高吞吐量分析,HOOPS Exchange助力其实现对 CAD 数据文件读取
Playbook 介绍
MVC mode and three-tier architecture
How to reinstall win11 system online with one click?
Pytorch deep learning practice-b station Liu erden-day1
Win11 terminal administrator cannot open the solution
Vivo official website app full model UI adaptation scheme
BigInteger: what does new BigInteger (tokenjason. Getbytes()). ToString (16) mean
DOF depth of field Foundation
STL map
牛客网 Fibonacci数列
服務器buffer/cache 的產生原因和釋放buffer/cache
对称式加密与非对称式加密的对比
Write a sequencer plug-in sequence subtitle (1)
STL resize容量规律集合
《PyTorch深度学习实践》-B站 刘二大人-day1
map 插入元素
How to implement Apache's built-in AB stress testing tool