SQL frequently used commands and interview questions

Below are the frequently used commands and interview questions for SQL basic and intermediate level SQL Developers, Administrators, and Testers. These questions are about SELECT commands and some of the important and frequently  used commands.

 
1) What are most important DDL Commands in SQL?
CREATE TABLE - creates a new database table
ALTER TABLE - alters (changes) a database table
DROP TABLE - deletes a database table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index

2) What are the Operators used in SELECT statements?
= Equal
<> or != Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range LIKE Search for a pattern

3) How to  INSERT Values into Tables?
INSERT INTO table_name VALUES (value1, value2,....)
INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)

4) How to Update a Column Name?
UPDATE table_name SET column_name = new_value WHERE column_name = some_value

5) How to Delete Columns, Rows?
Delete a particular column:
DELETE FROM table_name WHERE column_name = some_value
Delete All Rows:
DELETE FROM table_name or DELETE * FROM table_name

6) Give an usage for BETWEEN ... AND?
SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2 The values can be numbers, text, or dates.

7) What is the use of CASCADE CONSTRAINTS?
When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.

8) Why does the following command give a compilation error?
DROP TABLE &TABLE NAME;
Variable names should start with an alphabet. Here the table name starts with an '&' symbol.

9) Which system tables contain information on privileges granted and privileges obtained?
USER_TAB_PRIVS_MADE, USER_TAB_PRIVS_RECD

10) Which system table contains information on constraints on all the tables created?obtained?
USER_CONSTRAINTS.

11) State true or false. EXISTS, SOME, ANY are operators in SQL?
True.

12) What does the following query do?
SELECT SAL + NVL(COMM,0) FROM EMP;?
This displays the total salary of all employees. The null values in the commission column will be replaced by 0 and added to salary.

13) What is the advantage of specifying WITH GRANT OPTION in the GRANT command?
The privilege receiver can further grant the privileges he/she has obtained from the owner to any other user.

14) Which command executes the contents of a specified file?
START or @.

15) Which command displays the SQL command in the SQL buffer, and then executes it?
RUN.

16) What command is used to get back the privileges offered by the GRANT command?
REVOKE.

17) Which date function is used to find the difference between two dates?
MONTHS_BETWEEN.

18) What operator performs pattern matching?
LIKE operator.

19) What is the use of the DROP option in the ALTER TABLE command?
It is used to drop constraints specified on the table.

20) What operator tests column for the absence of data?
IS NULL operator.

0 Comment to "SQL frequently used commands and interview questions"

Post a Comment