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. 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 ','];
4. Select (project) all column data from Staff.
5. Start a "transaction" that may be committed("saved") or rolled back ("undo").
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.
7. Issue a select command to retrieve staff data in order by reviewDate.
8. Delete all data from staff and drop the table.
9. Exit the SQL interactive environment.
* Data for the Staff Table(id,name,office,fee,reviewDate):
033,'Huerter','JO 210',3579.13,'2013-11-02'
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'