Programming 6


Lesson 11

Lab–Work with SQL at the Command Line

 

Objectives

 

In this lab assignment, students will demonstrate the abilities to:

 

  • Start MySQL and Apache server
  • Access MySQL using the Command Line
  • Use the Command Line for SQL Commands
  • Change database and list tables using the Command Line
    • Use a Database
    • Describe a Database
    • Create simple queries from a table

 

Lab Task Checklist

 

  • Review:
    • The cmd_lecture presentation
    • Videos or Text Based Tutorials for Command Line (Windows) and Terminal (MAC) found in “Additional Materials”.
    • You will be using the ‘mydatabase’ database created in lab 10. If you were unsuccessful in Lab 10 talk to your instructor who may have an optional way to get the database created.
  • Complete the SQL Exercises and record work with snip shots
  • Make sure your snip shot includes both the SQL statement used and the result set
  • Check your work using the result setexpected at the end of the lab
  • Paste the required snip shots into ONE Word document.
  • Naming Convention: “lastname-cmd-sql”
  • Uploadyour file to Blackboard

Instructions

 

  • Launch your command line interface. You may press Windows logo key plus r key (i.e. hold down Windows logo key + r key) and type cmd.

 

  • Your Windows command line window pops up.

 

  • Create the required queries from the database mydatabaseusing the tables TIMESHEETand

 

  • Take a snapshot of the completed process/query with the command line.

 

 

 

 

 

 

  • Example:

 

 

 

 

 

  • Queries Required:

 

 

QueryTask RequiredTable to Use
1describes the data structuretimesheet
2show all the data and recordstimesheet
3show only the lastname and hourlyWagepersonnel
4show all the data and records where the order is  in ascending (default) based on the hoursWorkedtimesheet
5show all data and records WHERE employees  worked less than or equal to 30  OR equal to 40 hourstimesheet
6show all data and records  where the last digit in the empID is 8timesheet
7show hourlyWage and lastName for records where  the hourlyWage is equal to or more than $8.00 and less than or equal to $12.00 using the BETWEEN operatorpersonnel
8show the empID and hoursWorked  where the last digit in empID is 7 AND hoursWorked = 35timesheet
9show jobTitle and lastname where the order is first based on jobTitle (ascending) and then hourlyWage (descending) orderpersonnel

 

 

 

 

Result Set Expected:

 

 

Query 1:

 

 

 

Query 2:

 

 

Query 3:

 

 

 

 

 

Query 4:

 

 

 

Query 5:

 

 

Query 6:

 

 

 

 

Query 7:

 

 

Query 8:

.

 

 

Query 9:

 

 

 

 

 

Rubrics:

Submittal Requirement met: 9

Each Query: 11.11