Activity: Intro to Oracle & PL/SQL¶
Practice exercises for getting started with Oracle and PL/SQL blocks.
Exercise 1: Your First Block¶
Write an anonymous PL/SQL block that:
- Declares a variable for your name
- Declares a variable for the current date
- Prints: "Hello, [name]! Today is [date]."
Solution
Exercise 2: SELECT INTO¶
Write a block that retrieves the name and GPA of student 101 and prints them.
Solution
Exercise 3: Exploring the Schema¶
Run these queries to explore the lab database:
-- How many students?
SELECT COUNT(*) FROM Students;
-- What courses are offered?
SELECT dept, cnum, ctitle FROM Courses;
-- Who is enrolled where?
SELECT s.sname, c.ctitle, e.grade
FROM Students s
JOIN Enrollments e ON s.snum = e.snum
JOIN SchClasses sc ON e.classnum = sc.classnum
JOIN Courses c ON sc.cnum = c.cnum;