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

Database Questions (MySQL+Python)

database questions class 12

Uploaded by

Saanvi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
140 views

Database Questions (MySQL+Python)

database questions class 12

Uploaded by

Saanvi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

MULTIPLE CHOICE QUESTIONS (MCQ)

1. What is the use of DBMS?


a. Data Retrieval
b. Data Storage
c. Data Manipulation
d. All of the above

2. What is relational data model?


a. Where data is organized in tree like structure with parent child relationship
b. Where pointer is used to navigate through data
c. Where data is represented as objects.
d. Where data is organized into tables with rows and columns

3. What is tuple is relation?


a. row
b. column
c. field
d. attribute

4. What is attribute in relation?


a. row
b. column
c. tuple
d. key

5. What is degree in database?


a. Foreign key of the table
b. Primary key of the table
c. Number of columns in the table
d. Number of rows in the table

6. What is domain in database?


a. The alternate key of a table
b. The primary key of a table
c. The set of all possible values in column
d. The number of rows in table

7. What is cardinality in database?


a. Number of columns
b. Number of rows
c. Number of primary key
d. Number of attribute key

208 | P a g e
8. What is key in SQL?
a. Which is used to uniquely identify record
b. To maintain data integrity
c. To enable efficient data retrieval
d. All of the above

9. Which key is used to uniquely identify record in table and doesn’t allow NULL values?
a. Alternate key
b. Primary key
c. Super key
d. Foreign key

10. A column that could potentially be used as the primary key and it should also contain
unique values?
a. Alternate key
b. Primary key
c. Candidate key
d. Surrogate key

11. A candidate key that is not selected as primary key which can serve as a unique identifier.
a. Alternate key
b. Primary key
c. Candidate key
d. Surrogate key

12. What is the use of foreign key?


a. To uniquely identify record
b. To enforce data integrity
c. To define the data type of column
d. To establish a link between two tables

13. A column or set of column in table that refers to the primary key of another table.
a. Alternate key
b. Primary key
c. Candidate key
d. Foreign key

14. Which of the following SQL commands is used to view list of all database?
a. select databases
b. show databases
c. view databases
d. project databases

15. Which of the following SQL commands is used to use/select a particular database?

209 | P a g e
a. use
b. select
c. view
d. project

16. Which SQL command is used to define and maintain physical structure or schema of table
in database like creating, altering and deleting database object such as table and
constraints?
a. DDL
b. DML
c. DCL
d. TCL

17. Which SQL command used to change or modify any attribute/column like addition and
deletion of column in database?
a. create
b. alter
c. delete
d. update

18. A user request to retrieve data or information from database/table is called?


a. key
b. data
c. query
d. view

19. Which of the following is not a valid datatype in SQL?


a. Date
b. String
c. Decimal
d. Char

20. Which command is used to delete database permanently?


a. create database
b. delete database
c. drop database
d. use database

21. Which commands is used to show all table in current using database?
a. display tables;
b. show tables;
c. view tables;
d. select all tables;

210 | P a g e
22. Which command is used in where clause to search NULL values in a particular column?
a. IS NULL
b. IN NULL
c. NOT NULL
d. IS NOT NULL

23. Wild card operator (%,_) are used with?


a. count
b. max
c. like
d. min

24. Which SQL function is used to determine the no. of row or non-null values?
a. min
b. max
c. count
d. sum

25. Which SQL function is used to count the entire number of row in database table?
a. count
b. count(*)
c. max
d. min

26. In relational database, a key that established a link between two tables?
a. Primary key
b. Alternate key
c. Foreign key
d. Candidate key

27. A table containing data organized in the form of row and column in relational data
model?
a. Relation
b. View
c. Tuple
d. Database

28. Which SQL clause is used to filter the result of SELECT statement in Relational Database?
a. from
b. where
c. join
d. having

29. INSERT command is used in database to perform

211 | P a g e
a. To retrieve a set of statement
b. To add new row of data to a table
c. To change already existing data in table
d. To delete any existing row in table

30. How many candidate key can a relation/table have in relational database
a. One
b. Two
c. Multiple
d. None

31. What is the main difference between candidate key and primary key?
a. A candidate key can contain NULL value but primary key can’t contain NULL value
b. A primary key can contain unique value but it is not necessary for the candidate key to
have unique value
c. Candidate key is chosen by database system while primary key is chosen by the
designer
d. No difference

32. Which DDL command is used to modify the structure of an existing table?
a. create table
b. modify table
c. alter table
d. update table

33. Which DDL command is used to remove a table along with its all content from a database?
a. DELETE TABLE
b. DROP TABLE
c. REMOVE TABLE
d. ERASE TABLE

34. Which constraint enforce data integrity by ensuring that a column always contain a
values?
a. NULL
b. NOT NULL
c. CHECK
d. DEFAULT

35. What is primary difference between candidate key and primary key in database?
a. Primary key is chosen by the end user/designer while candidate key is generated by
database system
b. A candidate key uniquely identifies each row in a table, while primary key is not unique
c. A primary key can have NULL values while a candidate key can’t

212 | P a g e
d. A candidate key can become a primary key, but a primary key can’t become a candidate
key

36. Which key is used to enforce referential integrity between tables in database system
a. Primary key
b. Candidate key
c. Foreign key
d. Alternate key

37. What is the main difference between CHAR and VARCHAR datatype in SQL?
a. CHAR is case-sensitive while VARCHAR is non case sensitive
b. CHAR store variable length strings while VARCHAR stores fixed length string
c. CHAR store fixed length strings while VARCHAR stores variable length string
d. CHAR is used storing numeric data while VARCHAR is used for text data

38. What is the primary purpose of unique key constraints in a relational databases?
a. To ensure that values in a column are NULL
b. To ensure that values in a column are unique
c. To define relationship between tables
d. To specify a condition that must be met for data to be valid in a column

39. Which constraint key is used when you want to enforce uniqueness but allows NULL
values in database
a. PRIMARY KEY
b. UNIQUE KEY
c. NOT NULL
d. CHECK

40. Which of the following is not a valid DML command in SQL?


a. INSERT
b. UPDATE
c. ALTER
d. DELETE

41. Which keyword is used for table aliasing that involves giving a table short and alternative
name to simplify query syntax?
a. from
b. as
c. where
d. on

42. Which SQL clause is used in database table to eliminate duplicate rows from the query
result?
a. group by

213 | P a g e
b. distinct
c. describe
d. duplicate

43. Which of the following clauses in SQL is most appropriate to use to select matching tuples
in a specific range of values?
a. IN
b. LIKE
c. BETWEEN
d. IS

44. Which of the following SQL datatype allows NULL values by default?
a. INT
b. CHAR
c. VARCHAR
d. FLOAT

45. Which of the following is NOT a required argument to the connect() function?
a. Hostname
b. Username
c. Password
d. Database name

46. Which method is used to execute a SQL query on a MySQL database?


a. execute()
b. query()
c. run()
d. None of the above

47. Which method is used to fetch n number of results from a SQL query?
a. fetchall()
b. fetchone()
c. fetchmany()
d. All of the above

48. _______ it is a pointer or iterator which points towards the resultset of the SQL query.
a. cursor
b. rset
c. temp
d. None of these

49. Which of the following is not a valid method to fetch records from database in python.
a. fetchmany()
b. fetchone()

214 | P a g e
c. fetchmulti()
d. fetchall()

50. To get all the records from result set, you may use ___________.
a. cursor.fetchmany()
b. cursor.fetchall()
c. cursor.fetchone()
d. cursor.execute()

Short answer type Questions:


1. What is SQL?
2. Differentiate between DML and DDL. Explain with the help of examples.
3. What are the different type of SQL data type?
4. What is the difference between where statement and having statement in SQL?
5. What is primary key?
6. Differentiate between a database table and a database record.
7. What is foreign Key? And how does it relate in a database.
8. What is Domain in database?
9. Explain the role of clause in query of SQL commands.
10. What is Aliasing?
11. Explain char, varchar and int datatype in SQL with example.
12. Differentiate between candidate key and alternate key?
13. Differentiate between degree and cardinality of a table with the help of example.
14. What are database keys? Explain all the database keys.
15. What are constraints in SQL?
16. Explain the wildcards used with like operator.
17. What are joins in SQL?
18. Differentiate between Natural Join and Equi Join.
19. Explain any two aggregate function in SQL.
20. What is a cursor?
21. What is the role of commit() function in SQL?
22. What is Cartesian product? What will be the number of rows in output table if we
apply Cartesian product on two tables T1 and T2 with 9 and 10 rows respectively?
23. Explain alter table command with the help of example.
24. Differentiate between fetchall() function and fetchmany() function in SQL.
25. In SQL, Define aggregate function and write the name of the aggregate function which
will display the cardinality of a table.

215 | P a g e
Assertion-and-Reason Type
In the following questions, Assertion (A) and Reason (R).
Choose the correct choice as:
(a) Both Assertion (A) and Reason (R) are the true and Reason (R) is a correct explanation of
Assertion (A).
(b) Both Assertion (A) and Reason (R) are the true but Reason (R) is not a correct
explanation of Assertion (A).
(c) Assertion (A) is true and Reason (R) is false.
(d) Assertion (A) is false and Reason (R) is true.

1. Assertion (A): COUNT function can be work with distinct keyword.


Reason (R): DISTINCT keyword can only be used with COUNT function.

2. Assertion (A): HAVING clause can only be used with GROUP BY statement.
Reason (R): WHERE clause can be used in place of HAVING clause in GROUP BY
statement.

3. Assertion (A): LIKE operator is used for pattern matching in WHERE clause.
Reason (R): % and _ wildcard is used in LIKE operator for making a pattern.

4. Assertion (A): The primary key is applied on a column of a table.


Reason (R): NOT NULL constraint restricts NULL values in a column.

5. Assertion (A): SUM and COUNT are aggregate functions.


Reason (R): Aggregate functions works on multiple tuples.

6. Assertion (A): Primary key constraints allows NULL values.


Reason (R): The primary key constraints ensures that a column can contain unique
Values for each row.

7. Assertion (A): Unique key constraint allows NULL values.


Reason (R): The unique key constraints ensures that a column can contain unique
Values.

8. Assertion (A): The HAVING clause is used to filter aggregated data in SQL queries.
Reason (R): The HAVING clause is used to group rows with similar values in one or
more column into result sets.

9. Assertion (A): Inner Join retrieves rows that have matching values in both tables being
joined.
Reason (R): Inner join excludes row with no matching values

10. Assertion (A): Between operator is used to filter data within a specified range.
Reason (R): Where clause works exactly same as between operator

216 | P a g e
Long Answer Type Questions:
1. Write MySQL command to create the table ‘Employee’ with the following structure and
constraint. Table: Employee

Column_Name DataType(size) Constraint


Emp_ID Int(20) Primary key
Emp_Name char(100) Not Null
Salary int(20) Not Null
Department char(30)
Age int(15) Not Null
Address Varchar(200) Unique

2. Write MySQL command to create the table ‘Student’ and ‘Activities’ with the following
structure and constraint.
Table: Student
Column_Name DataType(size) Constraint
Student_ID varchar(20) Primary key
Student_Name char(80) Not Null
Gender char(20) Not Null
Class varchar(30)
Age int(20) Not Null
Address Varchar(150) Unique
Phone Int(15) Not Null, unique

Table: Activities
Column_Name DataType(size) Constraint
Student_ID varchar(20) Foreign key references to
Student_ID of Employee
table
Activity_Name char(80) Not Null
Position char(30) Not Null

3. Anmol maintain that database of medicines for his pharmacy using SQL to store the data.
The structure of the table PHARMA for the purpose is as follows:

 Name of the table-PHARMA


 The attributes of PHARMA are as follows:
MID - numeric
MNAME - character of size 20
PRICE - numeric
UNITS - numeric
EXPIRY – date

217 | P a g e
Table: PHARMA

MID MNAME PRICE UNITS EXPIRY


M1 PARACETAMOL 12 120 2022-12-25
M2 CETRIZINE 6 125 2022-10-12
M3 METFORMIN 14 150 2022-05-23
M4 VITAMIN B-6 12 120 2022-07-01
M5 VITAMIN D3 25 150 2022-06-30
M6 TELMISARTAN 22 115 2022-02-25

(a) Write the degree and cardinality of the table PHARMA.


(b) Identify the attribute best suitable to be declared as a primary key.
(c) Anmol has received a new medicine to be added into his stock, but for which he does not
know the number of UNITS. So he decides to add the medicine without its value for UNITS.
The rest of the values are as follows:

MID MNAME PRICE EXPIRY


M7 SUCRALFATE 17 2022-03-20
Write the SQL command which Anmol should execute to perform the required task.
(d) Anmol wants to change the name of the attribute UNITS to QUANTITY in the table
PHARMA. Which of the following commands will he use for the purpose?
I. UPDATE
II. DROP TABLE
III. CREATE TABLE
IV. ALTER TABLE

