Queries


1.select initcap('sample1text@for4demonstration#purpose')  test from dual;
OUTPUT:

TEST
-------------------------------------
Sample1text@For4demonstration#Purpose

2: Write an query to find the odd and even records of the table.

ANS:
select * from emp where  (rowid,1) in(select rowid,mod(rownum,2) from emp); (ODD)
select * from emp where  (rowid,0) in(select rowid,mod(rownum,2) from emp); (EVEN)
3 . write a query to identify the latest patching activity done in DB.
ANS:
SELECT * FROM registry$history; 

4. Show installed database components

ANS:
COL comp_name FOR a44 HEA 'COMPONENT' 
COL version FOR a17 HEA 'VERSION' 
COL status FOR a17 HEA 'STATUS' 

SELECT comp_name, version, status FROM dba_registry

5.

SELECT XMLElement("Emp", 
                  XMLAttributes(e.ename as "Name"),
                  XMLForest(e.hiredate, d.dname AS "department"))
AS "RESULT"
FROM emp e ,dept d  WHERE e.deptno=d.deptno;

6. Add 30 seconds to system date

Ans : select to_char(sysdate,'dd/mm/yyyy hh:mi:ss'),to_char (SYSDATE + NUMTODSINTERVAL(30,'SECOND'),'dd/mm/yyyy hh:mi:ss') from dual;

Note :One of the string constants: 'DAY', 'HOUR', 'MINUTE', or 'SECOND'.

1 comment:

  1. please write a query for finding the missing rows from database

    ReplyDelete