0% found this document useful (0 votes)
20 views

TYBCom Computer MySQL Notes - 241111 - 123746

Computer my sql

Uploaded by

Tanishqa More
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)
20 views

TYBCom Computer MySQL Notes - 241111 - 123746

Computer my sql

Uploaded by

Tanishqa More
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/ 4

Advait Coaching Classes

Advait Coaching Classes


TYBCom – MySQL

A. Write statements in MySQL for the following :


1. Display the names of all the databases.
2. To create a database dept.
3. To Select the database debt.
4. To see the list of tables in the current database.
5. To see the list of tables in the current database.

6. Write a MySQL statement to create a table name BILL containing information of customers staying in
a hotel. The table must have column for :-
✓ Customer’s name (CNAME, character, variable of width 20, distinct, not empty),
✓ Customer’ address (CADDR, character, fixed width 50),
✓ Room number (ROOM, integer),
✓ Type of room (TYPE, character, width 10, not empty, which contains default entry as “NON AC”) &
✓ Days stayed (DAYS, integer, positive).

7. Write a MySQL statement to create a table named ECHARGE containing information of the customers
using electricity provided by XYZ company, having the columns
✓ Customer’s identification number (C_ID, distinct integer),
✓ Customer name (CNAME, character, variable width 20, not empty),
✓ Customer’s address (C_ADR, character, variable width 30),
✓ Type of connection (TYPE, character, of width 12, containing default entry ‘RESIDENTIAL’, should
not be empty) and
✓ Units consumed (UNITS, positive integer).

8. Write MySQL statement to create a database UNIV. In this database create a table called ADMISSION
using the following :
Column Column Name Type Length
Name of the student Sname Char 25
Gender Male Boolean
Date of birth Dob Date
Fees paid Fees Decimal 8.2

9. Write MySQL statements to create a database COLLEGE. In this database create a table LIBRARY using
the following :
Column Column Name Type Length
Name of the book Bname Char 25
Author’s Name Author Char 15
Date of purchase Pdate Date ̶
Number of pages No Integer 4

10. Write a MySQL statement to create a database PAY. In this database create a table called STOCK having
the following columns,
✓ Item number (INO, integer, Primary key),
✓ Item name (INAME, character, having variable width of 15 columns)
✓ Opening stock (OPSTK, integer, default value 0),

ACC – TYBCom 1 Computer MySQL


Advait Coaching Classes
✓ Purchase (PURC, integer, should not be negative),
✓ Closing stock (CLSTK, integer),
✓ Price (PRICE, width 9 with 2 decimals) and
✓ Date of sale (DOS, Date),

11. Write a MySQL statement to create a table named DEPT containing information of the employees with
the following columns,
✓ Employee Identification Number (EID, integer primary key),
✓ Employee Name (NAME, character, variable width of 15 columns),
✓ Basic Salary (BSAL with 5 integer and 2 decimal places should not be negative),
✓ DA (DA with integer and 2 decimal places),
✓ HRA (HRA with 4 integer and 2 decimal places),
✓ Total Salary (TSAL with 6 integer and 2 decimal places should not be negative) and
✓ date of birth (DOB, date).

12. To create a table with name BIKE, containing the Columns


✓ Bike identification number (bikeid, integer, primary key, incremented automatically),
✓ Name of the bike (bikename, character, variable width 30 characters and cannot be empty),
✓ cost of the bike (bikecost, width 8 width 2 decimals), and
✓ the date of purchase of the bike(pr dt, date)

13. Create a table called STUDENT containing columns to


✓ Store Admission no. (admno integer, primary key),
✓ First name (fname, character variable width of 20 cols),
✓ Surname(sname, character variable width of 20 cols), and
✓ Fathers name (mname, character variable width of 20 cols),
✓ Gender (character width 1 col),
✓ Date of birth (dob date),
✓ Date of admission (doa date),
✓ Class admitted to (class variable width of 10 cols),
✓ fees paid (fees with 4 integer and 2 decimals).

14. Create a table called LIBRARY containing columns to


✓ store Student Identification no. (stud_id, integer),
✓ Accession No. (access_no character variable width of 10 cols),
✓ Book Name (bookname, character variable width of 25 cols),
✓ Author’s name (authorname, character variable width of 25 cols),
✓ Author name (authorname, character variable width of 25 cols),
✓ Date of issue (doi date),
✓ Date of return (dor date) where student Id should be the foreign key to the table STUDENT linked
by admission no.

15. Create the table DEPT containing the


