0% found this document useful (0 votes)
3 views1 page

SQL Practical Code

The document provides SQL code for creating and managing two tables: COURSES and STUDENTS. It includes commands to create the tables, insert records into them, and update course fees. The COURSES table contains course details while the STUDENTS table links students to their respective courses through a foreign key constraint.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

SQL Practical Code

The document provides SQL code for creating and managing two tables: COURSES and STUDENTS. It includes commands to create the tables, insert records into them, and update course fees. The COURSES table contains course details while the STUDENTS table links students to their respective courses through a foreign key constraint.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DBMS Practical SQL Code

1. Create COURSES Table


CREATE TABLE Courses (
Course_ID INT PRIMARY KEY,
Course_Name VARCHAR(50),
Duration VARCHAR(20),
Fees NUMERIC CHECK (Fees > 0)
);

2. Insert Records into COURSES


INSERT INTO Courses VALUES
(101, 'BCA', '3 Years', 45000),
(102, 'BBA', '3 Years', 50000),
(103, 'MCA', '2 Years', 60000),
(104, '[Link]', '4 Years', 80000);

3. Create STUDENTS Table


CREATE TABLE Students (
Student_ID INT PRIMARY KEY,
Name VARCHAR(50),
Age INT,
Course_ID INT,
Email VARCHAR(100),
CONSTRAINT fk_course
FOREIGN KEY (Course_ID)
REFERENCES Courses(Course_ID)
);

4. Insert Records into STUDENTS


INSERT INTO Students VALUES
(1, 'Amit Sharma', 19, 101, 'amit@[Link]'),
(2, 'Neha Verma', 21, 102, 'neha@[Link]'),
(3, 'Rahul Singh', 22, 103, 'rahul@[Link]'),
(4, 'Priya Gupta', 20, 101, 'priya@[Link]'),
(5, 'Anil Kumar', 23, 103, 'anil@[Link]');

5. Update Course Fees


UPDATE Courses
SET Fees = 96000
WHERE Course_ID = 104;

You might also like