Class Exercise: File Operations(SQL)
1. Login to an interactive interface for SQL.
2. Use the create command to define a table(file) named Staff.
The column names, data types and lengths are described below:
Table Name Column Name Data Type Length Comment/constraint
---------- ----------- --------- ------ -------------------
Staff: id int 3 primary key
name varchar 15 not null
office char 7
fee decimal 7,2 default 0.00
reviewDate date ---
3. Start a "transaction" that may be committed("saved") or rolled back ("undo").
4. Use insert commands(or load utility) to store data rows into Staff.
load data local infile 'd:/path.ext' into table staff
[fields terminated by ','];
5. Select (project) all column data from Staff.
6. Modify the staff table data with the following operations:
a. Delete that row where the id is = 705;
b. Use update to set the office to 'JO 235' for that with id=876;
c. Apply an insert to set id=864, Name='Harter', Office='JO 212', and
fee=4343.43 in a new row for Staff;
d. Select all data from Staff, then rollback your changes.
6. Issue a select command to retrieve staff data in order by ReviewDate.
7. Delete all data from staff and drop the table.
8. Exit the SQL interactive environment.
* Data for the Staff Table(id,name,office,fee,reviewDate):
033,Huerter,JO 210,3579.13,2013-11-2
428,Suh,JO 207,4567.80,2013-12-20
533,Brown,JO 238,3838.38,2013-12-23
705,McWhorter,JO 218,2975.31,2013-12-15
803,Creider,JO 122,7272.72,2013-12-19
876,Saffer,JO 122,5775.33,2013-12-19