selvaraj v


{ City } chennai
< Country > india
* Profession * programmer
User No # 37024
Total Questions Posted # 1
Total Answers Posted # 30

Total Answers Posted for My Questions # 1
Total Views for My Questions # 9068

Users Marked my Answers as Correct # 251
Users Marked my Answers as Wrong # 90
Questions / { selvaraj v }
Questions Answers Category Views Company eMail

What are the new features in Oracle 10g. Compared to Oracle 9i?

Polaris,

1 SQL PLSQL 9068




Answers / { selvaraj v }

Question { 24957 }

The Difference between 'Count' and 'Count(*)'


Answer

In SQL Server 2000,
Query:
------
select count from employees
Answer:
------
invalid column name 'count'


In SQL Server 2000,
Query:
------
select count(*) from employees

Answer:
-------
No column name
----------------
1. 20

Is This Answer Correct ?    9 Yes 0 No

Question { 8890 }

What is the difference between Userdefined function and
stored procedure? Explain and give the example also


Answer

1.A stored procedure is a precompiled collection of
Transact-SQL statements stored under a name and processed
as a unit that you can call from within another Transact-
SQL statement or from the client applications.
2.Stored procedure performs an action.
3.A collection of SQL statements often combined with
Control-of-flow statements.

1.User Defined Functions are compact pieces of Transact SQL
code, which can accept parameters, and return either a
value, or a table. They are saved as individual work units,
and are created using standard SQL commands. Data
transformation and reference value retrieval are common
uses for functions.

Is This Answer Correct ?    8 Yes 0 No


Question { Microsoft, 16813 }

How do you get all records from 2 tables. Which join do you use?


Answer

Use Full Outer Join in Oracle 10g :

SELECT p.part_id,s.supplier_name FROM part p
FULL OUTER JOIN
supplier s ON p.supplier_idv = s.supplier_id;

Is This Answer Correct ?    3 Yes 1 No

Question { CTS, 20665 }

State the difference between implict and explict cursor's?


Answer

Implicit Curosr : When a query return s Single Row Value
then Implicit Cursor is used.
It's return Only One Row. Curosr Name is assigned
Implicitly.

Implicit Cursor used for all SQL Stmts, that,
DECLARE,OPEN,FETCH,CLOSE.

It's defined by the Oracle Server wherenever the Opertions
Single Row.

Implicit Curosrs Automatically provides by Oracle which
performs DML Statements. Qureies return only one row.

We are able to handle NO_DATA_FOUND Exception in implicit
Cursor.

Explicit Curosr :

A subquery returns more than one row Explicit Curosr is
Created.

The rows returned by the query is called Active Set. It's
return multiple rows.

Curosr is assigned Explicitly. It's used to process
Multirow SELECT Statements.

Retrieving multiple rows the Programmer declare cursors
Explicitly.

Explicit Cursors defined by the User. Queries return more
than rows.

We are Not able to handle NO_DATA_FOUND Exception.

Is This Answer Correct ?    7 Yes 2 No

Question { Aricent, 43815 }

How to retrieve Duplicate Rows only in a Table?
Suppose if a Table Name is "Education". It consists of
multiple columns. Then if we insert rows into this table
with duplicate records then how can we retrieve only
duplicate records from that table?


Answer

In Oracle 10g :
-----------------

SQL> SELECT * FROM emp;

EMPNO ENAME JOB MGR HIREDATE
SAL COMM DEPTNO
---------- ---------- --------- ---------- ---------
---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80
7500 20
7499 ALLEN SALESMAN 7698 17-DEC-80
1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81
1250 500 30
7566 JONES MANAGER 7839 02-APR-81
2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81
1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81
2850 30
7782 CLARK MANAGER 7839 09-JUN-81
2450 10
7788 SCOTT ANALYST 7566 19-APR-87
3000 20
7839 KING PRESIDENT 17-NOV-81
5000 10
7844 TURNER SALESMAN 7698 08-SEP-81
1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87
1100 20

7900 JAMES CLERK 7698 03-DEC-81
950 30
7902 FORD ANALYST 7566 03-DEC-81
3000 20
7934 MILLER CLERK 7782 23-JAN-82
1300 10
1 SELVA S/W ENG 7521 18-DEC-09
15000 1000 10
7521 WARD SALESMAN 7698 22-FEB-81
1250 500 30

16 rows selected.

The emp table contains DUPLICATE empno in this table. that's
2 empno's same. We find that empno's, Using the below query :

SQL> SELECT * FROM EMP
2 WHERE ROWID IN(SELECT MAX(ROWID) FROM EMP
3 GROUP BY EMPNO,ENAME,MGR,SAL,DEPTNO
4 HAVING COUNT(*)>1);

EMPNO ENAME JOB MGR HIREDATE
SAL COMM DEPTNO
---------- ---------- --------- ---------- ---------
---------- ---------- ----------
7521 WARD SALESMAN 7698 22-FEB-81
1250 500 30

In this emp table contains empno 7251 is 2 times.

Anyone Check this query. I'm expecting user comments...

Is This Answer Correct ?    0 Yes 0 No

Question { 49116 }

How do we get current date in SQL Server 2000, Oracle, MS
Access?


Answer

In Access 'Select date()'
In Oracle 9i 'Select Sysdate from dual;'
In SQL Server 2000 'Select Getdate()'

Is This Answer Correct ?    33 Yes 7 No

Question { eicc, 14194 }

what command is used to create a table by copying the
structure of another table including constraints ?


Answer

To Use same database :
======================

CREATE TABLE NEW_TBLNAME AS SELECT * FROM OLD_TBLNAME WHERE
1=2;


