Sqlassignment 03

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Assignment:-03

Introduction to sql and sql commands


Instructions:
Please share your answers filled in line in the Word document. Submit code
separately wherever applicable.

Please ensure you update all the details:


Name: Tejas S Nichat ,Batch ID: _11092023__________
Topic: Introduction to sql and sql commands

1) What is SQL, and what are some common uses for it in database management?
2) What is a foreign key in SQL, and how is it used to establish relationships
between tables?
DATABASE CREATE:-
1. Create a database ‘classroom’
2. Create a table named ‘science_class’ with the following properties
3 columns(enrollment_no int, name varchar, science_marks int)

INSERTING & IMPORTING:-


1. Insert the following data into science_class using insert into command
1 popeye 33
2 olive 54
3 brutus 98

2. Import data from CSV file ‘student.csv’ attached in resources to


science_class to insert data of next 8 students
SELECT & WHERE:-
1. Retrieve all data from the table ‘Science_Class’
2. Retrieve the name of students who have scored more than 60 marks

© 360DigiTMG. All Rights Reserved.


Assignment:-03
Introduction to sql and sql commands
3. Retrieve all data of students who have scored more than 35 but less than
60 marks
4. Retrieve all other students i.e. who have scored less than or equal to 35
or more than or equal to 60.

UPDATING TABLES:-
1. Update the marks of popeye to 45
2. Delete the row containing details of the student named ‘robb’
3. Rename column ‘name’ to ‘student_name’

© 360DigiTMG. All Rights Reserved.


Assignment:-03
Introduction to sql and sql commands
create database class_room;
use class_room;
create table science_class(enrollment_id int,name
varchar(20),science_mark int(10));
insert into science_class values(1,'popeye',33),(2,'olive',54),
(3,'brutus',98);
select *from science_class;
select *from science_class where science_mark > 60;
select *from science_class where science_mark > 35 and science_mark <
60;
select *from science_class where science_mark <=35 or science_mark >=
60;
update science_class
set science_mark=45
where enrollment_id=1 limit 1;
select *from science_class;
delete from science_class where name="Robb" limit 1;
select *from science_class;
alter table science_class change column name student_name varchar(20);
select *from science_class;

© 360DigiTMG. All Rights Reserved.

You might also like