GeekInterview.com
Series: Subject:

Oracle SQL FAQ

Showing Questions 1 - 20 of 211 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

How can I disable a trigger trough SQL prompt.

Asked By: Saroj Panda | Asked On: Aug 14th, 2006

Answered by: vijaya on: May 11th, 2013

Alter trigger trigger_name disable/enable all triggers.

Answered by: aytasirs on: Nov 15th, 2012

Alter trigger Disable;

Can we give unique and not null constraint to an attribute? How it is different from primary key?

Asked By: Ganesh | Asked On: Jul 21st, 2007

Answered by: aytasirs on: Apr 29th, 2013

Yes We can. If we use the combination "unique+not null" the referential integrity is not maintained and that is not the case with primary key.

Answered by: EHSAN REHMANI on: Apr 27th, 2013

There is only one primary key per table but we can use unique and not null constraints more than one column in a table. Primary key having both functionality as it can not be null but unique.

List the premium customers who is not using the service within the last one week.

Asked By: mnmlove | Asked On: Jan 15th, 2008

List the premium customers who is not using the service within the last one week.If you have these tables: 1-'premuim_user'columns: customer_id, post_paid.2-'calls'columns: called_number, customer_id, call_date, call_time_started, call_time_ended, transaction_no.

Is it possible to insert a new column between two existing columns?For ex:i have a table with two cols:rollno and dateofbirth.Suppose if I want a new column named 'name' to be included in between rollno...

Asked By: Krishnan | Asked On: Jun 30th, 2006

Answered by: Ehsan Rehmani on: Apr 23rd, 2013

No, you cant insert column between existing columns in oracle database but, you can add or insert column in a table at end of last column.

Answered by: Sushant on: Jan 3rd, 2013

Oracle doesnt allow inserting column in between two. But there are work around to do this. Simple and best one is to add the new column at the end of table. Then rename that table, renaming table will...

Avoid data duplication

Asked By: maheshk_222 | Asked On: Jan 25th, 2010

If in a table we dont use primary key or any other unique key then how to avoid duplication of data?

Answered by: Ehsan Rehmani on: Apr 23rd, 2013

Its impossible to avoid duplication without constraint the PK on Column

Answered by: Ehsan Rehmani on: Feb 1st, 2013

We must constraint the column with primary key when designing the database to avoid the duplications.

I am writing a script to update a value in an Oracle table. The script has a 'from' clause which Oracle does not like. Is there another way to write this since I am bringing data from 3 different tables.Thankssamir

Asked By: Samir | Asked On: Mar 24th, 2006

Answered by: Vijay on: Mar 20th, 2013

By using merge statement we can do it simply.

Answered by: smi on: Jul 30th, 2012

Use merge stat

Fetch alternate rows

Asked By: priaa_7 | Asked On: Apr 16th, 2010

How to fetch alternate rows from the table?

Answered by: Ram on: Feb 6th, 2013

Code
  1. SELECT * FROM EMP
  2. WHERE (ROWID,1) IN (SELECT ROWID,MOD(ROWNUM,2) FROM EMP);
  3.  
  4. OR
  5.  
  6. SELECT * FROM (SELECT EMP.*,ROWNUM K FROM EMP)
  7. WHERE MOD(k,2)=0;

Answered by: Millar on: Jul 26th, 2012

Code
  1. SELECT * FROM table_name WHERE mod(primary_key_column,2)=0 --to find even rows in a table
  2.  
  3. SELECT * FROM employees WHERE mod(employee_id,2)=0 --to find even rows in a table
  4.  
  5. SELECT * FROM employees WHERE mod(employee_id,2)=1 --to find odd rows in a table

Retrieve rows without using select clause

Asked By: viji_info | Asked On: Sep 30th, 2010

How can we retrieve some rows from the database without using select clause?

Answered by: Ehsan Rehmani on: Jan 31st, 2013

Select clause is must for retrieving data from the database. You cant retrieve data without select clause.

Answered by: Ehsan Rehmani on: Jan 1st, 2013

Impossible! Rows will not be rerieved without select keyword.

Select comm from emp;

Asked By: pankaj_gauba | Asked On: Jul 6th, 2006

The null column in the output will come in the last i.E at the end. Why?E.G comm 1200 1000 1300 1450 ---- (null) ---- (null)

Answered by: SAMADREHMANY on: Dec 25th, 2012

SEE THIS ALSO,

Code
  1. SELECT EMPNO,ENAME,JOB,COMM
  2. FROM EMP
  3. ORDER BY COMM NULLS LAST;

