Академический Документы
Профессиональный Документы
Культура Документы
Question: When we give SELECT * FROM EMP; How does oracle respond:
Answer: When u give SELECT * FROM EMP;
the server check all the data in the EMP file and it displays the data of the EM
P file
Question: There are 2 tables, Employee and Department. There are few records in
employee table, for which, the department is not assigned. The output of the que
ry should contain all th employees names and their corresponding departments, if
the department is assigned otherwise employee names and null value in the place
department name. What is the query?
Answer: What you want to use here is called a left outer join with Employee tabl
e on the left side. A left outer join as the name says picks up all the records
from the left table and based on the joint column picks the matching records fro
m the right table and in case there are no matching records in the right table,
it shows null for the selected columns of the right table. E.g. in this query wh
ich uses the key-word LEFT OUTER JOIN. Syntax though varies across databases. In
DB2/UDB it uses the key word LEFT OUTER JOIN, in case of Oracle the connector i
s Employee_table.Dept_id *= Dept_table.Dept_id
SQL Server/Sybase :
Employee_table.Dept_id(+) = Dept_table.Dept_id
Question: on index
why u need indexing? Where that is stored
and what u mean by schema object?
For what purpose we are using view
Answer: We can?t create an Index on Index. Index is stored in user_index table.
Every object that has been created on Schema is Schema Object like Table, View e
tc. If we want to share the particular data to various users we have to use the
virtual table for the Base table...So that is a view.
Question: Which command displays the SQL command in the SQL buffer, and then exe
cutes it
Answer: You set the LIST or L command to get the recent one from SQL Buffer
Question: Which system table contains information on constraints on all the tabl
es created?
Answer: USER_CONSTRAINTS.
Question: How do I write a program which will run a SQL query and mail the resul
ts to a group?
Answer: Use DBMS_JOB for scheduling a program job and DBMS_MAIL to send the resu
lts through email.
Question: There is an Eno. & gender in a table. Eno. has primary key and gender
has a check constraints for the values 'M' and 'F'.
While inserting the data into the table M was misspelled as F and F as M.
What is the update?
Answer: update set gender=
Question: How can we backup the sql files & what is SAP?
Answer: You can backup the sql files through backup utilities or some backup com
mand in sql. SAP is ERP software for the organization to integrate the software.
Question: State true or false. !=, <>, ^= all denote the same operation.
Answer: True.
Question: State true or false. EXISTS, SOME, ANY are operators in SQL.
Answer: True.
- Another reason of using triggers can be for automatic updation of one or more
tables whenever a DML/DDL statement is executed for the table on which the trigg
er is created.
- Triggers can be used to enforce constraints. For eg: Any insert/update/ Delete
statements should not be allowed on a particular table after office hours. For
Question: How write a SQL statement to query the result set and display row as c
olumns and columns as row?
Answer: TRANSFORM Count (Roll_no) AS Count of Roll_no
SELECT Academic_Status
FROM tbl_enr_status
GROUP BY Academic_Status
PIVOT Curnt_status;
Question: How to write a sql statement to find the first occurrence of a non zer
o value?
Answer: There is a slight chance the column "a" has a value of 0 which is not nu
ll. In that case, you?ll loose the information. There is another way of searchin
g the first not null value of a column:
select column_name from table_name where column_name is not null and rownum<2;
Question: What is normalazation, types with e.g.\'s. _ with queries of all types
Answer: There are 5 normal forms. It is necessary for any database to be in the
third normal form to maintain referential integrity and non-redundancy.
First Normal Form: Every field of a table (row, col) must contain an atomic valu
e
Second Normal Form: All columns of a table must depend entirely on the primary k
ey column.
Third Normal Form: All columns of a table must depend on all columns of a compos
ite primary key.
Fourth Normal Form: A table must not contain two or more independent multi-value
d facts. This normal form is often avoided for maintenance reasons.
Fifth Normal Form: is about symmetric dependencies.
Each normal form assumes that the table is already in the earlier normal form.
Question: What is the advantage of specifying WITH GRANT OPTION in the GRANT com
mand?
Answer: The privilege receiver can further grant the privileges he/she has obtai
ned from the owner to any other user.
Question: What is the main difference between the IN and EXISTS clause in sub qu
eries??
Answer: The main difference between the IN and EXISTS predicate in sub query is
the way in which the query gets executed.
IN -- The inner query is executed first and the list of values obtained as its r
esult is used by the outer query. The inner query is executed for only once.
EXISTS -- The first row from the outer query is selected, then the inner query i
s executed and, the outer query output uses this result for checking. This proce
ss of inner query execution repeats as many no .of times as there are outer quer
y rows. That is, if there are ten rows that can result from outer query, the inn
er query is executed that many no. of times.
Question: How to find out the 10th highest salary in SQL query?
Question: What is the difference between Single row sub-Query and Scalar Sub-Que
ry?
Answer: SINGLE ROW SUBQUERY RETURNS A VALUE WHICH IS USED BY WHERE CLAUSE, WHERE
AS SCALAR SUBQUERY IS A SELECT STATEMENT USED IN COLUMN LIST CAN BE THOUGHT OF A
S AN INLINE FUNCTION IN SELECT COLUMN LIST.
It gives the added value of sal and comm for each employee in the emp table.
Question: I have a table with duplicate names in it. Write me a query which retu
rns only duplicate rows with number of times they are repeated.
Answer: SELECT COL1 FROM TAB1
WHERE COL1 IN
(SELECT MAX (COL1) FROM TAB1
GROUP BY COL1
HAVING COUNT (COL1) > 1)
Question: How to find out the database name from SQL*PLUS command prompt?
Answer: Select * from global_name;
This will give the data base name which u r currently connected to.....
group by (empid)
Question: What is the value of comm and sal after executing the following query
if the initial value of ?sal? is 10000