In this section, we will find out about different reinforcement stacking techniques. Reestablishing a data set from a reinforcement is a basic and some of the time horribly long cycle.
There are three choices in stacking information: the LOAD DATA proclamation, mysqlimport, and a basic mysqldump reestablish.
Using LOAD DATA
The LOAD DATA proclamation capacities as a mass loader. Survey an illustration of its utilization that heaps a content document −
mysql> LOAD DATA LOCAL INFILE 'products_copy.txt' INTO TABLE empty_tbl;
Note the accompanying characteristics of a LOAD DATA explanation −
- Utilize the LOCAL watchword to keep MariaDB from playing out a profound pursuit of the host, and utilize an unmistakable way.
- The assertion expects an organization comprising of lines ended by linefeeds (newlines) and information esteems isolated by tabs.
- Utilize the FIELDS statement to expressly determine arranging of fields on a line. Utilize the LINES proviso to indicate line finishing. Survey a model underneath.
mysql> LOAD DATA LOCAL INFILE 'products_copy.txt' INTO TABLE empty_tbl
FIELDS TERMINATED BY '|'
LINES TERMINATED BY '\n';
- The assertion expects sections inside the datafile utilize a similar request of the table. In the event that you need to set an alternate request, you can stack the record as follows −
mysql> LOAD DATA LOCAL INFILE 'products_copy.txt' INTO TABLE empty_tbl (c, b, a);
Using MYSQLIMPORT
The mysqlimport apparatus goes about as a LOAD DATA covering permitting similar tasks from the order line.
Burden information as follows −
$ mysqlimport -u root -p --local database_name source_file.txt
Indicate designing as follows −
$ mysqlimport -u root -p --local --fields-terminated-by="|" \
--lines-terminated-by="\n" database_name source_file.txt
Utilize the - segments choice to determine segment request −
$ mysqlimport -u root -p --local --columns=c,b,a \
database_name source_file.txt
Using MYSQLDUMP
Reestablishing with mysqldump requires this basic assertion for stacking the landfill record once more into the host −
shell> mysql database_name < source_file.sql
SPECIAL CHARACTERS AND QUOTES
In a LOAD DATA explanation, statements and extraordinary characters may not be deciphered accurately. The assertion accepts unquoted qualities and treats oblique punctuation lines as getaway characters. Utilize the FIELDS statement to indicate organizing. Highlight cites with "Encased BY," which causes the depriving of statements from information esteems. Change escapes with "Got away BY."