(e) Now Anmol wants to increase the PRICE of all medicines following commands will he use
for the purpose?
I. UPDATE SET
II. INCREASE BY
III. ALTER TABLE
IV. INSERT INTO

4. For the following SQL Table named PASSENGERS in a database TRAVEL:

TNO NAME START END


T1 RAVI KUMAR DELHI MUMBAI
T2 NISHANT JAIN DELHI KOLKATA
T3 DEEPAK PRAKASH MUMBAI PUNE

A cursor named Cur is created in Python for a connection of a host which contains the
database TRAVEL. Write the output for the execution of the following Python statements

218 | P a g e
for the above SQL Table PASSENGERS:
Cur.execute(‘USE TRAVEL’)
Cur.execute(‘SELECT * FROM PASSENGERS’)
Recs=Cur.fetchall()
For R in Recs:
Print(R[1])

5. Write SQL statements for the following queries (i) to (v) based on the relations
CUSTOMER and TRANSACTION given below:
Table: CUSTOMER

ACNO NAME GENDER BALANCE


C1 RISHABH M 15000
C2 AAKASH M 12500
C3 INDIRA F 9750
C4 TUSHAR M 14600
C5 ANKITA F 22000

Table: TRANSACTION

ACNO TDATE AMOUNT TYPE


C1 2020-07-21 1000 DEBIT
C5 2019-12-31 1500 CREDIT
C3 2020-01-01 2000 CREDIT

1. To display all information about the CUSTOMERS whose NAME starts with 'A'.
2. To display the NAME and BALANCE of Female CUSTOMERS (with GENDER as 'F') whose
TRANSACTION Date (TDATE) is in the year 2019.
3. To display the total number of CUSTOMERS for each GENDER.
4. To display the CUSTOMER NAME and BALANCE in ascending order of GENDER.
5. To display CUSTOMER NAME and their respective INTEREST for all CUSTOMERS where
INTEREST is calculated as 8% of BALANCE.

6. The IT Company XYZ has asked their IT manager Ms. Preeti to maintain the data of all the
employees in two tables EMPLOYEE and DEPT. Ms. Preeti has created two tables
EMPLOYEE and DEPT. She entered 6 rows in EMPLOYEE table and 5 rows in DEPT table.

Table: DEPT
D_CODE D_NAME CITY
D001 INFRASTRUCTURE DELHI
D002 MARKETING DELHI
D003 MEDIA MUMBAI
D005 FINANCE KOLKATA
D004 HUMAN RESOURCE MUMBAI

219 | P a g e
Table: EMPLOYEE
E_NO NAME DOJ DOB GENDER D_CODE Salary
1001 Vinay 2013-09-02 1991-09-01 MALE D001 250000
1002 Ruby 2012-12-11 1990-12-15 FEMALE D003 270000
1003 Anuj 2013-02-03 1987-09-04 MALE D005 240000
1007 Sunny 2014-01-17 1988-10-19 MALE D004 250000
1004 Rohit 2012-12-09 1986-11-14 MALE D001 270000
1005 Preeti 2013-11-18 1989-03-31 FEMALE D002 NULL

Note: DOJ refers to date of joining and DOB refers to date of Birth of employees.
Based on the above data, answer the following questions:
1. Identify the column which can be consider as primary key in EMPLOYEE table.
2. Identify the column which can be consider as primary key in DEPT table
3. What is the degree and cardinality of EMPLOYEE table?
4. What is the degree and cardinality of DEPT table?
5. Write SQL queries for the following:
1) Insert two new row in Employee table with following data:
1006 Rahul 2019-11-06 1992-01-04 MALE D003 156000
1008 Sonam 2022-01-06 1991-04-06 FEMALE D005 167000
2) To display E_NO, NAME, GENDER from the table EMPLOYEE in descending order of
E_NO.
3) To display the NAME of all the ‘FEMALE’ employees from the table EMPLOYEE.
4) To display the E_NO and NAME of those employees from the table EMPLOYEE who
are born between ‘1987-01-01’ and ‘1991-12-01’.
5) To display NAME and CITY of those employees whose DEPARTMENT is either ‘MEDIA’
or ‘FINANCE’.
6) To display the NAME of those employees whose name starts with letter ‘R’.
7) To display NAME of those employees whose name contains letter ‘n’.
8) To display NAME of those employees whose name has exact 5 letters.
9) To display D_NAME and CITY from table DEPT where D_NAME ends with letter ‘G’
and CITY is ‘DELHI’.
10) To display the maximum SALARY of EMPLOYEE table.
11) To delete data of all those employees whose age is less than 25.
12) To update SALARY to 230000 of those employee whose E_NO is 1004.
13) To change the sequence of DOB column in employee table and move it before DOJ
column.
14) To add a new column MOBILE int(20) before column SALARY in employee table.
15) To set SALARY to 300000 of all those employees whose age is NULL.
16) To Increase the salary of all employees by 30000 in EMPLOYEE table.
17) To display the average SALARY of EMPLOYEE table.
18) To display name of employees who have SALARY more than 200000 in ascending
order of NAME.
19) To display department wise average salary of employees.
20) To display total number of departments in XYZ company.
21) To delete data of all the employees whose D_CODE is not ‘D001’.
22) To display E_NO, NAME and SALARY of all those employees who don’t live in ‘DELHI’.

