当前位置:网站首页>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
边栏推荐
- 2022.07.15_Daily Question
- 2022.07.14_Daily Question
- 进程和线程的区别&&run和start区别与联系
- Chapter 17: go back to find the entrance to the specified traverse, "ma bu" or horse stance just look greedy, no back to search traversal, "ma bu" or horse stance just look recursive search NXM board
- 毫米波技术基础
- van-uploader uploads images, and cannot preview the image using base64 echo
- 2022.07.13 _ a day
- 【Star项目】小帽飞机大战(七)
- Postgresql source code learning (33) - transaction log ⑨ - see the overall process of log writing from the insert record
- [PSQL] SQL基础教程读书笔记(Chapter1-4)
猜你喜欢
![[PSQL] SQL基础教程读书笔记(Chapter1-4)](/img/76/d416f79b7f2c93c1c79a285c30d3e6.png)
[PSQL] SQL基础教程读书笔记(Chapter1-4)

【面试:并发篇38:多线程:线程池】ThreadPoolExecutor类的基本概念

《白帽子说Web安全》思维导图

DAY18: Xss Range Clearance Manual

电压源的电路分析知识分享

从 Google 离职,前Go 语言负责人跳槽小公司

完美指南|如何使用 ODBC 进行无代理 Oracle 数据库监控?

‘vite‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。

【网络攻防】常见的网络攻防技术——黑客攻防(通俗易懂版)

双倍数据速率同步动态随机存储器(Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM)- 逻辑描述部分
随机推荐
opencv、pil和from torchvision.transforms的Resize, Compose, ToTensor, Normalize等差别
Zabbix6.2惊喜发布!特别优化中大型环境部署的性能!
2022.07.24_Daily Question
文件 - 02 上传文件:上传临时文件到服务器
2022.07.18_每日一题
进程和线程的区别&&run和start区别与联系
Jetpack Compose学习(8)——State及remeber
2022.7.29 Array
文件 - 04 下载文件: 根据文件下载链接下载文件
2022.07.13 _ a day
Linked list implementation and task scheduling
【第四章】详解Feign的实现原理
【解决】npm ERR A complete log of this run can be found in npm ERR
2. (1) Chained storage of stack, operation of chain stack (illustration, comment, code)
Postgresql source code learning (33) - transaction log ⑨ - see the overall process of log writing from the insert record
mysql的建表语句_三种常用的MySQL建表语句
SQLite数据库连接字符串
2022.07.22_每日一题
SCI写作指南
ros小乌龟画图