(B) Alter (C) Drop: I.Data Definition Language
(B) Alter (C) Drop: I.Data Definition Language
emp;
savepoint s2;
2. How to retrieve the data from the table using between condition?
A. select * from emp where salary between 3000 and 7000;
select * from emp where salary not between 3000 and 7000;
3. How to retrieve data from the table using relation condition?
A. select * from emp where job_id='marketing' and salary>5000;
4. How to retrieve selected row more than one from the table?
A. select * from emp where empno in(100,105,110);
select * from emp where empno not in(100,105,110);
5. How to retrieve names which is starting with 'S' from the table?
A. select * from emp where ename like 's%';
select * from emp where ename not like 's%';
6. How to retrieve upper case characters?
A. select * from emp where upper(ename) like 'A%';
7. How to retrieve lower case characters?
A. select * from emp where lower(ename) like 'a%';
8. How to retrieve names which is ending with S from the table?
A. select * from emp where ename like '%s';
select * from emp where ename not like '%s';
9. How to retrieve names which is the second letter 'S' from the table?
A. select * from emp where ename like '_s%';
select * from emp where ename not like '_s%';
10. How to retrieve null values from the table?
A. select * from emp where comm is null;
select * from emp where comm is not null;
11. How to retrieve data belonging two column conditions from the table?
A. select * from emp where job_id='marketing' or salary>5000;
ARITHEMATIC OPERATIONS
1. How to see the absolute value in the select statement?
A. select empno,ename,abs(comm-salary) from emp;
2. How to see the square root of the given number?
A. select sqrt(5) from dual;
3. How to see the power of the given number?
A. select power(4,2) from dual;
4. How to see the modulus of the given number?
A. select mod(6,3) from dual;
[Ans: 20 19 19.78]
[Ans: 19 19 19.73]
14. How to display the first five letter of the string in the table?
A. select empno,ename,substr(ename,1,5) from emp;
15. How to see the position of the char?
A. select ename,instr(ename,'a',1,1) from emp;
DATE FUNCTIONS
1. How to display the sysdate date?
A. select sysdate from dual;
2. How to see how many months happen up to now from joining?
A. select ename,job,months_between(sysdate,hire_date) from emp;
3. How to add months to the hire_date in the select statement?
A. select ename,hire_date,add_months(hire_date,6) from emp;
4. How to display the next day using hire_date?
A. select hire_date,next_day(hire_date,'Friday') from emp;
5. How to display the last day of the month?
A. select hire_date,last_day(hire_date) from emp;
TIME FUNCTIONS
1. How to see the fractional seconds with date & time of server?
A. select systimestamp from dual;
2. How to see the fractional seconds with date & time of client system?
A. select current_timestamp from dual;
3. How to see the date of client system?
A. select current_date from dual;
GENERAL FUNCTIONS
1. How to select the least value from the given values?
A. select least(12,09,4,20,6,46) from dual;
2. How to select greatest value from the given values?
A. select greatest(12,09,4,20,6,46) from dual;
3. How to select minimum & maximum salary from the table?
A. select min(salary),max(salary) from emp;
SPECIAL OPERATORS
1. How to converts a null value in to actual value?
A. select empno,ename,nvl(comm,10) from emp;
select count(nvl(comm,0)) from emp;
exp1 is null it shows sal, if two exps are null it shows the value as 10]
5. How to use CASE expression in the select statement?
A. select ename,salary,case job_id when 'marketing' then .10*sal when 'clerk' then .5*sal
else salary end "revised salary" from emp;
6. How to use DECODE expression in the select statement?
A. select ename,salary decode(job_id,'marketing',0.10*sal,'clerk',0.5*sal,sal) "salary" from emp;
OREDER BY CLAUSE
1. How to retrieve the data in the ascending order from the table?
A. select * from emp order by deptno;
2. How to retrieve data in the descending order from the table?
A. select * from emp order by empno desc;
GROUP FUNCTIONS
Group functions operate on sets of rows to give one result per group
1. How to select average & sum salary from the table?
A. select avg(salary),sum(salary) from emp;
2. How to select maximum & minimum salary in the table?
A. select max(salary),min(salary) from emp;
3. How to select total no.of row in the table?
A. select count(*) from emp;
select count(empno) from emp;
4. How to display the salary according to deptno?
A. select deptno,avg(salary) from emp group by deptno;
(enter)
Password : tiger
(enter)
(enter)
(file name)
(enter)
(enter)
(enter)
(enter)
(enter)
(enter)
D:\oracle\ora90\bin>exit
(enter)
(enter)
(enter)
(enter)
(enter)
Username: scott
Enter table(T) or partition(T:P)name or . If done:
D:\oracle\ora90\bin>exit
(enter)