SQL
SQL
SQL
Create a table called ESAL having the following columns Employee Number (ENO,
integer, primary key), Employee Name (ENAME, character variable width 25
columns), Date of Birth (DOB, date and Salary (SAL, 5 integer and 2 decimals).
Insert 5 values in table.
a) Display the structure of the table ESAL
b) Increase the salary of all employees by 2000.
c) Rename the column DOB to DBT.
d) Delete the table ESAL.
2. Create a table called DEPOSIT containing columns seat number (SEAT NO,
character), Name (SNAME, character), Gender (GENDER, character) and marks
(MARK, numeric). Insert 5 values in table.
Write MySQL queries for the following.
a) Display the seat number, name and marks of students whose marks are
equal to the highest marks.
b) Display the seat number, gender and marks of students whose marks are
above the average marks.
c) Display the gender, minimum marks and maximum marks of the students
grouped by gender.
d) Display all the rows where the gender is ‘M’.
3. Create a table TAX having the columns Permanent Account Number (PAN, integer),
Name (Name, character), City (CITY, character), Taxable Income (INC, integer) and
Income Tax (ITAX , integer). Insert 5 values in table.
a) Display permanent Account Number, City and Income Tax from this table.
b) Display permanent Account Number, Name and Taxable Income where
Taxable Income is more than the average Taxable Income.
c) Display City, maximum and minimum taxable Income grouped by City.
d) Display all the rows from this table where name contains ‘B’.
4. Create a table TOUR containing columns Travellers Number (TNO, integer), Name
(TNAME, character), Age (Age, integer), destination city (DCity, Character 10), date
of travel (DOT, date) and Fare (Fare, decimal (6,2)). Insert 5 values in table.
a) Display all the rows from the following
b) Display travellers’ number and name where destination city is “Shimla”
from this table.
c) Display travellers no, name, age destination city of the traveller whose
name is “BHARGAV”.
5. Create a table called COLLEGE having the following columns roll number (RN,
integer), students Name (STNAME, character variable width 10 columns),Fees paid
(FEE, width of 6 with 2 decimals) and Date of Admission (DA, Date).Insert 5 values
in table.
a) Add a new columns confirmation (CO, Boolean) to this table.
b) Delete all rows from the table where fees paid are negative.
c) Change the name of the column Roll Number to RNO.
d) Rename the table COLLEGE to MARK
6. Create a table called TAX containing columns (PAN, integer), name (NAME, variable
character), City (CITY character), Taxable Income (INC, integer) and Income Tax
(ITAX, Integer). Insert 5 values in table.
a) Display Pan Number, Name and Income Tax.
b) Display City, maximum and minimum Taxable income group by city
c) Display all the rows where name contains “B”
d) Display Pan Number, Name and Income Tax where taxable income is more
than the Average Taxable.