Home > Database > Mysql Tutorial > What are the usage specifications of mysql columns?

What are the usage specifications of mysql columns?

王林
Release: 2023-06-01 20:12:13
forward
1191 people have browsed it

1. Decimal type is decimal, float and double are prohibited.

float and double have the problem of precision loss during storage, and incorrect results are likely to be obtained when comparing values.

2. If the range of stored data exceeds the range of decimal, it is recommended to split the data into integers and decimals and store them separately.

3. Use tinyint/int/bigint according to business classification, occupying 1/4/8 bytes respectively.

Char/varchar is used according to business differentiation.

Example

Demo:
mysql> use school;   #选择数据库school
mysql> create table class6(class_id integer(5) zerofill, class_name varchar(128), class_teacher                             
varchar(64) );         #创建表class6   
mysql> insert into class0 values(1,'三年级六班','张老师');  
mysql> select * from class0 ;
+-------+------------+---------+
| id    | name       | teacher |
+-------+------------+---------+
| 00001 | 三年级六班  | 张老师   |
+-------+------------+---------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of What are the usage specifications of mysql columns?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template