2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQL の LOAD DATA で関数や計算式をかます

Last updated at Posted at 2013-04-05
$ cat data.txt
1	a
2	b
3	c
CREATE TABLE xx
(
  id INT NOT NULL PRIMARY KEY,
  ss VARCHAR (255) NOT NULL
);

LOAD DATA LOCAL INFILE 'data.txt' INTO TABLE xx (@id, @ss)
  SET id = @id * 2, ss = UPPER(@ss);

SELECT * FROM xx;
/*
+------+------+
| id   | ss   |
+------+------+
|    2 | A    |
|    4 | B    |
|    6 | C    |
+------+------+
*/
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?