2005-03-16 10:13:35 +01:00
drop table if exists t1, t2;
2003-05-05 13:52:39 +02:00
create table t1 (a date, b date, c date not null, d date);
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',';
2003-05-22 10:58:39 +02:00
Warnings:
2004-02-16 09:03:25 +01:00
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'd' at row 1
Warning 1265 Data truncated for column 'a' at row 2
Warning 1265 Data truncated for column 'b' at row 2
Warning 1265 Data truncated for column 'd' at row 2
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
2003-05-05 13:52:39 +02:00
SELECT * from t1;
a b c d
0000-00-00 NULL 0000-00-00 0000-00-00
0000-00-00 0000-00-00 0000-00-00 0000-00-00
2003-03-03 2003-03-03 2003-03-03 NULL
2003-03-03 2003-03-03 2003-03-03 NULL
2003-05-26 10:47:03 +02:00
truncate table t1;
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
2003-06-04 22:17:01 +02:00
Warnings:
2004-02-16 09:03:25 +01:00
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'd' at row 1
Warning 1265 Data truncated for column 'b' at row 2
Warning 1265 Data truncated for column 'd' at row 2
2003-05-26 10:47:03 +02:00
SELECT * from t1;
a b c d
NULL NULL 0000-00-00 0000-00-00
NULL 0000-00-00 0000-00-00 0000-00-00
NULL 2003-03-03 2003-03-03 NULL
2003-05-05 13:52:39 +02:00
drop table t1;
2003-08-22 03:07:40 +02:00
create table t1 (a text, b text);
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
2003-09-11 18:06:23 +02:00
Warnings:
2004-02-16 09:03:25 +01:00
Warning 1261 Row 3 doesn't contain data for all columns
2003-08-22 03:07:40 +02:00
select concat('|',a,'|'), concat('|',b,'|') from t1;
concat('|',a,'|') concat('|',b,'|')
|Field A| |Field B|
|Field 1| |Field 2'
Field 3,'Field 4|
|Field 5' ,'Field 6| NULL
|Field 6| | 'Field 7'|
drop table t1;
2003-12-14 05:39:52 +01:00
create table t1 (a int, b char(10));
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
2003-12-19 15:25:50 +01:00
Warnings:
2005-12-02 12:01:44 +01:00
Warning 1264 Out of range value for column 'a' at row 3
2004-06-15 22:38:36 +02:00
Warning 1262 Row 3 was truncated; it contained more data than there were input columns
2005-12-02 12:01:44 +01:00
Warning 1264 Out of range value for column 'a' at row 5
2004-06-15 22:38:36 +02:00
Warning 1262 Row 5 was truncated; it contained more data than there were input columns
2003-12-14 05:39:52 +01:00
select * from t1;
a b
1 row 1
2 row 2
0 1234567890
3 row 3
0 1234567890
truncate table t1;
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines;
2003-12-19 15:25:50 +01:00
Warnings:
2005-12-02 12:01:44 +01:00
Warning 1264 Out of range value for column 'a' at row 4
2004-02-16 09:03:25 +01:00
Warning 1261 Row 4 doesn't contain data for all columns
2003-12-14 05:39:52 +01:00
select * from t1;
a b
1 row 1
2 row 2
3 row 3
0
drop table t1;
2005-09-22 09:46:01 +02:00
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
create table t1(id integer not null auto_increment primary key);
insert into t1 values(0);
select * from t1;
id
0
select * from t1;
id
0
SET @@SQL_MODE=@OLD_SQL_MODE;
2005-09-23 14:37:22 +02:00
drop table t1;
2005-06-23 01:14:14 +02:00
create table t1 (a varchar(20), b varchar(20));
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b);
2005-06-23 01:14:14 +02:00
select * from t1;
a b
field1 field2
a"b cd"ef
a"b c"d"e
drop table t1;
2005-03-16 02:32:47 +01:00
create table t1 (a int default 100, b int, c varchar(60));
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
2005-03-16 02:32:47 +01:00
select * from t1;
a b c
NULL 20 b=10
NULL 25 b=15
truncate table t1;
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
2005-03-16 02:32:47 +01:00
select * from t1;
a b c
NULL NULL oops
NULL NULL oops
truncate table t1;
set @c:=123;
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
2005-03-16 02:32:47 +01:00
select * from t1;
a b c
100 10 123
100 15 123
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b);
2005-03-16 02:32:47 +01:00
select * from t1;
a b c
100 10 123
100 15 123
100 NULL NULL
100 NULL NULL
select @a, @b;
@a @b
NULL 15
truncate table t1;
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
2005-03-16 02:32:47 +01:00
select * from t1;
a b c
1 2 Wow
3 4 Wow
5 6 Wow
truncate table t1;
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c));
2005-03-16 02:32:47 +01:00
select * from t1;
a b c
1 2 1+2+123+2+NIL
3 4 3+4+123+4+NIL
5 6 5+6+123+6+NIL
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
2005-03-16 02:32:47 +01:00
ERROR HY000: Can't load value from file with fixed size rows to variable
2005-03-16 10:13:35 +01:00
create table t2 (num int primary key, str varchar(10));
insert into t2 values (10,'Ten'), (15,'Fifteen');
truncate table t1;
2006-01-24 08:30:54 +01:00
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n);
2005-03-16 10:13:35 +01:00
select * from t1;
a b c
10 NULL Ten
15 NULL Fifteen
drop table t1, t2;
2006-01-18 09:55:38 +01:00
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1);
SET NAMES latin1;
SET character_set_filesystem=filename;
select @@character_set_filesystem;
@@character_set_filesystem
filename
SELECT * INTO OUTFILE 't-1' FROM t1;
DELETE FROM t1;
LOAD DATA INFILE 't-1' INTO TABLE t1;
SELECT * FROM t1;
a
1
DELETE FROM t1;
SET character_set_filesystem=latin1;
select @@character_set_filesystem;
@@character_set_filesystem
latin1
LOAD DATA INFILE 't@002d1' INTO TABLE t1;
SELECT * FROM t1;
a
1
DROP TABLE t1;
SET character_set_filesystem=default;
select @@character_set_filesystem;
@@character_set_filesystem
binary