Posts

Showing posts from January, 2022

Practice Queries

 1. How to join a table with like :  in one table we have data "CANADA" and in another table we have data "abc CANADA".  Now i want to apply a join using like clause.

Sequence

Generate Unique Sequential values     Sequence has 2 pseudocolumns     1. CURRVAL     2. NEXTVAL CURRVAL :  gives the most recently generated value NEXTVAL : gives the next available value in the sequence to generate sequence will start generating value from its MINVALUE Default MINVALUE is 1 default incremental value of sequence is +1 Same sequence can be used in multiple tables but not suggestable. One sequence for one table.

SQL Questions

1. When will ROW_NUMBER and RANK give different results? Give an example. 2. Is it possible for LEFT JOIN and FULL OUTER JOIN to produce the same results? Why or why not? 3. Why would I use DENSE_RANK instead of RANK? What about RANK instead of DENSE_RANK? 4. What happens if I GROUP BY a column that is not in the SELECT statement? Why does this happen? 5. LAG and LEAD are especially useful in what type of scenarios? 6. For dealing with NULL values, why would I choose to use IFNULL vs. CASE WHEN? 7. Do temp tables make your code cleaner and faster, one of the two, or none? Why? 8. When is a subquery a bad idea? A good idea?

Materialized View

 It is a database object. It is different from normal view. View doesn't contain any data in it whereas MV contains data in it. We create MV for remote database object in our local db.