SQL Interview Questions
1 .
Which are the different case manipulation functions in SQL?
There are three case manipulation functions in SQL:
LOWER : converts character into Lowercase.
UPPER : converts character into uppercase.
INITCAP : converts character values to uppercase for the initials of each word.
2 .
Which are the different character-manipulation functions in SQL?
CONCAT : join two or more values together.
SUBSTR : used to extract the string of specific length.
LENGTH : return the length of the string in numerical value.
INSTR : find the exact numeric position of a specified character.
LPAD : padding of the left-side character value for right-justified value.
RPAD : padding of right-side character value for left-justified value.
TRIM : remove all the defined character from the beginning, end or both beginning and end.
REPLACE : replace a specific sequence of character with other sequences of character.
3 .
What are all the different normalizations?
The normal forms can be divided into some forms, and they are explained below :
First Normal Form (1NF): This should remove all the duplicate columns from the table. Creation of tables for the related data and identification of unique columns.
Second Normal Form (2NF): Meeting all requirements of the first normal form. Placing the subsets of data in separate tables and Creation of relationships between the tables using primary keys.
Third Normal Form (3NF): This should meet all requirements of 2NF. Removing the columns which are not dependent on primary key constraints.
Fourth Normal Form (4NF):Meeting all the requirements of third normal form and it should not have multi- valued dependencies.
4 .
What is Datawarehouse?
Datawarehouse is a central repository of data from multiple sources of information. Those data are consolidated, transformed and made available for the mining and online processing. Warehouse data have a subset of data called Data Marts.
5 .
How many Aggregate functions are available in SQL?
SQL Aggregate functions determine and calculate values from multiple columns in a table and return a single value.
There are 7 aggregate functions in SQL :
AVG() : Returns the average value from specified columns.
COUNT() : Returns number of table rows.
MAX() : Returns the largest value among the records.
MIN() : Returns smallest value among the records.
SUM() : Returns the sum of specified column values.
FIRST() : Returns the first value.
LAST() : Returns last value.
6 .
What are Scalar functions in SQL?
Scalar functions are used to return a single value based on the input values.
Scalar Functions are as follows:
UCASE() : Converts the specified field in the upper case.
LCASE() : Converts the specified field in lower case.
MID() : Extracts and returns character from the text field.
FORMAT() : Specifies the display format.
LEN() : Specifies the length of the text field.
ROUND() : Rounds up the decimal field value to a number.
7 .
What is View in SQL?
A View can be defined as a virtual table that contains rows and columns with fields from one or more tables.
CREATE VIEW view_name AS
SELECT column_name(s) 
FROM table_name 
WHERE condition
8 .
How we can update the view?
SQL CREATE and REPLACE can be used for updating the view.
Execute the below query to update the created view.
SELECT column_name(s)
FROM table_name
WHERE condition
9 .
How many types of Privileges are available in SQL?
There are two types of privileges used in SQL, such as
System privilege : System privilege deals with the object of a particular type and provides users the right to perform one or more actions on it. These actions include performing administrative tasks, ALTER ANY INDEX, ALTER ANY CACHE GROUP CREATE/ALTER/DELETE TABLE, CREATE/ALTER/DELETE VIEW etc.

Object privilege : This allows to perform actions on an object or object of another user(s) viz. table, view, indexes etc. Some of the object privileges are EXECUTE, INSERT, UPDATE, DELETE, SELECT, FLUSH, LOAD, INDEX, REFERENCES etc.
10 .
What is SQL Injection?
SQL Injection is a type of database attack technique where malicious SQL statements are inserted into an entry field of database in a way that once it is executed, the database is exposed to an attacker for the attack. This technique is usually used for attacking data-driven applications to have access to sensitive data and perform administrative tasks on databases.
For Example,
SELECT column_name(s) FROM table_name WHERE condition;