Database Reference
In-Depth Information
LOAD DATA INFILE 'log.csv'
INTO TABLE Log
FIELDS TERMINATED BY ','
IGNORE 1 LINES
(ID,
DateCreated,
Browser,
IPNumber,
CookieID,
WebPageID,
ReferringPage )
Figure 5.7
The Log table populated by LOAD DATA.
Figure 5.7 shows the results of the above query, when we select everything from the Log
table.
The above process can seem like a lot of effort to put 5 rows in a table; we have had to
manipulate the load command and probably could have inserted that many rows in the
same time by using INSERT statements. The effort, however, would have been much more
worth if we were inserting a full log file into our database. The file that the above example
file was taken from had over 38 000 rows, which could be inserted into our database with the
same effort as we have expended in the above example. This is where the power of LOAD
DATA comes into its own.
We may also have been importing the data from another database system, such as Oracle
or SQL Server. If this was the case it would be easier to output the data from that DBMS in
a format that the LOAD DATA command instantly recognizes as default; for instance using
tabs as column separators and making the order of the columns the same as our create table
command. The more you can manipulate your data into a standard format, the easier it is
to import into other systems.
Now that we have some data in our database we can begin to see the techniques involved in
retrieving the data.
Search WWH ::




Custom Search