next up previous
Next: SQL Queries Up: p1 Previous: Interactive SQL

Creating an Example Database

  1. The first task is to create a small example database. To do so copy and paste the SQL statements from http://www.macs.hw.ac.uk/~trinder/DbInfSystems/ to create and populate the Emp employee, Dept department, Salgrade Salary Grade and (empty) Bonus tables.

    Hint: You can cut and paste SQL commands from the web page for this practical at http://www.macs.hw.ac.uk/~trinder/DbInfSystems/

  2. You can check the contents of your new tables with the simple queries:
      SELECT * FROM Emp; 
      SELECT * FROM Dept;
      SELECT * FROM Salgrade;
      SELECT * FROM Bonus;
    

  3. Now create a view, and check it's contents.
      CREATE VIEW Emp_View AS SELECT ename, empno FROM Emp;
      SELECT * FROM Emp_View;
    
  4. To preserve your newly created database you must either commit your updates, or quit from MySQL. Commit your new tables in your database:
      commit;
    



Phil Trinder 2011-10-14