What are cursors and what are the situations you will use them

SQL statements are good for set at a time operation. So it is good at handling set of data. But there are scenarios where we want to update row depending on certain criteria. we will loop through all rows and update data accordingly. There’s where cursors come in to picture. Cursors in database management systems … Read more

What’s the difference between “UNION” and “UNION ALL

UNION SQL syntax is used to select information from two tables. But it selects only distinct records from both the table. , while UNION ALL selects all records from both the tables. The main difference between “UNION” and “UNION ALL” in database management systems (DBMS) lies in how they handle duplicate rows. UNION: This operator … Read more

What’s the difference between DELETE and TRUNCATE

Following are difference between them: DELETE TABLE syntax logs the deletes thus making the delete operations low. TRUNCATE table does not log any information but it logs information about deallocation of data page of the table. So TRUNCATE table is faster as compared to delete table. DELETE table can have criteria while TRUNCATE can not. … Read more

What is a self-join

If we want to join two instances of the same table we can use self-join. A self-join in a database management system (DBMS) is when a table is joined with itself. This can be useful when you want to compare rows within the same table. For example, in a table representing employees, you might use … Read more

What is the default “-SORT” order for a SQL

ASCENDING In SQL, there’s no default “-SORT” order. Sorting in SQL is explicitly specified using the ORDER BY clause. If you don’t specify an ORDER BY clause, the result set’s order is not guaranteed. However, some database management systems might return results in the order they were inserted or some other internal ordering, but this … Read more