当前位置:网站首页>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 .
边栏推荐
- Installation of pagoda and deployment of flask project
- CANoe的数据回放(Replay Block),还是要结合CAPL脚本才能说的明白
- Routes and resources of AI
- Zsh configuration file
- South China Technology stack cnn+bilstm+attention
- 15 medical registration system_ [appointment registration]
- CDC: the outbreak of Listeria monocytogenes in the United States is related to ice cream products
- MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位
- [Julia] exit notes - Serial
- The governor of New Jersey signed seven bills to improve gun safety
猜你喜欢
如何让shell脚本变成可执行文件
The replay block of canoe still needs to be combined with CAPL script to make it clear
西南大学:胡航-关于学习行为和学习效果分析
Defensive C language programming in embedded development
PR 2021 quick start tutorial, first understanding the Premiere Pro working interface
Sichuan cloud education and double teacher model
Control the operation of the test module through the panel in canoe (Advanced)
cmooc互联网+教育
CAPL 脚本打印函数 write ,writeEx ,writeLineEx ,writeToLog ,writeToLogEx ,writeDbgLevel 你真的分的清楚什么情况下用哪个吗?
寶塔的安裝和flask項目部署
随机推荐
112 pages of mathematical knowledge sorting! Machine learning - a review of fundamentals of mathematics pptx
Super detailed steps for pushing wechat official account H5 messages
CANoe下载地址以及CAN Demo 16的下载与激活,并附录所有CANoe软件版本
The programming ranking list came out in February. Is the result as you expected?
竞赛vscode配置指南
MySQL storage engine
MySQL combat optimization expert 04 uses the execution process of update statements in the InnoDB storage engine to talk about what binlog is?
Control the operation of the test module through the panel in canoe (Advanced)
C杂讲 动态链表操作 再讲
VH6501学习系列文章
MySQL combat optimization expert 06 production experience: how does the production environment database of Internet companies conduct performance testing?
Zsh configuration file
Contest3145 - the 37th game of 2021 freshman individual training match_ B: Password
Use xtrabackup for MySQL database physical backup
A necessary soft skill for Software Test Engineers: structured thinking
Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
寶塔的安裝和flask項目部署
西南大学:胡航-关于学习行为和学习效果分析
Embedded development is much more difficult than MCU? Talk about SCM and embedded development and design experience
MySQL ERROR 1040: Too many connections