In this project, you will add a new table for home run leaders to the baseball_stats database. Before you create the new table, you will create a text file using data from the teamstats table. You will then import the data from the text file into MySQL to create a new table named hrleaders. To create the home run leaders table, you will use the INTO OUTFILE clause with a SELECT statement. The INTO OUTFILE clause copies the returned records into a specified file. You will use the FIELDS TERMINATED BY and LINES TERMINATED BY clauses to specify how the text file should be structured. Because you will import the home run records into the new table, you separate each field with a tab and each line with a line break. If you do not have the FILE privilege, skip this exercise.
What will be an ideal response?
Answer:
Please follow these steps in order to complete the given criteria:-
Step1)
a) Log into the MYSQL monitor with your root account.
b) Enter the following command to create a database named baseball_stats:
mysql> CREATE DATABASE baseball_stats;
c) After that you see "Query OK" message, then enter the following command to select the baseball_stats database:
mysql> use baseball_stats;
d)After that you see that "Database changed" message, then type the following command to ensure the selected database:
mysql> SELECT DATABASE();
Step 2)
a) Return to the MySQL Monitor and create the table teamstats:
mysql> CREATE TABLE teamstats( Team varchar(50), G int, AB int, B int AVG float);
b)After that you see "Query OK" message, then enter the following command to display the structure of the new table:
mysql> DESCRIBE teamstats;
c) Enter the following SQL statement which return the team and home run leader fields for the teams:
mysql>SELECT team, G FROM teamstats
-> INTO OUTFILE 'path/hrleaders.txt'
-> FIELDS TERMINATED BY '\t'
-> LINES TERMINATED BY '\n';
d) Enter Load data statement that insert records from team_stats.txt file into the hrleaders table:
mysql> LOAD DATA LOCAL INFILE 'path/team_stats.txt'
-> INTO TABLE hrleaders;
e)After that you see "Query OK" message, then enter the following command to view all the records in teamstats table:
mysql> SELECT * FROM hrleaders;
mysql> SHOW TABLES;
Step 3) NOw run these Queries
a) Return to the MySQL Monitor and enter the following statement, which return the team G(games played), and AB(at bats) fields from table teamstats:
mysql> SELECT team, G, AB FROM hrleaders;
You might also like to view...
Select the false statement. A rethrown exception:
a. Is detected by the next enclosing try block. b. Is the immediate result of a throw command. c. Can be processed by exception handlers following the enclosing try block. d. Must have been fully processed at the time it was rethrown.
Language standards are supposed to be reviewed every ______ years.
Fill in the blank(s) with the appropriate word(s).
____________________ is the process of entering audio data into the computer.
Fill in the blank(s) with the appropriate word(s).
Which one of the following packages provides encryption support?
a. org.json b. javax.* c. android.* d. junit.*