220 | P a g e
23) To change column name CITY to D_CITY in DEPT table.
24) To delete EMPLOYEE table.
25) To delete D_NAME column from DEPT table.

7. A garment store is considering to maintain their inventory using SQL to store the data. as
a database administrator, Mr.Rohit has decided that:
 Name of the database – STORE
 Name of the table – GARMENT
 The attributes of GARMENT table are as follows:
 GCODE – numeric
 DESCRIPTION – character of size 50
 PRICE – numeric
 FCODE – varchar of size 10
Table: GARMENT
GCODE DESCRIPTION PRICE FCODE
10023 JEANS 1150 F01
10001 SHIRT 750 F02
10044 SHORTS 600 F05
10005 TIE 400 F04
10002 JACKET 5000 F01
10022 SOCKS 150 NULL

1. Categorize the following commands as DDL or DML:


ALTER, INSERT, UPDATE, CREATE, DROP, DELETE
2. Identify the attribute of Garment table to be declared as primary key.
3. Write the degree and cardinality of the table GARMENT
4. Write SQL query to create database STORE.
5. Write SQL query to display list of available databases.
6. Write SQL query to use database STORE.
7. Write SQL query to display list of available tables in database STORE.
8. Write SQL query to create table GARMENT with aforementioned attributes.
9. Obtain the output of following SQL queries based on the data given in table
GARMENT:
(i) SELECT MAX(PRICE), MIN(PRICE) FROM GARMENT;
(ii) SELECT GCODE, DESCRIPTION FROM GARMENT;
(iii) SELECT FCODE,GCODE FROM GARMENT WHERE PRICE BETWEEN 500 AND
800;
(iv) SELECT * FROM GARMENT WHERE DESCRIPTION NOT IN (‘JEANS’,’TIE’);
(v) SELECT GCODE FROM GARMENT WHERE DESCRIPTION LIKE ‘%S%’;
(vi) SELECT GCODE,PRICE FROM GARMENT WHERE DESCRIPTION LIKE ‘_ _ _’;
(vii) SELECT DISTINCT FCODE FROM GARMENT;

221 | P a g e
(viii) SELECT SUM(PRICE) FROM GARMENT;
(ix) SELECT * FROM GARMENT WHERE DESCRIPTION LIKE ‘%T%’ AND
FCODE!=’F02’;
(x) SELECT * FROM GARMENT ORDER BY PRICE DESC;
(xi) SELECT PRICE*10 FROM GARMENT;
(xii) SELECT COUNT(DISTINCT FCODE) FROM GARMENT;
(xiii) SELECT * FROM GARMENT WHERE FCODE NOT IN (‘F01’,’F02’) AND
PRICE<500;
(xiv) SELECT GCODE, PRICE FROM GARMENT WHERE FCODE IS NULL;
(xv) SELECT * FROM GARMENT WHERE PRICE >500 AND PRICE <1000;

8. Write the output of the following SQL queries based on table TRANSACTION given below:
Table: TRANSACTION
T_NO M_NO AMOUNT CARD_TYPE DATE STATUS
1 11 5000 CREDIT 2019-10-11 SUCCESS
2 11 170 CREDIT 2019-10-14 FAILURE
3 13 800 DEBIT 201-10-24 FAILURE
4 12 90 CREDIT 2019-11-10 SUCCESS
5 13 1400 DEBIT 2019-11-11 SUCCESS
6 11 500 DEBIT 2019-11-18 SUCCESS
7 13 1600 DEBIT 2019-11-27 FAILURE

Table: COMPANY
T_NO QTY_ISSUED COMPANY
1 15 SBI
3 50 ICICI
4 34 HDFC

(i) SELECT M_NO, MIN(AMOUNT) FROM TRANSACTION GROUP BY M_NO HAVING


COUNT(*)>2;
(ii) SELECT T_NO,AMOUNT FROM TRANSACTION WHERE CARD_TYPE=’CREDIT’;
(iii) SELECT * FROM TRANSACTION WHERE M_NO>12 AND STATUS=’FAILURE’;
(iv) SELECT CARD_TYPE, SUM(AMOUNT) FROM TRANSACTION GROUP BY
CARD_TYPE;
(v) SELECT T_NO, AMOUNT*10 AS PAYMENT FROM TRANSACTION WHERE STATUS IN
(‘SUCCESS’);
(vi) SELECT COUNT(*) FROM TRANSACTION WHERE STATUS=’SUCCESS’;
(vii) SELECT T_NO, AMOUNT, CARD_TYPE FROM TRANSACTION WHERE T_NO>5;
(viii) SELECT DISTINCT M_NO FROM TRANSACTION;
(ix) SELECT T_NO, M_NO,CARD_TYPE, COMPANY FROM TRANSACTION T, COMPANY C
WHERE T.T_NO=C.T_NO AND AMOUNT>1000;
(x) SELECT T.T_NO AS TRANS_NO FROM TRANSACTION T, COMPANY C WHERE
T.T_NO=C.T_NO;

222 | P a g e
9. The code given below reads the records from the table employee and displays only those
records of employee table who don’t lives in city 'Delhi':

E_ID – varchar(50)
E_Name – char(50)
Salary – int(15)
City – char(20)
Note the following to establish connectivity between Python and MySQL:
 Username is root
 Password is 12345
 The table exists in a MySQL database named company.
 The table has four attributes (E_ID, E_Name, Salary, City).

Write the following statements to complete the code:


Statement 1- to import the desired library.
Statement 2- to create a cursor
Statement 3- to write a sql query that fetches records of all those employees who don’t
lives in delhi.
Statement 4- to execute the query
Statement 5- to print all the records fetched in statement 4

Import _________ as mysql #Statement 1


def print():
a=mysql.connect (host="localhost", user "root",passwd=12345, database=
"company")
b=____________ #Statement 2
query = ________________ #Statement 3
c = __________________ #Statement 4
for z in c:
_________ #Statement 5

10. The code given below deletes the records from the table employee which contains
following record structure:
E_ID – varchar(50)
E_Name – char(50)
Salary – int(15)
City – char(20)
Note the following to establish connectivity between Python and MySQL:
 Username is root
 Password is 12345
 The table exists in a MySQL database named company.
 The table has four attributes (E_ID, E_Name, Salary, City).

Write the following statements to complete the code:


Statement 1- to import the desired library.
Statement 2- to connect to the database
223 | P a g e
Statement 3- to create a cursor
Statement 4- to write a query that deletes the record with E_ID=’A101’ and E_Name starts
with letter ‘D’.
Statement 5- to remove the record permanently from the database.

Import _________ as mysql #Statement 1


def del():
a=_________ (host="localhost", user "root",passwd=12345, database= "company")
#Statement 2
b=____________ #Statement 3
query = ________________ #Statement 4
__________________ #Statement 5
print(‘Data deleted’)

11. Write a python program to delete all the tuples from Student table whose age>14.
Note the following to establish connectivity between Python and MySQL:
Username is root
Password is 12345
The table exists in a MySQL database named school.
The table has five attributes (Stu_ID, Stu_Name, age, Address)

12. Write a python program to insert 5 records in Employee table. Take these 5 records as an
input from the user (One record at a time).
Note the following to establish connectivity between Python and MySQL:
Username is root
Password is 12345
The table exists in a MySQL database named company.
The table has five attributes (Emp_ID, Emp_Name, DOJ, Gender, Salary)

13. Write a python program to update name of employee in Employee table whose employee
id is ‘E1001’ (Take updates name as an input from the user).
Note the following to establish connectivity between Python and MySQL:
Username is root
Password is 12345
The table exists in a MySQL database named company.
The table has five attributes (Emp_ID, Emp_Name, DOJ, Gender, Salary)

224 | P a g e

You might also like