In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the MySql data type example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
1. A brief overview
Why open MySQL as a learning section? Because this is a necessary skill for a data analyst. What is the most important thing to analyze data? Data, of course, that being the case! In the era of explosive growth of data, how can we not learn from the database? In fact, this is also what many readers would like to see, and it is also what they suggested me to write.
Those who are difficult will not, those who meet are not difficult! In fact, a lot of MySQL summary articles on the Internet, there is no denying that the knowledge points are very complete, but! This is just a query manual for friends who can use MySQL database. If you can't use it, you still won't use it (there is no detailed introduction). So I started writing in this section, hoping to help those who change careers and want to learn MySQL. Of course, I would like to add that these sections are not for developers who want to be DBA, but for those who switch to data analysis and then need to learn MySQL databases.
2. Detailed explanation of MySQL data types
Anyone who has studied a programming language knows how to learn a programming language. First of all, start with the data type. Although the library is created by others and the table is designed by others, these seem to have nothing to do with you, but mastering such a knowledge point will certainly be helpful for you to better understand and learn MySQL.
1) string type
① char (m): a string of fixed length.
② varchar (m): a string of variable length.
The above knowledge can be understood by referring to the following figure.
Comparison of space utilization for ③ char and varchar storage.
As can be seen from the above table:
④ tinytext 、 text 、 longtext
Note: as long as the storage is a string type, we should pay attention to the coding problem, generally using utf8 encoding.
2) Integer type
Symbolic bit and unsigned bit detailed explanation website: https://www.yisu.com/article/178768.htm
Parameter problems in the declaration of ① integer data types
② unsigned parameter.
-- create table create table person (pname varchar (20), page tinyint unsigned, psex bit (1)) charset=utf8;-- insert two records insert into person (pname,page,psex) values ("Zhang San", 1810), ("Li Si", 22)
Observe the following figure:
As can be seen from the above picture:
The ③ zerofill parameter must be used in conjunction with the M parameter to make sense.
-- A description of the student number field:-- 1: the student number cannot be negative;-- 2: the student number is generally the same, and even if it is different, it will be filled with 0. -- eg:00001,00013,00128,01280. Create table create table student (sid smallint (5) zerofill not null default 0, sname varchar (20), sage tinyint unsigned, ssex bit (1) default 0) charset=utf8;-- insert two records insert into student (sname,sid) values ("Zhang Fei", 5), ("Lv Bu", 1)
Observe the following figure:
As can be seen from the above picture:
3) floating point number type
Examples are as follows:
-swage stands for salary; sbonus stands for allowance, which cannot be negative. -- create tables create table salary (sname varchar (20), swage float (6jue 2), sbonus float (5je 2) unsigned not null default 0) charset=utf8;-- insert two records insert into salary (sname,swage,sbonus) values ("Ji Xiaolan", 9999.99111.11), ("Hefei",-9999.99444.44)
Observe the following figure:
As can be seen from the above picture:
Accuracy comparison between ① float/double and decimal
-- create tables create table bank (id varchar (20), acc1 float (9), acc2 decimal (9)) charset=utf8;-- inserts two records insert into bank (id,acc1,acc2) values (1 1234567.45, 1234567.45), (2) 1234567.678)
Observe the following table:
As can be seen from the above table:
4) date / time type
What is the date type and time type of ①?
1) date type: refers to the year, month and day, similar to 2019-11-16 (November 16, 2019)
2) time type: refers to hours, minutes, seconds, similar to 10:45:30 (10:45:30)
② date / time Typ
Thank you for reading this article carefully. I hope the article "sample Analysis of MySql data types" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.