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

SQL Sample

Uploaded by

areteshephaestus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

SQL Sample

Uploaded by

areteshephaestus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

CREATE DATABASE db_students_list;

USE db_students_list;

CREATE TABLE Students (


id INT AUTO_INCREMENT PRIMARY KEY,
lastname VARCHAR(255) NOT NULL,
firstname VARCHAR(255) NOT NULL,
age INT NOT NULL,
course VARCHAR(255) NOT NULL
);

CREATE TABLE Subject (


id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
code VARCHAR(255) NOT NULL,
grade VARCHAR(255) NOT NULL,
student_id INT NOT NULL,
FOREIGN KEY (student_id) REFERENCES Students(id)
);

INSERT INTO Students (lastname, firstname, age, course)


VALUES ('Senobio', 'Julius Robert', 34, 'BSINFOTECH');

INSERT INTO Subject (name, code, grade, student_id)


VALUES ('Information Management', 'ITEC 205', '1.75', 1);

SELECT * FROM Students;

SELECT * FROM Subject;

UPDATE Students
SET course = 'BSCOMSCI'
WHERE id = 1;

You might also like