EXAMPLE :
---------
CREATE Emp_tbl2 AS SELECT * FROM Employee_Tbl1 WHERE 1=2;

Table creation From One USER To Another USER :
======================================================

COPY FROM coeot1a2/coeot1a2@coeau TO scott/tiger@server1
CREATE s11 USING SELECT * FROM major_List;

coeot1a2 ----> USER NAME
coeot1a2 ----> PASSWORD
coeau -------> SERVER NAME
scott -------> Another USER NAME
tiger -------> Another User PASSWORD
server1 -----> Another SERVER NAME

Is This Answer Correct ?    1 Yes 6 No

Question { Hewitt, 128222 }

find out the third highest salary?


Answer

In ORACLE 10g,

SELECT * FROM employee x WHERE 3 = (SELECT COUNT(DISTINCT
salary)
FROM employee y WHERE x.salary <= y.salary);

Is This Answer Correct ?    16 Yes 5 No

Question { Hewitt, 128222 }

find out the third highest salary?


Answer

In Oracle 9i:
-------------

SQL> SELECT MAX(salary) FROM emp WHERE LEVEL=&no CONNECT BY
PRIOR Salary>salary;


Enter value for no: 3

old 1: SELECT MAX(SALARY) FROM EMP WHERE LEVEL=&no
CONNECT BY PRIOR SALARY>SALARY
new 1: SELECT MAX(SALARY) FROM EMP WHERE LEVEL=3 CONNECT
BY PRIOR SALARY>SALARY

MAX(SALARY)
-----------
500000

SQL>

Is This Answer Correct ?    8 Yes 5 No

Question { 10627 }

what is curser.


Answer

SQL SERVER 2000,

Cursor is a database object used by applications to
manipulate data in a set on a row-by-row basis.

Cursor helps to update, add, select, remove on a row by row
basis on a table.

A cursor is a mechanism by which you can assign a name to
a "select statement" and manipulate the information within
that SQL statement.

We've categorized cursors into the following topics:

1.Declare a Cursor
2.OPEN Statement
3.FETCH Statement
4.CLOSE Statement
5.Cursor Attributes (%FOUND, %NOTFOUND, etc)
6.SELECT FOR UPDATE Statement
7.WHERE CURRENT OF Statement

Is This Answer Correct ?    1 Yes 0 No

Question { IBM, 24999 }

can anybody tell us, how to select 2nd max salary from
table.
my id is ashish.akk@gmail.com


Answer

In SQL Server 2000 Query:
-------------------------

select max(salary) from Employee where salary not in(select
max(salary) from employee)

This Query only selects the 2'nd Higehest Salary in that
table. So, you will try...

Is This Answer Correct ?    1 Yes 0 No

Question { 9071 }

Ho to insert no. of records at a time..i mean i want to
insert 100 records at a time into a table


Answer

In oracle 10g :
---------------->

Step 1 : SQL> CREATE TABLE identity( ID NUMBER);

Step2 : Write a Simple Procedure for to insert values into
table.

DECLARE
i NUMBER;
BEGIN
FOR i IN 1..100 LOOP
INSERT INTO identity VALUES(i);
END LOOP;
END;
/
PL/SQL procedure successfully completed.

Step 3 : SELECT COUNT(*) FROM identity;

COUNT(*)
----------
100


Please check it. Works fine.



PL/SQL procedure successfully completed.

Is This Answer Correct ?    0 Yes 0 No

Question { 8025 }

Alternative way to DetDate() function?


Answer

First you Clearly Learn.It's GetDATE() function, Not DetDate
() function.

In SQL Server 2000 Query :
--------------------------

Select GetDate()

Output:
------
2008-01-22 17:37:20.280

Alternate to GetDate() function:
--------------------------------

Select GetUTCDate()

Output:
-------
2008-01-22 17:37:20.280

GetUTCDATE() means Greenwhich Mean Time of Current Date
Time.

Is This Answer Correct ?    1 Yes 1 No

Question { IBM, 33873 }

write the query for taking database backup in sql


Answer

SQL Server 2000 BackUp Database,
Query:
------
backup database selvaa to disk = 'c:\selvaa.bak'

Answer:
-------
Processed 160 pages for database 'selvaa',
file 'selvaa_Data' on file 1.
Processed 1 pages for database 'selvaa', file 'selvaa_Log'
on file 1.
BACKUP DATABASE successfully processed 161 pages in 0.151
seconds (8.687 MB/sec).

Is This Answer Correct ?    44 Yes 20 No

Question { Infosys, 21652 }

In performance wise distinct is good or group by is good?
eg:select name from emp group by name;
select distinct name from emp;


Answer

In SQL Server 2000:
-------------------
A DISTINCT and GROUP BY usually generate the same query
plan, so performance should be the same across both query
constructs. GROUP BY should be used to apply aggregate
operators to each group. If all you need is to remove
duplicates then use DISTINCT. If you are using sub-queries
execution plan for that query varies so in that case you
need to check the execution plan before making decision of
which is faster.

Example of DISTINCT:
--------------------
Query:

select DISTINCT Book_Title,COUNT(*) from bookdetails

Answer:

Server: Msg 8118, Level 16, State 1, Line 1
Column 'bookdetails.Book_Title' is invalid in the select
list because it is not contained in an aggregate function
and there is no GROUP BY clause.

Example of Group By:
--------------------
Query:

select Book_Title,COUNT(*) from bookdetails group by
Book_Title

Answer:

ASP 1
C 1
C++ 1
Oracle 1
SQL Server 1
VB.Net 3
Visual Bsic 1

In this Answer, the VB.NET is Duplicate, it having this
table in 3 times.

Is This Answer Correct ?    5 Yes 3 No

 [1]   2    Next