SQL Import TXT and time format operations in SQL

Source: Internet
Author: User
Tags month name

Original: SQL Import TXT and time format operation in SQL

The instructions for importing txt in MySQL are:

Load data local infile "path name" into table "tables name"

For example, the specific location of my file is "F:\\dataset\\beijing\\xx.txt", the table created by the name "person", then the specific expression of the above instruction is:

Load  into table Person;

If your TXT data contains multiple lines, the interval between each row of fields is a comma (",").

You need to specify the delimiter comma when reading, as shown in.

View the read-in data as shown in.

See, read a total of 18 data, as in the TXT file.

Date formatting operations in MySQL

Commonly used strings are formatted as:

Year

%Y Four-digit year

%y Two-digit year

As shown, gets the current system time and formats the display. When input is%y, four-bit time 2015 is displayed. When input is%y, two-bit time 15 is displayed.

Month

%m Two-digit month (01,02,03,,12)

The month (1,2,3,,12) in%c number representation

%b abbreviated month (jan,feb,,dec)

%M month name (january,february,,december)

As shown in. When you enter%y-%m, the display is 12-january (two-bit year, month name, where '-' is the delimiter). When%m is entered, it is displayed as a two digit month. When you enter%c, it is displayed as a number (one-bit and two-bit). When you enter%b, the abbreviated month is displayed.

Days

%d two-digit number of days (01,02,,31)

%e number of days in digital form (1,2,,31)

As shown in. When%e is entered, the number form is displayed. The number of days to display two digits when%d is entered.

Time

%l digital form of hour, 12 hours (1,2,3,,12)

%k digital form of hour, 24 hours (0,1,2,,23)

%H two-digit hours, 24 hours

%h Two-digit hours, 12 hours

%i,%i two-bit digital form (00,01,,59)

%s,%s Two-bit I digital form of second (00,01,02,,59)

%p Morning (AM), PM (PM)

As shown in.

Original content, reproduced please indicate the source. Http://www.cnblogs.com/chuantingSDU/p/4243990.html

Contact information: [Email protected]

SQL Import TXT and time format operations in SQL

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.