Professional Documents
Culture Documents
Generic Questions For A DBA
Generic Questions For A DBA
3. What other parts of your organization do you interact with and how?
4. Do you consider yourself a development DBA or a production DBA and why?
Looking for Core DBA Questions with practical exmaples read here
Unix Scheduling?
Ans:
crontab -e
* * * * 9.30,22.30 /opt/oracle/bin/scriptname.sh
4> how do you clear inodes usage when file system is full
ANS: go to file location and clean up files, inodes usage is basically the more files
in the filesystem than the descriptors has
ls -ltr
or
ls -lt | sort
ls | cut -d
10. How can i remove all lines in a file having string named 'suresh'
sed -i s/'suresh'//g filename
11. How can remove all lines except string anmes suresh
sed -i s/'suresh'//d! filename
12. How do you check lenght of a file
# sed –n 'n p' file.txt | wc –c
13.Can you tell me the various stages of a Linux process, it passes through?
Answer : A Linux process normally goes through four major stages in its processing
life.
To extract 2nd, 5th and 7th column of the same text file.
The ‘diff‘ command reports the changes one should make so that both the files look the
same. Whereas ‘cmp‘ command compares the two files byte-by-byte and reports the first
mismatch.
use read
CPU usage of all CPUs. “1 3″ reports for every 1 seconds a total of 3 times.
Memory usage
<span class = "pln" > sar </span><span class = "pun" > - </span><span class = "pln" >
r </span><span class = "lit" > 1 </span> <span class = "lit" > 3 Swap Usage </span>
<span class = "pln" > sar </span><span class = "pun" > - </span><span class = "pln" >
S </span><span class = "lit" > 1 </span> <span class = "lit" > 3 20. HOw do you clear
swap usage? by clearing memory intensive programs or reboot machine 22. HOw do
disable and enable network interface. by service network stop, ifdown eth0 23.
</span>
SQL Questions
1. What database you have worked with?
If yes,
then proceed
Another frequently asked SQL Interview Questions on Joins. In order to avoid data
duplication, data is stored in related tables. Join keyword is used to fetch data from
related tables. "Join" return rows when there is at least one match in both table.
Type of joins are
Right Join
Return all rows from the right table, even if there are no matches in the left table.
Outer Join
Left Join
Return all rows from the left table, even if there are no matches in the right table.
Full Join
Return rows when there is a match in one of the tables.
Self-join is query used to join a table to itself. Aliases should be used for the same
table comparison.
25. What is Cross Join?
Cross Join will return all records where each row from the first table is combined
with each row from the second table.
The views are virtual tables. Unlike tables that contain data, views simply contain
queries that dynamically retrieve data when used.
Database transaction takes database from one consistent state to another. At the end
of the transaction the system must be in the prior state if the transaction fails or
the status of the system should reflect the successful completion if the transaction
goes through.
10. What are properties of a transaction?
Expect this SQL Interview Questions as a part of an any interview, irrespective of
your experience. Properties of the transaction can be summarized as ACID Properties.
1. Atomicity
A transaction consists of many steps. When all the steps in a transaction get
completed, it will get reflected in DB or if any step fails, all the transactions are
rolled back.
2. Consistency
The database will move from one consistent state to another, if the transaction
succeeds and remain in the original state, if the transaction fails.
3. Isolation
Every transaction should operate as if it is the only transaction in the system.
4. Durability
Once a transaction has completed successfully, the updated rows/records must be
available for all other transactions on a permanent basis.
Database lock tells a transaction, if the data item in questions is currently being
used by other transactions.
1. Shared Lock
When a shared lock is applied on data item, other transactions can only read the item,
but can't write into it.
2. Exclusive Lock
When an exclusive lock is applied on data item, other transactions can't read or write
into the data item.
Database transaction takes database from one consistent state to another. At the end
of the transaction the system must be in the prior state if the transaction fails or
the status of the system should reflect the successful completion if the transaction
goes through.
10. What are properties of a transaction?
Expect this SQL Interview Questions as a part of an any interview, irrespective of
your experience. Properties of the transaction can be summarized as ACID Properties.
1. Atomicity
A transaction consists of many steps. When all the steps in a transaction get
completed, it will get reflected in DB or if any step fails, all the transactions are
rolled back.
2. Consistency
The database will move from one consistent state to another, if the transaction
succeeds and remain in the original state, if the transaction fails.
3. Isolation
Every transaction should operate as if it is the only transaction in the system.
4. Durability
Once a transaction has completed successfully, the updated rows/records must be
available for all other transactions on a permanent basis.
Database lock tells a transaction, if the data item in questions is currently being
used by other transactions.
1. Shared Lock
When a shared lock is applied on data item, other transactions can only read the item,
but can't write into it.
2. Exclusive Lock
When an exclusive lock is applied on data item, other transactions can't read or write
into the data item.
What is the difference between inner and outer join? Explain with example.
Inner Join
Inner join is the most common type of Join which is used to combine the rows from two
tables and create a result set containing only such records that are present in both
the tables based on the joining condition (predicate).
Inner join returns rows when there is at least one match in both tables
If none of the record matches between two tables, then INNER JOIN will return a NULL
set. Below is an example of INNER JOIN and the resulting set.
SQL JOIN allows us to “lookup” records on other table based on the given conditions
between two tables. For example, if we have the department ID of each employee, then
we can use this department ID of the employee table to join with the department ID of
department table to lookup department names.
UNION operation allows us to add 2 similar data sets to create resulting data set that
contains all the data from the source data sets. Union does not require any condition
for joining. For example, if you have 2 employee tables with same structure, you can
UNION them to create one result set that will contain all the employees from both of
the tables.
UNION and UNION ALL both unify for add two structurally similar data sets, but UNION
operation returns only the unique records from the resulting data set whereas UNION
ALL will return all the rows, even if one or more rows are duplicated to each other.
In the following example, I am choosing exactly the same employee from the emp table
and performing UNION and UNION ALL. Check the difference in the result.
This question, often asked in many interviews, does not make any sense to me. The
problem here is how do you define which record is first and which is second. Which
record is retrieved first from the database is not deterministic. It depends on many
uncontrollable factors such as how database works at that moment of execution etc. So
the question should really be – “how to select any 5 records from the table?” But
whatever it is, here is the solution:
In Oracle,
SELECT *
FROM EMP
WHERE ROWNUM <= 5;
Generic solution,
I believe a generic solution can be devised for this problem if and only if there
exists at least one distinct column in the table.
For example, in our EMP table ID is distinct. We can use that distinct column in the
below way to come up with a generic solution of this question that does not require
database specific functions such as ROWNUM, TOP etc.
SELECT name
FROM EMPLOYEE o
WHERE (SELECT count(*) FROM EMPLOYEE i WHERE i.name < o.name) < 5