mysql中load data infile时能为其它字段设值吗?

WBOY
Release: 2016-06-20 12:43:34
Original
1107 people have browsed it

比如我现在有一张表,字段有a、b、c、d四个,load data时的txt文件只包含3个字段(a、b、c)的值,在导入的同时,我能为每条记录的d字段设置一个值吗?(比如操作的用户名等)


回复讨论(解决方案)

LOAD DATA INFILE语法
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,...)]
套红的应能满足你的要求
注意:由character_set_database系统变量指示的字符集被用于解释文件中的信息。SET NAMES和character_set_client的设置不会影响对输入的解释。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template