Q26. Have you heard about the merge keyword in SQL?
Q27. You know what are transactions in SQL?
Q28. How to get data belong to TableA and TableB but not their command records ie get records from both table which is not common.
Q29. What are indexes in database?
Q30.There are 1000 records in a table. employee id, fname, lname, you have to get the last 5 entries from that table.
=======================================================================
Q26. Have you heard about the merge keyword in SQL?
Answer:
if there is a Source table and a Target table that are to be merged, then with the help of MERGE statement, all the three operations (INSERT, UPDATE, DELETE) can be performed at once.
=======================================================================
Q27. You know what are transactions in SQL?
Answer:
A transaction is a logical unit of work that contains one or more SQL statements.
Transactions have the following four standard properties, usually referred to by the acronym ACID.
- Atomicity − ensures that all operations within the work unit are completed successfully. Otherwise, the transaction is aborted at the point of failure and all the previous operations are rolled back to their former state.
- Consistency − ensures that the database properly changes states upon a successfully committed transaction.
- Isolation − enables transactions to operate independently of and transparent to each other.
- Durability − ensures that the result or effect of a committed transaction persists in case of a system failure.
The following commands are used to control transactions.
- COMMIT − to save the changes.
- ROLLBACK − to roll back the changes.
- SAVEPOINT − creates points within the groups of transactions in which to ROLLBACK.
- SET TRANSACTION − Places a name on a transaction.
=======================================================================
Q28. How to get data belong to TableA and TableB but not their command records ie get records from both table which is not common.
Answer:
select * from TableA as A
FULL JOIN from TableB as B on A.value == B.value
where A.value IS NULL or B.value IS NULL;
=======================================================================
Q30.There are 1000 records in a table. employee id, fname, lname, you have to get the last 5 entries from that table.
Answer:
select top 5 * from Employees order by EmployeeID desc
=======================================================================