Professional Documents
Culture Documents
1. What is an index?
2. What is normalization?
3. What is Denormalization?
whose definition is available only to the query in which the with clause occurs. SQL
applies predicates in the WITH clause after groups have been formed, so aggregate
6. What is a trigger?
A table can have only one A table can have multiple non-clustered
clustered index. indexes.
The clustered index has an The non-Clustered index does not have
CLUSTERED INDEX NON-CLUSTERED INDEX
inherent ability to store data on the inherent ability to store data on the
the disk. disk.
The transaction can not undo changes Transaction reaches its previous
after COMMIT execution. state after ROLLBACK.
14.What is a T-SQL?
A trigger can also contain INSERT, UPDATE, and DELETE logic within
itself, so when the trigger is fired because of data modification it can
also cause another data modification, thereby firing another trigger. A
trigger that contains data modification logic within itself is called a
nested trigger.
Live lock occurs when two or more processes continually repeat the
same interaction in response to changes in the other processes
without doing any useful work. These processes are not in the waiting
state, and they are running concurrently. This is different from a
deadlock because in a deadlock all processes are in the waiting state.
These functions work with any data type and pertain to the use of null
values in the expression list. These are all single-row functions i.e.
provide one result per row.
NVL(expr1, expr2): In SQL, NVL() converts a null value to an actual
value. Data types that can be used are date, character, and number.
Data types must match with each other. i.e. expr1 and expr2 must be
of the same data type.
Syntax:
Syntax:
NVL2 (expr1, expr2, expr3)
Syntax:
SELECT column(s), CAOLESCE(expression_1,....,expression_n)
FROM table_name;
ISNULL(): The ISNULL function has different uses in SQL Server and
MySQL. In SQL Server, ISNULL() function is used to replace NULL
values.
Syntax:
SELECT column(s), ISNULL(column_name, value_to_replace)
FROM table_name;
UCASE() (in other SQL flavors – UPPER()) – returns a string converted to the
upper case
LCASE() (in other SQL flavors – LOWER()) – returns a string converted to the
lower case
INITCAP() – returns a string converted to the title case (i.e., each word of the
string starts from a capital letter)
CONCAT() – joins two or more string values appending the second string to
the end of the first one
SUBSTR() – returns a part of a string satisfying the provided start and end
points
LENGTH() (in other SQL flavors – LEN()) – returns the length of a string,
including the blank spaces
REPLACE() – replaces all occurrences of a defined substring in a provided
string with another substring
INSTR() – returns the numeric position of a defined substring in a provided
string
LPAD() and RPAD() – return the padding of the left-side/right-side character
for right-justified/left-justified value
TRIM() – removes all the defined characters, as well as white spaces, from
the left, right, or both ends of a provided string
UNION – returns the records obtained by at least one of two queries (excluding
duplicates)
UNION ALL – returns the records obtained by at least one of two queries (including
duplicates)
INTERSECT – returns the records obtained by both queries
EXCEPT (called MINUS in MySQL and Oracle) – returns only the records obtained by
the first query but not the second one
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.
36. What are the syntax and use of the COALESCE function?
37. What is the difference between the RANK() and DENSE_RANK() functions?
The RANK() function in the result set defines the rank of each row within your
ordered partition. If both rows have the same rank, the next number in the
ranking will be the previous rank plus a number of duplicates . If we have
three records at rank 4, for example, the next level indicated is 7.
The RANK() function in the result set defines the rank of each row within your
ordered partition. If both rows have the same rank, the next number in the
ranking will be the previous rank plus a number of duplicates. If we have three
records at rank 4, for example, the next level indicated is 7.
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.
The phase that identifies a plan for evaluation query which has the least
estimated cost is known as query optimization.
44. What is the difference between cross join and natural join?
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.