Question

In: Computer Science

1. Write three command statements to back up the `Orders` Table for data only, structure with...

1. Write three command statements to back up the `Orders` Table for data only, structure with data and structure only using mysqldump. 2. Write the command statement to import the data using mysqlimport from customers.csv file. 3. What's the difference to use the LOAD DATA LOCAL INFILE vs mysqlimport. 4. Write SQL statements: a. Create a database user "cis495_dev1" with password "dolphins". b. Create the database "cis495Demo". c. Grant user "cis495_user1" with "select" ,"delete" and "execute" permission to DB "cis495Demo". d. Revoke the privilege "delete" for the user "cis495_user1". 5. List three ways ( SQL statement: update, alter, set) to change the password from "dolphines" to "icando" for the user "cis495_user1". 6. Explain the difference between user and role.

Solutions

Expert Solution

:: Solution ::

1. Mysqldump is a command-line utility that is used to generate the logical backup of the MySQL database.

# To export to file (data only)
mysqldump -t -u [user] -p[pass] -t orders > orders_data.sql

# To export to file and data

backup: # mysqldump -u[user] -p[pass] [orders] > dumpfilename.sql

# To export to file (structure only)
mysqldump -d -u [user] -p[pass] -d orders > orders_structure.sql

2. # To Import the data

$ mysqlimport -u [user] -p[pass] ~/customer.csv

Note : The options in use are:

  • The -u flag indicates that the MySQL username will follow.
  • The -p flag indicates we should be prompted for the password associated with the above username.
  • database_name is of course the exact name of the database to export.
  • The > symbol is a Unix directive for STDOUT, which allows Unix commands to output the text results of the issued command to another location. In this case, that output location is a file path, specified by output_file_path.

3. Differnce between The LOAD data local infile and mysqlimport

The LOAD DATA statement reads rows from a text file into a table at a very high speed. LOAD DATA is the complement of SELECT ... INTO OUTFILE. To write data from a table to a file, use SELECT ... INTO OUTFILE. To read the file back into a table, use LOAD DATA. The syntax of the FIELDS and LINES clauses is the same for both statements. At some MySQL installations, the LOCAL loading capability may have been disabled for security reasons. If that is true at your site, omit LOCAL from the statement and specify the full pathname to the file. See Specifying the Datafile Location for more information on local versus non-local data loading.

MySQL also includes a utility program named mysqlimport that acts as a wrapper around LOAD DATA so that you can load input files directly from the command line. The mysqlimport command that is equivalent to the preceding LOAD DATA statement looks like this, assuming that mytbl is in the cookbook database

Where as in mysqlimport, as with other MySQL programs, you may need to specify connection parameter options such as --user or --host (Starting and Stopping mysql).

The following list describes LOAD DATA’s general characteristics and capabilities; mysqlimport shares most of these behaviors. There are some differences that we’ll note as we go along, but for the most part.

Thank you...


Related Solutions

C++ only please Description A hash table is a data structure that is used to store...
C++ only please Description A hash table is a data structure that is used to store keys/value pairs. It is perfect to use when you have a large amount of directory-type information and the operations you need to perform are to insert, delete, print, and search. I am giving you all a lot more freedom in this program in that the value held in your hash table can be a pointer to any object created from your own custom class....
1. Using the alter table command, add a new column named gender making sure that only...
1. Using the alter table command, add a new column named gender making sure that only values of M, F or O are allowed. 2. Modify the data in the customers table to change the state for customers with ID number 2, 4, and 5 to NV. 3. Create a sequence that starts with -100 and increments by 10. Show the first value of the sequence. 4. Create a table named MYDATA with the following columns: id (primary key) and...
Write an SQL command that creates a SHOP table. The table should have a shop_id, a shop_name, a shop_location
Write an SQL command that creates a SHOP table. The table should have a shop_id, a shop_name, a shop_location
UNIX ONLY Write a bash script that will accept a filename as a command line argument....
UNIX ONLY Write a bash script that will accept a filename as a command line argument. Your script should first check whether the filename has been passed as argument or not (hint: at least one argument has to be provided). If no argument has been provided your script should display appropriate message and exit. If a file name has been provided, your script should check if the file exists in the current directory and display the contents of the file....
1. Write the statements to create a table named REQUIREMENTS. The table has the following columns:...
1. Write the statements to create a table named REQUIREMENTS. The table has the following columns: credits number (primary key) and degree name. 2. Write the statements to create a table named CANDIDATE with the following columns names. Pick the best column type: student_id, first name, last name, credits and graduation date. The credits column is a foreign key to the credits column in the REQUIREMENTS table. 3. Write the statement(s) to Insert 2 rows in your REQUIREMENTS table. Make...
1. The basic data structure for a Pivot Table is A. a pie chart B. a...
1. The basic data structure for a Pivot Table is A. a pie chart B. a line chart C. a decision variable D. an uncontrollable E. a multidimensional cube 2. Which traits can describe big data? A. All of the above B. None of the above C. High speed D. High variety E. High volume 3. When you only have one data series to visualize, you do need to add a legend. True False 4. Which of the following would...
- What SQL command would you use to make a table for products that includes three...
- What SQL command would you use to make a table for products that includes three columns: a product’s ID, a product’s cost, and a product’s selling price? - What SQL command would you use to make a table for telephone directory that contains a person’s full name, a person’s cellphone number, and a person’s home phone number? - What SQL command would you use to make a table for an inventory of network equipment that includes the following: the...
Surgical Technology program Case study: A CST is setting up the back table and mayo stand...
Surgical Technology program Case study: A CST is setting up the back table and mayo stand while the patient is in the OR, and the anesthesia care provider is preparing to administer general anesthesia. After confirming that the external steam indicator has changed color, the CST places the basin set from the ring stand to the back table and continues moving items to their appropriate place. Just before the patient is anesthetized, the circulator notices water on the inside of...
Question 1: Part 1 Write SQL statements for the following queries from the ‘EMPLOYEE’ table in...
Question 1: Part 1 Write SQL statements for the following queries from the ‘EMPLOYEE’ table in the WPC Database in MySQL: Display all records from the Employee table for employees working in the “Marketing” department. Display all records from the Employee table for employees working in the “Marketing” department OR “Finance” Department. Display the Last Names of all employees such that each last name appears only once. Display all the attributes for employees whose employee number is less than 10....
Hiring by race. Please state your opinion and back it up thoroughly to BOTH statements. Statement...
Hiring by race. Please state your opinion and back it up thoroughly to BOTH statements. Statement 1. Hiring by race allows for a more diverse workplace. Statement 2. Race should never be a factor in any hiring or school decision.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT