This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Fill in the blanks.1. A ……… is a horizontal entity in the table.2. DDL means …… |
|
Answer» 1. record 2. Data Defnition Language |
|
| 2. |
Which command lets to change the structure of the table? (a) SELECT(b) ORDER BY(c) MODIFY(d) ALTER |
|
Answer» Answer is (d) ALTER |
|
| 3. |
Queries can be generated using ……(a) SELECT (b) ORDER BY (c) MODIFY (d) ALTER |
|
Answer» Queries can be generated using SELECT |
|
| 4. |
Which command changes the structure of the database? a) update(b) alter(c) change(d) modify |
|
Answer» alter command changes the structure of the database |
|
| 5. |
Write note on having clause? |
||||||
|
Answer» HAVING clause: The HAVING clause can be used along with GROUP BY clause in the SELECT statement to place condition on groups and can include aggregate functions on them. For example to count the number of Male and Female students belonging to Chennai. SELECT gender, COUNT(*) FROM Student GROUP BY Gender HAVING Place = ‘Chennai’;
The above output shows the number of Male and Female students in Chennai from the table student. |
|||||||
| 6. |
Find the wrong statement from the following delete command (a) permanently removes one or more records(b) removes entire row(c) removes individual fields(d) deletes the record |
|
Answer» (c) removes individual fields |
|
| 7. |
Pick the odd outInsert, update, alter, delete |
|
Answer» Answer is alter |
|
| 8. |
The command to delete a table is ………(a) DROP (b) DELETE (c) DELETE ALL (d) ALTER TABLE |
|
Answer» The command to delete a table is DROP |
|
| 9. |
The ……. keyword in select command includes an upper value and a lower value. |
|
Answer» The betweeen keyword in select command includes an upper value and a lower value. |
|
| 10. |
Identify which is not a SQL DDL command?(a) create (b) delete (c) drop (d) truncate |
|
Answer» delete is not a SQL DDL command |
|
| 11. |
Match the following:1. DDL – (i) Modify Tuples2. Informix – (ii) Create Indexes3. DML – (iii) MySQL4. DCL – (iv) Grant(a) 1-ii, 2-iii, 3-i, 4-iv(b) 1-i, 2-ii, 3-iii, 4-iv(c) 1-iv, 2-iii, 3-ii, 4-i(d) 1-iv, 2-i, 3-ii, 4-iiii |
|
Answer» (a) 1-ii, 2-iii, 3-i, 4-iv |
|
| 12. |
Which of the following is a DDL command? (SELECT, UPDATE, CREATE TABLE, INSERT INTO) |
|
Answer» CREATETABLE is a DDL command. |
|
| 13. |
How to create and work with database? |
|
Answer» Creating Database (i) To create a database, type the following command in the prompt: CREATE DATABASE database_name; For example to create a database to store the tables: CREATE DATABASE stud; (ii) To work with the database, type the following command USE DATABASE; For example to use the stud database created, give the command USE stud; |
|
| 14. |
Write note on delete command ? |
|||||
|
Answer» DELETE COMMAND The DELETE command permanently removes one or more records from the table. It removes the entire row, not individual fields of the row, so no field argument is needed. The DELETE command is used as follows : DELETE FROM table-name WHERE condition; For example to delete the record whose admission number is 104 the command is given as follows: DELETE FROM Student WHERE Admno=104;
The following record is deleted from the Student table. To delete all the rows of the table, the. command is used as : DELETE * FROM Student; The table will be empty now and could be destroyed using the DROP command. |
||||||
| 15. |
Differentiate between and not between? |
||||||||||||||||||||||||||||||||||||||||||
|
Answer» BETWEEN and NOT BETWEEN Keywords The BETWEEN keyword defies a range of values the record must fall into to make the condition true. The range may include an upper value and a lower value between which the criteria must fall into. SELECT Admno, Name, Age, Gender FROM Student WHERE Age BETWEEN 18 AND 19;
The NOT BETWEEN is reverse of the BETWEEN operator where the records not satisfying the condition are displayed. SELECT Admno, Name, Age FROM Student WHERE Age NOT BETWEEN 18 AND 19;
|
|||||||||||||||||||||||||||||||||||||||||||
| 16. |
How many components of SQL are there?(a) 3(b) 4(c) 5(d) 6 |
|
Answer» There are 5 components of SQL |
|
| 17. |
Write about the parts of SQL Commands? |
|
Answer» Keywords They have a special meaning in SQL. They are understood as instructions. Commands They are instructions given by the user to the database also known as statements. Clauses They begin with a keyword and consist of keyword and argument. Arguments They are the values given to make the clause complete. |
|
| 18. |
What are the functions performed by DDL? |
|
Answer» A DDL performs the following functions : 1. It should identify the type of data division such as data item, segment, record and database file. 2. It gives a unique name to each data item type, record type, file type and data base. 3. It should specify the proper data type. 4. It should define the size of the data item. 5. It may define the range of values that a data item may use. 6. It may specify privacy locks for preventing unauthorized data entry. |
|
| 19. |
Write note on delete, truncate, drop commands? |
|
Answer» DELETE, TRUNCATE AND DROP statement: The DELETE command deletes only the rows from the table based on the condition given in the where clause or deletes all the rows from the table if no condition is specified. But it does not free the space containing the table. The TRUNCATE command is used to delete all the rows, the structure remains in the table and free the space containing the table. The DROP command is used to remove an object from the database. If you drop a table, all the rows in the table is deleted and the table structure is removed from the database. Once a table is dropped we cannot get it back. |
|
| 20. |
Name the SQL Commands under TCL. Explain? |
||||||
|
Answer» SQL command which come under Transfer Control Language are:
|
|||||||
| 21. |
What is TCL? |
|
Answer» Transaction Control Language- component of SQL includes commands for specifying transactions. |
|
| 22. |
Write about DML Commands? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Answer» DML COMMANDS Once the schema or structure of the table is created, values can be added to the table. The DML commands consist of inserting, deleting and updating rows into the table. (i) INSERT command The INSERT command helps to add new data to the database or add new records to the table. Syntax: INSERT INTO [column-list] VALUES (values); (a) INSER T INTO Student (Admno, Name, Gender, Age, Place) VALUES (100, ‘Ashish ’ , ‘M\ 17, ‘Chennai); (b) INSERT INTO Student (Admno, Name, Gender, Age, Place) VALUES (10, ‘Adarsh’ , ‘M’ , 18, ‘Delhi); (c) INSERT INTO Student VALUES (102, ‘Akshith \ ‘M’ , ‘17, ’ ‘Bangalore); The above command inserts the record into the student table. To add data to only some columns in a record by specifying the column name and their data, it can be done by: (d) INSERT INTO Student(Admno, Name, Place) VALUES (103, ‘Ayush’ , ‘Delhi’); (e) INSERT INTO Student (Admno, Name, Place) VALUES (104, ‘Abinandh ‘Chennai); The student table will have the following data:
(ii) DELETE COMMAND The DELETE command permanently removes one or more records from the table. It removes the entire row, not individual fields of the row, so no field argument is needed. The DELETE command is used as follows: DELETE FROM table-name WHERE condition; For example to delete the record whose admission number is 104 the command is given as follows: DELETE FROM Student WHERE Admno=104;
The following record is deleted from the Student table. To delete all the rows of the table, the command is used as : DELETE * FROM Student; The table will be empty now and could be destroyed using the DROP command. (iii) UPDATE COMMAND The UPDATE command updates some or all data values in a database. It can update one or more records in a table. The UPDATE command specifies the rows to be changed using the WHERE clause and the new data using the SET keyword. The command is used as follows: UPDATE SET columnname = value, column-name = value,… WHERE condition; For example to update the following fields: UPDATE Student SET Age = 20 WHERE Place = “Bangalore ”; The above command will change the age to 20 for those students whose place is “Bangalore”. The table will be as updated as below:
To update multiple fields, multiple field assignment can be specified with the SET clause separated by comma. For example to update multiple fields in the Student table, the command is given as: UPDATE Student SETAge=18, Place = ‘Chennai’ WHERE Admno = 102;
The above command modifies the record in the following way.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23. |
Pick the odd one out. (DEC, NUMBER, INT, DATE) |
|
Answer» DATE is odd from the above |
|
| 24. |
Null values in tables are specified as “null”. State whether true or false. |
|
Answer» False. (without double quotes i.e. null is then it is true.) |
|
| 25. |
Data dictionary is a special file in DBMS. What is it used for? |
|
Answer» Table details are stored in this file. |
|
| 26. |
Assume that CUSTOMER is a table with columns Cust_code, Cust_name, Mob_No and Email. Write an SQL statement to add the details of a customer who has no e-mail id |
|
Answer» INSERT INTO CUSTOMER VALUES(1001, ‘ALVIS’, 9447024365, NULL); |
|
| 27. |
Name the most appropriate SQL data type required to store the following data:(a) Name of a Student (b) Date of Birth of a Student (c) Percentage of marks obtained |
|
Answer» (a) varchar (b) date (c) decimal |
|
| 28. |
Distinguish between DDL and DML and give examples for each type. |
|
Answer» Data Definition Language(DDL) – It is used to define the structure of a table. Data Definition Language is used to specify the definitions of Database Schema. The result of the compilation of DDL statements is a set of tables stored in a special file called data dictionary. DDL Commands are Create table, Alter table and Drop table. Data Manipulation Language(DML) – It is used to add, retrieve, modify and delete records in a data base. It is a language that enable users to access or manipulate data in the database. It also provides interfaces with programming languages. DML Commands are select, insert, update and delete |
|
| 29. |
The command to remove rows from a table ‘CUSTOMER’ is:(a) Remove From Customer (b) Drop Table Customer (c) Delete From Customer (d) Update Customer |
|
Answer» (c) Delete From Customer |
|
| 30. |
Assume that CUSTOMER is a table with columns Cust_code, Cust_name, Mob_No and Email. Write an SQL statement to add the details of a customer who has no e-mail id. |
|
Answer» INSERT INTO CUSTOMER VALUES(1001, ‘ALVIS’, 9447024365, NULL); |
|
| 31. |
Identify the errors in the following SQL statement and give reason for the error. SELECT FROM STUDENT ORDER BY Group WHERE Marks above 50; |
|
Answer» In this query Group is the keyword hence it cannot be used. The correct query is as follows. SELECT * FROM STUDENT WHERE Marks > 50 ORDER BY Marks; |
|
| 32. |
Is there any data type available in SQL to store your date of birth information? |
|
Answer» Ip Yes. DATE data type |
|
| 33. |
Which command is used to remove a table from a database? |
|
Answer» DROP TABLE is used to remove a table from a database |
|
| 34. |
If a table named mark” has field’s regNo. sub code and marks write SQL statements for the following:a) List the subject codes eliminating duplicates. (b) List the marks obtained by Students with subject codes 3001 and 3002. (c) Arrange the table based on marks for each source (d) List all the Students who have obtained marks above 90 for the subject codes 3001 and 3002. (e) List the contents of the table in the descending order of marks. |
|
Answer» (a) Select distinct sub code from mark; (b) Select marks from mark where sub Code= 3001 or sub Code = 3002; (c) Select * from mark order by sub code, marks; (d) Select * from mark where sub code in (3001,3002) and marks >90; (e) Select *from mark order by marks desc; |
|
| 35. |
Differentiate CHAR and VARCHAR data types of SQL. |
|
Answer» 1. Char – It is used to store fixed number of characters. It is declared as char (size) 2. Varchar – It is used to store characters but it uses only enough memory. |
|
| 36. |
Consider the following variable Declaration in SQL. a. name char (25) b. name Varchar (25) 1. Considering the utilisation of memory, which variable declaration is more suitable. 2. Justify your answer |
|
Answer» 1. name varchar (25) 2. Because char data type is fixed length. It allocates maximum memory i.e, here it allocates memory for 25 characters maybe there is a chance of memory wastage. But Varchar allocates only enough memory to store the actual size. |
|
| 37. |
A table named student is given below.Roll NoNameBatchPercent1HariCommerce802BinuScience853SarithaBumanities4VimalaScience905SinduScience756BijuCommerce777VinodHumanitiesWrite answers for the questions based on the above table. 1. SQL statement to display the different courses available without duplication.2. SQL statement to display the Name and Batch of the students whose percentage has a null value.3. Output of the query select count (percentage) from Student. |
|
Answer» 1. Select distinct batch from Student; 2. Select name, batch from Student where percent is null 3. 5 |
|
| 38. |
Which SQL command is used to open a database? (a) OPEN (b) SHOW (c) USE (d) CREATE |
|
Answer» USE command is used to open a database. |
|
| 39. |
Which is the keyword used with SELECT command to avoid duplication of rows in the selection? |
|
Answer» DISTINCT is the keyword used with SELECT command to avoid duplication of rows in the selection. |
|
| 40. |
Some constraints in SQL are called column constraints. Some constraints are called table constraints. How do they differ? |
|
Answer» Column constraints are specified while defining each column, table constraints are specified once for the entire table at the end of table definition. |
|
| 41. |
………… symbol is used as substitution operator in SQL. |
|
Answer» & symbol is used as substitution operator in SQL. |
|
| 42. |
What are the different modifications that can be made on the structure of a table? Which is the SQL corn mand required for this? Specify the clauses needs for each type of modification. |
|
Answer» Alter table command is used to modify existing column or add new column to an existing table. There are 2 keywords used ADD and MODIFY. We can alter the table in two ways. We can add a new column to the existing table using the following syntax, ALTER TABLE <tablename>ADD(<cloumnname><type><constraint>); We can also cha rige or modify the existing column in terms of type or size using the following syntax, ALTER TABLE<tablename>MODIFY(<column><newtype>); |
|
| 43. |
Once the creation of a table is over, one can perform two changes in the schema of the table. What are they? Give syntax. |
|
Answer» We can alter the table in two ways.
syntax, ALTER TABLE <tablename>ADDD(<cloumnname><type><constraint>);
syntax, ALTER TABLE <tablename>MODIFY(<column><newtype>); |
|
| 44. |
During the discussion of study your friend say that table and view are the same. How can you correct him? |
|
Answer» Tables and views are different. A view is a single virtual table that is derived from other physically existing tables. When we access a view we actually access the base tables. We can use all the DML commands with the views but care should be taken as operation actually reflects in the base tables. The advantage of view is that without sparing extra storage space, we can use same table as different virtual tables. It also implements sharing along with privacy). |
|
| 45. |
Pick odd one out and write reason: (a) WHERE (b) ORDER BY (c) UPDATE (d) GROUP BY |
|
Answer» (c) UPDATE. It is a command and others are clauses. |
|
| 46. |
Explain how pattern matching can be done in SQL with an example. |
|
Answer» Pattern matching can be done using the operator LIKE while setting the condition with pattern matching. for eg., to display the names of all students whose name begins with letters ‘ma’, we can write the following query, SELECT name FROM STUDENT WHERE name LIKE ‘ma%’; here the character ‘%’ – substitutes any number of characters in the value of the specified column. Another character substitutes only one character of the specified column. |
|
| 47. |
........ symbol is used as substitution operator in SQL |
|
Answer» & symbol is used as substitution operator in SQL |
|
| 48. |
What is the difference between PRIMARY KEY and UNIQUE constraints? |
|
Answer» Unique – It ensures that no two rows have the same value in a column. Primary key – Similar to unique but it can be used only once in a table. The strings (i) and (iv) only |
|
| 49. |
Distinguish between COUNT (*) and COUNT (column-name). |
|
Answer» Count() – find the number of non null values in a column. Count(*) This is used to find the number of records with at least one field. |
|
| 50. |
Explain first generation computers. |
|
Answer» First generation computers were vacuum tubes based machines. These were large in size, difficult to operate and instructions were to be written in machine language. Their computation time was in milliseconds. |
|