SQL Interview Questions For Fresher

  • SQL Interview Questions for Freshers:

Following are some important SQL Interview Questions for freshers as well as experienced professionals:

1.What is SQL?[100 % asked  SQL Interview Questions ]

Answer: 

SQL Stands for Structured Query Language which is specially designed to communicate with databases.SQL pronounced as Sequel is very widely used language in most of the database management systems like Oracle,MySQL,PostgreSQL etc.SQL provides us  a simple and efficient way of reading,writing,executing the data from the system.this is one of the SQL Interview Question ever asked in interviews

2.What is the use of NVL function in Oracle?[80% asked SQL Interview Question ]

Answer:

NVL function is most important function to replace null value with another value.

Example: select NVL(null,'Amit') from dual; 
which will give you output as Amit.

3.What is Unique Key? [  90% asked SQL Interview Questions ]

Answer:

Unique key is nothing but the columns which are uniquely identifies the values.There are more than one unique keys for each table.The Entry of Null value is allowed in Unique key.Oracle does not permit you to create primary key and unique key on same column.

Syntax: 
Create table Table_name
(Column_name1 Datatype[null/not null],
 Column_name Datatype[null/not null].......
Constraint constraint_name Unique(uc_col1,uc_col2..));

4.What is difference between Unique Key Constraint and Primary Key Constraint?[80% asked SQL Interview Questions ]

Answer:

Primary Key constraint:

1.Primary key will not accept the null values in the table column.

2.Primary is  basically used to identify the unique records in the table.

3.We have only one primary key per table.

Unique Key Constraint:

1.Unique key accepts the null values in the table.

2.The main task of unique key is it is used to remove duplicate values from the table with exception of null entry.

3.We will have more than 1 unique keys on a single table.

 

SQL Interview Questions

SQL Interview Questions

5.What is difference between varchar and varchar2 datatype?

Answer:

Varchar can store up to 2000 bytes and varchar2 can store up to 4000 bytes of memory space.Varchar will occupy the space for null values whereas varchar2 can not occupy the space for null values.So varchar2 is good to use not to  face performace related problems.varchar2 is faster than varchar datatype.

6.How to represent comments in oracle?

Answer:

There are following 2 ways for commenting in oracle:

1.Single Line comment: Two dashes (–) before begining of the line

2.Multiline comment/Block comment:When user wants to comment multiple line /* */ operators are used.

7.What is raw datatype?[90% asked in SQL Interview Questions]

Answer:

Raw datatype is used to store values in binary data format.There are 2 types of RAW datatype.1.Raw 2.Long Raw. Long raw datatype is used to store graphics,sound documents.Raw datatype is variable length datatype like varchar2 but basically it only stores  data in 1 ‘s and 0’s means binary data format.

8.What is ROWID & ROWNUM?(90 % asked in SQL Interview Question)

Answer:

ROWID is nothing but the physical address given to that row which is in hexadecimal format.ROWNUM is nothing but the logical sequence given to the row of that column.

[click here for detailed description]

9.What are views in SQL?Explain types of Views in SQL?(Asked in almost every SQL Interview Questions)

Answer:

Views:

Views are nothing but the logical structure of the table where we can fetch the data from different tables or same table.

There are 2 types of views in Oracle:

1.Simple View:Simple view has been created on only a single table.

2.Complex view:Views which are created using more than 1 table which has joins clauses are known as complex views.

[Click here to get more information on views]

10.What is Materialized View in SQL?

Answer :

Materialized view is also logical structure of one or more table in which data is stored physically in the view.Data has been stored physically in materialized view so data retrieval is faster as compare to simple view.

[Click here to get more information on materialized view]

11.Why to use SQL? [90% asked SQL Interview Questions ]

Answer:

