Load Data into more than 1 Table

Load Data into more than 1 Table

am 03.11.2004 17:49:27 von Scott Simpson

------_=_NextPart_001_01C4C1C5.155AF3BE
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Can I use 'LOAD DATA INFILE' to load data into more than 1 table?
=20
For example, say I have a text file containing
=20
1 birthday cat
2 anniversary dog
=20
and I want column 2 in table birthdays and column 3 in table pets and
I'm lazy and can't be bothered to split the file or loop through an
insert statement. =20
=20
Can someone suggest a shortcut?
=20
Thanks,
Scott =20

=20


------_=_NextPart_001_01C4C1C5.155AF3BE--

Re: Load Data into more than 1 Table

am 03.11.2004 18:36:13 von Dan Bolser

Perhaps

man column (on linux) can help you..

Else I would load both and make a join to get what you want (if that is
possible).

Finally I would use a perl one liner to hack the files up.


On Wed, 3 Nov 2004, Scott Simpson wrote:

>Can I use 'LOAD DATA INFILE' to load data into more than 1 table?
>
>For example, say I have a text file containing
>
>1 birthday cat
>2 anniversary dog
>
>and I want column 2 in table birthdays and column 3 in table pets and
>I'm lazy and can't be bothered to split the file or loop through an
>insert statement.
>
>Can someone suggest a shortcut?
>
>Thanks,
>Scott
>
>
>
>


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Load Data into more than 1 Table

am 04.11.2004 20:17:10 von Darren Duncan

Once the writeable views support is functional, you should be able to
just create a view that joins the two tables and has the interface
matching your file; then just insert into the view from each file
line. -- Darren Duncan

At 4:49 PM +0000 11/3/04, Scott Simpson wrote:
>Can I use 'LOAD DATA INFILE' to load data into more than 1 table?
>
>For example, say I have a text file containing
>
>1 birthday cat
>2 anniversary dog
>
>and I want column 2 in table birthdays and column 3 in table pets and
>I'm lazy and can't be bothered to split the file or loop through an
>insert statement.
>
>Can someone suggest a shortcut?
>
>Thanks,
>Scott

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Load Data into more than 1 Table

am 04.11.2004 21:42:32 von Dan Bolser

Sorry, first time I read your mail wrong, I thought you had two files,
part of both to go to one table... Now I realize you have one file which
you want to part load twice.

This is easy...

From "man mysqlimport" (or it shoudl be... I found it at
http://dev.mysql.com/doc/mysql/en/mysqlimport.html)...

--columns=column_list, -c column_list
This option takes a comma-separated list of column names as its
value. The order of the column names indicates how to match up data file
columns with table columns.


(in linux) say

ln -s my_double_table_dump table_name_one.pipe
ln -s my_double_table_dump table_name_two.pipe

then

mysqlimport table_name_one.pipe --columns=1,2

ooops... That wont work, columns wan't table column names...

Cay you say

--columns=NULL,two,three
--columns-one,NULL,NULL

??




On Thu, 4 Nov 2004, Darren Duncan wrote:

>Once the writeable views support is functional, you should be able to
>just create a view that joins the two tables and has the interface
>matching your file; then just insert into the view from each file
>line. -- Darren Duncan
>
>At 4:49 PM +0000 11/3/04, Scott Simpson wrote:
>>Can I use 'LOAD DATA INFILE' to load data into more than 1 table?
>>
>>For example, say I have a text file containing
>>
>>1 birthday cat
>>2 anniversary dog
>>
>>and I want column 2 in table birthdays and column 3 in table pets and
>>I'm lazy and can't be bothered to split the file or loop through an
>>insert statement.
>>
>>Can someone suggest a shortcut?
>>
>>Thanks,
>>Scott
>
>


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org