Which two methods will restore data to the t1 table?

In a test database, you issue the SELECT … INTO OUTFILE statement to create a file with your
t1 table data.
You then TRUNCATE this table to empty it.

Mysql> SELECT * INTO OUTFILE ‘/tmp/t1.sql’ from t1;
mysql> TRUNCATE t1;
Which two methods will restore data to the t1 table?

In a test database, you issue the SELECT … INTO OUTFILE statement to create a file with your
t1 table data.
You then TRUNCATE this table to empty it.

Mysql> SELECT * INTO OUTFILE ‘/tmp/t1.sql’ from t1;
mysql> TRUNCATE t1;
Which two methods will restore data to the t1 table?

A.
Mysql> LOAD DATA INFILE ‘/tmp/t1.sql’ INTO TABLE t1;

B.
$ mysqladmin – u root – p – h localhost test – restore /tmp/t1.sql

C.
$ mysql – u root – p – h localhost test < /tmp/t1.sql

D.
$ mysqlinport – u root – p – h localhost test /tmp/t1.sql

E.
Mysql> INSERT INTO t1 VALUES FROM ‘/tmp/t1.sql’;

Explanation:



Leave a Reply 9

Your email address will not be published. Required fields are marked *


Ispanico

Ispanico

Incomplete
Answers A and D
Tested with MySQL

wolfsrudel

wolfsrudel

What about C?

ispanico

ispanico

I think not C
t1.sql don’t contain table structure, only data, as the question says “you issue the SELECT … INTO OUTFILE”

Kalyan

Kalyan

Table (structure) is already there in DB. just issued Truncate not drop.

Bruno

Bruno

On B,C,D the command refers to “test” table and not to “t1” table.

Bruno

Bruno

Ooops, test are the DATABASE!

I tested on Mysql and A and D works!

C doesn’t work!

vasben

vasben

A and D

From mysqlimport –help:

Loads tables from text files in various formats. The base name of the
text file must be the name of the table that should be used.
If one uses sockets to connect to the MySQL server, the server will open and
read the text file directly. In other cases the client will open the text
file. The SQL command ‘LOAD DATA INFILE’ is used to import the rows.

So, both A and D uses LOAD DATA INFILE, the right way to restore data exported with SELECT … INTO OUTFILE.

Jose

Jose

Is not C because a structured of ‘dump’:

cat /tmp/t1.sql
1
2
3
4
5

I’m testing in my instance and alternative A and D is correct.

The alternative C returned:

~# mysql test < /tmp/t1.sql
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1
2
3
4
5' at line 1