Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

SQL Interview Questions

SQL is a standard language used to define, manipulate, and control relational databases. It was initially created in 1970. SQL supports four main operations: DDL for defining data structure, DML for manipulating data, DCL for controlling access, and TCL for transaction control. SQL allows users to retrieve, insert, update, and delete data from a relational database. It also supports functions like joins, unions, and other operations on database tables.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

SQL Interview Questions

SQL is a standard language used to define, manipulate, and control relational databases. It was initially created in 1970. SQL supports four main operations: DDL for defining data structure, DML for manipulating data, DCL for controlling access, and TCL for transaction control. SQL allows users to retrieve, insert, update, and delete data from a relational database. It also supports functions like joins, unions, and other operations on database tables.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SQL INTERVIEW QUESTIONS

What is SQL?

SQL is Structured Query Language. It is standard language used to maintain the relational
database and perform many difficult data manipulation operations on the data. SQL was initially
invented in the year 1970. It is a database language used for database creation, deletion, fetching, and
modifying rows, etc. Sometimes, it is pronounced as ‘SEQUEL’. We can also used it to handle organized
data comprised of entities (variables) and relations between different entities of the data.

When SQL appeared?

SQL was first appeared in 1974. It is one of the most used languages for maintaining the
relational database. In 1986, SQL became the standard of the American National Standards Institute
(ANSI) and International Organization Standardization (ISO) in 1987.

What is clustered index in 1974?

A clustered index is actually a table where data for rows are stored. It determines the order of
the table data based on the key-values that can sort in only one direction. Each table can have only one
clustered index. It is the only index, which has been automatically created when primary key is
generated. If many data modifications needed to be done in the table, then clustered are preferred.

What are the usages of SQL?

SQL is responsible for maintaining the relational data and the data structures present in the
database, some of the common usage are given below

 To execute queries against a database.


 To retrieve data from database.
 To insert records in a database.
 To updates records in a database.
 To delete records from a database.
 To create new databases
 To create new tables in a database
 To create views in a database.
 To perform complex operations on the database.

Does SQL support programming language feature?

SQL refers to the Standard Query Language. Therefore it is true that SQL is a language but does
not actually support the programming language. It is a common language that doesn’t have a loop,
conditional statements, and logical operations. It cannot be used for anything other than data
manipulation. The primary purpose of SQL is to retrieve, manipulate, update and perform complex
operations like joins on the data present in the database.
What is the purpose of DDL language?

DDL stands for Data Definition Language. It is the subset of databases that defines the data
structure of the database when the database is created. For Example, we can use the DDL commands to
ass, remove, or modify tables. It consists of the following commands: - CREATE, ALTER and DELETE
database objects such as schema, tables, indexes, views, sequence, etc.

What are the subsets of SQL?

The following are the four significant subsets of SQL –

1. Data Definition Language(DDL) –

It defines the data structure that consists of commands like CREATE, ALTER, SROP, etc.

2. Data Manipulation Language(DML) –


It is used to manipulate existing data in the database. The commands in this category
are SELECT, UPDATE, INSERT, etc.
3. Data Control Language(DCL) –

It controls access to the data stored in the database. The commands in this category
include GRANT and REVOKE.

4. Transactional Control Language(TCL) –

It is used to deal with the transaction operations in the database. The commands in this
category are COMMIT, ROLLBACK, SET TRANSACTION, SAVEPOINT, etc.

What is primary key?

A primary key is a field or the combination of fields that uniquely identify each round in the
table. It is one of a special kind of unique key. If the column contains a primary key, it cannot be null or
empty. A table can have duplicate columns, but it cannot have more than one primary key. It always
stores unique values into a column.

What do you mean by table and field in SQL?

A table refers to a collection of data in an organized manner in form of rows and columns. A
field refers to the number of columns in a table.

Example: - Table – Student Information

Field – StuId, StuName, StuMarks.

What are constraints?


Constraints in SQL are used to specify the limit of the data type of the table. It can be specified
while creating and altering the table statements. Some of the constraints are –

1. NOTNULL
2. CHECK
3. DEFAULT
4. UNIQUE
5. PRIMARY KEY
6. FOREIGN KEY

Explain different types of normalization?

There are many successive levels of normalization. These are called normal forms. Each
consecutive normal form depends on the previous one. The first three normal forms are usually
adequate.

1. First Normal Form(1NF) –


No repeating groups within rows.
2. Second Normal Forms(2NF) –

Every non-key (supporting) column value is dependent on the whole primary.

3. Third Normal Form(3NF) –


Dependent solely on the primary key and no other non-key (supporting) common value.

What do you mean by “TRIGGER” in SQL?

Triggers in SQL are a special type of stored procedures that are defined to execute automatically
in place or after data modifications. It allows you to execute a batch of code when an INSER or UPDATE
or any other query is executed against a specific table.

What is the difference between CROSS JOIN and NATURAL JOIN?

The cross join produces the cross product or Cartesian product of two tabled whereas the
natural join is based on all columns have the same name and data types in both the tables.

What is the need for group functions in SQL?

Group functions work on the set of rows and return on result per group. Some of the commonly
used group functions are – AVG,COUNT, MAX, MIN, SUM, VARIANCE.

How do you fetch common records from two tables?

You can fetch common records from two tables using INTERSECT.

What are the different set operations available in SQL?


Some of the available set operations are – UNION, INTERSECT or MINUS operator.

What is stored procedure?

A stored procedure is a function which consists of many SQL statements to access the database
system. Several SQL statements are consolidated into a stored procedure and execute them whenever
and wherever required, which saves time and avoid writing code again and again

What is unique key?

Uniquely identifies a single row in the table. Multiple values allowed per table. Null values
allowed.

What is the difference between CHAR and VARCHAR2 data type in SQL?

Both Char and Varchar2 are used for characters data type but varchar2 is used for characters
string of variable length whereas char is used for strings of fixed length.

Example: - char(10) can store 10 characters and will not be able to store a string of any other length
whereas varchar2(10) can store any length i.e., 6,8,2 in this variable.

What is the difference between SQL and MYSQL

SQL MYSQL

SQL is a standard language which stands for MYSQL is a DataBase Management System
Structured Query Language based on the English
language

SQL is the core of the relational database which is MYSQL is an RDBMS (Relational DataBase
used for accessing and managing database. Management System) such as SQL server, Informix,
etc.

What is relationship and what are they?

Relation or links between entities that have something to do with each other. Relationships are
defined as the connection between the tables in a database. There are various relationships, namely-

1. One to one Relationship


2. One to many Relationship
3. Many to one Relationship
4. Self-Referencing Relationship

Explain different types of index in SQL


There are three types of index in SQL namely-

1. Unique Index –

This index does not allow the field to have duplicate if the column is unique indexed. It is
a primary key is defined, a unique index can be applied automatically.

2. Clustered Index –
This index records the physical order of the table and searches based on the basis of
key-values. Each table can only have one clustered index.
3. Non- clustered Index –
Non-clustered Index does not alter the physical order of the table and maintains a
logical order of the data. Each table can have many non-clustered indexes.

You might also like