当前位置:网站首页>SQL learning notes (02) - database table operation
SQL learning notes (02) - database table operation
2022-07-01 09:25:00 【Yuxuan godlike】
The contents of the catalog
One 、Mysql Database operation
- Create database
Format :create database Database name ;
create database student;
- Delete database
Format :drop database Database name ;
drop database student;
- Look directly at the existing database :
show databases;
Two 、Mysql Data type in
1. Integer and decimal
Integer types :int
Decimal type :decimal Format :decimal( Total length , Decimal places )
decimal(5,2) The total length of data required to be transmitted is 5 position , The decimal places are 2 position
2. Date and time type
datetime YYYY-MM-DD HH:MM:SS
date YYYY-MM-DD
3. String type
char( Length of string ) Fixed length
varchar( Length of string ) Lengthening
for example :
full name char(10) tom–> Occupy 3 Characters And then there were 7 The space of characters will not be released , The system will fill with blanks
full name varchar(10) tom–> Occupy 3 Characters And then there were 7 Characters were released
3、 ... and 、 Create and delete tables
Create table syntax format
create table Table name (
Name 1 data type ,
Name 2 data type ,
Name 3 data type
);
Comments in the database
Single-line comments :-- Content of notesMultiline comment :/* Content of notes */
Switch database
Format :use Database name
Open the table : Check whether there is data stored in the table
Design table : View table structure
Delete table
Delete single table :drop table Table name ;
Delete multiple tables :drop table Table name 1, Table name 2;
Four 、 Modify table structure
Add columns
alter table Table name add Column name data type ;
Delete column
alter table Table name drop Name ;
Change the data type of the column
alter table Table name modify Name New data types ;
Change column names
alter table Table name change Old column names New column names data type ;
Display table structure
desc Table name ;
Check constraints check( Limit the range of values in the column )
create table Table name (
Name 1 data type check( constraint condition )
);
give an example : In the table id The value range is 5-20
create table students(
id int check(id>5 and id<20)
);
边栏推荐
- 2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据
- R language observation log (part24) -- initialization settings
- 序列化、监听、自定义注解
- Get the list of a column in phpexcel get the letters of a column
- Structure de l'arbre - - - arbre binaire 2 traversée non récursive
- Mise en œuvre simple de l'équilibrage de la charge par nacos
- Promise asynchronous programming
- Pain points and solutions of equipment management in large factories
- pcl_ Viewer command
- Weidongshan board compilation kernel problem solving
猜你喜欢

How to solve the problem of fixed assets management and inventory?

Imitation of Baidu search results top navigation bar effect

Principles of Microcomputer - internal and external structure of microprocessor

Nacos service configuration and persistence configuration

2.2 【pytorch】torchvision.transforms

Tree structure -- binary tree 2 non recursive traversal

js作用域链与闭包

nacos服务配置和持久化配置

【电赛训练】红外光通信装置 2013年电赛真题

樹結構---二叉樹2非遞歸遍曆
随机推荐
pcl_ Viewer command
[pytorch learning] torch device
2.2 【pytorch】torchvision.transforms
集成积木报表报错 org.apache.catalina.core.StandardContext.filterStart 启动过滤器异常
2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据
Problems caused by delete and delete[]
laravel postman 提交表单出现419错误。2020年7月6日记。
Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)
nacos简易实现负载均衡
Set the type of the input tag to number, and remove the up and down arrows
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DS18B20温度传感器 +NodeJs本地服务+ MySQL数据库
JS prototype chain
闭包实现迭代器效果
Get the list of a column in phpexcel get the letters of a column
Mysql 优化
Databinding source code analysis
Why is the Ltd independent station a Web3.0 website!
Using closures to implement private variables
MySQL optimization
3D printing Arduino four axis aircraft