Sei sulla pagina 1di 3

SQL

SQL doesn't have loop or Conditional statement.


A query result displays all rows including the duplicate rows. To eliminate
duplicate rows in the result, the DISTINCT keyword is used in the SELECT
clause.
the LIKE condition operator is used to select rows that match a character
pattern. This is also called wildcard search.
The default sorting order is ascending. It can be changed using the DESC
keyword, after the column name in the ORDER BY clause.
The NVL function converts a NULL value to an actual value.
The COALESCE function has the expression COALESCE(exp1, exp2, .
expn)
It returns the first non-null expression given in the parameter list.
There is a built in function in SQL called GetDate() which is used to return
current timestamp.
What is "TRIGGER" in SQL?
Trigger allows you to execute a batch of SQL code when an insert, update
or delete command is executed against a specific table.
Actually triggers are special type of stored procedures that are defined to
execute automatically in place or after data modifications.
What is the difference between clustered and non-clustered index in SQL?
There are mainly two type of indexes in SQL, Clustered index and nonclustered index. The differences between these two indexes is very
important from SQL performance perspective.
1) One table can have only one clustered index but it can have many nonclustered index. (approximately 250).
2) clustered index determines how data is stored physically in table.
Actually clustered index stores data in cluster, related data is stored
together so it makes simple to retrieve data.
3) reading from a clustered index is much faster than reading from nonclustered index from the same table.

4) clustered index sort and store data rows in the table or view based on
their key value, while non cluster have a structure separate from the data
row.

What is the difference between having and where clause?


Ans: HAVING is used to specify a condition for a group or an aggregate
function used in select statement. The WHERE clause selects before
grouping. The HAVING clause selects rows after grouping. Unlike HAVING
clause, the WHERE clause cannot contain aggregate functions.

What is a Trigger?
Ans: A Trigger is a code that associated with insert, update or delete
operations. The code is executed automatically whenever the associated
query is executed on a table. Triggers can be useful to maintain integrity
in database.
What is a stored procedure?
Ans: A stored procedure is like a function that contains a set of operations
compiled together. It contains a set of operations that are commonly used
in an application to do some common database tasks.
What is the difference between Trigger and Stored Procedure?
Ans: Unlike Stored Procedures, Triggers cannot be called directly. They can
only be associated with queries.

What is a transaction? What are ACID properties?


Ans: A Database Transaction is a set of database operations that must be
treated as whole, means either all operations are executed or none of
them.
An example can be bank transaction from one account to another
account. Either both debit and credit operations must be executed or none
of them.
ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties
that guarantee that database transactions are processed reliably.

What are indexes?

Ans: A database index is a data structure that improves the speed of data
retrieval operations on a database table at the cost of additional writes
and the use of more storage space to maintain the extra copy of data.
Data can be stored only in one order on disk. To support faster access
according to different values, faster search like binary search for different
values is desired, For this purpose, indexes are created on tables. These
indexes need extra space on disk, but they allow faster search according
to different frequently searched values.

ACID:
Atomicity: Atomicity requires that each transaction be "all or nothing": if
one part of the transaction fails, then the entire transaction fails, and the
database state is left unchanged. An atomic system must guarantee
atomicity in each and every situation, including power failures, errors, and
crashes.

A data dictionary, or metadata repository, as defined in the IBM Dictionary


of Computing, is a "centralized repository of information about data such
as meaning, relationships to other data, origin, usage, and format." The
term can have one of several closely related meanings pertaining to
databases and database management systems (DBMS):
A document describing a database or collection of databases
An integral component of a DBMS that is required to determine its
structure
A piece of middleware that extends or supplants the native data dictionary
of a DBMS

Potrebbero piacerti anche