当前位置:网站首页>MySQL table creation statement_Three commonly used MySQL table creation statements
MySQL table creation statement_Three commonly used MySQL table creation statements
2022-07-31 07:46:00 【time Friend】
The MySQL table creation statement is one of the most basic SQL statements. Here are the three most commonly used MySQL table creation statements. If you are interested in MySQL table creation statements, you may wish to take a look.
1. The simplest:
CREATE TABLE t1(
id int not null,
name char(20)
);
2. With primary key:
CREATE TABLE t1(
id int not null primary key,
name char(20)
);
b: Composite primary key
CREATE TABLE t1(
id int not null,
name char(20),
primary key (id,name)
);
3. With default value:
CREATE TABLE t1(
id int not null default 0 primary key,
name char(20) default '1'
);
Complete example:
DROP TABLE IF EXISTS `user_t`;
CREATE TABLE `user_t` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(40) NOT NULL,
`password` varchar(255) NOT NULL,
`age` int(4) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*Data for the table `user_t` */
insert into `user_t`(`id`,`user_name`,`password`,`age`) values (1,'test','sfasgfaf',24);
Explanation::
ENGINE=InnoDB uses the innodb storage engine
DEFAULT CHARSET=utf8 The default encoding of the database is utf-8
AUTO_INCREMENT=1 The starting sequence number of the auto-increment key is 1
Extension:
1. InnoDB is one of MySQL's database engines, and one of the standards for the release of binary for MySQL AB. InnoDB supports advanced functions such as transaction processing and foreign keys.
2.AUTO_INCREMENT generates a unique number when a new record is inserted into the table.If you want to automatically create the value of the primary key field every time a new record is inserted, you can create an auto-increment field in the table.
—————————————————
Copyright statement: This article is an original article by CSDN blogger "Zhu Kun iamkun", following the CC 4.0 BY-SA copyright agreement, please reprintA link to the original source and this statement are attached.
Original link: https://blog.csdn.net/weixin_33582089/article/details/113112792
边栏推荐
- opencv、pil和from torchvision.transforms的Resize, Compose, ToTensor, Normalize等差别
- 解决win11/win10在登陆界面(解锁界面)点击获取每日壁纸无效的问题 - get Daily Lockscreen and Wallpaper - Win11/10的登录界面背景图片在哪里?
- Leetcode952. Calculate maximum component size by common factor
- 2022.07.26_每日一题
- leetcode 406. Queue Reconstruction by Height
- 第9章 异常try...except...else...finally
- 链表实现及任务调度
- How to set the computer password?How to add "safety lock" to your computer
- 嵌入式系统驱动初级【2】——内核模块下_参数和依赖
- nohup principle
猜你喜欢

CNN--各层的介绍

双倍数据速率同步动态随机存储器(Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM)- 逻辑描述部分

2022.07.20_Daily Question

Zabbix6.2 Surprise Release!Especially optimize the performance of medium and large environment deployment!

事务的传播机制

Environment_Variable_and_SetUID

Leetcode952. Calculate maximum component size by common factor

Financial leasing business

Thread 类的基本用法——一网打尽

Tasks and task switching
随机推荐
深度学习通信领域相关经典论文、数据集整理分享
2022.07.14_Daily Question
《白帽子说Web安全》思维导图
电压源的电路分析知识分享
2022.07.18_每日一题
机器学习---线性回归、Logistic回归问题相关笔记及实现
【微服务】Nacos集群搭建以及加载文件配置
LeetCode:952. 按公因数计算最大组件大小【欧拉筛 + 并查集】
How to set the computer password?How to add "safety lock" to your computer
DAY18:XSS 漏洞
‘vite‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
Explain the example + detail the difference between @Resource and @Autowired annotations (the most complete in the entire network)
DAY18:Xss 靶场通关手册
2022.07.15_Daily Question
多进程全局变量失效、变量共享问题
Linked list implementation and task scheduling
【并发编程】ReentrantLock的lock()方法源码分析
van-uploader上传图片,使用base64回显无法预览的问题
【愚公系列】2022年07月 Go教学课程 022-Go容器之字典
2022.07.12_每日一题