Mailing List
Home
MySQL General - General MySQL discussion
MaxDB - Everything about MaxDB, formerly known as SAP DB
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
ODBC - ODBC with the MySQL Connector/ODBC driver
Perl - Perl support for MySQL with DBI and DBD::mysql
MySQL++ - Programming with the C++ API to MySQL
Subjects
mysql openssl Question
mysql:it 's a db not a dbms how it 's possible?!
Does the binary log enabling affect the MySQL performances?
Strange behavior, Table Level Permission
FULLTEXT query format question
Preventing Duplicate Entries
Comparing and writing out BLOBS
Executing MySQL Commands From Within C Program
Can 't access mysql after kernel upgrade
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Downgrade Mysql from 4 to 3 23
MySQL Cluster Software
mysql test 4 1 fails with the gis test
ERROR 2002: Can 't connect to local MySQL server through socket
Getting Identity after INSERT
Update one field with more fields from another table
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
mysql have same function mthod as Oracle decode()
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
load data into 2 tables and set id

load data into 2 tables and set id

2004-06-09       - By mos

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

At 02:34 PM 6/9/2004, you wrote:
>Hi,
>
>I need some help please! I have 60GB of proxy logs to parse and load into
>a mysql database. I 've written a parsing script but I 'm stuck now on how
>to load the data in.
>
>I have a database called PROXY_LOG with 2 tables:
>
>USER_TABLE
>user_id date_time url_id size
>
>and
>
>URL_TABLE
>url_id url category
>
>
>The data values I have for each record are:
>
>user_id date_time size url category
>
>for example:
>
>u752359 2004-04-02 12:33:04 3403 http://www.mysql.com/index.html
>business
>
>The problem is I 'm not sure how to load the data into the 2 tables and set
>the url_id. Could anyone point me in the right direction please?
>
>Many thanks,
>
>js.

js,
Is this a one time operation? If so, you could create a temporary
table with all the fields:

>BIG_TABLE
>user_id date_time url_id size url category

and use Load Data InFile to load the data into this one table.
Then create the two smaller tables using:

create table USER_TABLE select user_id, date_time, url_id, size from
BIG_TABLE;
create table URL_TABLE select url_id, url, category from BIG_TABLE;
drop table BIG_TABLE;

So there you have it in 3 lines of code. :-)

Mike

P.S. If you could break the text file into two files to begin with, then
two Load Data InFile statements would handle things nicely.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=mysql @(protected)