✓ columns id (id, smallint),
✓ name (name, varchar 20) where id will be the primary key.
16. Create a table EMP containing the columns
✓ Id (id, smallint),
✓ Last name (last_name, varchar(25)),

ACC – TYBCom 2 Computer MySQL


Advait Coaching Classes
✓ First name (first_name varchar(25))
✓ Department id (dept_id, smallint) where dept_id will be the foreign key to the table DEPT.

a) Modify the table EMP change the column last_name to varchar (50).

17. Create the table DEPARTMENTS containing the columns


✓ Department id (dept_id, integer not empty),
✓ Name of the department (dept_name, varchara(25) should not be empty),
✓ Manager id (manager_id integer),
✓ Location id (location_id integer),
✓ Dept_id should be the primary key.
a) Display the structure of this table
b) Add 8 rows of data to this table.

18. A table called BIKE contains the columns


Bike identification number (bikeid, integer primary key, incremented automatically),
Name of the bike (bikename, character, variable width 30 characters and cannot be empty),
cost of the bike (bikecost, width 8 with 2 decimals), and
the date of purchase of the bike (pr_dt, date).

Write MySQL statements for the following :


a) To show the structure of the table bike.
b) To change the name of the column bikename to bkname.
c) To change the size for the column bikecost from decimal(6,2) to decimals(8,2).
d) To add a column sale date(sl_dt) to the table. How will you indicate that this should be the first
column in the table.
e) To delete the column sale date(sl_dt)
f) To insert a row of data in the BIKE table giving the bikeid as 1, bikename as Honda, bike cost as
75,000 and purchase date as ‘2009-09-21;
g) To change for table BIKE the contents of the column bikecost to 80,000 for bikeid 1.
h) To delete the row from the table BIKE where the bikename is ‘Honda’
i) To delete all the rows from the table BIKE.
j) To rename the table BIKE to MBIKE.
k) To delete the table MBIKE.

19. A table SALARY contains the columns


Employee number (ENO, integrate, primary key),
Name (ENAME, character, width 20) and
Date of Birth (DOB, Date), and
Salary (ESAL, 5 integer and 2 decimals).

Write MySQL statements for the following :


a) Display the structure of the table SALARY.
b) Delete the row where employee number is 101.
c) Rename the column DOB to DBT.
d) Increase the salary of all employees by 500.
e) Change the size of the column ESAL to 6 integer and 3 decimals.
f) Add a column BON with 4 integer and 2 decimals to this table.
g) Change the name of employee number 113 to ‘Manoj Pai’.
ACC – TYBCom 3 Computer MySQL
Advait Coaching Classes
20. Three exists a table called ATTEND containing the columns
Student name (SNAME, character, variable width 20),
Class (CLASS, character, width 10),
Division (DIV, character width 1) and
No. of lectures attended (TOTAL_LEC, numeric integer).

Write MySQL statements for the following :


a) ADD the new column for roll number (ROLL, integer) as first column the table.
b) Display the structure of the table.
c) Rename the column SNAME to NAME.
d) Increase the number of lectures attended by all the students by 1.
e) Delete all the rows where the Class is ‘FYBCom’.
f) Delete the column DIV from the table.
g) Rename the table as ‘ATTD_REPORT’.

21. There exists a table TYCLASS with column for


Roll number(RNO, integer),
Name of the student (SNAME character variable width 20),
Subject offered (OTP character. Width 10) and
Marks obtained in SY (MKSY integer).

Write MySQL statements to do the following :


a) Display the structure of this table,
b) Update the subject offered as COMPUTER when marks obtained in SY is 60 or more.
c) Change the name of the column OPT to OPTS.
d) Increase the marks obtained in SY by 12 for all the students.
e) Change the subject offered by roll number 123 to ‘ COMPUTER’.
f) Add a new column division (DIV character width 1) to this table after the name column.
g) Delete the table TYCLASS.

22. There exists a table NCARS having the columns


Registration Number (REGNO, character),
Model of the car (MAKE, character),
Date of Purchase (DOP, date), and
Value of the car (VALUE, numeric).

Write MySQL statements for the following :-


a) Display the structure of the table.
b) Add this row of data ‘MH 01 A 2053’, ’HONDA’,’2013-10-23’, 1000000 to this table.
c) Change the MAKE of car having Registration No. MH 02 XJ 1230 to ‘Maruti’.
d) Add a new column Date of Sale (DOS, date) to this table.
e) Delete all the rows from this table where the date of purchase is before June 15, 2001.
f) Rename the table NCARS to CARS.
g) Delete the table NCARS.

ACC – TYBCom 4 Computer MySQL

You might also like