Function call related to Mysqlconsole integer time and IP Query

Source: Internet
Author: User
The integer time of Mysqlconsole and the function call related to IP query involve function conversion, as shown in the following code: mysql database storage time. Generally, BigInt type, 10 bits, 13 BITs, or more are designed, the 13-bit value is millisecond, but it is inconvenient to view the bigint value when the database time is queried through the Console. Mysql provides the corresponding date conversion

Mysql console integer time and IP query related function calls are related function conversion, as follows: mysql database storage time, generally design BigInt type, 10 bits, or 13 BITs, or greater, the 13-bit value is millisecond, but it is inconvenient to view the bigint value when the database time is queried through the Console. Mysql provides the corresponding date conversion

Mysql console integer time and IP address query function call

There are related function conversions as follows:

The storage time of the mysql database. Generally, the BigInt type, 10 bits, 13 BITs, or more are designed, of which 13 BITs are milliseconds. However, when querying the database time through the Console, bigint is an integer and cannot be viewed.
Mysql provides functions for date conversion.
WhereFROM_UNIXTIMEThe function is the corresponding big integer converted to the corresponding date,UNIX_TIMESTAMPThe function is a reverse operation.
Example:
Select FROM_UNIXTIME (1344834077); ------ 13:01:17. 0
Select UNIX_TIMESTAMP ('2017-08-13 13:01:17. 0'); ----- 2012?

?

The above 10 bits are used. For 13 BITs, because mysql does not support the millisecond level, you need to remove the corresponding millisecond field, that is, the last three bits, such:
Select FROM_UNIXTIME (1344834077887/1000); ------------- 2012-08-13 13:01:17. 0
The function is also followed by '% Y % D % M % h: % I: % s % x' for the corresponding format date format, output the desired date!
For details, refer to the official website: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_from-unixtime

?

The function expression can be a corresponding field.

?

?

?

The IP address has the same problem when the time is solved. (Ps: Database IP fields have integers, which play an important role in data mining and anti-spam)

?

The corresponding functions are:

?

INET_ATON (expr): A "Point address" (such as 127.0.0.1) representing the network address of the string is provided, and an integer representing the address value is returned.

?

SELECT INET_ATON ('192. 168.130.55 '); ----------- (192 );

?

INET_NTOA (expr): Returns the representation of this address as a string.

?

Select INET_NTOA (3232268855); ------------------- 192.168.130.55

?

?

?

The above are several functions that are useful in queries!

?

(Ps: the above functions are only called during query. In actual use, the related conversion is still implemented in the application layer tool class, because the performance of the related conversion and data calls at the application layer are controllable)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.