1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
--------------
SET AUTOCOMMIT = 0
--------------
--------------
START TRANSACTION
--------------
--------------
DROP DATABASE IF EXISTS `base`
--------------
--------------
CREATE DATABASE IF NOT EXISTS `base`
DEFAULT CHARACTER SET `latin1`
DEFAULT COLLATE `latin1_general_ci`
--------------
--------------
DROP TABLE IF EXISTS trav
--------------
--------------
CREATE TABLE trav (
col_01 integer default null,
col_02 integer default null,
col_03 integer default null,
col_04 integer default null,
col_05 integer default null,
col_06 integer default null,
col_07 integer default null,
col_08 integer default null,
col_date1 datetime default null,
col_date2 datetime default null,
lib varchar(255) default null
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
LOAD DATA LOCAL INFILE 'fichier.txt'
INTO TABLE `trav`
CHARACTER SET latin1
FIELDS TERMINATED BY ';'
ENCLOSED BY ''
ESCAPED BY '\\' LINES
TERMINATED BY '\r\n'
IGNORE 0 LINES
(col_01, col_02, @3, @4, col_05, col_06, @7, @8, col_date1, col_date2, lib)
SET col_03 = case @3 when '' then null else @3 end,
col_04 = case @4 when '' then null else @4 end,
col_07 = case @7 when '' then null else @7 end,
col_08 = case @8 when '' then null else @8 end
--------------
--------------
select * from trav
--------------
+-------------+--------+--------+--------+-------------+--------+--------+--------+---------------------+---------------------+------+
| col_01 | col_02 | col_03 | col_04 | col_05 | col_06 | col_07 | col_08 | col_date1 | col_date2 | lib |
+-------------+--------+--------+--------+-------------+--------+--------+--------+---------------------+---------------------+------+
| -2127007880 | 10 | NULL | NULL | -1971156970 | 2014 | NULL | NULL | 2014-05-10 00:00:00 | 2014-05-10 00:00:00 | web |
| -2127007880 | 10 | 0 | NULL | -1971156970 | 2014 | NULL | 0 | 2014-05-10 00:00:00 | 2014-05-10 00:00:00 | web |
| -2127007880 | 10 | 1 | 0 | -1971156970 | 2014 | 0 | NULL | 2014-05-10 00:00:00 | 2014-05-10 00:00:00 | web |
+-------------+--------+--------+--------+-------------+--------+--------+--------+---------------------+---------------------+------+
--------------
COMMIT
--------------
--------------
SET AUTOCOMMIT = 0
--------------
Appuyez sur une touche pour continuer... |
Partager