0% found this document useful (0 votes)
6 views6 pages

Q. Create The Database Streams - of - Students

Uploaded by

samarsingh9551
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)
6 views6 pages

Q. Create The Database Streams - of - Students

Uploaded by

samarsingh9551
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
You are on page 1/ 6

Q.

Create the database streams_of_students


mysql> create database Streams_of_Students;

Query OK, 1 row affected (0.01 sec)

Using the database


mysql> USE Streams_of_Students;

Database changed

Q . Create the table student by choosing appropriate data


types based on the given data
mysql> create table stream

-> (stcode char(4) primary key,

-> streams varchar(30)

-> );

Query OK, 0 rows affected (0.01 sec)

desc streams;

SELECT*FROM STREAM;
Creating table
create table students

-> (admnno int primary key,

-> name varchar(25),

-> stcode char(4)

-> );

Query OK, 0 rows affected (0.01 sec)

select*from students;

Q . Jay has now changed his stream to humanity . Write an


appropriate sql query
mysql> UPDATE students

-> set stcode = 's03'

-> where name = 'jay';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0


Q. Display the name of student whose name end with
character ‘a’ .
select * from students

-> where name LIKE "%a"

-> ORDER BY name;

Q. Display the name of student enrolled in science and


humanity stream ,order by name in alphabetical order .
select name,streams from students,STREAM WHERE STUDENTS.STCODE=STREAM.STCODE AND
STREAMS IN('SCIENCE','HUMANITIES') ORDER BY NAME,ADMNNO;

Q. List the no. of in each stream having more than 1 student


> SELECT STREAMS,COUNT(STREAMS) FROM STUDENTS,STREAM

-> WHERE STUDENTS.STCODE = STREAM.STCODE

-> HAVING COUNT(STREAMS)>1;


Q. Display the name of student enrolled in different stream
mysql> SELECT ADMNNO,NAME,STREAMS FROM STUDENTS,STREAM

-> WHERE STUDENTS.STCODE = STREAM.STCODE

-> ORDER BY ADMNNO DESC;

SELECT* FROM STUDENTS,STREAM;

Q. Add a new column “teacher incharge” in the stream table.


ALTER TABLE STREAM

-> ADD COLUMN TEACHERSINCHARGE VARCHAR(30);


Query OK, 0 rows affected (0.01 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> UPDATE STREAM

-> SET TEACHERSINCHARGE = 'ANANYA KANT'

-> WHERE STREAMS = 'SCIENCE';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

UPDATE STREAM

-> SET TEACHERSINCHARGE = 'JOSEPH TURNER'

-> WHERE STREAMS ='COMMERCE';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

UPDATE STREAM

-> SET TEACHERSINCHARGE = 'SAKSHI GILL'

-> WHERE STREAMS = 'HUMANITIES';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0


Q. List the name of teachers and students .
-> WHERE STUDENTS.STCODE = STREAM.STCODE;

You might also like