SQL Questions and Answers 1
SQL Questions and Answers 1
SQL Questions and Answers 1
SQL vs MySQL
SQL MySQL
A DBMS allows a user to interact with the database. The data stored in the database
can be modified, retrieved and deleted and can be of any type like strings, numbers,
images etc.
Table: StudentInformation
Field: Stu Id, Stu Name, Stu Marks
• Inner Join
• Right Join
• Left Join
• Full Join
Both Char and Varchar2 are used for characters datatype but varchar2 is used for
character strings of variable length whereas Char is used for strings of fixed length.
For example, char(10) can only 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.
• NOT NULL
• CHECK
• DEFAULT
• UNIQUE
• PRIMARY KEY
• FOREIGN KEY
Q9. What is the difference between DELETE and
TRUNCATE statements?
DELETE vs TRUNCATE
DELETE TRUNCATE
Delete command is used to delete a row in a Truncate is used to delete all the rows from
table. a table.
Apart from this SQL Interview Questions blog, if you want to get trained from
professionals on this technology, you can opt for a structured training from edureka!
Click below to know more.
1. Clustered index is used for easy retrieval of data from the database and its faster
whereas reading from non clustered index is relatively slower.
2. Clustered index alters the way records are stored in a database as it sorts out rows by
the column which is set to be clustered index whereas in a non clustered index, it does
not alter the way it was stored but it creates a separate object within a table which
points back to the original table rows after searching.
3. One table can only have one clustered index whereas it can have many non
clustered index.
Q14. Write a SQL query to display the current date?
In SQL, there is a built-in function called GetDate() which helps to return the current
timestamp/date.
Inner join: Inner Join in MySQL is the most common type of join. It is used to return
all the rows from multiple tables where the join condition is satisfied.
Left Join: Left Join in MySQL is used to return all the rows from the left table but only
the matching rows from the right table where the join condition is fulfilled.
Right Join: Right Join in MySQL is used to return all the rows from the right table but
only the matching rows from the left table where the join condition is fulfilled.
Full Join: Full join returns all the records when there is a match in any of the tables.
Therefore, it returns all the rows from the left-hand side table and all the rows from the
right-hand side table.
Unique Index:
This index does not allow the field to have duplicate values if the column is unique
indexed. If a primary key is defined, a unique index can be applied automatically.
Clustered Index:
This index reorders the physical order of the table and searches based on the basis
of key values. Each table can only have one clustered index.
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 nonclustered indexes.
Apart from this SQL Interview Questions Blog, if you want to get trained from
professionals on this technology, you can opt for a structured training from edureka!
Click below to know more.
Atomicity: Atomicity refers to the transactions that are completely done or failed
where transaction refers to a single logical operation of a data. It means if one part of
any transaction fails, the entire transaction fails and the database state is left
unchanged.
Consistency: Consistency ensures that the data must meet all the validation rules. In
simple words, you can say that your transaction never leaves the database without
completing its state.
Durability: Durability means that if a transaction has been committed, it will occur
whatever may come in between such as power loss, crash or any sort of error.
1. Arithmetic Operators
2. Logical Operators
3. Comparison Operators
Apart from this SQL Interview Questions blog, if you want to get trained from
professionals on this technology, you can opt for a structured training from edureka!
Click below to know more.
Correlated subquery: These are queries which select the data from a table
referenced in the outer query. It is not considered as an independent query as it refers
to another table and refers the column in a table.
Apart from this SQL Interview Questions Blog, if you want to get trained from
professionals on this technology, you can opt for a structured training from edureka!
Click below to know more.
4 FROM employee_table
Group functions work on the set of rows and returns one result per group. Some of the
commonly used group functions are: AVG, COUNT, MAX, MIN, SUM, VARIANCE.
Example of BETWEEN:
SELECT * FROM Students where ROLL_NO BETWEEN 10 AND 50;
Example of IN:
Apart from this SQL Interview Questions Blog, if you want to get trained from
professionals on this technology, you can opt for a structured training from edureka!
Click below to know more.
• LOWER: This function returns the string in lowercase. It takes a string as an argument
and returns it by converting it into lower case. Syntax:
LOWER(‘string’)
• UPPER: This function returns the string in uppercase. It takes a string as an argument
and returns it by converting it into uppercase. Syntax:
UPPER(‘string’)
• INITCAP: This function returns the string with the first letter in uppercase and rest of
the letters in lowercase. Syntax:
INITCAP(‘string’)
Apart from this SQL Interview Questions blog, if you want to get trained from
professionals on this technology, you can opt for a structured training from edureka!
Click below to know more.
For example-
Scalar functions return a single value based on the input value. For example –
UCASE(), NOW() are calculated with respect to string.
Select studentId from (Select rowno, studentId from student) where mod(rowno,2)=0
Q50. Name the operator which is used in the query for pattern matching?
Apart from this SQL Interview Questions Blog, if you want to get trained from
professionals on this technology, you can opt for a structured training from edureka!
Click below to know more.
Disadvantage:
The only disadvantage of Stored Procedure is that it can be executed only in the
database and utilizes more memory in the database server.
• Scalar Functions
• Inline Table-valued functions
• Multi-statement valued functions
Scalar returns the unit, variant defined the return clause. Other two types of defined
functions return table.
Q59. What do you mean by Collation?
Collation is defined as a set of rules that determine how data can be sorted as well as
compared. Character data is sorted using the rules that define the correct character
sequence along with options for specifying case-sensitivity, character width etc.
Apart from this SQL Interview Questions Blog, if you want to get trained from
professionals on this technology, you can opt for a structured training from edureka!
Click below to know more.
Global variables:
These variables are the variables which can be accessed throughout the program.
Global variables cannot be created whenever that function is called.
AUTO INCREMENT keyword can be used in Oracle and IDENTITY keyword can be
used in SQL SERVER.
• Select SQL Server Configuration Properties, and choose the Security page.
REPLACE function: This function is used to replace the existing characters of all the
occurrences. Syntax:
So this brings us to the end of the SQL interview questions blog. I hope this set of SQL
Interview Questions will help you ace your job interview. All the best for your
interview!
Apart from this SQL Interview Questions Blog, if you want to get trained from
professionals on this technology, you can opt for a structured training from edureka!
Click below to know more.
Check out this MySQL DBA Certification Training by Edureka, a trusted online learning
company with a network of more than 250,000 satisfied learners spread across the
globe. This course trains you on the core concepts & advanced tools and techniques
to manage data and administer the MySQL Database. It includes hands-on learning
on concepts like MySQL Workbench, MySQL Server, Data Modeling, MySQL
Connector, Database Design, MySQL Command line, MySQL Functions etc. End of
the training you will be able to create and administer your own MySQL Database and
manage data.
Got a question for us? Please mention it in the comments section of this “SQL
Interview Questions” blog and we will get back to you as soon as possible.