Q 1. What is the full form of SQL?
A. Structured Query List
B. Structured Query Language
C. Simple Query Language
D. None of these
Show Answer
Answer:-B. Structured Query LanguageExplanation
SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS). Originally based upon relational algebra and tuple relational calculus, SQL consists of a data definition language and a data manipulation language. The scope of SQL includes data insert, query, update and delete, schema creation and modification, and data access control.Q 2. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?
A. Data Definition Language(DDL)
B. Data Manipulation Language(DML)
C. Both of above
D. None
Show Answer
Answer:-A. Data Definition Language(DDL)Explanation
Data Definition Language, represented by DDL, is the subset of SQL commands used to manipulate Oracle Database structures, including tables. DDL commands are responsible for defining, modifying, and deleting the structure of a database, such as creating and altering tables, defining constraints, and managing indexes. They do not deal with the actual data within the tables, which is the primary function of Data Manipulation Language (DML) commands. So, Option A is the correct answer. CREATE, ALTER, RENAME, DROP and TRUNCATE statements are the names of few data definition elements.Q 3. Which operator performs pattern matching?
A. BETWEEN operator
B. EXISTS operator
C. LIKE operator
D. None of these
Show Answer
Answer:-C. LIKE operatorExplanation
LIKE is a keyword that is used in the WHERE clause. Basically, LIKE allows us to do a search based operation on a pattern rather than specifying exactly what is desired (as in IN) or spell out a range (as in BETWEEN). The syntax is as follows: SELECT “column_name” FROM “table_name” WHERE “column_name” LIKE {PATTERN} {PATTERN} often consists of wildcards. In SQL, there are two wildcards: 1=% (percent sign) represents zero, one, or more characters. 2=_ (underscore) represents exactly one character.Q 4. What operator tests column for the absence of data?
A. EXISTS operator
B. NOT operator
C. IS NULL operator
D. None of these
Show Answer
Answer:-C. IS NULL operatorExplanation
Always use IS NULL to look for NULL values. Syntax: SELECT “column_name” FROM “table_name” WHERE “column_name” IS NULLQ 5. In SQL, which command(s) is(are) used to change a table’s storage characteristics?
A. CHANGE TABLE
B. MODIFY TABLE
C. ALTER TABLE
D. All of the above
Show Answer
Answer:-C. ALTER TABLEExplanation
To change the structure of the table we use ALTER TABLE. Sytax: ALTER TABLE “table_name” ADD “column_name” datatype OR ALTER TABLE “table_name” DROP COLUMN “column_name” etc..Q 6. In SQL, which of the following is not a data definition language commands?
A. RENAME
B. REVOKE
C. GRANT
D. UPDATE
Show Answer
Answer:-D. UPDATEExplanation
RENAME: – With RENAME statement you can rename a table. REVOKE: – The REVOKE command removes user access rights or privileges to the database objects. GRANT: – In SQL GRANT is a command used to provide access or privileges on the database objects to the users. UPDATE: – The UPDATE Statement is used to modify the existing rows in a table. RENAME, REVOKE and GRANT are DDL(Data Definition Language) commands and UPDATE is DML(Data Manipulation Language) command.Q 7. In SQL, which command is used to SELECT only one copy of each set of duplicable rows
A. SELECT DISTINCT
B. SELECT UNIQUE
C. SELECT DIFFERENT
D. All of the above
Show Answer
Answer:-A. SELECT DISTINCTExplanation
The SELECT keyword allows us to grab all information from a column (or columns) on a table. This, of course, necessarily means that there will be redundancies. What if we only want to select each distinct element? This is easy way to accomplish in SQL. All we need to do is that to add DISTINCT after SELECT. The syntax is as follows: SELECT DISTINCT column_name FROM table_name;Q 8. A command that lets you change one or more fields in a record is
A. Modify
B. Insert
C. Look-up
D. All of the above
Show Answer
Answer:-B. InsertExplanation
Sometimes we need to change the data type of a column. To do this, we use the ALTER TABLE Modify Column command. Sytax: ALTER TABLE table_name MODIFY column_name “New Data Type”Q 9. Which of the SQL statements is correct?
A. SELECT Username AND Password FROM Users
B. SELECT Username, Password FROM Users
C. SELECT Username, Password WHERE Username = ‘user1’
D. None of these
Show Answer
Answer:-B. SELECT Username, Password FROM UsersExplanation
Correct order of SELECT, FROM and WHERE clause is as follow: SELECT column_name1, column_name2, …. FROM table_name WHERE condition So, only SELECT Username, Password FROM Users follows the above syntax.Q 10. The FROM SQL clause is used to…
A. specify what table we are selecting or deleting data FROM
B. specify range for search condition
C. specify search condition
D. None of these
Show Answer
Answer:-A. specify what table we are selecting or deleting data FROMExplanation
specify what table we are selecting or deleting data FROM.Q 11. Which SQL keyword is used to retrieve only unique values?
A. DISTINCTIVE
B. UNIQUE
C. DISTINCT
D. DIFFERENT
Show Answer
Answer:-C. DISTINCTExplanation
This command is used to select the distinct rows. For Example: If we want to select all distinct department names from employee table, the query would be: SELECT DISTINCT dept FROM employee;Q 12. Which SQL keyword is used to retrieve a maximum value?
A. TOP
B. MOST
C. UPPER
D. MAX
Show Answer
Answer:-D. MAXExplanation
MAX function is used to get the maximum value from a column. To get the maximum salary drawn by an employee, the query would be: SELECT MAX (salary) FROM employee;Q 13. What is a view?
A. A view is a special stored procedure executed when certain event occurs.
B. A view is a virtual table which results of executing a pre-compiled query. A view is not part of the physical database schema, while the regular tables are.
C. A view is a database diagram.
D. None of these
Show Answer
Answer:-B. A view is a virtual table which results of executing a pre-compiled query. A view is not part of the physical database schema, while the regular tables are.Explanation
A VIEW is a virtual table, through which a selective portion of the data from one or more tables can be seen. A view do not contain data of their own. They are used to restrict access to the database or to hide data complexity. A view is stored as a SELECT statement in the database. DML operations on a view like INSERT, UPDATE, DELETE affects the data in the original table upon which the view is based. The Syntax to create a sql view is: CREATE VIEW view_name AS SELECT column_list FROM table_name [WHERE condition]; view_name is the name of the VIEW. The SELECT statement is used to define the columns and rows that you want to display in the view.Q 14. Which of the following SQL commands is used to retrieve data?
A. DELETE
B. INSERT
C. JOIN
D. SELECT
Show Answer
Answer:-D. SELECTExplanation
SELECT The SELECT command is specifically designed for retrieving data from one or more tables in a database. It is used to perform queries and retrieve records that match specified criteria.Q 15. Which of the following is a SQL aggregate function?
A. LEFT
B. AVG
C. JOIN
D. LEN
Show Answer
Answer:-B. AVGExplanation
SQL has several arithmetic functions to do math on the numbers, such as summing up, taking average, retrieved from the column. They are: AVG():- Average of the column COUNT():- Number of records MAX():- maximum of the column MIN():- minimum of the column SUM():- Sum of the columnQ 16. Which SQL statement is used to update data in a database?
A. UPDATE
B. SAVE
C. SAVE AS
D. MODIFY
Show Answer
Answer:-A. UPDATEExplanation
UPDATE The UPDATE command is used to modify existing records in a database table. It allows you to change the values of specific columns in one or more rows based on specified conditions.Q 17. Which SQL statement is used to delete data FROM a database?
A. COLLAPSE
B. REMOVE
C. ALTER
D. DELETE
Show Answer
Answer:-D. DELETEExplanation
DELETE The DELETE command is specifically designed to remove rows or records from a database table based on specified conditions.Q 18. Which SQL keyword is used to sort the result-set?
A. SORT BY
B. ORDER
C. ORDER BY
D. SORT
Show Answer
Answer:-C. ORDER BYExplanation
ORDER BY The ORDER BY clause is used to specify the sorting of the result-set based on one or more columns. You can use it to sort the result-set in ascending or descending order.Q 19. The SQL statement SELECT SUBSTR(‘123456789’, INSTR(‘abcabcabc’, ‘b’), 4) FROM DUAL;
A. 6789
B. 2345
C. 1234
D. 456789
Show Answer
Answer:-B. 2345Explanation
INSTR Function:- The INSTR function in SQL is used to find the starting location of a pattern in a string. The syntax for the INSTR function is as follows: INSTR (str, pattern): Find the starting location of pattern in string str. SUBSTR Function:- The Substring function in SQL is used to grab a portion of the stored data. The syntax for the SUBSTR function is as follows: SUBSTR(str,pos,len): Starting with the position pos in string str select the characters upto the length len. In the above query, INSTR(‘abcabcabc’, ‘b’) outputs 2 as the starting location of patternQ 20. Which of the following group functions ignore NULL values?
A. MAX
B. COUNT
C. SUM
D. All of the above
Leave a Reply