sql45r43rt43
sql45r43rt43
Question 2.
When using the LIKE clause, which wildcard symbol represents any sequence of none, one or more characters? (All
India 2014c)
Answer:
The % wildcard symbol is used in LIKE clause to represent any sequence of none, one or more characters.
Question 3.
Write the UPDATE statement in MySQL to increase commission by 100.00 in the “Commission” column in the ‘EMP’
table. (All India 2014C)
Answer:
UPDATE Emp
SET Commission = Commission +100;
Question 4.
Rewrite the following SQL statement after correcting the error(s). Underline the corrections made. (All India 2014C)
Question 6.
Table ‘CLUB’ has 4 rows and 3 columns. Table ‘MEMBER’ has 2 rows and 5 columns. What will be the cardinality of
the Cartesian product of them? (Delhi 2014)
Answer:
The cardinality of the cartesian product of Table ‘CLUB’ and Table ‘MEMBER’ = 8.
Question 7.
Distinguish between ALTER TABLE and UPDATE commands of MySQL. (All India 2014)
Answer:
ALTER TABLE command is a DDL (Data Definition Language) statement which is used to modify the table structure.
On the other hand UPDATE command is a DML (Data Manipulation Language) statement which is used to modify the
data stored in a table.
Question 8.
Mention two categories in which MySQL commands are broadly classified. (All India 2014)
Answer:
Two categories of Mysql commands are:
Question 9.
Give two characteristics of Primary Key. (All India 2014)
Answer:
Two characteristics of Primary Key are:
All the values in the Primary Key field are unique.
Does not allow NULL values.
Question 10.
Write two examples of DBMS software. (Delhi 2014)
Answer:
Two examples of DBMS Software are:
MySQL
Oracle
Question 11.
Write SQL command to create a SAVEPOINT called All (Delhi 2013)
Answer:
Question 13.
Write the command to display the list of existing databases. (Delhi 2012)
Answer:
The command to display list of existing databases are as follows:
Show databases;
Question 14.
Mr. William wants to remove all the rows from INVENTORY table to release the storage space, but he does not want
to remove the structure of the table. What MySQL statement should be used? (Delhi 2012)
Answer:
The command to delete all rows from the Inventory table without deleting the structure of the table will be as follows:
USE database_name;
Question 16.
Give one difference between COMMIT and ROLLBACK commands used in MySQL. (HOTS; Delhi 2012; All India
2012)
Answer:
The COMMIT command is used to save the changes made during the execution of a transaction permanentely on the
disk. After executing the COMMIT command, we cannot undo or cancel the changes made thereupon. Whereas the
ROLLBACK command is used to undo the changes made during the execution of a transaction.
Question 17.
Write MySQL command, which will be used to open an already existing database “LIBRARY”. (All India 2012, Delhi
2011)
Answer:
The SQL command to open an already existing database LIBRARY will be as follows:
USE LIBRARY;
Question 18.
Differentiate between alternate key and candidate key (All India2011)
Answer:
The attribute or a combination of attributes that have unique values for each record known as candidate key whereas
a candidate key that is not the primary key is known as an alternate key.
Question 19.
In MySQL Reena and Zebi are getting the following output of SELECT statement on a table EMPLOYEE (HOTS;
Delhi2011c)
Which keyword has Zebi used with a select statement to get the above output?
Answer:
Zebi has used DISTINCT clause with the SELECT command.
Question 20.
Write MySQL command, which will open an already existing database “CONTACTS (Delhi 2011c)
Answer:
The SQL command to open an already existing database CONTACTS will be as follows:
Use CONTACTS;
Question 21.
Write SQL command used to display the structure of a table. (Delhi 2011c)
Answer:
The command to display the structure of a table is as follows:
DESCRIBE table_name;
or DESC table_name;
Question 22.
Mr. lames created a table CLIENT with 2 rows and 4 columns. He added 2 more rows to it and deleted one column.
What is the Cardinality and Degree of the Table CLIENT?
Answer:
Cardinality = 4
Degree = 3
Cardinality are the number of rows and degree is number of the columns in a table.
2 Marks Questions
Question 23.
(i) If you have not executed the COMMIT command, executing which command will reverse all updates made during
the current work session in MySQL?
(ii) What effect does SET AUTOCOMMIT have in transactions? (All India 2014C)
Answer:
(i) ROLLBACK command can only be used to undo transactions.
(ii) Autocommit simply means that each statement in its own transaction which commits immediately. When
autocommit is set ON, the SET IMLICITTRANSACTION sets the connection to implicit transaction mode. When set
OFF, it returns the connection to autocommit transaction mode.
Question 24.
A table FUN FOOD has 13 rows and 17 columns. What is the cardinality and degree of the table? (All India 2014)
Answer:
Cardinality of FUN FOOD = 13
Degree of FUN FOOD = 17
Question 25.
What happens when “ROLLBACK” command is issued in a transaction process? (All India 2014)
Answer:
When a ROLLBACK command is issued in a transaction process then all the progress made by a transaction process
upto that point will be lost i.e. all the changes made by that transaction process are undone.
Question 26.
Gopi Krishna is using a table EMPLOYEE. It has the following columns:
Code, Name, Salary, Dept code He wants to display maximum salary Departmentwise.
He wrote the following command:
Question 28.
Name two categories into which SQL commands may be categorized. Also, give one example of SQL commands in
each category. (Delhi 2012)
Answer:
The two categories of SQL commands are as follow:
(i) DDL DDL stands for Data Definition Language. The DDL commands are used to Create, Modify or Destroy the
structure of the database objects,
E.g., CREATE TABLE, ALTER TABLE are of this category.
(ii) DML DML stands for Data Manipulation Language. The DML commands are used to insert, display, delete or
change data in tables,
E.g.,
SELECT, INSERT, UPDATE, DELETE, etc., commands are of this category.
Question 29.
The Mname Column of a table Members is given below
Question 30.
What is the purpose of ALTER TABLE command in MySQL? How it is different from UPDATE commands? (All India
2011)
Answer:
The ALTER TABLE command is used to change the structure of an existing table. It can be used to add a new
column, to change the size or type of a column or to remove a column from a table. But update commands cannot
effect the table structure.
Question 31.
The Doc_name column of a table HOSPITAL is given below (All India 2011)
Question 32.
A table “TRAINS” in a database has degree 3 and cardinality 8. What is the number of rows and columns in it? (Delhi
2011; All India 2011)
Answer:
There will be 8 rows and 3 columns.
Question 33.
Sarthak, a student of class XI created a table “CLASS”. Grade is one of the column of this table. To find the details of
students whose Grades have not been entered, he wrote the following MySQL query, which did not give the desired
result
Question 36.
Amit, a salesman in an Outlet, created a table TRANSACTIONS an Amount is one of the column of this Table. To
find the details of customer whose transaction amount is more than 800, he wrote the following MySQL query, which
did not give the desired result:
Question 40.
In a database BANK, there are two tables with a sample data given below
TABLE EMPLOYEE
TABLE DEPARTMENT
Note:
– EName refers to Employee Name
– DName refers to Department Name
– Dept refers to Department Code
– HOD refers to Employee number (ENO) of the Head of the Department
Write SQL queries for the following:
(i) To display ENo, EName, Salary and corresponding DName of all the employees whose age is between 25 and 35
(both values inclusive).
(ii) To display DName and corresponding EName from the tables DEPARTMENT and EMPLOYEE, (Hint’ HOD of the
DEPARTMENT table should be matched with ENo of the EMPLOYEE table for getting the desired result).
(iii) To display EName, Salary, Zone and Income Tax
(Note Income Tax to be calculated as 30% of salary) of all the employees with appropriate column headings. (HOTS;
Delhi 2013)
Answer:
TABLE BRAND
TABLE CUSTOMER
Write MySQL queries for the following:
(i) To display the details of Item, whose Price is in the range of 40 and 95 (both values included).
(ii) To display CustomerName, City from table CUSTOMER and ItemName and Price from table ITEM, with their
corresponding matching ID.
(iii) To increase the prices of all the Items by 50%. (Delhi 2011)
Answer:
Answer:
The SQL command to create a table as per given structure is as follows:
Answer:
The SQL command to create a table as per given structure is as follows:
Answer:
The SQL command to create a table as per given structure is as follows:
Answer:
The SQL command to create a table as per given structure is as follows:
CREATE TABLE TEACHER
(Teacher_ID INTEGER,
Teacher_Name VARCHAR(20),
Qualification VARCHAR(20),
Date_of_Appointment DATE);
Question 48.
Write an SQL query to create a table ITEM with the following structure
Answer:
The SQL command to create a table as per given structure is as follows:
Answer:
The SQL command to create a table as per given structure is as follows:
Answer:
The SQL command to create a table as per given structure is as follows:
Answer:
The SQL command to create a table as per given structure is as follows:
Answer:
The SQL command to create a table as per given structure is as follows: