GeekInterview.com
Series: Subject:

Oracle SQL FAQ

Showing Questions 21 - 40 of 234 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

What is the difference between drop,delete and truncate.. Can anyone tell why we require exists with example.

Asked By: Abhishek | Asked On: Sep 26th, 2006

Answered by: Nazeera Jaffar on: Sep 26th, 2012

Delete: Deletes the contents of the table.Also allows us to delete particular row(s) by condition.We can undo the delete operation and write trigger on delete action. Truncate: Delete the ...

Answered by: lakan reddy on: Sep 21st, 2012

delete:delets the records from the table by using where claus
truncate:removes all the records from the table and frees the space containing by the table
drop:drops the table and its structure

Records count

Asked By: Subashpanda | Asked On: Dec 19th, 2010

How to count number of records in a table without using count function?

Answered by: Sandipan on: Sep 6th, 2012

select sum(1) from emp;

Code
  1. SELECT sum(1) FROM emp;

Answered by: smily08 on: Aug 30th, 2012

select max(rownum) from
(select ROW_NUMBER() over (order by col_name) as rowNum from table_name)
withRowNum

A table consists of 10 employees how to find sum of 3,4,5,6 employees?

Asked By: kethineni | Asked On: Jul 24th, 2006

Answered by: smily08 on: Aug 30th, 2012

Code
  1. SELECT SUM(SALARY)
  2. FROM (SELECT ROW_NUMBER() over (ORDER BY EMPNO) AS rowNum,SALARY FROM EMP )
  3. withRowNum  
  4. WHERE rowNum IN (3, 4, 5, 6)

Answered by: smily08 on: Aug 29th, 2012

Code
  1. SELECT SUM(SALARY)
  2. FROM EMP
  3. WHERE EMPNO IN (103, 104, 105, 106)

How do I retrieve the last row of a table?

Asked By: A | Asked On: Mar 14th, 2006

Answered by: Arbind Kumar Singh on: Jul 23rd, 2012

sql query for retrieving last row particular column value depending upon its ID??? QUERY: select top 1 [column_name1],[column_name2] from [table_name] where ID=[ID_value] order by index desc here i...

Answered by: Ambarish on: Apr 19th, 2012

Select last(column_name) from Table.

Is there any function in Oracle to check whether a value is numeric or not. I have a column which contains both numeric and alphanumeric data. I want to fetch only the numeric data from that column. Can...

Asked By: anu_dw | Asked On: Sep 14th, 2006

Answered by: me on: Jul 3rd, 2012

Hello,

Using the upper/lower functions is faster than the regular expression approach.

Cheers

Answered by: hifake on: Jan 13th, 2010

REGEXP_LIKE can be used to match numbers
SELECT Fieldname1 FROM componentid WHERE REGEXP_LIKE (Fieldname1, '^[0-9]*$');

REGEXP_LIKE can be used to match alphabets only (alphanumeric and numbers ingnored)
SELECT Fieldname1 FROM componentid WHERE REGEXP_LIKE (Fieldname1, '^[a-zA-Z]*$');

Retrieve odd and even rows

Asked By: harpreet.karan | Asked On: Feb 21st, 2009

How to retrieve odd and even number of rows from a table?

Answered by: venkat on: Jun 27th, 2012

Code
  1. SELECT * FROM (SELECT rownum rn,col1,col1 FROM table_name) WHERE mod(rn,2)=0

union all

Code
  1. SELECT * FROM (SELECT rownum rn, col1,col2 FROM table_name) WHERE mod(rn,2)=1;

Answered by: Anup on: May 23rd, 2012

Code
  1. SELECT id, version, authority
  2. FROM (SELECT id, version, authority, rownum row_num FROM OBTWC_ROLE)
  3. WHERE mod(row_num,2) = 0;

Retrieve data from two tables

Asked By: sriram.bethe | Asked On: Mar 25th, 2008

How to retrieve data from two tables of different servers

Answered by: Sujaya on: Jun 8th, 2012

SELECT Ename, DeptNo, Sal, Emp.DeptNo, Dept.Dname, Dept.Loc, Dept FROM
Emp, Dept
WHERE Emp.DeptNo = Dept.DeptNo;

Answered by: sampra on: Mar 6th, 2012

you can use join

Literal meaning of SQL

Asked By: ssrao1985 | Asked On: Jan 28th, 2008

What is the literal meaning of SQL

Answered by: somasundaram on: Mar 20th, 2012

Structured Query Language

Answered by: sampra on: Mar 6th, 2012

Structerd quey language

Lock query

Asked By: lpsarathi.edu | Asked On: Mar 10th, 2009

What is use of lock query in SQL plus? Give its syntax and implementation?

Answered by: sampra on: Mar 6th, 2012

Exclusive Lock: This is placed when Insert, Update or Delete command is performed. There can be only one exclusive lock on a record at a time.

Answered by: hussasha on: Mar 17th, 2009

Locking protect table when several users are accessing the same table. Locking is a concurrency control technique in Oracle. It helps in data integrity while allowing maximum concurrency access to...

Aggregation key

Asked By: sekharnanda | Asked On: Apr 6th, 2010

What is the aggregation key?

Answered by: sampra on: Mar 6th, 2012

this is the composite key

Answered by: AnithaLetchumi on: Aug 10th, 2011

Aggregation Key is nothing but composite or concatenated key. It's the primary key having more than one column. For example different books may have identical titles, authors. In this case we can take...

SQL nullif function

Asked By: Subashpanda | Asked On: Feb 7th, 2011

What is the use of nullif function in SQL?

Answered by: sampra on: Mar 6th, 2012

In SQL, NullIf function is used to compare two expressions. There are 3 possible results for NULLIF. 1. If the values are same, NullIf returns NULL. Eg: NULLIF(Prem,Prem) returns NULL 2. If they are...

Answered by: Prem_p on: Apr 28th, 2011

In SQL, NullIf function is used to compare two expressions. There are 3 possible results for NULLIF.1. If the values are same, NullIf returns NULL. Eg: NULLIF('Prem','Prem') returns NU...

What are the advantages of views?

Asked By: Devendra Reddy Reddy | Asked On: May 8th, 2011

Answered by: sampra on: Mar 6th, 2012

1) To protect some of the columns of a table from other users.ie for security purpose.

2)To hide the complexity of a query.

3)To hide the complexity of calculations.

Answered by: vivekrajece on: May 19th, 2011

1) To protect some of the columns of a table from other users.ie for security purpose.


2)To hide the complexity of a query.

3)To hide the complexity of calculations.

Is there any other option other than desc query to describe the table

Asked By: abi | Asked On: Aug 16th, 2006

Answered by: sampra on: Mar 6th, 2012

SELECT
column_name "Name",
nullable "Null?",
concat(concat(concat(data_type,(),data_length),)) "Type"
FROM user_tab_columns
WHERE table_name=TABLE_NAME_TO_DESCRIBE;

Answered by: sunildas4U on: Aug 24th, 2006

An alternative to the DESC command is selecting directly from the data dictionary -

DESC MY_TABLE

is equivalent to

SELECT
column_name "Name",
nullable "Null?",
concat(concat(concat(data_type,'('),data_length),')') "Type"
FROM user_tab_columns
WHERE table_name='TABLE_NAME_TO_DESCRIBE';

How can we increase performance in a view?

Asked By: suneetharoy | Asked On: Aug 27th, 2007

Answered by: sampra on: Mar 6th, 2012

dont user select */in/write minimal cond

How to truncate the table with cascade option?

Asked By: vijay | Asked On: Sep 16th, 2007

I tried "truncate table cascadebut I got the error storage keyword is missing (says EIther drop storage or reuse storage) can any one help me out.

Answered by: sampra on: Mar 6th, 2012

write turnicate stmt

Answered by: vemurisasidhar on: Sep 22nd, 2007

if u want to delete a table with constraints i think u need to first disable the constraints on the table and the use
truncate table ;

alter table
disable constraint primary key cascade;

What is the basic difference in function and store procedure.Where we use function and where we need to use store procedure.Could you please explain me in brief.

Asked By: Vivek | Asked On: Apr 5th, 2006

Answered by: sampra on: Mar 6th, 2012

procedure wont retrun any value but it can return many values on condition. but function always returns a values

Answered by: shravanam on: Oct 28th, 2007

A procedure is used to perform a specific task. It can also return a value but its not mandatory.

But a function is used to perform some calculations and it is mandatory to return atleast one value.

Unique index and simple index

Asked By: newqtp | Asked On: Jan 9th, 2008

What is difference between unique index and simple index?Is it possible, two rows can have the same unique index?

Answered by: sampra on: Mar 6th, 2012

index create on Primary key or unique key is Unique index where as index created on any other element is simple index

Answered by: srinivasa.dinesh on: Jan 29th, 2008

Unique Index:If the index is for a primary or unique key then the owner, name, type, and columns cannot be modified. These properties are all derived from the key constraint. Changing the name of the ...

Describe table without desc command

Asked By: jagadeesh9 | Asked On: Mar 18th, 2008

How to desc table data without using desc command

Answered by: sampra on: Mar 6th, 2012

no ways

Answered by: saradajasti on: Mar 24th, 2008

select column_name name,data_type type
from user_tab_columns
where table_name =

Tune SQL query

Asked By: jagadeesh9 | Asked On: Mar 25th, 2008

How can you tune the query?

Answered by: sampra on: Mar 6th, 2012

1> always avoid select * from
2> do not use in operator

Answered by: Imran_Javed on: May 8th, 2008

First look at the explain plan if there is any full scan. Then add appropriate index on columns that are used in the query. Basically, always add index on foreign key and the date columns (Most of the application access tables based on dated)

Delete contents in two tables at a time

Asked By: jyothivdaru | Asked On: Apr 9th, 2008

How to delete contents in two tables at a time? When you delete contents in one table then other table contents should also be deleted.

Answered by: sampra on: Mar 6th, 2012

1> always avoid select * from
2> do not use in operator

Answered by: krishnaindia2007 on: Jun 20th, 2008

You may also use triggers for this purpose. But specifying on delete cascade while defining foreign key constraint is better option.

First | Prev | | Next | Last Page

 

 

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.