比如我现在有一张表,字段有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的设置不会影响对输入的解释。