13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

13<br />

Advanced <strong>MySQL</strong> Programming<br />

IN THIS CHAPTER,YOU LEARN ABOUT SOME more advanced <strong>MySQL</strong> topics, including<br />

table types, transactions, <strong>and</strong> stored procedures.<br />

Key topics covered in this chapter include<br />

n The LOAD DATA INFILE statement<br />

n Storage engines<br />

n Transactions<br />

n Foreign keys<br />

n Stored procedures<br />

The LOAD DATA INFILE Statement<br />

One useful feature of <strong>MySQL</strong> that we have not yet discussed is the LOAD DATA INFILE<br />

statement.You can use it to load table data in from a file. It executes very quickly.<br />

This flexible comm<strong>and</strong> has many options, but typical usage is something like the<br />

following:<br />

LOAD DATA INFILE “newbooks.txt” INTO TABLE books;<br />

This line reads row data from the file newbooks.txt into the table books. By default,<br />

data fields in the file must be separated by tabs <strong>and</strong> enclosed in single quotation marks,<br />

<strong>and</strong> each row must be separated by a newline (\n). Special characters must be escaped<br />

out with a slash (\). All these characteristics are configurable with the various options of<br />

the LOAD statement; see the <strong>MySQL</strong> manual for more details.<br />

To use the LOAD DATA INFILE statement, a user must have the FILE privilege discussed<br />

in Chapter 9,“Creating Your <strong>Web</strong> Database.”

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!