SQL is structured query language which is used for manipulation of data.There are following reasons why to use SQL:

  • Allows users to access data in relational database management systems.

  • Allows users to define the data in database and manipulate that data.

  • Allows users to create and drop databases and tables.

  • Allows users to create view, stored procedure, functions in a database.

  • Allows users to set permissions on tables, procedures, and views.

12.What is difference between Truncate ,Drop and DELETE?

Answer:

1.Drop:

1.Drop command is DDL command which is used to delete the object from the database.

2.We can not use the “ROLLBACK” after using drop command.

3.Drop command free’s the space of database object.

4.Drop table table_name;

2.Truncate:

1.Truncate command is DDL command which is used to truncate the data from the database table.

2.We can not use the “ROLLBACK” after using Truncate command.

3.It free’s the space of database object but the structure remains same and memory of structure also remains same.

4.Truncate table table_name;

3.Delete:

1.Delete command is DML command which is used to delete the records from table.

2.We can use Rollback to Rollback the records from the table.

3.Delete command not free’s the memory space.

4.Delete table table_name where condition;

13.Explain About DDL Statements of SQL?

DDL – DDL stands for Data Definition Language:

Statement  Description
CREATE Creates a new table, a view of a table, or other object in database
ALTER Modifies an existing database object, such as a table.
DROP Deletes an entire table, a view of a table or other object in the database.

14.What is DML in SQL.Explain DML Statements in Details?

Answer:

DML stands for Data Manipulation Language:

Statement Description
INSERT Creates a record
UPDATE Modifies records
DELETE Deletes records

15.What is Database?[90% asked SQL Interview Questions]

Answer:

  • It is a collection of Inter-Related data. Records the data in HDD (Permanent Memory).
  • Inter-Related data means relation among data values
  • Objective of DB is to record data & save it for future use.

16.What is RDBMS?

Answer:

RDBMS stands for Relational DataBase Management System. RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

A Relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd.

17. What are tables and Fields?

Answer:

A table is set of data which is organized in to specific structured manner.Table is made up of combination of columns and rows.A table has specified number of column called fields but can have any number of rows which is called record.

Example:Table

Name(Field 1) Salary(Field 2)
Amit S(Record1) 10000(Record1)

18.Explain me about SQL joins?

Answer:

CLICK HERE TO GET ANSWER IN DETAILS

Join is nothing but connecting 2 tables to fetch the records from 2 or more different tables.There are following types of joins in SQL:

1.Inner join:

Inner join retreives the records which are common between 2 or more tables.

2.Outer join:

Outer join retrieves the common records from the table as well as uncommon records from Left or right table.

2.1.Left outer join:

When user needs to fetch all data from left table and common records from left and right table then the join is called as left outer join.

2.2.Right outer join:

When user needs to fetch all data from right table and common records from left and right table then the join is called as right outer join.

2.3.Full Outer Join:

When user needs to fetch the data from both the tables and common records from both of the tables.

3.Cross join/Cartesian join:

When each and every record is connected to each and every record from other table then it is called as cross join or Cartesian join.

19.What is Views in SQL?(Asked in almost every SQL Interview Questions)

Answer:

View is nothing but the virtual structure which is been created from using single table or multiple tables.If the logical structure is created from single table then it is called as Simple view.If logical structure is created using  multiple tables using joins then it is called as Complex View.

Click here to get more information about views

20.What is index and what are types of indexes?[80% asked SQL Interview Questions ]

Answer:

Indexing is nothing but the performance tuning mechanism which allows the fast retrieval of the records from table.

Following are types of indexes:

1.Normal Indexes

2.Bit Map indexes

3.Unique indexes

4.Clustered Indexes

5.Non Clustered Indexes

Click here to get more information on Indexes

 

Hope you like this article on SQL Interview Questions for fresher.If You want the PDF for these interview questions kindly comment in comment section..

 

4 Comments

  1. Santhoshi November 25, 2018
    • Amit S November 26, 2018
  2. harish December 10, 2018
    • Amit S December 11, 2018

Leave a Reply