Answered by: Anurag Puranik on: Jul 29th, 2006

Nulls are unassigned and unavailable values.i.e. null means "no value".

So in order to obtain values the values get preference over the no values(null).

What is query analyser?

Asked By: Yogeshk | Asked On: Jul 30th, 2006

Answered by: SAMADREHMANY on: Dec 25th, 2012

g means Grid Computing..

Answered by: Sundaresan on: Aug 29th, 2006

grid computing

How to find out department wise second maximum salary.

Asked By: Srinu | Asked On: Mar 29th, 2006

Answered by: Mrinal on: Dec 14th, 2012

"sql SELECT DISTINCT d1.depno, e1.salary,e1.empid,d1.location FROM EMPLOYEE1 e1, dept d1 WHERE 2 = (SELECT count(DISTINCT e2.salary) FROM EMPLOYEE1 e2...

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

Code
  1. SELECT min(salary)
  2. FROM dept
  3. WHERE salary IN ( SELECT DISTINCT top 2 salary
  4.                         FROM dept
  5.                         ORDER BY salary DESC)

What is the difference between no data found and %notfound ?

Asked By: Kiran Bondre | Asked On: Aug 1st, 2006

Answered by: aytasirs on: Nov 15th, 2012

no data found is an exception where as %not found is a cursor attribute.

Answered by: sampra on: Mar 6th, 2012

no data found is exception where as %notfound is retrn by exception

I have two tables emp1&emp2 both having same fields if any updations made in emp1 how to reflect on emp2

Asked By: ramarao | Asked On: Oct 22nd, 2006

Answered by: aytasirs on: Nov 15th, 2012

Use DML Triggers to apply the same action to another table as well.

Answered by: sampra on: Mar 6th, 2012

write trigger

How do you know which index a table is using?

Asked By: Ganesh Babu | Asked On: Jan 9th, 2007

Answered by: aytasirs on: Nov 15th, 2012

Explain plan will tell you

Answered by: sampra on: Mar 6th, 2012

use select may be this works

How to avoid duplication in database if we are adding data from .Dat file ?

Asked By: anilkumarnani | Asked On: Sep 25th, 2007

Answered by: aytasirs on: Nov 15th, 2012

There is no option to avoid duplicates when inserting data from flatfiles using sql*loader.

The best way is load the data into staging table and write the
query to eliminate the duplicate rows.

Answered by: sampra on: Mar 6th, 2012

use PK or unique key

LEFT outer & right outer join

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

What is the use of lEFT outer & right outer join, using equi join with union we can do the outer join then why we need to go for outer join

Answered by: aytasirs on: Nov 15th, 2012

Left outer Join fetch all the records from Left side Table(Only Condition satisfied records from right side table) where as Right Outer Join fetch all the records from Right side Table(Only Condition satisfied records from Left side table).

Answered by: sampra on: Mar 6th, 2012

Using Equi Join with Union we can do the outer join then why we need to go for Outer Join -- increase the performance

Insert a record in two tables

Asked By: janardanneppali | Asked On: Apr 8th, 2008

How to insert a record in two tables with single insert statement ?

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

Answer:

Code
  1. INSERT ALL
  2.     INTO first_table VALUES(value1,value2)
  3.      INTO second_table VALUES(value1,value2)
  4.  
  5. SELECT * FROM dual;

Answered by: chandra411 on: Sep 2nd, 2008

Using merge concept, we can insert a record at a time into two tables.

Display middle record

Asked By: shameem_chandu | Asked On: Oct 20th, 2009

How to display middle record in a given table?

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

The below code selects the exact middle row from the table

Code
  1. SELECT * FROM TABLE WHERE rownum=trunc(SELECT count(*)/2 FROM TABLE)

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

The below code returns the rows from 50-74

Code
  1. TO SELECT the middle rows:
  2.         SELECT * FROM TABLE offset 50 rows fetch next 25 rows only
  3.              

SQL and PL/SQL

Asked By: jagadeesh9 | Asked On: Feb 19th, 2008

What is the difference between SQL & PL/SQL?

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

1.Sql is a declarative language.It tells only what to do. PL/Sql is a procedural language.It tells what to do and how to do. 2.Sql executes DDL and DML statements . Pl/Sql executes triggers,func...

Answered by: sampra on: Mar 6th, 2012

sql is structured query language and plsql is procedural sql. in sql we write a query to fetch the data from data base. in pl sql we write the set of sql command and execute it in one times. the benef...

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

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.