In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how mysql converts the specified value into a string type, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
Conversion method: 1, the use of CAST () function, you can convert the value to the specified data type, syntax "SELECT CAST (need to convert the value AS string type);"; 2, the use of CONVERT () function, syntax "SELECT CONVERT (need to convert the value, string type);".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
Mysql converts the specified value to a string type
1. Using the CAST () function
The CAST () function converts (any type) value to the specified data type.
Grammar
The CAST (value AS datatype) parameter describes the value requirements. The field name or value datatype required to be converted. The data type to convert to. It can be one of the following:
DATE: conversion of value to date. Format: "YYYY-MM-DD"
DATETIME: convert value to DATETIME. Format: "YYYY-MM-DD HH:MM:SS"
TIME: convert the value to the time. Format: "HH:MM:SS"
CHAR: converting value CHAR (fixed-length string)
SIGNED: converts value signatures (64-bit integers of signatures)
UNSIGNED: converting value to UNSIGNED (unsigned 64-bit integers)
BINARY: converting value to BINARY (binary string)
Example:
SELECT CAST (150 AS CHAR)
2. Using the CONVERT () function
The CONVERT () function converts the value to the specified data type or character set.
Grammar
CONVERT (value, type)
Or:
The CONVERT (value USING charset) parameter describes the value requirements. The value type to be converted
Must be. The data type to convert to. It can be one of the following:
DATE: conversion of value to date. Format: "YYYY-MM-DD"
DATETIME: converting value to DATETIME.Format: "YYYY-MM-DD HH:MM:SS"
TIME: convert the value to the time. Format: "HH:MM:SS"
CHAR: converting value CHAR (fixed-length string)
SIGNED: converts value signatures (64-bit integers of signatures)
UNSIGNED: converting value to UNSIGNED (unsigned 64-bit integers)
BINARY: converting value to BINARY (binary string)
Charset required. Character set to convert to
Example:
SELECT CONVERT (150, CHAR)
Extended knowledge: MySQL string type
The data type description CHAR (size) is a fixed-length string that can contain letters, numbers, and special characters. The size parameter specifies the column length in characters-it can range from 0 to 255. The default value is 1VARCHAR (size) to hold strings of variable length (which can contain letters, numbers, and special characters). The size parameter specifies the maximum column length of characters-can range from 0 to 65535BINARY (size) equals CHAR (), but stores binary byte strings. The size parameter specifies the column length in bytes. The default value is 1VARBINARY (size) equals VARCHAR (), but binary byte strings are stored. The size parameter specifies the maximum column length in bytes. TINYBLOB for BLOB (binary large objects). Maximum length: 255bytes TINYTEXT contains a string with a maximum length of 255characters TEXT (size) saves a string BLOB (size) with a maximum length of 65535 bytes for BLOB (binary large objects). Data that can hold up to 65535 bytes MEDIUMTEXT saves a string MEDIUMBLOB with a maximum length of 16777215 characters for BLOB (binary large objects). Can hold up to 16777215 bytes of data LONGTEXT saves the string LONGBLOB with a maximum length of 4294967295 characters for BLOB (binary large objects). Can hold up to 4294967295 bytes of data ENUM (val1, val2, val3,...) A string object that can have only one value, selected from a list of possible values. You can list up to 65535 values in the ENUM list. If the inserted value is not in the list, a null value is inserted. Values sort SET (val1, val2, val3,...) in the order you enter. A string object that can contain 0 or more values, selected from a list of possible values. You can list up to 64 value numeric data types in the SET list: this is the end of how mysql converts the specified value to a string type. I hope the above can be helpful and learn more. If you think the article is good, you can share it for more people to see.
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.