Can I set values for other fields when I load data infile in MySQL?

Source: Internet
Author: User
For example, I now have a table, the field has a, B, C, d four, the load data TXT file contains only 3 fields (A, B, c) values, while importing, I can set a value for each record's D field? (such as the user name of the operation, etc.)


Reply to discussion (solution)

LOAD DATA infile Syntax
LOAD DATA [Low_priority | CONCURRENT] [LOCAL] INFILE ' file_name.txt '
[REPLACE | IGNORE]
Into TABLE tbl_name
[Fields
[TERMINATED by ' string ']
[[optionally] enclosed by ' char ']
[Escaped by ' char ']
]
[LINES
[Starting by ' string ']
[TERMINATED by ' string ']
]
[IGNORE number LINES]
[(Col_name_or_user_var,...)]
[SET col_name = expr,...)]
Set broken should be able to meet your requirements.
Note: The character set indicated by the CHARACTER_SET_DATABASE system variable is used to interpret the information in the file. Set names and character_set_client settings do not affect the interpretation of the input.

  • Related Article

    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.