Saturday, 4 February 2023

DB interview question 2

1. How would you determine the time zone under which a database was operating?

    SELECT dbtimezone FROM DUAL; 

2. Explain the use of setting GLOBAL_NAMES equal to TRUE.

    It ensure the use of consistent naming conventions for databases and links in a networked environment. 

3. What command would you use to encrypt a PL/SQL application?

    WRAP 

4. Explain the difference between a FUNCTION, PROCEDURE and PACKAGE.

    They are all named PL/SQL blocks. 
    Function must return a value. Can be called inside a query. 
    Procedure may or may not return value. 
    Package is the collection of functions, procedures, variables which can be logically grouped together. 

5. Explain the use of table functions.

6. Name three advisory statistics you can collect.

7. Where in the Oracle directory tree structure are audit traces placed?

8. Explain materialized views and how they are used.

9. When a user process fails, what background process cleans up after it?

    PMON 

10. What background process refreshes materialized views?

    Job Queue Process (CJQ) 

11. How would you determine what sessions are connected and what resources they are waiting for?

    v$session,v$session_wait 

12. Describe what redo logs are.

13. How would you force a log switch?

    alter system switch logfile; 

14. Give two methods you could use to determine what DDL changes have been made.

15. What does coalescing a tablespace do?

    Coalesce simply takes contigous free extents and makes them into a single bigger free extent. 

16. What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace?

    TEMP tablespace gets cleared once the transaction is done where as PERMANENT tablespace retails the data. 

17. Name a tablespace automatically created when you create a database.

    SYSTEM 

18. When creating a user, what permissions must you grant to allow them to connect to the database?

    Grant create session to username; 

19. How do you add a data file to a tablespace?

    alter tablespace USERS add datafile '/ora01/oradata/users02.dbf' size 50M; 

20. How do you resize a data file?

    alter database datafile '/ora01/oradata/users02.dbf' resize 100M; 

21. What view would you use to look at the size of a data file?

    dba_data_files 

22. What view would you use to determine free space in a tablespace?

    dba_free_space 

23. How would you determine who has added a row to a table?

    By implementing an INSERT trigger for logging details during each INSERT operation on the table 

24. How can you rebuild an index?

    ALTER INDEX index_name REBUILD; 

25. Explain what partitioning is and what its benefit is.

    A table partition is also a table segment, and by using partitioning technique we can enhance performance of table access. 

26. You have just compiled a PL/SQL package but got errors, how would you view the errors?

    show errors 

27. How can you gather statistics on a table?

    exec dbms_stats.gather_table_stats 
    Also, remember to analyze all associated indexes on that table using dbms_stats.gather_index_stats 

28. How can you enable a trace for a session?

    alter session set sql_trace='TRUE'; 

29. What is the difference between the SQL*Loader and IMPORT utilities? 

30.Difference between DBMS_STATS and ANALYZE

   The Advantage of DBMS_STATS is:
-easier to automate
-can analyze external tables.
-can gather system statistics(from 9i onwards)
-Analyze cannot process virtual columns (reference: https://groups.google.com/forum/#!topic/comp.databases.oracle.server/6R-J5tiQyfM)
-DBMS_STATS gather statistics only for cost-based optimization,it doesn't gather other table statistics
-e.g:table statistics gahered by DBMS_STATS include the no.of rows, no.of blocks currently containing the data and avg. row length but not the no.of chained rows, avarage free space or no. of unused blocks.


-ANALYZE calculates global statistics for partitioned tables and indexes instead of gathering them directly. This can lead to inaccuracies for some statistics,
such as the number of distinct values. DBMS_Stats won't do that.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home