This content originally appeared on DEV Community and was authored by Nidheesh Thangavel
My Journey with SQL on Oracle LiveSQL | Assignment Practice
As part of my DBMS assignment, I decided to go hands-on with Oracle LiveSQL and practice real-world SQL queries. What started as just another task turned into an exciting journey of creating tables, inserting data, altering structures, and running some powerful queries. Let me walk you through my experience!
Step 1: Creating Tables
I began with three main tables:
Students – to store student details
Courses – to hold course information
Enrollments – to manage the many-to-many relationship between students and courses
CREATE TABLE Students (
StudentID NUMBER PRIMARY KEY,
Name VARCHAR2(50) NOT NULL,
Dept VARCHAR2(30),
DOB DATE,
Email VARCHAR2(50) UNIQUE
);
CREATE TABLE Courses (
CourseID NUMBER PRIMARY KEY,
CourseName VARCHAR2(50) NOT NULL,
Credits NUMBER(2)
);
CREATE TABLE Enrollments (
EnrollID NUMBER PRIMARY KEY,
StudentID NUMBER REFERENCES Students(StudentID),
CourseID NUMBER REFERENCES Courses(CourseID),
Grade CHAR(2)
);
Screenshot proof of successful table creation:
Step 2: Altering & Inserting Data
Next, I added a Phone Number column to the Students table and inserted some sample data.
ALTER TABLE Students ADD (PhoneNo VARCHAR2(10));
INSERT INTO Students (StudentID, Name, Dept, DOB, Email) VALUES
(1, ‘Alice’, ‘Computer Science’, DATE ‘2002-07-08’, ‘alice@example.com‘),
(2, ‘Bob’, ‘Electrical’, DATE ‘2001-05-12’, ‘bob@example.com‘),
(3, ‘Charlie’, ‘Mechanical’, DATE ‘2003-09-21’, ‘charlie@example.com‘);
Screenshot proof of inserted rows:
Step 3: Running Queries
String Functions
I queried all student names in uppercase and calculated the length of their email IDs:
SELECT UPPER(Name) AS StudentName, LENGTH(Email) AS EmailLength
FROM Students;
Output:
STUDENTNAME EMAILLENGTH
ALICE 17
BOB 15
CHARLIE 19
Screenshot of results:
I also tried aggregate functions to calculate the average credits of courses and the total number of students:
SELECT AVG(Credits) AS AvgCredits, COUNT(*) AS TotalStudents
FROM Courses, Students;
Screenshot output:
Key Takeaways
SQL is more powerful than it looks – even small queries give deep insights.
Working with constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK) is essential for maintaining data integrity.
Oracle LiveSQL is a fantastic tool for learning + testing SQL without needing local installation.
What’s Next?
This was just the beginning! My next steps will include:
JOIN queries to link Students and Courses.
GROUP BY with HAVING for department-wise insights.
Views & Stored Procedures to wrap logic neatly.
Stay tuned for Part 2 of my SQL journey
This content originally appeared on DEV Community and was authored by Nidheesh Thangavel