Mysql Lab Programs
Mysql Lab Programs
RESULT:
Thus the above program has been executed successfully and the
output is verified.
Q1.Write the query to create the above table and set the
constraints for the attributes.
EXAMNO-PRIMARY KEY,NAME- NOT NULL ,MARK CHECK-MARK SHOULD NOT
EXCEED 500.
QUERY:
Q2.Write the query to insert the mentioned records into the table.
QUERY:
QUERY:
QUERY:
Q5.Write the query to display whose marks in the range 400 to 450
(both values are inclusive).
QUERY:
SELECT * FROM STUDENTS WHERE MARK BETWEEN 400 AND 450;
26
SET-2:
QUERY:
Q2.Write the query to display the details whose name is starts with
‘P’ or ‘B’.
QUERY:
SELECT * FROM STUDENTS WHERE NAME LIKE 'P%' OR NAME LIKE 'B%';
Q3. Write the query to display the student name and section whose
name contain ‘priya’.
QUERY:
Q4. Write the query to display all the details sort by name in
descending order.
QUERY:
QUERY:
SET - 3:
Q1.Write the query to add a new column named as CITY with the data
type VARCHAR(30) and apply the default constraint ‘NOT MENTIONED’
in the students table.
27
QUERY:
QUERY:
Q3.Write the query to redefine the NAME field size into VARCHAR(40)
in the students table.
QUERY:
Q4.Write the query to update the mark as 350 whose marks is null
and update the section is A3 whose section is null.
QUERY:
Q5. Write the query to update the city of all records with the
following cities
[CHENNAI,BENGALURU]
QUERY:
SET-4:
Q1.Write the query to create the patient table and keep DOCID to be
the foreign key with update and delete cascade.
QUERY:
Q2.Write the query to display the count of male and female patients
in the age between 40 and 50.
QUERY:
Q3.Write the query to display the patient id,name and age who fixed
the appointment on September month.
3
29
QUERY:
QUERY:
Q5.write the query to display the sum of the salary of the doctors
department wise.
QUERY:
SET-5
QUERY:
Q2.Write the query to display the doctor id,doctor name and number
of patients need to visit.
QUERY:
Q3.Write the query to display the average salary of each dept from
doctor table.
QUERY:
QUERY:
QUERY:
OUTPUT:
ii)