Tuesday, December 14, 2010

DBMS Practical Program - 1 - SINGLE LINE FUNCTION

SQL> cl scr;


SQL> SELECT ABS(-87) "Absolute" FROM DUAL;


SQL> SELECT ACOS(.3)"Arc_Cosine" FROM DUAL;



SQL> select ceil(3.456) from dual;




SQL> select cos(80) from dual;


SQL> select sin(70) from dual;


SQL> select tan(60) from dual;


SQL> select power(25,2) from dual;


SQL> select sqrt(144) from dual;




SQL> select log(50,2) from dual;


SQL> select sign(-100) from dual;


SQL> select floor(25.7) from dual;




SQL> select mod(3,2) from dual;




SQL> select trunc(14.236,2) from dual;


SQL> select round(14.236,2) from dual;




SQL> select sysdate from dual;




SQL> select add_months(sysdate,2) from dual;




SQL> select trunc(sysdate,'month') from dual;




SQL> select months_between('01-jan-2010','01-jun-2010')from dual;



SQL> select next_day('12-FEB-2010',3)from dual;



SQL> select last_day('24-MAY-1990')from dual;




SQL> select to_char(sysdate,'mm-dd-yy') from dual;



SQL> select to_date('13-feb-90') from dual;




SQL> select to_number('3321',9999) from dual;





SQL> select initcap('indu') from dual;


SQL> select length('indu') from dual;




SQL> select upper('ksr college of engineering') from dual;



SQL> select lower('CRICKET') from dual;





SQL> select replace('elakkiya','kk','33') from dual;


SQL> select translate('elakkiya','ka','12') from dual;


SQL> select lpad('elakkiya','15','*') from dual;




SQL> select rpad('elakkiya','15','*') from dual;


SQL> select ltrim(' Ranjitha') from dual;



SQL> select rtrim('Ranjitha ') from dual;




SQL> select substr('Ranjitha',3,5) from dual;


SQL> create table pra1(Rno number(3),Name varchar2(15),Mark1 number(3),Mark2 number(3),Mark3 number(3));



SQL> insert into pra1 values(&rno,'&name',&m1,&m2,&m3);


SQL> /



SQL> select * from pra1;


SQL> select avg(mark1) from pra1;


SQL> select sum(mark1) from pra1;




SQL> select count(mark1) from pra1;


SQL> select max(mark2) from pra1;


SQL> select min(mark2) from pra1;


SQL> select mark1+mark2+mark3 "total" from pra1;


SQL> set linesize 140


SQL> select rno, name, mark1, mark2, mark3, mark1+mark2+mark3 "Total", (mark1+mark2+mark3)/3 "Average" from pra1;


SQL> spool off

The above script is worked with Oracle 10g Express Edition on Windows XP.


No comments:

Post a Comment