当前位置:网站首页>MySQL - 表字段的默认值约束
MySQL - 表字段的默认值约束
2022-07-18 01:03:00 【骆驼胡杨】
设置表字段的默认值(DEFAULT)
当为数据库表中插入一条新记录时,如果没有为某个字段赋值,数据库系统就会自动为这个字段插入默认值。为了达到这种效果,可通过SQL语句关键字DEFAULT来设置。
设置数据库表中某字段的默认值非常简单,可以在MySQL数据库管理系统中通过SQL语句DEFAULT来实现,其语法形式如下:
CREATE TABLE tablename( propName propType DEFAULT defaultvalue, ...... );
注意: 如果没有设置,则默认为空
mysql> create table class5(id int primary key, name varchar(64) default '无名', teacher varchar(64)); #创建表class5;
mysql> desc class5; #查询表信息


边栏推荐
- About the problem that only one IP can be accessed after dual network cards are configured
- Codeforce:b. difference array [optimization of prefix 0]
- 在线SQL转文本工具
- A Ye's new hairstyle
- Online dice rolling dice tool
- PwnTheBox,Web:Double-S
- 【干货】MySQL底层架构设计,你了解多少?
- Financial banking software testing super large strategy, the most popular financial banking big secret cover questions
- JUC源码学习笔记2——AQS共享和Semaphore,CountDownLatch
- Compile error recipe terminated with error when referencing latex pictures under vscade Retry building the project.
猜你喜欢

PwnTheBox,Web:Double-S

Lecture 21 of project practice: platform commodity Library
Qt | 控件之QComboBox
Advanced customization of uni app [day13]

Detailed explanation of the life cycle of arkui development framework components

Windows install MySQL

Compile error recipe terminated with error when referencing latex pictures under vscade Retry building the project.

Vscode下Latex 图片引用时 编译报错Recipe terminated with error. Retry building the project.

MySQL series "trigger details"

ArrayList源码解析一
随机推荐
LVS load balancing cluster
Liquibase learning 2 - Introduction to the extension plug-in liquibase data
2022/07 CSI tool installation process record
阿米的思考
基于二叉树的传球问题思考与推测
Liquibase learning 1 - installation, simple use
Thinking and speculation on passing based on binary tree
Typescript中对象扩展之动态添加方法与属性修改
阿叶的新发型
Next stop, embossed AI
uni-app进阶之自定义【day13】
uniapp授权登陆获取用户信息和code
Open3d library installation, CONDA common instructions, importing open3d times this error solving environment: failed with initial frozen solve Retrying w
同花顺炒股安全吗?
一款强大的mock数据生成工具
Enter /user/ username /library/application support/
初识convolution(卷积)+matlab对离散卷积过程的直观认识
The junior engineer in the group asked for help and said that if he wanted to collect the recruitment data, he must be arranged
深度学习环境配置Pytorch
Interference signal radiated from motor