当前位置:网站首页>MySQL learning diary (II)
MySQL learning diary (II)
2022-07-06 10:12:00 【AP840】
SQL Detailed explanation of connection mode :https://www.cnblogs.com/janneystory/p/5618140.html
MYSQL data type :
integer
tinyint(m) 1 Bytes Range (-128~127)
smallint(m) 2 Bytes Range (-32768~32767)
mediumint(m) 3 Bytes Range (-8388608~8388607)
int(m) 4 Bytes Range (-2147483648~2147483647)
bigint(m) 8 Bytes Range (+-9.22*10 Of 18 Power )
[ notes : Add in front unsigned, Then the maximum value in the range 、 The minimum values are doubled .(m) It refers to the display width in the query result set ]
floating-point
float(m,d) Single precision floating point 8 Bit accuracy (4 byte ) m Total number ,d Decimal places
double(m,d) Double precision floating point 16 Bit accuracy (8 byte ) m Total number ,d Decimal places
Fixed-point number
decimal(m,d) Parameters m<65 It's the total number ,d<30 And d<m It's a decimal place
character string (char,varchar,_text)
char(n) Fixed length , most 255 Characters
varchar(n) Fixed length , most 65535 Characters
tinytext Variable length , most 255 Characters
text Variable length , most 65535 Characters
mediumtext Variable length , most 2 Of 24 Power -1 Characters
longtext Variable length , most 2 Of 32 Power -1 Characters
[ notes :varchar The query speed ratio of text fast ,char The query speed ratio of varchar fast ]
MySQL It will be automatically modified to... Before the non-conforming value is inserted into the table 0!!!!!
Simple use of tables :
NULL : Allow null value
NOT NULL : Null value... Is not allowed , When inserting or updating rows , The column must have a value , When inserting a column without a value , Will return an error
【 notes : Space ““ Not equal to null value 】
DEFAULT : Specify default , Without assigning a value to the column , By default, the system assigns DEFAULT The number after
CREATE TABLE OrderItems
(
order_num INTEGER NOT NULL,
order_item INTEGER NOT NULL,
prod_id CHAR(10) NOT NULL,
quantity INTEGER NOT NULL DEFAULT 1,
item_price DECIMAL(8,2) NOT NULL
);
The assumption is that quantity There is no assignment in a cell , The system assigns values automatically 0;
————————————————————————————————————————————————————
Update table :
ALTER TABLE( surface )
------------------------------
Add a column to the existing table :
alter table Table name add Name data type ;( Such as ,vend_phone)
------------------------------
Delete a known column for the existing table :
alter table Table name drop Name ;
------------------------------
Delete an existing table :
drop table Table name ;
------------------------------
Change the table name of an existing table :
alter table The old name of the table rename to/as The new name of the table ;
------------------------------
Update the existing data in the table :
give an example :
Update a column :
update customers
set cust_email = '[email protected]'
where cust_id = 1000000005;
Update multiple columns :
update customers
set cust_contact = 'Sam Roberts',
cust_email = '[email protected]'
where cust_id = 1000000006;
When you want to delete the value of a column , It can be changed to cust_contact = NULL ,cust_email = NULL
------------------------------
Delete data :
give an example :
delect from customers
where cust_id = 1000000006;
This is intended to delete the table customers in cust_id=1000000006 A row of data , Note that if you delete a specific column , use update sentence ;
If there is no “where cust_id = 1000000006;” Delete customers All rows in , But the form still exists .
边栏推荐
- 四川云教和双师模式
- Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
- AI的路线和资源
- [after reading the series] how to realize app automation without programming (automatically start Kwai APP)
- cmooc互联网+教育
- Flash operation and maintenance script (running for a long time)
- 颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香
- Why is 51+ assembly in college SCM class? Why not come directly to STM32
- Some thoughts on the study of 51 single chip microcomputer
- [Julia] exit notes - Serial
猜你喜欢
![[flask] crud addition and query operation of data](/img/fc/7a12ede31befed5f42b32b94ae5ecf.jpg)
[flask] crud addition and query operation of data

实现微信公众号H5消息推送的超级详细步骤

AI的路线和资源

Southwest University: Hu hang - Analysis on learning behavior and learning effect

在CANoe中通过Panel面板控制Test Module 运行(初级)

How can I take a shortcut to learn C language in college

C杂讲 浅拷贝 与 深拷贝

MySQL实战优化高手12 Buffer Pool这个内存数据结构到底长个什么样子?

MySQL的存储引擎
![[after reading the series of must know] one of how to realize app automation without programming (preparation)](/img/eb/e789d88f10787c302f9457ca7ca2cc.jpg)
[after reading the series of must know] one of how to realize app automation without programming (preparation)
随机推荐
[after reading the series] how to realize app automation without programming (automatically start Kwai APP)
[after reading the series of must know] one of how to realize app automation without programming (preparation)
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
Implement context manager through with
华南技术栈CNN+Bilstm+Attention
CAPL 脚本对.ini 配置文件的高阶操作
Routes and resources of AI
Vscode common instructions
Learning SCM is of great help to society
MySQL底层的逻辑架构
实现以form-data参数发送post请求
美新泽西州州长签署七项提高枪支安全的法案
CAPL script pair High level operation of INI configuration file
Use xtrabackup for MySQL database physical backup
[NLP] bert4vec: a sentence vector generation tool based on pre training
13 medical registration system_ [wechat login]
MySQL实战优化高手06 生产经验:互联网公司的生产环境数据库是如何进行性能测试的?
软件测试工程师发展规划路线
[flask] crud addition and query operation of data
Random notes