当前位置:网站首页>SQL field type conversion
SQL field type conversion
2022-07-27 19:20:00 【The bearer of dark cuisine】
1、mysql vchar turn int、double etc.
MySQL Of CAST() Function can be used to get the value of a type , And produce another type of value
cast() Function is a conversion function , The argument is an expression , It includes the use of AS Key separated source and target data types .
cast Convert to double type , about D\M Value considerations .

# The formula
CAST(value as type);
#vchar turn int ( Decimals are rounded directly )
CAST(value as SIGNED);
#vchar turn double M Represents the reserved integer digits + Keep the decimal places ,D Represents the number of decimal places reserved
#1) Parameters m<65 It's the total number ,d<30 And d<m It's a decimal place .
#2)decimal The maximum possible value range is related to double equally , Its valid value range is, however M and D Value determination of .
# If you change M And fixed D, Then its value range will follow M That's bigger and bigger .
CAST(value as decimal(M,D));2、cast() Conversion type for function
Binary system , Syntaxis binary The effect of prefixes : BINARY
Character , With parameters : CHAR()
date : DATE
Time : TIME
Date time type : DATETIME
Floating point numbers : DECIMAL
Integers ( A signed ) : SIGNED
Unsigned integer ( Unsigned ): UNSIGNED 3、cast() and convert() Comparison
The same thing : It's all data type conversion , The functions realized are basically the same as
Difference : The grammar of the two is different ,cast(value as type) 、 convert(value,type)
If there are errors or inaccurate descriptions , Please correct me .
边栏推荐
猜你喜欢

Introduction to assembly language (1)

An article allows you to master threads and thread pools, and also solves thread safety problems. Are you sure you want to take a look?

Extension of regular expression

Opening and using Alibaba cloud object storage OSS

MySQL learning notes (2) -- stored procedures and stored functions

浅谈基本的网络基本故障和问题排查

Self control principle learning notes - system stability analysis (2) - loop analysis and Nyquist bode criterion

C language case: password setting and login > clear solution getchar and scanf

图的遍历的定义以及深度优先搜索和广度优先搜索(二)

kettle 分列、合并记录
随机推荐
阿里云视频点播服务的开通和使用
Rs2022/ cloud detection: semi supervised cloud detection in satellite images by considering the
Micaz+tinyos learning notes (1)
Kinect2 for Unity3D——AvatarDemo学习
There is another example of repeater
一个经验
C语言案例:密码设置及登录> 明解getchar与scanf
New system installation mysql+sqlyog
新系统安装MySQL+SQLyog
What if idea successfully connects to the database without displaying the table
Dynamic proxy
200行代码快速入门文档型数据库MonogoDB
The go zero singleton service uses generics to simplify the registration of handler routes
MySQL 02 initial experience
Basic use of Nacos (1) - getting started
NPM, cnpm Taobao image
JMeter interface automation - how to solve the content type conflict of request headers
Extension of regular expression
How can I get started quickly when I change my career to soft testing and job hopping to a new company?
WSN Journal indexed by SCI(转)