Save
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

DBA Interview

DBA Interview Questions

QuestionAnswer
Which command displays the SQL command in the SQL buffer, and then executes it? RUN
How can you call a PL/SQL procedure from SQL? By use of the EXECUTE (short form EXEC) command.
Which is the subset of SQL commands used to manipulate Oracle Database structures? Data Definition Language (DDL)
Write a query to select the second highest salary from a table. SELECT max(salary) AS salary_2 FROM emp WHERE salary < (SELECT max(salary) AS salary_1 FROM emp)
Write a query to select the 5th highest salary from a table. SELECT min(salary) AS high5 FROM employee WHERE salary IN(SELECT DISTINCT TOP 5 salary FROM employee ORDER BY salary DESC)
How to find duplicate records with the number they are duplicated? SELECT Id, count (*) as num_records from table group by id having count (*) > 1
What command is used to get back the privileges offered by the GRANT command? REVOKE
How do you execute a host operating system command from within SQL? By use of the exclamation point “!” (in UNIX and some other OS) or the HOST (HO) command.
What command is used to create a table by copying the structure of another table? CREATE TABLE .. AS SELECT command
What is the difference between Delete and Truncate command in SQL? Delete cmd&truncate cmd both will delete data,however truncate cmd cant be rolled back as delete can be. TRUNCATE is DDL cmd. whereas DELETE is a DML cmd.delete cmd can be used for selected records using where clause but w/truncate cmd we've to loose data
What SQLPlus command is used to format output from a select? This is best done with the COLUMN command
Can Primary key is a Foreign Key on the same table? Yes
You want to determine the location of identical rows in a table before attempting to place a unique index on the table, how can this be done? Oracle tables always ve one guaranteed unique column,rowid column.If you use a min/max function against your rowid and then select against proposed primary key you can squeeze out rowids of duplicate rows pretty quick.
What is the use of the DROP option in the ALTER TABLE command? t is used to drop constraints specified on the table.
What is a Cartesian product? A Cartesian product is the result of an unrestricted join of two or more tables. The result set of a three table Cartesian product will have x * y * z number of rows where x, y, z correspond to the number of rows in each table involved in the join
How do you prevent output from coming to the screen? The SET option TERMOUT controls output to the screen. Setting TERMOUT OFF turns off screen output. This option can be shortened to TERM
What is the use of CASCADE CONSTRAINTS? When this clause is used with the DROP command, a parent table can be dropped even when a child table exists
Which function is used to find the largest integer less than or equal to a specific value? FLOOR
What is a PRIMARY KEY? The PRIMARY KEY is the column(s) used to uniquely identify each row of a table.
What is a FOREIGN KEY? A FOREIGN KEY is one or more columns whose values are based on the PRIMARY or CANDITATE KEY values from the database.
What is a UNIQUE KEY? A UNIQUE KEY is one or more columns that must be unique for each row of the table.
What is the difference between UNIQUE and PRIMARY KEY? The UNIQUE KEY column restricts entry of duplicate values but entry of NULL value is allowed. In case of PRIMARY KEY columns entry of duplicate as well as <null> value is also restricted
Describe the difference between a procedure, function and anonymous pl/sql block. Level: Low Expected answer : Candidate should mention use of DECLARE statement, a function must return a value while a procedure doesn't have to.
What is a mutating table error and how can you get around it? Expected answer: This happens with triggers. It occurs because the trigger is trying to update a row it is currently using. The usual fix involves either use of views or temporary tables so the database is selecting from one while updating the other.
Describe the use of %ROWTYPE and %TYPE in PL/SQL %ROWTYPE allows you to associate a variable with an entire table row. The %TYPE associates a variable with a single column type.
What packages (if any) has Oracle provided for use by developers? Oracle provides the DBMS_ series of packages. There are many which developers should be aware of such as DBMS_SQL, DBMS_PIPE, DBMS_TRANSACTION, DBMS_LOCK, DBMS_ALERT, DBMS_OUTPUT, DBMS_JOB, DBMS_UTILITY, DBMS_DDL, UTL_FILE.
Describe the use of PL/SQL tables PL/SQL tables are scalar arrays that can be referenced by a binary integer. They can be used to hold values for use in later queries or calculations. In Oracle they will be able to be of the %ROWTYPE designation, or RECORD.
When is a declare statement needed ? The DECLARE statement is used in PL/SQL anonymous blocks such as with stand alone, non-stored PL/SQL procedures. It must come first in a PL/SQL stand alone file if it is used.
In what order should a open/fetch/loop set of commands in a PL/SQL block be implemented if you use the %NOTFOUND cursor variable in the exit when statement? Why? Expected answer: OPEN then FETCH then LOOP followed by the exit when. If not specified in this order will result in the final return being done twice because of the way the %NOTFOUND is handled by PL/SQL.
What are SQLCODE and SQLERRM and why are they important for PL/SQL developers? SQLCODE returns value of error number for last error encountered. SQLERRM returns actual error message for last error encountered. They can be used in exception handling to report, or, store in an error log table,error that occurred in code.
How can you find within a PL/SQL block, if a cursor is open? Expected answer: Use the %ISOPEN cursor status variable.
How can you generate debugging output from PL/SQL? Use DBMS_OUTPUT package. It is package can be used to show intermediate results from loops& status of variables as procedure is executed, however output only occurs after processing is finished, which might not be useful if processing takes a long time
What are the types of triggers? There are 12 types of triggers in PL/SQL that consist of combinations of the BEFORE, AFTER, ROW, TABLE, INSERT, UPDATE, DELETE and ALL key words: BEFORE ALL ROW INSERT AFTER ALL ROW INSERT BEFORE INSERT AFTER INSERT etc.
Give one method for transferring a table from one schema to another: There are several possible methods, export-import, CREATE TABLE... AS SELECT, or COPY.
What is the purpose of the IMPORT option IGNORE? What is it's default setting? The IMPORT IGNORE option tells import to ignore "already exists" errors. If it is not specified the tables that already exist will be skipped. If it is specified, the error is ignored and the tables data will be inserted. The default value is N.
You have a rollback segment in a version 7.2 database that has expanded beyond optimal, how can it be restored to optimal? Use the ALTER TABLESPACE ..... SHRINK command.
. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE USER command what happens? Is this bad or good? Why? The user is assigned the SYSTEM tablespace as a default and temporary tablespace. This is bad because it causes user objects and temporary segments to be placed into the SYSTEM tablespace resulting in fragmentation and improper table placement
What are some of the Oracle provided packages that DBAs should be aware of? Oracle provides no. of packages in form of DBMS_ packages owned by SYS user.packages used by DBAs include: DBMS_SHARED_POOL,DBMS_UTILITY,DBMS_SQL,DBMS_DDL,DBMS_SESSION,DBMS_OUTPUT&DBMS_SNAPSHOT. also try UTL*.SQL or CAT*.SQL series of SQL procedures
What happens if the constraint name is left out of a constraint clause? The Oracle system will use the default name of SYS_Cxxxx where xxxx is a system generated number. This is bad since it makes tracking which table the constraint belongs to or what the constraint does harder.
What happens if a tablespace clause is left off of a primary key constraint clause? This results in the index that is automatically generated being placed in then users default tablespace. Since this will usually be the same tablespace as the table is being created in, this can cause serious performance problems.
What is the proper method for disabling and re-enabling a primary key constraint? You use the ALTER TABLE command for both. However, for the enable clause you must specify the USING INDEX and TABLESPACE clause for primary keys.
What happens if a primary key constraint is disabled and then enabled without fully specifying the index clause? The index is created in users default tablespace&all sizing info. is lost.Oracle doesnt store this information as a part of constraint definition,but only as part of the index definition, when constraint was disabled index was dropped &information is gone
(On UNIX) When should more than one DB writer process be used? How many should be used? If UNIX system being used is capable of asynchronous IO then oly one is required,if system isnt capable of asynchronous IO then upto twice no. of disks used by Oracle number of DB writers should be specified by use of db_writers initialization parameter
You are using hot backup without being in archivelog mode, can you recover in the event of a failure? Why or why not? You can't use hot backup without being in archivelog mode. So no, you couldn't recover.
What causes the "snapshot too old" error? How can this be prevented or mitigated? This is caused by large or long running transactions that have either wrapped onto their own rollback space or have had another transaction write on part of their rollback space.
How can you tell if a database object is invalid? By checking the STATUS column of the DBA_, ALL_ or USER_OBJECTS views, depending upon whether you own or only have permission on the view or are using a DBA account.
A user is getting an ORA-00942 error yet you know you have granted them permission on the table, what else should you check? You need to check that the user has specified the full name of the object (SELECT empid FROM scott.emp; instead of SELECT empid FROM emp;) or has a synonym that points to the object (CREATE SYNONYM emp FOR scott.emp;)
A developer is trying to create a view and the database won?t let him. He has the "DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT grants on the tables he is using, what is the problem? You need to verify the developer has direct grants on all tables used in the view. You can't create a stored object with grants given through a role.
If you have an example table, what is the best way to get sizing data for the production table implementation? best way is analyze table&then use data provided in DBA_TABLES view to get avg row length &other pertinent data for calculation.
How can you find out how many users are currently logged into the database? How can you find their operating system id? There are several ways. One is to look at the v$session or v$process views. Another way is to check the current_logins parameter in the v$sysstat view. Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l? command,
A user selects from a sequence and gets back two values, his select is: SELECT pk_seq.nextval FROM dual; What is the problem? Somehow two values have been inserted into the dual table. This table is a single row, single column table that should only have one value in it.
How can you determine if an index needs to be dropped and rebuilt? Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near 1.0
How can variables be passed to a SQL routine? BBy use of the & symbol. For passing in variables the numbers 1-8 can be used (&1, &2,...,&8) to pass the values after the command into the SQLPLUS session.
You want to include a carriage return/linefeed in your output from a SQL script, how can you do this? The best method is to use the CHR() function (CHR(10) is a return/linefeed) and the concatenation function "||". Another method, although it is hard to document and isn?t always portable is to use the return/linefeed as a part of a quoted string.
How can you call a PL/SQL procedure from SQL? By use of the EXECUTE (short form EXEC) command.
How do you execute a host operating system command from within SQL? By use of the exclamation point "!" (in UNIX and some other OS) or the HOST (HO) command.
You want to use SQL to build SQL, what is this called and give an example This is called dynamic SQL. An example would be: set lines 90 pages 0 termout off feedback off verify off spool drop_all.sql select ?drop user ?||username||? cascade;? from dba_users where username not in ('SYS','SYSTEM');
What SQLPlus command is used to format output from a select? This is best done with the COLUMN command.
What special Oracle feature allows you to specify how the cost based system treats a SQL statement? The COST based system allows the use of HINTs to control the optimizer path selection. If they can give some example hints such as FIRST ROWS, ALL ROWS, USING INDEX, STAR, even better.
You want to determine the location of identical rows in a table before attempting to place a unique index on the table, how can this be done? Oracle tables always have one guaranteed unique column, the rowid column. If you use a min/max function against your rowid and then select against the proposed primary key you can squeeze out the rowids of the duplicate rows pretty quick.
What is a Cartesian product? A Cartesian product is the result of an unrestricted join of two or more tables. The result set of a three table Cartesian product will have x * y * z number of rows where x, y, z correspond to the number of rows in each table involved in the join.
You are joining a local and a remote table, the network manager complains about the traffic involved, how can you reduce the network traffic? Push the processing of the remote data to the remote instance by using a view to pre-select the information for the join. This will result in only the data required for the join being sent across
What is the default ordering of an ORDER BY clause in a SELECT statement? Ascending
How do you set the number of lines on a page of output? The width? The SET command in SQLPLUS is used to control the number of lines generated per page and the width of those lines, for example SET PAGESIZE 60 LINESIZE 80 will generate reports that are 60 lines long with a line width of 80 characters
How do you prevent output from coming to the screen? The SET option TERMOUT controls output to the screen. Setting TERMOUT OFF turns off screen output. This option can be shortened to TERM.
. How do you prevent Oracle from giving you informational messages during and after a SQL statement execution? The SET options FEEDBACK and VERIFY can be set to OFF.
How do you generate file output from SQL? By use of the SPOOL command
tablespace has a table with 30 extents in it. Is this bad? Why or why not. Multiple extents in and of themselves aren?t bad. However if you also have chained rows this can hurt performance.
How do you set up tablespaces during an Oracle installation? You should always attempt to use the Oracle Flexible Architecture standard or another partitioning scheme to ensure proper separation of SYSTEM, ROLLBACK, REDO LOG, DATA, TEMPORARY and INDEX segments.
You see multiple fragments in the SYSTEM tablespace, what should you check first? Ensure that users don?t have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view.
What are some indications that you need to increase the SHARED_POOL_SIZE parameter? Poor data dictionary or library cache hit ratios, getting error ORA-04031. Another indication is steadily decreasing performance with all other tuning parameters the same
What is the general guideline for sizing db_block_size and db_multi_block_read for an application that does many full table scans? : Oracle almost always reads in 64k chunks. The two should have a product equal to 64 or a multiple of 64.
What is the fastest query method for a table? Intermediate Expected answer: Fetch by rowid
Explain the use of TKPROF? What initialization parameter should be turned on to get full TKPROF output? tkprof tool is Tuning tool used to determine cpu&execution times for SQL stmts. U use it by 1st setting timed_statistics to true in initialization file &turning on tracing for either entire db via sql_trace parameter or for session using ALTER SESSION cmd
When looking at v$sysstat you see that sorts (disk) is high. Is this bad or good? If bad -How do you correct it? If you get excessive disk sorts this is bad. This indicates you need to tune the sort area parameters in the initialization files. The major sort are parameter is the SORT_AREA_SIZe parameter.
When should you increase copy latches? What parameters control copy latches? When you get excessive contention for the copy latches as shown by the "redo copy" latch hit ratio. You can increase copy latches via the initialization parameter LOG_SIMULTANEOUS_COPIES to twice the number of CPUs on your system.
Where can you get a list of all initialization parameters for your instance? How about an indication if they are default settings or have been changed? You can look in the init.ora file for an indication of manually set parameters. For all parameters, their value and whether or not the current value is the default value, look in the v$parameter
Describe hit ratio as it pertains to the database buffers. What is the difference between instantaneous and cumulative hit ratio and which should be used for tuning? The hit ratio is a measure of how many times the database was able to read a value from the buffers verses how many times it had to re-read a data value from the disks. A value greater than 80-90% is good, less could indicate problems.
Discuss row chaining, how does it happen? How can you reduce it? How do you correct it? Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won?t fit in the remaining block space.
When looking at the estat events report you see that you are getting busy buffer waits. Is this bad? How can you find what is causing it? Buffer busy waits could indicate contention in redo, rollback or data blocks. You need to check the v$waitstat view to see what areas are causing the problem.
. If you see contention for library caches how can you fix it? Increase the size of the shared pool.
. If you see statistics that deal with "undo" what are they really talking about? Expected answer: Rollback segments and associated structures.
If a tablespace has a default pctincrease of zero what will this cause (in relationship to the smon process)? SMON process won?t automatically coalesce its free space fragments.
If a tablespace shows excessive fragmentation what are some methods to defragment the tablespace? (7.1,7.2 and 7.3 only) : In Oracle 7.0 to 7.2 The use of the 'alter session set events 'immediate trace name coalesce level ts#';? command is the easiest way to defragment contiguous free space fragmentation.
How can you tell if a tablespace has excessive fragmentation? If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files, then it is fragmented.
You see the following on a status report: redo log space requests 23 redo log space wait time 0 Is this something to worry about? What if redo log space wait time is high? How can you fix this? Since the wait time is zero, no. If the wait time was high it might indicate a need for more or larger redo logs.
What can cause a high value for recursive calls? How can this be fixed? A high value for recursive calls is cause by improper cursor usage, excessive dynamic space management actions, and or excessive statement re-parses.
. If you see a pin hit ratio of less than 0.8 in the estat library cache report is this a problem? If so, how do you fix it? This indicate that the shared pool may be too small. Increase the shared pool size.
If you see the value for reloads is high in the estat library cache report is this a matter for concern? Yes, you should strive for zero reloads if possible. If you see excessive reloads then increase the size of the shared pool.
You look at the dba_rollback_segs view and see that there is a large number of shrinks and they are of relatively small size, is this a problem? How can it be fixed if it is a problem? A large number of small shrinks indicates a need to increase the size of the rollback segment extents. Ideally you should have no shrinks or a small number of large shrinks. To fix this just increase the size of the extents and adjust optimal accordingly.
Define OFA. OFA stands for Optimal Flexible Architecture. It is a method of placing directories and files in an Oracle system so that you get the maximum flexibility for future tuning and file placement.
What should be done prior to installing Oracle (for the OS and the disks)? adjust kernel parameters or OS tuning parameters in accordance with installation guide. Be sure enough contiguous disk space is available.
You have installed Oracle and you are now setting up the actual instance. You have been waiting an hour for the initialization script to finish, what should you check first to determine if there is a problem? Check to make sure that the archiver isn?t stuck. If archive logging is turned on during install a large number of logs will be created. This can fill up your archive log destination causing Oracle to stop to wait for more space.
When configuring SQLNET on the server what files must be set up? INITIALIZATION file, TNSNAMES.ORA file, SQLNET.ORA file
When configuring SQLNET on the client what files need to be set up? SQLNET.ORA, TNSNAMES.ORA
What must be installed with ODBC on the client in order for it to work with Oracle? SQLNET and PROTOCOL (for example: TCPIP adapter) layers of the transport programs.
You have just started a new instance with a large SGA on a busy existing server. Performance is terrible, what should you check for? The first thing to check with a large SGA is that it isn?t being swapped out.
What OS user should be used for the first part of an Oracle installation (on UNIX)? You must use root first.
When should the default values for Oracle initialization parameters be used as is? Never
How many control files should you have? Where should they be located? At least 2 on separate disk spindles. Be sure they say on separate disks, not just file systems.
How many redo logs should you have and how should they be configured for maximum recoverability? You should have at least three groups of two redo logs with the two logs each on a separate disk spindle (mirrored by Oracle). The redo logs should not be on raw devices on UNIX if it can be avoided.
You have a simple application with no "hot" tables (i.e. uniform IO and access requirements). How many disks should you have assuming standard layout for SYSTEM, USER, TEMP and ROLLBACK tablespaces? At least 7, see disk configuration answer above.
Describe third normal form? Something like: In third normal form all attributes in an entity are related to the primary key and only to the primary key
When should you consider denormalization? Whenever performance analysis indicates it would be beneficial to do so without compromising data integrity.
Created by: johnfaar
Popular Computers sets

 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards