SQL Database #1-Questions & Answers

What is an SQL Database

SQL (Structured Query Language) is a standardized programming language used for managing relational databases and performing various operations on the data in them. Initially created in the 1970s, SQL is regularly used by database administrators, as well as by developers writing data integration scripts and data analysts looking to set up and run analytical queries.
The uses of SQL include modifying database table and index structures; adding, updating and deleting rows of data; and retrieving subsets of information from within a database for transaction processing and analytics applications. Queries and other SQL operations take the form of commands written as statements — commonly used SQL statements include select, add, insert, update, delete, create, alter and truncate.

Some Important Questions about SQL Database are listed below:-


Related Link
Security Tool -Cyber Security # 4
Security Tips – Cyber Security #3
Method Of Defence – Cyber Security #2
Computer Threats – Cyber Security #1


1. What command is used to create a table by copying the structure of another table?

Answer: CREATE TABLE .. AS SELECT commandExplanation:To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement as in the following
CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2;
If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table.

2. What will be the output of the following query?
SELECT REPLACE(TRANSLATE(LTRIM(RTRIM(‘!! ATHEN !!’,’!’), ‘!’), ‘AN’, ‘**’),’*’,’TROUBLE’) FROM DUAL;

Answer: TROUBLETHETROUBLE

3. What will be the output of the following query?
SELECT DECODE(TRANSLATE(‘A’,’1234567890′,’1111111111′), ‘1’,’YES’, ‘NO’ ); Answer :

Answer: NO
Explanation : The query checks whether a given string is a numerical digit.

4. What does the following query do?

SELECT SAL + NVL(COMM,0) FROM EMP;

Answer: This displays the total salary of all employees. The null values in the commission column will be replaced by 0 and added to salary.

5. Which date function is used to find the difference between two dates?



Related Link
Security Tool -Cyber Security # 4
Security Tips – Cyber Security #3
Method Of Defence – Cyber Security #2
Computer Threats – Cyber Security #1

Answer: MONTHS_BETWEEN


6. Why does the following command give a compilation error? DROP TABLE &TABLE_NAME;

Answer: Variable names should start with an alphabet. Here the table name starts with an ‘&’ symbol.


7. What is the advantage of specifying WITH GRANT OPTION in the GRANT command?

Answer: The privilege receiver can further grant the privileges he/she has obtained from the owner to any other user.


8. What is the use of the DROP option in the ALTER TABLE command?

Answer: It is used to drop constraints specified on the table.


9. What is the value of ‘comm’ and ‘sal’ after executing the following query if the initial value of ‘sal’ is 10000?

UPDATE EMP SET SAL = SAL + 1000, COMM = SAL*0.1;

Answer: sal = 11000, comm = 1000


10. What is the use of DESC in SQL?

Answer : DESC has two purposes. It is used to describe a schema as well as to retrieve rows from table in descending order.Explanation: The query SELECT * FROM EMP ORDER BY ENAME DESC will display the output sorted on ENAME in descending order.




Related Link
Security Tool -Cyber Security # 4
Security Tips – Cyber Security #3
Method Of Defence – Cyber Security #2
Computer Threats – Cyber Security #1


Related Link ,See once

SECURITY TOOLS -Cyber Security # 4
Security Tips – Cyber Security #3
Method Of Defence – Cyber Security #2
Computer Threats – Cyber Security #1
Cyber Security Introduction
Cyber Security
World Wide G.K
Facts around World
Science
Geography
History of the World

Comment Please